@citolab/qti-components 9.3.0 → 9.5.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 (63) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +280 -220
  3. package/dist/base.d.ts +10 -10
  4. package/dist/base.js +1 -1
  5. package/dist/{chunk-G5RQ5GKG.js → chunk-6K3QWJHH.js} +2 -2
  6. package/dist/{chunk-REKCRWJV.js → chunk-6U3YPHXU.js} +231 -129
  7. package/dist/chunk-6U3YPHXU.js.map +1 -0
  8. package/dist/{chunk-JGPWBIVD.js → chunk-DAFB2E5H.js} +123 -47
  9. package/dist/{chunk-JGPWBIVD.js.map → chunk-DAFB2E5H.js.map} +1 -1
  10. package/dist/{chunk-YIYHCHHM.js → chunk-FD4AB6TM.js} +2 -2
  11. package/dist/{chunk-JLZCZVRX.js → chunk-GBZNFSFY.js} +2 -2
  12. package/dist/{chunk-ZG7FBQFP.js → chunk-MI7774NV.js} +2 -2
  13. package/dist/{chunk-7VDR765S.js → chunk-OQDBARD5.js} +2 -2
  14. package/dist/{chunk-RAJQKCQ3.js → chunk-RU6332MD.js} +3 -3
  15. package/dist/{chunk-TDWLV5OD.js → chunk-SIE3E4FG.js} +1159 -551
  16. package/dist/chunk-SIE3E4FG.js.map +1 -0
  17. package/dist/{chunk-CQHGVPOT.js → chunk-SU63QGGD.js} +6 -6
  18. package/dist/{chunk-YVZWNLF4.js → chunk-TDWJ6WZA.js} +158 -19
  19. package/dist/chunk-TDWJ6WZA.js.map +1 -0
  20. package/dist/{chunk-FG5JAWSN.js → chunk-YZRODVYZ.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 +34 -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 +536 -409
  41. package/dist/{qti-condition-expression.d-DLboq8bR.d.ts → qti-condition-expression.d-VJH6cWxf.d.ts} +1 -1
  42. package/dist/{qti-expression.d-BksT9iLB.d.ts → qti-expression.d-BPxEp8HU.d.ts} +8 -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-86TlaMlI.d.ts} +298 -39
  46. package/dist/{qti-text-entry-interaction.d-CATtcPyX.d.ts → qti-text-entry-interaction.d-C4eixT-D.d.ts} +8 -3
  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 +13 -5
  50. package/package.json +5 -5
  51. package/dist/chunk-A32YH4H5.js +0 -7
  52. package/dist/chunk-A32YH4H5.js.map +0 -1
  53. package/dist/chunk-REKCRWJV.js.map +0 -1
  54. package/dist/chunk-TDWLV5OD.js.map +0 -1
  55. package/dist/chunk-YVZWNLF4.js.map +0 -1
  56. /package/dist/{chunk-G5RQ5GKG.js.map → chunk-6K3QWJHH.js.map} +0 -0
  57. /package/dist/{chunk-YIYHCHHM.js.map → chunk-FD4AB6TM.js.map} +0 -0
  58. /package/dist/{chunk-JLZCZVRX.js.map → chunk-GBZNFSFY.js.map} +0 -0
  59. /package/dist/{chunk-ZG7FBQFP.js.map → chunk-MI7774NV.js.map} +0 -0
  60. /package/dist/{chunk-7VDR765S.js.map → chunk-OQDBARD5.js.map} +0 -0
  61. /package/dist/{chunk-RAJQKCQ3.js.map → chunk-RU6332MD.js.map} +0 -0
  62. /package/dist/{chunk-CQHGVPOT.js.map → chunk-SU63QGGD.js.map} +0 -0
  63. /package/dist/{chunk-FG5JAWSN.js.map → chunk-YZRODVYZ.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-BPxEp8HU.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 {
@@ -58,6 +58,13 @@ declare abstract class QtiExpression<T> extends LitElement implements QtiExpress
58
58
  * throwing, so callers degrade gracefully.
59
59
  */
60
60
  protected resolveVariable(identifier: string): VariableDeclaration<string | string[] | null> | null;
61
+ /**
62
+ * `ITEMREF.VAR`: a variable of an individual item session, looked up by prefixing the variable
63
+ * with the identifier the item ref gave the item (QTI 3 `qti-variable`), e.g. `Q01.SCORE`. An
64
+ * item that was never presented has no variables, which resolves to NULL. Instances of a cloned
65
+ * item (`Q01.2.SCORE`) are not supported: the item itself is used.
66
+ */
67
+ private resolveItemVariable;
61
68
  getVariables: () => ExpressionVariable[];
62
69
  }
63
70
 
@@ -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-BPxEp8HU.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,18 +128,38 @@ 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>;
131
+ /** An element that evaluates to a boolean: a `qti-pre-condition` or `qti-branch-rule`. */
132
+ interface Condition extends Element {
133
+ evaluate(): boolean;
134
+ }
135
+
136
+ /**
137
+ * @summary The qti-branch-rule element jumps the test forward to `target` when its expression is true.
138
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.branch-rule
139
+ *
140
+ * A child of `qti-test-part`, `qti-assessment-section` or `qti-assessment-item-ref`. It is
141
+ * evaluated after the parent has been presented; the first rule whose expression is true wins.
142
+ * Branch rules only apply in linear navigation mode. An expression that cannot be evaluated does
143
+ * not branch.
144
+ *
145
+ * @attr {string} target - Required. The identifier of an item ref, section or test part ahead of
146
+ * the parent, or one of the reserved targets `EXIT_SECTION`, `EXIT_TESTPART`, `EXIT_TEST`.
147
+ *
148
+ * @slot - The boolean expression.
149
+ */
150
+ declare class QtiBranchRule extends LitElement implements Condition {
151
+ static readonly EXIT_SECTION = "EXIT_SECTION";
152
+ static readonly EXIT_TESTPART = "EXIT_TESTPART";
153
+ static readonly EXIT_TEST = "EXIT_TEST";
154
+ static styles: lit.CSSResult;
155
+ target: string;
156
+ /** `true` when the test should jump to `target`. */
157
+ evaluate(): boolean;
96
158
  render(): lit.TemplateResult<1>;
97
159
  }
98
160
  declare global {
99
161
  interface HTMLElementTagNameMap {
100
- 'qti-assessment-test': QtiAssessmentTest;
162
+ 'qti-branch-rule': QtiBranchRule;
101
163
  }
102
164
  }
103
165
 
@@ -122,6 +184,33 @@ declare global {
122
184
  }
123
185
  }
124
186
 
187
+ /**
188
+ * @summary The qti-number-presented expression counts the selected items that have been presented to the candidate.
189
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-presented
190
+ *
191
+ * Outcome processing only. `section-identifier`, `include-category` and
192
+ * `exclude-category` narrow which item references are counted, the same way as
193
+ * for `qti-number-selected` and `qti-test-variables`.
194
+ *
195
+ * An item is presented once its `completionStatus` has left `not_attempted`:
196
+ * presenting an item starts its first attempt. An item a linear test part
197
+ * passed over (pre-condition, branch rule) or one the candidate has not reached
198
+ * keeps `not_attempted`. That makes this the count to use for a total over the
199
+ * candidate's own route, such as a maximum score of one point per presented item.
200
+ */
201
+ declare class QtiNumberPresented extends QtiExpression<number> {
202
+ #private;
203
+ _testContext?: TestContext;
204
+ constructor();
205
+ getResult(): number;
206
+ calculate(): number;
207
+ }
208
+ declare global {
209
+ interface HTMLElementTagNameMap {
210
+ 'qti-number-presented': QtiNumberPresented;
211
+ }
212
+ }
213
+
125
214
  /**
126
215
  * @summary The qti-number-selected expression counts the item refs selected for the test.
127
216
  * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-selected
@@ -146,6 +235,31 @@ declare global {
146
235
  }
147
236
  }
148
237
 
238
+ /**
239
+ * @summary The qti-pre-condition element holds one boolean expression that decides whether its parent is presented.
240
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.pre-condition
241
+ *
242
+ * A child of `qti-test-part`, `qti-assessment-section` or `qti-assessment-item-ref`. When the test
243
+ * is about to present the parent and the expression is false (or NULL), the parent is skipped.
244
+ * Pre-conditions only apply in linear navigation mode; in nonlinear mode they are ignored.
245
+ *
246
+ * Evaluation is pull-based, like every expression: the test calls `evaluate()` when it needs the
247
+ * answer. An expression that cannot be evaluated fails open, so the parent is shown.
248
+ *
249
+ * @slot - The boolean expression.
250
+ */
251
+ declare class QtiPreCondition extends LitElement implements Condition {
252
+ static styles: lit.CSSResult;
253
+ /** `true` when the parent may be presented. */
254
+ evaluate(): boolean;
255
+ render(): lit.TemplateResult<1>;
256
+ }
257
+ declare global {
258
+ interface HTMLElementTagNameMap {
259
+ 'qti-pre-condition': QtiPreCondition;
260
+ }
261
+ }
262
+
149
263
  declare class QtiOutcomeProcessing extends LitElement {
150
264
  static styles: lit.CSSResult[];
151
265
  render(): lit.TemplateResult<1>;
@@ -160,8 +274,19 @@ declare class QtiOutcomeProcessingProcessor {
160
274
  process(rules: QtiRuleBase[]): void;
161
275
  }
162
276
 
277
+ /**
278
+ * Test-level feedback. It renders nothing where it is declared: where and when it appears is up to
279
+ * the host. After outcome processing, `qtiTest.getTestFeedback(access)` returns the ones that apply.
280
+ */
163
281
  declare class QtiTestFeedback extends QtiModalFeedback {
164
282
  static styles: lit.CSSResult;
283
+ /** When the feedback may be shown: at the end of the test (`atEnd`), or while it runs (`during`). */
284
+ access: 'atEnd' | 'during';
285
+ /**
286
+ * Whether this feedback applies for a value of its `outcome-identifier`: with `show-hide="show"`
287
+ * when the value is (or, for a container, holds) its `identifier`; with `hide` when it is not.
288
+ */
289
+ matches(value: string | readonly string[] | null | undefined): boolean;
165
290
  render(): lit.TemplateResult<1>;
166
291
  }
167
292
  declare global {
@@ -214,12 +339,16 @@ interface TestBaseInterface extends LitElement {
214
339
  testContext: Readonly<TestContext>;
215
340
  sessionContext: Readonly<SessionContext>;
216
341
  configContext?: Readonly<ConfigContext>;
342
+ /** Provided by `qti-test`. */
343
+ qtiContext?: Readonly<QtiContext>;
217
344
  _testElement: QtiAssessmentTest;
218
- updateItemVariables(itemRefID: string, variables: VariableValue<string | string[] | null>[]): void;
345
+ updateItemVariables(itemRefID: string, variables: readonly ItemVariableValue[], state?: ItemContext['state']): void;
219
346
  }
347
+ /** A value to set on an item; `type` is only needed for a variable the item does not declare. */
348
+ type ItemVariableValue = Pick<VariableValue<string | string[] | null>, 'identifier' | 'value'> & Partial<Pick<VariableValue<string | string[] | null>, 'type'>>;
220
349
 
221
350
  type PostLoadTransformCallback = (transformer: transformItemApi, itemRef: QtiAssessmentItemRef) => transformItemApi | Promise<transformItemApi>;
222
- type PostLoadTestTransformCallback = (transformer: transformTestApi, testElement: QtiAssessmentTest) => transformTestApi | Promise<transformTestApi>;
351
+
223
352
  /**
224
353
  * Exactly what this mixin adds. `IQtiTest` composes it (see ../types/iqti-test, which
225
354
  * re-exports it), and `TestNavigationClass` below `implements` it, so the interface and the
@@ -250,13 +379,72 @@ interface ITestNavigationMixin {
250
379
  };
251
380
  }
252
381
 
253
- type CustomEventMap = {
254
- 'test-end-attempt': CustomEvent;
255
- };
382
+ /**
383
+ * Everything a host needs to persist to resume a candidate's test session, and nothing else.
384
+ *
385
+ * Read it from `qtiTest.state` or the `qti-state-changed` event, store it wherever you like —
386
+ * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.
387
+ *
388
+ * Deliberately not here:
389
+ * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes
390
+ * from the item XML on every load, and persisting the answer key with the candidate's data is
391
+ * both bloat and a leak;
392
+ * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.
393
+ * The shuffle `seed` in particular must be passed in again, or the restored order changes;
394
+ * - `view`: a role the host decides, not something the candidate produced;
395
+ * - anything computed — scores per section, `done`, `active` — which is rederived from this.
396
+ */
397
+ interface QtiTestState {
398
+ /** Bumped on any incompatible change to this shape. A state with another version is ignored. */
399
+ version: 1;
400
+ test: {
401
+ items: QtiTestStateItem[];
402
+ /** Test-level outcome values. Only outcomes the test declares are restored. */
403
+ outcomes: QtiTestStateValue[];
404
+ };
405
+ session: QtiTestStateSession;
406
+ }
407
+ interface QtiTestStateItem {
408
+ /** The `qti-assessment-item-ref` identifier. */
409
+ identifier: string;
410
+ variables: (QtiTestStateValue & {
411
+ type?: 'response' | 'outcome' | 'template' | 'context';
412
+ })[];
413
+ /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */
414
+ state?: Record<string, string | null>;
415
+ }
416
+ interface QtiTestStateValue {
417
+ identifier: string;
418
+ value: string | string[] | null;
419
+ }
420
+ /** Where the candidate is. */
421
+ interface QtiTestStateSession {
422
+ navPartId?: string | null;
423
+ navSectionId?: string | null;
424
+ navItemRefId?: string | null;
425
+ }
426
+
256
427
  declare global {
257
- interface GlobalEventHandlersEventMap extends CustomEventMap {
428
+ interface GlobalEventHandlersEventMap {
429
+ 'qti-state-changed': CustomEvent<QtiTestState>;
258
430
  }
259
431
  }
432
+ interface ITestStateMixin {
433
+ /**
434
+ * The candidate's persistable state: what they answered and where they are.
435
+ *
436
+ * Assign a stored state to resume. It may be assigned at any time: before the test document
437
+ * has loaded it is held and applied as soon as the test connects — before the first item
438
+ * loads, so items and the initial navigation start from it — and after that it is applied
439
+ * immediately and the test navigates to the restored position.
440
+ *
441
+ * Items are matched by item-ref identifier; items the state does not mention start fresh, and
442
+ * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a
443
+ * resume, so linear-mode navigation restrictions do not apply.
444
+ */
445
+ state: QtiTestState;
446
+ }
447
+
260
448
  declare class TestNavigation extends LitElement {
261
449
  #private;
262
450
  identifier: string | undefined;
@@ -264,7 +452,15 @@ declare class TestNavigation extends LitElement {
264
452
  identifier: string;
265
453
  [key: string]: any;
266
454
  }[];
267
- qtiContext: QtiContext;
455
+ /**
456
+ * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
457
+ * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
458
+ * shuffle seed here keeps working. Removed in the next major.
459
+ *
460
+ * Written before the navigation is inside a test, it waits and is handed over on connect.
461
+ */
462
+ get qtiContext(): QtiContext;
463
+ set qtiContext(value: QtiContext);
268
464
  configContext: ConfigContext;
269
465
  protected _testContext?: TestContext;
270
466
  protected _sessionContext?: SessionContext;
@@ -443,6 +639,8 @@ declare class TestContainer extends LitElement {
443
639
  testDoc: DocumentFragment | null;
444
640
  /** The raw XML string */
445
641
  testXML: string | null;
642
+ /** The `qti-test` this container is in: where the host's `postLoadTestTransformCallback` lives. */
643
+ protected testHost?: TestHost;
446
644
  protected qtiContext: QtiContext;
447
645
  protected createRenderRoot(): HTMLElement | DocumentFragment;
448
646
  /** Callback function to transform the test after loading */
@@ -543,7 +741,7 @@ declare class TestScoringButtons extends LitElement {
543
741
  protected createRenderRoot(): HTMLElement | DocumentFragment;
544
742
  connectedCallback(): void;
545
743
  protected computedContext?: ComputedContext;
546
- render(): typeof nothing | lit.TemplateResult<1>;
744
+ render(): lit.TemplateResult<1> | typeof nothing;
547
745
  constructor();
548
746
  }
549
747
  declare global {
@@ -579,6 +777,7 @@ declare global {
579
777
  }
580
778
 
581
779
  declare class TestCheckItem extends LitElement {
780
+ protected testHost?: TestHost;
582
781
  static styles: lit.CSSResult;
583
782
  constructor();
584
783
  render(): lit.TemplateResult<1>;
@@ -661,17 +860,66 @@ declare abstract class TtsButtonBase extends LitElement {
661
860
  * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with
662
861
  * `xml:lang="en-GB"` on a `<p>` or on the item root is honoured without further work.
663
862
  *
664
- * ### Which item is read
863
+ * ### What is read
864
+ *
865
+ * Decided once per connect, by where the player is placed. The first rule that matches wins:
866
+ *
867
+ * 1. **Next to a stimulus placeholder** — the player shares its parent with a
868
+ * `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the
869
+ * player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the
870
+ * placeholder: loading a stimulus replaces the placeholder's content. Items and navigation
871
+ * are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts
872
+ * over on the new content.
873
+ * 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked
874
+ * `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes
875
+ * on one container; the player reads the readable elements inside it. Navigation is ignored.
876
+ * The reading list is rebuilt when the player starts from the top, and when an element in it
877
+ * has left the page — so a re-render of the content never interrupts speech.
878
+ * 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,
879
+ * so every item gets a player of its own: the player reads that item, and only that item.
880
+ * The navigation cursor is ignored; speech stops when the player leaves the page with its item.
881
+ * 4. **Anywhere else** — a toolbar in the page chrome: the player follows the navigation cursor
882
+ * and reads the item `navItemRefId` (session context) points at, found in any
883
+ * `test-container` reachable from the player. Navigating stops speech and starts the next
884
+ * item from the top.
885
+ *
886
+ * ```html
887
+ * <!-- 1. a player for the shared reading text -->
888
+ * <aside>
889
+ * <test-item-to-speech>…</test-item-to-speech>
890
+ * <div data-stimulus-idref="Stimulus1"></div>
891
+ * </aside>
892
+ *
893
+ * <!-- 2. a player for any other HTML -->
894
+ * <div>
895
+ * <test-item-to-speech>…</test-item-to-speech>
896
+ * <section data-tts-content lang="nl-NL">…</section>
897
+ * </div>
898
+ *
899
+ * <!-- 3. one player per item -->
900
+ * <qti-test>
901
+ * <template item-ref>
902
+ * <test-item-to-speech>…</test-item-to-speech>
903
+ * {{ xmlDoc }}
904
+ * </template>
905
+ * …
906
+ * </qti-test>
907
+ *
908
+ * <!-- 4. one player in the toolbar, following navigation -->
909
+ * <test-navigation>
910
+ * <header><test-item-to-speech>…</test-item-to-speech></header>
911
+ * <test-container test-url="…"></test-container>
912
+ * </test-navigation>
913
+ * ```
665
914
  *
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.
915
+ * In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the
916
+ * player on the fresh content. An item player reads the item body as rendered: a stimulus
917
+ * placed inside the item is read with it, one placed outside (mode 1) is not. Only one player
918
+ * can speak at a time; starting one stops any other.
673
919
  *
674
- * Only one item can be spoken at a time; starting one player stops any other.
920
+ * Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,
921
+ * `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)
922
+ * or inside `aria-hidden="true"`.
675
923
  *
676
924
  * ### Starting somewhere in the middle
677
925
  *
@@ -689,16 +937,12 @@ declare class TestItemToSpeech extends LitElement {
689
937
  static styles: lit.CSSResult;
690
938
  /** Fallback language when neither the item content nor the document declares one. */
691
939
  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
940
  protected _sessionContext?: SessionContext;
941
+ /** The `qti-test` this player is in, across shadow roots. */
942
+ protected testHost?: TestHost;
698
943
  _ttsContext: TtsContext;
699
944
  constructor();
700
945
  willUpdate(changed: PropertyValues): void;
701
- updated(changed: PropertyValues): void;
702
946
  connectedCallback(): void;
703
947
  disconnectedCallback(): void;
704
948
  render(): lit.TemplateResult<1>;
@@ -800,7 +1044,8 @@ declare const QtiTest_base: (abstract new (...args: any[]) => ITestNavigationMix
800
1044
  getOutcome(identifier: string): Readonly<OutcomeVariable>;
801
1045
  getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;
802
1046
  outcomeProcessing(): boolean;
803
- }) & (abstract new (...args: any[]) => TestBaseInterface) & typeof LitElement;
1047
+ getTestFeedback(access?: "atEnd" | "during"): QtiTestFeedback[];
1048
+ }) & (abstract new (...args: any[]) => ITestStateMixin) & (abstract new (...args: any[]) => TestBaseInterface) & typeof LitElement;
804
1049
  /**
805
1050
  * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.
806
1051
  *
@@ -848,9 +1093,23 @@ declare const QtiTest_base: (abstract new (...args: any[]) => ITestNavigationMix
848
1093
  * You can use normal class names to style the elements.
849
1094
  * And you can use the `test-prev` and `test-next` elements to navigate through the test.
850
1095
  *
1096
+ * @event qti-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.
1097
+ * @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
1098
  */
852
1099
  declare class QtiTest extends QtiTest_base {
1100
+ constructor();
853
1101
  configContext: ConfigContext;
1102
+ /**
1103
+ * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so
1104
+ * everything inside reads one value: the test-container shuffling the item order, the test
1105
+ * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.
1106
+ *
1107
+ * Pass the same `seed` when resuming a session, or the order comes back different. Replace the
1108
+ * object, do not mutate it: an in-place change does not notify the components inside.
1109
+ *
1110
+ * `test-navigation.qtiContext` is an alias of this.
1111
+ */
1112
+ qtiContext: QtiContext;
854
1113
  /**
855
1114
  * Renders the component's template.
856
1115
  * Provides a default `<slot>` for content projection.
@@ -864,4 +1123,4 @@ declare global {
864
1123
  }
865
1124
  }
866
1125
 
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 };
1126
+ export { TestScoringButtons as A, TestScoringFeedback as B, TestSectionButtonsStamp as C, TestSectionLink as D, TestStamp as E, TestTtsNext as F, TestTtsPause as G, TestTtsPick as H, type ITestNavigationMixin as I, TestTtsPlay as J, TestTtsPrev as K, TestTtsResume as L, TestTtsStop as M, TestView as N, TestViewToggle as O, type TtsContext as P, QtiAssessmentItemRef as Q, ttsContext as R, type SpeechState as S, TestCheckItem as T, type ItemVariableValue as U, type ITestStateMixin as a, type ItemRefTemplateModel as b, QtiAssessmentSection as c, QtiAssessmentTest as d, QtiBranchRule as e, QtiItemSessionControl as f, QtiNumberPresented as g, QtiNumberSelected as h, QtiOutcomeProcessing as i, QtiOutcomeProcessingProcessor as j, QtiPreCondition as k, QtiTest as l, QtiTestFeedback as m, QtiTestPart as n, QtiTestVariables as o, QtiTestVariablesExpression as p, TestContainer as q, TestEndAttempt as r, TestItemLink as s, TestItemToSpeech as t, TestNavigation as u, TestNext as v, TestPagingButtonsStamp as w, TestPrev as x, TestPrintContext as y, TestPrintVariables 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
 
@@ -1498,7 +1498,12 @@ declare class QtiSliderInteraction extends Interaction {
1498
1498
  step: number;
1499
1499
  validate(): boolean;
1500
1500
  connectedCallback(): void;
1501
- get response(): string;
1501
+ willUpdate(changed: PropertyValues): void;
1502
+ /**
1503
+ * Shows the value without publishing it: it came from the item (a default or a restored answer) or
1504
+ * from the host, which hold it already. Only the candidate's input is published.
1505
+ */
1506
+ get response(): string | null;
1502
1507
  set response(val: string | null);
1503
1508
  /** Extension hook for optional content rendered on the slider rail. */
1504
1509
  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
  }