- 24 Sep 2024
- 5 minutes to read

# Calculated quiz question

- Updated on 24 Sep 2024
- 5 minutes to read

Calculated questions are used to create mathematical questions by substituting randomly generated values into a formula using wildcards (e.g. {x} , {y}). This randomisation allows each learner to have a individualised calculated quiz question during an attempt.

For example, a question could be 'Calculate the area of a rectangle where its width = {width} and the height = {height}'. When displayed to the Learner, {width} and {height} would be replaced with randomly selected numerical values - e.g. 'Calculate the area of a rectangle where its width = 18cm and the height = 7cm'.

You can also specify the units required for the answers (e.g. cm).

**Calculated simple**question type is an alternative question type with a simpler user interface.

**Calculated**,

**Calculated simple**and

**Calculated multiple choice**quiz questions is controlled by the

**moodle/question:managecalculated**capability. For upgraded sites this capability will be assigned to any users who already have the

**moodle/question:add**capability. For new sites, this capability is not assigned to any roles by default. In either case, we recommend that Site Administrators review whether calculated quiz questions are required, and limit the capability to administrative roles where possible. No special role is required to use existing calculated questions in a quiz.

To set up a calculated quiz question, follow these steps:

- In the quiz activity, click
**Add**, then select**a new question**. - Select
**Calculated**, then click**Add**. - Give the question a name, then enter the question in the
**Question text**field. The question text must include the wildcards you will use in the answer formula, with each one inside a set of curly brackets. For example:

'A rectangle has a width of {width} and a height of {height}. What is the area of this rectangle?' - Set the
**Default mark**, i.e. how many marks the Learner will be awarded if they answer correctly. - In the
**Answer 1 formula**field, enter the formula that will be used to calculated the correct answer based on the wildcards that are randomly generated. For example, entering {width}*{height} would mean the correct answer would be calculated by multiplying two wildcards: {height} and {width}. See Answer formula syntax for more information. You can configure additional answers by clicking**Blanks for 1 more answer**. - Set the grade weighting for each answer.
- Set the error tolerance and how many decimal places or significant figures will be displayed.
- Either enter feedback for each answer, or use the
**General feedback**field. - If required, configure the
**Units**and**Unit handling** - If required, configure the
**Multiple tries**and**Tags**sections. - Click
**Save changes**. - Set which dataset you wish to use for the wildcards, and set whether data is synchronised with other questions in the quiz.
- Click
**Next page**. - Manually add wildcard values by entering values in the
**Wild card {x}**fields, then clicking**Add**. If you want Totara to generate the values, you can additionally enter the**Minimum**and**Maximum**for the**Range of values**, set the number of decimal places, and select which distribution to use (**Uniform**means all values in the range are equally likely, while**Loguniform**means higher values are less likely to be generated). Note that you can generate multiple wildcards at once using the dropdown next to the**Add**button. - Click
**Save changes**.

## Answer formula syntax

- There is no need to use an equals symbol in the formula.
- As a general rule, enter formulas as you would on a calculator e.g. 3 + 5 * sin(3/{x}. Exponentiation should be entered as pow({x}, y).
- Any special mathematical function must have parentheses around its values.
- Use an asterisk (*) for multiplication.

## Tolerance

You can set the acceptable tolerance for error within the Learner's response and the type of tolerance allowed. The specified tolerance value and the tolerance type selected combine to generate a range of acceptable scores.

If tolerance = t, correct answer = x and the difference between the user's answer and the correct answer is cx, then the tolerance types are as follows:

**Nominal:**Mark correct if cx <= t**Relative:**Mark correct if cx / x <= t**Geometric:**Mark correct if cx² / x² <= t²

## Units and unit handling

In the **Units **section you can configure any units that should be accounted for in the Learner's response. These can be visible in a dropdown list or radio buttons, or the user can enter a unit as part of their answer. You can set up multiple units and use multipliers to allow for multiple correct answers, such as 5kg and 5000g. For this example, you could set up one unit as 'g' with a multiplier of 1, and a second unit as 'kg' with a multiplier of 0.001.

There are several settings to configure in the **Unit handling **section if your question requires units.

Setting | Description | Notes |
---|---|---|

Unit handling | Set whether units are used for the question, and whether they are optional or mandatory. | - |

Unit penalty | Set the penalty that will be applied if the Learner enters the unit incorrectly. For example, a penalty of 0.2 will mean 20% of the grade is subtracted. | This setting is only available if Unit handling is set to The unit must be given, and will be graded. |

Units are input using | Set whether the unit is entered using the text input element, radio buttons, or a dropdown menu. | This setting is only available if Unit handling is set to The unit must be given, and will be graded. |

Units go | Set whether the unit should go before the number (e.g. $40) or after the number (e.g. 100kg). | - |

## Wildcards

Wildcards are placeholders for the numbers, values and/or measurements used in a calculated question formula. Wildcards (such as {width} and {height} from the above example) can be saved within a wildcard bank within a quiz category and reused across quizzes and quiz questions.

After adding a wildcard to a calculated question and saving, select the wildcard datasets available for this question.

Wildcard datasets defines the range of numerical values available for each wildcard, specifies the number of different datasets (values) available for random selection, and determines the wildcard values for each of the datasets available.

For the **Next 'Item to Add' **field you can choose to either reuse previously generated wildcard values, or regenerate all or only non-shared wildcards.

There are two courses in the Totara Academy about using quizzes in Totara Learn, Getting started with quizzes and Advanced quiz Using these courses you can learn more on how to use these features, see best practice, and give it a go yourself.

© Copyright 2024 Totara Learning Solutions. All rights reserved. Some content originally obtained via GPLv3 license and continues to be available under GPLv3. All other content is the sole copyright of Totara Learning Solutions.