Skip to content
Classroom

Number Question Type

Students enter a single numerical value (integer or decimal).

Basic Syntax

[number]
answer = 42;

Options

answer (required)

The correct numerical value students must match.

$result = 15 * 3;
[number]
answer = $result;  // 45

tolerance

Acceptable deviation from the correct answer. Useful for rounding or measurement scenarios.

[number]
answer = 3.14159;
tolerance = 0.01;  // Accept 3.13 to 3.15

type

  • real (default) — Decimal numbers (3.5, -2.1, etc.)
  • integer — Whole numbers only (42, -7, etc.)
[number]
answer = 10;
type = integer;

displayformat

Controls how the answer is displayed to students: - 1 — Standard: 3.5 - 2 — Percent: 350% - 3 — Fraction: 7/2

$answer = 0.75;
[number]
answer = $answer;
displayformat = 2;  // Shows as 75%

showpreview

Display a preview box before submission (default: true).

[number]
answer = 25;
showpreview = false;

Examples

Simple Integer Answer

$num1 = rand(5, 10);
$num2 = rand(3, 8);
$answer = $num1 + $num2;

What is $num1 + $num2?

[number]
answer = $answer;
tolerance = 0;

Percentage with Tolerance

$total = 200;
$part = 50;
$percentage = ($part / $total) * 100;

If a class has $total students and $part are absent, what percentage is absent?

[number]
answer = $percentage;
tolerance = 0.1;
displayformat = 2;

Decimal Approximation

$result = sqrt(7);

Approximate √7 to 2 decimal places.

[number]
answer = $result;
tolerance = 0.01;

Grading

The system checks if the student's answer falls within the tolerance range: - Student enters 42.5, answer is 42, tolerance is 0.6 → Correct (within 42 ± 0.6) - Student enters 43, answer is 42, tolerance is 0.6 → Incorrect (43 > 42.6)

See Also