@citolab/qti-components 9.3.0 → 10.0.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.
Files changed (64) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +258 -206
  3. package/dist/base.d.ts +10 -10
  4. package/dist/base.js +1 -1
  5. package/dist/{chunk-G5RQ5GKG.js → chunk-3BAQWO5C.js} +2 -2
  6. package/dist/{chunk-ZG7FBQFP.js → chunk-ACRN7YJM.js} +2 -2
  7. package/dist/{chunk-REKCRWJV.js → chunk-AWTQKBC4.js} +231 -129
  8. package/dist/chunk-AWTQKBC4.js.map +1 -0
  9. package/dist/{chunk-JGPWBIVD.js → chunk-CNFVA3AA.js} +128 -48
  10. package/dist/chunk-CNFVA3AA.js.map +1 -0
  11. package/dist/{chunk-CQHGVPOT.js → chunk-EPSUZIWL.js} +6 -6
  12. package/dist/{chunk-TDWLV5OD.js → chunk-EUKU5QKV.js} +633 -352
  13. package/dist/chunk-EUKU5QKV.js.map +1 -0
  14. package/dist/{chunk-RAJQKCQ3.js → chunk-F7R7GSWL.js} +3 -3
  15. package/dist/{chunk-FG5JAWSN.js → chunk-GPNWMLLA.js} +2 -2
  16. package/dist/{chunk-7VDR765S.js → chunk-QD3Y6UK3.js} +2 -2
  17. package/dist/{chunk-YVZWNLF4.js → chunk-R7MMMDP7.js} +139 -18
  18. package/dist/chunk-R7MMMDP7.js.map +1 -0
  19. package/dist/{chunk-JLZCZVRX.js → chunk-SVYHZIJ7.js} +2 -2
  20. package/dist/{chunk-YIYHCHHM.js → chunk-WNAOVXXN.js} +2 -2
  21. package/dist/chunk-ZP6QQYSU.js +7 -0
  22. package/dist/chunk-ZP6QQYSU.js.map +1 -0
  23. package/dist/{computed.types.d-DB5gfOh9.d.ts → computed.types.d-gJrBeUMG.d.ts} +1 -1
  24. package/dist/corrections.d.ts +9 -9
  25. package/dist/corrections.js +8 -8
  26. package/dist/elements.d.ts +108 -6
  27. package/dist/elements.js +17 -5
  28. package/dist/index.d.ts +12 -12
  29. package/dist/index.js +28 -14
  30. package/dist/{interaction.d-DegNJ5ZA.d.ts → interaction.d-g6XG0T0Z.d.ts} +2 -2
  31. package/dist/interactions.d.ts +4 -4
  32. package/dist/interactions.js +3 -3
  33. package/dist/item.css +11 -0
  34. package/dist/item.d.ts +4 -4
  35. package/dist/item.js +4 -4
  36. package/dist/{item.types.d-BDFrq19E.d.ts → item.types.d-B55QkJ92.d.ts} +10 -0
  37. package/dist/loader.d.ts +2 -2
  38. package/dist/processing.d.ts +3 -3
  39. package/dist/processing.js +3 -3
  40. package/dist/qti-components-jsx.d.ts +354 -440
  41. package/dist/{qti-condition-expression.d-DLboq8bR.d.ts → qti-condition-expression.d-L7yb3Rzy.d.ts} +1 -1
  42. package/dist/{qti-expression.d-BksT9iLB.d.ts → qti-expression.d-CuaLjZ6g.d.ts} +1 -1
  43. package/dist/{qti-feedback.d-D-w6-mJv.d.ts → qti-feedback.d-wMYNVkkj.d.ts} +2 -3
  44. package/dist/{qti-item.d-D_-9_0e6.d.ts → qti-item.d-DgC1AQbY.d.ts} +1 -1
  45. package/dist/{qti-test.d-D-ELy0Mr.d.ts → qti-test.d-_THYXPzd.d.ts} +206 -46
  46. package/dist/{qti-text-entry-interaction.d-CATtcPyX.d.ts → qti-text-entry-interaction.d-q8u5BiVK.d.ts} +13 -4
  47. package/dist/{session.context.d-Cjs0BkJB.d.ts → session.context.d-D5080LVx.d.ts} +3 -1
  48. package/dist/test.d.ts +58 -11
  49. package/dist/test.js +7 -5
  50. package/package.json +9 -9
  51. package/dist/chunk-A32YH4H5.js +0 -7
  52. package/dist/chunk-A32YH4H5.js.map +0 -1
  53. package/dist/chunk-JGPWBIVD.js.map +0 -1
  54. package/dist/chunk-REKCRWJV.js.map +0 -1
  55. package/dist/chunk-TDWLV5OD.js.map +0 -1
  56. package/dist/chunk-YVZWNLF4.js.map +0 -1
  57. /package/dist/{chunk-G5RQ5GKG.js.map → chunk-3BAQWO5C.js.map} +0 -0
  58. /package/dist/{chunk-ZG7FBQFP.js.map → chunk-ACRN7YJM.js.map} +0 -0
  59. /package/dist/{chunk-CQHGVPOT.js.map → chunk-EPSUZIWL.js.map} +0 -0
  60. /package/dist/{chunk-RAJQKCQ3.js.map → chunk-F7R7GSWL.js.map} +0 -0
  61. /package/dist/{chunk-FG5JAWSN.js.map → chunk-GPNWMLLA.js.map} +0 -0
  62. /package/dist/{chunk-7VDR765S.js.map → chunk-QD3Y6UK3.js.map} +0 -0
  63. /package/dist/{chunk-JLZCZVRX.js.map → chunk-SVYHZIJ7.js.map} +0 -0
  64. /package/dist/{chunk-YIYHCHHM.js.map → chunk-WNAOVXXN.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { Q as QtiExpression } from './qti-expression.d-BksT9iLB.js';
1
+ import { Q as QtiExpression } from './qti-expression.d-CuaLjZ6g.js';
2
2
 
3
3
  declare abstract class QtiConditionExpression extends QtiExpression<boolean> {
4
4
  calculate(): Readonly<boolean>;
@@ -1,6 +1,6 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement } from 'lit';
3
- import { b as ItemContext, V as VariableDeclaration, g as ResponseVariable, B as BaseType } from './item.types.d-BDFrq19E.js';
3
+ import { b as ItemContext, V as VariableDeclaration, g as ResponseVariable, B as BaseType } from './item.types.d-B55QkJ92.js';
4
4
  import { a as QtiContextType, Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
5
5
 
6
6
  interface TestContext {
@@ -1,6 +1,6 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement } from 'lit';
3
- import { a as Cardinality } from './item.types.d-BDFrq19E.js';
3
+ import { a as Cardinality } from './item.types.d-B55QkJ92.js';
4
4
 
5
5
  declare abstract class QtiVariableDeclaration extends LitElement {
6
6
  render(): lit.TemplateResult<1>;
@@ -13,9 +13,8 @@ declare abstract class QtiFeedback extends LitElement {
13
13
  outcomeIdentifier: string;
14
14
  protected identifier: string;
15
15
  showStatus: string;
16
- private _context?;
16
+ private get _context();
17
17
  private _computedContext?;
18
- connectedCallback(): void;
19
18
  checkShowFeedback(outcomeIdentifier: string): void;
20
19
  }
21
20
 
@@ -1,7 +1,7 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement } from 'lit';
3
3
  import { Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
4
- import { C as ComputedItemContext, V as View } from './session.context.d-Cjs0BkJB.js';
4
+ import { C as ComputedItemContext, V as View } from './session.context.d-D5080LVx.js';
5
5
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
6
6
  import { QtiAssessmentItem } from './elements.js';
7
7
 
@@ -1,15 +1,54 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, nothing } from 'lit';
3
- import { t as transformItemApi, b as transformTestApi } from './qti-transform-test.d-BL7GGFJj.js';
4
- import { C as ComputedContext, a as ComputedItem } from './computed.types.d-DB5gfOh9.js';
3
+ import { b as transformTestApi, t as transformItemApi } from './qti-transform-test.d-BL7GGFJj.js';
4
+ import { C as ComputedContext, a as ComputedItem } from './computed.types.d-gJrBeUMG.js';
5
5
  import { QtiAssessmentItem, QtiModalFeedback } from './elements.js';
6
+ import { Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
7
+ import { T as TestContext, Q as QtiExpression, a as QtiExpressionBase } from './qti-expression.d-CuaLjZ6g.js';
6
8
  import { TemplateFunction } from '@heximal/templates';
7
- import { T as TestContext, Q as QtiExpression, a as QtiExpressionBase } from './qti-expression.d-BksT9iLB.js';
8
- import { h as VariableValue, c as OutcomeVariable, V as VariableDeclaration } from './item.types.d-BDFrq19E.js';
9
- import { S as SessionContext, V as View } from './session.context.d-Cjs0BkJB.js';
9
+ import { h as VariableValue, b as ItemContext, c as OutcomeVariable, V as VariableDeclaration } from './item.types.d-B55QkJ92.js';
10
+ import { S as SessionContext, V as View } from './session.context.d-D5080LVx.js';
10
11
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
11
12
  import { b as QtiRuleBase } from './qti-rule-base.d-Bdzg8eGH.js';
12
- import { Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
13
+
14
+ declare class QtiAssessmentTest extends LitElement {
15
+ #private;
16
+ identifier: string;
17
+ get title(): string;
18
+ set title(value: string);
19
+ _testContext?: TestContext;
20
+ connectedCallback(): Promise<void>;
21
+ render(): lit.TemplateResult<1>;
22
+ }
23
+ declare global {
24
+ interface HTMLElementTagNameMap {
25
+ 'qti-assessment-test': QtiAssessmentTest;
26
+ }
27
+ }
28
+ declare module '../../public-events' {
29
+ interface PublicEventMap {
30
+ 'cito-test-loaded': CustomEvent<QtiAssessmentTest>;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Defined here, and re-exported by the navigation mixin under the same name, so this file imports
36
+ * nothing from the mixin: the mixin imports the components that consume this context, and a type
37
+ * import counts as a dependency for madge.
38
+ */
39
+ type PostLoadTestTransformCallback = (transformer: transformTestApi, testElement: QtiAssessmentTest) => transformTestApi | Promise<transformTestApi>;
40
+ /**
41
+ * What the components inside a test need from the `qti-test` that contains them: the things a host
42
+ * put on it, and the element to query. Provided by `qti-test` about itself.
43
+ *
44
+ * It is context and not `closest('qti-test')` because a request crosses shadow roots and `closest`
45
+ * stops at the first one, so a navigation or container a host renders inside its own component
46
+ * would never find its test. Internal on purpose: not exported from the package, and not API.
47
+ */
48
+ interface TestHost extends HTMLElement {
49
+ qtiContext: QtiContext;
50
+ postLoadTestTransformCallback: PostLoadTestTransformCallback | null;
51
+ }
13
52
 
14
53
  /**
15
54
  * The model a `<template item-ref>` is rendered with.
@@ -56,6 +95,9 @@ declare class QtiAssessmentItemRef extends LitElement {
56
95
  protected createRenderRoot(): HTMLElement | DocumentFragment;
57
96
  get assessmentItem(): QtiAssessmentItem | null;
58
97
  myTemplate: TemplateFunction | null;
98
+ /** The `qti-test` this ref belongs to, wherever it renders: light DOM, or any depth of shadow roots. */
99
+ protected testHost?: TestHost;
100
+ disconnectedCallback(): void;
59
101
  connectedCallback(): Promise<void>;
60
102
  render(): unknown;
61
103
  }
@@ -86,21 +128,6 @@ declare global {
86
128
  }
87
129
  }
88
130
 
89
- declare class QtiAssessmentTest extends LitElement {
90
- #private;
91
- identifier: string;
92
- get title(): string;
93
- set title(value: string);
94
- _testContext?: TestContext;
95
- connectedCallback(): Promise<void>;
96
- render(): lit.TemplateResult<1>;
97
- }
98
- declare global {
99
- interface HTMLElementTagNameMap {
100
- 'qti-assessment-test': QtiAssessmentTest;
101
- }
102
- }
103
-
104
131
  /**
105
132
  * @summary The qti-item-session-control element contains configurations relating to flow of test sessions.
106
133
  * @documentation https://www.imsglobal.org/sites/default/files/spec/qti/v3/info/imsqti_asi_v3p0p1_infomodel_v1p0.html#Derived_ItemSessionControl
@@ -214,12 +241,16 @@ interface TestBaseInterface extends LitElement {
214
241
  testContext: Readonly<TestContext>;
215
242
  sessionContext: Readonly<SessionContext>;
216
243
  configContext?: Readonly<ConfigContext>;
244
+ /** Provided by `qti-test`. */
245
+ qtiContext?: Readonly<QtiContext>;
217
246
  _testElement: QtiAssessmentTest;
218
- updateItemVariables(itemRefID: string, variables: VariableValue<string | string[] | null>[]): void;
247
+ updateItemVariables(itemRefID: string, variables: readonly ItemVariableValue[], state?: ItemContext['state']): void;
219
248
  }
249
+ /** A value to set on an item; `type` is only needed for a variable the item does not declare. */
250
+ type ItemVariableValue = Pick<VariableValue<string | string[] | null>, 'identifier' | 'value'> & Partial<Pick<VariableValue<string | string[] | null>, 'type'>>;
220
251
 
221
252
  type PostLoadTransformCallback = (transformer: transformItemApi, itemRef: QtiAssessmentItemRef) => transformItemApi | Promise<transformItemApi>;
222
- type PostLoadTestTransformCallback = (transformer: transformTestApi, testElement: QtiAssessmentTest) => transformTestApi | Promise<transformTestApi>;
253
+
223
254
  /**
224
255
  * Exactly what this mixin adds. `IQtiTest` composes it (see ../types/iqti-test, which
225
256
  * re-exports it), and `TestNavigationClass` below `implements` it, so the interface and the
@@ -250,13 +281,72 @@ interface ITestNavigationMixin {
250
281
  };
251
282
  }
252
283
 
253
- type CustomEventMap = {
254
- 'test-end-attempt': CustomEvent;
255
- };
284
+ /**
285
+ * Everything a host needs to persist to resume a candidate's test session, and nothing else.
286
+ *
287
+ * Read it from `qtiTest.state` or the `qti-state-changed` event, store it wherever you like —
288
+ * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.
289
+ *
290
+ * Deliberately not here:
291
+ * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes
292
+ * from the item XML on every load, and persisting the answer key with the candidate's data is
293
+ * both bloat and a leak;
294
+ * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.
295
+ * The shuffle `seed` in particular must be passed in again, or the restored order changes;
296
+ * - `view`: a role the host decides, not something the candidate produced;
297
+ * - anything computed — scores per section, `done`, `active` — which is rederived from this.
298
+ */
299
+ interface QtiTestState {
300
+ /** Bumped on any incompatible change to this shape. A state with another version is ignored. */
301
+ version: 1;
302
+ test: {
303
+ items: QtiTestStateItem[];
304
+ /** Test-level outcome values. Only outcomes the test declares are restored. */
305
+ outcomes: QtiTestStateValue[];
306
+ };
307
+ session: QtiTestStateSession;
308
+ }
309
+ interface QtiTestStateItem {
310
+ /** The `qti-assessment-item-ref` identifier. */
311
+ identifier: string;
312
+ variables: (QtiTestStateValue & {
313
+ type?: 'response' | 'outcome' | 'template' | 'context';
314
+ })[];
315
+ /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */
316
+ state?: Record<string, string | null>;
317
+ }
318
+ interface QtiTestStateValue {
319
+ identifier: string;
320
+ value: string | string[] | null;
321
+ }
322
+ /** Where the candidate is. */
323
+ interface QtiTestStateSession {
324
+ navPartId?: string | null;
325
+ navSectionId?: string | null;
326
+ navItemRefId?: string | null;
327
+ }
328
+
256
329
  declare global {
257
- interface GlobalEventHandlersEventMap extends CustomEventMap {
330
+ interface GlobalEventHandlersEventMap {
331
+ 'qti-state-changed': CustomEvent<QtiTestState>;
258
332
  }
259
333
  }
334
+ interface ITestStateMixin {
335
+ /**
336
+ * The candidate's persistable state: what they answered and where they are.
337
+ *
338
+ * Assign a stored state to resume. It may be assigned at any time: before the test document
339
+ * has loaded it is held and applied as soon as the test connects — before the first item
340
+ * loads, so items and the initial navigation start from it — and after that it is applied
341
+ * immediately and the test navigates to the restored position.
342
+ *
343
+ * Items are matched by item-ref identifier; items the state does not mention start fresh, and
344
+ * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a
345
+ * resume, so linear-mode navigation restrictions do not apply.
346
+ */
347
+ state: QtiTestState;
348
+ }
349
+
260
350
  declare class TestNavigation extends LitElement {
261
351
  #private;
262
352
  identifier: string | undefined;
@@ -264,7 +354,15 @@ declare class TestNavigation extends LitElement {
264
354
  identifier: string;
265
355
  [key: string]: any;
266
356
  }[];
267
- qtiContext: QtiContext;
357
+ /**
358
+ * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
359
+ * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
360
+ * shuffle seed here keeps working. Removed in the next major.
361
+ *
362
+ * Written before the navigation is inside a test, it waits and is handed over on connect.
363
+ */
364
+ get qtiContext(): QtiContext;
365
+ set qtiContext(value: QtiContext);
268
366
  configContext: ConfigContext;
269
367
  protected _testContext?: TestContext;
270
368
  protected _sessionContext?: SessionContext;
@@ -443,6 +541,8 @@ declare class TestContainer extends LitElement {
443
541
  testDoc: DocumentFragment | null;
444
542
  /** The raw XML string */
445
543
  testXML: string | null;
544
+ /** The `qti-test` this container is in: where the host's `postLoadTestTransformCallback` lives. */
545
+ protected testHost?: TestHost;
446
546
  protected qtiContext: QtiContext;
447
547
  protected createRenderRoot(): HTMLElement | DocumentFragment;
448
548
  /** Callback function to transform the test after loading */
@@ -543,7 +643,7 @@ declare class TestScoringButtons extends LitElement {
543
643
  protected createRenderRoot(): HTMLElement | DocumentFragment;
544
644
  connectedCallback(): void;
545
645
  protected computedContext?: ComputedContext;
546
- render(): typeof nothing | lit.TemplateResult<1>;
646
+ render(): lit.TemplateResult<1> | typeof nothing;
547
647
  constructor();
548
648
  }
549
649
  declare global {
@@ -579,6 +679,7 @@ declare global {
579
679
  }
580
680
 
581
681
  declare class TestCheckItem extends LitElement {
682
+ protected testHost?: TestHost;
582
683
  static styles: lit.CSSResult;
583
684
  constructor();
584
685
  render(): lit.TemplateResult<1>;
@@ -661,17 +762,66 @@ declare abstract class TtsButtonBase extends LitElement {
661
762
  * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with
662
763
  * `xml:lang="en-GB"` on a `<p>` or on the item root is honoured without further work.
663
764
  *
664
- * ### Which item is read
765
+ * ### What is read
766
+ *
767
+ * Decided once per connect, by where the player is placed. The first rule that matches wins:
768
+ *
769
+ * 1. **Next to a stimulus placeholder** — the player shares its parent with a
770
+ * `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the
771
+ * player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the
772
+ * placeholder: loading a stimulus replaces the placeholder's content. Items and navigation
773
+ * are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts
774
+ * over on the new content.
775
+ * 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked
776
+ * `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes
777
+ * on one container; the player reads the readable elements inside it. Navigation is ignored.
778
+ * The reading list is rebuilt when the player starts from the top, and when an element in it
779
+ * has left the page — so a re-render of the content never interrupts speech.
780
+ * 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,
781
+ * so every item gets a player of its own: the player reads that item, and only that item.
782
+ * The navigation cursor is ignored; speech stops when the player leaves the page with its item.
783
+ * 4. **Anywhere else** — a toolbar in the page chrome: the player follows the navigation cursor
784
+ * and reads the item `navItemRefId` (session context) points at, found in any
785
+ * `test-container` reachable from the player. Navigating stops speech and starts the next
786
+ * item from the top.
787
+ *
788
+ * ```html
789
+ * <!-- 1. a player for the shared reading text -->
790
+ * <aside>
791
+ * <test-item-to-speech>…</test-item-to-speech>
792
+ * <div data-stimulus-idref="Stimulus1"></div>
793
+ * </aside>
794
+ *
795
+ * <!-- 2. a player for any other HTML -->
796
+ * <div>
797
+ * <test-item-to-speech>…</test-item-to-speech>
798
+ * <section data-tts-content lang="nl-NL">…</section>
799
+ * </div>
800
+ *
801
+ * <!-- 3. one player per item -->
802
+ * <qti-test>
803
+ * <template item-ref>
804
+ * <test-item-to-speech>…</test-item-to-speech>
805
+ * {{ xmlDoc }}
806
+ * </template>
807
+ * …
808
+ * </qti-test>
809
+ *
810
+ * <!-- 4. one player in the toolbar, following navigation -->
811
+ * <test-navigation>
812
+ * <header><test-item-to-speech>…</test-item-to-speech></header>
813
+ * <test-container test-url="…"></test-container>
814
+ * </test-navigation>
815
+ * ```
665
816
  *
666
- * By default the player reads the item the test is navigated to (`navItemRefId` from the
667
- * session context). When several items share one page — a keep-together section or a
668
- * vertically scrolling booklet — give each player its own `item-ref-id` so it reads that
669
- * item regardless of the navigation cursor. The item is looked up by its
670
- * `qti-assessment-item-ref` identifier, in the player's own tree first and otherwise in
671
- * any `test-container` shadow root reachable from it, so the player can live inside the
672
- * item card, next to it, or in the page chrome.
817
+ * In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the
818
+ * player on the fresh content. An item player reads the item body as rendered: a stimulus
819
+ * placed inside the item is read with it, one placed outside (mode 1) is not. Only one player
820
+ * can speak at a time; starting one stops any other.
673
821
  *
674
- * Only one item can be spoken at a time; starting one player stops any other.
822
+ * Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,
823
+ * `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)
824
+ * or inside `aria-hidden="true"`.
675
825
  *
676
826
  * ### Starting somewhere in the middle
677
827
  *
@@ -689,16 +839,12 @@ declare class TestItemToSpeech extends LitElement {
689
839
  static styles: lit.CSSResult;
690
840
  /** Fallback language when neither the item content nor the document declares one. */
691
841
  language: string;
692
- /**
693
- * Identifier of the `qti-assessment-item-ref` this player reads. Leave unset to follow the
694
- * navigation cursor (`navItemRefId`) instead.
695
- */
696
- itemRefId?: string;
697
842
  protected _sessionContext?: SessionContext;
843
+ /** The `qti-test` this player is in, across shadow roots. */
844
+ protected testHost?: TestHost;
698
845
  _ttsContext: TtsContext;
699
846
  constructor();
700
847
  willUpdate(changed: PropertyValues): void;
701
- updated(changed: PropertyValues): void;
702
848
  connectedCallback(): void;
703
849
  disconnectedCallback(): void;
704
850
  render(): lit.TemplateResult<1>;
@@ -800,7 +946,7 @@ declare const QtiTest_base: (abstract new (...args: any[]) => ITestNavigationMix
800
946
  getOutcome(identifier: string): Readonly<OutcomeVariable>;
801
947
  getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;
802
948
  outcomeProcessing(): boolean;
803
- }) & (abstract new (...args: any[]) => TestBaseInterface) & typeof LitElement;
949
+ }) & (abstract new (...args: any[]) => ITestStateMixin) & (abstract new (...args: any[]) => TestBaseInterface) & typeof LitElement;
804
950
  /**
805
951
  * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.
806
952
  *
@@ -848,9 +994,23 @@ declare const QtiTest_base: (abstract new (...args: any[]) => ITestNavigationMix
848
994
  * You can use normal class names to style the elements.
849
995
  * And you can use the `test-prev` and `test-next` elements to navigate through the test.
850
996
  *
997
+ * @event qti-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
998
+ * @event qti-test-context-updated - Deprecated: listen to `qti-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.
851
999
  */
852
1000
  declare class QtiTest extends QtiTest_base {
1001
+ constructor();
853
1002
  configContext: ConfigContext;
1003
+ /**
1004
+ * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so
1005
+ * everything inside reads one value: the test-container shuffling the item order, the test
1006
+ * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.
1007
+ *
1008
+ * Pass the same `seed` when resuming a session, or the order comes back different. Replace the
1009
+ * object, do not mutate it: an in-place change does not notify the components inside.
1010
+ *
1011
+ * `test-navigation.qtiContext` is an alias of this.
1012
+ */
1013
+ qtiContext: QtiContext;
854
1014
  /**
855
1015
  * Renders the component's template.
856
1016
  * Provides a default `<slot>` for content projection.
@@ -864,4 +1024,4 @@ declare global {
864
1024
  }
865
1025
  }
866
1026
 
867
- export { TestStamp as A, TestTtsNext as B, TestTtsPause as C, TestTtsPick as D, TestTtsPlay as E, TestTtsPrev as F, TestTtsResume as G, TestTtsStop as H, type ITestNavigationMixin as I, TestView as J, TestViewToggle as K, type TtsContext as L, ttsContext as M, QtiAssessmentItemRef as Q, type SpeechState as S, TestCheckItem as T, type ItemRefTemplateModel as a, QtiAssessmentSection as b, QtiAssessmentTest as c, QtiItemSessionControl as d, QtiNumberSelected as e, QtiOutcomeProcessing as f, QtiOutcomeProcessingProcessor as g, QtiTest as h, QtiTestFeedback as i, QtiTestPart as j, QtiTestVariables as k, QtiTestVariablesExpression as l, TestContainer as m, TestEndAttempt as n, TestItemLink as o, TestItemToSpeech as p, TestNavigation as q, TestNext as r, TestPagingButtonsStamp as s, TestPrev as t, TestPrintContext as u, TestPrintVariables as v, TestScoringButtons as w, TestScoringFeedback as x, TestSectionButtonsStamp as y, TestSectionLink as z };
1027
+ export { TestSectionLink as A, TestStamp as B, TestTtsNext as C, TestTtsPause as D, TestTtsPick as E, TestTtsPlay as F, TestTtsPrev as G, TestTtsResume as H, type ITestNavigationMixin as I, TestTtsStop as J, TestView as K, TestViewToggle as L, type TtsContext as M, ttsContext as N, type ItemVariableValue as O, QtiAssessmentItemRef as Q, type SpeechState as S, TestCheckItem as T, type ITestStateMixin as a, type ItemRefTemplateModel as b, QtiAssessmentSection as c, QtiAssessmentTest as d, QtiItemSessionControl as e, QtiNumberSelected as f, QtiOutcomeProcessing as g, QtiOutcomeProcessingProcessor as h, QtiTest as i, QtiTestFeedback as j, QtiTestPart as k, QtiTestVariables as l, QtiTestVariablesExpression as m, TestContainer as n, TestEndAttempt as o, TestItemLink as p, TestItemToSpeech as q, TestNavigation as r, TestNext as s, TestPagingButtonsStamp as t, TestPrev as u, TestPrintContext as v, TestPrintVariables as w, TestScoringButtons as x, TestScoringFeedback as y, TestSectionButtonsStamp as z };
@@ -1,9 +1,9 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, CSSResultGroup, PropertyValues } from 'lit';
3
- import { I as Interaction } from './interaction.d-DegNJ5ZA.js';
3
+ import { I as Interaction } from './interaction.d-g6XG0T0Z.js';
4
4
  import { V as ValidatableInteraction } from './interaction.interface.d-CvjHM2bi.js';
5
5
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
6
- import { B as BaseType, a as Cardinality, b as ItemContext, Q as QtiAreaMapEntry } from './item.types.d-BDFrq19E.js';
6
+ import { B as BaseType, a as Cardinality, b as ItemContext, Q as QtiAreaMapEntry } from './item.types.d-B55QkJ92.js';
7
7
  import { Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
8
8
  import * as lit_directives_ref_js from 'lit/directives/ref.js';
9
9
 
@@ -608,7 +608,9 @@ declare global {
608
608
  * element renders a single textarea bound to one variable, so there is nothing for the bounds
609
609
  * to count: reading them as a word or paragraph limit would invent a rule QTI does not state.
610
610
  * Implement alongside multi-string rendering, not before it.
611
- * @attr {number} min-strings - Not implemented. See `max-strings`.
611
+ * @attr {number} [min-strings=0] - Whether a response is required. Below 1 an empty field is valid; from 1
612
+ * it must hold a value. Only that threshold is read: the field is a single string, so the
613
+ * count itself (see `max-strings`) has nothing to bound.
612
614
  * @attr {'plain'|'preformatted'|'xhtml'} [format=plain] - How the response is presented.
613
615
  * `preformatted` renders the field monospaced; `xhtml` is accepted but downgraded to plain,
614
616
  * because the field is a textarea with no rich-text editor behind it.
@@ -635,6 +637,8 @@ declare class QtiExtendedTextInteraction extends Interaction {
635
637
  */
636
638
  format: 'plain' | 'preformatted' | 'xhtml';
637
639
  protected _handleFormatChange: () => void;
640
+ /** Below 1 an empty field is valid; from 1 it must hold a value. Defaults to 0, as in the QTI spec. */
641
+ minStrings: number;
638
642
  patternMask: string;
639
643
  /** text appearing in the extended-text-interaction if it is empty */
640
644
  placeholderText: string;
@@ -1498,7 +1502,12 @@ declare class QtiSliderInteraction extends Interaction {
1498
1502
  step: number;
1499
1503
  validate(): boolean;
1500
1504
  connectedCallback(): void;
1501
- get response(): string;
1505
+ willUpdate(changed: PropertyValues): void;
1506
+ /**
1507
+ * Shows the value without publishing it: it came from the item (a default or a restored answer) or
1508
+ * from the host, which hold it already. Only the candidate's input is published.
1509
+ */
1510
+ get response(): string | null;
1502
1511
  set response(val: string | null);
1503
1512
  /** Extension hook for optional content rendered on the slider rail. */
1504
1513
  protected renderRailSupplement(): unknown;
@@ -1,4 +1,4 @@
1
- import { V as VariableDeclaration } from './item.types.d-BDFrq19E.js';
1
+ import { V as VariableDeclaration } from './item.types.d-B55QkJ92.js';
2
2
 
3
3
  type ComputedItemContext = {
4
4
  identifier: string;
@@ -21,7 +21,9 @@ interface SessionContext {
21
21
  navPartId?: string | null;
22
22
  navSectionId?: string | null;
23
23
  navItemRefId?: string | null;
24
+ /** @deprecated Never set by the library. Removed in the next major. */
24
25
  navItemLoading?: boolean;
26
+ /** @deprecated Never set by the library. Removed in the next major. */
25
27
  navTestLoading?: boolean;
26
28
  view?: View;
27
29
  }
package/dist/test.d.ts CHANGED
@@ -1,26 +1,27 @@
1
- import { I as ITestNavigationMixin } from './qti-test.d-D-ELy0Mr.js';
2
- export { a as ItemRefTemplateModel, Q as QtiAssessmentItemRef, b as QtiAssessmentSection, c as QtiAssessmentTest, d as QtiItemSessionControl, e as QtiNumberSelected, f as QtiOutcomeProcessing, g as QtiOutcomeProcessingProcessor, h as QtiTest, i as QtiTestFeedback, j as QtiTestPart, k as QtiTestVariables, l as QtiTestVariablesExpression, S as SpeechState, T as TestCheckItem, m as TestContainer, n as TestEndAttempt, o as TestItemLink, p as TestItemToSpeech, q as TestNavigation, r as TestNext, s as TestPagingButtonsStamp, t as TestPrev, u as TestPrintContext, v as TestPrintVariables, w as TestScoringButtons, x as TestScoringFeedback, y as TestSectionButtonsStamp, z as TestSectionLink, A as TestStamp, B as TestTtsNext, C as TestTtsPause, D as TestTtsPick, E as TestTtsPlay, F as TestTtsPrev, G as TestTtsResume, H as TestTtsStop, J as TestView, K as TestViewToggle, L as TtsContext, M as ttsContext } from './qti-test.d-D-ELy0Mr.js';
1
+ import { O as ItemVariableValue, I as ITestNavigationMixin, a as ITestStateMixin } from './qti-test.d-_THYXPzd.js';
2
+ export { b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiItemSessionControl, f as QtiNumberSelected, g as QtiOutcomeProcessing, h as QtiOutcomeProcessingProcessor, i as QtiTest, j as QtiTestFeedback, k as QtiTestPart, l as QtiTestVariables, m as QtiTestVariablesExpression, S as SpeechState, T as TestCheckItem, n as TestContainer, o as TestEndAttempt, p as TestItemLink, q as TestItemToSpeech, r as TestNavigation, s as TestNext, t as TestPagingButtonsStamp, u as TestPrev, v as TestPrintContext, w as TestPrintVariables, x as TestScoringButtons, y as TestScoringFeedback, z as TestSectionButtonsStamp, A as TestSectionLink, B as TestStamp, C as TestTtsNext, D as TestTtsPause, E as TestTtsPick, F as TestTtsPlay, G as TestTtsPrev, H as TestTtsResume, J as TestTtsStop, K as TestView, L as TestViewToggle, M as TtsContext, N as ttsContext } from './qti-test.d-_THYXPzd.js';
3
3
  import { LitElement } from 'lit';
4
- import { h as VariableValue, c as OutcomeVariable, V as VariableDeclaration } from './item.types.d-BDFrq19E.js';
5
- import { S as SessionContext } from './session.context.d-Cjs0BkJB.js';
4
+ import { b as ItemContext, c as OutcomeVariable, V as VariableDeclaration } from './item.types.d-B55QkJ92.js';
5
+ import { S as SessionContext } from './session.context.d-D5080LVx.js';
6
6
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
7
- import { T as TestContext } from './qti-expression.d-BksT9iLB.js';
7
+ import { T as TestContext } from './qti-expression.d-CuaLjZ6g.js';
8
8
  import './qti-transform-test.d-BL7GGFJj.js';
9
- import './computed.types.d-DB5gfOh9.js';
9
+ import './computed.types.d-gJrBeUMG.js';
10
10
  import './elements.js';
11
11
  import './interaction.interface.d-CvjHM2bi.js';
12
- import './qti-feedback.d-D-w6-mJv.js';
12
+ import './qti-feedback.d-wMYNVkkj.js';
13
13
  import './qti-rule-base.d-Bdzg8eGH.js';
14
- import '@heximal/templates';
15
14
  import './qti.context.d-CejJMlfZ.js';
15
+ import '@heximal/templates';
16
16
 
17
- interface IQtiTest extends LitElement, ITestNavigationMixin, ITestProcessingMixin, IMyQtiTest {
17
+ interface IQtiTest extends LitElement, ITestNavigationMixin, ITestProcessingMixin, ITestStateMixin, IMyQtiTest {
18
18
  }
19
19
  interface IMyQtiTest {
20
20
  testContext: Readonly<TestContext>;
21
21
  sessionContext: Readonly<SessionContext>;
22
22
  configContext: ConfigContext;
23
- updateItemVariables(itemRefID: string, variables: VariableValue<string | string[] | null>[]): void;
23
+ /** Sets values on one item, keyed by its `qti-assessment-item-ref` identifier. */
24
+ updateItemVariables(itemRefID: string, variables: readonly ItemVariableValue[], state?: ItemContext['state']): void;
24
25
  }
25
26
  interface ITestProcessingMixin {
26
27
  updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;
@@ -29,4 +30,50 @@ interface ITestProcessingMixin {
29
30
  outcomeProcessing(): boolean;
30
31
  }
31
32
 
32
- export { type IMyQtiTest, type IQtiTest, ITestNavigationMixin, type ITestProcessingMixin };
33
+ /**
34
+ * Everything a host needs to persist to resume a candidate's test session, and nothing else.
35
+ *
36
+ * Read it from `qtiTest.state` or the `qti-state-changed` event, store it wherever you like —
37
+ * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.
38
+ *
39
+ * Deliberately not here:
40
+ * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes
41
+ * from the item XML on every load, and persisting the answer key with the candidate's data is
42
+ * both bloat and a leak;
43
+ * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.
44
+ * The shuffle `seed` in particular must be passed in again, or the restored order changes;
45
+ * - `view`: a role the host decides, not something the candidate produced;
46
+ * - anything computed — scores per section, `done`, `active` — which is rederived from this.
47
+ */
48
+ interface QtiTestState {
49
+ /** Bumped on any incompatible change to this shape. A state with another version is ignored. */
50
+ version: 1;
51
+ test: {
52
+ items: QtiTestStateItem[];
53
+ /** Test-level outcome values. Only outcomes the test declares are restored. */
54
+ outcomes: QtiTestStateValue[];
55
+ };
56
+ session: QtiTestStateSession;
57
+ }
58
+ interface QtiTestStateItem {
59
+ /** The `qti-assessment-item-ref` identifier. */
60
+ identifier: string;
61
+ variables: (QtiTestStateValue & {
62
+ type?: 'response' | 'outcome' | 'template' | 'context';
63
+ })[];
64
+ /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */
65
+ state?: Record<string, string | null>;
66
+ }
67
+ interface QtiTestStateValue {
68
+ identifier: string;
69
+ value: string | string[] | null;
70
+ }
71
+ /** Where the candidate is. */
72
+ interface QtiTestStateSession {
73
+ navPartId?: string | null;
74
+ navSectionId?: string | null;
75
+ navItemRefId?: string | null;
76
+ }
77
+ declare const QTI_TEST_STATE_VERSION = 1;
78
+
79
+ export { type IMyQtiTest, type IQtiTest, ITestNavigationMixin, type ITestProcessingMixin, ITestStateMixin, QTI_TEST_STATE_VERSION, type QtiTestState, type QtiTestStateItem, type QtiTestStateSession, type QtiTestStateValue };
package/dist/test.js CHANGED
@@ -1,5 +1,6 @@
1
- import "./chunk-7VDR765S.js";
1
+ import "./chunk-QD3Y6UK3.js";
2
2
  import {
3
+ QTI_TEST_STATE_VERSION,
3
4
  QtiAssessmentItemRef,
4
5
  QtiAssessmentSection,
5
6
  QtiAssessmentTest,
@@ -38,13 +39,14 @@ import {
38
39
  TestView,
39
40
  TestViewToggle,
40
41
  ttsContext
41
- } from "./chunk-TDWLV5OD.js";
42
- import "./chunk-REKCRWJV.js";
43
- import "./chunk-A32YH4H5.js";
42
+ } from "./chunk-EUKU5QKV.js";
43
+ import "./chunk-AWTQKBC4.js";
44
+ import "./chunk-ZP6QQYSU.js";
44
45
  import "./chunk-4DB4SC5K.js";
45
46
  import "./chunk-TLAVOBEM.js";
46
- import "./chunk-YVZWNLF4.js";
47
+ import "./chunk-R7MMMDP7.js";
47
48
  export {
49
+ QTI_TEST_STATE_VERSION,
48
50
  QtiAssessmentItemRef,
49
51
  QtiAssessmentSection,
50
52
  QtiAssessmentTest,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@citolab/qti-components",
3
3
  "description": "QTI component utilities",
4
- "version": "9.3.0",
4
+ "version": "10.0.0-next.0",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
@@ -10,15 +10,15 @@
10
10
  "lit-html": "^3.3.1"
11
11
  },
12
12
  "devDependencies": {
13
- "@qti-components/base": "^2.3.0",
14
- "@qti-components/corrections": "^0.4.0",
15
- "@qti-components/elements": "^1.8.0",
16
- "@qti-components/interactions": "^1.10.4",
17
- "@qti-components/item": "^1.5.0",
18
- "@qti-components/loader": "^1.3.3",
13
+ "@qti-components/base": "^2.4.0",
14
+ "@qti-components/corrections": "^0.4.1-next.0",
15
+ "@qti-components/elements": "^1.10.0-next.0",
16
+ "@qti-components/interactions": "^1.10.5-next.0",
17
+ "@qti-components/item": "^1.5.1-next.0",
18
+ "@qti-components/loader": "^1.3.4-next.0",
19
19
  "@qti-components/processing": "^1.6.0",
20
- "@qti-components/test": "^1.8.0",
21
- "@qti-components/theme": "^2.2.1",
20
+ "@qti-components/test": "^1.10.0-next.0",
21
+ "@qti-components/theme": "^2.2.2-next.0",
22
22
  "@qti-components/transformers": "^1.7.3"
23
23
  },
24
24
  "exports": {