Build auto-graded computational and short-answer questions with dynamic variables
General questions are the most flexible question type on BlitzGrok. Students enter a numeric or short-text answer into a single-line input. The answer is evaluated as a Python expression in the context of the generated variables, giving you complete control over correctness.
The answer is a Python expression evaluated in the variable context. The learner's input is compared against the result. You can use any Python operations available in the variable environment.
Create the variables your question needs. Variables are Python expressions that generate values for each instance.
Constraints prevent invalid variable combinations. Each constraint is a Python boolean expression.
Use {variable_name} to insert generated values directly into the question text.
Enter the Python expression for the correct answer. The learner's input is compared against this value.
The expression force evaluates to the value computed in step 1 for each generated instance.
Variables:
a = randint(1, 5)b = randint(-10, 10)c = randint(-20, 20)discriminant = b**2 - 4*a*croot1 = round((-b + sqrt(discriminant)) / (2*a), 2)root2 = round((-b - sqrt(discriminant)) / (2*a), 2)
Constraint: discriminant >= 0
Prompt: Solve for x: {a}x² + {b}x + {c} = 0. Enter the smaller root.
Answer: min(root1, root2)
Variables:
name = choice(["Alice", "Bob", "Charlie"])num_apples = randint(3, 8)gave = randint(1, num_apples - 1)remaining = num_apples - gave
Prompt: {name} had {num_apples} apples and gave {gave} away. How many does {name} have left?
Answer: remaining
Variables:
original = round(uniform(50, 500), 2)percentage = choice([10, 15, 20, 25, 50])discount = round(original * percentage / 100, 2)final = round(original - discount, 2)
Prompt: A ${original} item is on sale at {percentage}% off. What is the final price?
Answer: final
See how the other two question types work:
We're here to help