재생목록으로 엑셀 만들기: 관리자 → 퀴즈 목록 카드. 플레이리스트 가져오기와 같은 검토(서버 DB 곡, 영상 제목 정리, 스포티파이는 유튜브 뮤직 검색, 다른 사이트 재생 확인) 결과를 파일로 만들기가 그대로 읽는 엑셀로 받음 — 시트 '퀴즈'(순번·유튜브 영상 링크·제목·가수·시작(초)·하이라이트(초)·길이(초)·비고)와 '빠진 곡'(재생 막힘·없는 영상·못 찾은 곡·같은 영상, 이유와 함께; 제목 열이 없어 곡으로 읽히지 않음). 비고: DB 곡 / 제목·가수 확인 필요(영상 제목에 가수-제목 형식이 없어 채널 이름을 가수로 씀, 플레이리스트 가져오기에도 표시) / 확인 필요 / 유튜브 뮤직에서 찾음. 조회수 열은 넣지 않음(이지선다는 서버가 불러옴). 파일로 만들기·파일에서 가져오기: '시작·하이라이트가 빈 곡: 자동 / 처음부터' 선택(처음부터 = 0/0으로 적어 하이라이트부터 방에서도 처음부터), 길이(초) 열 읽기. 파일로 만들기의 자동 곡은 서버 DB에 같은 영상이 있으면 그 하이라이트(직접 위치로)와 길이를 씀 — 파일 곡은 DB와 연결하지 않아 자동이 늘 처음부터였던 것. writeXlsxSheets(여러 시트). 단위·API 테스트, e2e quiz 단계, docs 10·12

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-03 23:20:04 +09:00
parent 8a52fd3b68
commit 70edadfe36
13 changed files with 441 additions and 40 deletions

View File

@@ -82,8 +82,17 @@ export function mountQuizAdmin(app: Hono<Env>, d: QuizAdminDeps, h: { actor: (c:
if (limits.maxSongs && p.data.items.length > limits.maxSongs) return c.json({ error: `퀴즈 하나에는 곡을 ${limits.maxSongs}곡까지 넣을 수 있어요.` }, 400);
const id = d.quizzes.create(h.actor(c), p.data.name, limits, Date.now(), p.data.kind);
if (typeof id === 'string') return c.json({ error: id }, 400);
// 이지선다: a 조회수 written in the file is used as is, the others are fetched (토픽 + MV) after saving
const items = p.data.items.map((it) => ({ ...it, id: undefined, songId: null, fromFile: true, viewsAuto: null, ...(duel ? {} : { views: null }) }));
// 자동 (시작·하이라이트 칸이 빈 곡): the item stays unlinked (values as written), so the DB song with this very video
// lends its highlight (stored as the song's own positions) and its length (for the 30% rule when there is no highlight)
const sameVideo = d.db.query<{ highlight_sec: number | null; duration_sec: number | null }, [string]>(
"SELECT highlight_sec, duration_sec FROM songs WHERE youtube_id = ? AND youtube_status = 'matched' AND deleted_at IS NULL ORDER BY highlight_sec IS NULL, id LIMIT 1",
);
const items = p.data.items.map((it) => {
const s = it.auto ? sameVideo.get(it.videoId) : null;
const pos = s?.highlight_sec != null ? { auto: false, startSec: 0, highlightSec: s.highlight_sec } : {};
// 이지선다: a 조회수 written in the file is used as is, the others are fetched (토픽 + MV) after saving
return { ...it, ...pos, durationSec: it.durationSec ?? s?.duration_sec ?? null, id: undefined, songId: null, fromFile: true, viewsAuto: null, ...(duel ? {} : { views: null }) };
});
// songs with their own hints: hints come by vote unless the maker changes it in 설정
const settings = { ...DEFAULT_QUIZ_SETTINGS, ...(items.some((it) => it.hints.length) ? { hint: 'manual' as const } : {}) };
const saved = d.quizzes.save(id, { name: p.data.name, description: '', visibility: 'private', settings, items }, limits);