A <primer-quiz> builds a short test from a bank of questions
you author inline, as a child <script type="application/json">.
The count attribute says how many questions to show; they're picked
at random. Each question is one of two kinds.
Give it options. Exactly one (or more) is marked
"correct": true; the options are shuffled for each learner. Prompt
and option text may contain inline maths between $…$.
{ "prompt": "Which sum equals $10$?",
"options": [
{ "text": "$7 + 3$", "correct": true },
{ "text": "$6 + 3$", "correct": false },
{ "text": "$5 + 4$", "correct": false }
] }
Live:
Give it an answer instead of options and the learner
types into a box. The answer can be a literal (a number, or text like
"Paris"): typed answers are graded numerically with a small
tolerance, or as case- and space-insensitive text.
{ "prompt": "What is the capital of France?",
"answer": "Paris" }
Live:
Add variables and the question becomes a template: fresh
random numbers each time, with the answer computed from them. A
single template can fill several slots, so each learner gets a different set.
a=[1:10] — an integer in 1…10.b=[1;10] — a real number (3 dp) in 1…10.c=[2,3,5] — a choice of one listed value.{a} in the prompt expands to the value; answer is an
expression like "a * b" (supports + - * / % ^,
brackets, and sqrt abs round min max…).{ "prompt": "What is ${a} \\times {b}$?",
"variables": "a=[2:9] b=[2:9]",
"answer": "a * b" }
Live (reload the page for new numbers):
That's the whole quiz vocabulary. Mix kinds freely in one bank — the Primer
picks count of them and grades whatever the learner answers.