@mmon-co/ncept-default-theory 3.0.9 → 3.0.11

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.
@@ -28,6 +28,20 @@ export interface CheckResult {
28
28
  readonly outcome: "shown" | "absent" | "mistaken" | "skipped";
29
29
  readonly error?: string;
30
30
  }
31
+ type OutcomeCheck = {
32
+ readonly id: string;
33
+ readonly about: readonly NodeId[];
34
+ readonly hint?: string;
35
+ } & ({
36
+ readonly kind: "test";
37
+ readonly correction?: string;
38
+ } | {
39
+ readonly ask: string;
40
+ readonly shown: string;
41
+ readonly absent: string;
42
+ readonly mistaken?: Readonly<Record<string, string>>;
43
+ readonly corrections?: Readonly<Record<string, string>>;
44
+ });
31
45
  /**
32
46
  * One assessed Problem response, with its content and revision captured before grading.
33
47
  * Answer describes the response surface; grader records who judged it.
@@ -52,6 +66,13 @@ export interface AttemptOutcome {
52
66
  readonly kind: "short";
53
67
  } | {
54
68
  readonly kind: "text";
69
+ } | {
70
+ readonly kind: "code";
71
+ readonly material?: {
72
+ readonly id: string;
73
+ readonly revision: ExactPatchRef;
74
+ };
75
+ readonly feedback?: "on-run" | "on-submit" | "hidden";
55
76
  } | {
56
77
  readonly kind: "roleplay";
57
78
  readonly material: {
@@ -85,23 +106,14 @@ export interface AttemptOutcome {
85
106
  } | {
86
107
  readonly by: "checks";
87
108
  readonly help: "pump" | "hint" | "correct";
88
- readonly checks: readonly {
89
- id: string;
90
- about: readonly NodeId[];
91
- ask: string;
92
- shown: string;
93
- absent: string;
94
- mistaken?: Readonly<Record<string, string>>;
95
- hint?: string;
96
- corrections?: Readonly<Record<string, string>>;
97
- }[];
109
+ readonly checks: readonly OutcomeCheck[];
98
110
  readonly pumps: readonly {
99
111
  text: string;
100
112
  checks: readonly string[];
101
113
  }[];
102
114
  };
103
115
  };
104
- /** A choice option id, a literal short/text answer, the applet query value as JSON, or a speaker-labelled roleplay transcript. */
116
+ /** A choice key, literal short/text answer, applet query JSON, roleplay transcript, or visible code submission JSON. */
105
117
  readonly response: string;
106
118
  readonly assessment: {
107
119
  readonly correct: boolean;
package/dist/outcomes.js CHANGED
@@ -92,6 +92,16 @@ export function isAttemptOutcome(value) {
92
92
  if (!object(answer.material) || !text(answer.material.id) || !exactRef(answer.material.revision))
93
93
  return false;
94
94
  }
95
+ else if (answer.kind === "code") {
96
+ if (answer.material !== undefined &&
97
+ (!object(answer.material) || !text(answer.material.id) || !exactRef(answer.material.revision)))
98
+ return false;
99
+ if (answer.feedback !== undefined &&
100
+ answer.feedback !== "on-run" &&
101
+ answer.feedback !== "on-submit" &&
102
+ answer.feedback !== "hidden")
103
+ return false;
104
+ }
95
105
  else if (answer.kind !== "text")
96
106
  return false;
97
107
  if (grader.by === "tutor" || grader.by === "learner")
@@ -104,9 +114,9 @@ export function isAttemptOutcome(value) {
104
114
  return false;
105
115
  const valid = checks.every((c) => object(c) &&
106
116
  text(c.id) &&
107
- text(c.ask) &&
108
- text(c.shown) &&
109
- text(c.absent) &&
117
+ (c.kind === "test"
118
+ ? answer.kind === "code"
119
+ : c.kind === undefined && text(c.ask) && text(c.shown) && text(c.absent)) &&
110
120
  Array.isArray(c.about) &&
111
121
  c.about.length > 0 &&
112
122
  c.about.every((node) => nodeId(node) && about.has(node)));
@@ -117,7 +127,7 @@ export function isAttemptOutcome(value) {
117
127
  (dontKnow ||
118
128
  // Decision outages can delegate the whole assessment to the tutor.
119
129
  assessment.grader === "tutor" ||
120
- (assessment.grader === "decision" &&
130
+ (assessment.grader === (checks.every((c) => c.kind === "test") ? "mechanical" : "decision") &&
121
131
  results(final) &&
122
132
  (assessment.helped === undefined || results(assessment.helped)) &&
123
133
  assessment.correct ===
@@ -166,6 +176,8 @@ export function isQuizOutcome(value) {
166
176
  }));
167
177
  }
168
178
  function checkNote(check, { outcome, error }) {
179
+ if ("kind" in check)
180
+ return `${check.id}: ${outcome === "shown" ? "passed" : "failed"}`;
169
181
  if (outcome === "shown")
170
182
  return `Shown: ${check.shown}`;
171
183
  if (outcome === "absent")
@@ -221,8 +233,12 @@ export function problemAttempts(outcome, at) {
221
233
  outcome: result,
222
234
  unaided: beforeHelp && !assessment.aided,
223
235
  grader: result === "dont-know" ? "learner" : assessment.grader,
224
- task: [problem.prompt, ...checks.map((check) => `Check: ${check.ask}`)].join("\n"),
225
- response: [response, ...results.map(({ check, result }) => checkNote(check, result))].join("\n"),
236
+ task: problem.answer.kind === "code" && problem.answer.feedback === "hidden"
237
+ ? problem.prompt
238
+ : [problem.prompt, ...checks.map((check) => `Check: ${"kind" in check ? check.id : check.ask}`)].join("\n"),
239
+ response: problem.answer.kind === "code" && problem.answer.feedback === "hidden"
240
+ ? response
241
+ : [response, ...results.map(({ check, result }) => checkNote(check, result))].join("\n"),
226
242
  },
227
243
  };
228
244
  };
package/dist/release.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const theoryContent = "d14acd00c2b3352ea6374ef8920830c15cbbef017043d899f74dece8f52a0e39";
1
+ export declare const theoryContent = "922d7ffb3c3f3e6b626b32d62e008d20a427e222a12489ebeef02132349bd1ad";
package/dist/release.js CHANGED
@@ -1 +1 @@
1
- export const theoryContent = "d14acd00c2b3352ea6374ef8920830c15cbbef017043d899f74dece8f52a0e39";
1
+ export const theoryContent = "922d7ffb3c3f3e6b626b32d62e008d20a427e222a12489ebeef02132349bd1ad";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmon-co/ncept-default-theory",
3
- "version": "3.0.9",
3
+ "version": "3.0.11",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "repository": {
6
6
  "type": "git",