@qti-components/test 1.8.0 → 1.10.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 (74) hide show
  1. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.d.ts +4 -0
  2. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +16 -28
  3. package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
  4. package/dist/components/qti-assessment-test/qti-assessment-test.d.ts +5 -0
  5. package/dist/components/qti-assessment-test/qti-assessment-test.js +2 -5
  6. package/dist/components/qti-assessment-test/qti-assessment-test.js.map +1 -1
  7. package/dist/components/qti-number-selected/qti-number-selected.js +2 -1
  8. package/dist/components/qti-number-selected/qti-number-selected.js.map +1 -1
  9. package/dist/components/qti-test/qti-test.d.ts +16 -2
  10. package/dist/components/qti-test/qti-test.js +33 -6
  11. package/dist/components/qti-test/qti-test.js.map +1 -1
  12. package/dist/components/qti-test-variables/qti-test-variables.js +2 -1
  13. package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -1
  14. package/dist/components/test-check-item/test-check-item.d.ts +2 -0
  15. package/dist/components/test-check-item/test-check-item.js +16 -3
  16. package/dist/components/test-check-item/test-check-item.js.map +1 -1
  17. package/dist/components/test-container/test-container.d.ts +3 -0
  18. package/dist/components/test-container/test-container.js +5 -1
  19. package/dist/components/test-container/test-container.js.map +1 -1
  20. package/dist/components/test-end-attempt/test-end-attempt.js +2 -1
  21. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  22. package/dist/components/test-item-link/test-item-link.js +2 -8
  23. package/dist/components/test-item-link/test-item-link.js.map +1 -1
  24. package/dist/components/test-item-to-speech/test-item-to-speech.d.ts +61 -15
  25. package/dist/components/test-item-to-speech/test-item-to-speech.js +287 -103
  26. package/dist/components/test-item-to-speech/test-item-to-speech.js.map +1 -1
  27. package/dist/components/test-navigation/test-navigation.d.ts +9 -9
  28. package/dist/components/test-navigation/test-navigation.js +68 -21
  29. package/dist/components/test-navigation/test-navigation.js.map +1 -1
  30. package/dist/components/test-next/test-next.js +2 -8
  31. package/dist/components/test-next/test-next.js.map +1 -1
  32. package/dist/components/test-prev/test-prev.js +2 -8
  33. package/dist/components/test-prev/test-prev.js.map +1 -1
  34. package/dist/components/test-scoring-buttons/test-scoring-buttons.d.ts +1 -1
  35. package/dist/components/test-scoring-buttons/test-scoring-buttons.js +6 -8
  36. package/dist/components/test-scoring-buttons/test-scoring-buttons.js.map +1 -1
  37. package/dist/components/test-section-link/test-section-link.js +2 -8
  38. package/dist/components/test-section-link/test-section-link.js.map +1 -1
  39. package/dist/components/test-view-toggle/test-view-toggle.js +2 -5
  40. package/dist/components/test-view-toggle/test-view-toggle.js.map +1 -1
  41. package/dist/components/test-view-toggle/test-view.js +2 -5
  42. package/dist/components/test-view-toggle/test-view.js.map +1 -1
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.js +1 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/internal/item-ref-selection.js.map +1 -1
  47. package/dist/internal/test-host.context.d.ts +24 -0
  48. package/dist/internal/test-host.context.js +3 -0
  49. package/dist/internal/test-host.context.js.map +1 -0
  50. package/dist/mixins/index.d.ts +1 -0
  51. package/dist/mixins/index.js +1 -0
  52. package/dist/mixins/index.js.map +1 -1
  53. package/dist/mixins/test-base.d.ts +7 -2
  54. package/dist/mixins/test-base.js +55 -20
  55. package/dist/mixins/test-base.js.map +1 -1
  56. package/dist/mixins/test-navigation.mixin.d.ts +3 -4
  57. package/dist/mixins/test-navigation.mixin.js +26 -40
  58. package/dist/mixins/test-navigation.mixin.js.map +1 -1
  59. package/dist/mixins/test-processing.mixin.js +3 -1
  60. package/dist/mixins/test-processing.mixin.js.map +1 -1
  61. package/dist/mixins/test-state.mixin.d.ts +33 -0
  62. package/dist/mixins/test-state.mixin.js +131 -0
  63. package/dist/mixins/test-state.mixin.js.map +1 -0
  64. package/dist/mixins/test-view.mixin.js +3 -2
  65. package/dist/mixins/test-view.mixin.js.map +1 -1
  66. package/dist/public-events.d.ts +62 -0
  67. package/dist/public-events.js +33 -0
  68. package/dist/public-events.js.map +1 -0
  69. package/dist/types/iqti-test.d.ts +8 -5
  70. package/dist/types/iqti-test.js.map +1 -1
  71. package/dist/types/qti-test-state.d.ts +45 -0
  72. package/dist/types/qti-test-state.js +2 -0
  73. package/dist/types/qti-test-state.js.map +1 -0
  74. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAIpC,MAAM,OAAO,cAAe,SAAQ,UAAU;IAS5C,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAEF;QACE,KAAK,EAAE,CAAC;QAzBH,sBAAiB,GAAG,KAAK,CAAC;QA0B/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YACjC,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,iB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;YAC1E,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,UAAU,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,KAAK,KAAK,IAAI,UAAU,CAAC,iBAAiB,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AA/ES;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDACY;AAGpC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAGjC;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n this.dispatchEvent(new CustomEvent('test-end-attempt', { bubbles: true }));\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
1
+ {"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EA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AC;yDACjC;AAGjC;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { css, html, LitElement } from 'lit';
8
8
  import { property } from 'lit/decorators.js';
9
9
  import * as styles from '../styles';
10
+ import { dispatchPublic } from '../../public-events';
10
11
  export class TestItemLink extends LitElement {
11
12
  static { this.styles = css `
12
13
  :host {
@@ -28,14 +29,7 @@ export class TestItemLink extends LitElement {
28
29
  this.addEventListener('click', () => this._requestItem(this.itemId));
29
30
  }
30
31
  _requestItem(identifier) {
31
- this.dispatchEvent(new CustomEvent('qti-request-navigation', {
32
- composed: true,
33
- bubbles: true,
34
- detail: {
35
- type: 'item',
36
- id: identifier
37
- }
38
- }));
32
+ dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });
39
33
  }
40
34
  render() {
41
35
  return html ` <slot></slot> `;
@@ -1 +1 @@
1
- {"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAKF;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,wBAAwB,EAAE;YACxC,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,UAAU;aACf;SACF,CAAC,CACH,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAtBO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\n\nexport class TestItemLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n this.dispatchEvent(\n new CustomEvent('qti-request-navigation', {\n composed: true,\n bubbles: true,\n detail: {\n type: 'item',\n id: identifier\n }\n })\n );\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
1
+ {"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAKF;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { LitElement } from 'lit';
2
2
  import type { PropertyValues } from 'lit';
3
3
  import type { SessionContext } from '@qti-components/base';
4
+ import type { TestHost } from '../../internal/test-host.context';
4
5
  type SpeechState = 'idle' | 'playing' | 'paused';
5
6
  export interface TtsContext {
6
7
  state: SpeechState;
@@ -73,17 +74,66 @@ declare abstract class TtsButtonBase extends LitElement {
73
74
  * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with
74
75
  * `xml:lang="en-GB"` on a `<p>` or on the item root is honoured without further work.
75
76
  *
76
- * ### Which item is read
77
+ * ### What is read
77
78
  *
78
- * By default the player reads the item the test is navigated to (`navItemRefId` from the
79
- * session context). When several items share one page — a keep-together section or a
80
- * vertically scrolling booklet — give each player its own `item-ref-id` so it reads that
81
- * item regardless of the navigation cursor. The item is looked up by its
82
- * `qti-assessment-item-ref` identifier, in the player's own tree first and otherwise in
83
- * any `test-container` shadow root reachable from it, so the player can live inside the
84
- * item card, next to it, or in the page chrome.
79
+ * Decided once per connect, by where the player is placed. The first rule that matches wins:
85
80
  *
86
- * Only one item can be spoken at a time; starting one player stops any other.
81
+ * 1. **Next to a stimulus placeholder** — the player shares its parent with a
82
+ * `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the
83
+ * player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the
84
+ * placeholder: loading a stimulus replaces the placeholder's content. Items and navigation
85
+ * are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts
86
+ * over on the new content.
87
+ * 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked
88
+ * `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes
89
+ * on one container; the player reads the readable elements inside it. Navigation is ignored.
90
+ * The reading list is rebuilt when the player starts from the top, and when an element in it
91
+ * has left the page — so a re-render of the content never interrupts speech.
92
+ * 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,
93
+ * so every item gets a player of its own: the player reads that item, and only that item.
94
+ * The navigation cursor is ignored; speech stops when the player leaves the page with its item.
95
+ * 4. **Anywhere else** — a toolbar in the page chrome: the player follows the navigation cursor
96
+ * and reads the item `navItemRefId` (session context) points at, found in any
97
+ * `test-container` reachable from the player. Navigating stops speech and starts the next
98
+ * item from the top.
99
+ *
100
+ * ```html
101
+ * <!-- 1. a player for the shared reading text -->
102
+ * <aside>
103
+ * <test-item-to-speech>…</test-item-to-speech>
104
+ * <div data-stimulus-idref="Stimulus1"></div>
105
+ * </aside>
106
+ *
107
+ * <!-- 2. a player for any other HTML -->
108
+ * <div>
109
+ * <test-item-to-speech>…</test-item-to-speech>
110
+ * <section data-tts-content lang="nl-NL">…</section>
111
+ * </div>
112
+ *
113
+ * <!-- 3. one player per item -->
114
+ * <qti-test>
115
+ * <template item-ref>
116
+ * <test-item-to-speech>…</test-item-to-speech>
117
+ * {{ xmlDoc }}
118
+ * </template>
119
+ * …
120
+ * </qti-test>
121
+ *
122
+ * <!-- 4. one player in the toolbar, following navigation -->
123
+ * <test-navigation>
124
+ * <header><test-item-to-speech>…</test-item-to-speech></header>
125
+ * <test-container test-url="…"></test-container>
126
+ * </test-navigation>
127
+ * ```
128
+ *
129
+ * In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the
130
+ * player on the fresh content. An item player reads the item body as rendered: a stimulus
131
+ * placed inside the item is read with it, one placed outside (mode 1) is not. Only one player
132
+ * can speak at a time; starting one stops any other.
133
+ *
134
+ * Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,
135
+ * `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)
136
+ * or inside `aria-hidden="true"`.
87
137
  *
88
138
  * ### Starting somewhere in the middle
89
139
  *
@@ -101,16 +151,12 @@ export declare class TestItemToSpeech extends LitElement {
101
151
  static styles: import("lit").CSSResult;
102
152
  /** Fallback language when neither the item content nor the document declares one. */
103
153
  language: string;
104
- /**
105
- * Identifier of the `qti-assessment-item-ref` this player reads. Leave unset to follow the
106
- * navigation cursor (`navItemRefId`) instead.
107
- */
108
- itemRefId?: string;
109
154
  protected _sessionContext?: SessionContext;
155
+ /** The `qti-test` this player is in, across shadow roots. */
156
+ protected testHost?: TestHost;
110
157
  _ttsContext: TtsContext;
111
158
  constructor();
112
159
  willUpdate(changed: PropertyValues): void;
113
- updated(changed: PropertyValues): void;
114
160
  connectedCallback(): void;
115
161
  disconnectedCallback(): void;
116
162
  render(): import("lit").TemplateResult<1>;