Build auto-graded MCQ questions with dynamic variables and conditional answer choices
Multiple Choice Questions present students with a set of predefined answer options. Each option is backed by a Python expression that evaluates to 'True' (correct) or 'False' (incorrect) in the context of the generated variables.
Each choice has two parts: a label (what the student sees) and an expression (Python code determining correctness).
Create variables that your question will use. These feed into both the prompt and answer choice expressions.
Choose Multiple Choice (MCQ) from the question type dropdown when creating a new question. Set the difficulty — this determines the marks (Low=1, Medium=3, High=5).
Use {variable_name} to insert generated values into the question text.
Add choices with labels and expressions. The correct choice expression must evaluate to 'True'.
Check if a generated number is even
n = randint(1, 100)
Is {n} an even number?
Yes → str(n % 2 == 0)No → str(n % 2 != 0)
Pick the largest of three generated numbers
a = randint(1, 20)b = randint(1, 20)c = randint(1, 20)
a != ba != cb != c
Which is largest: {a}, {b}, or {c}?
{a} → str(a == max(a, b, c)){b} → str(b == max(a, b, c)){c} → str(c == max(a, b, c))
See how the other two question types work:
We're here to help