@qti-components/test 2.0.0-next.26 → 2.0.0-next.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/components/test-end-attempt/test-end-attempt.d.ts +7 -5
  2. package/dist/components/test-end-attempt/test-end-attempt.js +26 -31
  3. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  4. package/dist/components/test-navigation/test-navigation.d.ts +5 -4
  5. package/dist/components/test-navigation/test-navigation.js +146 -46
  6. package/dist/components/test-navigation/test-navigation.js.map +1 -1
  7. package/dist/components/test-next/test-next.d.ts +4 -1
  8. package/dist/components/test-next/test-next.js +16 -13
  9. package/dist/components/test-next/test-next.js.map +1 -1
  10. package/dist/components/test-prev/test-prev.js +10 -3
  11. package/dist/components/test-prev/test-prev.js.map +1 -1
  12. package/dist/internal/derive-computed-context.d.ts +0 -20
  13. package/dist/internal/derive-computed-context.js +6 -36
  14. package/dist/internal/derive-computed-context.js.map +1 -1
  15. package/dist/internal/test-host.context.d.ts +14 -0
  16. package/dist/internal/test-host.context.js.map +1 -1
  17. package/dist/mixins/test-base.d.ts +2 -0
  18. package/dist/mixins/test-base.js +16 -0
  19. package/dist/mixins/test-base.js.map +1 -1
  20. package/dist/mixins/test-navigation.mixin.js +22 -0
  21. package/dist/mixins/test-navigation.mixin.js.map +1 -1
  22. package/dist/mixins/test-state.mixin.js +3 -1
  23. package/dist/mixins/test-state.mixin.js.map +1 -1
  24. package/dist/public-events.d.ts +9 -0
  25. package/dist/public-events.js +1 -0
  26. package/dist/public-events.js.map +1 -1
  27. package/dist/state-from-contexts.d.ts +1 -0
  28. package/dist/state-from-contexts.js +2 -1
  29. package/dist/state-from-contexts.js.map +1 -1
  30. package/dist/types/qti-test-state.d.ts +5 -0
  31. package/dist/types/qti-test-state.js.map +1 -1
  32. package/package.json +3 -3
@@ -17,6 +17,7 @@ export interface StoredTestContext {
17
17
  identifier?: string;
18
18
  variables?: readonly StoredVariable[];
19
19
  state?: Readonly<Record<string, string | null>>;
20
+ comment?: string;
20
21
  }[];
21
22
  testOutcomeVariables?: readonly StoredVariable[];
22
23
  }
@@ -37,7 +37,8 @@ export const stateFromContexts = (testContext, sessionContext) => ({
37
37
  .map(item => ({
38
38
  identifier: item.identifier,
39
39
  variables: (item.variables ?? []).map(variable),
40
- ...(item.state ? { state: { ...item.state } } : {})
40
+ ...(item.state ? { state: { ...item.state } } : {}),
41
+ ...(typeof item.comment === 'string' ? { comment: item.comment } : {})
41
42
  })),
42
43
  outcomes: (testContext?.testOutcomeVariables ?? []).map(v => ({
43
44
  identifier: v.identifier,
@@ -1 +1 @@
1
- {"version":3,"file":"state-from-contexts.js","sourceRoot":"","sources":["../src/state-from-contexts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAoCnE,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAU,CAAC;AAE/E,MAAM,OAAO,GAAG,CAAC,KAAkB,EAA8B,EAAE;IACjE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAkB,EAAyC,EAAE,CAAC,CAAC;IACxG,UAAU;IACV,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAuC,CAAC;QAClE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAuC,EAAE;QACnD,CAAC,CAAC,EAAE,CAAC;IACP,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC;CACtB,CAAC,CAAC;AAEH;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C3F,GAAG,CAAC,cAAc,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,GAAG,CAAC,cAAc,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrG;CACF,CAAC,CAAC","sourcesContent":["import { QTI_TEST_STATE_VERSION } from './types/qti-test-state.js';\n\nimport type { QtiTestState, QtiTestStateItem, QtiTestStateValue } from './types/qti-test-state.js';\n\n/** A value as a 9.x host may have stored it: QTI values are strings, but JSON kept numbers as numbers. */\ntype StoredValue = string | number | boolean | null | undefined | readonly (string | number | boolean)[];\n\n/** A variable as stored: only `identifier`, `value` and `type` are read; declaration metadata is ignored. */\nexport interface StoredVariable {\n identifier: string;\n value?: StoredValue;\n type?: string;\n}\n\n/**\n * A `testContext` as a 9.x host stored it (`qtiTest.testContext` or the `qti-test-context-updated`\n * payload), plain JSON. Fields this does not name, such as an item's `href` or a host's own\n * additions, are ignored.\n */\nexport interface StoredTestContext {\n items?: readonly {\n identifier?: string;\n variables?: readonly StoredVariable[];\n state?: Readonly<Record<string, string | null>>;\n }[];\n testOutcomeVariables?: readonly StoredVariable[];\n}\n\n/** A `sessionContext` as a 9.x host stored it: the position and the plugin entries. */\nexport interface StoredSessionContext {\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n plugins?: Readonly<Record<string, unknown>>;\n}\n\nconst VARIABLE_TYPES = ['response', 'outcome', 'template', 'context'] as const;\n\nconst valueOf = (value: StoredValue): QtiTestStateValue['value'] => {\n if (value === null || value === undefined) return null;\n if (Array.isArray(value)) return value.map(String);\n return String(value);\n};\n\nconst variable = ({ identifier, type, value }: StoredVariable): QtiTestStateItem['variables'][number] => ({\n identifier,\n ...(VARIABLE_TYPES.includes(type as (typeof VARIABLE_TYPES)[number])\n ? { type: type as (typeof VARIABLE_TYPES)[number] }\n : {}),\n value: valueOf(value)\n});\n\n/**\n * Turns a stored `testContext` and `sessionContext` into a `QtiTestState`, so a host that stored the\n * contexts in 9.x can resume with `qtiTest.state = stateFromContexts(testContext, sessionContext)`.\n * `qtiTest.state` reads the same way from the live contexts.\n *\n * It keeps the values only: each item's variables (identifier, value and `type` when it is one QTI\n * knows) and per-interaction state, the test outcomes, the position and the plugin entries. Values\n * are written as QTI's strings, so a number a host stored as a JSON number (`SCORE: 0`) becomes\n * `'0'`. Declaration metadata (`baseType`, `cardinality`, `correctResponse`, …) is left out, as in\n * every `QtiTestState`. Items without an identifier are skipped.\n *\n * @param testContext The stored test context, plain JSON.\n * @param sessionContext The stored session context, if the host kept one. A host that stored only the\n * item it was on passes `{ navItemRefId }`.\n */\nexport const stateFromContexts = (\n testContext: Readonly<StoredTestContext> | null | undefined,\n sessionContext?: Readonly<StoredSessionContext> | null\n): QtiTestState => ({\n version: QTI_TEST_STATE_VERSION,\n test: {\n items: (testContext?.items ?? [])\n .filter(item => item?.identifier)\n .map(item => ({\n identifier: item.identifier as string,\n variables: (item.variables ?? []).map(variable),\n ...(item.state ? { state: { ...item.state } } : {})\n })),\n outcomes: (testContext?.testOutcomeVariables ?? []).map(v => ({\n identifier: v.identifier,\n value: valueOf(v.value)\n }))\n },\n session: {\n ...(sessionContext?.plugins && Object.keys(sessionContext.plugins).length > 0\n ? { plugins: { ...sessionContext.plugins } }\n : {}),\n ...(sessionContext?.navPartId !== undefined ? { navPartId: sessionContext.navPartId } : {}),\n ...(sessionContext?.navSectionId !== undefined ? { navSectionId: sessionContext.navSectionId } : {}),\n ...(sessionContext?.navItemRefId !== undefined ? { navItemRefId: sessionContext.navItemRefId } : {})\n }\n});\n"]}
1
+ {"version":3,"file":"state-from-contexts.js","sourceRoot":"","sources":["../src/state-from-contexts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,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'./types/qti-test-state.js';\n\n/** A value as a 9.x host may have stored it: QTI values are strings, but JSON kept numbers as numbers. */\ntype StoredValue = string | number | boolean | null | undefined | readonly (string | number | boolean)[];\n\n/** A variable as stored: only `identifier`, `value` and `type` are read; declaration metadata is ignored. */\nexport interface StoredVariable {\n identifier: string;\n value?: StoredValue;\n type?: string;\n}\n\n/**\n * A `testContext` as a 9.x host stored it (`qtiTest.testContext` or the `qti-test-context-updated`\n * payload), plain JSON. Fields this does not name, such as an item's `href` or a host's own\n * additions, are ignored.\n */\nexport interface StoredTestContext {\n items?: readonly {\n identifier?: string;\n variables?: readonly StoredVariable[];\n state?: Readonly<Record<string, string | null>>;\n comment?: string;\n }[];\n testOutcomeVariables?: readonly StoredVariable[];\n}\n\n/** A `sessionContext` as a 9.x host stored it: the position and the plugin entries. */\nexport interface StoredSessionContext {\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n plugins?: Readonly<Record<string, unknown>>;\n}\n\nconst VARIABLE_TYPES = ['response', 'outcome', 'template', 'context'] as const;\n\nconst valueOf = (value: StoredValue): QtiTestStateValue['value'] => {\n if (value === null || value === undefined) return null;\n if (Array.isArray(value)) return value.map(String);\n return String(value);\n};\n\nconst variable = ({ identifier, type, value }: StoredVariable): QtiTestStateItem['variables'][number] => ({\n identifier,\n ...(VARIABLE_TYPES.includes(type as (typeof VARIABLE_TYPES)[number])\n ? { type: type as (typeof VARIABLE_TYPES)[number] }\n : {}),\n value: valueOf(value)\n});\n\n/**\n * Turns a stored `testContext` and `sessionContext` into a `QtiTestState`, so a host that stored the\n * contexts in 9.x can resume with `qtiTest.state = stateFromContexts(testContext, sessionContext)`.\n * `qtiTest.state` reads the same way from the live contexts.\n *\n * It keeps the values only: each item's variables (identifier, value and `type` when it is one QTI\n * knows) and per-interaction state, the test outcomes, the position and the plugin entries. Values\n * are written as QTI's strings, so a number a host stored as a JSON number (`SCORE: 0`) becomes\n * `'0'`. Declaration metadata (`baseType`, `cardinality`, `correctResponse`, …) is left out, as in\n * every `QtiTestState`. Items without an identifier are skipped.\n *\n * @param testContext The stored test context, plain JSON.\n * @param sessionContext The stored session context, if the host kept one. A host that stored only the\n * item it was on passes `{ navItemRefId }`.\n */\nexport const stateFromContexts = (\n testContext: Readonly<StoredTestContext> | null | undefined,\n sessionContext?: Readonly<StoredSessionContext> | null\n): QtiTestState => ({\n version: QTI_TEST_STATE_VERSION,\n test: {\n items: (testContext?.items ?? [])\n .filter(item => item?.identifier)\n .map(item => ({\n identifier: item.identifier as string,\n variables: (item.variables ?? []).map(variable),\n ...(item.state ? { state: { ...item.state } } : {}),\n ...(typeof item.comment === 'string' ? { comment: item.comment } : {})\n })),\n outcomes: (testContext?.testOutcomeVariables ?? []).map(v => ({\n identifier: v.identifier,\n value: valueOf(v.value)\n }))\n },\n session: {\n ...(sessionContext?.plugins && Object.keys(sessionContext.plugins).length > 0\n ? { plugins: { ...sessionContext.plugins } }\n : {}),\n ...(sessionContext?.navPartId !== undefined ? { navPartId: sessionContext.navPartId } : {}),\n ...(sessionContext?.navSectionId !== undefined ? { navSectionId: sessionContext.navSectionId } : {}),\n ...(sessionContext?.navItemRefId !== undefined ? { navItemRefId: sessionContext.navItemRefId } : {})\n }\n});\n"]}
@@ -34,6 +34,11 @@ export interface QtiTestStateItem {
34
34
  })[];
35
35
  /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */
36
36
  state?: Record<string, string | null>;
37
+ /**
38
+ * The candidate's comment on the item, set with `qc-test-update-comment` when the item's
39
+ * `allow-comment` allows it (QTI 3 `qti-item-session-control`). Not assessed (roadmap 1 T3c).
40
+ */
41
+ comment?: string;
37
42
  }
38
43
  export interface QtiTestStateValue {
39
44
  identifier: string;
@@ -1 +1 @@
1
- {"version":3,"file":"qti-test-state.js","sourceRoot":"","sources":["../../src/types/qti-test-state.ts"],"names":[],"mappings":"AA8DA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC","sourcesContent":["/**\n * Everything a host needs to persist to resume a candidate's test session, and nothing else.\n *\n * Read it from `qtiTest.state` or the `qc-test-state-changed` event, store it wherever you like —\n * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.\n *\n * Deliberately not here:\n * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes\n * from the item XML on every load, and persisting the answer key with the candidate's data is\n * both bloat and a leak;\n * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.\n * The shuffle `seed` in particular must be passed in again, or the restored order changes;\n * - `view`: a role the host decides, not something the candidate produced;\n * - anything computed — scores per section, `done`, `active` — which is rederived from this.\n */\nexport interface QtiTestState {\n /** Bumped on any incompatible change to this shape. A state with another version is ignored. */\n version: 1;\n test: {\n items: QtiTestStateItem[];\n /** Test-level outcome values. Only outcomes the test declares are restored. */\n outcomes: QtiTestStateValue[];\n };\n session: QtiTestStateSession;\n}\n\nexport interface QtiTestStateItem {\n /**\n * The `qti-assessment-item-ref` identifier; for the clone of an item-ref that `qti-selection\n * with-replacement=\"true\"` selected again, its instance id: `item-3#2` (roadmap 1 T4).\n */\n identifier: string;\n variables: (QtiTestStateValue & { type?: 'response' | 'outcome' | 'template' | 'context' })[];\n /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */\n state?: Record<string, string | null>;\n}\n\nexport interface QtiTestStateValue {\n identifier: string;\n value: string | string[] | null;\n}\n\n/**\n * What each plugin keeps in the state, by plugin name. Empty here: a plugin adds its own entry by\n * augmenting this interface (`declare module` on the module that declares it, with\n * `interface QtiTestPluginState { bookmarks: string[] }`), and reads it with\n * `pluginState(computedContext, 'bookmarks')`. The test never reads an entry; it\n * stores and restores it, so a value must survive `JSON.stringify`.\n */\n\nexport interface QtiTestPluginState {}\n\n/** Where the candidate is, and what plugins keep. */\nexport interface QtiTestStateSession {\n /** Plugin entries by plugin name. Entries of plugins that are not loaded are kept as they are. */\n plugins?: Partial<QtiTestPluginState> & Record<string, unknown>;\n navPartId?: string | null;\n navSectionId?: string | null;\n /** The item on screen, as `items[].identifier` names it: a clone is `item-3#2`. */\n navItemRefId?: string | null;\n}\n\nexport const QTI_TEST_STATE_VERSION = 1;\n"]}
1
+ {"version":3,"file":"qti-test-state.js","sourceRoot":"","sources":["../../src/types/qti-test-state.ts"],"names":[],"mappings":"AAmEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC","sourcesContent":["/**\n * Everything a host needs to persist to resume a candidate's test session, and nothing else.\n *\n * Read it from `qtiTest.state` or the `qc-test-state-changed` event, store it wherever you like —\n * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.\n *\n * Deliberately not here:\n * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes\n * from the item XML on every load, and persisting the answer key with the candidate's data is\n * both bloat and a leak;\n * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.\n * The shuffle `seed` in particular must be passed in again, or the restored order changes;\n * - `view`: a role the host decides, not something the candidate produced;\n * - anything computed — scores per section, `done`, `active` — which is rederived from this.\n */\nexport interface QtiTestState {\n /** Bumped on any incompatible change to this shape. A state with another version is ignored. */\n version: 1;\n test: {\n items: QtiTestStateItem[];\n /** Test-level outcome values. Only outcomes the test declares are restored. */\n outcomes: QtiTestStateValue[];\n };\n session: QtiTestStateSession;\n}\n\nexport interface QtiTestStateItem {\n /**\n * The `qti-assessment-item-ref` identifier; for the clone of an item-ref that `qti-selection\n * with-replacement=\"true\"` selected again, its instance id: `item-3#2` (roadmap 1 T4).\n */\n identifier: string;\n variables: (QtiTestStateValue & { type?: 'response' | 'outcome' | 'template' | 'context' })[];\n /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */\n state?: Record<string, string | null>;\n /**\n * The candidate's comment on the item, set with `qc-test-update-comment` when the item's\n * `allow-comment` allows it (QTI 3 `qti-item-session-control`). Not assessed (roadmap 1 T3c).\n */\n comment?: string;\n}\n\nexport interface QtiTestStateValue {\n identifier: string;\n value: string | string[] | null;\n}\n\n/**\n * What each plugin keeps in the state, by plugin name. Empty here: a plugin adds its own entry by\n * augmenting this interface (`declare module` on the module that declares it, with\n * `interface QtiTestPluginState { bookmarks: string[] }`), and reads it with\n * `pluginState(computedContext, 'bookmarks')`. The test never reads an entry; it\n * stores and restores it, so a value must survive `JSON.stringify`.\n */\n\nexport interface QtiTestPluginState {}\n\n/** Where the candidate is, and what plugins keep. */\nexport interface QtiTestStateSession {\n /** Plugin entries by plugin name. Entries of plugins that are not loaded are kept as they are. */\n plugins?: Partial<QtiTestPluginState> & Record<string, unknown>;\n navPartId?: string | null;\n navSectionId?: string | null;\n /** The item on screen, as `items[].identifier` names it: a clone is `item-3#2`. */\n navItemRefId?: string | null;\n}\n\nexport const QTI_TEST_STATE_VERSION = 1;\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@qti-components/test",
3
3
  "description": "QTI test utilities",
4
- "version": "2.0.0-next.26",
4
+ "version": "2.0.0-next.28",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
8
- "@qti-components/base": "^3.0.0-next.13",
9
- "@qti-components/delivery": "^0.1.0-next.6",
8
+ "@qti-components/base": "^3.0.0-next.15",
9
+ "@qti-components/delivery": "^0.1.0-next.8",
10
10
  "@qti-components/elements": "^2.0.0-next.7",
11
11
  "@qti-components/interactions": "^1.10.5-next.8",
12
12
  "@qti-components/processing": "^1.6.1-next.5",