@citolab/qti-components 10.0.0-next.22 → 10.0.0-next.23

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  QtiTest,
3
3
  TestNavigation
4
- } from "./chunk-373IRT4X.js";
4
+ } from "./chunk-IJKHXJSM.js";
5
5
  import {
6
6
  QtiAssessmentItem
7
7
  } from "./chunk-H6DO5UHC.js";
@@ -1686,4 +1686,4 @@ export {
1686
1686
  TestNavigationCorrection,
1687
1687
  QtiTestCorrection
1688
1688
  };
1689
- //# sourceMappingURL=chunk-L73QXB6G.js.map
1689
+ //# sourceMappingURL=chunk-ULJ22VKL.js.map
@@ -33,10 +33,10 @@ import {
33
33
  TestNavigationCorrection,
34
34
  TestShowCorrectResponse,
35
35
  correctionPart
36
- } from "./chunk-L73QXB6G.js";
36
+ } from "./chunk-ULJ22VKL.js";
37
37
  import {
38
38
  qtiTestElements
39
- } from "./chunk-373IRT4X.js";
39
+ } from "./chunk-IJKHXJSM.js";
40
40
  import "./chunk-J6VX4N7M.js";
41
41
  import {
42
42
  qtiContentElements
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { I as ITestNavigationMixin, a as ITestStateMixin, b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiBranchRule, f as QtiItemSessionControl, g as QtiNumberPresented, h as QtiNumberSelected, i as QtiOutcomeProcessing, j as QtiOutcomeProcessingProcessor, k as QtiPreCondition, l as QtiTest, m as QtiTestFeedback, n as QtiTestPart, o as QtiTestVariables, p as QtiTestVariablesExpression, T as TestContainer, q as TestEndAttempt, r as TestNavigation, s as TestNext, t as TestPrev, u as TestSubmit } from './qti-test.d-CN2JZwAz.js';
2
- export { IMyQtiTest, IQtiTest, ITestProcessingMixin, pluginElements } from './test.js';
2
+ export { IMyQtiTest, IQtiTest, ITestProcessingMixin, StoredSessionContext, StoredTestContext, StoredVariable, pluginElements, stateFromContexts } from './test.js';
3
3
  export { Q as QTI_TEST_STATE_VERSION, a as QtiTestPluginState, b as QtiTestState, c as QtiTestStateItem, d as QtiTestStateSession, e as QtiTestStateValue, p as pluginState } from './qti-test-state-C71K8UNC.js';
4
4
  export { I as ItemContainer, a as ItemPrintVariables, Q as QtiItem } from './qti-item.d-CxP6KtCH.js';
5
5
  export { ItemViewMixin } from './item.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-BB2ZSJXP.js";
1
+ import "./chunk-DJQE4M7B.js";
2
2
  import {
3
3
  pluginState
4
4
  } from "./chunk-DJ7PB252.js";
@@ -37,7 +37,7 @@ import {
37
37
  TestNavigationCorrection,
38
38
  TestShowCorrectResponse,
39
39
  correctionPart
40
- } from "./chunk-L73QXB6G.js";
40
+ } from "./chunk-ULJ22VKL.js";
41
41
  import {
42
42
  QTI_TEST_STATE_VERSION,
43
43
  QtiAssessmentItemRef,
@@ -61,8 +61,9 @@ import {
61
61
  TestNext,
62
62
  TestPrev,
63
63
  TestSubmit,
64
- pluginElements
65
- } from "./chunk-373IRT4X.js";
64
+ pluginElements,
65
+ stateFromContexts
66
+ } from "./chunk-IJKHXJSM.js";
66
67
  import "./chunk-J6VX4N7M.js";
67
68
  import "./chunk-TSJGL6FI.js";
68
69
  import {
@@ -531,6 +532,7 @@ export {
531
532
  serializeResponseAttribute,
532
533
  sessionContext,
533
534
  setState,
535
+ stateFromContexts,
534
536
  testContext,
535
537
  unregisterCustomOperator,
536
538
  validationMessage
package/dist/test.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { u as TestSubmit, v as ItemVariableValue, I as ITestNavigationMixin, a as ITestStateMixin } from './qti-test.d-CN2JZwAz.js';
2
2
  export { b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiBranchRule, f as QtiItemSessionControl, g as QtiNumberPresented, h as QtiNumberSelected, i as QtiOutcomeProcessing, j as QtiOutcomeProcessingProcessor, k as QtiPreCondition, l as QtiTest, m as QtiTestFeedback, n as QtiTestPart, o as QtiTestVariables, p as QtiTestVariablesExpression, T as TestContainer, q as TestEndAttempt, r as TestNavigation, s as TestNext, t as TestPrev } from './qti-test.d-CN2JZwAz.js';
3
- export { Q as QTI_TEST_STATE_VERSION, a as QtiTestPluginState, b as QtiTestState, c as QtiTestStateItem, d as QtiTestStateSession, e as QtiTestStateValue, p as pluginState } from './qti-test-state-C71K8UNC.js';
3
+ import { b as QtiTestState } from './qti-test-state-C71K8UNC.js';
4
+ export { Q as QTI_TEST_STATE_VERSION, a as QtiTestPluginState, c as QtiTestStateItem, d as QtiTestStateSession, e as QtiTestStateValue, p as pluginState } from './qti-test-state-C71K8UNC.js';
4
5
  import { LitElement } from 'lit';
5
6
  import { b as OutcomeVariable, V as VariableDeclaration } from './variables.d-DWHlTszN.js';
6
7
  import { S as SessionContext } from './session.context.d-9gRdGK4T.js';
@@ -29,6 +30,51 @@ declare const pluginElements: readonly [{
29
30
  readonly ctor: typeof TestSubmit;
30
31
  }];
31
32
 
33
+ /** A value as a 9.x host may have stored it: QTI values are strings, but JSON kept numbers as numbers. */
34
+ type StoredValue = string | number | boolean | null | undefined | readonly (string | number | boolean)[];
35
+ /** A variable as stored: only `identifier`, `value` and `type` are read; declaration metadata is ignored. */
36
+ interface StoredVariable {
37
+ identifier: string;
38
+ value?: StoredValue;
39
+ type?: string;
40
+ }
41
+ /**
42
+ * A `testContext` as a 9.x host stored it (`qtiTest.testContext` or the `qti-test-context-updated`
43
+ * payload), plain JSON. Fields this does not name, such as an item's `href` or a host's own
44
+ * additions, are ignored.
45
+ */
46
+ interface StoredTestContext {
47
+ items?: readonly {
48
+ identifier?: string;
49
+ variables?: readonly StoredVariable[];
50
+ state?: Readonly<Record<string, string | null>>;
51
+ }[];
52
+ testOutcomeVariables?: readonly StoredVariable[];
53
+ }
54
+ /** A `sessionContext` as a 9.x host stored it: the position and the plugin entries. */
55
+ interface StoredSessionContext {
56
+ navPartId?: string | null;
57
+ navSectionId?: string | null;
58
+ navItemRefId?: string | null;
59
+ plugins?: Readonly<Record<string, unknown>>;
60
+ }
61
+ /**
62
+ * Turns a stored `testContext` and `sessionContext` into a `QtiTestState`, so a host that stored the
63
+ * contexts in 9.x can resume with `qtiTest.state = stateFromContexts(testContext, sessionContext)`.
64
+ * `qtiTest.state` reads the same way from the live contexts.
65
+ *
66
+ * It keeps the values only: each item's variables (identifier, value and `type` when it is one QTI
67
+ * knows) and per-interaction state, the test outcomes, the position and the plugin entries. Values
68
+ * are written as QTI's strings, so a number a host stored as a JSON number (`SCORE: 0`) becomes
69
+ * `'0'`. Declaration metadata (`baseType`, `cardinality`, `correctResponse`, …) is left out, as in
70
+ * every `QtiTestState`. Items without an identifier are skipped.
71
+ *
72
+ * @param testContext The stored test context, plain JSON.
73
+ * @param sessionContext The stored session context, if the host kept one. A host that stored only the
74
+ * item it was on passes `{ navItemRefId }`.
75
+ */
76
+ declare const stateFromContexts: (testContext: Readonly<StoredTestContext> | null | undefined, sessionContext?: Readonly<StoredSessionContext> | null) => QtiTestState;
77
+
32
78
  interface IQtiTest extends LitElement, ITestNavigationMixin, ITestProcessingMixin, ITestStateMixin, IMyQtiTest {
33
79
  }
34
80
  interface IMyQtiTest {
@@ -45,4 +91,4 @@ interface ITestProcessingMixin {
45
91
  outcomeProcessing(): boolean;
46
92
  }
47
93
 
48
- export { type IMyQtiTest, type IQtiTest, ITestNavigationMixin, type ITestProcessingMixin, ITestStateMixin, TestSubmit, pluginElements };
94
+ export { type IMyQtiTest, type IQtiTest, ITestNavigationMixin, type ITestProcessingMixin, ITestStateMixin, QtiTestState, type StoredSessionContext, type StoredTestContext, type StoredVariable, TestSubmit, pluginElements, stateFromContexts };
package/dist/test.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-BB2ZSJXP.js";
1
+ import "./chunk-DJQE4M7B.js";
2
2
  import {
3
3
  pluginState
4
4
  } from "./chunk-DJ7PB252.js";
@@ -25,8 +25,9 @@ import {
25
25
  TestNext,
26
26
  TestPrev,
27
27
  TestSubmit,
28
- pluginElements
29
- } from "./chunk-373IRT4X.js";
28
+ pluginElements,
29
+ stateFromContexts
30
+ } from "./chunk-IJKHXJSM.js";
30
31
  import "./chunk-J6VX4N7M.js";
31
32
  import "./chunk-H6DO5UHC.js";
32
33
  import "./chunk-UCXLDQYA.js";
@@ -59,6 +60,7 @@ export {
59
60
  TestPrev,
60
61
  TestSubmit,
61
62
  pluginElements,
62
- pluginState
63
+ pluginState,
64
+ stateFromContexts
63
65
  };
64
66
  //# sourceMappingURL=test.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@citolab/qti-components",
3
3
  "description": "QTI component utilities",
4
- "version": "10.0.0-next.22",
4
+ "version": "10.0.0-next.23",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
@@ -18,7 +18,7 @@
18
18
  "@qti-components/item": "^1.5.1-next.7",
19
19
  "@qti-components/loader": "^1.3.4-next.2",
20
20
  "@qti-components/processing": "^1.6.1-next.5",
21
- "@qti-components/test": "^2.0.0-next.18",
21
+ "@qti-components/test": "^2.0.0-next.19",
22
22
  "@qti-components/theme": "^3.0.0-next.6",
23
23
  "@qti-components/transformers": "^1.8.0-next.1"
24
24
  },