@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
|
@@ -0,0 +1,28 @@
|
|
|
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 const DELIVERY_STATE_VERSION = 1;
|
|
12
|
+
/** The instance id of the `occurrence`th selection of an item-ref: `item-3`, `item-3#2`. */
|
|
13
|
+
export const itemInstanceId = (itemRefIdentifier, occurrence = 1) => occurrence === 1 ? itemRefIdentifier : `${itemRefIdentifier}#${occurrence}`;
|
|
14
|
+
/**
|
|
15
|
+
* Read a stored state back. Throws on a state this release cannot read (another version, or not a
|
|
16
|
+
* state at all) rather than guessing, so a host never resumes from something half understood.
|
|
17
|
+
*/
|
|
18
|
+
export function parseDeliveryState(value) {
|
|
19
|
+
if (typeof value !== 'object' || value === null) {
|
|
20
|
+
throw new TypeError('A delivery state is an object.');
|
|
21
|
+
}
|
|
22
|
+
const { version } = value;
|
|
23
|
+
if (version !== DELIVERY_STATE_VERSION) {
|
|
24
|
+
throw new RangeError(`Delivery state version ${String(version)} is not supported; expected ${DELIVERY_STATE_VERSION}.`);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=delivery-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-state.js","sourceRoot":"","sources":["../../src/state/delivery-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AA6BxC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,iBAAyB,EAAE,UAAU,GAAG,CAAC,EAAkB,EAAE,CAC1F,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,iBAAiB,IAAI,UAAU,EAAE,CAAC;AAE9E;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,KAA8B,CAAC;IACnD,IAAI,OAAO,KAAK,sBAAsB,EAAE,CAAC;QACvC,MAAM,IAAI,UAAU,CAClB,0BAA0B,MAAM,CAAC,OAAO,CAAC,+BAA+B,sBAAsB,GAAG,CAClG,CAAC;IACJ,CAAC;IACD,OAAO,KAAsB,CAAC;AAChC,CAAC","sourcesContent":["/**\n * The one source of truth for one candidate in one test: what a resumed test, or a server taking\n * over, needs to carry on. Written only through commands; every context is an input or a view\n * derived from it, and anything derivable (done, can*, scores) is never stored here. Plain JSON,\n * versioned, so a stored state can be read back by a later release (or a .NET port) and refused\n * when it cannot.\n *\n * Experimental (0.x): roadmap 1 fills in the target fields, phase by phase; see\n * `plans/delivery-state.md`.\n */\nexport const DELIVERY_STATE_VERSION = 1;\n\n/**\n * One item session. With `with-replacement` selection a single item-ref appears more than once,\n * so a session is keyed by its instance, never by the item-ref identifier alone.\n */\nexport type ItemInstanceId = string;\n\nexport interface ItemDeliveryState {\n /** The `identifier` of the `qti-assessment-item-ref` this instance was selected from. */\n itemRefIdentifier: string;\n /** 1 for the first time the item-ref was selected, 2 for its first clone, and so on. */\n occurrence: number;\n}\n\nexport interface DeliveryState {\n version: typeof DELIVERY_STATE_VERSION;\n /**\n * The seed actually used for selection and ordering; the same seed gives the same test on every\n * runtime. On a first start it comes from the host (`qtiContext.seed`); on resume this one wins.\n */\n seed: string | null;\n /** When the test started, in milliseconds since the epoch, read from the injected clock. */\n startedAt: number;\n /** The item instance on screen, or null before the first navigation and after the end. */\n current: ItemInstanceId | null;\n items: Record<ItemInstanceId, ItemDeliveryState>;\n}\n\n/** The instance id of the `occurrence`th selection of an item-ref: `item-3`, `item-3#2`. */\nexport const itemInstanceId = (itemRefIdentifier: string, occurrence = 1): ItemInstanceId =>\n occurrence === 1 ? itemRefIdentifier : `${itemRefIdentifier}#${occurrence}`;\n\n/**\n * Read a stored state back. Throws on a state this release cannot read (another version, or not a\n * state at all) rather than guessing, so a host never resumes from something half understood.\n */\nexport function parseDeliveryState(value: unknown): DeliveryState {\n if (typeof value !== 'object' || value === null) {\n throw new TypeError('A delivery state is an object.');\n }\n const { version } = value as { version?: unknown };\n if (version !== DELIVERY_STATE_VERSION) {\n throw new RangeError(\n `Delivery state version ${String(version)} is not supported; expected ${DELIVERY_STATE_VERSION}.`\n );\n }\n return value as DeliveryState;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qti-components/delivery",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "The QTI 3 delivery engine: test model, item session lifecycle, sequencing and session state, with no browser globals",
|
|
4
|
+
"version": "0.1.0-next.0",
|
|
5
|
+
"author": "",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"qti",
|
|
8
|
+
"delivery"
|
|
9
|
+
],
|
|
10
|
+
"license": "GPL-3.0-only",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"type": "module",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/Citolab/qti-components.git",
|
|
30
|
+
"directory": "packages/qti-delivery"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@xmldom/xmldom": "^0.9.12"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"attw": "attw --profile esm-only --pack",
|
|
37
|
+
"build": "pnpm run clean && tsc --paths null",
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"yalc": "yalc publish",
|
|
40
|
+
"yalc:push": "yalc push"
|
|
41
|
+
}
|
|
6
42
|
}
|
package/README.md
DELETED