Quiz Widget
Quiz Widget
The current quiz slice is a Hugo-rendered widget backed by authored JSON or YAML source, with lightweight browser-side answer checking and a dedicated file-backed quiz editor path.
Architecture:
- Hugo remains the render authority.
- Authored quiz definitions live near content as JSON/YAML source files, or inline in the shortcode as a fallback.
- Browser JS enhances the rendered form for local scoring only.
- Submission storage is still out of scope.
- The editor currently supports file-backed quiz definitions, not inline shortcode quiz bodies.
Entry points:
- layouts/shortcodes/quiz.html
- layouts/shortcodes/quiz.tex
- layouts/partials/widgets/quiz-load.html
- layouts/partials/widgets/quiz.html
- assets/scss/components/_quiz.scss
- cdn/custom/quiz.js
Recommended usage:
Quiz source "quizzes/cell-basics.json" was not found as a page resource or readable file.
If the current page is a page bundle, src is resolved against page resources first. If no
src is given, the shortcode will parse inline YAML/JSON from its body.
Supported top-level fields:
idtitleeyebrowintroordescriptionsubmit_labelreset_labelpassing_scorequestionsoritems
Supported question fields:
idtype:singleormultiplepromptorquestionbodyexplanationchoicesoroptionscorrect_answer,correct_answers, or per-choicecorrect
Supported choice fields:
idvaluetext,label,body, ortitlecorrect
The runtime reads the rendered answer key from data-correct attributes and computes score in
the browser when the user submits the quiz. It does not persist answers and it no-ops while the
site is in edit mode.
Editor integration:
- Rendered quiz widgets now emit
data-ql-editable="quiz"plus a provider-readabledata-ql-source-pathwhen the shortcode usessrc="...". - Clicking a rendered quiz in live edit mode opens the
Quiz Editorspecial modal against the source JSON/YAML file. - Opening a quiz definition file directly from the file list also routes into the same special modal instead of replacing the markdown editor surface.
- Inline shortcode quiz bodies currently keep the
#quiz-inlinesentinel path and remain raw-source only.