@citolab/qti-components 9.1.0 → 9.3.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 (75) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +338 -213
  3. package/dist/base.d.ts +54 -11
  4. package/dist/base.js +11 -1
  5. package/dist/{chunk-XYQNTF5B.js → chunk-7VDR765S.js} +2 -2
  6. package/dist/{chunk-XE7BALDO.js → chunk-A32YH4H5.js} +2 -2
  7. package/dist/{chunk-XE7BALDO.js.map → chunk-A32YH4H5.js.map} +1 -1
  8. package/dist/{chunk-5SU3MP6Y.js → chunk-CQHGVPOT.js} +20 -6
  9. package/dist/{chunk-5SU3MP6Y.js.map → chunk-CQHGVPOT.js.map} +1 -1
  10. package/dist/{chunk-MKZ374OJ.js → chunk-FG5JAWSN.js} +2 -2
  11. package/dist/{chunk-3VQSUWCK.js → chunk-G5RQ5GKG.js} +407 -131
  12. package/dist/chunk-G5RQ5GKG.js.map +1 -0
  13. package/dist/{chunk-5BXJRO5O.js → chunk-JGPWBIVD.js} +389 -229
  14. package/dist/chunk-JGPWBIVD.js.map +1 -0
  15. package/dist/{chunk-RT6WZ3P7.js → chunk-JLZCZVRX.js} +2 -2
  16. package/dist/{chunk-6ITD55QE.js → chunk-LFVPS7KB.js} +2 -2
  17. package/dist/{chunk-DAUU2NJL.js → chunk-RAJQKCQ3.js} +66 -9
  18. package/dist/chunk-RAJQKCQ3.js.map +1 -0
  19. package/dist/{chunk-WKWCOV5P.js → chunk-REKCRWJV.js} +83 -21
  20. package/dist/chunk-REKCRWJV.js.map +1 -0
  21. package/dist/{chunk-QCPN7E6K.js → chunk-TDWLV5OD.js} +3767 -3271
  22. package/dist/chunk-TDWLV5OD.js.map +1 -0
  23. package/dist/{chunk-HDEG6BAZ.js → chunk-TLAVOBEM.js} +16 -8
  24. package/dist/chunk-TLAVOBEM.js.map +1 -0
  25. package/dist/{chunk-LDY4C2OT.js → chunk-YIYHCHHM.js} +2 -2
  26. package/dist/{chunk-WCWJPIUQ.js → chunk-YVZWNLF4.js} +191 -52
  27. package/dist/chunk-YVZWNLF4.js.map +1 -0
  28. package/dist/{chunk-KCK27QBP.js → chunk-ZG7FBQFP.js} +2 -2
  29. package/dist/{computed.types.d-CJarqC6s.d.ts → computed.types.d-DB5gfOh9.d.ts} +2 -16
  30. package/dist/corrections.d.ts +21 -10
  31. package/dist/corrections.js +20 -20
  32. package/dist/corrections.js.map +1 -1
  33. package/dist/elements.d.ts +43 -11
  34. package/dist/elements.js +4 -4
  35. package/dist/index.d.ts +14 -13
  36. package/dist/index.js +39 -15
  37. package/dist/{interaction.d-CJiMv8H7.d.ts → interaction.d-DegNJ5ZA.d.ts} +1 -1
  38. package/dist/interactions.d.ts +35 -35
  39. package/dist/interactions.js +3 -3
  40. package/dist/item.css +11 -2
  41. package/dist/item.d.ts +31 -82
  42. package/dist/item.js +7 -5
  43. package/dist/{item.types.d-QU7LljEK.d.ts → item.types.d-BDFrq19E.d.ts} +18 -2
  44. package/dist/loader.d.ts +3 -3
  45. package/dist/loader.js +2 -2
  46. package/dist/processing.d.ts +139 -20
  47. package/dist/processing.js +11 -3
  48. package/dist/qti-components-jsx.d.ts +2254 -132
  49. package/dist/{qti-condition-expression.d-CYwXOUb1.d.ts → qti-condition-expression.d-DLboq8bR.d.ts} +1 -1
  50. package/dist/{qti-expression.d-B_-m9emA.d.ts → qti-expression.d-BksT9iLB.d.ts} +26 -3
  51. package/dist/{qti-feedback.d-B1EIF-fU.d.ts → qti-feedback.d-D-w6-mJv.d.ts} +1 -1
  52. package/dist/qti-item.d-D_-9_0e6.d.ts +101 -0
  53. package/dist/qti-rule-base.d-Bdzg8eGH.d.ts +41 -0
  54. package/dist/{qti-test.d-C6lCEMRB.d.ts → qti-test.d-D-ELy0Mr.d.ts} +150 -20
  55. package/dist/{qti-text-entry-interaction.d-BGdfV9qG.d.ts → qti-text-entry-interaction.d-CATtcPyX.d.ts} +10 -9
  56. package/dist/session.context.d-Cjs0BkJB.d.ts +33 -0
  57. package/dist/test.d.ts +8 -8
  58. package/dist/test.js +10 -6
  59. package/dist/transformers.js +1 -1
  60. package/package.json +12 -11
  61. package/dist/chunk-3VQSUWCK.js.map +0 -1
  62. package/dist/chunk-5BXJRO5O.js.map +0 -1
  63. package/dist/chunk-DAUU2NJL.js.map +0 -1
  64. package/dist/chunk-HDEG6BAZ.js.map +0 -1
  65. package/dist/chunk-QCPN7E6K.js.map +0 -1
  66. package/dist/chunk-WCWJPIUQ.js.map +0 -1
  67. package/dist/chunk-WKWCOV5P.js.map +0 -1
  68. package/dist/computed-item.types.d-BKZdSLLJ.d.ts +0 -19
  69. package/dist/qti-rule-base.d-ajOnfGXY.d.ts +0 -16
  70. /package/dist/{chunk-XYQNTF5B.js.map → chunk-7VDR765S.js.map} +0 -0
  71. /package/dist/{chunk-MKZ374OJ.js.map → chunk-FG5JAWSN.js.map} +0 -0
  72. /package/dist/{chunk-RT6WZ3P7.js.map → chunk-JLZCZVRX.js.map} +0 -0
  73. /package/dist/{chunk-6ITD55QE.js.map → chunk-LFVPS7KB.js.map} +0 -0
  74. /package/dist/{chunk-LDY4C2OT.js.map → chunk-YIYHCHHM.js.map} +0 -0
  75. /package/dist/{chunk-KCK27QBP.js.map → chunk-ZG7FBQFP.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { Q as QtiExpression } from './qti-expression.d-B_-m9emA.js';
1
+ import { Q as QtiExpression } from './qti-expression.d-BksT9iLB.js';
2
2
 
3
3
  declare abstract class QtiConditionExpression extends QtiExpression<boolean> {
4
4
  calculate(): Readonly<boolean>;
@@ -1,7 +1,7 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement } from 'lit';
3
- import { I as ItemContext, V as VariableDeclaration, f as ResponseVariable } from './item.types.d-QU7LljEK.js';
4
- import { Q as QtiContext, a as QtiContextType } from './qti.context.d-CejJMlfZ.js';
3
+ import { b as ItemContext, V as VariableDeclaration, g as ResponseVariable, B as BaseType } from './item.types.d-BDFrq19E.js';
4
+ import { a as QtiContextType, Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
5
5
 
6
6
  interface TestContext {
7
7
  items: (ItemContext & {
@@ -14,15 +14,38 @@ declare const testContext: {
14
14
  __context__: Readonly<TestContext>;
15
15
  };
16
16
 
17
+ type ExpressionVariable = ResponseVariable | VariableDeclaration<QtiContextType>;
17
18
  interface QtiExpressionBase<T> {
18
19
  calculate(): Readonly<T>;
19
20
  }
20
21
  declare abstract class QtiExpression<T> extends LitElement implements QtiExpressionBase<T> {
22
+ #private;
21
23
  protected result: any;
24
+ /**
25
+ * What the last `calculate()` produced, or undefined if it has not run.
26
+ *
27
+ * This is the supported way to inspect a scoring run: process the responses,
28
+ * then walk the rule tree reading this off each expression. A tool that wants
29
+ * to visualise how a score came about gets the whole tree annotated with its
30
+ * values, without the components having to re-render to show them.
31
+ */
32
+ get lastResult(): Readonly<T> | undefined;
33
+ get lastVariables(): readonly ExpressionVariable[];
22
34
  static styles: lit.CSSResult;
23
35
  render(): lit.TemplateResult<1>;
36
+ protected shouldUpdate(): boolean;
24
37
  calculate(): Readonly<T>;
25
38
  protected getResult(): Readonly<T>;
39
+ /**
40
+ * The base type this operator always produces, when the QTI vocabulary fixes
41
+ * one regardless of its operands — `qti-divide` is a float even dividing two
42
+ * integers exactly, and `qti-round` is an integer whatever it rounds.
43
+ *
44
+ * Left undefined by operators whose result type follows their operands (a
45
+ * `qti-sum` of integers is an integer) and by those that return no number at
46
+ * all; the type is then read off the value.
47
+ */
48
+ get resultBaseType(): BaseType | undefined;
26
49
  protected context?: ItemContext;
27
50
  protected qtiContext?: QtiContext;
28
51
  protected _testContext?: TestContext;
@@ -35,7 +58,7 @@ declare abstract class QtiExpression<T> extends LitElement implements QtiExpress
35
58
  * throwing, so callers degrade gracefully.
36
59
  */
37
60
  protected resolveVariable(identifier: string): VariableDeclaration<string | string[] | null> | null;
38
- getVariables: () => (ResponseVariable | VariableDeclaration<QtiContextType>)[];
61
+ getVariables: () => ExpressionVariable[];
39
62
  }
40
63
 
41
64
  export { INITIAL_TEST_CONTEXT as I, QtiExpression as Q, type TestContext as T, type QtiExpressionBase as a, testContext as t };
@@ -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-QU7LljEK.js';
3
+ import { a as Cardinality } from './item.types.d-BDFrq19E.js';
4
4
 
5
5
  declare abstract class QtiVariableDeclaration extends LitElement {
6
6
  render(): lit.TemplateResult<1>;
@@ -0,0 +1,101 @@
1
+ import * as lit from 'lit';
2
+ import { LitElement } from 'lit';
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';
5
+ import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
6
+ import { QtiAssessmentItem } from './elements.js';
7
+
8
+ /**
9
+ * `<item-container>` is a custom element designed for hosting the qti-assessment-item.
10
+ * The `qti-assessment-item` will be placed inside the shadow DOM of this element.
11
+ * The element loads the item from the provided URL and renders it inside the shadow DOM.
12
+ *
13
+ * ### Styling
14
+ * Add a class to the element for styling.
15
+ *
16
+ * ```html
17
+ * <qti-item>
18
+ * <item-container class="m-4 bg-white" item-url="./path/to/item.xml"></item-container>
19
+ * </qti-item>
20
+ * ```
21
+ */
22
+ declare class ItemContainer extends LitElement {
23
+ #private;
24
+ /** Scoped registry used by the item shadow root. Must be set before connection. */
25
+ customElementRegistry: CustomElementRegistry | null;
26
+ /** URL of the item to load */
27
+ itemURL: string | null;
28
+ /** A parsed HTML document */
29
+ itemDoc: DocumentFragment | null;
30
+ /** The raw XML string */
31
+ itemXML: string | null;
32
+ protected qtiContext: QtiContext;
33
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
34
+ protected handleItemURLChange(): Promise<void>;
35
+ protected handleItemXMLChange(): void;
36
+ connectedCallback(): Promise<void>;
37
+ render(): lit.TemplateResult<1>;
38
+ }
39
+ declare global {
40
+ interface HTMLElementTagNameMap {
41
+ 'item-container': ItemContainer;
42
+ }
43
+ }
44
+
45
+ declare class ItemPrintVariables extends LitElement {
46
+ protected computedContext?: ComputedItemContext;
47
+ static styles: lit.CSSResult;
48
+ render(): lit.TemplateResult<1>;
49
+ }
50
+ declare global {
51
+ interface HTMLElementTagNameMap {
52
+ 'item-print-variables': ItemPrintVariables;
53
+ }
54
+ }
55
+
56
+ declare const QtiItem_base: (abstract new (...args: any[]) => {
57
+ view: View;
58
+ updateAssessmentItemView(assessmentItem: QtiAssessmentItem, view: View): void;
59
+ }) & typeof LitElement;
60
+ /**
61
+ * `<qti-item>` is a custom element designed for rendering a single `qti-assessment-item`.
62
+ * It can also host some functionalities to interact with the item like scoring, showing feedback, etc.
63
+ * Placing a mandatory `<item-container>` inside '<qti-item>' will load or parse the item and render it.
64
+ * See `<item-container>` for more details.
65
+ *
66
+ * ```html
67
+ * <qti-item>
68
+ * <item-container class="m-4 bg-white" item-url="./path/to/item.xml"></item-container>
69
+ * </qti-item>
70
+ * ```
71
+ *
72
+ * `view` selects the audience the item is presented to, which is what reveals `view`-tagged
73
+ * content such as a scorer's `qti-rubric-block` — see `ItemViewMixin`.
74
+ *
75
+ * ```html
76
+ * <qti-item view="scorer">
77
+ * <item-container item-url="./path/to/item.xml"></item-container>
78
+ * </qti-item>
79
+ * ```
80
+ */
81
+ declare class QtiItem extends QtiItem_base {
82
+ #private;
83
+ computedContext: ComputedItemContext;
84
+ protected assessmentItem?: QtiAssessmentItem;
85
+ configContext: ConfigContext;
86
+ /**
87
+ * Provided so that descendants (e.g. `<item-container>`) can read the QTI runtime
88
+ * context for standalone item delivery, including the optional shuffle `seed`.
89
+ */
90
+ qtiContext: QtiContext;
91
+ constructor();
92
+ render(): lit.TemplateResult<1>;
93
+ disconnectedCallback(): void;
94
+ }
95
+ declare global {
96
+ interface HTMLElementTagNameMap {
97
+ 'qti-item': QtiItem;
98
+ }
99
+ }
100
+
101
+ export { ItemContainer as I, QtiItem as Q, ItemPrintVariables as a };
@@ -0,0 +1,41 @@
1
+ import { LitElement } from 'lit';
2
+
3
+ /**
4
+ * Interface for any object that can process QTI rules
5
+ */
6
+ interface QtiRuleBase {
7
+ process(): any;
8
+ }
9
+ /**
10
+ * Abstract base class for QTI rule DOM elements
11
+ */
12
+ declare abstract class QtiRuleElement extends LitElement implements QtiRuleBase {
13
+ abstract process(): any;
14
+ }
15
+ /**
16
+ * Thrown by `qti-exit-response` to end the response processing of an attempt.
17
+ *
18
+ * An exit can sit at any depth — inside a `qti-response-condition` branch, or
19
+ * inside a `qti-response-processing-fragment` — and has to stop every rule
20
+ * after it, not just its own siblings. Unwinding the stack is what reaches
21
+ * every one of those loops without each of them having to report upwards.
22
+ *
23
+ * `qti-response-processing` catches it at the top of the run. The outcomes set
24
+ * before the exit are kept, because each `qti-set-outcome-value` has already
25
+ * dispatched by the time this is thrown.
26
+ */
27
+ declare class QtiExitResponseSignal extends Error {
28
+ constructor();
29
+ }
30
+ /**
31
+ * Thrown by `qti-exit-test` to end the outcome processing of a test.
32
+ *
33
+ * The test-level twin of {@link QtiExitResponseSignal}, and unwinds the stack
34
+ * for the same reason: an exit inside a `qti-outcome-condition` branch has to
35
+ * stop the rules after the condition, not just its own siblings.
36
+ */
37
+ declare class QtiExitTestSignal extends Error {
38
+ constructor();
39
+ }
40
+
41
+ export { QtiExitResponseSignal as Q, QtiExitTestSignal as a, type QtiRuleBase as b, QtiRuleElement as c };
@@ -1,26 +1,61 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, nothing } from 'lit';
3
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';
4
5
  import { QtiAssessmentItem, QtiModalFeedback } from './elements.js';
5
6
  import { TemplateFunction } from '@heximal/templates';
6
- import { T as TestContext, Q as QtiExpression, a as QtiExpressionBase } from './qti-expression.d-B_-m9emA.js';
7
- import { g as VariableValue, b as OutcomeVariable, V as VariableDeclaration } from './item.types.d-QU7LljEK.js';
8
- import { S as SessionContext, C as ComputedContext, a as ComputedItem, V as View } from './computed.types.d-CJarqC6s.js';
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
10
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
10
- import { Q as QtiRuleBase } from './qti-rule-base.d-ajOnfGXY.js';
11
+ import { b as QtiRuleBase } from './qti-rule-base.d-Bdzg8eGH.js';
11
12
  import { Q as QtiContext } from './qti.context.d-CejJMlfZ.js';
12
13
 
14
+ /**
15
+ * The model a `<template item-ref>` is rendered with.
16
+ *
17
+ * Only what this element already knows: the item's parsed document and the
18
+ * attributes off the item-ref itself. `itemRef` is the escape hatch — a
19
+ * template that needs anything else (a click handler, a value from the host
20
+ * app) reaches it through a property on the element, which the host is free to
21
+ * set.
22
+ */
23
+ interface ItemRefTemplateModel {
24
+ /** The item's parsed document, i.e. what the element renders by default. */
25
+ xmlDoc: DocumentFragment;
26
+ identifier?: string;
27
+ href?: string;
28
+ category?: string;
29
+ /**
30
+ * This item's entry in the computed context, the same object the stamps
31
+ * iterate as `item`: `index` (1-based, null for info items), `score`,
32
+ * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.
33
+ */
34
+ item?: ComputedItem;
35
+ /** The element being rendered. */
36
+ itemRef: QtiAssessmentItemRef;
37
+ }
13
38
  declare class QtiAssessmentItemRef extends LitElement {
39
+ #private;
14
40
  category?: string;
15
41
  identifier?: string;
16
42
  required?: boolean;
17
43
  fixed?: boolean;
18
44
  href?: string;
19
- weigths: Map<string, number>;
20
- xmlDoc: DocumentFragment;
45
+ protected computedContext?: ComputedContext;
46
+ /**
47
+ * The `<qti-weight>` children of this ref, keyed by identifier — what
48
+ * `qti-test-variables`' `weight-identifier` resolves against.
49
+ *
50
+ * Read on access rather than cached: the test document is rendered into this
51
+ * element's light DOM, so the weights are not in place at construction time,
52
+ * and outcome processing runs long after they are.
53
+ */
54
+ get weights(): Map<string, number>;
55
+ xmlDoc: DocumentFragment | null;
21
56
  protected createRenderRoot(): HTMLElement | DocumentFragment;
22
57
  get assessmentItem(): QtiAssessmentItem | null;
23
- myTemplate: TemplateFunction;
58
+ myTemplate: TemplateFunction | null;
24
59
  connectedCallback(): Promise<void>;
25
60
  render(): unknown;
26
61
  }
@@ -87,6 +122,30 @@ declare global {
87
122
  }
88
123
  }
89
124
 
125
+ /**
126
+ * @summary The qti-number-selected expression counts the item refs selected for the test.
127
+ * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-selected
128
+ *
129
+ * Outcome processing only. `section-identifier`, `include-category` and
130
+ * `exclude-category` narrow which item references are counted; with none of
131
+ * them it is every item reference in the test.
132
+ *
133
+ * The count comes from the item refs in the document rather than the test
134
+ * context, so it is the same set `qti-test-variables` aggregates over — and it
135
+ * is right before any item has been attempted.
136
+ */
137
+ declare class QtiNumberSelected extends QtiExpression<number> {
138
+ #private;
139
+ constructor();
140
+ getResult(): number;
141
+ calculate(): number;
142
+ }
143
+ declare global {
144
+ interface HTMLElementTagNameMap {
145
+ 'qti-number-selected': QtiNumberSelected;
146
+ }
147
+ }
148
+
90
149
  declare class QtiOutcomeProcessing extends LitElement {
91
150
  static styles: lit.CSSResult[];
92
151
  render(): lit.TemplateResult<1>;
@@ -484,7 +543,7 @@ declare class TestScoringButtons extends LitElement {
484
543
  protected createRenderRoot(): HTMLElement | DocumentFragment;
485
544
  connectedCallback(): void;
486
545
  protected computedContext?: ComputedContext;
487
- render(): lit.TemplateResult<1> | typeof nothing;
546
+ render(): typeof nothing | lit.TemplateResult<1>;
488
547
  constructor();
489
548
  }
490
549
  declare global {
@@ -533,6 +592,8 @@ declare global {
533
592
  type SpeechState = 'idle' | 'playing' | 'paused';
534
593
  interface TtsContext {
535
594
  state: SpeechState;
595
+ /** True while every reading element is highlighted and a click on one starts reading there. */
596
+ picking: boolean;
536
597
  /** Index of the currently highlighted reading element (0-based). */
537
598
  currentElementIndex: number;
538
599
  /** Total number of navigable reading elements in the current item. */
@@ -543,6 +604,8 @@ interface TtsContext {
543
604
  stop(): void;
544
605
  prevElement(): void;
545
606
  nextElement(): void;
607
+ /** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */
608
+ togglePick(): void;
546
609
  }
547
610
 
548
611
  declare const ttsContext: {
@@ -556,8 +619,14 @@ declare const ttsContext: {
556
619
  declare abstract class TtsButtonBase extends LitElement {
557
620
  #private;
558
621
  static styles: lit.CSSResult;
622
+ /**
623
+ * Accessible name of the button. Without it the default icon carries an English name, and
624
+ * slotted content names the button by its text; set it when you slot an icon of your own,
625
+ * which has no text to be named by.
626
+ */
627
+ label?: string;
559
628
  protected _tts?: TtsContext;
560
- updated(changed: PropertyValues): void;
629
+ updated(_changed: PropertyValues): void;
561
630
  }
562
631
  /**
563
632
  * `<test-item-to-speech>` is the controller and context provider. It manages
@@ -568,37 +637,82 @@ declare abstract class TtsButtonBase extends LitElement {
568
637
  * ```html
569
638
  * <test-item-to-speech language="nl-NL">
570
639
  * <test-tts-play></test-tts-play>
571
- * <test-tts-prev>◀◀</test-tts-prev>
572
- * <test-tts-next>▶▶</test-tts-next>
573
- * <test-tts-stop>■</test-tts-stop>
640
+ * <test-tts-prev></test-tts-prev>
641
+ * <test-tts-next></test-tts-next>
642
+ * <test-tts-stop></test-tts-stop>
574
643
  * </test-item-to-speech>
575
644
  * ```
576
645
  *
646
+ * The controller lays its controls out as a wrapping row; each control draws an icon button,
647
+ * and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a
648
+ * control with a slotted icon a `label`, since an icon has no text to name the button by. Buttons read the qti-theme tokens (with the theme's
649
+ * defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.
650
+ *
651
+ * ### Language resolution
652
+ *
653
+ * Each reading element is spoken in the language of the nearest `lang` attribute:
654
+ *
655
+ * 1. `lang` (or `xml:lang`) on the element itself
656
+ * 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across
657
+ * shadow roots, anything wrapping the test
658
+ * 3. `lang` on the document's `<html>` element
659
+ * 4. the `language` attribute on `<test-item-to-speech>`
660
+ *
661
+ * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with
662
+ * `xml:lang="en-GB"` on a `<p>` or on the item root is honoured without further work.
663
+ *
664
+ * ### Which item is read
665
+ *
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.
673
+ *
674
+ * Only one item can be spoken at a time; starting one player stops any other.
675
+ *
676
+ * ### Starting somewhere in the middle
677
+ *
678
+ * `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue
679
+ * cursor highlight, and the first click on one of them leaves pick mode and starts reading
680
+ * from that element. Pressing the button again leaves pick mode without reading.
681
+ *
577
682
  * @cssstate idle - No speech active
683
+ * @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click
578
684
  * @cssstate playing - Speech is playing
579
685
  * @cssstate paused - Speech is paused
580
686
  */
581
687
  declare class TestItemToSpeech extends LitElement {
582
688
  #private;
689
+ static styles: lit.CSSResult;
690
+ /** Fallback language when neither the item content nor the document declares one. */
583
691
  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;
584
697
  protected _sessionContext?: SessionContext;
585
698
  _ttsContext: TtsContext;
586
699
  constructor();
587
700
  willUpdate(changed: PropertyValues): void;
588
- updated(_changed: PropertyValues): void;
701
+ updated(changed: PropertyValues): void;
589
702
  connectedCallback(): void;
590
703
  disconnectedCallback(): void;
591
704
  render(): lit.TemplateResult<1>;
592
705
  }
593
706
  /**
594
707
  * Play/pause/resume toggle button — always enabled, cycles through states.
595
- * Use named slots `play` and `pause` to customise the icons/labels independently.
708
+ * Use named slots `play` and `pause` to customise the icons/labels independently; `label` and
709
+ * `pause-label` name the button in each state (set them when the slotted content is an icon).
596
710
  *
597
711
  * @example
598
712
  * ```html
599
713
  * <test-tts-play>
600
- * <span slot="play">▶ Play</span>
601
- * <span slot="pause">⏸ Pause</span>
714
+ * <span slot="play">Voorlezen</span>
715
+ * <span slot="pause">Pauzeren</span>
602
716
  * </test-tts-play>
603
717
  * ```
604
718
  *
@@ -607,6 +721,8 @@ declare class TestItemToSpeech extends LitElement {
607
721
  */
608
722
  declare class TestTtsPlay extends TtsButtonBase {
609
723
  #private;
724
+ /** Accessible name of the button while speech is playing; see `label`. */
725
+ pauseLabel?: string;
610
726
  render(): lit.TemplateResult<1>;
611
727
  }
612
728
  /**
@@ -626,7 +742,7 @@ declare class TestTtsResume extends TtsButtonBase {
626
742
  render(): lit.TemplateResult<1>;
627
743
  }
628
744
  /**
629
- * Stop button — enabled when playing or paused.
745
+ * Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).
630
746
  * @cssstate idle / playing / paused
631
747
  * @csspart button
632
748
  */
@@ -635,7 +751,9 @@ declare class TestTtsStop extends TtsButtonBase {
635
751
  }
636
752
  /**
637
753
  * Prev-element button — moves cursor to the previous reading element and pauses.
638
- * Disabled at the first element or when no elements are loaded.
754
+ * Disabled at the first element. Reading elements are collected lazily, so an element count
755
+ * of 0 means "not looked yet" rather than "nothing to read": the button stays enabled and the
756
+ * first click collects them.
639
757
  * @cssstate idle / playing / paused
640
758
  * @csspart button
641
759
  */
@@ -644,13 +762,24 @@ declare class TestTtsPrev extends TtsButtonBase {
644
762
  }
645
763
  /**
646
764
  * Next-element button — moves cursor to the next reading element and pauses.
647
- * Disabled at the last element or when no elements are loaded.
765
+ * Disabled at the last element; enabled while the elements have not been collected yet
766
+ * (see `TestTtsPrev`).
648
767
  * @cssstate idle / playing / paused
649
768
  * @csspart button
650
769
  */
651
770
  declare class TestTtsNext extends TtsButtonBase {
652
771
  render(): lit.TemplateResult<1>;
653
772
  }
773
+ /**
774
+ * Pick button — toggles pick mode on the controller: every reading element is highlighted and
775
+ * a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.
776
+ * @cssstate idle / playing / paused
777
+ * @cssstate picking
778
+ * @csspart button
779
+ */
780
+ declare class TestTtsPick extends TtsButtonBase {
781
+ render(): lit.TemplateResult<1>;
782
+ }
654
783
  declare global {
655
784
  interface HTMLElementTagNameMap {
656
785
  'test-item-to-speech': TestItemToSpeech;
@@ -660,6 +789,7 @@ declare global {
660
789
  'test-tts-stop': TestTtsStop;
661
790
  'test-tts-prev': TestTtsPrev;
662
791
  'test-tts-next': TestTtsNext;
792
+ 'test-tts-pick': TestTtsPick;
663
793
  }
664
794
  }
665
795
 
@@ -734,4 +864,4 @@ declare global {
734
864
  }
735
865
  }
736
866
 
737
- export { TestTtsPause as A, TestTtsPlay as B, TestTtsPrev as C, TestTtsResume as D, TestTtsStop as E, TestView as F, TestViewToggle as G, type TtsContext as H, type ITestNavigationMixin as I, ttsContext as J, QtiAssessmentItemRef as Q, type SpeechState as S, TestCheckItem as T, QtiAssessmentSection as a, QtiAssessmentTest as b, QtiItemSessionControl as c, QtiOutcomeProcessing as d, QtiOutcomeProcessingProcessor as e, QtiTest as f, QtiTestFeedback as g, QtiTestPart as h, QtiTestVariables as i, QtiTestVariablesExpression as j, TestContainer as k, TestEndAttempt as l, TestItemLink as m, TestItemToSpeech as n, TestNavigation as o, TestNext as p, TestPagingButtonsStamp as q, TestPrev as r, TestPrintContext as s, TestPrintVariables as t, TestScoringButtons as u, TestScoringFeedback as v, TestSectionButtonsStamp as w, TestSectionLink as x, TestStamp as y, TestTtsNext as z };
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 };
@@ -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-CJiMv8H7.js';
3
+ import { I as Interaction } from './interaction.d-DegNJ5ZA.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, I as ItemContext, Q as QtiAreaMapEntry } from './item.types.d-QU7LljEK.js';
6
+ import { B as BaseType, a as Cardinality, b as ItemContext, Q as QtiAreaMapEntry } from './item.types.d-BDFrq19E.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
 
@@ -86,14 +86,11 @@ declare class QtiGapImg extends LitElement {
86
86
  tabindex: number | undefined;
87
87
  /**
88
88
  * `qti-gap-img` is a draggable chip, so it needs ElementInternals to carry the drag states
89
- * (`dragging`, `placeholder`). It works without a shadow root.
90
- *
91
- * NOTE: this element never calls `super.connectedCallback()`, so Lit never enables updating
92
- * and it has no shadow root — which makes `qti-gap-img.styles.ts` dead code. Fixing that means
93
- * adding a `<slot>` to a `render()` first, otherwise the authored `<img>` child disappears.
89
+ * (`dragging`, `placeholder`).
94
90
  */
95
91
  internals: ElementInternals;
96
92
  connectedCallback(): void;
93
+ render(): lit.TemplateResult<1>;
97
94
  }
98
95
  declare global {
99
96
  interface HTMLElementTagNameMap {
@@ -765,7 +762,7 @@ declare global {
765
762
  }
766
763
 
767
764
  type HotspotChoice = Choice & {
768
- order: number;
765
+ order: number | null;
769
766
  };
770
767
  declare const QtiGraphicOrderInteraction_base: (abstract new (...args: any[]) => ChoicesInterface) & typeof Interaction;
771
768
  /**
@@ -779,9 +776,13 @@ declare const QtiGraphicOrderInteraction_base: (abstract new (...args: any[]) =>
779
776
  declare class QtiGraphicOrderInteraction extends QtiGraphicOrderInteraction_base {
780
777
  #private;
781
778
  static styles: CSSResultGroup;
782
- protected choiceOrdering: boolean;
779
+ maxChoices: number;
783
780
  protected _choiceElements: Choice[];
784
781
  render(): lit.TemplateResult<1>;
782
+ protected _choiceElementSelectedHandler(event: CustomEvent<{
783
+ identifier: string;
784
+ }>): void;
785
+ protected handleOrderedResponseChange(): void;
785
786
  /** Extension hook for packages that add semantic color states to locator pins. */
786
787
  protected resolvePinColor(_choice: HotspotChoice): string;
787
788
  protected refreshLocatorPins(): void;
@@ -0,0 +1,33 @@
1
+ import { V as VariableDeclaration } from './item.types.d-BDFrq19E.js';
2
+
3
+ type ComputedItemContext = {
4
+ identifier: string;
5
+ href?: string;
6
+ correct?: boolean;
7
+ incorrect?: boolean;
8
+ completed?: boolean;
9
+ adaptive?: boolean;
10
+ timeDependent?: boolean;
11
+ title?: string;
12
+ label?: string;
13
+ score?: number;
14
+ maxScore?: number;
15
+ completionStatus?: string;
16
+ variables: ReadonlyArray<VariableDeclaration<string | string[] | null>>;
17
+ };
18
+
19
+ type View = 'author' | 'candidate' | 'proctor' | 'scorer' | 'testConstructor' | 'tutor' | '';
20
+ interface SessionContext {
21
+ navPartId?: string | null;
22
+ navSectionId?: string | null;
23
+ navItemRefId?: string | null;
24
+ navItemLoading?: boolean;
25
+ navTestLoading?: boolean;
26
+ view?: View;
27
+ }
28
+ declare const INITIAL_SESSION_CONTEXT: Readonly<SessionContext>;
29
+ declare const sessionContext: {
30
+ __context__: Readonly<SessionContext>;
31
+ };
32
+
33
+ export { type ComputedItemContext as C, INITIAL_SESSION_CONTEXT as I, type SessionContext as S, type View as V, sessionContext as s };
package/dist/test.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- import { I as ITestNavigationMixin } from './qti-test.d-C6lCEMRB.js';
2
- export { Q as QtiAssessmentItemRef, a as QtiAssessmentSection, b as QtiAssessmentTest, c as QtiItemSessionControl, d as QtiOutcomeProcessing, e as QtiOutcomeProcessingProcessor, f as QtiTest, g as QtiTestFeedback, h as QtiTestPart, i as QtiTestVariables, j as QtiTestVariablesExpression, S as SpeechState, T as TestCheckItem, k as TestContainer, l as TestEndAttempt, m as TestItemLink, n as TestItemToSpeech, o as TestNavigation, p as TestNext, q as TestPagingButtonsStamp, r as TestPrev, s as TestPrintContext, t as TestPrintVariables, u as TestScoringButtons, v as TestScoringFeedback, w as TestSectionButtonsStamp, x as TestSectionLink, y as TestStamp, z as TestTtsNext, A as TestTtsPause, B as TestTtsPlay, C as TestTtsPrev, D as TestTtsResume, E as TestTtsStop, F as TestView, G as TestViewToggle, H as TtsContext, J as ttsContext } from './qti-test.d-C6lCEMRB.js';
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';
3
3
  import { LitElement } from 'lit';
4
- import { g as VariableValue, b as OutcomeVariable, V as VariableDeclaration } from './item.types.d-QU7LljEK.js';
5
- import { S as SessionContext } from './computed.types.d-CJarqC6s.js';
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';
6
6
  import { C as ConfigContext } from './config.context.d-BvU9r-Mg.js';
7
- import { T as TestContext } from './qti-expression.d-B_-m9emA.js';
7
+ import { T as TestContext } from './qti-expression.d-BksT9iLB.js';
8
8
  import './qti-transform-test.d-BL7GGFJj.js';
9
+ import './computed.types.d-DB5gfOh9.js';
9
10
  import './elements.js';
10
11
  import './interaction.interface.d-CvjHM2bi.js';
11
- import './qti-feedback.d-B1EIF-fU.js';
12
- import './qti-rule-base.d-ajOnfGXY.js';
12
+ import './qti-feedback.d-D-w6-mJv.js';
13
+ import './qti-rule-base.d-Bdzg8eGH.js';
13
14
  import '@heximal/templates';
14
15
  import './qti.context.d-CejJMlfZ.js';
15
- import './computed-item.types.d-BKZdSLLJ.js';
16
16
 
17
17
  interface IQtiTest extends LitElement, ITestNavigationMixin, ITestProcessingMixin, IMyQtiTest {
18
18
  }