Creating General Questions

Build auto-graded computational and short-answer questions with dynamic variables

What is a General Question?

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.

  • Auto-graded — correct answer expression is evaluated against learner input
  • Variable-based — generates unique instances each attempt
  • Supports constraints — filter out invalid variable combinations
  • Marks set per question — configurable for assessments
  • Infinite practice — one template produces unlimited variations
General questions are the go-to choice for math, physics, chemistry, and any subject where answers are computable from given variables.

Answer Expressions

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.

Expression What It Does Use Case
answer Pre-computed variable Standard approach — compute answer as a variable
x + y Direct computation Small expressions without a separate variable
round(result, 2) Rounded result Floating-point answers with precision
str(choice) String conversion Text answers: choice(["True", "False"])

Step-by-Step Creation

1

Define Variables

Create the variables your question needs. Variables are Python expressions that generate values for each instance.

mass = round(uniform(5, 25), 1)
acceleration = round(uniform(2, 10), 1)
force = round(mass * acceleration, 1)
2

Add Constraints (Optional)

Constraints prevent invalid variable combinations. Each constraint is a Python boolean expression.

mass > 0
acceleration > 0
mass != acceleration
Excessively restrictive constraints may cause generation to fail if no valid combinations are possible.
3

Write the Prompt

Use {variable_name} to insert generated values directly into the question text.

A {mass} kg object accelerates at {acceleration} m/s². What is the force applied? (F = ma)
4

Set the Answer Expression

Enter the Python expression for the correct answer. The learner's input is compared against this value.

force

The expression force evaluates to the value computed in step 1 for each generated instance.

Examples

Example 1: Quadratic Equation Roots

Variables:

a = randint(1, 5)
b = randint(-10, 10)
c = randint(-20, 20)
discriminant = b**2 - 4*a*c
root1 = 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)

Example 2: Fill-in-the-Blank

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

Example 3: Percentage Calculation

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

Explore Other Question Types

See how the other two question types work:

Questions about creating General questions?

We're here to help

Contact Us