After some back-and-forth and much cleaner code with less Claude Sonnet intervention this time, we’ve now merged a PR where questions transition from symbol-based to type-based dispatch.
Previously, questions were created using symbol-based dispatch:
Question("What is 2+2?", :code, 4, "Add the numbers")
Question("Welcome!", :message, nothing)
Question("Pick one:", :multiple_choice, 2, "hint", ["A", "B", "C"])
Now, we use explicit typed constructors:
CodeQ(text="What is 2+2?", answer=4, hint="Add the numbers")
MessageQ(text="Welcome!")
ChoiceQ(text="Pick one:", choices=["A", "B", "C"], answer=2, hint="hint")
New Question Types
The refactoring also introduces new question types:
CodeQ - Single-step code questions (replaces :code)
MultistepCodeQ - Multi-step code questions with step-by-step guidance
MessageQ - Display-only messages (replaces :message)
ChoiceQ - Single-choice questions (replaces :multiple_choice)
MultipleChoiceQ - Multiple-selection questions
StringQ - String matching with regex support
NumericQ - Numeric answers with range checking
Example: Multi-Step Code Questions
MultistepCodeQ(
text=md"**Good**! Bindings let you reuse values. Now create a binding `y` with the value `5`, then add `x` and `y` together.",
answer=15,
hint="",
steps=[
md"Create a binding `y` with value `5`.",
md"Add `x` and `y` together."
],
step_hints=[
md"Type: `y = 5`
Bindings let you refer to values for later use.",
md"Type: `x + y`
Remember: `x` is still `10` from the previous question!"
],
setup="x = 10"
)
Also, a few new features and changes were adopted that improve the experience such as the <- in progress and the <- just completed indicators.
UPDATE: The README.md has just been updated.
UPDATE2: Here is a short new yt demo of the current state of the UI.