-
MathType
-
WirisQuizzes
-
LearningLemur
-
CalcMe
-
MathPlayer
-
Store FAQ
-
VPAT for the electronic documentation
-
MathFlow
-
BF FAQ
-
Miscellaneous
-
Wiris Integrations
Create a randomized right-triangle question with tolerance
Reading time: 4minIn this tutorial, you will create a randomized geometry question where students must compute the hypotenuse of a right-angled triangle. You will learn how to:
- Generate random triangle dimensions
- Compute the hypotenuse automatically
- Accept approximate answers using tolerance
Outcome: By the end of this tutorial, your question will generate different right triangles and accept answers that are numerically close to the correct result.
Before you begin
Prerequisites
- You should be familiar with basic right-triangle geometry and have access to a LearningLemur-enabled course
- You should have completed Create a right-triangle hypotenuse question with units
Requirements
- A teacher account with permission to create questions in LearningLemur, accessed through learninglemur.com or your LMS
Step 0 — Create or open a quiz
Why: LearningLemur organises all questions inside quizzes, so creating a quiz first provides the workspace where you will add and manage your questions.
- Open LearningLemur
- Open an existing quiz or create a new one
Checkpoint: You should now see the quiz workspace with options to add questions.
Step 1 — Add a new question
Why: LearningLemur allows you to create questions either manually or with the help of AI. In this tutorial, we will create the question manually to understand how the editor works.
- Inside the quiz, click Add question
- In the creation dialog, choose Manually
- Select the Open answer question
This question type allows students to enter a mathematical expression using the math editor.
If you prefer, you can also use the AI generated option to automatically create a draft question. However, understanding the manual workflow will help you customize questions more precisely.
Checkpoint: You should see the Open Answer question editor, including fields for the title, statement, and answers.
Step 2 — Write the question statement
Why: The statement explains the problem students must solve. It will use variables instead of fixed values.
- Enter a Question title, for example: Hypotenuse of a random right triangle
- In the Question statement, write the exercise text (these letters will later be defined as random variables)

You can use the MathType editor to format mathematical expressions if needed.
Checkpoint: The question statement should display the variables (#a, #b) instead of fixed numbers.
Step 3 — Define the random variables
Why: Random variables allow LearningLemur to generate a different version of the question each time.
- Open Question settings
- Locate the Random variables section
- Add the following variables:
| Variable | Value |
|---|---|
| a | random integer from 2 to 7 in steps of 1 |
| b | random integer from 2 to 7 in steps of 1 |
These variables will define the numerators and denominators of the two fractions.

Checkpoint: The variables should appear listed in the Random variables section.
Step 4 — Define the random expression (solution)
Why: Instead of defining the answer directly, LearningLemur allows you to compute the correct result using a random expression based on the generated variables.
Define the exact expression
- In the Random variables panel, go to Random expressions
- Click Add random expression
- Create the following expression:

This expression calculates the hypotenuse using the generated values. LearningLemur evaluates expressions in exact mode by default, so results are expressed symbolically when possible.
Preview the result
- Click the Preview button next to the random expression definition
- A pop-up with a sample-generated value should be displayed

You may see results such as instead of a decimal number.
(Optional) Show the result as a decimal
In some cases, you may prefer students to see a decimal approximation instead of a symbolic expression.
- Edit the expression:
sol = 1.0 * sqrt(a^2 + b^2)Multiplying by 1.0 forces the calculation to use decimal values.
Preview again
- Click the Preview button next to the random expression definition
- A pop-up with a sample-generated value should be displayed, now showing the result in decimal form

When building randomized questions, it is recommended to compute intermediate results using Random expressions, and reference them later in the Answers section. This keeps the question logic clearer and makes the question easier to maintain and modify.
Checkpoint: The variable sol should appear under Random expressions, and the preview shows either a symbolic or decimal result depending on how the expression is defined.
Step 5 — Define the correct answer with units
Why: LearningLemur needs to know the expected solution in order to evaluate student responses.
- Scroll to the Answers section
-
In the first answer field, enter the expression
#solwith the corresponding units of measure - Mark this answer as a Correct answer

Using #sol ensures the answer corresponds to the computed result of the random expression. LearningLemur will compare student responses with this expression using the mathematical evaluation engine.
Checkpoint: You should see the answer marked as a correct answer (100%).
Step 6 — Enable units of measure
Why: LearningLemur must recognize the unit and prefix you use in the answer. Otherwise, the unit will be treated as plain text instead of a supported unit of measure.
- Open Question settings
- Go to Units of measure
- Enable the units you want to support
- Go to Unit prefixes
- Enable the prefixes you want to support
- For this example, make sure the settings allow centimetres

If it is more convenient, use the option All to select all units and don't need to look for the particular ones.
Checkpoint: The unit is now recognized by the editor in the answer field. For example, cm appears as a recognized unit instead of plain text.
Step 7 — Allow tolerance for approximate answers
Why: By default, LearningLemur evaluates answers using exact mathematical comparison. In this tutorial, we will allow answers that are numerically close to the correct result.
- Click Edit in the Evaluation options section
- Ensure Mathematically equal is selected
- In the Error Margin field, enter a tolerance value (for example,
0.1) - Choose how the tolerance is applied (you can choose between absolute error and % error)

This setting allows small differences between the student's answer and the correct result. For example, if the answer is , and we have set the tolerance to 0.1 of absolute error
| Student answer | Result |
|---|---|
| 7.81 | ✅ Correct |
| 7.76 | ✅ Correct |
| 7.92 | ❌ Incorrect |
If you want greater precision, use a smaller error margin.
Checkpoint: The evaluation summary should indicate that an error margin is defined.
Step 8 — Preview the question
Why: Previewing allows you to verify that the question generates different values and that LearningLemur evaluates the corresponding result correctly each time.
- Click Preview question
-
Note the generated values for
aandbin the question -
Try entering several answers, such as:
- the exact value (if available)
- a rounded value (e.g. 2 decimal places)
- Verify that correct answers are accepted.

LearningLemur automatically saves your changes while you edit the question. You do not need to manually save the question.
Checkpoint: Each preview can yield different triangles, and the correct answer is evaluated based on the values shown in that preview.
You're done
You have created a randomized geometry question that accepts approximate answers, in which students must compute the hypotenuse of a right triangle and include the unit in their answer. You learned how to:
- Generate random variables
- Compute results dynamically
- Accept approximate answers using tolerance
- Combine numerical evaluation with units
Next, you can continue learning with the following tutorials:
- Add partial scoring when units are missing
Troubleshooting
The same values always appear
Check that the question uses random variables and not fixed values.
Correct answers are marked as incorrect
Check that:
- The answer uses the computed expression (
#sol) - The tolerance is enabled
- The evaluation option is set to Mathematically equal, not Literally equal
Approximate answers are rejected
Check that:
- Tolerance is enabled
- The tolerance value is large enough
- The answer is expressed in the expected unit