Skip to content
Classroom

Calculated

Answer type: calculated

The student types a numeric answer: a number, or an arithmetic expression such as 3/4, 2^5 or sqrt(2)/2. It is graded by evaluating it to a number and comparing that with the value of $answer (relative tolerance 0.0015 unless you set one), so any arithmetically equivalent form is accepted.

No variables

$answer and the student's entry must both evaluate to a number. An $answer such as "2*x + 3" cannot be evaluated, so every response, including 2*x+3 itself, scores 0. For an answer that is an expression in x, use Function (numfunc) with $variables = "x".

The minimum

Common Control:

$answer = "3/4"

3/4, 0.75, 6/8 and 1.5/2 all evaluate to 0.75 and are all accepted. Use this type whenever the form of the value is not what you are assessing; when it is, add $answerformat flags.

No [calculated] section, and no simplify option

Earlier versions of this page showed [calculated], answer = x^2 + 1; and simplify = full;. None of it exists. The type is chosen in the editor, options are plain $ variables, and there is no simplify option. To require a simplified form, use $answerformat, for example "reducedfraction".

Options

Variable Effect
$answer the correct expression — required
$abstolerance / $reltolerance grading tolerance
$reqdecimals grade to N decimal places: unless you set $abstolerance or $reltolerance, it sets $abstolerance to 0.5×10⁻ᴺ (2 → 0.005) and adds an "accurate to N decimal places" entry tip; the number of decimals typed is not checked
$reqsigfigs required significant figures, enforced only when $answerformat includes decimal, scinot or scinotordec
$requiretimes symbol-count rules the typed answer must satisfy, e.g. "^,=0"
$requiretimeslistpart the same kind of rule, checked against each entry of a list answer separately
$answerformat accepted-format flags
$displayformat "point" wraps the input box in ( ), "vector" in < >
$formatfeedbackon set to 1 to flag a correct value in the wrong format (it still scores 0)
$ansprompt text before the input box
$answerboxsize width of the input box
$hidepreview hide the live preview

$requiretimes

A quoted string of symbol, rule pairs checked against what the student typed; if a rule fails, the answer scores 0 even when its value is right. It does not change how the entry is read. To make students evaluate a power rather than copy it:

$answer = 32
$requiretimes = "^,=0"

32 and 16*2 are accepted; 2^5 has the right value but scores 0. A bare number such as $requiretimes = 1 is not a valid rule and is ignored.

$formatfeedbackon

A correct value in the wrong format, for example 0.75 where $answerformat = "reducedfraction" asked for 3/4, scores 0. Set $formatfeedbackon = 1 so the box is marked orange instead of red and the student can see that only the form was wrong, and state the required form in qtext.

Example

Common Control — setup:

$b, $d = diffrands(2, 9, 2)
$a = rand(1, $b - 1)
$c = rand(1, $d - 1)
$sum = makereducedfraction($a*$d + $c*$b, $b*$d)

Question Text:

<p>Add `$a/$b + $c/$d`. Write your answer in lowest terms.</p>

Common Control, continued — answer and options:

$answer = $sum
$answerformat = "reducedfraction,allowmixed"
$formatfeedbackon = 1

The sum in lowest terms scores full marks. An unreduced fraction or a decimal has the right value but the wrong form: it scores 0, and $formatfeedbackon marks the box orange instead of red so the student can see why.

See Also

  • Number — when the student must type a plain number, not a calculation such as 3/4
  • Function — when it is a function compared across a domain
  • Math Entry — what students can type