{{- /* Multiple-choice knowledge check, scored in the browser. Usage: {{< quiz "triage_engine" >}} Questions live in data/quizzes/.yaml: a subject (used in the result message) and a list of questions, each with q, options, answer (0-based index), why, an optional source, and optional hints (one per option, null for the correct one) that point a wrong pick at the feature it describes. Links starting with "/" are site paths; others are relative to the page's section, e.g. "runs/#cascading". The markup is rendered here so the questions read without JavaScript; the inline script adds answering, feedback and scoring. Styles are inline rather than in _custom.scss because PurgeCSS cannot see classes that only appear in a shortcode used on one page. */ -}} {{- $name := .Get 0 -}} {{- $quiz := index site.Data.quizzes $name -}} {{- if not $quiz -}} {{- errorf "quiz shortcode: no data/quizzes/%s.yaml (used in %s)" $name .Page.File.Path -}} {{- end -}} {{- $page := .Page -}} {{- $base := .Page.CurrentSection.RelPermalink -}} {{- $total := len $quiz.questions -}} {{- $letters := slice "A" "B" "C" "D" "E" "F" -}}
Answered 0 / {{ $total }} Score 0
{{- range $i, $item := $quiz.questions }}
{{ add $i 1 }}.{{ $page.RenderString $item.q }} {{- range $j, $opt := $item.options }} {{- end }}
{{- end }}