judgeMaths
Judges a reader's maths answer against what a question expects, and says why when it is wrong.
@internote/canvas-sdkOn this page
import { judgeMaths } from '@internote/canvas-sdk';Checks in order: the right shape, one value or a tuple, vector or matrix of the same size; only the letters the question allows; equivalent to the expectation component by component; and in the form asked for. An answer that is the right value in the wrong form is incorrect, with a message saying the value was right. An answer the sampling could not decide is indeterminate, with a message asking for it another way.
#Signature
(question: MathsExpectation, answer: {
value: MathsValue;
letters: readonly string[];
}): MathsJudgement#Parameters
questionWhat the question expects: its value, its letters and its form.
answerThe reader's answer as parsed, and the letters it uses.
#Example
const parsed = parseMathsValue(typed);
if (!parsed.ok) return;
const judgement = judgeMaths({ expect, variables: ['x'], form: { kind: 'simplified' } }, { value: parsed.value, letters: parsed.letters });
if (judgement.verdict !== 'correct') show(judgement.message);Declared in packages/canvas-sdk/src/assess/judge.ts:377.