@pie-qti/assessment-player 1.0.0-beta.4 → 1.0.0-beta.6
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/README.md +28 -7
- package/dist/components/createPlayerConnection.svelte.d.ts +90 -0
- package/dist/components/createPlayerConnection.svelte.js +151 -0
- package/dist/components/createPlayerConnection.svelte.js.map +1 -0
- package/dist/components/displaySettings.svelte.d.ts +23 -0
- package/dist/components/displaySettings.svelte.js +40 -0
- package/dist/components/displaySettings.svelte.js.map +1 -0
- package/dist/components/srOnly.d.ts +29 -0
- package/dist/components/srOnly.js +55 -0
- package/dist/components/srOnly.js.map +1 -0
- package/dist/components/submitDialogAction.d.ts +25 -0
- package/dist/components/submitDialogAction.js +89 -0
- package/dist/components/submitDialogAction.js.map +1 -0
- package/dist/core/AssessmentPlayer.d.ts +1102 -53
- package/dist/core/AssessmentPlayer.js +2835 -460
- package/dist/core/AssessmentPlayer.js.map +1 -1
- package/dist/core/AssessmentSessionCoordinator.d.ts +76 -7
- package/dist/core/AssessmentSessionCoordinator.js +185 -10
- package/dist/core/AssessmentSessionCoordinator.js.map +1 -1
- package/dist/core/AutosaveManager.d.ts +104 -0
- package/dist/core/AutosaveManager.js +181 -0
- package/dist/core/AutosaveManager.js.map +1 -0
- package/dist/core/ItemSessionController.d.ts +17 -26
- package/dist/core/ItemSessionController.js +33 -73
- package/dist/core/ItemSessionController.js.map +1 -1
- package/dist/core/NavigationManager.d.ts +18 -50
- package/dist/core/NavigationManager.js +21 -83
- package/dist/core/NavigationManager.js.map +1 -1
- package/dist/core/TimeManager.d.ts +62 -16
- package/dist/core/TimeManager.js +148 -57
- package/dist/core/TimeManager.js.map +1 -1
- package/dist/core/autosave.d.ts +44 -0
- package/dist/core/autosave.js +46 -0
- package/dist/core/autosave.js.map +1 -0
- package/dist/core/deliveryStructure.d.ts +54 -0
- package/dist/core/deliveryStructure.js +72 -0
- package/dist/core/deliveryStructure.js.map +1 -0
- package/dist/core/errors.d.ts +116 -0
- package/dist/core/errors.js +77 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/exitBoundaries.d.ts +64 -0
- package/dist/core/exitBoundaries.js +98 -0
- package/dist/core/exitBoundaries.js.map +1 -0
- package/dist/core/feedback.d.ts +46 -0
- package/dist/core/feedback.js +47 -0
- package/dist/core/feedback.js.map +1 -0
- package/dist/core/formatTime.d.ts +8 -0
- package/dist/core/formatTime.js +20 -0
- package/dist/core/formatTime.js.map +1 -0
- package/dist/core/index.d.ts +7 -4
- package/dist/core/index.js +4 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/navigationPolicy.d.ts +42 -0
- package/dist/core/navigationPolicy.js +62 -0
- package/dist/core/navigationPolicy.js.map +1 -0
- package/dist/core/pause.d.ts +58 -0
- package/dist/core/pause.js +101 -0
- package/dist/core/pause.js.map +1 -0
- package/dist/core/playerEvents.d.ts +51 -0
- package/dist/core/playerEvents.js +66 -0
- package/dist/core/playerEvents.js.map +1 -0
- package/dist/core/reviewState.d.ts +81 -0
- package/dist/core/reviewState.js +113 -0
- package/dist/core/reviewState.js.map +1 -0
- package/dist/core/reviewViews.d.ts +43 -0
- package/dist/core/reviewViews.js +88 -0
- package/dist/core/reviewViews.js.map +1 -0
- package/dist/core/scopeLocks.d.ts +36 -0
- package/dist/core/scopeLocks.js +78 -0
- package/dist/core/scopeLocks.js.map +1 -0
- package/dist/core/sessionRecords.d.ts +31 -0
- package/dist/core/sessionRecords.js +74 -0
- package/dist/core/sessionRecords.js.map +1 -0
- package/dist/core/submissionPolicy.d.ts +62 -0
- package/dist/core/submissionPolicy.js +67 -0
- package/dist/core/submissionPolicy.js.map +1 -0
- package/dist/core/templateDefaults.d.ts +26 -0
- package/dist/core/templateDefaults.js +53 -0
- package/dist/core/templateDefaults.js.map +1 -0
- package/dist/core/testStructure.d.ts +118 -3
- package/dist/core/testStructure.js +252 -6
- package/dist/core/testStructure.js.map +1 -1
- package/dist/core/timePolicy.d.ts +40 -0
- package/dist/core/timePolicy.js +106 -0
- package/dist/core/timePolicy.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/integration/ReferenceBackendAdapter.d.ts +64 -101
- package/dist/integration/ReferenceBackendAdapter.js +216 -1035
- package/dist/integration/ReferenceBackendAdapter.js.map +1 -1
- package/dist/integration/api-contract.d.ts +179 -17
- package/dist/integration/api-contract.js.map +1 -1
- package/dist/integration/assessment-item-scorer.d.ts +56 -5
- package/dist/integration/assessment-item-scorer.js +116 -13
- package/dist/integration/assessment-item-scorer.js.map +1 -1
- package/dist/integration/index.d.ts +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/integration/index.js.map +1 -1
- package/dist/integration/qti-test-parser.d.ts +44 -0
- package/dist/integration/qti-test-parser.js +529 -0
- package/dist/integration/qti-test-parser.js.map +1 -0
- package/dist/integration/session-store.d.ts +54 -0
- package/dist/integration/session-store.js +75 -0
- package/dist/integration/session-store.js.map +1 -0
- package/dist/integration/test-navigation.d.ts +23 -0
- package/dist/integration/test-navigation.js +32 -0
- package/dist/integration/test-navigation.js.map +1 -0
- package/dist/integration/toSectionComposition.js +8 -1
- package/dist/integration/toSectionComposition.js.map +1 -1
- package/dist/reporting/index.d.ts +3 -0
- package/dist/reporting/index.js +3 -0
- package/dist/reporting/index.js.map +1 -0
- package/dist/reporting/inferBaseType.d.ts +13 -0
- package/dist/reporting/inferBaseType.js +26 -0
- package/dist/reporting/inferBaseType.js.map +1 -0
- package/dist/reporting/serializeAssessmentResult.d.ts +27 -0
- package/dist/reporting/serializeAssessmentResult.js +377 -0
- package/dist/reporting/serializeAssessmentResult.js.map +1 -0
- package/dist/reporting/toAssessmentResultXml.d.ts +39 -0
- package/dist/reporting/toAssessmentResultXml.js +304 -0
- package/dist/reporting/toAssessmentResultXml.js.map +1 -0
- package/dist/reporting/types.d.ts +85 -0
- package/dist/reporting/types.js +8 -0
- package/dist/reporting/types.js.map +1 -0
- package/dist/types/index.d.ts +96 -9
- package/dist/types/index.js.map +1 -1
- package/package.json +21 -15
- package/dist/core/StatePersistenceManager.d.ts +0 -125
- package/dist/core/StatePersistenceManager.js +0 -268
- package/dist/core/StatePersistenceManager.js.map +0 -1
- package/dist/utils/PerformanceMonitor.d.ts +0 -114
- package/dist/utils/PerformanceMonitor.js +0 -172
- package/dist/utils/PerformanceMonitor.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope time locks.
|
|
3
|
+
*
|
|
4
|
+
* A test part, section or item whose hard limit expired without late submission
|
|
5
|
+
* closes for the candidate; a whole-test expiry closes everything. Moved out of
|
|
6
|
+
* `AssessmentPlayer.ts` verbatim (pure code motion): the registry and its queries
|
|
7
|
+
* are policy only — no lock, no session state. The whole-test expiry flag stays
|
|
8
|
+
* with the orchestrator's terminal state and is passed in explicitly.
|
|
9
|
+
*/
|
|
10
|
+
import type { TimeLimits } from '../types/index.js';
|
|
11
|
+
import type { FlatItem } from './deliveryStructure.js';
|
|
12
|
+
import type { ExtendedTime } from './TimeManager.js';
|
|
13
|
+
export type TimeScope = 'testPart' | 'section' | 'item';
|
|
14
|
+
export declare function scopeKey(scope: TimeScope, identifier: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a hard maximum has run out for the given elapsed milliseconds (PNP
|
|
17
|
+
* extended time applied). Limits that allow late submission never lock.
|
|
18
|
+
*/
|
|
19
|
+
export declare function scopeLimitRanOut(limits: TimeLimits | undefined, elapsedMs: number | undefined, extendedTime: ExtendedTime | undefined): boolean;
|
|
20
|
+
/** The scopes whose time limit expired without late submission, keyed `scope:identifier`. */
|
|
21
|
+
export declare class ScopeLocks {
|
|
22
|
+
#private;
|
|
23
|
+
/** Lock a scope; true when it was not locked before. */
|
|
24
|
+
lock(scope: TimeScope, identifier: string): boolean;
|
|
25
|
+
isLocked(scope: TimeScope, identifier: string): boolean;
|
|
26
|
+
/** Drop every lock (a host-driven restore recomputes them from the snapshot's clocks). */
|
|
27
|
+
clear(): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether an expired limit closes the item for the candidate: its own, any
|
|
31
|
+
* enclosing section's, its test part's — or the whole test expired, which closes
|
|
32
|
+
* every item (the collection of the test is all that remains).
|
|
33
|
+
*/
|
|
34
|
+
export declare function isItemLocked(q: FlatItem, locks: ScopeLocks, assessmentExpired: boolean): boolean;
|
|
35
|
+
/** The expired scope that closes an item (outermost first); the assessment for a whole-test expiry. */
|
|
36
|
+
export declare function lockingScopeOf(q: FlatItem | undefined, locks: ScopeLocks, assessmentExpired: boolean): Pick<import('./AssessmentPlayer.js').AssessmentTimeExpiryEvent, 'scope' | 'identifier'>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope time locks.
|
|
3
|
+
*
|
|
4
|
+
* A test part, section or item whose hard limit expired without late submission
|
|
5
|
+
* closes for the candidate; a whole-test expiry closes everything. Moved out of
|
|
6
|
+
* `AssessmentPlayer.ts` verbatim (pure code motion): the registry and its queries
|
|
7
|
+
* are policy only — no lock, no session state. The whole-test expiry flag stays
|
|
8
|
+
* with the orchestrator's terminal state and is passed in explicitly.
|
|
9
|
+
*/
|
|
10
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
11
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _ScopeLocks_locked;
|
|
16
|
+
import { extendTimeLimit } from './TimeManager.js';
|
|
17
|
+
export function scopeKey(scope, identifier) {
|
|
18
|
+
return `${scope}:${identifier}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Whether a hard maximum has run out for the given elapsed milliseconds (PNP
|
|
22
|
+
* extended time applied). Limits that allow late submission never lock.
|
|
23
|
+
*/
|
|
24
|
+
export function scopeLimitRanOut(limits, elapsedMs, extendedTime) {
|
|
25
|
+
if (limits?.maxTime === undefined || limits.allowLateSubmission === true)
|
|
26
|
+
return false;
|
|
27
|
+
const maxSeconds = extendTimeLimit(limits.maxTime, extendedTime);
|
|
28
|
+
return maxSeconds !== undefined && (Number(elapsedMs) || 0) >= maxSeconds * 1000;
|
|
29
|
+
}
|
|
30
|
+
/** The scopes whose time limit expired without late submission, keyed `scope:identifier`. */
|
|
31
|
+
export class ScopeLocks {
|
|
32
|
+
constructor() {
|
|
33
|
+
_ScopeLocks_locked.set(this, new Set());
|
|
34
|
+
}
|
|
35
|
+
/** Lock a scope; true when it was not locked before. */
|
|
36
|
+
lock(scope, identifier) {
|
|
37
|
+
const key = scopeKey(scope, identifier);
|
|
38
|
+
if (__classPrivateFieldGet(this, _ScopeLocks_locked, "f").has(key))
|
|
39
|
+
return false;
|
|
40
|
+
__classPrivateFieldGet(this, _ScopeLocks_locked, "f").add(key);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
isLocked(scope, identifier) {
|
|
44
|
+
return __classPrivateFieldGet(this, _ScopeLocks_locked, "f").has(scopeKey(scope, identifier));
|
|
45
|
+
}
|
|
46
|
+
/** Drop every lock (a host-driven restore recomputes them from the snapshot's clocks). */
|
|
47
|
+
clear() {
|
|
48
|
+
__classPrivateFieldGet(this, _ScopeLocks_locked, "f").clear();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
_ScopeLocks_locked = new WeakMap();
|
|
52
|
+
/**
|
|
53
|
+
* Whether an expired limit closes the item for the candidate: its own, any
|
|
54
|
+
* enclosing section's, its test part's — or the whole test expired, which closes
|
|
55
|
+
* every item (the collection of the test is all that remains).
|
|
56
|
+
*/
|
|
57
|
+
export function isItemLocked(q, locks, assessmentExpired) {
|
|
58
|
+
if (assessmentExpired)
|
|
59
|
+
return true;
|
|
60
|
+
return (locks.isLocked('item', q.identifier) ||
|
|
61
|
+
locks.isLocked('testPart', q.testPart.identifier) ||
|
|
62
|
+
q.sections.some((section) => locks.isLocked('section', section.identifier)));
|
|
63
|
+
}
|
|
64
|
+
/** The expired scope that closes an item (outermost first); the assessment for a whole-test expiry. */
|
|
65
|
+
export function lockingScopeOf(q, locks, assessmentExpired) {
|
|
66
|
+
if (assessmentExpired || !q)
|
|
67
|
+
return { scope: 'assessment' };
|
|
68
|
+
if (locks.isLocked('testPart', q.testPart.identifier)) {
|
|
69
|
+
return { scope: 'testPart', identifier: q.testPart.identifier };
|
|
70
|
+
}
|
|
71
|
+
for (const section of q.sections) {
|
|
72
|
+
if (locks.isLocked('section', section.identifier)) {
|
|
73
|
+
return { scope: 'section', identifier: section.identifier };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { scope: 'item', identifier: q.identifier };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=scopeLocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeLocks.js","sourceRoot":"","sources":["../../src/core/scopeLocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;;;;;;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,UAAU,QAAQ,CAAC,KAAgB,EAAE,UAAkB;IAC5D,OAAO,GAAG,KAAK,IAAI,UAAU,EAAE,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAA8B,EAC9B,SAA6B,EAC7B,YAAsC;IAEtC,IAAI,MAAM,EAAE,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,mBAAmB,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACvF,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACjE,OAAO,UAAU,KAAK,SAAS,IAAI,CAAC,MAAM,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B,KAAiB,EACjB,iBAA0B;IAE1B,IAAI,iBAAiB,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;IAC5D,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACvD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACjE,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YACnD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;QAC7D,CAAC;IACF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;AACpD,CAAC","sourcesContent":["/**\n * Scope time locks.\n *\n * A test part, section or item whose hard limit expired without late submission\n * closes for the candidate; a whole-test expiry closes everything. Moved out of\n * `AssessmentPlayer.ts` verbatim (pure code motion): the registry and its queries\n * are policy only — no lock, no session state. The whole-test expiry flag stays\n * with the orchestrator's terminal state and is passed in explicitly.\n */\n\nimport type { TimeLimits } from '../types/index.js';\nimport type { FlatItem } from './deliveryStructure.js';\nimport type { ExtendedTime } from './TimeManager.js';\nimport { extendTimeLimit } from './TimeManager.js';\n\nexport type TimeScope = 'testPart' | 'section' | 'item';\n\nexport function scopeKey(scope: TimeScope, identifier: string): string {\n\treturn `${scope}:${identifier}`;\n}\n\n/**\n * Whether a hard maximum has run out for the given elapsed milliseconds (PNP\n * extended time applied). Limits that allow late submission never lock.\n */\nexport function scopeLimitRanOut(\n\tlimits: TimeLimits | undefined,\n\telapsedMs: number | undefined,\n\textendedTime: ExtendedTime | undefined,\n): boolean {\n\tif (limits?.maxTime === undefined || limits.allowLateSubmission === true) return false;\n\tconst maxSeconds = extendTimeLimit(limits.maxTime, extendedTime);\n\treturn maxSeconds !== undefined && (Number(elapsedMs) || 0) >= maxSeconds * 1000;\n}\n\n/** The scopes whose time limit expired without late submission, keyed `scope:identifier`. */\nexport class ScopeLocks {\n\treadonly #locked = new Set<string>();\n\n\t/** Lock a scope; true when it was not locked before. */\n\tlock(scope: TimeScope, identifier: string): boolean {\n\t\tconst key = scopeKey(scope, identifier);\n\t\tif (this.#locked.has(key)) return false;\n\t\tthis.#locked.add(key);\n\t\treturn true;\n\t}\n\n\tisLocked(scope: TimeScope, identifier: string): boolean {\n\t\treturn this.#locked.has(scopeKey(scope, identifier));\n\t}\n\n\t/** Drop every lock (a host-driven restore recomputes them from the snapshot's clocks). */\n\tclear(): void {\n\t\tthis.#locked.clear();\n\t}\n}\n\n/**\n * Whether an expired limit closes the item for the candidate: its own, any\n * enclosing section's, its test part's — or the whole test expired, which closes\n * every item (the collection of the test is all that remains).\n */\nexport function isItemLocked(q: FlatItem, locks: ScopeLocks, assessmentExpired: boolean): boolean {\n\tif (assessmentExpired) return true;\n\treturn (\n\t\tlocks.isLocked('item', q.identifier) ||\n\t\tlocks.isLocked('testPart', q.testPart.identifier) ||\n\t\tq.sections.some((section) => locks.isLocked('section', section.identifier))\n\t);\n}\n\n/** The expired scope that closes an item (outermost first); the assessment for a whole-test expiry. */\nexport function lockingScopeOf(\n\tq: FlatItem | undefined,\n\tlocks: ScopeLocks,\n\tassessmentExpired: boolean,\n): Pick<import('./AssessmentPlayer.js').AssessmentTimeExpiryEvent, 'scope' | 'identifier'> {\n\tif (assessmentExpired || !q) return { scope: 'assessment' };\n\tif (locks.isLocked('testPart', q.testPart.identifier)) {\n\t\treturn { scope: 'testPart', identifier: q.testPart.identifier };\n\t}\n\tfor (const section of q.sections) {\n\t\tif (locks.isLocked('section', section.identifier)) {\n\t\t\treturn { scope: 'section', identifier: section.identifier };\n\t\t}\n\t}\n\treturn { scope: 'item', identifier: q.identifier };\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers over serialized item sessions and response records.
|
|
3
|
+
*
|
|
4
|
+
* Moved out of `AssessmentPlayer.ts` verbatim (pure code motion): the player and
|
|
5
|
+
* the session coordinator share them, and none of them takes the transition lock
|
|
6
|
+
* or touches session state on its own.
|
|
7
|
+
*/
|
|
8
|
+
import type { SerializedItemSessionState } from '@pie-qti/item-player';
|
|
9
|
+
import type { ResponseDefault } from './AssessmentSessionCoordinator.js';
|
|
10
|
+
import type { ResponseValue } from '../integration/api-contract.js';
|
|
11
|
+
/**
|
|
12
|
+
* The persisted response-record type (what backends receive and what snapshots
|
|
13
|
+
* carry). Item sessions hold `unknown` values; every response the player persists
|
|
14
|
+
* or submits passes through this one boundary. The runtime value is unchanged —
|
|
15
|
+
* this single documented conversion replaces the scattered `as any` writes the
|
|
16
|
+
* player used to make into session state.
|
|
17
|
+
*/
|
|
18
|
+
export declare function asResponseValues(responses: Record<string, unknown>): Record<string, ResponseValue>;
|
|
19
|
+
export declare function cloneData<T>(value: T | undefined): T | undefined;
|
|
20
|
+
export declare function cloneResponseRecord(responses: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
21
|
+
export declare function valuesFromItemSession(state: SerializedItemSessionState): Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Each response variable's declared default from a serialized session (QTI: a response
|
|
24
|
+
* still equal to its default is no response — the `numberResponded` test). Variables
|
|
25
|
+
* without a declared default carry none, so NULL/empty stays the only skipped shape.
|
|
26
|
+
*/
|
|
27
|
+
export declare function responseDefaultsOf(state: Pick<SerializedItemSessionState, 'responseVariables'>): Record<string, ResponseDefault>;
|
|
28
|
+
export declare function responseValuesEqual(left: unknown, right: unknown): boolean;
|
|
29
|
+
export declare function isWritableItemLifecycle(lifecycleStatus: SerializedItemSessionState['lifecycleStatus']): boolean;
|
|
30
|
+
/** A serialized item session as the end of the test leaves it: an open or suspended one is closed. */
|
|
31
|
+
export declare function closedItemSession(session: SerializedItemSessionState): SerializedItemSessionState;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers over serialized item sessions and response records.
|
|
3
|
+
*
|
|
4
|
+
* Moved out of `AssessmentPlayer.ts` verbatim (pure code motion): the player and
|
|
5
|
+
* the session coordinator share them, and none of them takes the transition lock
|
|
6
|
+
* or touches session state on its own.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The persisted response-record type (what backends receive and what snapshots
|
|
10
|
+
* carry). Item sessions hold `unknown` values; every response the player persists
|
|
11
|
+
* or submits passes through this one boundary. The runtime value is unchanged —
|
|
12
|
+
* this single documented conversion replaces the scattered `as any` writes the
|
|
13
|
+
* player used to make into session state.
|
|
14
|
+
*/
|
|
15
|
+
export function asResponseValues(responses) {
|
|
16
|
+
return responses;
|
|
17
|
+
}
|
|
18
|
+
export function cloneData(value) {
|
|
19
|
+
return value === undefined ? undefined : structuredClone(value);
|
|
20
|
+
}
|
|
21
|
+
export function cloneResponseRecord(responses) {
|
|
22
|
+
return structuredClone(responses);
|
|
23
|
+
}
|
|
24
|
+
export function valuesFromItemSession(state) {
|
|
25
|
+
return Object.fromEntries(Object.entries(state.responseVariables).map(([identifier, variable]) => [
|
|
26
|
+
identifier,
|
|
27
|
+
cloneData(variable.value),
|
|
28
|
+
]));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Each response variable's declared default from a serialized session (QTI: a response
|
|
32
|
+
* still equal to its default is no response — the `numberResponded` test). Variables
|
|
33
|
+
* without a declared default carry none, so NULL/empty stays the only skipped shape.
|
|
34
|
+
*/
|
|
35
|
+
export function responseDefaultsOf(state) {
|
|
36
|
+
const out = {};
|
|
37
|
+
for (const [identifier, variable] of Object.entries(state.responseVariables)) {
|
|
38
|
+
if (variable.defaultValue === null || variable.defaultValue === undefined)
|
|
39
|
+
continue;
|
|
40
|
+
out[identifier] = { value: variable.defaultValue, cardinality: variable.cardinality };
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
export function responseValuesEqual(left, right) {
|
|
45
|
+
if (Object.is(left, right))
|
|
46
|
+
return true;
|
|
47
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
48
|
+
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length)
|
|
49
|
+
return false;
|
|
50
|
+
return left.every((value, index) => responseValuesEqual(value, right[index]));
|
|
51
|
+
}
|
|
52
|
+
if (!isRecord(left) || !isRecord(right))
|
|
53
|
+
return false;
|
|
54
|
+
const leftKeys = Object.keys(left);
|
|
55
|
+
const rightKeys = Object.keys(right);
|
|
56
|
+
if (leftKeys.length !== rightKeys.length)
|
|
57
|
+
return false;
|
|
58
|
+
const rightKeySet = new Set(rightKeys);
|
|
59
|
+
return leftKeys.every((key) => rightKeySet.has(key) && responseValuesEqual(left[key], right[key]));
|
|
60
|
+
}
|
|
61
|
+
function isRecord(value) {
|
|
62
|
+
return value !== null && typeof value === 'object';
|
|
63
|
+
}
|
|
64
|
+
export function isWritableItemLifecycle(lifecycleStatus) {
|
|
65
|
+
return lifecycleStatus === 'initial' || lifecycleStatus === 'interacting';
|
|
66
|
+
}
|
|
67
|
+
/** A serialized item session as the end of the test leaves it: an open or suspended one is closed. */
|
|
68
|
+
export function closedItemSession(session) {
|
|
69
|
+
const open = session.lifecycleStatus === 'initial' ||
|
|
70
|
+
session.lifecycleStatus === 'interacting' ||
|
|
71
|
+
session.lifecycleStatus === 'suspended';
|
|
72
|
+
return open ? { ...session, lifecycleStatus: 'closed' } : session;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=sessionRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionRecords.js","sourceRoot":"","sources":["../../src/core/sessionRecords.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;GAM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AAED,sGAAsG;AACtG,MAAM,UAAU,iBAAiB,CAAC,OAAmC;IACpE,MAAM,IAAI,GACT,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,eAAe,KAAK,aAAa;QACzC,OAAO,CAAC,eAAe,KAAK,WAAW,CAAC;IACzC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACnE,CAAC","sourcesContent":["/**\n * Pure helpers over serialized item sessions and response records.\n *\n * Moved out of `AssessmentPlayer.ts` verbatim (pure code motion): the player and\n * the session coordinator share them, and none of them takes the transition lock\n * or touches session state on its own.\n */\n\nimport type { SerializedItemSessionState } from '@pie-qti/item-player';\nimport type { ResponseDefault } from './AssessmentSessionCoordinator.js';\nimport type { ResponseValue } from '../integration/api-contract.js';\n\n/**\n * The persisted response-record type (what backends receive and what snapshots\n * carry). Item sessions hold `unknown` values; every response the player persists\n * or submits passes through this one boundary. The runtime value is unchanged —\n * this single documented conversion replaces the scattered `as any` writes the\n * player used to make into session state.\n */\nexport function asResponseValues(responses: Record<string, unknown>): Record<string, ResponseValue> {\n\treturn responses as Record<string, ResponseValue>;\n}\n\nexport function cloneData<T>(value: T | undefined): T | undefined {\n\treturn value === undefined ? undefined : structuredClone(value);\n}\n\nexport function cloneResponseRecord(\n\tresponses: Readonly<Record<string, unknown>>,\n): Record<string, unknown> {\n\treturn structuredClone(responses) as Record<string, unknown>;\n}\n\nexport function valuesFromItemSession(\n\tstate: SerializedItemSessionState,\n): Record<string, unknown> {\n\treturn Object.fromEntries(\n\t\tObject.entries(state.responseVariables).map(([identifier, variable]) => [\n\t\t\tidentifier,\n\t\t\tcloneData(variable.value),\n\t\t]),\n\t);\n}\n\n/**\n * Each response variable's declared default from a serialized session (QTI: a response\n * still equal to its default is no response — the `numberResponded` test). Variables\n * without a declared default carry none, so NULL/empty stays the only skipped shape.\n */\nexport function responseDefaultsOf(\n\tstate: Pick<SerializedItemSessionState, 'responseVariables'>,\n): Record<string, ResponseDefault> {\n\tconst out: Record<string, ResponseDefault> = {};\n\tfor (const [identifier, variable] of Object.entries(state.responseVariables)) {\n\t\tif (variable.defaultValue === null || variable.defaultValue === undefined) continue;\n\t\tout[identifier] = { value: variable.defaultValue, cardinality: variable.cardinality };\n\t}\n\treturn out;\n}\n\nexport function responseValuesEqual(left: unknown, right: unknown): boolean {\n\tif (Object.is(left, right)) return true;\n\tif (Array.isArray(left) || Array.isArray(right)) {\n\t\tif (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;\n\t\treturn left.every((value, index) => responseValuesEqual(value, right[index]));\n\t}\n\tif (!isRecord(left) || !isRecord(right)) return false;\n\n\tconst leftKeys = Object.keys(left);\n\tconst rightKeys = Object.keys(right);\n\tif (leftKeys.length !== rightKeys.length) return false;\n\tconst rightKeySet = new Set(rightKeys);\n\treturn leftKeys.every(\n\t\t(key) => rightKeySet.has(key) && responseValuesEqual(left[key], right[key]),\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object';\n}\n\nexport function isWritableItemLifecycle(lifecycleStatus: SerializedItemSessionState['lifecycleStatus']): boolean {\n\treturn lifecycleStatus === 'initial' || lifecycleStatus === 'interacting';\n}\n\n/** A serialized item session as the end of the test leaves it: an open or suspended one is closed. */\nexport function closedItemSession(session: SerializedItemSessionState): SerializedItemSessionState {\n\tconst open =\n\t\tsession.lifecycleStatus === 'initial' ||\n\t\tsession.lifecycleStatus === 'interacting' ||\n\t\tsession.lifecycleStatus === 'suspended';\n\treturn open ? { ...session, lifecycleStatus: 'closed' } : session;\n}\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Submission policy.
|
|
3
|
+
*
|
|
4
|
+
* The QTI itemSessionControl submission gate (`allowSkipping` / `validateResponses`)
|
|
5
|
+
* and the coded rejections for held-back items. Moved out of `AssessmentPlayer.ts`
|
|
6
|
+
* verbatim (pure code motion): pure decisions over explicit inputs — no lock, no
|
|
7
|
+
* session state. Kept deliberately separate from the constraint-validation layer:
|
|
8
|
+
* *whether* an item may be skipped or must validate is policy; *what* the item's
|
|
9
|
+
* interactions require is read live from a detached item session by the orchestrator
|
|
10
|
+
* (`responseValidationFor`) and only shapes the blocker's user-facing `requirement`.
|
|
11
|
+
*/
|
|
12
|
+
import type { FlatItem } from './deliveryStructure.js';
|
|
13
|
+
import { type ResponseDefault } from './AssessmentSessionCoordinator.js';
|
|
14
|
+
import type { ItemSessionControlSettings } from './ItemSessionController.js';
|
|
15
|
+
/**
|
|
16
|
+
* QTI itemSessionControl `allowSkipping` / `validateResponses` for one item's
|
|
17
|
+
* responses. Both are "only applicable when the item is in a testPart with individual
|
|
18
|
+
* submission mode", so a simultaneous part is never gated. A skipped item (no
|
|
19
|
+
* response at all: every response NULL, empty or still equal to its declared default —
|
|
20
|
+
* the test `numberResponded` applies) may be submitted only when skipping is allowed,
|
|
21
|
+
* and is then not validated; an answered item validates when the item asks for it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function submissionGate(options: {
|
|
24
|
+
individual: boolean;
|
|
25
|
+
settings: Pick<ItemSessionControlSettings, 'allowSkipping' | 'validateResponses'>;
|
|
26
|
+
responses: Record<string, unknown>;
|
|
27
|
+
defaults: Readonly<Record<string, ResponseDefault>>;
|
|
28
|
+
}): {
|
|
29
|
+
mustAnswer: boolean;
|
|
30
|
+
validate: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* An item a candidate-initiated end of the test would refuse to submit
|
|
34
|
+
* (`getSubmissionBlockers()`): QTI `allowSkipping=false` with no response (`required`),
|
|
35
|
+
* or `validateResponses=true` with responses that do not satisfy the interactions
|
|
36
|
+
* (`invalid`). Both apply only to items in individual submission parts.
|
|
37
|
+
*/
|
|
38
|
+
export interface SubmissionBlocker {
|
|
39
|
+
identifier: string;
|
|
40
|
+
/** Flat delivery index (for `navigateTo`). */
|
|
41
|
+
index: number;
|
|
42
|
+
/** 1-based position shown to the candidate. */
|
|
43
|
+
number: number;
|
|
44
|
+
reason: 'required' | 'invalid';
|
|
45
|
+
/** Whether the navigation rules let the candidate jump to it now. */
|
|
46
|
+
jumpAllowed: boolean;
|
|
47
|
+
/** False when the candidate can no longer reach the question (its part was left). */
|
|
48
|
+
reachable: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* What the response still owes, when derivable from the item's interaction constraints
|
|
51
|
+
* (a minimum number of selections, strings, associations or plays); absent when the
|
|
52
|
+
* item only needs an answer. The shell localizes it into the entry text.
|
|
53
|
+
*/
|
|
54
|
+
requirement?: {
|
|
55
|
+
kind: 'minChoices' | 'minStrings' | 'minAssociations' | 'minPlays' | 'incomplete';
|
|
56
|
+
count?: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Reject a candidate-initiated end of the test (or part leave) that would submit held-back items, naming them. */
|
|
60
|
+
export declare function throwForBlockers(blockers: ReadonlyArray<SubmissionBlocker>, context: 'finalize' | 'leavePart'): void;
|
|
61
|
+
/** Assemble the blocker view for an item a submission control would refuse right now. */
|
|
62
|
+
export declare function submissionBlockerFor(q: FlatItem, reason: SubmissionBlocker['reason'], requirement: SubmissionBlocker['requirement'] | undefined, jumpAllowed: boolean): SubmissionBlocker;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Submission policy.
|
|
3
|
+
*
|
|
4
|
+
* The QTI itemSessionControl submission gate (`allowSkipping` / `validateResponses`)
|
|
5
|
+
* and the coded rejections for held-back items. Moved out of `AssessmentPlayer.ts`
|
|
6
|
+
* verbatim (pure code motion): pure decisions over explicit inputs — no lock, no
|
|
7
|
+
* session state. Kept deliberately separate from the constraint-validation layer:
|
|
8
|
+
* *whether* an item may be skipped or must validate is policy; *what* the item's
|
|
9
|
+
* interactions require is read live from a detached item session by the orchestrator
|
|
10
|
+
* (`responseValidationFor`) and only shapes the blocker's user-facing `requirement`.
|
|
11
|
+
*/
|
|
12
|
+
import { isSkippedResponseSet } from './AssessmentSessionCoordinator.js';
|
|
13
|
+
import { AssessmentPlayerError } from './errors.js';
|
|
14
|
+
/**
|
|
15
|
+
* QTI itemSessionControl `allowSkipping` / `validateResponses` for one item's
|
|
16
|
+
* responses. Both are "only applicable when the item is in a testPart with individual
|
|
17
|
+
* submission mode", so a simultaneous part is never gated. A skipped item (no
|
|
18
|
+
* response at all: every response NULL, empty or still equal to its declared default —
|
|
19
|
+
* the test `numberResponded` applies) may be submitted only when skipping is allowed,
|
|
20
|
+
* and is then not validated; an answered item validates when the item asks for it.
|
|
21
|
+
*/
|
|
22
|
+
export function submissionGate(options) {
|
|
23
|
+
const { individual, settings, responses, defaults } = options;
|
|
24
|
+
if (!individual)
|
|
25
|
+
return { mustAnswer: false, validate: false };
|
|
26
|
+
const skipped = isSkippedResponseSet(responses, defaults);
|
|
27
|
+
return {
|
|
28
|
+
mustAnswer: skipped && settings.allowSkipping === false,
|
|
29
|
+
validate: !skipped && settings.validateResponses === true,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Reject a candidate-initiated end of the test (or part leave) that would submit held-back items, naming them. */
|
|
33
|
+
export function throwForBlockers(blockers, context) {
|
|
34
|
+
const required = blockers.filter((blocker) => blocker.reason === 'required');
|
|
35
|
+
const named = required.length > 0 ? required : blockers;
|
|
36
|
+
if (named.length === 0)
|
|
37
|
+
return;
|
|
38
|
+
const code = context === 'finalize'
|
|
39
|
+
? required.length > 0
|
|
40
|
+
? 'finalizeResponseRequired'
|
|
41
|
+
: 'finalizeResponseInvalid'
|
|
42
|
+
: required.length > 0
|
|
43
|
+
? 'leavePartResponseRequired'
|
|
44
|
+
: 'leavePartResponseInvalid';
|
|
45
|
+
const identifiers = named.map((blocker) => blocker.identifier);
|
|
46
|
+
const what = context === 'finalize' ? 'the test can end' : 'leaving this test part';
|
|
47
|
+
throw new AssessmentPlayerError(code, required.length > 0
|
|
48
|
+
? `These items need a response before ${what}: ${identifiers.join(', ')}`
|
|
49
|
+
: `These items have responses that do not satisfy their interactions (before ${what}): ${identifiers.join(', ')}`, {
|
|
50
|
+
items: named.map((blocker) => blocker.number).join(', '),
|
|
51
|
+
itemIdentifiers: identifiers.join(','),
|
|
52
|
+
count: named.length,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Assemble the blocker view for an item a submission control would refuse right now. */
|
|
56
|
+
export function submissionBlockerFor(q, reason, requirement, jumpAllowed) {
|
|
57
|
+
return {
|
|
58
|
+
identifier: q.identifier,
|
|
59
|
+
index: q.index,
|
|
60
|
+
number: q.index + 1,
|
|
61
|
+
reason,
|
|
62
|
+
jumpAllowed,
|
|
63
|
+
reachable: jumpAllowed,
|
|
64
|
+
...(requirement ? { requirement } : {}),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=submissionPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submissionPolicy.js","sourceRoot":"","sources":["../../src/core/submissionPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,oBAAoB,EAAwB,MAAM,mCAAmC,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAkC,MAAM,aAAa,CAAC;AAEpF;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,OAK9B;IACA,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC9D,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC/D,MAAM,OAAO,GAAG,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC1D,OAAO;QACN,UAAU,EAAE,OAAO,IAAI,QAAQ,CAAC,aAAa,KAAK,KAAK;QACvD,QAAQ,EAAE,CAAC,OAAO,IAAI,QAAQ,CAAC,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,CAAC;QACxD,eAAe,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QACtC,KAAK,EAAE,KAAK,CAAC,MAAM;KACnB,CACD,CAAC;AACH,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,oBAAoB,CACnC,CAAW,EACX,MAAmC,EACnC,WAAyD,EACzD,WAAoB;IAEpB,OAAO;QACN,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,MAAM,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC;QACnB,MAAM;QACN,WAAW;QACX,SAAS,EAAE,WAAW;QACtB,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvC,CAAC;AACH,CAAC","sourcesContent":["/**\n * Submission policy.\n *\n * The QTI itemSessionControl submission gate (`allowSkipping` / `validateResponses`)\n * and the coded rejections for held-back items. Moved out of `AssessmentPlayer.ts`\n * verbatim (pure code motion): pure decisions over explicit inputs — no lock, no\n * session state. Kept deliberately separate from the constraint-validation layer:\n * *whether* an item may be skipped or must validate is policy; *what* the item's\n * interactions require is read live from a detached item session by the orchestrator\n * (`responseValidationFor`) and only shapes the blocker's user-facing `requirement`.\n */\n\nimport type { FlatItem } from './deliveryStructure.js';\nimport { isSkippedResponseSet, type ResponseDefault } from './AssessmentSessionCoordinator.js';\nimport type { ItemSessionControlSettings } from './ItemSessionController.js';\nimport { AssessmentPlayerError, type AssessmentPlayerErrorCode } from './errors.js';\n\n/**\n * QTI itemSessionControl `allowSkipping` / `validateResponses` for one item's\n * responses. Both are \"only applicable when the item is in a testPart with individual\n * submission mode\", so a simultaneous part is never gated. A skipped item (no\n * response at all: every response NULL, empty or still equal to its declared default —\n * the test `numberResponded` applies) may be submitted only when skipping is allowed,\n * and is then not validated; an answered item validates when the item asks for it.\n */\nexport function submissionGate(options: {\n\tindividual: boolean;\n\tsettings: Pick<ItemSessionControlSettings, 'allowSkipping' | 'validateResponses'>;\n\tresponses: Record<string, unknown>;\n\tdefaults: Readonly<Record<string, ResponseDefault>>;\n}): { mustAnswer: boolean; validate: boolean } {\n\tconst { individual, settings, responses, defaults } = options;\n\tif (!individual) return { mustAnswer: false, validate: false };\n\tconst skipped = isSkippedResponseSet(responses, defaults);\n\treturn {\n\t\tmustAnswer: skipped && settings.allowSkipping === false,\n\t\tvalidate: !skipped && settings.validateResponses === true,\n\t};\n}\n\n/**\n * An item a candidate-initiated end of the test would refuse to submit\n * (`getSubmissionBlockers()`): QTI `allowSkipping=false` with no response (`required`),\n * or `validateResponses=true` with responses that do not satisfy the interactions\n * (`invalid`). Both apply only to items in individual submission parts.\n */\nexport interface SubmissionBlocker {\n\tidentifier: string;\n\t/** Flat delivery index (for `navigateTo`). */\n\tindex: number;\n\t/** 1-based position shown to the candidate. */\n\tnumber: number;\n\treason: 'required' | 'invalid';\n\t/** Whether the navigation rules let the candidate jump to it now. */\n\tjumpAllowed: boolean;\n\t/** False when the candidate can no longer reach the question (its part was left). */\n\treachable: boolean;\n\t/**\n\t * What the response still owes, when derivable from the item's interaction constraints\n\t * (a minimum number of selections, strings, associations or plays); absent when the\n\t * item only needs an answer. The shell localizes it into the entry text.\n\t */\n\trequirement?: { kind: 'minChoices' | 'minStrings' | 'minAssociations' | 'minPlays' | 'incomplete'; count?: number };\n}\n\n/** Reject a candidate-initiated end of the test (or part leave) that would submit held-back items, naming them. */\nexport function throwForBlockers(blockers: ReadonlyArray<SubmissionBlocker>, context: 'finalize' | 'leavePart'): void {\n\tconst required = blockers.filter((blocker) => blocker.reason === 'required');\n\tconst named = required.length > 0 ? required : blockers;\n\tif (named.length === 0) return;\n\tconst code: AssessmentPlayerErrorCode =\n\t\tcontext === 'finalize'\n\t\t\t? required.length > 0\n\t\t\t\t? 'finalizeResponseRequired'\n\t\t\t\t: 'finalizeResponseInvalid'\n\t\t\t: required.length > 0\n\t\t\t\t? 'leavePartResponseRequired'\n\t\t\t\t: 'leavePartResponseInvalid';\n\tconst identifiers = named.map((blocker) => blocker.identifier);\n\tconst what = context === 'finalize' ? 'the test can end' : 'leaving this test part';\n\tthrow new AssessmentPlayerError(\n\t\tcode,\n\t\trequired.length > 0\n\t\t\t? `These items need a response before ${what}: ${identifiers.join(', ')}`\n\t\t\t: `These items have responses that do not satisfy their interactions (before ${what}): ${identifiers.join(', ')}`,\n\t\t{\n\t\t\titems: named.map((blocker) => blocker.number).join(', '),\n\t\t\titemIdentifiers: identifiers.join(','),\n\t\t\tcount: named.length,\n\t\t},\n\t);\n}\n\n/** Assemble the blocker view for an item a submission control would refuse right now. */\nexport function submissionBlockerFor(\n\tq: FlatItem,\n\treason: SubmissionBlocker['reason'],\n\trequirement: SubmissionBlocker['requirement'] | undefined,\n\tjumpAllowed: boolean,\n): SubmissionBlocker {\n\treturn {\n\t\tidentifier: q.identifier,\n\t\tindex: q.index,\n\t\tnumber: q.index + 1,\n\t\treason,\n\t\tjumpAllowed,\n\t\treachable: jumpAllowed,\n\t\t...(requirement ? { requirement } : {}),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template defaults policy (QTI `templateDefault`).
|
|
3
|
+
*
|
|
4
|
+
* How an item's new session is seeded in a nonlinear test part: evaluated once,
|
|
5
|
+
* at the start of the part, for every item ref in it — with the test outcomes and
|
|
6
|
+
* the other items' variables (`ITEM.VARIABLE`, as persisted so far; NULL for an
|
|
7
|
+
* item not instantiated yet) in scope — and cached for the part. Linear parts
|
|
8
|
+
* evaluate each item's defaults on entering it, against the test outcomes.
|
|
9
|
+
*
|
|
10
|
+
* Moved out of `AssessmentPlayer.ts` verbatim (pure code motion): pure functions
|
|
11
|
+
* over the delivery structure, the assessment and the persisted sessions — the
|
|
12
|
+
* orchestrator passes the part cache in and keeps owning it. No lock.
|
|
13
|
+
*/
|
|
14
|
+
import type { SerializedItemSessionState } from '@pie-qti/item-player';
|
|
15
|
+
import type { SecureAssessment, TestOutcomeValues } from '../integration/api-contract.js';
|
|
16
|
+
import type { FlatItem } from './deliveryStructure.js';
|
|
17
|
+
/** Template defaults of nonlinear test parts, per part → item identifier (the player's part cache). */
|
|
18
|
+
export type TemplateDefaultsByPart = Map<string, Map<string, Record<string, unknown> | undefined>>;
|
|
19
|
+
export declare function templateDefaultsFor(options: {
|
|
20
|
+
q: FlatItem;
|
|
21
|
+
items: readonly FlatItem[];
|
|
22
|
+
assessment: SecureAssessment;
|
|
23
|
+
outcomes: TestOutcomeValues | null;
|
|
24
|
+
persistedSessions: Record<string, SerializedItemSessionState> | undefined;
|
|
25
|
+
byPart: TemplateDefaultsByPart;
|
|
26
|
+
}): Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template defaults policy (QTI `templateDefault`).
|
|
3
|
+
*
|
|
4
|
+
* How an item's new session is seeded in a nonlinear test part: evaluated once,
|
|
5
|
+
* at the start of the part, for every item ref in it — with the test outcomes and
|
|
6
|
+
* the other items' variables (`ITEM.VARIABLE`, as persisted so far; NULL for an
|
|
7
|
+
* item not instantiated yet) in scope — and cached for the part. Linear parts
|
|
8
|
+
* evaluate each item's defaults on entering it, against the test outcomes.
|
|
9
|
+
*
|
|
10
|
+
* Moved out of `AssessmentPlayer.ts` verbatim (pure code motion): pure functions
|
|
11
|
+
* over the delivery structure, the assessment and the persisted sessions — the
|
|
12
|
+
* orchestrator passes the part cache in and keeps owning it. No lock.
|
|
13
|
+
*/
|
|
14
|
+
import { addItemVariableDeclarations, applyVariableMappings, evaluateTestExpression, itemSessionVariableValues, plainQtiValue, testOutcomeDeclarations, } from './testStructure.js';
|
|
15
|
+
export function templateDefaultsFor(options) {
|
|
16
|
+
const { q, items, assessment, outcomes, persistedSessions, byPart } = options;
|
|
17
|
+
if (q.testPart.navigationMode !== 'nonlinear') {
|
|
18
|
+
if (!q.item.templateDefaults?.length)
|
|
19
|
+
return undefined;
|
|
20
|
+
return evaluateTemplateDefaults(q, testOutcomeDeclarations(assessment, outcomes ?? undefined));
|
|
21
|
+
}
|
|
22
|
+
let defaults = byPart.get(q.testPart.identifier);
|
|
23
|
+
if (!defaults) {
|
|
24
|
+
const declarations = addItemVariableDeclarations(testOutcomeDeclarations(assessment, outcomes ?? undefined), persistedItemVariables(items, persistedSessions));
|
|
25
|
+
defaults = new Map(items
|
|
26
|
+
.filter((item) => item.testPart === q.testPart)
|
|
27
|
+
.map((item) => [item.identifier, evaluateTemplateDefaults(item, declarations)]));
|
|
28
|
+
byPart.set(q.testPart.identifier, defaults);
|
|
29
|
+
}
|
|
30
|
+
return defaults.get(q.identifier);
|
|
31
|
+
}
|
|
32
|
+
/** Every item's variables from its persisted session, as test-scope expressions read them. */
|
|
33
|
+
function persistedItemVariables(items, persistedSessions) {
|
|
34
|
+
const out = {};
|
|
35
|
+
for (const item of items) {
|
|
36
|
+
const serialized = persistedSessions?.[item.identifier];
|
|
37
|
+
if (!serialized)
|
|
38
|
+
continue;
|
|
39
|
+
out[item.identifier] = applyVariableMappings(itemSessionVariableValues(serialized), item.item.variableMappings);
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function evaluateTemplateDefaults(q, declarations) {
|
|
44
|
+
const defaults = q.item.templateDefaults;
|
|
45
|
+
if (!defaults?.length)
|
|
46
|
+
return undefined;
|
|
47
|
+
const out = {};
|
|
48
|
+
for (const { templateIdentifier, expressionXml } of defaults) {
|
|
49
|
+
out[templateIdentifier] = plainQtiValue(evaluateTestExpression(expressionXml, declarations, Math.random));
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=templateDefaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateDefaults.js","sourceRoot":"","sources":["../../src/core/templateDefaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EACN,2BAA2B,EAC3B,qBAAqB,EACr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AAC;AAED,8FAA8F;AAC9F,SAAS,sBAAsB,CAC9B,KAA0B,EAC1B,iBAAyE;IAEzE,MAAM,GAAG,GAA6C,EAAE,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU;YAAE,SAAS;QAC1B,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC,yBAAyB,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,wBAAwB,CAAC,CAAW,EAAE,YAA4B;IAC1E,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACzC,IAAI,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC9D,GAAG,CAAC,kBAAkB,CAAC,GAAG,aAAa,CAAC,sBAAsB,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3G,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["/**\n * Template defaults policy (QTI `templateDefault`).\n *\n * How an item's new session is seeded in a nonlinear test part: evaluated once,\n * at the start of the part, for every item ref in it — with the test outcomes and\n * the other items' variables (`ITEM.VARIABLE`, as persisted so far; NULL for an\n * item not instantiated yet) in scope — and cached for the part. Linear parts\n * evaluate each item's defaults on entering it, against the test outcomes.\n *\n * Moved out of `AssessmentPlayer.ts` verbatim (pure code motion): pure functions\n * over the delivery structure, the assessment and the persisted sessions — the\n * orchestrator passes the part cache in and keeps owning it. No lock.\n */\n\nimport type { DeclarationMap, QtiValue } from '@pie-qti/qti-processing';\nimport type { SerializedItemSessionState } from '@pie-qti/item-player';\nimport type { SecureAssessment, TestOutcomeValues } from '../integration/api-contract.js';\nimport type { FlatItem } from './deliveryStructure.js';\nimport {\n\taddItemVariableDeclarations,\n\tapplyVariableMappings,\n\tevaluateTestExpression,\n\titemSessionVariableValues,\n\tplainQtiValue,\n\ttestOutcomeDeclarations,\n} from './testStructure.js';\n\n/** Template defaults of nonlinear test parts, per part → item identifier (the player's part cache). */\nexport type TemplateDefaultsByPart = Map<string, Map<string, Record<string, unknown> | undefined>>;\n\nexport function templateDefaultsFor(options: {\n\tq: FlatItem;\n\titems: readonly FlatItem[];\n\tassessment: SecureAssessment;\n\toutcomes: TestOutcomeValues | null;\n\tpersistedSessions: Record<string, SerializedItemSessionState> | undefined;\n\tbyPart: TemplateDefaultsByPart;\n}): Record<string, unknown> | undefined {\n\tconst { q, items, assessment, outcomes, persistedSessions, byPart } = options;\n\tif (q.testPart.navigationMode !== 'nonlinear') {\n\t\tif (!q.item.templateDefaults?.length) return undefined;\n\t\treturn evaluateTemplateDefaults(q, testOutcomeDeclarations(assessment, outcomes ?? undefined));\n\t}\n\tlet defaults = byPart.get(q.testPart.identifier);\n\tif (!defaults) {\n\t\tconst declarations = addItemVariableDeclarations(\n\t\t\ttestOutcomeDeclarations(assessment, outcomes ?? undefined),\n\t\t\tpersistedItemVariables(items, persistedSessions),\n\t\t);\n\t\tdefaults = new Map(\n\t\t\titems\n\t\t\t\t.filter((item) => item.testPart === q.testPart)\n\t\t\t\t.map((item) => [item.identifier, evaluateTemplateDefaults(item, declarations)]),\n\t\t);\n\t\tbyPart.set(q.testPart.identifier, defaults);\n\t}\n\treturn defaults.get(q.identifier);\n}\n\n/** Every item's variables from its persisted session, as test-scope expressions read them. */\nfunction persistedItemVariables(\n\titems: readonly FlatItem[],\n\tpersistedSessions: Record<string, SerializedItemSessionState> | undefined,\n): Record<string, Record<string, QtiValue>> {\n\tconst out: Record<string, Record<string, QtiValue>> = {};\n\tfor (const item of items) {\n\t\tconst serialized = persistedSessions?.[item.identifier];\n\t\tif (!serialized) continue;\n\t\tout[item.identifier] = applyVariableMappings(itemSessionVariableValues(serialized), item.item.variableMappings);\n\t}\n\treturn out;\n}\n\nfunction evaluateTemplateDefaults(q: FlatItem, declarations: DeclarationMap): Record<string, unknown> | undefined {\n\tconst defaults = q.item.templateDefaults;\n\tif (!defaults?.length) return undefined;\n\tconst out: Record<string, unknown> = {};\n\tfor (const { templateIdentifier, expressionXml } of defaults) {\n\t\tout[templateIdentifier] = plainQtiValue(evaluateTestExpression(expressionXml, declarations, Math.random));\n\t}\n\treturn out;\n}\n"]}
|