@mmon-co/ncept-default-theory 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +73 -2
- package/dist/catalog-contract.d.ts +102 -0
- package/dist/catalog-contract.js +75 -0
- package/dist/catalog.d.ts +14 -0
- package/dist/catalog.js +164 -0
- package/dist/chat.d.ts +171 -0
- package/dist/chat.js +232 -0
- package/dist/completion.d.ts +74 -0
- package/dist/completion.js +277 -0
- package/dist/dependent-cone.d.ts +3 -0
- package/dist/dependent-cone.js +26 -0
- package/dist/diagnosis.d.ts +9 -0
- package/dist/diagnosis.js +1 -0
- package/dist/diagnostics.d.ts +25 -0
- package/dist/diagnostics.js +34 -0
- package/dist/evaluation.d.ts +33 -0
- package/dist/evaluation.js +376 -0
- package/dist/event.d.ts +7 -0
- package/dist/event.js +405 -0
- package/dist/history.d.ts +4 -0
- package/dist/history.js +61 -0
- package/dist/implementation.d.ts +184 -0
- package/dist/implementation.js +31 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +27 -0
- package/dist/messages.d.ts +167 -0
- package/dist/messages.js +56 -0
- package/dist/opening.d.ts +20 -0
- package/dist/opening.js +33 -0
- package/dist/outcomes.d.ts +143 -0
- package/dist/outcomes.js +323 -0
- package/dist/path.d.ts +19 -0
- package/dist/path.js +293 -0
- package/dist/reading.d.ts +12 -0
- package/dist/reading.js +75 -0
- package/dist/release.d.ts +1 -0
- package/dist/release.js +1 -0
- package/dist/roleplay.d.ts +17 -0
- package/dist/roleplay.js +2 -0
- package/dist/skills/sources.d.ts +12 -0
- package/dist/skills/sources.js +13 -0
- package/dist/skills.d.ts +12 -0
- package/dist/skills.js +70 -0
- package/dist/state.d.ts +316 -0
- package/dist/state.js +1309 -0
- package/dist/tags.d.ts +34 -0
- package/dist/tags.js +306 -0
- package/dist/timing.d.ts +21 -0
- package/dist/timing.js +79 -0
- package/dist/tools.d.ts +394 -0
- package/dist/tools.js +872 -0
- package/package.json +52 -4
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Demonstration, NodeRef } from "./state.js";
|
|
2
|
+
import type { ExactPatchRef, NodeId } from "@mmon-co/ncept-core/patch";
|
|
3
|
+
export { isCompletionOutcome } from "./state.js";
|
|
4
|
+
export type { CompletionOutcome } from "./state.js";
|
|
5
|
+
/** Content captured when retrieval happened, not a pointer to an editable card. */
|
|
6
|
+
export interface RecallOutcome {
|
|
7
|
+
readonly kind: "recall";
|
|
8
|
+
readonly card: {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly front: string;
|
|
11
|
+
readonly back: string;
|
|
12
|
+
readonly nodes: readonly NodeRef[];
|
|
13
|
+
};
|
|
14
|
+
readonly grade: {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly cardId: string;
|
|
17
|
+
readonly gradedAt: string;
|
|
18
|
+
readonly answer: string;
|
|
19
|
+
readonly grade: "again" | "hard" | "good" | "easy";
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface QuizOutcome {
|
|
23
|
+
readonly kind: "quiz";
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly at: string;
|
|
26
|
+
readonly node: NodeRef;
|
|
27
|
+
readonly questions: readonly {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly prompt: string;
|
|
30
|
+
readonly options: readonly {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly label: string;
|
|
33
|
+
readonly correct: boolean;
|
|
34
|
+
readonly error?: string;
|
|
35
|
+
}[];
|
|
36
|
+
}[];
|
|
37
|
+
readonly responses: readonly {
|
|
38
|
+
readonly questionId: string;
|
|
39
|
+
readonly selectedOptionId?: string;
|
|
40
|
+
readonly skipped: boolean;
|
|
41
|
+
readonly comment?: string;
|
|
42
|
+
}[];
|
|
43
|
+
}
|
|
44
|
+
export interface CheckResult {
|
|
45
|
+
readonly outcome: "shown" | "absent" | "mistaken" | "skipped";
|
|
46
|
+
readonly error?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One assessed Quizzes Playground response, with the Problem captured at open and the revision pinned there.
|
|
50
|
+
* Answer describes the response surface; grader records who judged it.
|
|
51
|
+
*/
|
|
52
|
+
export interface AttemptOutcome {
|
|
53
|
+
readonly kind: "attempt";
|
|
54
|
+
readonly problem: {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly digest: string;
|
|
57
|
+
readonly about: readonly NodeId[];
|
|
58
|
+
readonly prompt: string;
|
|
59
|
+
readonly presentation?: string;
|
|
60
|
+
readonly answer: {
|
|
61
|
+
readonly kind: "choice";
|
|
62
|
+
readonly options: readonly {
|
|
63
|
+
id: string;
|
|
64
|
+
label: string;
|
|
65
|
+
correct: boolean;
|
|
66
|
+
error?: string;
|
|
67
|
+
}[];
|
|
68
|
+
} | {
|
|
69
|
+
readonly kind: "short";
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: "text";
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: "roleplay";
|
|
74
|
+
readonly material: {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly revision: ExactPatchRef;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: "applet";
|
|
80
|
+
readonly material: {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly revision: ExactPatchRef;
|
|
83
|
+
};
|
|
84
|
+
readonly setup?: readonly {
|
|
85
|
+
readonly command: string;
|
|
86
|
+
readonly input: unknown;
|
|
87
|
+
}[];
|
|
88
|
+
readonly read: string;
|
|
89
|
+
};
|
|
90
|
+
readonly grader: {
|
|
91
|
+
readonly by: "mechanical";
|
|
92
|
+
readonly accepted?: readonly string[];
|
|
93
|
+
} | {
|
|
94
|
+
readonly by: "tutor" | "learner";
|
|
95
|
+
readonly rubric?: string;
|
|
96
|
+
} | {
|
|
97
|
+
readonly by: "checks";
|
|
98
|
+
readonly help: "pump" | "hint" | "correct";
|
|
99
|
+
readonly checks: readonly {
|
|
100
|
+
id: string;
|
|
101
|
+
about: readonly NodeId[];
|
|
102
|
+
ask: string;
|
|
103
|
+
shown: string;
|
|
104
|
+
absent: string;
|
|
105
|
+
mistaken?: Readonly<Record<string, string>>;
|
|
106
|
+
hint?: string;
|
|
107
|
+
corrections?: Readonly<Record<string, string>>;
|
|
108
|
+
}[];
|
|
109
|
+
readonly pumps: readonly {
|
|
110
|
+
text: string;
|
|
111
|
+
checks: readonly string[];
|
|
112
|
+
}[];
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/** A choice option id, a literal short/text answer, the applet query value as JSON, or a speaker-labelled roleplay transcript. */
|
|
116
|
+
readonly response: string;
|
|
117
|
+
readonly assessment: {
|
|
118
|
+
readonly correct: boolean;
|
|
119
|
+
/** Answer supplied or reference available: practice, not independent evidence. */
|
|
120
|
+
readonly aided?: true;
|
|
121
|
+
readonly dontKnow?: boolean;
|
|
122
|
+
readonly grader: "mechanical" | "tutor" | "learner" | "decision";
|
|
123
|
+
readonly feedback?: string;
|
|
124
|
+
/** Expectations: each check as the final response left it, and as it stood when help first touched it. */
|
|
125
|
+
readonly checks?: Readonly<Record<string, CheckResult>>;
|
|
126
|
+
readonly helped?: Readonly<Record<string, CheckResult>>;
|
|
127
|
+
};
|
|
128
|
+
readonly revision: ExactPatchRef;
|
|
129
|
+
}
|
|
130
|
+
export declare function isAttemptOutcome(value: unknown): value is AttemptOutcome;
|
|
131
|
+
/** Guards validate the supported payload, including the captured grading invariants. */
|
|
132
|
+
export declare function isRecallOutcome(value: unknown): value is RecallOutcome;
|
|
133
|
+
export declare function isQuizOutcome(value: unknown): value is QuizOutcome;
|
|
134
|
+
/** The existing verbatim unaided-card rule, recomputed from the attempt's content. */
|
|
135
|
+
export declare function recallUnaided(card: Pick<RecallOutcome["card"], "front" | "back">): boolean;
|
|
136
|
+
export interface OriginalAttempt {
|
|
137
|
+
readonly at: string;
|
|
138
|
+
readonly payload: Demonstration;
|
|
139
|
+
}
|
|
140
|
+
/** One demonstration per Node and help state, pinned to the revision the Problem was opened at. */
|
|
141
|
+
export declare function problemAttempts(outcome: AttemptOutcome, at: string): readonly OriginalAttempt[];
|
|
142
|
+
/** Pure scoring over captured values; no current Material or graph read can rewrite an attempt. */
|
|
143
|
+
export declare function practiceAttempts(outcome: RecallOutcome | QuizOutcome): readonly OriginalAttempt[];
|
package/dist/outcomes.js
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { isContentDigest } from "@mmon-co/ncept-core/digest";
|
|
2
|
+
import { isObservationTimestamp } from "@mmon-co/ncept-core/observations";
|
|
3
|
+
export { isCompletionOutcome } from "./state.js";
|
|
4
|
+
function object(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function text(value) {
|
|
8
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
9
|
+
}
|
|
10
|
+
const checkOutcome = (value) => value === "shown" || value === "absent" || value === "mistaken" || value === "skipped";
|
|
11
|
+
const nodeId = (value) => typeof value === "string" && /^node-.+/.test(value);
|
|
12
|
+
const exactRef = (value) => object(value) &&
|
|
13
|
+
typeof value.identity === "string" &&
|
|
14
|
+
/^patch-.+/.test(value.identity) &&
|
|
15
|
+
isContentDigest(value.digest);
|
|
16
|
+
const nodeRef = (value) => object(value) && nodeId(value.node) && exactRef(value.provenance);
|
|
17
|
+
export function isAttemptOutcome(value) {
|
|
18
|
+
if (!object(value) || value.kind !== "attempt" || !object(value.problem) || !object(value.assessment))
|
|
19
|
+
return false;
|
|
20
|
+
const { problem, assessment, response } = value;
|
|
21
|
+
const optional = (field) => field === undefined || text(field);
|
|
22
|
+
if (!text(problem.id) ||
|
|
23
|
+
!isContentDigest(problem.digest) ||
|
|
24
|
+
!Array.isArray(problem.about) ||
|
|
25
|
+
problem.about.length === 0 ||
|
|
26
|
+
!problem.about.every(nodeId) ||
|
|
27
|
+
new Set(problem.about).size !== problem.about.length ||
|
|
28
|
+
!text(problem.prompt) ||
|
|
29
|
+
!optional(problem.presentation) ||
|
|
30
|
+
typeof response !== "string" ||
|
|
31
|
+
typeof assessment.correct !== "boolean" ||
|
|
32
|
+
(assessment.aided !== undefined && assessment.aided !== true) ||
|
|
33
|
+
!optional(assessment.feedback) ||
|
|
34
|
+
(assessment.dontKnow !== undefined &&
|
|
35
|
+
(assessment.dontKnow !== true || assessment.correct !== false || assessment.grader !== "learner")) ||
|
|
36
|
+
!exactRef(value.revision))
|
|
37
|
+
return false;
|
|
38
|
+
const dontKnow = assessment.dontKnow === true;
|
|
39
|
+
const { answer, grader } = problem;
|
|
40
|
+
if (!object(answer) || !object(grader))
|
|
41
|
+
return false;
|
|
42
|
+
if (answer.kind === "choice") {
|
|
43
|
+
const options = answer.options;
|
|
44
|
+
if (grader.by !== "mechanical" ||
|
|
45
|
+
grader.accepted !== undefined ||
|
|
46
|
+
!Array.isArray(options) ||
|
|
47
|
+
!options.every((option) => object(option) &&
|
|
48
|
+
text(option.id) &&
|
|
49
|
+
text(option.label) &&
|
|
50
|
+
typeof option.correct === "boolean" &&
|
|
51
|
+
optional(option.error)) ||
|
|
52
|
+
new Set(options.map(({ id }) => id)).size !== options.length)
|
|
53
|
+
return false;
|
|
54
|
+
const chosen = options.find(({ id }) => id === response);
|
|
55
|
+
return (dontKnow ||
|
|
56
|
+
(chosen !== undefined &&
|
|
57
|
+
(assessment.grader === "tutor" ||
|
|
58
|
+
(assessment.grader === "mechanical" && chosen.correct === assessment.correct))));
|
|
59
|
+
}
|
|
60
|
+
if (answer.kind === "short")
|
|
61
|
+
return (grader.by === "mechanical" &&
|
|
62
|
+
Array.isArray(grader.accepted) &&
|
|
63
|
+
grader.accepted.length > 0 &&
|
|
64
|
+
grader.accepted.every(text) &&
|
|
65
|
+
// Natural-language assessment standards can require adjudicating the authored answer key.
|
|
66
|
+
(dontKnow || assessment.grader === "mechanical" || assessment.grader === "tutor"));
|
|
67
|
+
if (answer.kind === "applet") {
|
|
68
|
+
if (!object(answer.material) ||
|
|
69
|
+
!text(answer.material.id) ||
|
|
70
|
+
!exactRef(answer.material.revision) ||
|
|
71
|
+
!text(answer.read) ||
|
|
72
|
+
(answer.setup !== undefined &&
|
|
73
|
+
(!Array.isArray(answer.setup) ||
|
|
74
|
+
!answer.setup.every((step) => object(step) && text(step.command) && Object.hasOwn(step, "input")))))
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
else if (answer.kind === "roleplay") {
|
|
78
|
+
if (!object(answer.material) || !text(answer.material.id) || !exactRef(answer.material.revision))
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
else if (answer.kind !== "text")
|
|
82
|
+
return false;
|
|
83
|
+
if (grader.by === "tutor" || grader.by === "learner")
|
|
84
|
+
return optional(grader.rubric) && (dontKnow || assessment.grader === grader.by);
|
|
85
|
+
if (grader.by !== "checks")
|
|
86
|
+
return false;
|
|
87
|
+
const checks = grader.checks;
|
|
88
|
+
const about = new Set(Array.isArray(problem.about) ? problem.about : []);
|
|
89
|
+
if (!Array.isArray(checks) || checks.length === 0 || !Array.isArray(grader.pumps))
|
|
90
|
+
return false;
|
|
91
|
+
const valid = checks.every((c) => object(c) &&
|
|
92
|
+
text(c.id) &&
|
|
93
|
+
text(c.ask) &&
|
|
94
|
+
text(c.shown) &&
|
|
95
|
+
text(c.absent) &&
|
|
96
|
+
Array.isArray(c.about) &&
|
|
97
|
+
c.about.length > 0 &&
|
|
98
|
+
c.about.every((node) => nodeId(node) && about.has(node)));
|
|
99
|
+
const results = (value) => object(value) && Object.values(value).every((r) => object(r) && checkOutcome(r.outcome));
|
|
100
|
+
const final = assessment.checks;
|
|
101
|
+
return (valid &&
|
|
102
|
+
["pump", "hint", "correct"].includes(String(grader.help)) &&
|
|
103
|
+
(dontKnow ||
|
|
104
|
+
// Decision outages can delegate the whole assessment to the tutor.
|
|
105
|
+
assessment.grader === "tutor" ||
|
|
106
|
+
(assessment.grader === "decision" &&
|
|
107
|
+
results(final) &&
|
|
108
|
+
(assessment.helped === undefined || results(assessment.helped)) &&
|
|
109
|
+
assessment.correct ===
|
|
110
|
+
checks.every((c) => {
|
|
111
|
+
const result = object(final) ? final[c.id] : undefined;
|
|
112
|
+
return object(result) && result.outcome === "shown";
|
|
113
|
+
}))));
|
|
114
|
+
}
|
|
115
|
+
/** Guards validate the supported payload, including the captured grading invariants. */
|
|
116
|
+
export function isRecallOutcome(value) {
|
|
117
|
+
if (!object(value) || value.kind !== "recall" || !object(value.card) || !object(value.grade))
|
|
118
|
+
return false;
|
|
119
|
+
const { card, grade } = value;
|
|
120
|
+
return (text(card.id) &&
|
|
121
|
+
typeof card.front === "string" &&
|
|
122
|
+
typeof card.back === "string" &&
|
|
123
|
+
Array.isArray(card.nodes) &&
|
|
124
|
+
card.nodes.length > 0 &&
|
|
125
|
+
card.nodes.every(nodeRef) &&
|
|
126
|
+
new Set(card.nodes.map((node) => node.node)).size === card.nodes.length &&
|
|
127
|
+
text(grade.id) &&
|
|
128
|
+
grade.cardId === card.id &&
|
|
129
|
+
isObservationTimestamp(grade.gradedAt) &&
|
|
130
|
+
text(grade.answer) &&
|
|
131
|
+
typeof grade.grade === "string" &&
|
|
132
|
+
["again", "hard", "good", "easy"].includes(grade.grade) &&
|
|
133
|
+
!(grade.answer.trim() === card.back.trim() && grade.grade === "again"));
|
|
134
|
+
}
|
|
135
|
+
export function isQuizOutcome(value) {
|
|
136
|
+
if (!object(value) ||
|
|
137
|
+
value.kind !== "quiz" ||
|
|
138
|
+
!text(value.id) ||
|
|
139
|
+
!isObservationTimestamp(value.at) ||
|
|
140
|
+
!nodeRef(value.node) ||
|
|
141
|
+
!Array.isArray(value.questions) ||
|
|
142
|
+
!Array.isArray(value.responses))
|
|
143
|
+
return false;
|
|
144
|
+
if (!value.questions.every((question) => object(question) &&
|
|
145
|
+
text(question.id) &&
|
|
146
|
+
typeof question.prompt === "string" &&
|
|
147
|
+
Array.isArray(question.options) &&
|
|
148
|
+
question.options.length > 0 &&
|
|
149
|
+
question.options.every((option) => object(option) &&
|
|
150
|
+
text(option.id) &&
|
|
151
|
+
typeof option.label === "string" &&
|
|
152
|
+
typeof option.correct === "boolean" &&
|
|
153
|
+
(option.error === undefined || typeof option.error === "string")) &&
|
|
154
|
+
new Set(question.options.map((option) => option.id)).size === question.options.length))
|
|
155
|
+
return false;
|
|
156
|
+
if (!value.responses.every((response) => object(response) &&
|
|
157
|
+
text(response.questionId) &&
|
|
158
|
+
typeof response.skipped === "boolean" &&
|
|
159
|
+
(response.selectedOptionId === undefined || text(response.selectedOptionId)) &&
|
|
160
|
+
(response.comment === undefined || typeof response.comment === "string")))
|
|
161
|
+
return false;
|
|
162
|
+
const { questions, responses } = value;
|
|
163
|
+
return (responses.length === questions.length &&
|
|
164
|
+
new Set(questions.map(({ id }) => id)).size === questions.length &&
|
|
165
|
+
new Set(responses.map(({ questionId }) => questionId)).size === questions.length &&
|
|
166
|
+
questions.every((question) => {
|
|
167
|
+
const response = responses.find(({ questionId }) => questionId === question.id);
|
|
168
|
+
return (response !== undefined &&
|
|
169
|
+
(response.skipped
|
|
170
|
+
? response.selectedOptionId === undefined
|
|
171
|
+
: question.options.some(({ id }) => id === response.selectedOptionId)));
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
/** The existing verbatim unaided-card rule, recomputed from the attempt's content. */
|
|
175
|
+
export function recallUnaided(card) {
|
|
176
|
+
const normalize = (value) => value.trim().toLocaleLowerCase().replace(/\s+/g, " ");
|
|
177
|
+
const front = normalize(card.front);
|
|
178
|
+
const back = normalize(card.back);
|
|
179
|
+
const leaksAnswer = back.length > 0 && front.includes(back);
|
|
180
|
+
const offersCandidates = /(^|\n)\s*(?:[a-d][).]|[-*•])\s+/i.test(card.front) || /\bwhich of\b/i.test(card.front);
|
|
181
|
+
return !leaksAnswer && !offersCandidates;
|
|
182
|
+
}
|
|
183
|
+
function checkNote(check, { outcome, error }) {
|
|
184
|
+
if (outcome === "shown")
|
|
185
|
+
return `Shown: ${check.shown}`;
|
|
186
|
+
if (outcome === "absent")
|
|
187
|
+
return `Not taken up: ${check.absent}`;
|
|
188
|
+
if (outcome === "skipped")
|
|
189
|
+
return "Set aside: I can't say";
|
|
190
|
+
return `Mistaken (${error ?? "unnamed"}): ${(error && check.mistaken?.[error]) ?? "a wrong version"}`;
|
|
191
|
+
}
|
|
192
|
+
/** One demonstration per Node and help state, pinned to the revision the Problem was opened at. */
|
|
193
|
+
export function problemAttempts(outcome, at) {
|
|
194
|
+
const { problem, response, assessment } = outcome;
|
|
195
|
+
if (assessment.dontKnow)
|
|
196
|
+
return problem.about.map((node) => ({
|
|
197
|
+
at,
|
|
198
|
+
payload: {
|
|
199
|
+
kind: "demonstration",
|
|
200
|
+
item: problem.id,
|
|
201
|
+
node: { node, provenance: { ...outcome.revision } },
|
|
202
|
+
outcome: "dont-know",
|
|
203
|
+
unaided: !assessment.aided,
|
|
204
|
+
grader: "learner",
|
|
205
|
+
task: problem.prompt,
|
|
206
|
+
response,
|
|
207
|
+
},
|
|
208
|
+
}));
|
|
209
|
+
// Checks judged from one response are dependent evidence, not separate window entries.
|
|
210
|
+
if (problem.grader.by === "checks" && assessment.grader !== "tutor") {
|
|
211
|
+
const checksByNode = new Map();
|
|
212
|
+
for (const check of problem.grader.checks)
|
|
213
|
+
for (const node of check.about) {
|
|
214
|
+
const checks = checksByNode.get(node) ?? [];
|
|
215
|
+
checks.push(check);
|
|
216
|
+
checksByNode.set(node, checks);
|
|
217
|
+
}
|
|
218
|
+
return [...checksByNode].flatMap(([node, checks]) => {
|
|
219
|
+
const record = (beforeHelp) => {
|
|
220
|
+
const results = checks.map((check) => ({
|
|
221
|
+
check,
|
|
222
|
+
result: (beforeHelp ? assessment.helped?.[check.id] : undefined) ??
|
|
223
|
+
assessment.checks?.[check.id] ?? { outcome: "absent" },
|
|
224
|
+
}));
|
|
225
|
+
const result = results.some(({ result: { outcome } }) => outcome === "absent" || outcome === "mistaken")
|
|
226
|
+
? "failure"
|
|
227
|
+
: results.some(({ result: { outcome } }) => outcome === "skipped")
|
|
228
|
+
? "dont-know"
|
|
229
|
+
: "success";
|
|
230
|
+
return {
|
|
231
|
+
at,
|
|
232
|
+
payload: {
|
|
233
|
+
kind: "demonstration",
|
|
234
|
+
item: problem.id,
|
|
235
|
+
node: { node, provenance: { ...outcome.revision } },
|
|
236
|
+
outcome: result,
|
|
237
|
+
unaided: beforeHelp && !assessment.aided,
|
|
238
|
+
grader: result === "dont-know" ? "learner" : assessment.grader,
|
|
239
|
+
task: [problem.prompt, ...checks.map((check) => `Check: ${check.ask}`)].join("\n"),
|
|
240
|
+
response: [response, ...results.map(({ check, result }) => checkNote(check, result))].join("\n"),
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
return checks.some((check) => assessment.helped?.[check.id] !== undefined)
|
|
245
|
+
? [record(true), record(false)]
|
|
246
|
+
: [record(true)];
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const choice = problem.answer.kind === "choice" ? problem.answer.options : undefined;
|
|
250
|
+
const answer = choice?.find(({ id }) => id === response)?.label ?? response;
|
|
251
|
+
return problem.about.map((node) => ({
|
|
252
|
+
at,
|
|
253
|
+
payload: {
|
|
254
|
+
kind: "demonstration",
|
|
255
|
+
item: problem.id,
|
|
256
|
+
node: { node, provenance: { ...outcome.revision } },
|
|
257
|
+
outcome: assessment.correct ? "success" : "failure",
|
|
258
|
+
unaided: !assessment.aided,
|
|
259
|
+
grader: assessment.grader,
|
|
260
|
+
task: choice ? `${problem.prompt}\n${choice.map(({ label }) => `- ${label}`).join("\n")}` : problem.prompt,
|
|
261
|
+
response: answer,
|
|
262
|
+
},
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
/** Pure scoring over captured values; no current Material or graph read can rewrite an attempt. */
|
|
266
|
+
export function practiceAttempts(outcome) {
|
|
267
|
+
if (outcome.kind === "recall") {
|
|
268
|
+
const { card, grade } = outcome;
|
|
269
|
+
return card.nodes.map((node) => ({
|
|
270
|
+
at: grade.gradedAt,
|
|
271
|
+
payload: {
|
|
272
|
+
kind: "demonstration",
|
|
273
|
+
item: card.id,
|
|
274
|
+
node: { node: node.node, provenance: { ...node.provenance } },
|
|
275
|
+
outcome: grade.grade === "again" ? "failure" : "success",
|
|
276
|
+
unaided: recallUnaided(card),
|
|
277
|
+
grader: grade.answer.trim() === card.back.trim() ? "mechanical" : "learner",
|
|
278
|
+
task: card.front,
|
|
279
|
+
response: grade.answer,
|
|
280
|
+
},
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
return outcome.questions.flatMap((question) => {
|
|
284
|
+
const response = outcome.responses.find(({ questionId }) => questionId === question.id);
|
|
285
|
+
if (response === undefined)
|
|
286
|
+
return [];
|
|
287
|
+
if (response.skipped)
|
|
288
|
+
return [
|
|
289
|
+
{
|
|
290
|
+
at: outcome.at,
|
|
291
|
+
payload: {
|
|
292
|
+
kind: "demonstration",
|
|
293
|
+
item: question.id,
|
|
294
|
+
node: { ...outcome.node },
|
|
295
|
+
outcome: "dont-know",
|
|
296
|
+
unaided: true,
|
|
297
|
+
grader: "learner",
|
|
298
|
+
task: question.prompt,
|
|
299
|
+
response: response.comment ? `I don\u0027t know\n${response.comment}` : "I don\u0027t know",
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
];
|
|
303
|
+
const option = question.options.find(({ id }) => id === response.selectedOptionId);
|
|
304
|
+
if (option === undefined)
|
|
305
|
+
throw new Error("Invalid question response");
|
|
306
|
+
const answer = response.comment ? `${option.label}\n${response.comment}` : option.label;
|
|
307
|
+
return [
|
|
308
|
+
{
|
|
309
|
+
at: outcome.at,
|
|
310
|
+
payload: {
|
|
311
|
+
kind: "demonstration",
|
|
312
|
+
item: question.id,
|
|
313
|
+
node: { node: outcome.node.node, provenance: { ...outcome.node.provenance } },
|
|
314
|
+
outcome: option.correct ? "success" : "failure",
|
|
315
|
+
unaided: true,
|
|
316
|
+
grader: "mechanical",
|
|
317
|
+
task: `${question.prompt}\n${question.options.map((choice) => `- ${choice.label}`).join("\n")}`,
|
|
318
|
+
response: option.error === undefined ? answer : `${answer}\n${option.error}`,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
];
|
|
322
|
+
});
|
|
323
|
+
}
|
package/dist/path.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type NodeId, type ResolvedGraph } from "@mmon-co/ncept-core/patch";
|
|
2
|
+
import { type MissionPath, type MissionFuture, type PathContext } from "@mmon-co/ncept-core/theory";
|
|
3
|
+
/** Default-theory authoring metadata, not Core graph vocabulary. */
|
|
4
|
+
export declare function pathProperty(graph: ResolvedGraph, node: NodeId, key: string): unknown;
|
|
5
|
+
/** Milestones and one-off steps keep their evidence without entering Review. */
|
|
6
|
+
export declare function nodeAllowsReview(graph: ResolvedGraph, node: NodeId): boolean;
|
|
7
|
+
/** Default-theory hint: an absolute integer, higher first, inherited from tags. */
|
|
8
|
+
export declare function nodePriority(graph: ResolvedGraph, node: NodeId): number;
|
|
9
|
+
/** A topological schedule with atomic lesson groups wherever their external blockers allow it.
|
|
10
|
+
* If contraction would create a cycle, emit a ready prefix and leave the rest for after the
|
|
11
|
+
* outside blocker. Overlapping tags remain separate lessons; coverage is claimed by section,
|
|
12
|
+
* not by lesson, so a Node may be taught in more than one group.
|
|
13
|
+
*/
|
|
14
|
+
export declare function teachingPath(graph: ResolvedGraph, targets: readonly NodeId[]): MissionPath;
|
|
15
|
+
/** The syllabus stays addressable as progress changes; only the future is upcoming.
|
|
16
|
+
* A trailing unnumbered review is maintenance; a review with numberOffset 1 blocks the
|
|
17
|
+
* following teaching stop. A graph-wide reading has only maintenance, and no Mission.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pathDefault(context: PathContext): MissionFuture;
|