Marking answers

How a question’s answer is judged: a maths answer against its expected value and form, a text answer against its accepted strings, and a choice scored by the options picked.

@internote/canvas-sdk12 exports

#Functions

equivalent
packages/canvas-sdk/src/assess/judge.ts:98
Whether two expressions take the same value everywhere both are defined: true, false, or undefined when too few sampled points were defined on both sides to say.
(a: MathsNode, b: MathsNode): boolean | undefined
judgeChoice
packages/canvas-sdk/src/assess/judge.ts:369
Judges a choice from the indices the reader selected and the indices of the correct options.
(
    selected: readonly number[],
    correct: readonly number[],
    multiple: boolean,
): ChoiceJudgement

With one correct option and multiple off, only that option is right. With multiple, the fraction is correct picks minus wrong picks over the number of correct options, floored at zero, so selecting everything scores nothing.

judgeMaths
packages/canvas-sdk/src/assess/judge.ts:285
Judges a reader's maths answer against what a question expects: the right shape (one value or a tuple of the same length), only the letters the question allows, equivalent component by component, and in the form asked for.
(question: MathsExpectation, answer: {
    value: MathsValue;
    letters: readonly string[];
}): MathsJudgement
judgeText
packages/canvas-sdk/src/assess/judge.ts:347
Judges a text answer: correct when, ignoring case and surrounding or repeated whitespace, it matches any one of the accepted strings.
correctincorrect
parseMathsForm
packages/canvas-sdk/src/assess/index.ts:19
Parses a form: value — exact, simplified or rounded(n) with n a whole number from 0 to 10 — into a MathsForm, or returns the reason it could not be read.
(text: string): { ok: true; form: MathsForm; } | { ok: false; error: string; }
roundedAnswerText
packages/canvas-sdk/src/assess/judge.ts:198
A number expectation written to places decimal places — the answer a rounded(n) question wants — as LaTeX: 8.06, (1.00, 2.50) for a tuple, a column for a vector.
(expect: MathsValue, places: number): string | null

#Interfaces

ChoiceJudgement
packages/canvas-sdk/src/assess/judge.ts:353
The verdict on a choice, and the fraction of it that was right.
fractionRequired
How much of the answer was right, from 0 to 1 — what score is marks times.
number
verdictRequired
correct, partial or incorrect.
correctpartialincorrect
MathsExpectation
packages/canvas-sdk/src/assess/judge.ts:35
What a maths question expects, read from its compiled attributes.
expectRequired
The right answer, parsed.
MathsValue
form
The form the answer must be written in, when the question asks for one.
MathsForm
variablesRequired
The letters an answer may use.
readonly string[]

#Types

MathsForm
packages/canvas-sdk/src/assess/judge.ts:29
The form a maths answer must be written in, as form: declares it.
{
    kind: "exact";
} | {
    kind: "simplified";
} | {
    kind: "rounded";
    places: number;
}
MathsJudgement
packages/canvas-sdk/src/assess/judge.ts:48
The verdict on one maths answer, with a sentence for the reader when it is not correct.
{
    verdict: "correct";
} | {
    verdict: "incorrect";
    reason: MathsReason;
    message: string;
} | {
    verdict: "indeterminate";
    message: string;
}
MathsReason
packages/canvas-sdk/src/assess/judge.ts:45
Why a maths answer was judged incorrect.
not-equivalentwrong-shapewrong-formstray-letter
Verdict
packages/canvas-sdk/src/assess/judge.ts:26
Where a question stands: not yet answered, or the verdict on its last answer.
unansweredcorrectpartialincorrectindeterminate

Last updated