@qti-components/delivery 0.0.0-stage → 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +674 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/model/test-model.d.ts +74 -0
- package/dist/model/test-model.js +102 -0
- package/dist/model/test-model.js.map +1 -0
- package/dist/model/xml-node.d.ts +24 -0
- package/dist/model/xml-node.js +30 -0
- package/dist/model/xml-node.js.map +1 -0
- package/dist/processing.d.ts +10 -0
- package/dist/processing.js +2 -0
- package/dist/processing.js.map +1 -0
- package/dist/random/seeded-random.d.ts +20 -0
- package/dist/random/seeded-random.js +76 -0
- package/dist/random/seeded-random.js.map +1 -0
- package/dist/random/shuffle.d.ts +9 -0
- package/dist/random/shuffle.js +15 -0
- package/dist/random/shuffle.js.map +1 -0
- package/dist/state/clock.d.ts +12 -0
- package/dist/state/clock.js +5 -0
- package/dist/state/clock.js.map +1 -0
- package/dist/state/commands.d.ts +59 -0
- package/dist/state/commands.js +2 -0
- package/dist/state/commands.js.map +1 -0
- package/dist/state/create-delivery-state.d.ts +8 -0
- package/dist/state/create-delivery-state.js +6 -0
- package/dist/state/create-delivery-state.js.map +1 -0
- package/dist/state/delivery-state.d.ts +42 -0
- package/dist/state/delivery-state.js +28 -0
- package/dist/state/delivery-state.js.map +1 -0
- package/package.json +39 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './model/test-model.js';
|
|
2
|
+
export type { XmlElement, XmlNode } from './model/xml-node.js';
|
|
3
|
+
export * from './random/seeded-random.js';
|
|
4
|
+
export * from './random/shuffle.js';
|
|
5
|
+
export * from './state/clock.js';
|
|
6
|
+
export * from './state/commands.js';
|
|
7
|
+
export * from './state/create-delivery-state.js';
|
|
8
|
+
export * from './state/delivery-state.js';
|
|
9
|
+
export * from './processing.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './model/test-model.js';
|
|
2
|
+
export * from './random/seeded-random.js';
|
|
3
|
+
export * from './random/shuffle.js';
|
|
4
|
+
export * from './state/clock.js';
|
|
5
|
+
export * from './state/commands.js';
|
|
6
|
+
export * from './state/create-delivery-state.js';
|
|
7
|
+
export * from './state/delivery-state.js';
|
|
8
|
+
export * from './processing.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './model/test-model.js';\nexport type { XmlElement, XmlNode } from './model/xml-node.js';\nexport * from './random/seeded-random.js';\nexport * from './random/shuffle.js';\nexport * from './state/clock.js';\nexport * from './state/commands.js';\nexport * from './state/create-delivery-state.js';\nexport * from './state/delivery-state.js';\nexport * from './processing.js';\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { XmlElement } from './xml-node.js';
|
|
2
|
+
/**
|
|
3
|
+
* The structure and the resolved rules of a `qti-assessment-test`, read from its XML once per load.
|
|
4
|
+
* Plain JSON, so a server can build it from the same file.
|
|
5
|
+
*
|
|
6
|
+
* Experimental (0.x): roadmap 1 phase T1; see `plans/test-model.md`.
|
|
7
|
+
*/
|
|
8
|
+
export interface TestModel {
|
|
9
|
+
identifier: string;
|
|
10
|
+
title: string;
|
|
11
|
+
testParts: TestPartModel[];
|
|
12
|
+
}
|
|
13
|
+
export interface TestPartModel {
|
|
14
|
+
identifier: string;
|
|
15
|
+
/** Defined on the test part only (QTI 3 XSD); a section never changes it. */
|
|
16
|
+
navigationMode: 'linear' | 'nonlinear';
|
|
17
|
+
submissionMode: 'individual' | 'simultaneous';
|
|
18
|
+
sessionControl: SessionControl;
|
|
19
|
+
sections: SectionModel[];
|
|
20
|
+
}
|
|
21
|
+
export interface SectionModel {
|
|
22
|
+
kind: 'section';
|
|
23
|
+
identifier: string;
|
|
24
|
+
title: string;
|
|
25
|
+
visible: boolean;
|
|
26
|
+
sessionControl: SessionControl;
|
|
27
|
+
/** The item-refs and sections directly inside this one, in document order, as the XML has them. */
|
|
28
|
+
content: SectionContent[];
|
|
29
|
+
}
|
|
30
|
+
export interface ItemRefModel {
|
|
31
|
+
kind: 'itemRef';
|
|
32
|
+
identifier: string;
|
|
33
|
+
href: string;
|
|
34
|
+
categories: string[];
|
|
35
|
+
sessionControl: SessionControl;
|
|
36
|
+
/** What this item-ref's own `qti-item-session-control` declares, nothing inherited. */
|
|
37
|
+
declaredSessionControl: Partial<SessionControl>;
|
|
38
|
+
}
|
|
39
|
+
export type SectionContent = SectionModel | ItemRefModel;
|
|
40
|
+
/** `qti-item-session-control`, resolved for one level (QTI 3 info model §7.19). */
|
|
41
|
+
export interface SessionControl {
|
|
42
|
+
/** 0 is unlimited. Ignored for adaptive items, which end by `completionStatus`. */
|
|
43
|
+
maxAttempts: number;
|
|
44
|
+
showFeedback: boolean;
|
|
45
|
+
allowReview: boolean;
|
|
46
|
+
showSolution: boolean;
|
|
47
|
+
allowComment: boolean;
|
|
48
|
+
/** Applies only in a test part with individual submission. */
|
|
49
|
+
allowSkipping: boolean;
|
|
50
|
+
/** Applies only in a test part with individual submission. */
|
|
51
|
+
validateResponses: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The values when no level declares an attribute: the XSD defaults, and 1 for `max-attempts`,
|
|
55
|
+
* which the spec text gives ("if it is unspecified it is treated as 1 for non-adaptive items").
|
|
56
|
+
*/
|
|
57
|
+
export declare const DEFAULT_SESSION_CONTROL: Readonly<SessionControl>;
|
|
58
|
+
/**
|
|
59
|
+
* Build the model of a test from its `qti-assessment-test` element: the XML document under Node, the
|
|
60
|
+
* rendered element in the browser. Reads attributes and child elements only, so no element needs
|
|
61
|
+
* to be registered.
|
|
62
|
+
*
|
|
63
|
+
* Session control inherits per attribute: each one comes from the closest level that declares it
|
|
64
|
+
* (item-ref, then each enclosing section, then the test part), and its default only when none does.
|
|
65
|
+
* The spec: a test-part setting applies "unless the setting is overridden", and the defaults "are
|
|
66
|
+
* used only in the absence of any applicable constraint" (implementation guide §4.4.2).
|
|
67
|
+
*/
|
|
68
|
+
export declare function buildTestModel(test: XmlElement): TestModel;
|
|
69
|
+
/** The item-refs directly inside a section, in document order; not those of its subsections. */
|
|
70
|
+
export declare const ownItemRefs: (section: SectionModel) => ItemRefModel[];
|
|
71
|
+
/** Every section, depth first in document order: a section before its subsections. */
|
|
72
|
+
export declare function sectionsInOrder(sections: SectionModel[]): SectionModel[];
|
|
73
|
+
/** Every item-ref inside the given sections, at any depth, in document order. */
|
|
74
|
+
export declare function itemRefsInOrder(sections: SectionContent[]): ItemRefModel[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { booleanAttribute, childElement, childElements, integerAttribute } from './xml-node.js';
|
|
2
|
+
/**
|
|
3
|
+
* The values when no level declares an attribute: the XSD defaults, and 1 for `max-attempts`,
|
|
4
|
+
* which the spec text gives ("if it is unspecified it is treated as 1 for non-adaptive items").
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_SESSION_CONTROL = Object.freeze({
|
|
7
|
+
maxAttempts: 1,
|
|
8
|
+
showFeedback: false,
|
|
9
|
+
allowReview: true,
|
|
10
|
+
showSolution: false,
|
|
11
|
+
allowComment: false,
|
|
12
|
+
allowSkipping: true,
|
|
13
|
+
validateResponses: false
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Build the model of a test from its `qti-assessment-test` element: the XML document under Node, the
|
|
17
|
+
* rendered element in the browser. Reads attributes and child elements only, so no element needs
|
|
18
|
+
* to be registered.
|
|
19
|
+
*
|
|
20
|
+
* Session control inherits per attribute: each one comes from the closest level that declares it
|
|
21
|
+
* (item-ref, then each enclosing section, then the test part), and its default only when none does.
|
|
22
|
+
* The spec: a test-part setting applies "unless the setting is overridden", and the defaults "are
|
|
23
|
+
* used only in the absence of any applicable constraint" (implementation guide §4.4.2).
|
|
24
|
+
*/
|
|
25
|
+
export function buildTestModel(test) {
|
|
26
|
+
if (test.localName !== 'qti-assessment-test') {
|
|
27
|
+
throw new TypeError(`Expected a qti-assessment-test element, not ${String(test.localName)}.`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
identifier: test.getAttribute('identifier') ?? '',
|
|
31
|
+
title: test.getAttribute('title') ?? '',
|
|
32
|
+
testParts: childElements(test, 'qti-test-part').map(buildTestPart)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function buildTestPart(part) {
|
|
36
|
+
const sessionControl = resolveSessionControl(DEFAULT_SESSION_CONTROL, part);
|
|
37
|
+
return {
|
|
38
|
+
identifier: part.getAttribute('identifier') ?? '',
|
|
39
|
+
navigationMode: part.getAttribute('navigation-mode') === 'linear' ? 'linear' : 'nonlinear',
|
|
40
|
+
submissionMode: part.getAttribute('submission-mode') === 'simultaneous' ? 'simultaneous' : 'individual',
|
|
41
|
+
sessionControl,
|
|
42
|
+
sections: childElements(part, 'qti-assessment-section').map(section => buildSection(section, sessionControl))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function buildSection(section, inherited) {
|
|
46
|
+
const sessionControl = resolveSessionControl(inherited, section);
|
|
47
|
+
return {
|
|
48
|
+
kind: 'section',
|
|
49
|
+
identifier: section.getAttribute('identifier') ?? '',
|
|
50
|
+
title: section.getAttribute('title') ?? '',
|
|
51
|
+
visible: booleanAttribute(section, 'visible') ?? true,
|
|
52
|
+
sessionControl,
|
|
53
|
+
content: childElements(section, 'qti-assessment-section', 'qti-assessment-item-ref').map(child => child.localName === 'qti-assessment-section'
|
|
54
|
+
? buildSection(child, sessionControl)
|
|
55
|
+
: buildItemRef(child, sessionControl))
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function buildItemRef(itemRef, inherited) {
|
|
59
|
+
const category = itemRef.getAttribute('category')?.trim();
|
|
60
|
+
return {
|
|
61
|
+
kind: 'itemRef',
|
|
62
|
+
identifier: itemRef.getAttribute('identifier') ?? '',
|
|
63
|
+
href: itemRef.getAttribute('href') ?? '',
|
|
64
|
+
categories: category ? category.split(/\s+/) : [],
|
|
65
|
+
sessionControl: resolveSessionControl(inherited, itemRef),
|
|
66
|
+
declaredSessionControl: declaredSessionControl(itemRef)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** `inherited`, with what `owner`'s own `qti-item-session-control` declares on top. */
|
|
70
|
+
function resolveSessionControl(inherited, owner) {
|
|
71
|
+
return { ...inherited, ...declaredSessionControl(owner) };
|
|
72
|
+
}
|
|
73
|
+
/** Only the attributes `owner`'s `qti-item-session-control` declares, so an absent one inherits. */
|
|
74
|
+
function declaredSessionControl(owner) {
|
|
75
|
+
const element = childElement(owner, 'qti-item-session-control');
|
|
76
|
+
if (!element)
|
|
77
|
+
return {};
|
|
78
|
+
const declared = {
|
|
79
|
+
maxAttempts: integerAttribute(element, 'max-attempts'),
|
|
80
|
+
showFeedback: booleanAttribute(element, 'show-feedback'),
|
|
81
|
+
allowReview: booleanAttribute(element, 'allow-review'),
|
|
82
|
+
showSolution: booleanAttribute(element, 'show-solution'),
|
|
83
|
+
allowComment: booleanAttribute(element, 'allow-comment'),
|
|
84
|
+
allowSkipping: booleanAttribute(element, 'allow-skipping'),
|
|
85
|
+
validateResponses: booleanAttribute(element, 'validate-responses')
|
|
86
|
+
};
|
|
87
|
+
return Object.fromEntries(Object.entries(declared).filter(([, value]) => value !== undefined));
|
|
88
|
+
}
|
|
89
|
+
/** The item-refs directly inside a section, in document order; not those of its subsections. */
|
|
90
|
+
export const ownItemRefs = (section) => section.content.filter((child) => child.kind === 'itemRef');
|
|
91
|
+
/** Every section, depth first in document order: a section before its subsections. */
|
|
92
|
+
export function sectionsInOrder(sections) {
|
|
93
|
+
return sections.flatMap(section => [
|
|
94
|
+
section,
|
|
95
|
+
...sectionsInOrder(section.content.filter((child) => child.kind === 'section'))
|
|
96
|
+
]);
|
|
97
|
+
}
|
|
98
|
+
/** Every item-ref inside the given sections, at any depth, in document order. */
|
|
99
|
+
export function itemRefsInOrder(sections) {
|
|
100
|
+
return sections.flatMap(child => (child.kind === 'itemRef' ? [child] : itemRefsInOrder(child.content)));
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=test-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-model.js","sourceRoot":"","sources":["../../src/model/test-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AA6DhG;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA6B,MAAM,CAAC,MAAM,CAAC;IAC7E,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,KAAK;CACzB,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,IAAgB;IAC7C,IAAI,IAAI,CAAC,SAAS,KAAK,qBAAqB,EAAE,CAAC;QAC7C,MAAM,IAAI,SAAS,CAAC,+CAA+C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAChG,CAAC;IACD,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,EAAE;QACjD,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE;QAC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AAgB,CAAC,OAAO,EAAE,eAAe,CAAC;QACxD,aAAa,EAAE,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,CAAC;QAC1D,iBAAiB,EAAE,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,CAAC;KACnE,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;AACjG,CAAC;AAED,gGAAgG;AAChG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAqB,EAAkB,EAAE,CACnE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAyB,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;AAErF,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,QAAwB;IACtD,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,OAAO;QACP,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAyB,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;KACvG,CAAC,CAAC;AACL,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,eAAe,CAAC,QAA0B;IACxD,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["import { booleanAttribute, childElement, childElements, integerAttribute } from './xml-node.js';\n\nimport type { XmlElement } from './xml-node.js';\n\n/**\n * The structure and the resolved rules of a `qti-assessment-test`, read from its XML once per load.\n * Plain JSON, so a server can build it from the same file.\n *\n * Experimental (0.x): roadmap 1 phase T1; see `plans/test-model.md`.\n */\nexport interface TestModel {\n identifier: string;\n title: string;\n testParts: TestPartModel[];\n}\n\nexport interface TestPartModel {\n identifier: string;\n /** Defined on the test part only (QTI 3 XSD); a section never changes it. */\n navigationMode: 'linear' | 'nonlinear';\n submissionMode: 'individual' | 'simultaneous';\n sessionControl: SessionControl;\n sections: SectionModel[];\n}\n\nexport interface SectionModel {\n kind: 'section';\n identifier: string;\n title: string;\n visible: boolean;\n sessionControl: SessionControl;\n /** The item-refs and sections directly inside this one, in document order, as the XML has them. */\n content: SectionContent[];\n}\n\nexport interface ItemRefModel {\n kind: 'itemRef';\n identifier: string;\n href: string;\n categories: string[];\n sessionControl: SessionControl;\n /** What this item-ref's own `qti-item-session-control` declares, nothing inherited. */\n declaredSessionControl: Partial<SessionControl>;\n}\n\nexport type SectionContent = SectionModel | ItemRefModel;\n\n/** `qti-item-session-control`, resolved for one level (QTI 3 info model §7.19). */\nexport interface SessionControl {\n /** 0 is unlimited. Ignored for adaptive items, which end by `completionStatus`. */\n maxAttempts: number;\n showFeedback: boolean;\n allowReview: boolean;\n showSolution: boolean;\n allowComment: boolean;\n /** Applies only in a test part with individual submission. */\n allowSkipping: boolean;\n /** Applies only in a test part with individual submission. */\n validateResponses: boolean;\n}\n\n/**\n * The values when no level declares an attribute: the XSD defaults, and 1 for `max-attempts`,\n * which the spec text gives (\"if it is unspecified it is treated as 1 for non-adaptive items\").\n */\nexport const DEFAULT_SESSION_CONTROL: Readonly<SessionControl> = Object.freeze({\n maxAttempts: 1,\n showFeedback: false,\n allowReview: true,\n showSolution: false,\n allowComment: false,\n allowSkipping: true,\n validateResponses: false\n});\n\n/**\n * Build the model of a test from its `qti-assessment-test` element: the XML document under Node, the\n * rendered element in the browser. Reads attributes and child elements only, so no element needs\n * to be registered.\n *\n * Session control inherits per attribute: each one comes from the closest level that declares it\n * (item-ref, then each enclosing section, then the test part), and its default only when none does.\n * The spec: a test-part setting applies \"unless the setting is overridden\", and the defaults \"are\n * used only in the absence of any applicable constraint\" (implementation guide §4.4.2).\n */\nexport function buildTestModel(test: XmlElement): TestModel {\n if (test.localName !== 'qti-assessment-test') {\n throw new TypeError(`Expected a qti-assessment-test element, not ${String(test.localName)}.`);\n }\n return {\n identifier: test.getAttribute('identifier') ?? '',\n title: test.getAttribute('title') ?? '',\n testParts: childElements(test, 'qti-test-part').map(buildTestPart)\n };\n}\n\nfunction buildTestPart(part: XmlElement): TestPartModel {\n const sessionControl = resolveSessionControl(DEFAULT_SESSION_CONTROL, part);\n return {\n identifier: part.getAttribute('identifier') ?? '',\n navigationMode: part.getAttribute('navigation-mode') === 'linear' ? 'linear' : 'nonlinear',\n submissionMode: part.getAttribute('submission-mode') === 'simultaneous' ? 'simultaneous' : 'individual',\n sessionControl,\n sections: childElements(part, 'qti-assessment-section').map(section => buildSection(section, sessionControl))\n };\n}\n\nfunction buildSection(section: XmlElement, inherited: SessionControl): SectionModel {\n const sessionControl = resolveSessionControl(inherited, section);\n return {\n kind: 'section',\n identifier: section.getAttribute('identifier') ?? '',\n title: section.getAttribute('title') ?? '',\n visible: booleanAttribute(section, 'visible') ?? true,\n sessionControl,\n content: childElements(section, 'qti-assessment-section', 'qti-assessment-item-ref').map(child =>\n child.localName === 'qti-assessment-section'\n ? buildSection(child, sessionControl)\n : buildItemRef(child, sessionControl)\n )\n };\n}\n\nfunction buildItemRef(itemRef: XmlElement, inherited: SessionControl): ItemRefModel {\n const category = itemRef.getAttribute('category')?.trim();\n return {\n kind: 'itemRef',\n identifier: itemRef.getAttribute('identifier') ?? '',\n href: itemRef.getAttribute('href') ?? '',\n categories: category ? category.split(/\\s+/) : [],\n sessionControl: resolveSessionControl(inherited, itemRef),\n declaredSessionControl: declaredSessionControl(itemRef)\n };\n}\n\n/** `inherited`, with what `owner`'s own `qti-item-session-control` declares on top. */\nfunction resolveSessionControl(inherited: Readonly<SessionControl>, owner: XmlElement): SessionControl {\n return { ...inherited, ...declaredSessionControl(owner) };\n}\n\n/** Only the attributes `owner`'s `qti-item-session-control` declares, so an absent one inherits. */\nfunction declaredSessionControl(owner: XmlElement): Partial<SessionControl> {\n const element = childElement(owner, 'qti-item-session-control');\n if (!element) return {};\n const declared: Partial<SessionControl> = {\n maxAttempts: integerAttribute(element, 'max-attempts'),\n showFeedback: booleanAttribute(element, 'show-feedback'),\n allowReview: booleanAttribute(element, 'allow-review'),\n showSolution: booleanAttribute(element, 'show-solution'),\n allowComment: booleanAttribute(element, 'allow-comment'),\n allowSkipping: booleanAttribute(element, 'allow-skipping'),\n validateResponses: booleanAttribute(element, 'validate-responses')\n };\n return Object.fromEntries(Object.entries(declared).filter(([, value]) => value !== undefined));\n}\n\n/** The item-refs directly inside a section, in document order; not those of its subsections. */\nexport const ownItemRefs = (section: SectionModel): ItemRefModel[] =>\n section.content.filter((child): child is ItemRefModel => child.kind === 'itemRef');\n\n/** Every section, depth first in document order: a section before its subsections. */\nexport function sectionsInOrder(sections: SectionModel[]): SectionModel[] {\n return sections.flatMap(section => [\n section,\n ...sectionsInOrder(section.content.filter((child): child is SectionModel => child.kind === 'section'))\n ]);\n}\n\n/** Every item-ref inside the given sections, at any depth, in document order. */\nexport function itemRefsInOrder(sections: SectionContent[]): ItemRefModel[] {\n return sections.flatMap(child => (child.kind === 'itemRef' ? [child] : itemRefsInOrder(child.content)));\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of a DOM element that `delivery` reads: a browser `Element` and an `@xmldom/xmldom`
|
|
3
|
+
* element both satisfy it, so the same code builds the model in the browser and under Node. Only
|
|
4
|
+
* attributes and child elements, never upgraded properties, so nothing depends on a custom element
|
|
5
|
+
* being registered.
|
|
6
|
+
*/
|
|
7
|
+
export interface XmlElement {
|
|
8
|
+
readonly nodeType: number;
|
|
9
|
+
readonly localName: string | null;
|
|
10
|
+
readonly childNodes: ArrayLike<XmlNode>;
|
|
11
|
+
/** Null when the attribute is absent, in the browser and in xmldom alike. */
|
|
12
|
+
getAttribute(name: string): string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface XmlNode {
|
|
15
|
+
readonly nodeType: number;
|
|
16
|
+
}
|
|
17
|
+
/** The child elements of `parent` with one of the given local names, in document order. */
|
|
18
|
+
export declare function childElements(parent: XmlElement, ...localNames: string[]): XmlElement[];
|
|
19
|
+
/** The first child element with the given local name, or null. */
|
|
20
|
+
export declare const childElement: (parent: XmlElement, localName: string) => XmlElement | null;
|
|
21
|
+
/** An `xs:boolean` attribute: `true`/`1` and `false`/`0`; anything else, or absent, is undefined. */
|
|
22
|
+
export declare function booleanAttribute(element: XmlElement, name: string): boolean | undefined;
|
|
23
|
+
/** An `xs:int` attribute, or undefined when absent or not an integer. */
|
|
24
|
+
export declare function integerAttribute(element: XmlElement, name: string): number | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const ELEMENT_NODE = 1;
|
|
2
|
+
/** The child elements of `parent` with one of the given local names, in document order. */
|
|
3
|
+
export function childElements(parent, ...localNames) {
|
|
4
|
+
const nodes = parent.childNodes;
|
|
5
|
+
const children = [];
|
|
6
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
7
|
+
const node = nodes[index];
|
|
8
|
+
if (node.nodeType === ELEMENT_NODE && localNames.includes(node.localName ?? '')) {
|
|
9
|
+
children.push(node);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return children;
|
|
13
|
+
}
|
|
14
|
+
/** The first child element with the given local name, or null. */
|
|
15
|
+
export const childElement = (parent, localName) => childElements(parent, localName)[0] ?? null;
|
|
16
|
+
/** An `xs:boolean` attribute: `true`/`1` and `false`/`0`; anything else, or absent, is undefined. */
|
|
17
|
+
export function booleanAttribute(element, name) {
|
|
18
|
+
const value = element.getAttribute(name)?.trim();
|
|
19
|
+
if (value === 'true' || value === '1')
|
|
20
|
+
return true;
|
|
21
|
+
if (value === 'false' || value === '0')
|
|
22
|
+
return false;
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/** An `xs:int` attribute, or undefined when absent or not an integer. */
|
|
26
|
+
export function integerAttribute(element, name) {
|
|
27
|
+
const value = element.getAttribute(name)?.trim();
|
|
28
|
+
return value && /^[+-]?\d+$/.test(value) ? Number(value) : undefined;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=xml-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml-node.js","sourceRoot":"","sources":["../../src/model/xml-node.ts"],"names":[],"mappings":"AAkBA,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,2FAA2F;AAC3F,MAAM,UAAU,aAAa,CAAC,MAAkB,EAAE,GAAG,UAAoB;IACvE,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;IAChC,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAClC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,QAAQ,KAAK,YAAY,IAAI,UAAU,CAAC,QAAQ,CAAE,IAAmB,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;YAChG,QAAQ,CAAC,IAAI,CAAC,IAAkB,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAkB,EAAE,SAAiB,EAAqB,EAAE,CACvF,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAE9C,qGAAqG;AACrG,MAAM,UAAU,gBAAgB,CAAC,OAAmB,EAAE,IAAY;IAChE,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACjD,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACnD,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IACrD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAAC,OAAmB,EAAE,IAAY;IAChE,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACjD,OAAO,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC","sourcesContent":["/**\n * The part of a DOM element that `delivery` reads: a browser `Element` and an `@xmldom/xmldom`\n * element both satisfy it, so the same code builds the model in the browser and under Node. Only\n * attributes and child elements, never upgraded properties, so nothing depends on a custom element\n * being registered.\n */\nexport interface XmlElement {\n readonly nodeType: number;\n readonly localName: string | null;\n readonly childNodes: ArrayLike<XmlNode>;\n /** Null when the attribute is absent, in the browser and in xmldom alike. */\n getAttribute(name: string): string | null;\n}\n\nexport interface XmlNode {\n readonly nodeType: number;\n}\n\nconst ELEMENT_NODE = 1;\n\n/** The child elements of `parent` with one of the given local names, in document order. */\nexport function childElements(parent: XmlElement, ...localNames: string[]): XmlElement[] {\n const nodes = parent.childNodes;\n const children: XmlElement[] = [];\n for (let index = 0; index < nodes.length; index++) {\n const node = nodes[index];\n if (node.nodeType === ELEMENT_NODE && localNames.includes((node as XmlElement).localName ?? '')) {\n children.push(node as XmlElement);\n }\n }\n return children;\n}\n\n/** The first child element with the given local name, or null. */\nexport const childElement = (parent: XmlElement, localName: string): XmlElement | null =>\n childElements(parent, localName)[0] ?? null;\n\n/** An `xs:boolean` attribute: `true`/`1` and `false`/`0`; anything else, or absent, is undefined. */\nexport function booleanAttribute(element: XmlElement, name: string): boolean | undefined {\n const value = element.getAttribute(name)?.trim();\n if (value === 'true' || value === '1') return true;\n if (value === 'false' || value === '0') return false;\n return undefined;\n}\n\n/** An `xs:int` attribute, or undefined when absent or not an integer. */\nexport function integerAttribute(element: XmlElement, name: string): number | undefined {\n const value = element.getAttribute(name)?.trim();\n return value && /^[+-]?\\d+$/.test(value) ? Number(value) : undefined;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ItemInstanceId } from './state/delivery-state.js';
|
|
2
|
+
/**
|
|
3
|
+
* The seam to response and outcome processing. `delivery` decides when processing runs; the
|
|
4
|
+
* runtime runs it. In the browser that is the `qti-processing` elements; on a server, a processor
|
|
5
|
+
* that needs no DOM (roadmap 3) or the .NET qti-scoring-engine.
|
|
6
|
+
*/
|
|
7
|
+
export interface Processor {
|
|
8
|
+
responseProcessing(item: ItemInstanceId): void | Promise<void>;
|
|
9
|
+
outcomeProcessing(): void | Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processing.js","sourceRoot":"","sources":["../src/processing.ts"],"names":[],"mappings":"","sourcesContent":["import type { ItemInstanceId } from './state/delivery-state.js';\n\n/**\n * The seam to response and outcome processing. `delivery` decides when processing runs; the\n * runtime runs it. In the browser that is the `qti-processing` elements; on a server, a processor\n * that needs no DOM (roadmap 3) or the .NET qti-scoring-engine.\n */\nexport interface Processor {\n responseProcessing(item: ItemInstanceId): void | Promise<void>;\n outcomeProcessing(): void | Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SeededRandomSource {
|
|
2
|
+
random(): number;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Small, dependency-free seeded PRNG used for deterministic QTI shuffling
|
|
6
|
+
* (sections and interactions). It intentionally exposes a `random()` method,
|
|
7
|
+
* matching the TC39 seeded-random proposal shape so this can be swapped when a
|
|
8
|
+
* standard implementation is available.
|
|
9
|
+
*
|
|
10
|
+
* xmur3-style seed hashing feeds mulberry32 (fast 32-bit generator).
|
|
11
|
+
*/
|
|
12
|
+
export declare class SeededRandom implements SeededRandomSource {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(seed: Uint8Array);
|
|
15
|
+
static fromSeed(seed: Uint8Array): SeededRandom;
|
|
16
|
+
static fromFixed(byte: number): SeededRandom;
|
|
17
|
+
static fromSeedKey(seedKey: string | number): SeededRandom;
|
|
18
|
+
random(): number;
|
|
19
|
+
}
|
|
20
|
+
export declare function createSeededRandom(seedKey: string | number): SeededRandomSource;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small, dependency-free seeded PRNG used for deterministic QTI shuffling
|
|
3
|
+
* (sections and interactions). It intentionally exposes a `random()` method,
|
|
4
|
+
* matching the TC39 seeded-random proposal shape so this can be swapped when a
|
|
5
|
+
* standard implementation is available.
|
|
6
|
+
*
|
|
7
|
+
* xmur3-style seed hashing feeds mulberry32 (fast 32-bit generator).
|
|
8
|
+
*/
|
|
9
|
+
export class SeededRandom {
|
|
10
|
+
#state;
|
|
11
|
+
constructor(seed) {
|
|
12
|
+
if (!(seed instanceof Uint8Array)) {
|
|
13
|
+
throw new TypeError('SeededRandom seed must be a Uint8Array.');
|
|
14
|
+
}
|
|
15
|
+
if (seed.length > 32) {
|
|
16
|
+
throw new RangeError('SeededRandom seed must be 32 bytes or less.');
|
|
17
|
+
}
|
|
18
|
+
const paddedSeed = new Uint8Array(32);
|
|
19
|
+
paddedSeed.set(seed, 32 - seed.length);
|
|
20
|
+
this.#state = hashBytes(paddedSeed);
|
|
21
|
+
}
|
|
22
|
+
static fromSeed(seed) {
|
|
23
|
+
if (seed.length !== 32) {
|
|
24
|
+
throw new RangeError('SeededRandom.fromSeed requires a 32-byte seed.');
|
|
25
|
+
}
|
|
26
|
+
return new SeededRandom(seed);
|
|
27
|
+
}
|
|
28
|
+
static fromFixed(byte) {
|
|
29
|
+
if (typeof byte !== 'number') {
|
|
30
|
+
throw new TypeError('SeededRandom.fromFixed requires a number.');
|
|
31
|
+
}
|
|
32
|
+
if (!Number.isInteger(byte) || byte < 0 || byte > 255) {
|
|
33
|
+
throw new RangeError('SeededRandom.fromFixed requires an integer from 0 to 255.');
|
|
34
|
+
}
|
|
35
|
+
const seed = new Uint8Array(32);
|
|
36
|
+
seed[31] = byte;
|
|
37
|
+
return new SeededRandom(seed);
|
|
38
|
+
}
|
|
39
|
+
static fromSeedKey(seedKey) {
|
|
40
|
+
const random = new SeededRandom(new Uint8Array());
|
|
41
|
+
random.#state = hashString(`${seedKey}`);
|
|
42
|
+
return random;
|
|
43
|
+
}
|
|
44
|
+
random() {
|
|
45
|
+
this.#state |= 0;
|
|
46
|
+
this.#state = (this.#state + 0x6d2b79f5) | 0;
|
|
47
|
+
let t = Math.imul(this.#state ^ (this.#state >>> 15), 1 | this.#state);
|
|
48
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
49
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function createSeededRandom(seedKey) {
|
|
53
|
+
return SeededRandom.fromSeedKey(seedKey);
|
|
54
|
+
}
|
|
55
|
+
function hashString(seedKey) {
|
|
56
|
+
let h = 1779033703 ^ seedKey.length;
|
|
57
|
+
for (let i = 0; i < seedKey.length; i++) {
|
|
58
|
+
h = Math.imul(h ^ seedKey.charCodeAt(i), 3432918353);
|
|
59
|
+
h = (h << 13) | (h >>> 19);
|
|
60
|
+
}
|
|
61
|
+
return finalizeHash(h);
|
|
62
|
+
}
|
|
63
|
+
function hashBytes(seed) {
|
|
64
|
+
let h = 1779033703 ^ seed.length;
|
|
65
|
+
for (let i = 0; i < seed.length; i++) {
|
|
66
|
+
h = Math.imul(h ^ seed[i], 3432918353);
|
|
67
|
+
h = (h << 13) | (h >>> 19);
|
|
68
|
+
}
|
|
69
|
+
return finalizeHash(h);
|
|
70
|
+
}
|
|
71
|
+
function finalizeHash(hash) {
|
|
72
|
+
let h = Math.imul(hash ^ (hash >>> 16), 2246822507);
|
|
73
|
+
h = Math.imul(h ^ (h >>> 13), 3266489909);
|
|
74
|
+
return (h ^ (h >>> 16)) >>> 0;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=seeded-random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeded-random.js","sourceRoot":"","sources":["../../src/random/seeded-random.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,OAAO,YAAY;IACvB,MAAM,CAAS;IAEf,YAAY,IAAgB;QAC1B,IAAI,CAAC,CAAC,IAAI,YAAY,UAAU,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACrB,MAAM,IAAI,UAAU,CAAC,6CAA6C,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;QACtC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAgB;QAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YACvB,MAAM,IAAI,UAAU,CAAC,gDAAgD,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAY;QAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;QACnE,CA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AC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC","sourcesContent":["export interface SeededRandomSource {\n random(): number;\n}\n\n/**\n * Small, dependency-free seeded PRNG used for deterministic QTI shuffling\n * (sections and interactions). It intentionally exposes a `random()` method,\n * matching the TC39 seeded-random proposal shape so this can be swapped when a\n * standard implementation is available.\n *\n * xmur3-style seed hashing feeds mulberry32 (fast 32-bit generator).\n */\nexport class SeededRandom implements SeededRandomSource {\n #state: number;\n\n constructor(seed: Uint8Array) {\n if (!(seed instanceof Uint8Array)) {\n throw new TypeError('SeededRandom seed must be a Uint8Array.');\n }\n if (seed.length > 32) {\n throw new RangeError('SeededRandom seed must be 32 bytes or less.');\n }\n\n const paddedSeed = new Uint8Array(32);\n paddedSeed.set(seed, 32 - seed.length);\n this.#state = hashBytes(paddedSeed);\n }\n\n static fromSeed(seed: Uint8Array): SeededRandom {\n if (seed.length !== 32) {\n throw new RangeError('SeededRandom.fromSeed requires a 32-byte seed.');\n }\n return new SeededRandom(seed);\n }\n\n static fromFixed(byte: number): SeededRandom {\n if (typeof byte !== 'number') {\n throw new TypeError('SeededRandom.fromFixed requires a number.');\n }\n if (!Number.isInteger(byte) || byte < 0 || byte > 255) {\n throw new RangeError('SeededRandom.fromFixed requires an integer from 0 to 255.');\n }\n\n const seed = new Uint8Array(32);\n seed[31] = byte;\n return new SeededRandom(seed);\n }\n\n static fromSeedKey(seedKey: string | number): SeededRandom {\n const random = new SeededRandom(new Uint8Array());\n random.#state = hashString(`${seedKey}`);\n return random;\n }\n\n random(): number {\n this.#state |= 0;\n this.#state = (this.#state + 0x6d2b79f5) | 0;\n let t = Math.imul(this.#state ^ (this.#state >>> 15), 1 | this.#state);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n }\n}\n\nexport function createSeededRandom(seedKey: string | number): SeededRandomSource {\n return SeededRandom.fromSeedKey(seedKey);\n}\n\nfunction hashString(seedKey: string): number {\n let h = 1779033703 ^ seedKey.length;\n for (let i = 0; i < seedKey.length; i++) {\n h = Math.imul(h ^ seedKey.charCodeAt(i), 3432918353);\n h = (h << 13) | (h >>> 19);\n }\n return finalizeHash(h);\n}\n\nfunction hashBytes(seed: Uint8Array): number {\n let h = 1779033703 ^ seed.length;\n for (let i = 0; i < seed.length; i++) {\n h = Math.imul(h ^ seed[i], 3432918353);\n h = (h << 13) | (h >>> 19);\n }\n return finalizeHash(h);\n}\n\nfunction finalizeHash(hash: number): number {\n let h = Math.imul(hash ^ (hash >>> 16), 2246822507);\n h = Math.imul(h ^ (h >>> 13), 3266489909);\n return (h ^ (h >>> 16)) >>> 0;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SeededRandomSource } from './seeded-random.js';
|
|
2
|
+
export type RandomSource = SeededRandomSource | (() => number);
|
|
3
|
+
/**
|
|
4
|
+
* Fisher-Yates over non-fixed units only. Fixed units keep their authored slot
|
|
5
|
+
* index while movable units are shuffled into the remaining slots.
|
|
6
|
+
*/
|
|
7
|
+
export declare function shuffleKeepingFixed<T extends {
|
|
8
|
+
fixed: boolean;
|
|
9
|
+
}>(units: T[], random: RandomSource): T[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const randomValue = (source) => (typeof source === 'function' ? source() : source.random());
|
|
2
|
+
/**
|
|
3
|
+
* Fisher-Yates over non-fixed units only. Fixed units keep their authored slot
|
|
4
|
+
* index while movable units are shuffled into the remaining slots.
|
|
5
|
+
*/
|
|
6
|
+
export function shuffleKeepingFixed(units, random) {
|
|
7
|
+
const movable = units.filter(unit => !unit.fixed);
|
|
8
|
+
for (let i = movable.length - 1; i > 0; i--) {
|
|
9
|
+
const j = Math.floor(randomValue(random) * (i + 1));
|
|
10
|
+
[movable[i], movable[j]] = [movable[j], movable[i]];
|
|
11
|
+
}
|
|
12
|
+
let movableIndex = 0;
|
|
13
|
+
return units.map(unit => (unit.fixed ? unit : movable[movableIndex++]));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=shuffle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shuffle.js","sourceRoot":"","sources":["../../src/random/shuffle.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,GAAG,CAAC,MAAoB,EAAU,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAElH;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAA+B,KAAU,EAAE,MAAoB;IAChG,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAElD,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import type { SeededRandomSource } from './seeded-random.js';\n\nexport type RandomSource = SeededRandomSource | (() => number);\n\nconst randomValue = (source: RandomSource): number => (typeof source === 'function' ? source() : source.random());\n\n/**\n * Fisher-Yates over non-fixed units only. Fixed units keep their authored slot\n * index while movable units are shuffled into the remaining slots.\n */\nexport function shuffleKeepingFixed<T extends { fixed: boolean }>(units: T[], random: RandomSource): T[] {\n const movable = units.filter(unit => !unit.fixed);\n\n for (let i = movable.length - 1; i > 0; i--) {\n const j = Math.floor(randomValue(random) * (i + 1));\n [movable[i], movable[j]] = [movable[j], movable[i]];\n }\n\n let movableIndex = 0;\n return units.map(unit => (unit.fixed ? unit : movable[movableIndex++]));\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where `delivery` reads the time. Passed in, never read from the runtime, so a server can be the
|
|
3
|
+
* only clock a high-stakes test trusts, and a spec can fix the time.
|
|
4
|
+
*/
|
|
5
|
+
export interface Clock {
|
|
6
|
+
/** Milliseconds since the epoch. */
|
|
7
|
+
now(): number;
|
|
8
|
+
}
|
|
9
|
+
/** The runtime's own clock, for a browser or server that trusts itself. */
|
|
10
|
+
export declare const systemClock: Clock;
|
|
11
|
+
/** A clock that always answers `time`; for specs and test vectors. */
|
|
12
|
+
export declare const fixedClock: (time: number) => Clock;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The runtime's own clock, for a browser or server that trusts itself. */
|
|
2
|
+
export const systemClock = { now: () => Date.now() };
|
|
3
|
+
/** A clock that always answers `time`; for specs and test vectors. */
|
|
4
|
+
export const fixedClock = (time) => ({ now: () => time });
|
|
5
|
+
//# sourceMappingURL=clock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../../src/state/clock.ts"],"names":[],"mappings":"AASA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,WAAW,GAAU,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAE5D,sEAAsE;AACtE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC","sourcesContent":["/**\n * Where `delivery` reads the time. Passed in, never read from the runtime, so a server can be the\n * only clock a high-stakes test trusts, and a spec can fix the time.\n */\nexport interface Clock {\n /** Milliseconds since the epoch. */\n now(): number;\n}\n\n/** The runtime's own clock, for a browser or server that trusts itself. */\nexport const systemClock: Clock = { now: () => Date.now() };\n\n/** A clock that always answers `time`; for specs and test vectors. */\nexport const fixedClock = (time: number): Clock => ({ now: () => time });\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ItemInstanceId, DeliveryState } from './delivery-state.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a candidate, a host or a timer asks of the delivery. A server can sit at this boundary: the
|
|
4
|
+
* browser sends commands, the server answers with the new state and the effects.
|
|
5
|
+
*
|
|
6
|
+
* Experimental (0.x): the shapes are settled here; roadmap 1 (T3, T7, T8) gives them behaviour.
|
|
7
|
+
*/
|
|
8
|
+
export type Command = {
|
|
9
|
+
type: 'navigate';
|
|
10
|
+
target: NavigationTarget;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'beginAttempt';
|
|
13
|
+
item: ItemInstanceId;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'endAttempt';
|
|
16
|
+
item: ItemInstanceId;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'endTestPart';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'timeUp';
|
|
21
|
+
scope: 'test' | 'testPart' | 'section' | 'item';
|
|
22
|
+
identifier: string;
|
|
23
|
+
};
|
|
24
|
+
export type NavigationTarget = {
|
|
25
|
+
kind: 'next';
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'previous';
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'item';
|
|
30
|
+
item: ItemInstanceId;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'section';
|
|
33
|
+
identifier: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'feedback';
|
|
36
|
+
identifier: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* What the runtime has to do for a command: `delivery` decides, the runtime (a browser element, a
|
|
40
|
+
* server) carries it out.
|
|
41
|
+
*/
|
|
42
|
+
export type Effect = {
|
|
43
|
+
type: 'loadItem';
|
|
44
|
+
item: ItemInstanceId;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'runResponseProcessing';
|
|
47
|
+
item: ItemInstanceId;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'runOutcomeProcessing';
|
|
50
|
+
} | {
|
|
51
|
+
type: 'showTestFeedback';
|
|
52
|
+
identifier: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'testEnded';
|
|
55
|
+
};
|
|
56
|
+
export interface Transition {
|
|
57
|
+
state: DeliveryState;
|
|
58
|
+
effects: Effect[];
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/state/commands.ts"],"names":[],"mappings":"","sourcesContent":["import type { ItemInstanceId, DeliveryState } from './delivery-state.js';\n\n/**\n * What a candidate, a host or a timer asks of the delivery. A server can sit at this boundary: the\n * browser sends commands, the server answers with the new state and the effects.\n *\n * Experimental (0.x): the shapes are settled here; roadmap 1 (T3, T7, T8) gives them behaviour.\n */\nexport type Command =\n | { type: 'navigate'; target: NavigationTarget }\n | { type: 'beginAttempt'; item: ItemInstanceId }\n | { type: 'endAttempt'; item: ItemInstanceId }\n | { type: 'endTestPart' }\n | { type: 'timeUp'; scope: 'test' | 'testPart' | 'section' | 'item'; identifier: string };\n\nexport type NavigationTarget =\n | { kind: 'next' }\n | { kind: 'previous' }\n | { kind: 'item'; item: ItemInstanceId }\n | { kind: 'section'; identifier: string }\n | { kind: 'feedback'; identifier: string };\n\n/**\n * What the runtime has to do for a command: `delivery` decides, the runtime (a browser element, a\n * server) carries it out.\n */\nexport type Effect =\n | { type: 'loadItem'; item: ItemInstanceId }\n | { type: 'runResponseProcessing'; item: ItemInstanceId }\n | { type: 'runOutcomeProcessing' }\n | { type: 'showTestFeedback'; identifier: string }\n | { type: 'testEnded' };\n\nexport interface Transition {\n state: DeliveryState;\n effects: Effect[];\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Clock } from './clock.js';
|
|
2
|
+
import type { DeliveryState } from './delivery-state.js';
|
|
3
|
+
export interface CreateDeliveryStateOptions {
|
|
4
|
+
clock: Clock;
|
|
5
|
+
seed?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** A fresh delivery state: nothing selected, nothing on screen, started now by the given clock. */
|
|
8
|
+
export declare function createDeliveryState({ clock, seed }: CreateDeliveryStateOptions): DeliveryState;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DELIVERY_STATE_VERSION } from './delivery-state.js';
|
|
2
|
+
/** A fresh delivery state: nothing selected, nothing on screen, started now by the given clock. */
|
|
3
|
+
export function createDeliveryState({ clock, seed = null }) {
|
|
4
|
+
return { version: DELIVERY_STATE_VERSION, seed, startedAt: clock.now(), current: null, items: {} };
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=create-delivery-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-delivery-state.js","sourceRoot":"","sources":["../../src/state/create-delivery-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAU7D,mGAAmG;AACnG,MAAM,UAAU,mBAAmB,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,EAA8B;IACpF,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACrG,CAAC","sourcesContent":["import { DELIVERY_STATE_VERSION } from './delivery-state.js';\n\nimport type { Clock } from './clock.js';\nimport type { DeliveryState } from './delivery-state.js';\n\nexport interface CreateDeliveryStateOptions {\n clock: Clock;\n seed?: string | null;\n}\n\n/** A fresh delivery state: nothing selected, nothing on screen, started now by the given clock. */\nexport function createDeliveryState({ clock, seed = null }: CreateDeliveryStateOptions): DeliveryState {\n return { version: DELIVERY_STATE_VERSION, seed, startedAt: clock.now(), current: null, items: {} };\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one source of truth for one candidate in one test: what a resumed test, or a server taking
|
|
3
|
+
* over, needs to carry on. Written only through commands; every context is an input or a view
|
|
4
|
+
* derived from it, and anything derivable (done, can*, scores) is never stored here. Plain JSON,
|
|
5
|
+
* versioned, so a stored state can be read back by a later release (or a .NET port) and refused
|
|
6
|
+
* when it cannot.
|
|
7
|
+
*
|
|
8
|
+
* Experimental (0.x): roadmap 1 fills in the target fields, phase by phase; see
|
|
9
|
+
* `plans/delivery-state.md`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DELIVERY_STATE_VERSION = 1;
|
|
12
|
+
/**
|
|
13
|
+
* One item session. With `with-replacement` selection a single item-ref appears more than once,
|
|
14
|
+
* so a session is keyed by its instance, never by the item-ref identifier alone.
|
|
15
|
+
*/
|
|
16
|
+
export type ItemInstanceId = string;
|
|
17
|
+
export interface ItemDeliveryState {
|
|
18
|
+
/** The `identifier` of the `qti-assessment-item-ref` this instance was selected from. */
|
|
19
|
+
itemRefIdentifier: string;
|
|
20
|
+
/** 1 for the first time the item-ref was selected, 2 for its first clone, and so on. */
|
|
21
|
+
occurrence: number;
|
|
22
|
+
}
|
|
23
|
+
export interface DeliveryState {
|
|
24
|
+
version: typeof DELIVERY_STATE_VERSION;
|
|
25
|
+
/**
|
|
26
|
+
* The seed actually used for selection and ordering; the same seed gives the same test on every
|
|
27
|
+
* runtime. On a first start it comes from the host (`qtiContext.seed`); on resume this one wins.
|
|
28
|
+
*/
|
|
29
|
+
seed: string | null;
|
|
30
|
+
/** When the test started, in milliseconds since the epoch, read from the injected clock. */
|
|
31
|
+
startedAt: number;
|
|
32
|
+
/** The item instance on screen, or null before the first navigation and after the end. */
|
|
33
|
+
current: ItemInstanceId | null;
|
|
34
|
+
items: Record<ItemInstanceId, ItemDeliveryState>;
|
|
35
|
+
}
|
|
36
|
+
/** The instance id of the `occurrence`th selection of an item-ref: `item-3`, `item-3#2`. */
|
|
37
|
+
export declare const itemInstanceId: (itemRefIdentifier: string, occurrence?: number) => ItemInstanceId;
|
|
38
|
+
/**
|
|
39
|
+
* Read a stored state back. Throws on a state this release cannot read (another version, or not a
|
|
40
|
+
* state at all) rather than guessing, so a host never resumes from something half understood.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseDeliveryState(value: unknown): DeliveryState;
|