@qti-components/test 2.0.0-next.19 → 2.0.0-next.20

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.
@@ -58,6 +58,7 @@ declare const QtiTest_base: (abstract new (...args: any[]) => import("../..").IT
58
58
  * And you can use the `test-prev` and `test-next` elements to navigate through the test.
59
59
  *
60
60
  * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
61
+ * @event qc-test-state-refused - A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
61
62
  * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
62
63
  */
63
64
  export declare class QtiTest extends QtiTest_base {
@@ -61,6 +61,7 @@ import { TestStateMixin } from '../../mixins/test-state.mixin';
61
61
  * And you can use the `test-prev` and `test-next` elements to navigate through the test.
62
62
  *
63
63
  * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
64
+ * @event qc-test-state-refused - A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.
64
65
  * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
65
66
  */
66
67
  export class QtiTest extends TestNavigationMixin(TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))) {
@@ -1 +1 @@
1
- {"version":3,"file":"qti-test.js","sourceRoot":"","sources":["../../../src/components/qti-test/qti-test.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,mB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AC;CACF;AAnCQ;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;8CACK;AAclC;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;2CAO/B","sourcesContent":["import { ContextProvider, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { configContext, qtiContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { TestNavigationMixin, TestViewMixin } from '../../mixins';\nimport { TestBaseMixin } from '../../mixins/test-base';\nimport { TestProcessingMixin } from '../../mixins/test-processing.mixin';\nimport { TestStateMixin } from '../../mixins/test-state.mixin';\n\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { IQtiTest } from '../../types/iqti-test';\n\n/**\n * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.\n *\n * This component leverages several mixins to provide functionality for loading, navigating, processing, and displaying QTI test assessments.\n *\n * ### Example Usage\n *\n * Minimal example including navigation:\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container test-url=\"./path/to/assessment.xml\"></test-container>\n * <nav class=\"flex\">\n * <test-prev></test-prev>\n * <test-next></test-next>\n * </nav>\n * </test-navigation>\n * </qti-test>\n * ```\n *\n * Use the following file structure\n * A qti-test loads a QTI3.0 assessmenttest.xml file from a package folder.\n *\n * ```plaintext\n * Root/\n * ├── index.html\n * └── /assets/api/examples/\n * ├── assessmenttest.xml\n * └── imsmanifest.xml\n *\n * ```\n *\n * ### Test components\n *\n * Use test components inside the qti-test component for added functionality.\n * ### Test next\n * `<test-next> | TestNext`\n *\n * ### Test prev\n *\n * `<test-prev> | TestPrev`\n * ### Test components\n *\n * You can use normal class names to style the elements.\n * And you can use the `test-prev` and `test-next` elements to navigate through the test.\n *\n * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.\n * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.\n */\n\nexport class QtiTest extends TestNavigationMixin(\n TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))\n) {\n // TODO: Properly implement IQtiTest interface\n // export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {\n\n constructor() {\n super();\n // The components inside find their test through this, across shadow roots (see TestHost).\n new ContextProvider(this, { context: testHostContext, initialValue: this });\n }\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n /**\n * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so\n * everything inside reads one value: the test-container shuffling the item order, the test\n * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.\n *\n * Pass the same `seed` when resuming a session, or the order comes back different. Replace the\n * object, do not mutate it: an in-place change does not notify the components inside.\n *\n * `test-navigation.qtiContext` is an alias of this.\n */\n @state()\n @provide({ context: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\n\n /**\n * Renders the component's template.\n * Provides a default `<slot>` for content projection.\n */\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(new CustomEvent('qti-test-connected', { detail: this }));\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test': QtiTest;\n }\n}\n"]}
1
+ {"version":3,"file":"qti-test.js","sourceRoot":"","sources":["../../../src/components/qti-test/qti-test.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,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AFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;8CACK;AAclC;IAFN,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;2CAO/B","sourcesContent":["import { ContextProvider, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { configContext, qtiContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { TestNavigationMixin, TestViewMixin } from '../../mixins';\nimport { TestBaseMixin } from '../../mixins/test-base';\nimport { TestProcessingMixin } from '../../mixins/test-processing.mixin';\nimport { TestStateMixin } from '../../mixins/test-state.mixin';\n\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { IQtiTest } from '../../types/iqti-test';\n\n/**\n * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.\n *\n * This component leverages several mixins to provide functionality for loading, navigating, processing, and displaying QTI test assessments.\n *\n * ### Example Usage\n *\n * Minimal example including navigation:\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container test-url=\"./path/to/assessment.xml\"></test-container>\n * <nav class=\"flex\">\n * <test-prev></test-prev>\n * <test-next></test-next>\n * </nav>\n * </test-navigation>\n * </qti-test>\n * ```\n *\n * Use the following file structure\n * A qti-test loads a QTI3.0 assessmenttest.xml file from a package folder.\n *\n * ```plaintext\n * Root/\n * ├── index.html\n * └── /assets/api/examples/\n * ├── assessmenttest.xml\n * └── imsmanifest.xml\n *\n * ```\n *\n * ### Test components\n *\n * Use test components inside the qti-test component for added functionality.\n * ### Test next\n * `<test-next> | TestNext`\n *\n * ### Test prev\n *\n * `<test-prev> | TestPrev`\n * ### Test components\n *\n * You can use normal class names to style the elements.\n * And you can use the `test-prev` and `test-next` elements to navigate through the test.\n *\n * @event qc-test-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.\n * @event qc-test-state-refused - A value assigned to `state` is not a version 1 `QtiTestState` and was ignored; the test goes on without it. `detail` is `{ message, state }`. Sent once the test has loaded.\n * @event qti-test-context-updated - Deprecated: listen to `qc-test-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.\n */\n\nexport class QtiTest extends TestNavigationMixin(\n TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))\n) {\n // TODO: Properly implement IQtiTest interface\n // export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {\n\n constructor() {\n super();\n // The components inside find their test through this, across shadow roots (see TestHost).\n new ContextProvider(this, { context: testHostContext, initialValue: this });\n }\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n /**\n * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so\n * everything inside reads one value: the test-container shuffling the item order, the test\n * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.\n *\n * Pass the same `seed` when resuming a session, or the order comes back different. Replace the\n * object, do not mutate it: an in-place change does not notify the components inside.\n *\n * `test-navigation.qtiContext` is an alias of this.\n */\n @state()\n @provide({ context: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\n\n /**\n * Renders the component's template.\n * Provides a default `<slot>` for content projection.\n */\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(new CustomEvent('qti-test-connected', { detail: this }));\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test': QtiTest;\n }\n}\n"]}
@@ -0,0 +1,43 @@
1
+ import type { Clock, DeliveryState } from '@qti-components/delivery';
2
+ import type { QtiTestState } from '../types/qti-test-state';
3
+ /**
4
+ * Converts between `QtiTestState`, the host's persistence format, and `DeliveryState`, the one source
5
+ * of truth to come (`plans/delivery-state.md`). Roadmap 1 T1e: pure functions, called by nothing at
6
+ * runtime yet; `qti-test` keeps its state in `testContext` and `sessionContext` until T2 and T3 derive
7
+ * from a `DeliveryState`.
8
+ *
9
+ * Lossy on purpose, until the fields exist on both sides:
10
+ * - the variables are not in `DeliveryState` until T8, so the way back takes them as an input;
11
+ * - `DeliveryState.current` is an item instance, so a position of only a section (`navigate="section"`)
12
+ * or a part (`navSectionId`, `navPartId`) is not kept (decided 2026-11-27);
13
+ * - a version 1 `QtiTestState` has no seed, order or start time, so the caller passes them in.
14
+ *
15
+ * @internal
16
+ */
17
+ export interface DeliveryStateInputs {
18
+ /**
19
+ * The item-ref identifiers in the order the candidate meets them: the rendered test's, which is
20
+ * already shuffled with the seed the host passed.
21
+ */
22
+ order: readonly string[];
23
+ /** The seed actually used for that order. */
24
+ seed: string | null;
25
+ /** When the delivery starts; a version 1 state does not say when the test started. */
26
+ clock: Clock;
27
+ }
28
+ /**
29
+ * A `DeliveryState` from a stored `QtiTestState`: the order, the item on screen and the plugin
30
+ * entries. An item on screen that the order does not have, and a position of only a section or a
31
+ * part, give `current: null`.
32
+ *
33
+ * @internal
34
+ */
35
+ export declare function deliveryStateFromQtiTestState(state: QtiTestState, inputs: DeliveryStateInputs): DeliveryState;
36
+ /**
37
+ * A `QtiTestState` from a `DeliveryState`: the item on screen and the plugin entries, with the
38
+ * variables from `test` (the live contexts' values, as `qtiTest.state` reads them). The `test` input
39
+ * goes when the variables move into `DeliveryState` (T8).
40
+ *
41
+ * @internal
42
+ */
43
+ export declare function qtiTestStateFromDeliveryState(delivery: DeliveryState, test: QtiTestState['test']): QtiTestState;
@@ -0,0 +1,44 @@
1
+ import { createDeliveryState, itemInstanceId } from '@qti-components/delivery';
2
+ import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';
3
+ /**
4
+ * A `DeliveryState` from a stored `QtiTestState`: the order, the item on screen and the plugin
5
+ * entries. An item on screen that the order does not have, and a position of only a section or a
6
+ * part, give `current: null`.
7
+ *
8
+ * @internal
9
+ */
10
+ export function deliveryStateFromQtiTestState(state, inputs) {
11
+ const delivery = createDeliveryState(inputs);
12
+ const onScreen = state.session.navItemRefId ? itemInstanceId(state.session.navItemRefId) : null;
13
+ return {
14
+ ...delivery,
15
+ current: onScreen && Object.hasOwn(delivery.items, onScreen) ? onScreen : null,
16
+ plugins: { ...(state.session.plugins ?? {}) }
17
+ };
18
+ }
19
+ /**
20
+ * A `QtiTestState` from a `DeliveryState`: the item on screen and the plugin entries, with the
21
+ * variables from `test` (the live contexts' values, as `qtiTest.state` reads them). The `test` input
22
+ * goes when the variables move into `DeliveryState` (T8).
23
+ *
24
+ * @internal
25
+ */
26
+ export function qtiTestStateFromDeliveryState(delivery, test) {
27
+ const current = delivery.current ? delivery.items[delivery.current] : undefined;
28
+ return {
29
+ version: QTI_TEST_STATE_VERSION,
30
+ test: {
31
+ items: test.items.map(item => ({
32
+ ...item,
33
+ variables: item.variables.map(v => ({ ...v, value: Array.isArray(v.value) ? [...v.value] : v.value })),
34
+ ...(item.state ? { state: { ...item.state } } : {})
35
+ })),
36
+ outcomes: test.outcomes.map(o => ({ ...o, value: Array.isArray(o.value) ? [...o.value] : o.value }))
37
+ },
38
+ session: {
39
+ ...(Object.keys(delivery.plugins).length > 0 ? { plugins: { ...delivery.plugins } } : {}),
40
+ ...(current ? { navItemRefId: current.itemRefIdentifier } : {})
41
+ }
42
+ };
43
+ }
44
+ //# sourceMappingURL=delivery-state-conversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-state-conversion.js","sourceRoot":"","sources":["../../src/internal/delivery-state-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAgCjE;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAAC,KAAmB,EAAE,MAA2B;IAC5F,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,C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AC,EAAE,CAAC;aACpD,CAAC,CAAC;YACH,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;SACrG;QACD,OAAO,EAAE;YACP,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzF,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChE;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { createDeliveryState, itemInstanceId } from '@qti-components/delivery';\n\nimport { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';\n\nimport type { Clock, DeliveryState } from '@qti-components/delivery';\nimport type { QtiTestState } from '../types/qti-test-state';\n\n/**\n * Converts between `QtiTestState`, the host's persistence format, and `DeliveryState`, the one source\n * of truth to come (`plans/delivery-state.md`). Roadmap 1 T1e: pure functions, called by nothing at\n * runtime yet; `qti-test` keeps its state in `testContext` and `sessionContext` until T2 and T3 derive\n * from a `DeliveryState`.\n *\n * Lossy on purpose, until the fields exist on both sides:\n * - the variables are not in `DeliveryState` until T8, so the way back takes them as an input;\n * - `DeliveryState.current` is an item instance, so a position of only a section (`navigate=\"section\"`)\n * or a part (`navSectionId`, `navPartId`) is not kept (decided 2026-11-27);\n * - a version 1 `QtiTestState` has no seed, order or start time, so the caller passes them in.\n *\n * @internal\n */\n\nexport interface DeliveryStateInputs {\n /**\n * The item-ref identifiers in the order the candidate meets them: the rendered test's, which is\n * already shuffled with the seed the host passed.\n */\n order: readonly string[];\n /** The seed actually used for that order. */\n seed: string | null;\n /** When the delivery starts; a version 1 state does not say when the test started. */\n clock: Clock;\n}\n\n/**\n * A `DeliveryState` from a stored `QtiTestState`: the order, the item on screen and the plugin\n * entries. An item on screen that the order does not have, and a position of only a section or a\n * part, give `current: null`.\n *\n * @internal\n */\nexport function deliveryStateFromQtiTestState(state: QtiTestState, inputs: DeliveryStateInputs): DeliveryState {\n const delivery = createDeliveryState(inputs);\n const onScreen = state.session.navItemRefId ? itemInstanceId(state.session.navItemRefId) : null;\n return {\n ...delivery,\n current: onScreen && Object.hasOwn(delivery.items, onScreen) ? onScreen : null,\n plugins: { ...(state.session.plugins ?? {}) }\n };\n}\n\n/**\n * A `QtiTestState` from a `DeliveryState`: the item on screen and the plugin entries, with the\n * variables from `test` (the live contexts' values, as `qtiTest.state` reads them). The `test` input\n * goes when the variables move into `DeliveryState` (T8).\n *\n * @internal\n */\nexport function qtiTestStateFromDeliveryState(delivery: DeliveryState, test: QtiTestState['test']): QtiTestState {\n const current = delivery.current ? delivery.items[delivery.current] : undefined;\n return {\n version: QTI_TEST_STATE_VERSION,\n test: {\n items: test.items.map(item => ({\n ...item,\n variables: item.variables.map(v => ({ ...v, value: Array.isArray(v.value) ? [...v.value] : v.value })),\n ...(item.state ? { state: { ...item.state } } : {})\n })),\n outcomes: test.outcomes.map(o => ({ ...o, value: Array.isArray(o.value) ? [...o.value] : o.value }))\n },\n session: {\n ...(Object.keys(delivery.plugins).length > 0 ? { plugins: { ...delivery.plugins } } : {}),\n ...(current ? { navItemRefId: current.itemRefIdentifier } : {})\n }\n };\n}\n"]}
@@ -13,6 +13,11 @@ export interface ITestStateMixin {
13
13
  * Items are matched by item-ref identifier; items the state does not mention start fresh, and
14
14
  * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a
15
15
  * resume, so linear-mode navigation restrictions do not apply.
16
+ *
17
+ * A value that is not a version 1 `QtiTestState` is ignored and reported with
18
+ * `qc-test-state-refused`: at once when the test has loaded, or when it does if it was assigned
19
+ * before. A state assigned earlier that could be read stays in effect. A stored 9.x
20
+ * `testContext` is turned into a state with `stateFromContexts`.
16
21
  */
17
22
  state: QtiTestState;
18
23
  }
@@ -22,6 +22,8 @@ export const TestStateMixin = (superClass) => {
22
22
  class TestStateClass extends superClass {
23
23
  /** A state assigned before the test connected, applied when it does. */
24
24
  #pending = null;
25
+ /** A refused state assigned before the test connected, reported when it does. */
26
+ #refused = null;
25
27
  /**
26
28
  * False while a test document is loading. Loading resets both contexts and rebuilds them, so
27
29
  * the intermediate states are empty — emitting one would invite a host to save it over the
@@ -42,6 +44,10 @@ export const TestStateMixin = (superClass) => {
42
44
  this.#pending = null;
43
45
  }
44
46
  this.#ready = true;
47
+ if (this.#refused) {
48
+ dispatchPublic(this, 'qc-test-state-refused', this.#refused);
49
+ this.#refused = null;
50
+ }
45
51
  });
46
52
  }
47
53
  /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */
@@ -66,7 +72,13 @@ export const TestStateMixin = (superClass) => {
66
72
  }
67
73
  set state(value) {
68
74
  if (!isQtiTestState(value)) {
69
- console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);
75
+ const message = `Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`;
76
+ console.warn(`[qti-test] ${message}`);
77
+ // Hosts assign state before the test is in the page, where an event reaches no listener.
78
+ if (this.#ready)
79
+ dispatchPublic(this, 'qc-test-state-refused', { message, state: value });
80
+ else
81
+ this.#refused = { message, state: value };
70
82
  return;
71
83
  }
72
84
  if (!this.#ready) {
@@ -1 +1 @@
1
- {"version":3,"file":"test-state.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-state.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,C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AAC,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;aAChH,CAAC;QACJ,CAAC;QAED,sFAAsF;QACtF,aAAa,CAAC,OAA4B;YACxC,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAE,EAA6B,EAAE,EAAE,CACjE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,QAAQ,gBAAgB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAC5F,OAAO;gBACL,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvF,GAAG,CAAC,MAAM,CAAC,wBAAwB,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzG,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC;oBACzE,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE;oBACxC,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;QACJ,CAAC;QAED,kBAAkB,CAAC,IAAwB,EAAE,EAAU;YACrD,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACzD,CAAC;KACF;IAED,OAAO,cAAkD,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';\nimport { dispatchPublic, listenPublic } from '../public-events';\nimport { stateFromContexts } from '../state-from-contexts';\n\nimport type { PropertyValues } from 'lit';\nimport type { QtiTestState, QtiTestStateSession } from '../types/qti-test-state';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\ntype Value = string | string[] | null;\n\nexport interface ITestStateMixin {\n /**\n * The candidate's persistable state: what they answered and where they are.\n *\n * Assign a stored state to resume. It may be assigned at any time: before the test document\n * has loaded it is held and applied as soon as the test connects — before the first item\n * loads, so items and the initial navigation start from it — and after that it is applied\n * immediately and the test navigates to the restored position.\n *\n * Items are matched by item-ref identifier; items the state does not mention start fresh, and\n * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a\n * resume, so linear-mode navigation restrictions do not apply.\n */\n state: QtiTestState;\n}\n\nconst copy = (value: Readonly<Value> | undefined): Value =>\n Array.isArray(value) ? [...value] : ((value as string | null | undefined) ?? null);\n\nconst isQtiTestState = (value: unknown): value is QtiTestState => {\n const state = value as QtiTestState | null;\n return (\n state?.version === QTI_TEST_STATE_VERSION &&\n Array.isArray(state.test?.items) &&\n Array.isArray(state.test?.outcomes) &&\n typeof state.session === 'object' &&\n state.session !== null\n );\n};\n\n/**\n * Persist and resume a test session through one value, `state`, and one event,\n * `qc-test-state-changed`.\n *\n * Sits directly on top of `TestBaseMixin`, so its `qc-test-loaded` listener runs\n * after the base has built `testContext.items` from the item-refs, and before the navigation\n * mixin's listener picks the first item to load.\n */\nexport const TestStateMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestStateClass extends superClass implements ITestStateMixin {\n /** A state assigned before the test connected, applied when it does. */\n #pending: QtiTestState | null = null;\n\n /**\n * False while a test document is loading. Loading resets both contexts and rebuilds them, so\n * the intermediate states are empty — emitting one would invite a host to save it over the\n * real one.\n */\n #ready = false;\n\n #lastEmitted: string | null = null;\n\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-testdoc-loaded', () => {\n this.#ready = false;\n this.#lastEmitted = null;\n });\n listenPublic(this, 'qc-test-update-plugin-state', ({ detail }) => this.#updatePluginState(detail));\n listenPublic(this, 'qc-test-loaded', () => {\n if (this.#pending) {\n this.#apply(this.#pending);\n this.#pending = null;\n }\n this.#ready = true;\n });\n }\n\n /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */\n #updatePluginState({ plugin, value }: { plugin: string; value: unknown }): void {\n if (typeof plugin !== 'string' || plugin === '') return;\n const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};\n let next: Record<string, unknown> = others;\n if (value !== null && value !== undefined) {\n try {\n next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };\n } catch {\n console.warn(`[qti-test] Ignoring plugin state for \"${plugin}\": it is not JSON.`);\n return;\n }\n }\n this.sessionContext = { ...this.sessionContext, plugins: next };\n }\n\n get state(): QtiTestState {\n return stateFromContexts(this.testContext, this.sessionContext);\n }\n\n set state(value: QtiTestState) {\n if (!isQtiTestState(value)) {\n console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);\n return;\n }\n if (!this.#ready) {\n this.#pending = value;\n return;\n }\n\n const { navItemRefId, navSectionId } = this.sessionContext;\n this.#apply(value);\n\n const restored = this.sessionContext;\n if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {\n this.#requestNavigation('item', restored.navItemRefId);\n } else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {\n this.#requestNavigation('section', restored.navSectionId);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (!this.#ready || !(changed.has('testContext') || changed.has('sessionContext'))) return;\n\n const state = this.state;\n const serialized = JSON.stringify(state);\n if (serialized === this.#lastEmitted) return;\n this.#lastEmitted = serialized;\n dispatchPublic(this, 'qc-test-state-changed', state);\n }\n\n #apply(state: QtiTestState): void {\n // Before the items load this only fills the test context; items already on screen are\n // updated too.\n for (const saved of state.test.items) this.updateItemVariables(saved.identifier, saved.variables, saved.state);\n\n const savedOutcomes = new Map(state.test.outcomes.map(outcome => [outcome.identifier, outcome.value]));\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v =>\n savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v\n )\n };\n\n // Written before any navigation request, so the linear-mode restriction — which compares\n // against the current position — sees the restored item as current and lets it load.\n // Plugins are replaced, not merged: a state without them clears what an earlier one left.\n this.sessionContext = {\n ...this.sessionContext,\n ...this.#validSession(state.session),\n plugins: state.session.plugins && typeof state.session.plugins === 'object' ? { ...state.session.plugins } : {}\n };\n }\n\n /** A stored position may point at an item or section a revised test no longer has. */\n #validSession(session: QtiTestStateSession): QtiTestStateSession {\n const exists = (selector: string, id: string | null | undefined) =>\n !!id && !!this._testElement?.querySelector(`${selector}[identifier=\"${CSS.escape(id)}\"]`);\n return {\n ...(exists('qti-test-part', session.navPartId) ? { navPartId: session.navPartId } : {}),\n ...(exists('qti-assessment-section', session.navSectionId) ? { navSectionId: session.navSectionId } : {}),\n ...(this.testContext.items.some(i => i.identifier === session.navItemRefId)\n ? { navItemRefId: session.navItemRefId }\n : {})\n };\n }\n\n #requestNavigation(type: 'item' | 'section', id: string): void {\n dispatchPublic(this, 'qc-test-navigate', { type, id });\n }\n }\n\n return TestStateClass as Constructor<ITestStateMixin> & T;\n};\n"]}
1
+ {"version":3,"file":"test-state.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-state.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AA+B3D,MAAM,IAAI,GAAG,CAAC,KAAkC,EAAS,EAAE,CACzD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,KAAmC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kB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACzD,CAAC;KACF;IAED,OAAO,cAAkD,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';\nimport { dispatchPublic, listenPublic } from '../public-events';\nimport { stateFromContexts } from '../state-from-contexts';\n\nimport type { PropertyValues } from 'lit';\nimport type { StateRefusal } from '../public-events';\nimport type { QtiTestState, QtiTestStateSession } from '../types/qti-test-state';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\ntype Value = string | string[] | null;\n\nexport interface ITestStateMixin {\n /**\n * The candidate's persistable state: what they answered and where they are.\n *\n * Assign a stored state to resume. It may be assigned at any time: before the test document\n * has loaded it is held and applied as soon as the test connects — before the first item\n * loads, so items and the initial navigation start from it — and after that it is applied\n * immediately and the test navigates to the restored position.\n *\n * Items are matched by item-ref identifier; items the state does not mention start fresh, and\n * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a\n * resume, so linear-mode navigation restrictions do not apply.\n *\n * A value that is not a version 1 `QtiTestState` is ignored and reported with\n * `qc-test-state-refused`: at once when the test has loaded, or when it does if it was assigned\n * before. A state assigned earlier that could be read stays in effect. A stored 9.x\n * `testContext` is turned into a state with `stateFromContexts`.\n */\n state: QtiTestState;\n}\n\nconst copy = (value: Readonly<Value> | undefined): Value =>\n Array.isArray(value) ? [...value] : ((value as string | null | undefined) ?? null);\n\nconst isQtiTestState = (value: unknown): value is QtiTestState => {\n const state = value as QtiTestState | null;\n return (\n state?.version === QTI_TEST_STATE_VERSION &&\n Array.isArray(state.test?.items) &&\n Array.isArray(state.test?.outcomes) &&\n typeof state.session === 'object' &&\n state.session !== null\n );\n};\n\n/**\n * Persist and resume a test session through one value, `state`, and one event,\n * `qc-test-state-changed`.\n *\n * Sits directly on top of `TestBaseMixin`, so its `qc-test-loaded` listener runs\n * after the base has built `testContext.items` from the item-refs, and before the navigation\n * mixin's listener picks the first item to load.\n */\nexport const TestStateMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestStateClass extends superClass implements ITestStateMixin {\n /** A state assigned before the test connected, applied when it does. */\n #pending: QtiTestState | null = null;\n\n /** A refused state assigned before the test connected, reported when it does. */\n #refused: StateRefusal | null = null;\n\n /**\n * False while a test document is loading. Loading resets both contexts and rebuilds them, so\n * the intermediate states are empty — emitting one would invite a host to save it over the\n * real one.\n */\n #ready = false;\n\n #lastEmitted: string | null = null;\n\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-testdoc-loaded', () => {\n this.#ready = false;\n this.#lastEmitted = null;\n });\n listenPublic(this, 'qc-test-update-plugin-state', ({ detail }) => this.#updatePluginState(detail));\n listenPublic(this, 'qc-test-loaded', () => {\n if (this.#pending) {\n this.#apply(this.#pending);\n this.#pending = null;\n }\n this.#ready = true;\n if (this.#refused) {\n dispatchPublic(this, 'qc-test-state-refused', this.#refused);\n this.#refused = null;\n }\n });\n }\n\n /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */\n #updatePluginState({ plugin, value }: { plugin: string; value: unknown }): void {\n if (typeof plugin !== 'string' || plugin === '') return;\n const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};\n let next: Record<string, unknown> = others;\n if (value !== null && value !== undefined) {\n try {\n next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };\n } catch {\n console.warn(`[qti-test] Ignoring plugin state for \"${plugin}\": it is not JSON.`);\n return;\n }\n }\n this.sessionContext = { ...this.sessionContext, plugins: next };\n }\n\n get state(): QtiTestState {\n return stateFromContexts(this.testContext, this.sessionContext);\n }\n\n set state(value: QtiTestState) {\n if (!isQtiTestState(value)) {\n const message = `Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`;\n console.warn(`[qti-test] ${message}`);\n // Hosts assign state before the test is in the page, where an event reaches no listener.\n if (this.#ready) dispatchPublic(this, 'qc-test-state-refused', { message, state: value });\n else this.#refused = { message, state: value };\n return;\n }\n if (!this.#ready) {\n this.#pending = value;\n return;\n }\n\n const { navItemRefId, navSectionId } = this.sessionContext;\n this.#apply(value);\n\n const restored = this.sessionContext;\n if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {\n this.#requestNavigation('item', restored.navItemRefId);\n } else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {\n this.#requestNavigation('section', restored.navSectionId);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (!this.#ready || !(changed.has('testContext') || changed.has('sessionContext'))) return;\n\n const state = this.state;\n const serialized = JSON.stringify(state);\n if (serialized === this.#lastEmitted) return;\n this.#lastEmitted = serialized;\n dispatchPublic(this, 'qc-test-state-changed', state);\n }\n\n #apply(state: QtiTestState): void {\n // Before the items load this only fills the test context; items already on screen are\n // updated too.\n for (const saved of state.test.items) this.updateItemVariables(saved.identifier, saved.variables, saved.state);\n\n const savedOutcomes = new Map(state.test.outcomes.map(outcome => [outcome.identifier, outcome.value]));\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v =>\n savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v\n )\n };\n\n // Written before any navigation request, so the linear-mode restriction — which compares\n // against the current position — sees the restored item as current and lets it load.\n // Plugins are replaced, not merged: a state without them clears what an earlier one left.\n this.sessionContext = {\n ...this.sessionContext,\n ...this.#validSession(state.session),\n plugins: state.session.plugins && typeof state.session.plugins === 'object' ? { ...state.session.plugins } : {}\n };\n }\n\n /** A stored position may point at an item or section a revised test no longer has. */\n #validSession(session: QtiTestStateSession): QtiTestStateSession {\n const exists = (selector: string, id: string | null | undefined) =>\n !!id && !!this._testElement?.querySelector(`${selector}[identifier=\"${CSS.escape(id)}\"]`);\n return {\n ...(exists('qti-test-part', session.navPartId) ? { navPartId: session.navPartId } : {}),\n ...(exists('qti-assessment-section', session.navSectionId) ? { navSectionId: session.navSectionId } : {}),\n ...(this.testContext.items.some(i => i.identifier === session.navItemRefId)\n ? { navItemRefId: session.navItemRefId }\n : {})\n };\n }\n\n #requestNavigation(type: 'item' | 'section', id: string): void {\n dispatchPublic(this, 'qc-test-navigate', { type, id });\n }\n }\n\n return TestStateClass as Constructor<ITestStateMixin> & T;\n};\n"]}
@@ -4,7 +4,7 @@
4
4
  * controls. `@qti-components/extended` is the consumer; a plugin of your own may use it too.
5
5
  */
6
6
  export { dispatchPublic, listenPublic, PUBLIC_EVENTS } from './public-events.js';
7
- export type { NavigationFailure, NavigationTarget, PublicEventMap, PublicEventName } from './public-events.js';
7
+ export type { NavigationFailure, NavigationTarget, PublicEventMap, PublicEventName, StateRefusal } from './public-events.js';
8
8
  export { pluginState } from './plugin-state.js';
9
9
  export type { QtiTestPluginState, QtiTestState } from './types/qti-test-state.js';
10
10
  export * as controlStyles from './components/styles.js';
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-api.js","sourceRoot":"","sources":["../src/plugin-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC","sourcesContent":["/**\n * What a plugin in another package builds on, with no registration side effect: the public events\n * and their helpers, the typed read of plugin state, the state types, and the look of the test\n * controls. `@qti-components/extended` is the consumer; a plugin of your own may use it too.\n */\nexport { dispatchPublic, listenPublic, PUBLIC_EVENTS } from './public-events.js';\nexport type { NavigationFailure, NavigationTarget, PublicEventMap, PublicEventName } from './public-events.js';\nexport { pluginState } from './plugin-state.js';\nexport type { QtiTestPluginState, QtiTestState } from './types/qti-test-state.js';\nexport * as controlStyles from './components/styles.js';\n"]}
1
+ {"version":3,"file":"plugin-api.js","sourceRoot":"","sources":["../src/plugin-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQjF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC","sourcesContent":["/**\n * What a plugin in another package builds on, with no registration side effect: the public events\n * and their helpers, the typed read of plugin state, the state types, and the look of the test\n * controls. `@qti-components/extended` is the consumer; a plugin of your own may use it too.\n */\nexport { dispatchPublic, listenPublic, PUBLIC_EVENTS } from './public-events.js';\nexport type {\n NavigationFailure,\n NavigationTarget,\n PublicEventMap,\n PublicEventName,\n StateRefusal\n} from './public-events.js';\nexport { pluginState } from './plugin-state.js';\nexport type { QtiTestPluginState, QtiTestState } from './types/qti-test-state.js';\nexport * as controlStyles from './components/styles.js';\n"]}
@@ -8,10 +8,10 @@ import type { QtiTestState } from './types/qti-test-state';
8
8
  * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense
9
9
  * (the test dispatches them). All bubble and are composed.
10
10
  *
11
- * `deprecated` is the `cito-` name this event had in 9.x. One helper (`dispatchPublic`,
12
- * `listenPublic`) sends or handles both names until the next major, then the field goes. The 7.x
13
- * names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no longer sent
14
- * or handled.
11
+ * `deprecated` is the `cito-` name this event had in 9.x; an event new in 10.0 has none. One helper
12
+ * (`dispatchPublic`, `listenPublic`) sends or handles both names until the next major, then the field
13
+ * goes. The 7.x names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no
14
+ * longer sent or handled.
15
15
  */
16
16
  export interface NavigationTarget {
17
17
  type: 'item' | 'section';
@@ -23,6 +23,13 @@ export interface NavigationFailure {
23
23
  itemId?: string;
24
24
  sectionId?: string;
25
25
  }
26
+ /** The detail of `qc-test-state-refused`. */
27
+ export interface StateRefusal {
28
+ /** Why the state was not read. */
29
+ message: string;
30
+ /** The value that was assigned to `state`, as given. */
31
+ state: unknown;
32
+ }
26
33
  export interface PublicEventMap {
27
34
  'qc-test-navigate': CustomEvent<NavigationTarget>;
28
35
  /**
@@ -55,6 +62,8 @@ export interface PublicEventMap {
55
62
  element: Element;
56
63
  }[]>;
57
64
  'qc-test-state-changed': CustomEvent<QtiTestState>;
65
+ /** A value assigned to `state` could not be read and was ignored: the test goes on without it. */
66
+ 'qc-test-state-refused': CustomEvent<StateRefusal>;
58
67
  'qc-test-items-skipped': CustomEvent<{
59
68
  ids: string[];
60
69
  }>;
@@ -13,6 +13,8 @@ export const PUBLIC_EVENTS = {
13
13
  'qc-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'cito-test-rendered' },
14
14
  'qc-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'cito-test-loaded' },
15
15
  'qc-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-state-changed' },
16
+ // New in 10.0, so it has no cito- name.
17
+ 'qc-test-state-refused': { kind: 'notification', scope: 'test' },
16
18
  'qc-test-items-skipped': { kind: 'notification', scope: 'test', deprecated: 'cito-test-items-skipped' },
17
19
  'qc-test-end-reached': { kind: 'notification', scope: 'test', deprecated: 'cito-test-end-reached' },
18
20
  'qc-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'cito-item-ref-connected' }
@@ -1 +1 @@
1
- {"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AA+D1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,kBAAkB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE;IACxF,qBAAqB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,uBAAuB,EAAE;IAC9F,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EA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AE,UAAU,EAAE,uBAAuB,EAAE;IACnG,uBAAuB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE;CACxG,CAAC;AAMF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,IAAO,EACP,MAAkE;IAElE,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `qc-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the `cito-` name this event had in 9.x. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes. The 7.x\n * names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no longer sent\n * or handled.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'qc-test-navigate': CustomEvent<NavigationTarget>;\n /**\n * Ends an attempt: processes the response of the item-ref `itemId`, or, without it, of the item on\n * screen. `<test-end-attempt>` sends the `itemId` of the item it is stamped into or names.\n */\n 'qc-test-end-attempt': CustomEvent<{ itemId?: string }>;\n /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `qc-test-submitted`. */\n 'qc-test-submit': CustomEvent<Record<string, never>>;\n 'qc-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'qc-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'qc-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n /** Outcome processing ran after a submit: read the test outcomes now. */\n 'qc-test-submitted': CustomEvent<Record<string, never>>;\n 'qc-test-navigated': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-started': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'qc-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `qc-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'qc-test-state-changed': CustomEvent<QtiTestState>;\n 'qc-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'qc-test-end-reached': CustomEvent<Record<string, never>>;\n 'qc-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'qc-test-navigate': { kind: 'request', scope: 'test', deprecated: 'cito-test-navigate' },\n 'qc-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'cito-test-end-attempt' },\n 'qc-test-submit': { kind: 'request', scope: 'test', deprecated: 'cito-test-submit' },\n 'qc-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-outcome' },\n 'qc-test-update-plugin-state': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-plugin-state' },\n 'qc-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'cito-test-switch-view' },\n 'qc-test-submitted': { kind: 'notification', scope: 'test', deprecated: 'cito-test-submitted' },\n 'qc-test-navigated': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigated' },\n 'qc-test-navigation-started': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-started' },\n 'qc-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-failed' },\n 'qc-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'cito-test-rendered' },\n 'qc-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'cito-test-loaded' },\n 'qc-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-state-changed' },\n 'qc-test-items-skipped': { kind: 'notification', scope: 'test', deprecated: 'cito-test-items-skipped' },\n 'qc-test-end-reached': { kind: 'notification', scope: 'test', deprecated: 'cito-test-end-reached' },\n 'qc-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'cito-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
1
+ {"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAyE1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,kBAAkB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE;IACx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IACxC,uBAAuB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAChE,uBAAuB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE;IACvG,qBAAqB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,uBAAuB,EAAE;IACnG,uBAAuB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE;CACxG,CAAC;AAMF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,IAAO,EACP,MAAkE;IAElE,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `qc-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the `cito-` name this event had in 9.x; an event new in 10.0 has none. One helper\n * (`dispatchPublic`, `listenPublic`) sends or handles both names until the next major, then the field\n * goes. The 7.x names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no\n * longer sent or handled.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\n/** The detail of `qc-test-state-refused`. */\nexport interface StateRefusal {\n /** Why the state was not read. */\n message: string;\n /** The value that was assigned to `state`, as given. */\n state: unknown;\n}\n\nexport interface PublicEventMap {\n 'qc-test-navigate': CustomEvent<NavigationTarget>;\n /**\n * Ends an attempt: processes the response of the item-ref `itemId`, or, without it, of the item on\n * screen. `<test-end-attempt>` sends the `itemId` of the item it is stamped into or names.\n */\n 'qc-test-end-attempt': CustomEvent<{ itemId?: string }>;\n /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `qc-test-submitted`. */\n 'qc-test-submit': CustomEvent<Record<string, never>>;\n 'qc-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'qc-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'qc-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n /** Outcome processing ran after a submit: read the test outcomes now. */\n 'qc-test-submitted': CustomEvent<Record<string, never>>;\n 'qc-test-navigated': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-started': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'qc-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `qc-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'qc-test-state-changed': CustomEvent<QtiTestState>;\n /** A value assigned to `state` could not be read and was ignored: the test goes on without it. */\n 'qc-test-state-refused': CustomEvent<StateRefusal>;\n 'qc-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'qc-test-end-reached': CustomEvent<Record<string, never>>;\n 'qc-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'qc-test-navigate': { kind: 'request', scope: 'test', deprecated: 'cito-test-navigate' },\n 'qc-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'cito-test-end-attempt' },\n 'qc-test-submit': { kind: 'request', scope: 'test', deprecated: 'cito-test-submit' },\n 'qc-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-outcome' },\n 'qc-test-update-plugin-state': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-plugin-state' },\n 'qc-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'cito-test-switch-view' },\n 'qc-test-submitted': { kind: 'notification', scope: 'test', deprecated: 'cito-test-submitted' },\n 'qc-test-navigated': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigated' },\n 'qc-test-navigation-started': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-started' },\n 'qc-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-failed' },\n 'qc-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'cito-test-rendered' },\n 'qc-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'cito-test-loaded' },\n 'qc-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-state-changed' },\n // New in 10.0, so it has no cito- name.\n 'qc-test-state-refused': { kind: 'notification', scope: 'test' },\n 'qc-test-items-skipped': { kind: 'notification', scope: 'test', deprecated: 'cito-test-items-skipped' },\n 'qc-test-end-reached': { kind: 'notification', scope: 'test', deprecated: 'cito-test-end-reached' },\n 'qc-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'cito-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\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.19",
4
+ "version": "2.0.0-next.20",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
8
8
  "@qti-components/base": "^3.0.0-next.9",
9
- "@qti-components/delivery": "^0.1.0-next.1",
9
+ "@qti-components/delivery": "^0.1.0-next.2",
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",