@interlacejs/quiz 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/tokens.ts","../src/quiz-player.ts","../src/quiz-editor.ts","../src/quiz-content-type.ts","../src/validate.ts"],"sourcesContent":["export { QuizContentType } from \"./quiz-content-type\";\nexport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nexport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nexport { validateQuizData } from \"./validate\";\n\nexport type { QuizPlaybackCallbacks } from \"./quiz-player\";\nexport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";","/**\n * Interlace design tokens.\n *\n * These values mirror the demo app's CSS custom properties so the library\n * surfaces feel like a single system. They are duplicated per package to\n * avoid adding runtime cross-package dependencies.\n */\n\nexport const COLORS = {\n accent: \"#0066cc\",\n accentHover: \"#0052a3\",\n accentLight: \"rgba(0, 102, 204, 0.15)\",\n accentLighter: \"rgba(0, 102, 204, 0.08)\",\n text: \"#0f172a\",\n textMuted: \"#64748b\",\n border: \"#e2e8f0\",\n borderStrong: \"#cbd5e1\",\n surface: \"#ffffff\",\n surfaceRaised: \"#f8fafc\",\n ground: \"#f6f7f9\",\n errorBg: \"#fef2f2\",\n errorText: \"#b91c1c\",\n errorBorder: \"#fecaca\",\n white: \"#ffffff\",\n black: \"#000000\",\n // Reveal-state aliases for quiz option feedback.\n correctBg: \"#0066cc\",\n correctText: \"#ffffff\",\n incorrectBg: \"#fef2f2\",\n incorrectText: \"#b91c1c\",\n incorrectBorder: \"#fecaca\",\n} as const;\n\nexport const FONTS = {\n display: 'Georgia, \"Times New Roman\", Times, serif',\n body: 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n} as const;\n\nexport const SPACE = {\n 1: 4,\n 2: 8,\n 3: 12,\n 4: 16,\n 5: 24,\n} as const;\n\nexport const RADIUS = {\n sm: 4,\n md: 8,\n lg: 12,\n} as const;\n\nexport const SHADOWS = {\n sm: \"0 1px 2px 0 rgba(15, 23, 42, 0.04)\",\n md: \"0 4px 12px -2px rgba(15, 23, 42, 0.08)\",\n} as const;\n\nexport const TYPE = {\n xs: 12,\n sm: 13,\n base: 15,\n md: 16,\n lg: 20,\n xl: 24,\n} as const;\n","import type { QuizData, QuizOption } from \"./schema\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\n\nexport interface QuizPlaybackCallbacks {\n onComplete(score?: number): void;\n}\n\ninterface QuizPlaybackSession {\n destroy: () => void;\n}\n\ninterface OptionEntry {\n button: HTMLButtonElement;\n option: QuizOption;\n statusGlyph: HTMLSpanElement;\n statusLabel: HTMLSpanElement;\n}\n\n/**\n * Per-container playback sessions, so `unmountQuizPlayback` can tear down\n * the listeners built by `renderQuizPlayback`.\n */\nconst quizPlaybackSessions = new WeakMap<HTMLElement, QuizPlaybackSession>();\n\n/** Creates a playback media `<img>`, or `null` when src is blank. */\nfunction createMediaImage(\n className: string,\n src: string,\n alt: string | undefined,\n): HTMLImageElement | null {\n if (src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = src;\n img.style.maxWidth = \"100%\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}px`;\n img.style.marginBottom = `${SPACE[2]}px`;\n if (alt) img.alt = alt;\n return img;\n}\n\n/** Locks an option button so it can no longer be clicked. */\nfunction lockOption(button: HTMLButtonElement): void {\n button.disabled = true;\n button.style.cursor = \"default\";\n}\n\n/** Reveals the correct-answer state on an option button. */\nfunction revealCorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-correct\");\n button.style.backgroundColor = COLORS.correctBg;\n button.style.borderColor = COLORS.correctBg;\n button.style.color = COLORS.correctText;\n glyph.textContent = \"✓\";\n label.textContent = \"Correct\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/** Reveals the wrong-answer state on the selected option button. */\nfunction revealIncorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-incorrect\");\n button.style.backgroundColor = COLORS.incorrectBg;\n button.style.borderColor = COLORS.incorrectBorder;\n button.style.color = COLORS.incorrectText;\n glyph.textContent = \"✕\";\n label.textContent = \"Incorrect\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/**\n * Renders a multi-question quiz into `container`: one question at a time\n * with a \"Question i of n\" indicator, per-question media and option buttons,\n * and an explicit navigation footer. Answering a question reveals\n * correctness and locks its options; the user then advances with **Next**.\n * On the final question, clicking **Next** reports the per-question\n * correct count (`onComplete(correctCount)`, one point per question) ONCE,\n * as the click handler's final statement. **Previous** returns to an\n * answered question in its locked, review-only state. The document is the\n * canonical single-format {@link QuizData} shape.\n */\nexport function renderQuizPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: QuizPlaybackCallbacks,\n): void {\n // Destroy any session already mounted in this container: the overlay\n // lifecycle may re-render without an intervening unmount, and overwriting\n // the WeakMap entry would leak the first root (and its click listeners).\n unmountQuizPlayback(container);\n\n const total = data.questions.length;\n // Per-question recorded selections; back-navigation and the final\n // aggregate both read from here, and reveal locks make it stable.\n const answers: (string | null)[] = data.questions.map(() => null);\n let currentIndex = 0;\n let completed = false;\n\n const root = document.createElement(\"div\");\n root.className = \"quiz-playback\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n\n const indicator = document.createElement(\"div\");\n indicator.className = \"quiz-playback-indicator\";\n indicator.style.fontSize = `${TYPE.xs}px`;\n indicator.style.fontWeight = \"600\";\n indicator.style.color = COLORS.textMuted;\n indicator.style.marginBottom = `${SPACE[2]}px`;\n indicator.style.textTransform = \"uppercase\";\n indicator.style.letterSpacing = \"0.06em\";\n root.appendChild(indicator);\n\n const question = document.createElement(\"p\");\n question.className = \"quiz-playback-question\";\n question.style.margin = `0 0 ${SPACE[2]}px 0`;\n question.style.fontFamily = FONTS.display;\n question.style.fontSize = `${TYPE.lg}px`;\n question.style.fontWeight = \"600\";\n root.appendChild(question);\n\n const questionMediaSlot = document.createElement(\"div\");\n root.appendChild(questionMediaSlot);\n\n const optionsBox = document.createElement(\"div\");\n optionsBox.className = \"quiz-playback-options\";\n optionsBox.style.display = \"flex\";\n optionsBox.style.flexDirection = \"column\";\n optionsBox.style.gap = `${SPACE[2]}px`;\n root.appendChild(optionsBox);\n\n // Navigation footer: Previous (review-only back) and Next. The final\n // question uses the same Next label; clicking it aggregates the score\n // and fires onComplete once.\n const navFooter = document.createElement(\"div\");\n navFooter.className = \"quiz-playback-nav\";\n navFooter.style.display = \"flex\";\n navFooter.style.justifyContent = \"flex-end\";\n navFooter.style.gap = `${SPACE[2]}px`;\n navFooter.style.marginTop = `${SPACE[4]}px`;\n root.appendChild(navFooter);\n\n const prevButton = document.createElement(\"button\");\n prevButton.type = \"button\";\n prevButton.className = \"quiz-playback-prev\";\n prevButton.textContent = \"Previous\";\n prevButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n prevButton.style.backgroundColor = COLORS.surface;\n prevButton.style.border = `1px solid ${COLORS.borderStrong}`;\n prevButton.style.borderRadius = `${RADIUS.md}px`;\n prevButton.style.color = COLORS.text;\n prevButton.style.cursor = \"pointer\";\n prevButton.style.fontSize = `${TYPE.base}px`;\n prevButton.style.fontWeight = \"600\";\n prevButton.style.transition = \"background-color 150ms ease\";\n prevButton.addEventListener(\"click\", () => {\n if (currentIndex > 0) {\n renderQuestion(currentIndex - 1);\n }\n });\n navFooter.appendChild(prevButton);\n\n const nextButton = document.createElement(\"button\");\n nextButton.type = \"button\";\n nextButton.className = \"quiz-playback-next\";\n nextButton.textContent = \"Next\";\n nextButton.disabled = true;\n nextButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n nextButton.style.backgroundColor = COLORS.accent;\n nextButton.style.border = \"none\";\n nextButton.style.borderRadius = `${RADIUS.md}px`;\n nextButton.style.color = COLORS.white;\n nextButton.style.cursor = \"pointer\";\n nextButton.style.fontSize = `${TYPE.base}px`;\n nextButton.style.fontWeight = \"600\";\n nextButton.style.transition =\n \"background-color 150ms ease, opacity 150ms ease\";\n nextButton.addEventListener(\"click\", () => {\n if (completed) return;\n if (currentIndex < total - 1) {\n renderQuestion(currentIndex + 1);\n } else {\n // Final question: aggregate the per-question answers.\n completed = true;\n const correctCount = data.questions.reduce(\n (count, questionSpec, questionIndex) =>\n count +\n (answers[questionIndex] !== null &&\n answers[questionIndex] === questionSpec.correctOptionId\n ? 1\n : 0),\n 0,\n );\n nextButton.disabled = true;\n nextButton.style.opacity = \"0.55\";\n callbacks.onComplete(correctCount);\n }\n });\n navFooter.appendChild(nextButton);\n\n container.appendChild(root);\n\n let optionEntries: OptionEntry[] = [];\n\n const syncFooter = (index: number): void => {\n prevButton.style.display = index > 0 ? \"block\" : \"none\";\n nextButton.textContent = \"Next\";\n const answered = answers[index] !== null;\n nextButton.disabled = completed || !answered;\n nextButton.style.opacity = nextButton.disabled ? \"0.55\" : \"1\";\n };\n\n const createOptionButton = (\n option: QuizOption,\n isReview: boolean,\n ): OptionEntry => {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"quiz-playback-option\";\n button.style.display = \"flex\";\n button.style.alignItems = \"center\";\n button.style.gap = `${SPACE[2]}px`;\n button.style.width = \"100%\";\n button.style.padding = `${SPACE[3]}px ${SPACE[4]}px`;\n button.style.backgroundColor = COLORS.surface;\n button.style.border = `1px solid ${COLORS.borderStrong}`;\n button.style.borderRadius = `${RADIUS.md}px`;\n button.style.cursor = \"pointer\";\n button.style.fontSize = `${TYPE.base}px`;\n button.style.color = COLORS.text;\n button.style.textAlign = \"left\";\n button.style.transition =\n \"background-color 150ms ease, border-color 150ms ease, color 150ms ease\";\n\n const text = document.createElement(\"span\");\n text.className = \"quiz-playback-option-text\";\n text.textContent = option.text;\n text.style.flex = \"1\";\n button.appendChild(text);\n\n const thumbnail = createMediaImage(\n \"quiz-playback-option-media\",\n option.media?.src ?? \"\",\n option.media?.alt,\n );\n if (thumbnail) button.appendChild(thumbnail);\n\n const status = document.createElement(\"span\");\n status.style.display = \"flex\";\n status.style.alignItems = \"center\";\n status.style.gap = `${SPACE[1]}px`;\n status.style.marginLeft = \"auto\";\n status.style.transition = \"opacity 150ms ease\";\n\n const glyph = document.createElement(\"span\");\n glyph.style.fontWeight = \"700\";\n glyph.style.fontSize = `${TYPE.md}px`;\n glyph.style.lineHeight = \"1\";\n status.appendChild(glyph);\n\n const label = document.createElement(\"span\");\n label.style.fontWeight = \"600\";\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.letterSpacing = \"0.04em\";\n status.appendChild(label);\n\n button.appendChild(status);\n\n if (isReview) {\n lockOption(button);\n }\n\n return { button, option, statusGlyph: glyph, statusLabel: label };\n };\n\n const revealQuestion = (\n questionIndex: number,\n selectedOptionId: string,\n ): void => {\n const spec = data.questions[questionIndex]!;\n const correctOptionId = spec.correctOptionId;\n\n optionEntries.forEach((entry) => {\n lockOption(entry.button);\n if (entry.option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (\n entry.option.id === selectedOptionId &&\n selectedOptionId !== correctOptionId\n ) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n });\n };\n\n const renderQuestion = (index: number): void => {\n currentIndex = index;\n const spec = data.questions[index]!;\n const correctOptionId = spec.correctOptionId;\n const answered = answers[index] ?? null;\n\n indicator.textContent = `Question ${index + 1} of ${total}`;\n question.textContent = spec.text;\n questionMediaSlot.innerHTML = \"\";\n const questionMedia = createMediaImage(\n \"quiz-playback-question-media\",\n spec.media?.src ?? \"\",\n spec.media?.alt,\n );\n if (questionMedia) questionMediaSlot.appendChild(questionMedia);\n\n optionsBox.innerHTML = \"\";\n optionEntries = spec.options.map((option) => {\n const isReview = answered !== null;\n const entry = createOptionButton(option, isReview);\n\n if (isReview) {\n if (option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (option.id === answered && answered !== correctOptionId) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n } else {\n entry.button.addEventListener(\"click\", () => {\n if (completed) return;\n answers[index] = option.id;\n // Reveal correctness and lock this question's options. No\n // auto-advance and no auto-complete: the footer gates progress.\n revealQuestion(index, option.id);\n syncFooter(index);\n });\n }\n\n optionsBox.appendChild(entry.button);\n return entry;\n });\n\n syncFooter(index);\n };\n\n renderQuestion(0);\n\n quizPlaybackSessions.set(container, {\n destroy: () => {\n root.remove();\n },\n });\n}\n\n/** Cleans up the playback session mounted in `container`, if any. */\nexport function unmountQuizPlayback(container: HTMLElement): void {\n quizPlaybackSessions.get(container)?.destroy();\n quizPlaybackSessions.delete(container);\n}\n","import { ContentType } from \"@interlacejs/core\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport { COLORS, FONTS, RADIUS, SHADOWS, SPACE, TYPE } from \"./tokens\";\nimport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";\n\ninterface QuizEditorController {\n syncTo(data: QuizData, onChange: (next: QuizData) => void): void;\n}\n\n/**\n * Controllers are stashed per container so the slot can hand the same\n * controller back across the mount/update lifecycle. The slot always passes\n * the same container element to `renderEditor`/`updateEditor`/`unmount`.\n */\nconst quizEditorControllers = new WeakMap<HTMLElement, QuizEditorController>();\n\n/** Builds a media ref from src/alt text; `undefined` when src is blank. */\nfunction buildMediaRef(src: string, alt: string): QuizMediaRef | undefined {\n if (src.length === 0) return undefined;\n return alt.length > 0 ? { src, alt } : { src };\n}\n\n/** Creates a preview `<img>` for a media ref, or `null` when src is blank. */\nfunction createPreview(\n media: QuizMediaRef | undefined,\n className: string,\n): HTMLImageElement | null {\n if (!media || media.src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = media.src;\n img.style.maxWidth = \"100%\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}px`;\n img.style.marginTop = `${SPACE[1]}px`;\n if (media.alt) img.alt = media.alt;\n return img;\n}\n\n/** Renders `media` into `slot`, replacing any previous preview. */\nfunction syncPreview(\n slot: HTMLElement,\n media: QuizMediaRef | undefined,\n className: string,\n): void {\n slot.innerHTML = \"\";\n const img = createPreview(media, className);\n if (img) slot.appendChild(img);\n}\n\n/** Generates an option id that does not collide with existing ids. */\nfunction nextOptionId(options: QuizOption[], index: number): string {\n const base = `opt-${index}`;\n if (!options.some((option) => option.id === base)) return base;\n let candidate = index + 1;\n while (options.some((option) => option.id === `opt-${candidate}`)) {\n candidate += 1;\n }\n return `opt-${candidate}`;\n}\n\n/** Generates a question id that does not collide with existing ids. */\nfunction nextQuestionId(questions: QuizQuestionSpec[], index: number): string {\n const base = `q-${index}`;\n if (!questions.some((question) => question.id === base)) return base;\n let candidate = index + 1;\n while (questions.some((question) => question.id === `q-${candidate}`)) {\n candidate += 1;\n }\n return `q-${candidate}`;\n}\n\n/** An empty question stub so the form is never without a question. */\nfunction emptyQuestion(id: string): QuizQuestionSpec {\n return { id, text: \"\", options: [], correctOptionId: null };\n}\n\ninterface OptionRow {\n row: HTMLDivElement;\n textInput: HTMLInputElement;\n mediaSrcInput: HTMLInputElement;\n mediaAltInput: HTMLInputElement;\n previewSlot: HTMLDivElement;\n}\n\n/**\n * Builds the quiz authoring form once and returns a controller whose\n * `syncTo` patches inputs in place (preserving focus) instead of rebuilding\n * the DOM on every keystroke. The form has a question list (add/remove,\n * selectable tabs); the ACTIVE question's text/media/options/correct select\n * are edited below it. Switching the selected question rebuilds that\n * question's editor rows (an explicit action); within the active question,\n * edits patch in place. All edits emit canonical multi-question\n * {@link QuizData}.\n */\nfunction createQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n container.innerHTML = \"\";\n const root = document.createElement(\"div\");\n root.className = \"quiz-editor\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n\n let currentData: QuizData = data;\n let currentOnChange = onChange;\n let selectedIndex = 0;\n let bodyQuestionIndex = -1;\n let optionRows: OptionRow[] = [];\n\n const emit = (questions: QuizQuestionSpec[]): void => {\n currentOnChange({ questions });\n };\n\n /** Applies `mutate` to the active question and emits the canonical list. */\n const patchActiveQuestion = (\n mutate: (question: QuizQuestionSpec) => QuizQuestionSpec,\n ): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n const questions = currentData.questions.slice();\n questions[selectedIndex] = mutate(active);\n emit(questions);\n };\n\n // --- Questions toolbar ---\n const questionsHeader = document.createElement(\"div\");\n questionsHeader.textContent = \"Questions\";\n questionsHeader.style.marginBottom = `${SPACE[2]}px`;\n questionsHeader.style.fontWeight = \"600\";\n questionsHeader.style.fontSize = `${TYPE.sm}px`;\n questionsHeader.style.color = COLORS.textMuted;\n root.appendChild(questionsHeader);\n\n const tabsBar = document.createElement(\"div\");\n tabsBar.className = \"quiz-question-tabs\";\n tabsBar.style.display = \"flex\";\n tabsBar.style.flexWrap = \"wrap\";\n tabsBar.style.gap = `${SPACE[2]}px`;\n tabsBar.style.marginBottom = `${SPACE[3]}px`;\n root.appendChild(tabsBar);\n\n const addQuestionButton = document.createElement(\"button\");\n addQuestionButton.type = \"button\";\n addQuestionButton.className = \"quiz-add-question\";\n addQuestionButton.textContent = \"Add question\";\n addQuestionButton.style.marginBottom = `${SPACE[4]}px`;\n addQuestionButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n addQuestionButton.style.backgroundColor = COLORS.surface;\n addQuestionButton.style.border = `1px solid ${COLORS.borderStrong}`;\n addQuestionButton.style.borderRadius = `${RADIUS.sm}px`;\n addQuestionButton.style.cursor = \"pointer\";\n addQuestionButton.style.fontSize = `${TYPE.sm}px`;\n addQuestionButton.style.fontWeight = \"600\";\n addQuestionButton.style.color = COLORS.text;\n addQuestionButton.addEventListener(\"click\", () => {\n const id = nextQuestionId(currentData.questions, currentData.questions.length);\n const questions = [...currentData.questions, emptyQuestion(id)];\n currentData = { questions };\n selectedIndex = questions.length - 1;\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n });\n root.appendChild(addQuestionButton);\n\n // --- Active question editor body ---\n const body = document.createElement(\"div\");\n body.className = \"quiz-editor-body\";\n root.appendChild(body);\n\n const questionInput = document.createElement(\"input\");\n questionInput.type = \"text\";\n questionInput.className = \"quiz-question\";\n questionInput.style.display = \"block\";\n questionInput.style.width = \"100%\";\n questionInput.style.boxSizing = \"border-box\";\n questionInput.style.padding = `${SPACE[2]}px ${SPACE[3]}px`;\n questionInput.style.fontSize = `${TYPE.md}px`;\n questionInput.style.color = COLORS.text;\n questionInput.style.border = `1px solid ${COLORS.borderStrong}`;\n questionInput.style.borderRadius = `${RADIUS.sm}px`;\n questionInput.style.backgroundColor = COLORS.surface;\n questionInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => ({\n ...question,\n text: questionInput.value,\n }));\n });\n const questionLabel = document.createElement(\"label\");\n questionLabel.style.display = \"block\";\n questionLabel.style.marginBottom = `${SPACE[3]}px`;\n questionLabel.style.fontWeight = \"600\";\n questionLabel.style.fontSize = `${TYPE.sm}px`;\n questionLabel.style.color = COLORS.textMuted;\n questionLabel.appendChild(document.createTextNode(\"Question\"));\n questionLabel.appendChild(questionInput);\n body.appendChild(questionLabel);\n\n // Active question media sub-block: src + alt inputs and a live preview.\n const questionMediaBox = document.createElement(\"div\");\n questionMediaBox.className = \"quiz-question-media\";\n questionMediaBox.style.padding = `${SPACE[3]}px`;\n questionMediaBox.style.marginBottom = `${SPACE[4]}px`;\n questionMediaBox.style.backgroundColor = COLORS.surfaceRaised;\n questionMediaBox.style.border = `1px solid ${COLORS.border}`;\n questionMediaBox.style.borderRadius = `${RADIUS.md}px`;\n\n const questionMediaSrc = document.createElement(\"input\");\n questionMediaSrc.type = \"text\";\n questionMediaSrc.className = \"quiz-question-media-src\";\n questionMediaSrc.placeholder = \"Question media URL\";\n questionMediaSrc.style.display = \"block\";\n questionMediaSrc.style.width = \"100%\";\n questionMediaSrc.style.boxSizing = \"border-box\";\n questionMediaSrc.style.padding = `${SPACE[2]}px ${SPACE[3]}px`;\n questionMediaSrc.style.marginBottom = `${SPACE[2]}px`;\n questionMediaSrc.style.fontSize = `${TYPE.base}px`;\n questionMediaSrc.style.color = COLORS.text;\n questionMediaSrc.style.border = `1px solid ${COLORS.borderStrong}`;\n questionMediaSrc.style.borderRadius = `${RADIUS.sm}px`;\n questionMediaSrc.style.backgroundColor = COLORS.surface;\n\n const questionMediaAlt = document.createElement(\"input\");\n questionMediaAlt.type = \"text\";\n questionMediaAlt.className = \"quiz-question-media-alt\";\n questionMediaAlt.placeholder = \"Media alt text\";\n questionMediaAlt.style.display = \"block\";\n questionMediaAlt.style.width = \"100%\";\n questionMediaAlt.style.boxSizing = \"border-box\";\n questionMediaAlt.style.padding = `${SPACE[2]}px ${SPACE[3]}px`;\n questionMediaAlt.style.fontSize = `${TYPE.base}px`;\n questionMediaAlt.style.color = COLORS.text;\n questionMediaAlt.style.border = `1px solid ${COLORS.borderStrong}`;\n questionMediaAlt.style.borderRadius = `${RADIUS.sm}px`;\n questionMediaAlt.style.backgroundColor = COLORS.surface;\n const questionPreviewSlot = document.createElement(\"div\");\n questionPreviewSlot.className = \"quiz-question-media-preview-slot\";\n const emitQuestionMedia = () => {\n const media = buildMediaRef(questionMediaSrc.value, questionMediaAlt.value);\n syncPreview(questionPreviewSlot, media, \"quiz-question-media-preview\");\n patchActiveQuestion((question) => ({ ...question, media }));\n };\n questionMediaSrc.addEventListener(\"input\", emitQuestionMedia);\n questionMediaAlt.addEventListener(\"input\", emitQuestionMedia);\n questionMediaBox.append(questionMediaSrc, questionMediaAlt, questionPreviewSlot);\n body.appendChild(questionMediaBox);\n\n const optionsTitle = document.createElement(\"div\");\n optionsTitle.textContent = \"Options\";\n optionsTitle.style.marginBottom = `${SPACE[2]}px`;\n optionsTitle.style.fontWeight = \"600\";\n optionsTitle.style.fontSize = `${TYPE.sm}px`;\n optionsTitle.style.color = COLORS.textMuted;\n body.appendChild(optionsTitle);\n const optionsContainer = document.createElement(\"div\");\n optionsContainer.style.display = \"flex\";\n optionsContainer.style.flexDirection = \"column\";\n optionsContainer.style.gap = `${SPACE[2]}px`;\n body.appendChild(optionsContainer);\n\n const addOptionButton = document.createElement(\"button\");\n addOptionButton.type = \"button\";\n addOptionButton.className = \"quiz-add-option\";\n addOptionButton.textContent = \"Add option\";\n addOptionButton.style.marginTop = `${SPACE[2]}px`;\n addOptionButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n addOptionButton.style.backgroundColor = COLORS.surface;\n addOptionButton.style.border = `1px solid ${COLORS.borderStrong}`;\n addOptionButton.style.borderRadius = `${RADIUS.sm}px`;\n addOptionButton.style.cursor = \"pointer\";\n addOptionButton.style.fontSize = `${TYPE.sm}px`;\n addOptionButton.style.fontWeight = \"600\";\n addOptionButton.style.color = COLORS.text;\n addOptionButton.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const nextOptions: QuizOption[] = [\n ...question.options,\n {\n id: nextOptionId(question.options, question.options.length),\n text: \"\",\n },\n ];\n // Adding the first option defaults it to correct (ported behavior).\n const nextCorrectOptionId =\n question.options.length === 0\n ? nextOptions[0]!.id\n : question.correctOptionId;\n return {\n ...question,\n options: nextOptions,\n correctOptionId: nextCorrectOptionId,\n };\n });\n });\n body.appendChild(addOptionButton);\n\n const correctLabel = document.createElement(\"label\");\n correctLabel.style.display = \"block\";\n correctLabel.style.marginTop = `${SPACE[4]}px`;\n correctLabel.style.fontWeight = \"600\";\n correctLabel.style.fontSize = `${TYPE.sm}px`;\n correctLabel.style.color = COLORS.textMuted;\n correctLabel.appendChild(document.createTextNode(\"Correct answer\"));\n const select = document.createElement(\"select\");\n select.className = \"quiz-correct-answer\";\n select.style.display = \"block\";\n select.style.width = \"100%\";\n select.style.marginTop = `${SPACE[1]}px`;\n select.style.padding = `${SPACE[2]}px ${SPACE[3]}px`;\n select.style.fontSize = `${TYPE.base}px`;\n select.style.color = COLORS.text;\n select.style.border = `1px solid ${COLORS.borderStrong}`;\n select.style.borderRadius = `${RADIUS.sm}px`;\n select.style.backgroundColor = COLORS.surface;\n select.addEventListener(\"change\", () => {\n patchActiveQuestion((question) => ({\n ...question,\n correctOptionId: select.value.length > 0 ? select.value : null,\n }));\n });\n correctLabel.appendChild(select);\n body.appendChild(correctLabel);\n\n container.appendChild(root);\n\n const createOptionRow = (option: QuizOption, optionIndex: number): OptionRow => {\n const row = document.createElement(\"div\");\n row.className = \"quiz-option-row\";\n row.style.display = \"flex\";\n row.style.flexWrap = \"wrap\";\n row.style.gap = `${SPACE[2]}px`;\n row.style.alignItems = \"center\";\n row.style.padding = `${SPACE[2]}px`;\n row.style.backgroundColor = COLORS.surfaceRaised;\n row.style.border = `1px solid ${COLORS.border}`;\n row.style.borderRadius = `${RADIUS.md}px`;\n\n const textInput = document.createElement(\"input\");\n textInput.type = \"text\";\n textInput.className = \"quiz-option-text\";\n textInput.style.flex = \"1\";\n textInput.style.minWidth = \"120px\";\n textInput.style.padding = `${SPACE[2]}px ${SPACE[3]}px`;\n textInput.style.fontSize = `${TYPE.base}px`;\n textInput.style.color = COLORS.text;\n textInput.style.border = `1px solid ${COLORS.borderStrong}`;\n textInput.style.borderRadius = `${RADIUS.sm}px`;\n textInput.style.backgroundColor = COLORS.surface;\n textInput.value = option.text;\n textInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = {\n ...nextOptions[optionIndex]!,\n text: textInput.value,\n };\n return { ...question, options: nextOptions };\n });\n });\n\n const mediaSrcInput = document.createElement(\"input\");\n mediaSrcInput.type = \"text\";\n mediaSrcInput.className = \"quiz-option-media-src\";\n mediaSrcInput.placeholder = \"Option media URL\";\n mediaSrcInput.value = option.media?.src ?? \"\";\n mediaSrcInput.style.flex = \"1\";\n mediaSrcInput.style.minWidth = \"120px\";\n mediaSrcInput.style.padding = `${SPACE[2]}px ${SPACE[3]}px`;\n mediaSrcInput.style.fontSize = `${TYPE.base}px`;\n mediaSrcInput.style.color = COLORS.text;\n mediaSrcInput.style.border = `1px solid ${COLORS.borderStrong}`;\n mediaSrcInput.style.borderRadius = `${RADIUS.sm}px`;\n mediaSrcInput.style.backgroundColor = COLORS.surface;\n\n const mediaAltInput = document.createElement(\"input\");\n mediaAltInput.type = \"text\";\n mediaAltInput.className = \"quiz-option-media-alt\";\n mediaAltInput.placeholder = \"Option media alt\";\n mediaAltInput.value = option.media?.alt ?? \"\";\n mediaAltInput.style.flex = \"1\";\n mediaAltInput.style.minWidth = \"120px\";\n mediaAltInput.style.padding = `${SPACE[2]}px ${SPACE[3]}px`;\n mediaAltInput.style.fontSize = `${TYPE.base}px`;\n mediaAltInput.style.color = COLORS.text;\n mediaAltInput.style.border = `1px solid ${COLORS.borderStrong}`;\n mediaAltInput.style.borderRadius = `${RADIUS.sm}px`;\n mediaAltInput.style.backgroundColor = COLORS.surface;\n\n const previewSlot = document.createElement(\"div\");\n previewSlot.className = \"quiz-option-media-preview\";\n syncPreview(previewSlot, option.media, \"quiz-option-thumb\");\n\n const emitOptionMedia = () => {\n const media = buildMediaRef(mediaSrcInput.value, mediaAltInput.value);\n syncPreview(previewSlot, media, \"quiz-option-thumb\");\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = { ...nextOptions[optionIndex]!, media };\n return { ...question, options: nextOptions };\n });\n };\n mediaSrcInput.addEventListener(\"input\", emitOptionMedia);\n mediaAltInput.addEventListener(\"input\", emitOptionMedia);\n\n const remove = document.createElement(\"button\");\n remove.type = \"button\";\n remove.className = \"quiz-option-remove\";\n remove.textContent = \"Remove\";\n remove.style.padding = `${SPACE[1]}px ${SPACE[3]}px`;\n remove.style.backgroundColor = COLORS.errorBg;\n remove.style.border = `1px solid ${COLORS.errorBorder}`;\n remove.style.borderRadius = `${RADIUS.sm}px`;\n remove.style.cursor = \"pointer\";\n remove.style.fontSize = `${TYPE.sm}px`;\n remove.style.fontWeight = \"600\";\n remove.style.color = COLORS.errorText;\n remove.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const removed = question.options[optionIndex];\n const nextOptions = question.options.filter((_, i) => i !== optionIndex);\n return {\n ...question,\n options: nextOptions,\n // Removing the correct option clears correctness; do not shift it.\n correctOptionId:\n removed && removed.id === question.correctOptionId\n ? null\n : question.correctOptionId,\n };\n });\n });\n\n row.append(textInput, mediaSrcInput, mediaAltInput, previewSlot, remove);\n optionsContainer.appendChild(row);\n return { row, textInput, mediaSrcInput, mediaAltInput, previewSlot };\n };\n\n const selectQuestion = (index: number): void => {\n selectedIndex = index;\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const removeQuestion = (index: number): void => {\n const next = currentData.questions.filter((_, i) => i !== index);\n const questions =\n next.length > 0 ? next : [emptyQuestion(nextQuestionId([], 0))];\n if (selectedIndex === index) {\n selectedIndex = 0; // removing the selected question selects the first remaining\n } else if (index < selectedIndex) {\n selectedIndex -= 1;\n }\n currentData = { questions };\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const renderTabs = (): void => {\n tabsBar.innerHTML = \"\";\n currentData.questions.forEach((question, index) => {\n const wrap = document.createElement(\"div\");\n wrap.className = \"quiz-question-tab-wrap\";\n wrap.style.display = \"inline-flex\";\n wrap.style.alignItems = \"center\";\n wrap.style.gap = `${SPACE[1]}px`;\n\n const tab = document.createElement(\"button\");\n tab.type = \"button\";\n tab.className = \"quiz-question-tab\";\n tab.textContent = `Question ${index + 1}`;\n tab.style.padding = `${SPACE[1]}px ${SPACE[3]}px`;\n tab.style.borderRadius = `${RADIUS.sm}px`;\n tab.style.border = `1px solid ${COLORS.borderStrong}`;\n tab.style.cursor = \"pointer\";\n tab.style.fontSize = `${TYPE.sm}px`;\n tab.style.fontWeight = \"600\";\n if (index === selectedIndex) {\n tab.style.backgroundColor = COLORS.accent;\n tab.style.borderColor = COLORS.accent;\n tab.style.color = COLORS.white;\n } else {\n tab.style.backgroundColor = COLORS.surface;\n tab.style.color = COLORS.text;\n }\n tab.addEventListener(\"click\", () => selectQuestion(index));\n\n const remove = document.createElement(\"button\");\n remove.type = \"button\";\n remove.className = \"quiz-question-remove\";\n remove.textContent = \"Remove\";\n remove.style.padding = `${SPACE[1]}px ${SPACE[2]}px`;\n remove.style.borderRadius = `${RADIUS.sm}px`;\n remove.style.border = `1px solid ${COLORS.errorBorder}`;\n remove.style.backgroundColor = COLORS.errorBg;\n remove.style.color = COLORS.errorText;\n remove.style.cursor = \"pointer\";\n remove.style.fontSize = `${TYPE.xs}px`;\n remove.style.fontWeight = \"600\";\n remove.addEventListener(\"click\", () => removeQuestion(index));\n\n wrap.append(tab, remove);\n tabsBar.appendChild(wrap);\n });\n };\n\n const syncActiveBody = (): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n\n questionInput.value = active.text;\n questionMediaSrc.value = active.media?.src ?? \"\";\n questionMediaAlt.value = active.media?.alt ?? \"\";\n syncPreview(questionPreviewSlot, active.media, \"quiz-question-media-preview\");\n\n const options = active.options;\n if (bodyQuestionIndex !== selectedIndex || optionRows.length !== options.length) {\n // Question switch or option count change: rebuild the active question's rows.\n optionsContainer.innerHTML = \"\";\n optionRows = options.map((option, optionIndex) =>\n createOptionRow(option, optionIndex),\n );\n bodyQuestionIndex = selectedIndex;\n } else {\n // Count unchanged: patch values in place, preserving input focus.\n optionRows.forEach((row, optionIndex) => {\n const option = options[optionIndex]!;\n row.textInput.value = option.text;\n row.mediaSrcInput.value = option.media?.src ?? \"\";\n row.mediaAltInput.value = option.media?.alt ?? \"\";\n syncPreview(row.previewSlot, option.media, \"quiz-option-thumb\");\n });\n }\n\n // Patch the select in place, keyed by option id.\n while (select.options.length < options.length) {\n select.add(document.createElement(\"option\"));\n }\n while (select.options.length > options.length) {\n select.remove(select.options.length - 1);\n }\n for (let i = 0; i < options.length; i++) {\n const el = select.options[i];\n if (!el) continue;\n const option = options[i]!;\n el.value = option.id;\n el.textContent = `Option ${i + 1}: ${option.text}`;\n el.selected = option.id === active.correctOptionId;\n }\n };\n\n const syncTo = (\n nextData: QuizData,\n nextOnChange: (next: QuizData) => void,\n ): void => {\n currentData = nextData;\n currentOnChange = nextOnChange;\n if (currentData.questions.length === 0) {\n currentData = { questions: [emptyQuestion(\"q-0\")] };\n }\n if (selectedIndex >= currentData.questions.length) {\n selectedIndex = 0;\n }\n renderTabs();\n syncActiveBody();\n };\n\n renderTabs();\n syncActiveBody();\n\n return { syncTo };\n}\n\nfunction getOrCreateQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n let controller = quizEditorControllers.get(container);\n if (!controller) {\n controller = createQuizEditorController(container, data, onChange);\n quizEditorControllers.set(container, controller);\n }\n return controller;\n}\n\n/** Tears down the editor controller mounted in `container`, if any. */\nexport function unmountQuizEditor(container: HTMLElement): void {\n quizEditorControllers.delete(container);\n container.innerHTML = \"\";\n}\n\n/**\n * Built-in Quiz editor content type. Authors the canonical multi-question\n * {@link QuizData} shape with rich media (the single supported format).\n * Registered id is `quiz-editor`, matching the player's built-in quiz\n * content type.\n */\nexport const QuizEditorType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};","import { ContentType } from \"@interlacejs/core\";\nimport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport type { QuizData } from \"./schema\";\n\n/**\n * Built-in Quiz content type for Interlace. Authors the canonical\n * {@link QuizData} shape with rich media and plays it back with immediate\n * scoring. Registered id is `quiz-editor` — the id the editor's built-in\n * quiz type authors with — so authored documents resolve without extra\n * registry wiring.\n */\nexport const QuizContentType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.renderEditor(container, data, onChange);\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.updateEditor?.(container, data, onChange);\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n","import type { QuizData } from \"./schema\";\n\n/**\n * Validates canonical quiz data, returning human-readable error strings\n * indexed per question. An empty array means the document is valid.\n *\n * The legacy flat input format was removed; only the canonical\n * multi-question `QuizData` shape is accepted.\n */\nexport function validateQuizData(data: QuizData): string[] {\n const errors: string[] = [];\n\n if (data.questions.length === 0) {\n errors.push(\"at least one question is required\");\n return errors;\n }\n\n data.questions.forEach((question, index) => {\n if (question.text.trim().length === 0) {\n errors.push(`questions[${index}].text must be a non-empty string`);\n }\n\n if (question.options.length === 0) {\n errors.push(`questions[${index}].at least one option is required`);\n } else {\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n errors.push(\n `questions[${index}].options[${optionIndex}].text must be a non-empty string`,\n );\n }\n });\n }\n\n if (question.correctOptionId === null) {\n errors.push(\n `questions[${index}].exactly one correct option must be resolvable`,\n );\n }\n });\n\n return errors;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,SAAS;AAAA,EACpB,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,aAAa;AAAA,EACb,eAAe;AAAA,EACf,MAAM;AAAA,EACN,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,SAAS;AAAA,EACT,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AAAA;AAAA,EAEP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,EACb,eAAe;AAAA,EACf,iBAAiB;AACnB;AAEO,IAAM,QAAQ;AAAA,EACnB,SAAS;AAAA,EACT,MAAM;AACR;AAEO,IAAM,QAAQ;AAAA,EACnB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,IAAM,SAAS;AAAA,EACpB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAOO,IAAM,OAAO;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;;;AC1CA,IAAM,u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SAAS,KAAK,KAAK,EAAE,WAAW,GAAG;AACrC,aAAO,KAAK,aAAa,KAAK,mCAAmC;AAAA,IACnE;AAEA,QAAI,SAAS,QAAQ,WAAW,GAAG;AACjC,aAAO,KAAK,aAAa,KAAK,mCAAmC;AAAA,IACnE,OAAO;AACL,eAAS,QAAQ,QAAQ,CAAC,QAAQ,gBAAgB;AAChD,YAAI,OAAO,KAAK,KAAK,EAAE,WAAW,GAAG;AACnC,iBAAO;AAAA,YACL,aAAa,KAAK,aAAa,WAAW;AAAA,UAC5C;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,SAAS,oBAAoB,MAAM;AACrC,aAAO;AAAA,QACL,aAAa,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -0,0 +1,77 @@
1
+ import { ContentType } from '@interlacejs/core';
2
+
3
+ interface QuizMediaRef {
4
+ /** Absolute or relative URL of the media asset. */
5
+ src: string;
6
+ /** Accessible description of the media. */
7
+ alt?: string;
8
+ }
9
+ interface QuizOption {
10
+ id: string;
11
+ text: string;
12
+ media?: QuizMediaRef;
13
+ }
14
+ /** Canonical per-question shape this package defines and maintains. */
15
+ interface QuizQuestionSpec {
16
+ id: string;
17
+ text: string;
18
+ media?: QuizMediaRef;
19
+ options: QuizOption[];
20
+ correctOptionId: string | null;
21
+ }
22
+ /**
23
+ * Canonical single-format QuizData shape this package defines and maintains.
24
+ * There is only ONE format: a `questions` list of fully-authored specs (ids,
25
+ * option objects, explicit correctness). The legacy flat format was removed.
26
+ */
27
+ interface QuizData {
28
+ questions: QuizQuestionSpec[];
29
+ }
30
+
31
+ /**
32
+ * Built-in Quiz content type for Interlace. Authors the canonical
33
+ * {@link QuizData} shape with rich media and plays it back with immediate
34
+ * scoring. Registered id is `quiz-editor` — the id the editor's built-in
35
+ * quiz type authors with — so authored documents resolve without extra
36
+ * registry wiring.
37
+ */
38
+ declare const QuizContentType: ContentType<QuizData>;
39
+
40
+ /** Tears down the editor controller mounted in `container`, if any. */
41
+ declare function unmountQuizEditor(container: HTMLElement): void;
42
+ /**
43
+ * Built-in Quiz editor content type. Authors the canonical multi-question
44
+ * {@link QuizData} shape with rich media (the single supported format).
45
+ * Registered id is `quiz-editor`, matching the player's built-in quiz
46
+ * content type.
47
+ */
48
+ declare const QuizEditorType: ContentType<QuizData>;
49
+
50
+ interface QuizPlaybackCallbacks {
51
+ onComplete(score?: number): void;
52
+ }
53
+ /**
54
+ * Renders a multi-question quiz into `container`: one question at a time
55
+ * with a "Question i of n" indicator, per-question media and option buttons,
56
+ * and an explicit navigation footer. Answering a question reveals
57
+ * correctness and locks its options; the user then advances with **Next**.
58
+ * On the final question, clicking **Next** reports the per-question
59
+ * correct count (`onComplete(correctCount)`, one point per question) ONCE,
60
+ * as the click handler's final statement. **Previous** returns to an
61
+ * answered question in its locked, review-only state. The document is the
62
+ * canonical single-format {@link QuizData} shape.
63
+ */
64
+ declare function renderQuizPlayback(container: HTMLElement, data: QuizData, callbacks: QuizPlaybackCallbacks): void;
65
+ /** Cleans up the playback session mounted in `container`, if any. */
66
+ declare function unmountQuizPlayback(container: HTMLElement): void;
67
+
68
+ /**
69
+ * Validates canonical quiz data, returning human-readable error strings
70
+ * indexed per question. An empty array means the document is valid.
71
+ *
72
+ * The legacy flat input format was removed; only the canonical
73
+ * multi-question `QuizData` shape is accepted.
74
+ */
75
+ declare function validateQuizData(data: QuizData): string[];
76
+
77
+ export { QuizContentType, type QuizData, QuizEditorType, type QuizMediaRef, type QuizOption, type QuizPlaybackCallbacks, type QuizQuestionSpec, renderQuizPlayback, unmountQuizEditor, unmountQuizPlayback, validateQuizData };
@@ -0,0 +1,77 @@
1
+ import { ContentType } from '@interlacejs/core';
2
+
3
+ interface QuizMediaRef {
4
+ /** Absolute or relative URL of the media asset. */
5
+ src: string;
6
+ /** Accessible description of the media. */
7
+ alt?: string;
8
+ }
9
+ interface QuizOption {
10
+ id: string;
11
+ text: string;
12
+ media?: QuizMediaRef;
13
+ }
14
+ /** Canonical per-question shape this package defines and maintains. */
15
+ interface QuizQuestionSpec {
16
+ id: string;
17
+ text: string;
18
+ media?: QuizMediaRef;
19
+ options: QuizOption[];
20
+ correctOptionId: string | null;
21
+ }
22
+ /**
23
+ * Canonical single-format QuizData shape this package defines and maintains.
24
+ * There is only ONE format: a `questions` list of fully-authored specs (ids,
25
+ * option objects, explicit correctness). The legacy flat format was removed.
26
+ */
27
+ interface QuizData {
28
+ questions: QuizQuestionSpec[];
29
+ }
30
+
31
+ /**
32
+ * Built-in Quiz content type for Interlace. Authors the canonical
33
+ * {@link QuizData} shape with rich media and plays it back with immediate
34
+ * scoring. Registered id is `quiz-editor` — the id the editor's built-in
35
+ * quiz type authors with — so authored documents resolve without extra
36
+ * registry wiring.
37
+ */
38
+ declare const QuizContentType: ContentType<QuizData>;
39
+
40
+ /** Tears down the editor controller mounted in `container`, if any. */
41
+ declare function unmountQuizEditor(container: HTMLElement): void;
42
+ /**
43
+ * Built-in Quiz editor content type. Authors the canonical multi-question
44
+ * {@link QuizData} shape with rich media (the single supported format).
45
+ * Registered id is `quiz-editor`, matching the player's built-in quiz
46
+ * content type.
47
+ */
48
+ declare const QuizEditorType: ContentType<QuizData>;
49
+
50
+ interface QuizPlaybackCallbacks {
51
+ onComplete(score?: number): void;
52
+ }
53
+ /**
54
+ * Renders a multi-question quiz into `container`: one question at a time
55
+ * with a "Question i of n" indicator, per-question media and option buttons,
56
+ * and an explicit navigation footer. Answering a question reveals
57
+ * correctness and locks its options; the user then advances with **Next**.
58
+ * On the final question, clicking **Next** reports the per-question
59
+ * correct count (`onComplete(correctCount)`, one point per question) ONCE,
60
+ * as the click handler's final statement. **Previous** returns to an
61
+ * answered question in its locked, review-only state. The document is the
62
+ * canonical single-format {@link QuizData} shape.
63
+ */
64
+ declare function renderQuizPlayback(container: HTMLElement, data: QuizData, callbacks: QuizPlaybackCallbacks): void;
65
+ /** Cleans up the playback session mounted in `container`, if any. */
66
+ declare function unmountQuizPlayback(container: HTMLElement): void;
67
+
68
+ /**
69
+ * Validates canonical quiz data, returning human-readable error strings
70
+ * indexed per question. An empty array means the document is valid.
71
+ *
72
+ * The legacy flat input format was removed; only the canonical
73
+ * multi-question `QuizData` shape is accepted.
74
+ */
75
+ declare function validateQuizData(data: QuizData): string[];
76
+
77
+ export { QuizContentType, type QuizData, QuizEditorType, type QuizMediaRef, type QuizOption, type QuizPlaybackCallbacks, type QuizQuestionSpec, renderQuizPlayback, unmountQuizEditor, unmountQuizPlayback, validateQuizData };