@pie-qti/assessment-player 1.0.0-beta.3 → 1.0.0-beta.5

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.
Files changed (134) hide show
  1. package/README.md +28 -7
  2. package/dist/components/createPlayerConnection.svelte.d.ts +90 -0
  3. package/dist/components/createPlayerConnection.svelte.js +151 -0
  4. package/dist/components/createPlayerConnection.svelte.js.map +1 -0
  5. package/dist/components/displaySettings.svelte.d.ts +23 -0
  6. package/dist/components/displaySettings.svelte.js +40 -0
  7. package/dist/components/displaySettings.svelte.js.map +1 -0
  8. package/dist/components/srOnly.d.ts +29 -0
  9. package/dist/components/srOnly.js +55 -0
  10. package/dist/components/srOnly.js.map +1 -0
  11. package/dist/components/submitDialogAction.d.ts +25 -0
  12. package/dist/components/submitDialogAction.js +89 -0
  13. package/dist/components/submitDialogAction.js.map +1 -0
  14. package/dist/core/AssessmentPlayer.d.ts +1102 -53
  15. package/dist/core/AssessmentPlayer.js +2836 -457
  16. package/dist/core/AssessmentPlayer.js.map +1 -1
  17. package/dist/core/AssessmentSessionCoordinator.d.ts +76 -7
  18. package/dist/core/AssessmentSessionCoordinator.js +185 -10
  19. package/dist/core/AssessmentSessionCoordinator.js.map +1 -1
  20. package/dist/core/AutosaveManager.d.ts +104 -0
  21. package/dist/core/AutosaveManager.js +181 -0
  22. package/dist/core/AutosaveManager.js.map +1 -0
  23. package/dist/core/ItemSessionController.d.ts +17 -26
  24. package/dist/core/ItemSessionController.js +33 -73
  25. package/dist/core/ItemSessionController.js.map +1 -1
  26. package/dist/core/NavigationManager.d.ts +18 -50
  27. package/dist/core/NavigationManager.js +21 -83
  28. package/dist/core/NavigationManager.js.map +1 -1
  29. package/dist/core/TimeManager.d.ts +62 -16
  30. package/dist/core/TimeManager.js +148 -57
  31. package/dist/core/TimeManager.js.map +1 -1
  32. package/dist/core/autosave.d.ts +44 -0
  33. package/dist/core/autosave.js +46 -0
  34. package/dist/core/autosave.js.map +1 -0
  35. package/dist/core/deliveryStructure.d.ts +54 -0
  36. package/dist/core/deliveryStructure.js +72 -0
  37. package/dist/core/deliveryStructure.js.map +1 -0
  38. package/dist/core/errors.d.ts +116 -0
  39. package/dist/core/errors.js +77 -0
  40. package/dist/core/errors.js.map +1 -0
  41. package/dist/core/exitBoundaries.d.ts +64 -0
  42. package/dist/core/exitBoundaries.js +98 -0
  43. package/dist/core/exitBoundaries.js.map +1 -0
  44. package/dist/core/feedback.d.ts +46 -0
  45. package/dist/core/feedback.js +47 -0
  46. package/dist/core/feedback.js.map +1 -0
  47. package/dist/core/formatTime.d.ts +8 -0
  48. package/dist/core/formatTime.js +20 -0
  49. package/dist/core/formatTime.js.map +1 -0
  50. package/dist/core/index.d.ts +7 -4
  51. package/dist/core/index.js +4 -1
  52. package/dist/core/index.js.map +1 -1
  53. package/dist/core/navigationPolicy.d.ts +46 -0
  54. package/dist/core/navigationPolicy.js +66 -0
  55. package/dist/core/navigationPolicy.js.map +1 -0
  56. package/dist/core/pause.d.ts +58 -0
  57. package/dist/core/pause.js +101 -0
  58. package/dist/core/pause.js.map +1 -0
  59. package/dist/core/playerEvents.d.ts +51 -0
  60. package/dist/core/playerEvents.js +66 -0
  61. package/dist/core/playerEvents.js.map +1 -0
  62. package/dist/core/reviewState.d.ts +81 -0
  63. package/dist/core/reviewState.js +113 -0
  64. package/dist/core/reviewState.js.map +1 -0
  65. package/dist/core/reviewViews.d.ts +43 -0
  66. package/dist/core/reviewViews.js +88 -0
  67. package/dist/core/reviewViews.js.map +1 -0
  68. package/dist/core/scopeLocks.d.ts +36 -0
  69. package/dist/core/scopeLocks.js +78 -0
  70. package/dist/core/scopeLocks.js.map +1 -0
  71. package/dist/core/sessionRecords.d.ts +31 -0
  72. package/dist/core/sessionRecords.js +74 -0
  73. package/dist/core/sessionRecords.js.map +1 -0
  74. package/dist/core/submissionPolicy.d.ts +65 -0
  75. package/dist/core/submissionPolicy.js +71 -0
  76. package/dist/core/submissionPolicy.js.map +1 -0
  77. package/dist/core/templateDefaults.d.ts +26 -0
  78. package/dist/core/templateDefaults.js +54 -0
  79. package/dist/core/templateDefaults.js.map +1 -0
  80. package/dist/core/testStructure.d.ts +118 -3
  81. package/dist/core/testStructure.js +255 -6
  82. package/dist/core/testStructure.js.map +1 -1
  83. package/dist/core/timePolicy.d.ts +40 -0
  84. package/dist/core/timePolicy.js +106 -0
  85. package/dist/core/timePolicy.js.map +1 -0
  86. package/dist/index.d.ts +7 -4
  87. package/dist/index.js +5 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/integration/ReferenceBackendAdapter.d.ts +64 -101
  90. package/dist/integration/ReferenceBackendAdapter.js +214 -1033
  91. package/dist/integration/ReferenceBackendAdapter.js.map +1 -1
  92. package/dist/integration/api-contract.d.ts +175 -10
  93. package/dist/integration/api-contract.js.map +1 -1
  94. package/dist/integration/assessment-item-scorer.d.ts +56 -5
  95. package/dist/integration/assessment-item-scorer.js +116 -13
  96. package/dist/integration/assessment-item-scorer.js.map +1 -1
  97. package/dist/integration/index.d.ts +2 -2
  98. package/dist/integration/index.js +1 -1
  99. package/dist/integration/index.js.map +1 -1
  100. package/dist/integration/qti-test-parser.d.ts +44 -0
  101. package/dist/integration/qti-test-parser.js +558 -0
  102. package/dist/integration/qti-test-parser.js.map +1 -0
  103. package/dist/integration/session-store.d.ts +54 -0
  104. package/dist/integration/session-store.js +75 -0
  105. package/dist/integration/session-store.js.map +1 -0
  106. package/dist/integration/test-navigation.d.ts +23 -0
  107. package/dist/integration/test-navigation.js +32 -0
  108. package/dist/integration/test-navigation.js.map +1 -0
  109. package/dist/integration/toSectionComposition.js +8 -1
  110. package/dist/integration/toSectionComposition.js.map +1 -1
  111. package/dist/reporting/index.d.ts +3 -0
  112. package/dist/reporting/index.js +3 -0
  113. package/dist/reporting/index.js.map +1 -0
  114. package/dist/reporting/inferBaseType.d.ts +13 -0
  115. package/dist/reporting/inferBaseType.js +26 -0
  116. package/dist/reporting/inferBaseType.js.map +1 -0
  117. package/dist/reporting/serializeAssessmentResult.d.ts +27 -0
  118. package/dist/reporting/serializeAssessmentResult.js +377 -0
  119. package/dist/reporting/serializeAssessmentResult.js.map +1 -0
  120. package/dist/reporting/toAssessmentResultXml.d.ts +39 -0
  121. package/dist/reporting/toAssessmentResultXml.js +304 -0
  122. package/dist/reporting/toAssessmentResultXml.js.map +1 -0
  123. package/dist/reporting/types.d.ts +85 -0
  124. package/dist/reporting/types.js +8 -0
  125. package/dist/reporting/types.js.map +1 -0
  126. package/dist/types/index.d.ts +96 -9
  127. package/dist/types/index.js.map +1 -1
  128. package/package.json +18 -14
  129. package/dist/core/StatePersistenceManager.d.ts +0 -125
  130. package/dist/core/StatePersistenceManager.js +0 -268
  131. package/dist/core/StatePersistenceManager.js.map +0 -1
  132. package/dist/utils/PerformanceMonitor.d.ts +0 -114
  133. package/dist/utils/PerformanceMonitor.js +0 -172
  134. package/dist/utils/PerformanceMonitor.js.map +0 -1
@@ -0,0 +1,304 @@
1
+ import { childElements, durationSecondsFromMilliseconds, getAttr, parseXml } from '@pie-qti/qti-processing';
2
+ import { deliveredItems } from '../core/testStructure.js';
3
+ import { inferBaseType } from './inferBaseType.js';
4
+ import { serializeAssessmentResult } from './serializeAssessmentResult.js';
5
+ /**
6
+ * Writes the assessment's results as a QTI Results Reporting `assessmentResult` document (QTI 2.2
7
+ * or 3.0, per `options.version`).
8
+ *
9
+ * The test result carries the test outcomes, typed by the test's outcome declarations, and the
10
+ * built-in `duration` response variables of the test, each test part and each section
11
+ * (`PART.duration`, `SECTION.duration`), in seconds. Each item with recorded data gets an item
12
+ * result in delivery order, with its `sequenceIndex`, its `sessionStatus` derived from the session
13
+ * lifecycle and scoring, its response, outcome, template and (QTI 3.0) context variables, the
14
+ * built-in `numAttempts` and `duration` (seconds) response variables, and the candidate comment.
15
+ * Item session snapshots give variables their types; the item's declarations fill in where a
16
+ * snapshot is missing.
17
+ */
18
+ export function toAssessmentResultXml(results, options) {
19
+ return serializeAssessmentResult(buildAssessmentResultReport(results, options), options);
20
+ }
21
+ /** The Results Reporting model `toAssessmentResultXml` writes, for hosts that adjust it first. */
22
+ export function buildAssessmentResultReport(results, options = {}) {
23
+ const { assessment, state, finalized } = results;
24
+ const itemScores = { ...(state.itemScores ?? {}), ...(finalized?.itemScores ?? {}) };
25
+ const itemXmlById = new Map();
26
+ const ordered = deliveredItems(assessment).map(({ item }, index) => {
27
+ itemXmlById.set(item.identifier, item.itemXml);
28
+ return { identifier: item.identifier, sequenceIndex: index + 1 };
29
+ });
30
+ const known = new Set(ordered.map((item) => item.identifier));
31
+ for (const identifier of [
32
+ ...Object.keys(state.itemSessions ?? {}),
33
+ ...Object.keys(itemScores),
34
+ ...Object.keys(state.itemResponses ?? {}),
35
+ ]) {
36
+ if (!known.has(identifier)) {
37
+ known.add(identifier);
38
+ ordered.push({ identifier });
39
+ }
40
+ }
41
+ const itemResults = [];
42
+ for (const { identifier, sequenceIndex } of ordered) {
43
+ const item = itemResultData(identifier, state, itemScores[identifier]);
44
+ if (!item)
45
+ continue;
46
+ itemResults.push({
47
+ identifier,
48
+ ...(sequenceIndex === undefined ? {} : { sequenceIndex }),
49
+ datestamp: itemDatestamp(item, options.datestamp ?? finalized?.finalizedAt),
50
+ sessionStatus: sessionStatus(item),
51
+ variables: itemVariables(item, readDeclarations(itemXmlById.get(identifier)), options.includeCorrectResponses === true),
52
+ ...(state.itemComments?.[identifier] !== undefined ? { candidateComment: state.itemComments[identifier] } : {}),
53
+ });
54
+ }
55
+ return {
56
+ context: {
57
+ ...(options.candidateSourcedId !== undefined ? { sourcedId: options.candidateSourcedId } : {}),
58
+ ...(options.sessionIdentifiers ? { sessionIdentifiers: options.sessionIdentifiers } : {}),
59
+ },
60
+ testResult: {
61
+ identifier: assessment.identifier,
62
+ datestamp: options.datestamp ?? finalized?.finalizedAt ?? Date.now(),
63
+ variables: testVariables(assessment, state, results.outcomes ?? finalized?.outcomes),
64
+ },
65
+ itemResults,
66
+ };
67
+ }
68
+ // ---------------------------------------------------------------------------------------------
69
+ // Test result
70
+ // ---------------------------------------------------------------------------------------------
71
+ function testVariables(assessment, state, outcomes) {
72
+ const timing = state.timing;
73
+ const variables = [durationVariable('duration', timing?.totalTime)];
74
+ for (const [part, milliseconds] of Object.entries(timing?.testPartTimes ?? {})) {
75
+ variables.push(durationVariable(`${part}.duration`, milliseconds));
76
+ }
77
+ for (const [section, milliseconds] of Object.entries(timing?.sectionTimes ?? {})) {
78
+ variables.push(durationVariable(`${section}.duration`, milliseconds));
79
+ }
80
+ const declarations = new Map((assessment.outcomeDeclarations ?? []).map((declaration) => [declaration.identifier, declaration]));
81
+ for (const [identifier, value] of Object.entries(outcomes ?? {})) {
82
+ const declaration = declarations.get(identifier);
83
+ const cardinality = asCardinality(declaration?.cardinality) ?? inferCardinality(value);
84
+ variables.push({
85
+ kind: 'outcome',
86
+ identifier,
87
+ cardinality,
88
+ ...(cardinality === 'record' ? {} : { baseType: asBaseType(declaration?.baseType) ?? inferBaseType(value) }),
89
+ value,
90
+ });
91
+ }
92
+ return variables;
93
+ }
94
+ function durationVariable(identifier, milliseconds) {
95
+ return {
96
+ kind: 'response',
97
+ identifier,
98
+ cardinality: 'single',
99
+ baseType: 'duration',
100
+ value: durationSecondsFromMilliseconds(Number(milliseconds) || 0),
101
+ };
102
+ }
103
+ /** The recorded data of one item; undefined for an item nothing was recorded for. */
104
+ function itemResultData(identifier, state, scoring) {
105
+ const session = state.itemSessions?.[identifier];
106
+ const responses = state.itemResponses?.[identifier];
107
+ const sessionState = state.itemSessionStates?.[identifier];
108
+ if (!session && !scoring && !responses && !sessionState)
109
+ return undefined;
110
+ const durationMs = session?.duration ?? state.timing?.itemTimes?.[identifier];
111
+ return { identifier, session, scoring, responses, sessionState, ...(durationMs === undefined ? {} : { durationMs }) };
112
+ }
113
+ /**
114
+ * The Results Reporting session status: `final` once response processing has scored the latest
115
+ * submission, `pendingSubmission` while the candidate works (including edits newer than the last
116
+ * scored submission), `pendingResponseProcessing` for a submission not yet scored, and `initial`
117
+ * for an item with no attempt and no response.
118
+ */
119
+ function sessionStatus({ session, scoring, responses, sessionState }) {
120
+ const lifecycle = session?.lifecycleStatus;
121
+ const working = lifecycle === 'interacting' || lifecycle === 'suspended' || lifecycle === 'initial';
122
+ if (scoring) {
123
+ const savedAt = session ? Date.parse(session.savedAt) : Number.NaN;
124
+ const submittedAt = sessionState?.lastSubmissionTime;
125
+ const editedSince = working && submittedAt !== undefined && Number.isFinite(savedAt) && savedAt > submittedAt;
126
+ return editedSince ? 'pendingSubmission' : 'final';
127
+ }
128
+ if (lifecycle && !working)
129
+ return 'final';
130
+ if (sessionState?.isSubmitted)
131
+ return 'pendingResponseProcessing';
132
+ const attempts = sessionState?.attemptCount ?? session?.numAttempts ?? 0;
133
+ const responded = Object.values(responses ?? valuesOf(session?.responseVariables)).some(hasValue);
134
+ return attempts === 0 && !responded ? 'initial' : 'pendingSubmission';
135
+ }
136
+ /** When the item's latest recorded data was recorded: its last submission or its session snapshot. */
137
+ function itemDatestamp(item, fallback) {
138
+ const submittedAt = item.sessionState?.lastSubmissionTime;
139
+ const savedAt = item.session ? Date.parse(item.session.savedAt) : Number.NaN;
140
+ const times = [submittedAt, Number.isFinite(savedAt) ? savedAt : undefined].filter((time) => typeof time === 'number' && Number.isFinite(time));
141
+ return times.length > 0 ? Math.max(...times) : (fallback ?? Date.now());
142
+ }
143
+ const BUILT_IN_RESPONSES = new Set(['numAttempts', 'duration']);
144
+ function itemVariables(item, declarations, includeCorrectResponses) {
145
+ const { session, scoring, responses, sessionState } = item;
146
+ const variables = [];
147
+ // Built-in response variables: numAttempts, and duration in seconds.
148
+ const numAttempts = sessionState?.attemptCount ??
149
+ (typeof scoring?.outcomeValues?.numAttempts === 'number' ? scoring.outcomeValues.numAttempts : undefined) ??
150
+ session?.numAttempts ??
151
+ 0;
152
+ variables.push({ kind: 'response', identifier: 'numAttempts', cardinality: 'single', baseType: 'integer', value: numAttempts });
153
+ if (item.durationMs !== undefined)
154
+ variables.push(durationVariable('duration', item.durationMs));
155
+ // Response variables: the latest recorded responses, typed by the session or the declarations.
156
+ const responseIds = new Set([...Object.keys(session?.responseVariables ?? {}), ...Object.keys(responses ?? {})]);
157
+ for (const identifier of responseIds) {
158
+ if (BUILT_IN_RESPONSES.has(identifier))
159
+ continue;
160
+ const serialized = session?.responseVariables?.[identifier];
161
+ const value = responses && identifier in responses ? responses[identifier] : serialized?.value;
162
+ const correct = includeCorrectResponses ? scoring?.correctResponse?.[identifier] : undefined;
163
+ variables.push({
164
+ kind: 'response',
165
+ ...typed(identifier, value, serialized, declarations.get(identifier)),
166
+ ...(correct === undefined ? {} : { correctResponse: correct }),
167
+ });
168
+ }
169
+ // Outcome variables: the scored outcomes, else the session's.
170
+ const outcomeValues = { ...(scoring?.outcomeValues ?? valuesOf(session?.outcomeVariables)) };
171
+ if (!('completionStatus' in outcomeValues) && session?.completionStatus) {
172
+ outcomeValues.completionStatus = session.completionStatus;
173
+ }
174
+ for (const [identifier, value] of Object.entries(outcomeValues)) {
175
+ if (BUILT_IN_RESPONSES.has(identifier))
176
+ continue;
177
+ const declaration = declarations.get(identifier);
178
+ const outcome = {
179
+ kind: 'outcome',
180
+ ...typed(identifier, value, session?.outcomeVariables?.[identifier], declaration, BUILT_IN_OUTCOMES[identifier]),
181
+ ...(declaration?.outcome ?? {}),
182
+ };
183
+ variables.push(outcome);
184
+ }
185
+ for (const serialized of Object.values(session?.templateVariables ?? {})) {
186
+ variables.push({ kind: 'template', ...typed(serialized.identifier, serialized.value, serialized) });
187
+ }
188
+ for (const serialized of Object.values(session?.contextVariables ?? {})) {
189
+ if (BUILT_IN_RESPONSES.has(serialized.identifier) || serialized.identifier === 'completionStatus')
190
+ continue;
191
+ variables.push({ kind: 'context', ...typed(serialized.identifier, serialized.value, serialized) });
192
+ }
193
+ return variables;
194
+ }
195
+ /** The built-in outcomes' declarations, for results without a session snapshot. */
196
+ const BUILT_IN_OUTCOMES = {
197
+ completionStatus: { cardinality: 'single', baseType: 'identifier' },
198
+ SCORE: { cardinality: 'single', baseType: 'float' },
199
+ MAXSCORE: { cardinality: 'single', baseType: 'float' },
200
+ };
201
+ function typed(identifier, value, serialized, ...declarations) {
202
+ const declaration = declarations.find((candidate) => candidate !== undefined);
203
+ const cardinality = asCardinality(serialized?.cardinality) ?? declaration?.cardinality ?? inferCardinality(value);
204
+ if (cardinality === 'record')
205
+ return { identifier, cardinality, value };
206
+ const baseType = asBaseType(serialized?.baseType) ?? declaration?.baseType ?? inferBaseType(value);
207
+ return { identifier, cardinality, baseType, value };
208
+ }
209
+ const DECLARATION_ELEMENTS = new Set([
210
+ 'responsedeclaration',
211
+ 'outcomedeclaration',
212
+ 'templatedeclaration',
213
+ 'contextdeclaration',
214
+ ]);
215
+ /** The variable declarations of an item's XML, in either QTI version; empty when it does not parse. */
216
+ function readDeclarations(itemXml) {
217
+ const declarations = new Map();
218
+ if (!itemXml)
219
+ return declarations;
220
+ let root;
221
+ try {
222
+ root = parseXml(itemXml).documentElement;
223
+ }
224
+ catch {
225
+ return declarations;
226
+ }
227
+ for (const element of root ? childElements(root) : []) {
228
+ const name = element.localName.replace(/^qti-/, '').replace(/-/g, '').toLowerCase();
229
+ if (!DECLARATION_ELEMENTS.has(name))
230
+ continue;
231
+ const identifier = getAttr(element, 'identifier')?.trim();
232
+ const cardinality = asCardinality(getAttr(element, 'cardinality') ?? 'single');
233
+ if (!identifier || !cardinality)
234
+ continue;
235
+ const baseType = asBaseType(getAttr(element, 'baseType') ?? undefined);
236
+ declarations.set(identifier, {
237
+ cardinality,
238
+ ...(baseType && cardinality !== 'record' ? { baseType } : {}),
239
+ ...(name === 'outcomedeclaration' ? { outcome: outcomeAttributes(element) } : {}),
240
+ });
241
+ }
242
+ return declarations;
243
+ }
244
+ function outcomeAttributes(element) {
245
+ const number = (name) => {
246
+ const raw = getAttr(element, name);
247
+ const value = raw === null ? Number.NaN : Number.parseFloat(raw);
248
+ return Number.isFinite(value) ? value : undefined;
249
+ };
250
+ const text = (name) => getAttr(element, name)?.trim() || undefined;
251
+ const view = text('view')?.split(/\s+/);
252
+ const attributes = {
253
+ view,
254
+ interpretation: text('interpretation'),
255
+ longInterpretation: text('longInterpretation'),
256
+ normalMaximum: number('normalMaximum'),
257
+ normalMinimum: number('normalMinimum'),
258
+ masteryValue: number('masteryValue'),
259
+ };
260
+ return Object.fromEntries(Object.entries(attributes).filter(([, value]) => value !== undefined));
261
+ }
262
+ // ---------------------------------------------------------------------------------------------
263
+ // Value helpers
264
+ // ---------------------------------------------------------------------------------------------
265
+ const BASE_TYPES = new Set([
266
+ 'boolean',
267
+ 'directedPair',
268
+ 'duration',
269
+ 'file',
270
+ 'float',
271
+ 'identifier',
272
+ 'integer',
273
+ 'pair',
274
+ 'point',
275
+ 'string',
276
+ 'uri',
277
+ ]);
278
+ const CARDINALITIES = new Set(['single', 'multiple', 'ordered', 'record']);
279
+ function asBaseType(value) {
280
+ return value !== undefined && BASE_TYPES.has(value) ? value : undefined;
281
+ }
282
+ function asCardinality(value) {
283
+ return value !== undefined && CARDINALITIES.has(value) ? value : undefined;
284
+ }
285
+ function inferCardinality(value) {
286
+ if (Array.isArray(value))
287
+ return 'multiple';
288
+ if (value !== null && typeof value === 'object')
289
+ return 'record';
290
+ return 'single';
291
+ }
292
+ function valuesOf(variables) {
293
+ return Object.fromEntries(Object.entries(variables ?? {}).map(([identifier, variable]) => [identifier, variable.value]));
294
+ }
295
+ function hasValue(value) {
296
+ if (value === null || value === undefined)
297
+ return false;
298
+ if (Array.isArray(value))
299
+ return value.length > 0;
300
+ if (typeof value === 'string')
301
+ return value.trim().length > 0;
302
+ return true;
303
+ }
304
+ //# sourceMappingURL=toAssessmentResultXml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toAssessmentResultXml.js","sourceRoot":"","sources":["../../src/reporting/toAssessmentResultXml.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,+BAA+B,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBA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,KAA2B,CAAC,CAAC,CAAC,SAAS,CAAC;AACnG,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC;IAC5C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACjE,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,SAAoE;IACrF,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1H,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import type { SerializedItemSessionState, SerializedItemSessionVariable } from '@pie-qti/item-player';\nimport { childElements, durationSecondsFromMilliseconds, getAttr, parseXml } from '@pie-qti/qti-processing';\nimport { deliveredItems } from '../core/testStructure.js';\nimport { inferBaseType } from './inferBaseType.js';\nimport type {\n\tAssessmentItemSessionState,\n\tAssessmentScoringResult,\n\tAssessmentSessionState,\n\tFinalizeAssessmentResponse,\n\tSecureAssessment,\n\tTestOutcomeValues,\n} from '../integration/api-contract.js';\nimport { type SerializeAssessmentResultOptions, serializeAssessmentResult } from './serializeAssessmentResult.js';\nimport type {\n\tAssessmentItemResult,\n\tAssessmentResultReport,\n\tResultBaseType,\n\tResultCardinality,\n\tResultDatestamp,\n\tResultOutcomeVariable,\n\tResultSessionIdentifier,\n\tResultSessionStatus,\n\tResultVariable,\n} from './types.js';\n\n/** The assessment results a host holds: the delivered test, its session state, and the finalize response. */\nexport interface AssessmentResultsData {\n\t/** The assessment as delivered (drawn) for this session; its order gives each item's sequenceIndex. */\n\treadonly assessment: SecureAssessment;\n\t/** The session state: responses, item sessions, scores, comments and timing. */\n\treadonly state: AssessmentSessionState;\n\t/** The finalize response, once the test has ended: final item scores and test outcomes. */\n\treadonly finalized?: FinalizeAssessmentResponse;\n\t/** Test outcome values, when the host has them without a finalize response. */\n\treadonly outcomes?: TestOutcomeValues;\n}\n\nexport interface AssessmentResultXmlOptions extends SerializeAssessmentResultOptions {\n\t/** `context@sourcedId`: the candidate's sourcedId (an NCName). */\n\treadonly candidateSourcedId?: string;\n\treadonly sessionIdentifiers?: readonly ResultSessionIdentifier[];\n\t/** `testResult@datestamp`. Default: `finalized.finalizedAt`, else now. */\n\treadonly datestamp?: ResultDatestamp;\n\t/** Report the correct responses the scoring results carry. Default: false. */\n\treadonly includeCorrectResponses?: boolean;\n}\n\n/**\n * Writes the assessment's results as a QTI Results Reporting `assessmentResult` document (QTI 2.2\n * or 3.0, per `options.version`).\n *\n * The test result carries the test outcomes, typed by the test's outcome declarations, and the\n * built-in `duration` response variables of the test, each test part and each section\n * (`PART.duration`, `SECTION.duration`), in seconds. Each item with recorded data gets an item\n * result in delivery order, with its `sequenceIndex`, its `sessionStatus` derived from the session\n * lifecycle and scoring, its response, outcome, template and (QTI 3.0) context variables, the\n * built-in `numAttempts` and `duration` (seconds) response variables, and the candidate comment.\n * Item session snapshots give variables their types; the item's declarations fill in where a\n * snapshot is missing.\n */\nexport function toAssessmentResultXml(results: AssessmentResultsData, options: AssessmentResultXmlOptions): string {\n\treturn serializeAssessmentResult(buildAssessmentResultReport(results, options), options);\n}\n\n/** The Results Reporting model `toAssessmentResultXml` writes, for hosts that adjust it first. */\nexport function buildAssessmentResultReport(\n\tresults: AssessmentResultsData,\n\toptions: Omit<AssessmentResultXmlOptions, 'version' | 'schemaLocation'> = {},\n): AssessmentResultReport {\n\tconst { assessment, state, finalized } = results;\n\tconst itemScores: Record<string, AssessmentScoringResult> = { ...(state.itemScores ?? {}), ...(finalized?.itemScores ?? {}) };\n\tconst itemXmlById = new Map<string, string>();\n\tconst ordered: Array<{ identifier: string; sequenceIndex?: number }> = deliveredItems(assessment).map(\n\t\t({ item }, index) => {\n\t\t\titemXmlById.set(item.identifier, item.itemXml);\n\t\t\treturn { identifier: item.identifier, sequenceIndex: index + 1 };\n\t\t},\n\t);\n\tconst known = new Set(ordered.map((item) => item.identifier));\n\tfor (const identifier of [\n\t\t...Object.keys(state.itemSessions ?? {}),\n\t\t...Object.keys(itemScores),\n\t\t...Object.keys(state.itemResponses ?? {}),\n\t]) {\n\t\tif (!known.has(identifier)) {\n\t\t\tknown.add(identifier);\n\t\t\tordered.push({ identifier });\n\t\t}\n\t}\n\n\tconst itemResults: AssessmentItemResult[] = [];\n\tfor (const { identifier, sequenceIndex } of ordered) {\n\t\tconst item = itemResultData(identifier, state, itemScores[identifier]);\n\t\tif (!item) continue;\n\t\titemResults.push({\n\t\t\tidentifier,\n\t\t\t...(sequenceIndex === undefined ? {} : { sequenceIndex }),\n\t\t\tdatestamp: itemDatestamp(item, options.datestamp ?? finalized?.finalizedAt),\n\t\t\tsessionStatus: sessionStatus(item),\n\t\t\tvariables: itemVariables(item, readDeclarations(itemXmlById.get(identifier)), options.includeCorrectResponses === true),\n\t\t\t...(state.itemComments?.[identifier] !== undefined ? { candidateComment: state.itemComments[identifier] } : {}),\n\t\t});\n\t}\n\n\treturn {\n\t\tcontext: {\n\t\t\t...(options.candidateSourcedId !== undefined ? { sourcedId: options.candidateSourcedId } : {}),\n\t\t\t...(options.sessionIdentifiers ? { sessionIdentifiers: options.sessionIdentifiers } : {}),\n\t\t},\n\t\ttestResult: {\n\t\t\tidentifier: assessment.identifier,\n\t\t\tdatestamp: options.datestamp ?? finalized?.finalizedAt ?? Date.now(),\n\t\t\tvariables: testVariables(assessment, state, results.outcomes ?? finalized?.outcomes),\n\t\t},\n\t\titemResults,\n\t};\n}\n\n// ---------------------------------------------------------------------------------------------\n// Test result\n// ---------------------------------------------------------------------------------------------\n\nfunction testVariables(\n\tassessment: SecureAssessment,\n\tstate: AssessmentSessionState,\n\toutcomes: TestOutcomeValues | undefined,\n): ResultVariable[] {\n\tconst timing = state.timing;\n\tconst variables: ResultVariable[] = [durationVariable('duration', timing?.totalTime)];\n\tfor (const [part, milliseconds] of Object.entries(timing?.testPartTimes ?? {})) {\n\t\tvariables.push(durationVariable(`${part}.duration`, milliseconds));\n\t}\n\tfor (const [section, milliseconds] of Object.entries(timing?.sectionTimes ?? {})) {\n\t\tvariables.push(durationVariable(`${section}.duration`, milliseconds));\n\t}\n\tconst declarations = new Map((assessment.outcomeDeclarations ?? []).map((declaration) => [declaration.identifier, declaration]));\n\tfor (const [identifier, value] of Object.entries(outcomes ?? {})) {\n\t\tconst declaration = declarations.get(identifier);\n\t\tconst cardinality = asCardinality(declaration?.cardinality) ?? inferCardinality(value);\n\t\tvariables.push({\n\t\t\tkind: 'outcome',\n\t\t\tidentifier,\n\t\t\tcardinality,\n\t\t\t...(cardinality === 'record' ? {} : { baseType: asBaseType(declaration?.baseType) ?? inferBaseType(value) }),\n\t\t\tvalue,\n\t\t});\n\t}\n\treturn variables;\n}\n\nfunction durationVariable(identifier: string, milliseconds: number | undefined): ResultVariable {\n\treturn {\n\t\tkind: 'response',\n\t\tidentifier,\n\t\tcardinality: 'single',\n\t\tbaseType: 'duration',\n\t\tvalue: durationSecondsFromMilliseconds(Number(milliseconds) || 0),\n\t};\n}\n\n// ---------------------------------------------------------------------------------------------\n// Item results\n// ---------------------------------------------------------------------------------------------\n\ninterface ItemResultData {\n\treadonly identifier: string;\n\treadonly session?: SerializedItemSessionState;\n\treadonly scoring?: AssessmentScoringResult;\n\treadonly responses?: Record<string, unknown>;\n\treadonly sessionState?: AssessmentItemSessionState;\n\treadonly durationMs?: number;\n}\n\n/** The recorded data of one item; undefined for an item nothing was recorded for. */\nfunction itemResultData(\n\tidentifier: string,\n\tstate: AssessmentSessionState,\n\tscoring: AssessmentScoringResult | undefined,\n): ItemResultData | undefined {\n\tconst session = state.itemSessions?.[identifier];\n\tconst responses = state.itemResponses?.[identifier] as Record<string, unknown> | undefined;\n\tconst sessionState = state.itemSessionStates?.[identifier];\n\tif (!session && !scoring && !responses && !sessionState) return undefined;\n\tconst durationMs = session?.duration ?? state.timing?.itemTimes?.[identifier];\n\treturn { identifier, session, scoring, responses, sessionState, ...(durationMs === undefined ? {} : { durationMs }) };\n}\n\n/**\n * The Results Reporting session status: `final` once response processing has scored the latest\n * submission, `pendingSubmission` while the candidate works (including edits newer than the last\n * scored submission), `pendingResponseProcessing` for a submission not yet scored, and `initial`\n * for an item with no attempt and no response.\n */\nfunction sessionStatus({ session, scoring, responses, sessionState }: ItemResultData): ResultSessionStatus {\n\tconst lifecycle = session?.lifecycleStatus;\n\tconst working = lifecycle === 'interacting' || lifecycle === 'suspended' || lifecycle === 'initial';\n\tif (scoring) {\n\t\tconst savedAt = session ? Date.parse(session.savedAt) : Number.NaN;\n\t\tconst submittedAt = sessionState?.lastSubmissionTime;\n\t\tconst editedSince = working && submittedAt !== undefined && Number.isFinite(savedAt) && savedAt > submittedAt;\n\t\treturn editedSince ? 'pendingSubmission' : 'final';\n\t}\n\tif (lifecycle && !working) return 'final';\n\tif (sessionState?.isSubmitted) return 'pendingResponseProcessing';\n\tconst attempts = sessionState?.attemptCount ?? session?.numAttempts ?? 0;\n\tconst responded = Object.values(responses ?? valuesOf(session?.responseVariables)).some(hasValue);\n\treturn attempts === 0 && !responded ? 'initial' : 'pendingSubmission';\n}\n\n/** When the item's latest recorded data was recorded: its last submission or its session snapshot. */\nfunction itemDatestamp(item: ItemResultData, fallback: ResultDatestamp | undefined): ResultDatestamp {\n\tconst submittedAt = item.sessionState?.lastSubmissionTime;\n\tconst savedAt = item.session ? Date.parse(item.session.savedAt) : Number.NaN;\n\tconst times = [submittedAt, Number.isFinite(savedAt) ? savedAt : undefined].filter(\n\t\t(time): time is number => typeof time === 'number' && Number.isFinite(time),\n\t);\n\treturn times.length > 0 ? Math.max(...times) : (fallback ?? Date.now());\n}\n\nconst BUILT_IN_RESPONSES = new Set(['numAttempts', 'duration']);\n\nfunction itemVariables(item: ItemResultData, declarations: ItemDeclarations, includeCorrectResponses: boolean): ResultVariable[] {\n\tconst { session, scoring, responses, sessionState } = item;\n\tconst variables: ResultVariable[] = [];\n\n\t// Built-in response variables: numAttempts, and duration in seconds.\n\tconst numAttempts =\n\t\tsessionState?.attemptCount ??\n\t\t(typeof scoring?.outcomeValues?.numAttempts === 'number' ? scoring.outcomeValues.numAttempts : undefined) ??\n\t\tsession?.numAttempts ??\n\t\t0;\n\tvariables.push({ kind: 'response', identifier: 'numAttempts', cardinality: 'single', baseType: 'integer', value: numAttempts });\n\tif (item.durationMs !== undefined) variables.push(durationVariable('duration', item.durationMs));\n\n\t// Response variables: the latest recorded responses, typed by the session or the declarations.\n\tconst responseIds = new Set([...Object.keys(session?.responseVariables ?? {}), ...Object.keys(responses ?? {})]);\n\tfor (const identifier of responseIds) {\n\t\tif (BUILT_IN_RESPONSES.has(identifier)) continue;\n\t\tconst serialized = session?.responseVariables?.[identifier];\n\t\tconst value = responses && identifier in responses ? responses[identifier] : serialized?.value;\n\t\tconst correct = includeCorrectResponses ? scoring?.correctResponse?.[identifier] : undefined;\n\t\tvariables.push({\n\t\t\tkind: 'response',\n\t\t\t...typed(identifier, value, serialized, declarations.get(identifier)),\n\t\t\t...(correct === undefined ? {} : { correctResponse: correct }),\n\t\t});\n\t}\n\n\t// Outcome variables: the scored outcomes, else the session's.\n\tconst outcomeValues: Record<string, unknown> = { ...(scoring?.outcomeValues ?? valuesOf(session?.outcomeVariables)) };\n\tif (!('completionStatus' in outcomeValues) && session?.completionStatus) {\n\t\toutcomeValues.completionStatus = session.completionStatus;\n\t}\n\tfor (const [identifier, value] of Object.entries(outcomeValues)) {\n\t\tif (BUILT_IN_RESPONSES.has(identifier)) continue;\n\t\tconst declaration = declarations.get(identifier);\n\t\tconst outcome: ResultOutcomeVariable = {\n\t\t\tkind: 'outcome',\n\t\t\t...typed(identifier, value, session?.outcomeVariables?.[identifier], declaration, BUILT_IN_OUTCOMES[identifier]),\n\t\t\t...(declaration?.outcome ?? {}),\n\t\t};\n\t\tvariables.push(outcome);\n\t}\n\n\tfor (const serialized of Object.values(session?.templateVariables ?? {})) {\n\t\tvariables.push({ kind: 'template', ...typed(serialized.identifier, serialized.value, serialized) });\n\t}\n\tfor (const serialized of Object.values(session?.contextVariables ?? {})) {\n\t\tif (BUILT_IN_RESPONSES.has(serialized.identifier) || serialized.identifier === 'completionStatus') continue;\n\t\tvariables.push({ kind: 'context', ...typed(serialized.identifier, serialized.value, serialized) });\n\t}\n\treturn variables;\n}\n\n/** The built-in outcomes' declarations, for results without a session snapshot. */\nconst BUILT_IN_OUTCOMES: Readonly<Record<string, ItemDeclaration>> = {\n\tcompletionStatus: { cardinality: 'single', baseType: 'identifier' },\n\tSCORE: { cardinality: 'single', baseType: 'float' },\n\tMAXSCORE: { cardinality: 'single', baseType: 'float' },\n};\n\nfunction typed(\n\tidentifier: string,\n\tvalue: unknown,\n\tserialized?: Pick<SerializedItemSessionVariable, 'baseType' | 'cardinality'>,\n\t...declarations: Array<ItemDeclaration | undefined>\n): { identifier: string; cardinality: ResultCardinality; baseType?: ResultBaseType; value: unknown } {\n\tconst declaration = declarations.find((candidate) => candidate !== undefined);\n\tconst cardinality =\n\t\tasCardinality(serialized?.cardinality) ?? declaration?.cardinality ?? inferCardinality(value);\n\tif (cardinality === 'record') return { identifier, cardinality, value };\n\tconst baseType = asBaseType(serialized?.baseType) ?? declaration?.baseType ?? inferBaseType(value);\n\treturn { identifier, cardinality, baseType, value };\n}\n\n// ---------------------------------------------------------------------------------------------\n// Item declarations, from the item XML\n// ---------------------------------------------------------------------------------------------\n\ninterface ItemDeclaration {\n\treadonly cardinality: ResultCardinality;\n\treadonly baseType?: ResultBaseType;\n\treadonly outcome?: Pick<\n\t\tResultOutcomeVariable,\n\t\t'view' | 'interpretation' | 'longInterpretation' | 'normalMaximum' | 'normalMinimum' | 'masteryValue'\n\t>;\n}\n\ntype ItemDeclarations = ReadonlyMap<string, ItemDeclaration>;\n\nconst DECLARATION_ELEMENTS = new Set([\n\t'responsedeclaration',\n\t'outcomedeclaration',\n\t'templatedeclaration',\n\t'contextdeclaration',\n]);\n\n/** The variable declarations of an item's XML, in either QTI version; empty when it does not parse. */\nfunction readDeclarations(itemXml: string | undefined): ItemDeclarations {\n\tconst declarations = new Map<string, ItemDeclaration>();\n\tif (!itemXml) return declarations;\n\tlet root: Element | null;\n\ttry {\n\t\troot = parseXml(itemXml).documentElement;\n\t} catch {\n\t\treturn declarations;\n\t}\n\tfor (const element of root ? childElements(root) : []) {\n\t\tconst name = element.localName.replace(/^qti-/, '').replace(/-/g, '').toLowerCase();\n\t\tif (!DECLARATION_ELEMENTS.has(name)) continue;\n\t\tconst identifier = getAttr(element, 'identifier')?.trim();\n\t\tconst cardinality = asCardinality(getAttr(element, 'cardinality') ?? 'single');\n\t\tif (!identifier || !cardinality) continue;\n\t\tconst baseType = asBaseType(getAttr(element, 'baseType') ?? undefined);\n\t\tdeclarations.set(identifier, {\n\t\t\tcardinality,\n\t\t\t...(baseType && cardinality !== 'record' ? { baseType } : {}),\n\t\t\t...(name === 'outcomedeclaration' ? { outcome: outcomeAttributes(element) } : {}),\n\t\t});\n\t}\n\treturn declarations;\n}\n\nfunction outcomeAttributes(element: Element): ItemDeclaration['outcome'] {\n\tconst number = (name: string): number | undefined => {\n\t\tconst raw = getAttr(element, name);\n\t\tconst value = raw === null ? Number.NaN : Number.parseFloat(raw);\n\t\treturn Number.isFinite(value) ? value : undefined;\n\t};\n\tconst text = (name: string): string | undefined => getAttr(element, name)?.trim() || undefined;\n\tconst view = text('view')?.split(/\\s+/);\n\tconst attributes = {\n\t\tview,\n\t\tinterpretation: text('interpretation'),\n\t\tlongInterpretation: text('longInterpretation'),\n\t\tnormalMaximum: number('normalMaximum'),\n\t\tnormalMinimum: number('normalMinimum'),\n\t\tmasteryValue: number('masteryValue'),\n\t};\n\treturn Object.fromEntries(Object.entries(attributes).filter(([, value]) => value !== undefined));\n}\n\n// ---------------------------------------------------------------------------------------------\n// Value helpers\n// ---------------------------------------------------------------------------------------------\n\nconst BASE_TYPES = new Set<string>([\n\t'boolean',\n\t'directedPair',\n\t'duration',\n\t'file',\n\t'float',\n\t'identifier',\n\t'integer',\n\t'pair',\n\t'point',\n\t'string',\n\t'uri',\n]);\nconst CARDINALITIES = new Set<string>(['single', 'multiple', 'ordered', 'record']);\n\nfunction asBaseType(value: string | undefined): ResultBaseType | undefined {\n\treturn value !== undefined && BASE_TYPES.has(value) ? (value as ResultBaseType) : undefined;\n}\n\nfunction asCardinality(value: string | undefined): ResultCardinality | undefined {\n\treturn value !== undefined && CARDINALITIES.has(value) ? (value as ResultCardinality) : undefined;\n}\n\nfunction inferCardinality(value: unknown): ResultCardinality {\n\tif (Array.isArray(value)) return 'multiple';\n\tif (value !== null && typeof value === 'object') return 'record';\n\treturn 'single';\n}\n\nfunction valuesOf(variables: Record<string, SerializedItemSessionVariable> | undefined): Record<string, unknown> {\n\treturn Object.fromEntries(Object.entries(variables ?? {}).map(([identifier, variable]) => [identifier, variable.value]));\n}\n\nfunction hasValue(value: unknown): boolean {\n\tif (value === null || value === undefined) return false;\n\tif (Array.isArray(value)) return value.length > 0;\n\tif (typeof value === 'string') return value.trim().length > 0;\n\treturn true;\n}\n"]}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The QTI Results Reporting model the serializer writes: an `assessmentResult` with its context,
3
+ * an optional test result and item results, each carrying response, outcome, template and (QTI 3.0)
4
+ * context variables. Mirrors the 1EdTech QTI Results Reporting information model for QTI 2.2
5
+ * (`imsqti_result_v2p2`) and QTI 3.0 (`imsqti_result_v3p0`); see `serializeAssessmentResult`.
6
+ */
7
+ /** The QTI Results Reporting version to write. */
8
+ export type AssessmentResultVersion = '2.2' | '3.0';
9
+ export type ResultBaseType = 'boolean' | 'directedPair' | 'duration' | 'file' | 'float' | 'identifier' | 'integer' | 'pair' | 'point' | 'string' | 'uri';
10
+ export type ResultCardinality = 'single' | 'multiple' | 'ordered' | 'record';
11
+ /**
12
+ * How far an item session got, as the Results Reporting `sessionStatus` vocabulary defines it.
13
+ * `pendingExternalScoring` exists in QTI 3.0 only.
14
+ */
15
+ export type ResultSessionStatus = 'final' | 'initial' | 'pendingResponseProcessing' | 'pendingSubmission' | 'pendingExternalScoring';
16
+ /** When a result was recorded: a Date, epoch milliseconds, or an ISO 8601 date-time. */
17
+ export type ResultDatestamp = Date | number | string;
18
+ interface ResultVariableBase {
19
+ readonly identifier: string;
20
+ readonly cardinality: ResultCardinality;
21
+ /** Omitted, and ignored, for record cardinality. */
22
+ readonly baseType?: ResultBaseType;
23
+ /**
24
+ * The value in the player's runtime shape: a scalar for single cardinality, an array for
25
+ * multiple and ordered, an object of fields for record (each field a plain value, or
26
+ * `{ baseType, value }`), null or undefined for NULL. Durations are seconds.
27
+ */
28
+ readonly value: unknown;
29
+ }
30
+ export interface ResultResponseVariable extends ResultVariableBase {
31
+ readonly kind: 'response';
32
+ /** The correct response, when the report should carry it. */
33
+ readonly correctResponse?: unknown;
34
+ /** The order the choices were presented in, as choice identifiers. */
35
+ readonly choiceSequence?: readonly string[];
36
+ }
37
+ export interface ResultOutcomeVariable extends ResultVariableBase {
38
+ readonly kind: 'outcome';
39
+ readonly view?: readonly string[];
40
+ readonly interpretation?: string;
41
+ readonly longInterpretation?: string;
42
+ readonly normalMaximum?: number;
43
+ readonly normalMinimum?: number;
44
+ readonly masteryValue?: number;
45
+ }
46
+ export interface ResultTemplateVariable extends ResultVariableBase {
47
+ readonly kind: 'template';
48
+ }
49
+ /** QTI 3.0 only; a QTI 2.2 report leaves context variables out. */
50
+ export interface ResultContextVariable extends ResultVariableBase {
51
+ readonly kind: 'context';
52
+ }
53
+ export type ResultVariable = ResultResponseVariable | ResultOutcomeVariable | ResultTemplateVariable | ResultContextVariable;
54
+ export interface ResultSessionIdentifier {
55
+ /** The system that assigned the identifier, as a URI. */
56
+ readonly sourceID: string;
57
+ readonly identifier: string;
58
+ }
59
+ export interface AssessmentResultContext {
60
+ /** The candidate's sourcedId (an NCName, per LIS). */
61
+ readonly sourcedId?: string;
62
+ readonly sessionIdentifiers?: readonly ResultSessionIdentifier[];
63
+ }
64
+ export interface AssessmentTestResult {
65
+ /** The assessmentTest identifier. */
66
+ readonly identifier: string;
67
+ readonly datestamp: ResultDatestamp;
68
+ readonly variables: readonly ResultVariable[];
69
+ }
70
+ export interface AssessmentItemResult {
71
+ /** The assessmentItemRef identifier within the test (or the item identifier outside one). */
72
+ readonly identifier: string;
73
+ /** The item's 1-based position in this instance of the test. */
74
+ readonly sequenceIndex?: number;
75
+ readonly datestamp: ResultDatestamp;
76
+ readonly sessionStatus: ResultSessionStatus;
77
+ readonly variables: readonly ResultVariable[];
78
+ readonly candidateComment?: string;
79
+ }
80
+ export interface AssessmentResultReport {
81
+ readonly context: AssessmentResultContext;
82
+ readonly testResult?: AssessmentTestResult;
83
+ readonly itemResults: readonly AssessmentItemResult[];
84
+ }
85
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The QTI Results Reporting model the serializer writes: an `assessmentResult` with its context,
3
+ * an optional test result and item results, each carrying response, outcome, template and (QTI 3.0)
4
+ * context variables. Mirrors the 1EdTech QTI Results Reporting information model for QTI 2.2
5
+ * (`imsqti_result_v2p2`) and QTI 3.0 (`imsqti_result_v3p0`); see `serializeAssessmentResult`.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/reporting/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * The QTI Results Reporting model the serializer writes: an `assessmentResult` with its context,\n * an optional test result and item results, each carrying response, outcome, template and (QTI 3.0)\n * context variables. Mirrors the 1EdTech QTI Results Reporting information model for QTI 2.2\n * (`imsqti_result_v2p2`) and QTI 3.0 (`imsqti_result_v3p0`); see `serializeAssessmentResult`.\n */\n\n/** The QTI Results Reporting version to write. */\nexport type AssessmentResultVersion = '2.2' | '3.0';\n\nexport type ResultBaseType =\n\t| 'boolean'\n\t| 'directedPair'\n\t| 'duration'\n\t| 'file'\n\t| 'float'\n\t| 'identifier'\n\t| 'integer'\n\t| 'pair'\n\t| 'point'\n\t| 'string'\n\t| 'uri';\n\nexport type ResultCardinality = 'single' | 'multiple' | 'ordered' | 'record';\n\n/**\n * How far an item session got, as the Results Reporting `sessionStatus` vocabulary defines it.\n * `pendingExternalScoring` exists in QTI 3.0 only.\n */\nexport type ResultSessionStatus =\n\t| 'final'\n\t| 'initial'\n\t| 'pendingResponseProcessing'\n\t| 'pendingSubmission'\n\t| 'pendingExternalScoring';\n\n/** When a result was recorded: a Date, epoch milliseconds, or an ISO 8601 date-time. */\nexport type ResultDatestamp = Date | number | string;\n\ninterface ResultVariableBase {\n\treadonly identifier: string;\n\treadonly cardinality: ResultCardinality;\n\t/** Omitted, and ignored, for record cardinality. */\n\treadonly baseType?: ResultBaseType;\n\t/**\n\t * The value in the player's runtime shape: a scalar for single cardinality, an array for\n\t * multiple and ordered, an object of fields for record (each field a plain value, or\n\t * `{ baseType, value }`), null or undefined for NULL. Durations are seconds.\n\t */\n\treadonly value: unknown;\n}\n\nexport interface ResultResponseVariable extends ResultVariableBase {\n\treadonly kind: 'response';\n\t/** The correct response, when the report should carry it. */\n\treadonly correctResponse?: unknown;\n\t/** The order the choices were presented in, as choice identifiers. */\n\treadonly choiceSequence?: readonly string[];\n}\n\nexport interface ResultOutcomeVariable extends ResultVariableBase {\n\treadonly kind: 'outcome';\n\treadonly view?: readonly string[];\n\treadonly interpretation?: string;\n\treadonly longInterpretation?: string;\n\treadonly normalMaximum?: number;\n\treadonly normalMinimum?: number;\n\treadonly masteryValue?: number;\n}\n\nexport interface ResultTemplateVariable extends ResultVariableBase {\n\treadonly kind: 'template';\n}\n\n/** QTI 3.0 only; a QTI 2.2 report leaves context variables out. */\nexport interface ResultContextVariable extends ResultVariableBase {\n\treadonly kind: 'context';\n}\n\nexport type ResultVariable =\n\t| ResultResponseVariable\n\t| ResultOutcomeVariable\n\t| ResultTemplateVariable\n\t| ResultContextVariable;\n\nexport interface ResultSessionIdentifier {\n\t/** The system that assigned the identifier, as a URI. */\n\treadonly sourceID: string;\n\treadonly identifier: string;\n}\n\nexport interface AssessmentResultContext {\n\t/** The candidate's sourcedId (an NCName, per LIS). */\n\treadonly sourcedId?: string;\n\treadonly sessionIdentifiers?: readonly ResultSessionIdentifier[];\n}\n\nexport interface AssessmentTestResult {\n\t/** The assessmentTest identifier. */\n\treadonly identifier: string;\n\treadonly datestamp: ResultDatestamp;\n\treadonly variables: readonly ResultVariable[];\n}\n\nexport interface AssessmentItemResult {\n\t/** The assessmentItemRef identifier within the test (or the item identifier outside one). */\n\treadonly identifier: string;\n\t/** The item's 1-based position in this instance of the test. */\n\treadonly sequenceIndex?: number;\n\treadonly datestamp: ResultDatestamp;\n\treadonly sessionStatus: ResultSessionStatus;\n\treadonly variables: readonly ResultVariable[];\n\treadonly candidateComment?: string;\n}\n\nexport interface AssessmentResultReport {\n\treadonly context: AssessmentResultContext;\n\treadonly testResult?: AssessmentTestResult;\n\treadonly itemResults: readonly AssessmentItemResult[];\n}\n"]}
@@ -5,18 +5,25 @@
5
5
  * delegates decisions to a BackendAdapter.
6
6
  */
7
7
  export type QTIRole = import('@pie-qti/item-player').QTIRole;
8
- export type ResolvedItemDeliveryContext = import('@pie-qti/item-player').ResolvedItemDeliveryContext;
8
+ export type OutcomeProcessingError = import('../integration/api-contract.js').OutcomeProcessingError;
9
9
  /**
10
- * Minimal item reference shape used by the UI renderer.
10
+ * A candidate-facing section as listed by `AssessmentPlayer.getAllSections()`.
11
+ *
12
+ * Sections with `visible="false"` (or hidden by an invisible ancestor) are never
13
+ * listed: per QTI their content appears as part of the parent and their titles are
14
+ * not surfaced.
11
15
  */
12
- export interface ItemRef {
13
- identifier: string;
16
+ export interface CandidateSectionView {
17
+ id: string;
14
18
  title?: string;
15
- required?: boolean;
16
- /** Client-safe item XML (backend filtered by role). */
17
- itemXml?: string;
18
- /** Optional resolved QTI 3 delivery context produced by package/assessment layers. */
19
- deliveryContext?: ResolvedItemDeliveryContext;
19
+ /** Position within the candidate-facing section list. */
20
+ index: number;
21
+ /**
22
+ * Whether jumping to this section is legal right now (navigationMode, test part
23
+ * locks and finalization). Illegal targets must not be offered to the candidate;
24
+ * navigating to one is rejected with an `AssessmentPlayerError`.
25
+ */
26
+ navigable: boolean;
20
27
  }
21
28
  /**
22
29
  * Time limits (test/section/item level), matching QTI concepts.
@@ -31,7 +38,14 @@ export interface NavigationState {
31
38
  totalItems: number;
32
39
  canNext: boolean;
33
40
  canPrevious: boolean;
41
+ /**
42
+ * True while a navigation or submission transition is in flight. Shells must
43
+ * disable navigation controls while this is set; the core also serializes
44
+ * transitions so concurrent calls are rejected as busy.
45
+ */
34
46
  isLoading: boolean;
47
+ /** True once the assessment is finalized; navigation is closed afterwards. */
48
+ isComplete?: boolean;
35
49
  currentSection?: {
36
50
  id: string;
37
51
  title?: string;
@@ -45,11 +59,26 @@ export interface ItemResult {
45
59
  maxScore: number;
46
60
  responses: Record<string, unknown>;
47
61
  }
62
+ /**
63
+ * Why the test ended: the candidate's submit, a time expiry, a proctor's forced submit,
64
+ * or a QTI branch rule (`EXIT_TEST`, or an `EXIT_TESTPART`/`EXIT_SECTION` with nothing
65
+ * following). An end that collects a delivery the time already closed — the whole test
66
+ * expired, or a scope expiry left nothing open — is `expiry` whoever triggers it (the
67
+ * automatic submission, the candidate's Submit after it failed, a proctor's force-submit).
68
+ */
69
+ export type AssessmentEndReason = 'candidate' | 'expiry' | 'proctor' | 'branch';
48
70
  export interface AssessmentResults {
49
71
  totalScore: number;
50
72
  maxScore: number;
51
73
  itemResults: ItemResult[];
52
74
  completedAt: Date;
75
+ /**
76
+ * Set when test-level outcome processing failed on the backend: responses were
77
+ * accepted and persisted, but SCORE/testFeedback outcomes could not be computed.
78
+ */
79
+ outcomeProcessingError?: OutcomeProcessingError;
80
+ /** Why the test ended in this delivery; absent for a session restored already finalized. */
81
+ endReason?: AssessmentEndReason;
53
82
  }
54
83
  /** A test feedback block `AssessmentPlayer.getVisibleFeedback()` shows now. */
55
84
  export interface VisibleTestFeedback {
@@ -60,4 +89,62 @@ export interface VisibleTestFeedback {
60
89
  access: 'atEnd' | 'during';
61
90
  /** Set for feedback authored on a test part. */
62
91
  testPartIdentifier?: string;
92
+ /** The content's language (`TestFeedbackItem.language`), when it has one. */
93
+ language?: string;
94
+ }
95
+ /**
96
+ * Whether the shell should render an item-level "Check answer" control for the
97
+ * active item, and the attempt facts it displays (`AssessmentPlayer.getCheckAnswerState()`).
98
+ *
99
+ * The control exists only in `individual` submission-mode parts that allow more than
100
+ * one attempt (or deliver an adaptive item): QTI shows feedback for every non-final
101
+ * attempt there, whatever `showFeedback` says. QTI gives simultaneous parts no per-item
102
+ * submission, and a single attempt keeps the submit-on-move delivery (`reason`
103
+ * `feedbackOff`: nothing to check in place).
104
+ */
105
+ export interface CheckAnswerState {
106
+ /** True when the control renders. */
107
+ available: boolean;
108
+ /** Why the control does not render (`feedbackOff`: a single attempt); null when it does. */
109
+ reason: 'simultaneous' | 'feedbackOff' | null;
110
+ /** Whether the active item is adaptive (its attempt loop stays open until completed). */
111
+ adaptive: boolean;
112
+ /** Counted attempts already submitted for the item. */
113
+ attemptsUsed: number;
114
+ /** The resolved maxAttempts; null when attempts are unlimited (adaptive or maxAttempts 0). */
115
+ maxAttempts: number | null;
116
+ /** Counted attempts left; null when unlimited. */
117
+ remainingAttempts: number | null;
118
+ /** True once every allowed attempt has been consumed: the control renders disabled. */
119
+ attemptsExhausted: boolean;
120
+ }
121
+ /** One item feedback block captured from an item-level submission. */
122
+ export interface ItemFeedbackEntry {
123
+ identifier: string;
124
+ content: string;
125
+ /** Authored title, when the feedback block declares one. */
126
+ title?: string;
127
+ }
128
+ /** The item feedback a submission produced (`AssessmentPlayer.getLastItemFeedback()`). */
129
+ export interface ItemFeedbackView {
130
+ itemIdentifier: string;
131
+ feedback: ItemFeedbackEntry[];
132
+ }
133
+ /**
134
+ * Candidate-facing results for the shell's opt-in completion summary
135
+ * (`AssessmentPlayer.getResultsSummary()`); null before finalization.
136
+ */
137
+ export interface ResultsSummary {
138
+ totalScore: number;
139
+ maxScore: number;
140
+ items: Array<{
141
+ identifier: string;
142
+ /** 1-based position in the delivered order. */
143
+ number: number;
144
+ title?: string;
145
+ status: import('../core/reviewState.js').ItemAnswerStatus;
146
+ /** The backend's normalized score for the item, when it returned one. */
147
+ score?: number;
148
+ maxScore?: number;
149
+ }>;
63
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Public type definitions for the backend-authoritative assessment player.\n *\n * The client does not evaluate branching or outcome processing; it renders items and\n * delegates decisions to a BackendAdapter.\n */\n\nexport type QTIRole = import('@pie-qti/item-player').QTIRole;\nexport type ResolvedItemDeliveryContext = import('@pie-qti/item-player').ResolvedItemDeliveryContext;\n\n/**\n * Minimal item reference shape used by the UI renderer.\n */\nexport interface ItemRef {\n\tidentifier: string;\n\ttitle?: string;\n\trequired?: boolean;\n\t/** Client-safe item XML (backend filtered by role). */\n\titemXml?: string;\n\t/** Optional resolved QTI 3 delivery context produced by package/assessment layers. */\n\tdeliveryContext?: ResolvedItemDeliveryContext;\n}\n\n/**\n * Time limits (test/section/item level), matching QTI concepts.\n */\nexport interface TimeLimits {\n\tmaxTime?: number; // seconds\n\tminTime?: number; // seconds\n\tallowLateSubmission?: boolean;\n}\n\nexport interface NavigationState {\n\tcurrentIndex: number;\n\ttotalItems: number;\n\tcanNext: boolean;\n\tcanPrevious: boolean;\n\tisLoading: boolean;\n\tcurrentSection?: {\n\t\tid: string;\n\t\ttitle?: string;\n\t\tindex: number;\n\t};\n\ttotalSections?: number;\n}\n\nexport interface ItemResult {\n\titemIdentifier: string;\n\tscore: number;\n\tmaxScore: number;\n\tresponses: Record<string, unknown>;\n}\n\nexport interface AssessmentResults {\n\ttotalScore: number;\n\tmaxScore: number;\n\titemResults: ItemResult[];\n\tcompletedAt: Date;\n}\n\n/** A test feedback block `AssessmentPlayer.getVisibleFeedback()` shows now. */\nexport interface VisibleTestFeedback {\n\t/** Unique across the test; feedback identifiers repeat, for example in show/hide pairs. */\n\tkey: string;\n\tidentifier: string;\n\tcontent: string;\n\taccess: 'atEnd' | 'during';\n\t/** Set for feedback authored on a test part. */\n\ttestPartIdentifier?: string;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Public type definitions for the backend-authoritative assessment player.\n *\n * The client does not evaluate branching or outcome processing; it renders items and\n * delegates decisions to a BackendAdapter.\n */\n\nexport type QTIRole = import('@pie-qti/item-player').QTIRole;\nexport type OutcomeProcessingError = import('../integration/api-contract.js').OutcomeProcessingError;\n\n/**\n * A candidate-facing section as listed by `AssessmentPlayer.getAllSections()`.\n *\n * Sections with `visible=\"false\"` (or hidden by an invisible ancestor) are never\n * listed: per QTI their content appears as part of the parent and their titles are\n * not surfaced.\n */\nexport interface CandidateSectionView {\n\tid: string;\n\ttitle?: string;\n\t/** Position within the candidate-facing section list. */\n\tindex: number;\n\t/**\n\t * Whether jumping to this section is legal right now (navigationMode, test part\n\t * locks and finalization). Illegal targets must not be offered to the candidate;\n\t * navigating to one is rejected with an `AssessmentPlayerError`.\n\t */\n\tnavigable: boolean;\n}\n\n/**\n * Time limits (test/section/item level), matching QTI concepts.\n */\nexport interface TimeLimits {\n\tmaxTime?: number; // seconds\n\tminTime?: number; // seconds\n\tallowLateSubmission?: boolean;\n}\n\nexport interface NavigationState {\n\tcurrentIndex: number;\n\ttotalItems: number;\n\tcanNext: boolean;\n\tcanPrevious: boolean;\n\t/**\n\t * True while a navigation or submission transition is in flight. Shells must\n\t * disable navigation controls while this is set; the core also serializes\n\t * transitions so concurrent calls are rejected as busy.\n\t */\n\tisLoading: boolean;\n\t/** True once the assessment is finalized; navigation is closed afterwards. */\n\tisComplete?: boolean;\n\tcurrentSection?: {\n\t\tid: string;\n\t\ttitle?: string;\n\t\tindex: number;\n\t};\n\ttotalSections?: number;\n}\n\nexport interface ItemResult {\n\titemIdentifier: string;\n\tscore: number;\n\tmaxScore: number;\n\tresponses: Record<string, unknown>;\n}\n\n/**\n * Why the test ended: the candidate's submit, a time expiry, a proctor's forced submit,\n * or a QTI branch rule (`EXIT_TEST`, or an `EXIT_TESTPART`/`EXIT_SECTION` with nothing\n * following). An end that collects a delivery the time already closed — the whole test\n * expired, or a scope expiry left nothing open — is `expiry` whoever triggers it (the\n * automatic submission, the candidate's Submit after it failed, a proctor's force-submit).\n */\nexport type AssessmentEndReason = 'candidate' | 'expiry' | 'proctor' | 'branch';\n\nexport interface AssessmentResults {\n\ttotalScore: number;\n\tmaxScore: number;\n\titemResults: ItemResult[];\n\tcompletedAt: Date;\n\t/**\n\t * Set when test-level outcome processing failed on the backend: responses were\n\t * accepted and persisted, but SCORE/testFeedback outcomes could not be computed.\n\t */\n\toutcomeProcessingError?: OutcomeProcessingError;\n\t/** Why the test ended in this delivery; absent for a session restored already finalized. */\n\tendReason?: AssessmentEndReason;\n}\n\n/** A test feedback block `AssessmentPlayer.getVisibleFeedback()` shows now. */\nexport interface VisibleTestFeedback {\n\t/** Unique across the test; feedback identifiers repeat, for example in show/hide pairs. */\n\tkey: string;\n\tidentifier: string;\n\tcontent: string;\n\taccess: 'atEnd' | 'during';\n\t/** Set for feedback authored on a test part. */\n\ttestPartIdentifier?: string;\n\t/** The content's language (`TestFeedbackItem.language`), when it has one. */\n\tlanguage?: string;\n}\n\n/**\n * Whether the shell should render an item-level \"Check answer\" control for the\n * active item, and the attempt facts it displays (`AssessmentPlayer.getCheckAnswerState()`).\n *\n * The control exists only in `individual` submission-mode parts that allow more than\n * one attempt (or deliver an adaptive item): QTI shows feedback for every non-final\n * attempt there, whatever `showFeedback` says. QTI gives simultaneous parts no per-item\n * submission, and a single attempt keeps the submit-on-move delivery (`reason`\n * `feedbackOff`: nothing to check in place).\n */\nexport interface CheckAnswerState {\n\t/** True when the control renders. */\n\tavailable: boolean;\n\t/** Why the control does not render (`feedbackOff`: a single attempt); null when it does. */\n\treason: 'simultaneous' | 'feedbackOff' | null;\n\t/** Whether the active item is adaptive (its attempt loop stays open until completed). */\n\tadaptive: boolean;\n\t/** Counted attempts already submitted for the item. */\n\tattemptsUsed: number;\n\t/** The resolved maxAttempts; null when attempts are unlimited (adaptive or maxAttempts 0). */\n\tmaxAttempts: number | null;\n\t/** Counted attempts left; null when unlimited. */\n\tremainingAttempts: number | null;\n\t/** True once every allowed attempt has been consumed: the control renders disabled. */\n\tattemptsExhausted: boolean;\n}\n\n/** One item feedback block captured from an item-level submission. */\nexport interface ItemFeedbackEntry {\n\tidentifier: string;\n\tcontent: string;\n\t/** Authored title, when the feedback block declares one. */\n\ttitle?: string;\n}\n\n/** The item feedback a submission produced (`AssessmentPlayer.getLastItemFeedback()`). */\nexport interface ItemFeedbackView {\n\titemIdentifier: string;\n\tfeedback: ItemFeedbackEntry[];\n}\n\n/**\n * Candidate-facing results for the shell's opt-in completion summary\n * (`AssessmentPlayer.getResultsSummary()`); null before finalization.\n */\nexport interface ResultsSummary {\n\ttotalScore: number;\n\tmaxScore: number;\n\titems: Array<{\n\t\tidentifier: string;\n\t\t/** 1-based position in the delivered order. */\n\t\tnumber: number;\n\t\ttitle?: string;\n\t\tstatus: import('../core/reviewState.js').ItemAnswerStatus;\n\t\t/** The backend's normalized score for the item, when it returned one. */\n\t\tscore?: number;\n\t\tmaxScore?: number;\n\t}>;\n}\n"]}