Calculated Questions

Calculated Questions in Moodle

Calculated questions are a powerful question type that generates individualised numerical problems using formulas with wildcards. Each student can receive a different set of values, making it much harder to share answers while testing the same underlying concept. This question type is particularly valuable in mathematics, physics, chemistry, engineering, and finance courses.

How Calculated Questions Work

A calculated question uses a formula containing wildcards (variables enclosed in curly braces). Moodle generates random values for each wildcard from a defined range and computes the correct answer using the formula. Each time a student takes the quiz, they may see a different set of values.

Example

Question text: What is the area of a rectangle with length {l} cm and width {w} cm?
Correct answer formula: {l} * {w}

Student A sees: length = 5, width = 3 → answer = 15
Student B sees: length = 8, width = 4 → answer = 32

Creating a Calculated Question

  1. Navigate to the Question bank and click Create a new question.
  2. Select Calculated from the question type list.
  3. Configure the question text with wildcards.
  4. Define the answer formula.
  5. Configure wildcard datasets.
  6. Generate and preview dataset values.
  7. Click Save changes.

Question Text with Wildcards

Wildcards are variables enclosed in curly braces within the question text and formula. For example:

Question: A car travels {distance} kilometres in {time} hours.
What is the average speed in km/h?

Answer formula: {distance} / {time}

Wildcard names can contain letters, numbers, and underscores but must start with a letter. They are case-sensitive.

Answer Formula

The correct answer formula supports standard mathematical operations and functions:

  • Basic operations: +, -, *, /
  • Power: pow({x}, 2) for x squared
  • Square root: sqrt({x})
  • Trigonometric functions: sin(), cos(), tan(), asin(), acos(), atan()
  • Logarithms: log() (natural log), log10() (base-10 log)
  • Absolute value: abs()
  • Rounding: ceil(), floor(), round()
  • Constants: pi() for pi, exp(1) for e
  • Minimum/Maximum: min({a}, {b}), max({a}, {b})
  • Modulo: fmod({a}, {b})

Tolerance Settings

Since calculated answers may involve rounding, you can set a tolerance for each answer:

  • Relative tolerance: The accepted error is a fraction of the correct answer. For example, a tolerance of 0.01 means the answer can be within 1% of the correct value.
  • Nominal tolerance: The accepted error is a fixed amount. For example, a tolerance of 0.5 means the answer can be within ±0.5 of the correct value.
  • Geometric tolerance: The acceptable range is defined by multiplying/dividing the correct answer by the tolerance factor.

The Correct answer shows setting determines how many decimal places are displayed in the correct answer when shown to students.

Shared Datasets

Wildcards can use private datasets (unique to this question) or shared datasets (shared with other calculated questions in the same category). Shared datasets are useful when you want multiple questions to use the same set of random values, creating consistent problem scenarios across questions.

  • Private dataset: The wildcard values are independent and unique to this question.
  • Shared dataset: The wildcard uses a dataset that is shared with other questions. Changes to the shared dataset affect all questions using it.

Wildcard Dataset Configuration

For each wildcard, you configure:

  • Minimum value: The lower bound of the random range.
  • Maximum value: The upper bound of the random range.
  • Decimal places: The number of decimal places for the generated values (0 for whole numbers).
  • Distribution: Uniform (equal probability across the range) or loguniform (logarithmic distribution).

Generating Dataset Items

After configuring wildcards, you must generate a set of specific values (dataset items):

  1. Choose how many items to generate (e.g., 10, 20, 50, or 100).
  2. Click Generate to create random value sets.
  3. Review the generated values and the computed correct answers.
  4. Delete any items that produce problematic values (e.g., division by zero).

Each time a student takes the quiz, Moodle randomly selects one dataset item for the question.

Calculated Question Variants

Moodle offers several variants of calculated questions:

  • Calculated: The standard type described above with wildcards and formulas.
  • Calculated simple: A simplified version that defines the wildcards and formula on a single page, without shared datasets.
  • Calculated multichoice: Combines calculated answers with multiple choice format. Each answer option uses a formula, and students select the correct result.

Units in Calculated Questions

Calculated questions support the same unit handling as numerical questions, including unit multipliers, optional/required units, and unit penalties. See the Numerical Questions article for full details on unit configuration.

Best Practices

  • Test your formulas carefully with the preview feature before deploying the question.
  • Set appropriate wildcard ranges to avoid impossible scenarios (e.g., division by zero, negative square roots).
  • Generate a sufficient number of dataset items (at least 20-50) to reduce the chance of students getting the same values.
  • Use shared datasets when creating multi-part problem sets that should reference the same scenario.
  • Set appropriate tolerance values based on the expected precision of the calculation.
  • Verify generated answers manually for a few dataset items to confirm correctness.
  • State the required units and precision in the question text clearly.

¿Le ha resultado útil este artículo?

  • Question Bank

    Question Bank Overview The Question Bank in Moodle is a central repository where all questions are s...
  • Multiple Choice Questions

    Multiple Choice Questions in Moodle Multiple choice is one of the most widely used question types in...
  • True/False Questions

    True/False Questions in Moodle The True/False question type is one of the simplest question types av...
  • Short Answer Questions

    Short Answer Questions in Moodle The Short Answer question type requires students to type a word or ...
  • Essay Questions

    Essay Questions in Moodle The Essay question type allows students to write an extended response, whi...