Quarto Exercises Extension Example
This document shows how to use the quarto-exercises extension to write interactive practice exercises in Quarto HTML pages.
Multiple Choice / Multiple Answer
Minimal Single-Choice
Who carried the One Ring out of the Shire?
Multiple-Correct with Custom Keys & Shuffling
Which members of the Fellowship are hobbits? Select all that apply.
There are four hobbits in the Fellowship. One of them is Peregrin Took (Pippin), who is not listed here.
Per-Answer Feedback & Question Explanation
What is the name of the wizard who guides the Fellowship?
Gandalf is one of the Istari (wizards) sent to Middle-earth to oppose Sauron.
Code Blocks in Choices
What does the following Python statement print?
print([x * 2 for x in range(3)])Fill-in-the-blank
Basic Blank
The wizard who guides the Fellowship is .
Multiple Accepted Answers (Case-insensitive)
The Ringbearer is .
Escaped Pipe in Answers
Answer with the literal token .
Regex Matching
The full title of the first volume of Lord of the Rings is .
Inline Choice / Dropdown Cloze
Standalone Dropdowns
The One Ring was forged in .
The literal token is .
Nested in a Parent Exercise
Grouping inline choices and blanks under a parent .exercise block combines their Check and Reset controls:
The hobbits are saved at the Prancing Pony by , who is also known as .
What does Sam call him?
Code Cloze
Blanks and dropdowns can live directly inside code blocks. Syntax highlighting is fully preserved.
A standalone .code-cloze block gets its own Check and Reset buttons:
x <- QEXCLOZEP000001(1, 2, 3, 4, 5)
total <- QEXCLOZEP000002(x)
cat("Total:", total, "\n")Wrapping a .code-cloze block in an .exercise div gives it the same Check and Reset controls as any other exercise:
numbers = [1, 2, 3, 4, 5]
total = QEXCLOZEP000001(numbers)
print(QEXCLOZEP000002)x <- 1:10
mean <- QEXCLOZEP000001(x)
cat(QEXCLOZEP000002, "\n")