@qti-components/test 2.0.0-next.4 → 2.0.0-next.6
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.
- package/dist/components/index.d.ts +0 -11
- package/dist/components/index.js +0 -11
- package/dist/components/index.js.map +1 -1
- package/dist/components/test-bookmark/test-bookmark.d.ts +48 -0
- package/dist/components/test-bookmark/test-bookmark.js +144 -0
- package/dist/components/test-bookmark/test-bookmark.js.map +1 -0
- package/dist/components/test-navigation/test-navigation.js +8 -2
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/components/test-stamp/test-stamp.js +6 -2
- package/dist/components/test-stamp/test-stamp.js.map +1 -1
- package/dist/elements.d.ts +31 -44
- package/dist/elements.js +4 -30
- package/dist/elements.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mixins/test-state.mixin.js +25 -1
- package/dist/mixins/test-state.mixin.js.map +1 -1
- package/dist/plugin-state.d.ts +8 -0
- package/dist/plugin-state.js +7 -0
- package/dist/plugin-state.js.map +1 -0
- package/dist/plugins/elements.d.ts +71 -0
- package/dist/plugins/elements.js +33 -0
- package/dist/plugins/elements.js.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/public-events.d.ts +5 -0
- package/dist/public-events.js +1 -0
- package/dist/public-events.js.map +1 -1
- package/dist/tts/elements.d.ts +28 -0
- package/dist/tts/elements.js +14 -0
- package/dist/tts/elements.js.map +1 -0
- package/dist/{components/test-item-to-speech → tts}/test-item-to-speech.d.ts +9 -9
- package/dist/{components/test-item-to-speech → tts}/test-item-to-speech.js +59 -85
- package/dist/tts/test-item-to-speech.js.map +1 -0
- package/dist/types/qti-test-state.d.ts +12 -1
- package/dist/types/qti-test-state.js.map +1 -1
- package/package.json +11 -7
- package/dist/components/test-item-to-speech/test-item-to-speech.js.map +0 -1
- package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.d.ts +0 -19
- package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js +0 -39
- package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js.map +0 -1
- package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.d.ts +0 -19
- package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js +0 -39
- package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAqD1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAAE;IAC9F,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE;IAC3F,0BAA0B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,8BAA8B,EAAE;IAC1G,+BAA+B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;IACnE,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE;IAC9F,qBAAqB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAC9D,8BAA8B,EAAE;QAC9B,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,MAAM;QACb,UAAU,EAAE,gCAAgC;KAC7C;IACD,6BAA6B,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,sBAAsB,EAAE;IAC1G,oBAAoB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE;IAC5F,kBAAkB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,+BAA+B,EAAE;IACxG,yBAAyB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE;IACnG,yBAAyB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAClE,uBAAuB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;IAChE,yBAAyB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,mCAAmC,EAAE;CACpH,CAAC;AAMF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,IAAO,EACP,MAAkE;IAElE,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,IAAO,EACP,OAAuC;IAEvC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAA6B,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'cito-test-navigate': CustomEvent<NavigationTarget>;\n 'cito-test-end-attempt': CustomEvent<unknown>;\n 'cito-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'cito-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'cito-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n 'cito-test-navigated': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-started': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'cito-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `cito-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-test-state-changed': CustomEvent<QtiTestState>;\n 'cito-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'cito-test-end-reached': CustomEvent<Record<string, never>>;\n 'cito-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },\n 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },\n 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },\n 'cito-test-update-plugin-state': { kind: 'request', scope: 'test' },\n 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },\n 'cito-test-navigated': { kind: 'notification', scope: 'test' },\n 'cito-test-navigation-started': {\n kind: 'notification',\n scope: 'test',\n deprecated: 'qti-navigation-loading-started'\n },\n 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },\n 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },\n 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },\n 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },\n 'cito-test-items-skipped': { kind: 'notification', scope: 'test' },\n 'cito-test-end-reached': { kind: 'notification', scope: 'test' },\n 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TestItemToSpeech, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop } from './test-item-to-speech';
|
|
2
|
+
export { TestItemToSpeech, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop };
|
|
3
|
+
/** The text-to-speech elements, for registering them yourself (e.g. in a scoped registry). Defines nothing. */
|
|
4
|
+
export declare const ttsElements: readonly [{
|
|
5
|
+
readonly tag: "test-item-to-speech";
|
|
6
|
+
readonly ctor: typeof TestItemToSpeech;
|
|
7
|
+
}, {
|
|
8
|
+
readonly tag: "test-tts-next";
|
|
9
|
+
readonly ctor: typeof TestTtsNext;
|
|
10
|
+
}, {
|
|
11
|
+
readonly tag: "test-tts-pause";
|
|
12
|
+
readonly ctor: typeof TestTtsPause;
|
|
13
|
+
}, {
|
|
14
|
+
readonly tag: "test-tts-pick";
|
|
15
|
+
readonly ctor: typeof TestTtsPick;
|
|
16
|
+
}, {
|
|
17
|
+
readonly tag: "test-tts-play";
|
|
18
|
+
readonly ctor: typeof TestTtsPlay;
|
|
19
|
+
}, {
|
|
20
|
+
readonly tag: "test-tts-prev";
|
|
21
|
+
readonly ctor: typeof TestTtsPrev;
|
|
22
|
+
}, {
|
|
23
|
+
readonly tag: "test-tts-resume";
|
|
24
|
+
readonly ctor: typeof TestTtsResume;
|
|
25
|
+
}, {
|
|
26
|
+
readonly tag: "test-tts-stop";
|
|
27
|
+
readonly ctor: typeof TestTtsStop;
|
|
28
|
+
}];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TestItemToSpeech, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop } from './test-item-to-speech';
|
|
2
|
+
export { TestItemToSpeech, TestTtsNext, TestTtsPause, TestTtsPick, TestTtsPlay, TestTtsPrev, TestTtsResume, TestTtsStop };
|
|
3
|
+
/** The text-to-speech elements, for registering them yourself (e.g. in a scoped registry). Defines nothing. */
|
|
4
|
+
export const ttsElements = [
|
|
5
|
+
{ tag: 'test-item-to-speech', ctor: TestItemToSpeech },
|
|
6
|
+
{ tag: 'test-tts-next', ctor: TestTtsNext },
|
|
7
|
+
{ tag: 'test-tts-pause', ctor: TestTtsPause },
|
|
8
|
+
{ tag: 'test-tts-pick', ctor: TestTtsPick },
|
|
9
|
+
{ tag: 'test-tts-play', ctor: TestTtsPlay },
|
|
10
|
+
{ tag: 'test-tts-prev', ctor: TestTtsPrev },
|
|
11
|
+
{ tag: 'test-tts-resume', ctor: TestTtsResume },
|
|
12
|
+
{ tag: 'test-tts-stop', ctor: TestTtsStop }
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=elements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../src/tts/elements.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACZ,CAAC;AAEF,+GAA+G;AAC/G,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,GAAG,EAAE,qBAAqB,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACtD,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAAE;IAC7C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,aAAa,EAAE;IAC/C,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;CACnC,CAAC","sourcesContent":["import {\n TestItemToSpeech,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop\n} from './test-item-to-speech';\n\nexport {\n TestItemToSpeech,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop\n};\n\n/** The text-to-speech elements, for registering them yourself (e.g. in a scoped registry). Defines nothing. */\nexport const ttsElements = [\n { tag: 'test-item-to-speech', ctor: TestItemToSpeech },\n { tag: 'test-tts-next', ctor: TestTtsNext },\n { tag: 'test-tts-pause', ctor: TestTtsPause },\n { tag: 'test-tts-pick', ctor: TestTtsPick },\n { tag: 'test-tts-play', ctor: TestTtsPlay },\n { tag: 'test-tts-prev', ctor: TestTtsPrev },\n { tag: 'test-tts-resume', ctor: TestTtsResume },\n { tag: 'test-tts-stop', ctor: TestTtsStop }\n] as const;\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import type { PropertyValues } from 'lit';
|
|
3
|
-
import type {
|
|
4
|
-
import type { TestHost } from '../../internal/test-host.context';
|
|
3
|
+
import type { ComputedContext } from '@qti-components/base';
|
|
5
4
|
type SpeechState = 'idle' | 'playing' | 'paused';
|
|
6
5
|
export interface TtsContext {
|
|
7
6
|
state: SpeechState;
|
|
@@ -92,10 +91,9 @@ declare abstract class TtsButtonBase extends LitElement {
|
|
|
92
91
|
* 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,
|
|
93
92
|
* so every item gets a player of its own: the player reads that item, and only that item.
|
|
94
93
|
* The navigation cursor is ignored; speech stops when the player leaves the page with its item.
|
|
95
|
-
* 4. **Anywhere else
|
|
96
|
-
* and reads the item
|
|
97
|
-
*
|
|
98
|
-
* item from the top.
|
|
94
|
+
* 4. **Anywhere else inside `<test-navigation>`** — e.g. a toolbar: the player follows the
|
|
95
|
+
* navigation cursor and reads the active item of the computed context. Navigating stops
|
|
96
|
+
* speech and starts the next item from the top.
|
|
99
97
|
*
|
|
100
98
|
* ```html
|
|
101
99
|
* <!-- 1. a player for the shared reading text -->
|
|
@@ -151,9 +149,11 @@ export declare class TestItemToSpeech extends LitElement {
|
|
|
151
149
|
static styles: import("lit").CSSResult;
|
|
152
150
|
/** Fallback language when neither the item content nor the document declares one. */
|
|
153
151
|
language: string;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
/**
|
|
153
|
+
* The test as `test-navigation` computes it: which item is active, and where it is rendered
|
|
154
|
+
* (`itemElement`). Updated on navigation and whenever an item is rendered.
|
|
155
|
+
*/
|
|
156
|
+
protected _computedContext?: ComputedContext;
|
|
157
157
|
_ttsContext: TtsContext;
|
|
158
158
|
constructor();
|
|
159
159
|
willUpdate(changed: PropertyValues): void;
|
|
@@ -8,9 +8,8 @@ import { html, LitElement, css } from 'lit';
|
|
|
8
8
|
import { consume, provide, createContext } from '@lit/context';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import * as styles from '../styles';
|
|
11
|
+
import { computedContext } from '@qti-components/base';
|
|
12
|
+
import * as styles from '../components/styles';
|
|
14
13
|
// ─── CSS Custom Highlight ─────────────────────────────────────────────────────
|
|
15
14
|
const HIGHLIGHT_ELEMENT = 'tts-element'; // navigation cursor — whole element
|
|
16
15
|
const HIGHLIGHT_WORD = 'tts-word'; // word boundary during speech
|
|
@@ -176,10 +175,9 @@ __decorate([
|
|
|
176
175
|
* 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,
|
|
177
176
|
* so every item gets a player of its own: the player reads that item, and only that item.
|
|
178
177
|
* The navigation cursor is ignored; speech stops when the player leaves the page with its item.
|
|
179
|
-
* 4. **Anywhere else
|
|
180
|
-
* and reads the item
|
|
181
|
-
*
|
|
182
|
-
* item from the top.
|
|
178
|
+
* 4. **Anywhere else inside `<test-navigation>`** — e.g. a toolbar: the player follows the
|
|
179
|
+
* navigation cursor and reads the active item of the computed context. Navigating stops
|
|
180
|
+
* speech and starts the next item from the top.
|
|
183
181
|
*
|
|
184
182
|
* ```html
|
|
185
183
|
* <!-- 1. a player for the shared reading text -->
|
|
@@ -250,15 +248,17 @@ export class TestItemToSpeech extends LitElement {
|
|
|
250
248
|
#contentMode;
|
|
251
249
|
// Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
|
|
252
250
|
#itemRef;
|
|
253
|
-
//
|
|
251
|
+
// Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's
|
|
252
|
+
// navigation request is heard.
|
|
254
253
|
#eventHost;
|
|
255
254
|
#boundHandleItemConnected;
|
|
256
255
|
#boundHandleNavigation;
|
|
257
256
|
// Cursor mode: the previous navigation position, to detect moving to another item or section.
|
|
258
257
|
#prevNavItemRefId;
|
|
259
258
|
#prevNavSectionId;
|
|
260
|
-
// Current set of block-level reading elements for the item
|
|
259
|
+
// Current set of block-level reading elements for the item, and the root they were collected from
|
|
261
260
|
#readingElements;
|
|
261
|
+
#readingRoot;
|
|
262
262
|
#currentElementIndex;
|
|
263
263
|
// Text nodes of the element currently being spoken (for word-boundary highlight)
|
|
264
264
|
#textNodes;
|
|
@@ -290,15 +290,17 @@ export class TestItemToSpeech extends LitElement {
|
|
|
290
290
|
this.#contentMode = false;
|
|
291
291
|
// Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
|
|
292
292
|
this.#itemRef = null;
|
|
293
|
-
//
|
|
293
|
+
// Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's
|
|
294
|
+
// navigation request is heard.
|
|
294
295
|
this.#eventHost = null;
|
|
295
296
|
this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
|
|
296
297
|
this.#boundHandleNavigation = () => this.#stop();
|
|
297
298
|
// Cursor mode: the previous navigation position, to detect moving to another item or section.
|
|
298
299
|
this.#prevNavItemRefId = undefined;
|
|
299
300
|
this.#prevNavSectionId = undefined;
|
|
300
|
-
// Current set of block-level reading elements for the item
|
|
301
|
+
// Current set of block-level reading elements for the item, and the root they were collected from
|
|
301
302
|
this.#readingElements = null;
|
|
303
|
+
this.#readingRoot = null;
|
|
302
304
|
this.#currentElementIndex = 0;
|
|
303
305
|
// Text nodes of the element currently being spoken (for word-boundary highlight)
|
|
304
306
|
this.#textNodes = [];
|
|
@@ -340,13 +342,15 @@ export class TestItemToSpeech extends LitElement {
|
|
|
340
342
|
if (this.#stimulusMode || this.#contentMode || this.#itemRef)
|
|
341
343
|
return;
|
|
342
344
|
// Cursor mode: moving to another item or section stops speech and starts over (ignore the
|
|
343
|
-
// initial undefined → value transition). Section navigation leaves
|
|
345
|
+
// initial undefined → value transition). Section navigation leaves no item active, so it
|
|
344
346
|
// needs its own check.
|
|
345
|
-
const item = this
|
|
346
|
-
const section = this._sessionContext?.navSectionId ?? null;
|
|
347
|
+
const { item, section } = this.#activePosition();
|
|
347
348
|
const itemChanged = this.#prevNavItemRefId !== undefined && this.#prevNavItemRefId !== item;
|
|
348
349
|
const sectionChanged = this.#prevNavSectionId !== undefined && this.#prevNavSectionId !== section;
|
|
349
|
-
|
|
350
|
+
// The same item rendered again (e.g. linking to the item already shown): the elements
|
|
351
|
+
// collected earlier are detached. The context updates when an item renders, so check here.
|
|
352
|
+
const rerendered = this.#readingElements !== null && this.#readingRoot !== null && this.#readingRoot !== this.#resolveReadingRoot();
|
|
353
|
+
if (itemChanged || sectionChanged || rerendered)
|
|
350
354
|
this.#resetReadingPosition();
|
|
351
355
|
this.#prevNavItemRefId = item;
|
|
352
356
|
this.#prevNavSectionId = section;
|
|
@@ -364,7 +368,7 @@ export class TestItemToSpeech extends LitElement {
|
|
|
364
368
|
super.connectedCallback();
|
|
365
369
|
this.#setSpeechState('idle');
|
|
366
370
|
// NOTE: #ensureHighlightStyles() is called lazily on first highlight use
|
|
367
|
-
// because
|
|
371
|
+
// because the item to read may not be in the DOM yet at this point.
|
|
368
372
|
this.#stimulusMode = this.#stimulusPlaceholder() !== null;
|
|
369
373
|
if (this.#stimulusMode) {
|
|
370
374
|
// Stimulus mode: neither items nor navigation decide what is read, only the content of the
|
|
@@ -383,14 +387,16 @@ export class TestItemToSpeech extends LitElement {
|
|
|
383
387
|
if (this.#contentMode)
|
|
384
388
|
return;
|
|
385
389
|
this.#itemRef = this.closest('qti-assessment-item-ref');
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this.#
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
if (this.#itemRef) {
|
|
391
|
+
// Item-ref mode: qti-assessment-item-connected (bubbles+composed) passes our own item-ref
|
|
392
|
+
// when our item renders again.
|
|
393
|
+
this.#eventHost = this.#itemRef;
|
|
394
|
+
this.#eventHost.addEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
392
397
|
// Cursor mode: cito-test-navigate fires synchronously on prev/next — stop right away
|
|
393
|
-
// instead of waiting for the new position to arrive through the
|
|
398
|
+
// instead of waiting for the new position to arrive through the computed context.
|
|
399
|
+
this.#eventHost = this.closest('test-navigation') ?? this.getRootNode();
|
|
394
400
|
this.#eventHost.addEventListener('cito-test-navigate', this.#boundHandleNavigation);
|
|
395
401
|
this.#eventHost.addEventListener('qti-request-navigation', this.#boundHandleNavigation); // deprecated name, still sent by hosts
|
|
396
402
|
}
|
|
@@ -417,19 +423,22 @@ export class TestItemToSpeech extends LitElement {
|
|
|
417
423
|
render() {
|
|
418
424
|
return html `<slot></slot>`;
|
|
419
425
|
}
|
|
420
|
-
/**
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
* the check in updated() does not catch it.
|
|
424
|
-
*/
|
|
425
|
-
#handleItemConnected(event) {
|
|
426
|
-
if (this.#readingElements === null)
|
|
427
|
-
return;
|
|
428
|
-
// In item-ref mode the event came through our own item-ref, so it is always ours.
|
|
429
|
-
const identifier = event.detail?.identifier;
|
|
430
|
-
if (this.#itemRef || identifier === this._sessionContext?.navItemRefId)
|
|
426
|
+
/** Item-ref mode: our item rendered again, so the elements collected earlier are detached. */
|
|
427
|
+
#handleItemConnected() {
|
|
428
|
+
if (this.#readingElements !== null)
|
|
431
429
|
this.#resetReadingPosition();
|
|
432
430
|
}
|
|
431
|
+
/** Cursor mode: the active item and section, from the computed context. */
|
|
432
|
+
#activePosition() {
|
|
433
|
+
for (const part of this._computedContext?.testParts ?? []) {
|
|
434
|
+
for (const section of part.sections) {
|
|
435
|
+
if (!section.active)
|
|
436
|
+
continue;
|
|
437
|
+
return { item: section.items.find(item => item.active)?.identifier ?? null, section: section.identifier };
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return { item: null, section: null };
|
|
441
|
+
}
|
|
433
442
|
/**
|
|
434
443
|
* Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
|
|
435
444
|
* collected, so the next play reads the new content from the top. Unlike
|
|
@@ -475,45 +484,16 @@ export class TestItemToSpeech extends LitElement {
|
|
|
475
484
|
return this.#contentElement();
|
|
476
485
|
return this.#resolveItem()?.querySelector('qti-item-body') ?? null;
|
|
477
486
|
}
|
|
478
|
-
/**
|
|
487
|
+
/**
|
|
488
|
+
* The item to read: our item-ref's (item-ref mode), or the active one (cursor mode). The test
|
|
489
|
+
* looks the active one up in its own items (`computedContext.itemElement`), so a page with
|
|
490
|
+
* several tests showing the same item still reads the right one.
|
|
491
|
+
*/
|
|
479
492
|
#resolveItem() {
|
|
480
493
|
if (this.#itemRef)
|
|
481
494
|
return this.#itemRef.assessmentItem;
|
|
482
|
-
const
|
|
483
|
-
return
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Cursor mode: find the rendered item for an item-ref identifier. Our own `<qti-test>` first —
|
|
487
|
-
* a page can hold several tests showing the same item — then every root from here up to the
|
|
488
|
-
* document; each scope directly and in the `test-container` shadow roots inside it.
|
|
489
|
-
*/
|
|
490
|
-
#findItemInDom(identifier) {
|
|
491
|
-
const selector = `qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"] qti-assessment-item`;
|
|
492
|
-
const search = (scope) => {
|
|
493
|
-
const direct = scope.querySelector(selector);
|
|
494
|
-
if (direct)
|
|
495
|
-
return direct;
|
|
496
|
-
for (const container of Array.from(scope.querySelectorAll('test-container'))) {
|
|
497
|
-
const inShadow = container.shadowRoot?.querySelector(selector);
|
|
498
|
-
if (inShadow)
|
|
499
|
-
return inShadow;
|
|
500
|
-
}
|
|
501
|
-
return null;
|
|
502
|
-
};
|
|
503
|
-
const test = this.closest('qti-test');
|
|
504
|
-
const inTest = test && search(test);
|
|
505
|
-
if (inTest)
|
|
506
|
-
return inTest;
|
|
507
|
-
let root = this.getRootNode();
|
|
508
|
-
for (;;) {
|
|
509
|
-
const found = search(root);
|
|
510
|
-
if (found)
|
|
511
|
-
return found;
|
|
512
|
-
const host = root.host;
|
|
513
|
-
if (!host)
|
|
514
|
-
return null;
|
|
515
|
-
root = host.getRootNode();
|
|
516
|
-
}
|
|
495
|
+
const { item } = this.#activePosition();
|
|
496
|
+
return item ? (this._computedContext?.itemElement?.(item) ?? null) : null;
|
|
517
497
|
}
|
|
518
498
|
/** Update speech state on both the context (notifies children) and the host's CSS custom states. */
|
|
519
499
|
#setSpeechState(state) {
|
|
@@ -553,6 +533,7 @@ export class TestItemToSpeech extends LitElement {
|
|
|
553
533
|
// so the next call retries instead of getting stuck on an empty result forever.
|
|
554
534
|
if (!root)
|
|
555
535
|
return [];
|
|
536
|
+
this.#readingRoot = root;
|
|
556
537
|
// Collect block-level elements (and QTI prompt / choice elements) that contain readable text.
|
|
557
538
|
// Keep only the innermost matches so `<li><p>…</p></li>` is not read twice. Content hidden
|
|
558
539
|
// from assistive technology (`aria-hidden="true"`, e.g. decorative icons) is not read either.
|
|
@@ -852,10 +833,9 @@ export class TestItemToSpeech extends LitElement {
|
|
|
852
833
|
return right < 0 ? text.length - charIndex : right;
|
|
853
834
|
}
|
|
854
835
|
/**
|
|
855
|
-
* Add ::highlight() rules both to
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
* guaranteed to be in the DOM by the time navigation or speech starts.
|
|
836
|
+
* Add ::highlight() rules both to the shadow root the highlighted text lives in and to the
|
|
837
|
+
* document (safety net — spec allows document rules to apply across shadow DOM). Called lazily
|
|
838
|
+
* on first highlight use, once the reading elements have been collected.
|
|
859
839
|
*/
|
|
860
840
|
#ensureHighlightStyles() {
|
|
861
841
|
if (!('highlights' in CSS))
|
|
@@ -865,13 +845,10 @@ export class TestItemToSpeech extends LitElement {
|
|
|
865
845
|
if (!document.adoptedStyleSheets.includes(sheet)) {
|
|
866
846
|
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
867
847
|
}
|
|
868
|
-
// 2. Shadow roots the highlighted text may live in: test-container's, and
|
|
869
|
-
// root when the player itself sits inside a shadow tree (e.g. built into
|
|
848
|
+
// 2. Shadow roots the highlighted text may live in: the item's (e.g. test-container's), and
|
|
849
|
+
// the player's own root when the player itself sits inside a shadow tree (e.g. built into
|
|
850
|
+
// an item card).
|
|
870
851
|
const roots = new Set();
|
|
871
|
-
const testContainer = this.closest('test-navigation')?.querySelector('test-container') ??
|
|
872
|
-
this.testHost?.querySelector('test-container');
|
|
873
|
-
if (testContainer?.shadowRoot)
|
|
874
|
-
roots.add(testContainer.shadowRoot);
|
|
875
852
|
const ownRoot = this.getRootNode();
|
|
876
853
|
if (ownRoot instanceof ShadowRoot)
|
|
877
854
|
roots.add(ownRoot);
|
|
@@ -889,11 +866,8 @@ __decorate([
|
|
|
889
866
|
property({ type: String })
|
|
890
867
|
], TestItemToSpeech.prototype, "language", void 0);
|
|
891
868
|
__decorate([
|
|
892
|
-
consume({ context:
|
|
893
|
-
], TestItemToSpeech.prototype, "
|
|
894
|
-
__decorate([
|
|
895
|
-
consume({ context: testHostContext, subscribe: true })
|
|
896
|
-
], TestItemToSpeech.prototype, "testHost", void 0);
|
|
869
|
+
consume({ context: computedContext, subscribe: true })
|
|
870
|
+
], TestItemToSpeech.prototype, "_computedContext", void 0);
|
|
897
871
|
__decorate([
|
|
898
872
|
state(),
|
|
899
873
|
provide({ context: ttsContext })
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-item-to-speech.js","sourceRoot":"","sources":["../../src/tts/test-item-to-speech.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAO/C,iFAAiF;AAEjF,MAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,oCAAoC;AAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,8BAA8B;AAEjE,wEAAwE;AACxE,IAAI,cAAc,GAAyB,IAAI,CAAC;AAEhD,SAAS,iBAAiB;IACxB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,aAAa,EAAE,CAAC;QACrC,cAAc,CAAC,WAAW,CAAC;oBACX,iBAAiB;oBACjB,cAAc;KAC7B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAyBD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAa,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;AAE3E,iFAAiF;AAEjF,6FAA6F;AAC7F,+FAA+F;AAC/F,gDAAgD;AAChD,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,4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AI,gBAAgB,CAAC;;KAE9D,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { html, LitElement, css } from 'lit';\nimport { consume, provide, createContext } from '@lit/context';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../components/styles';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\n\n// ─── CSS Custom Highlight ─────────────────────────────────────────────────────\n\nconst HIGHLIGHT_ELEMENT = 'tts-element'; // navigation cursor — whole element\nconst HIGHLIGHT_WORD = 'tts-word'; // word boundary during speech\n\n// Shared across all instances — added to whichever shadow root needs it\nlet highlightSheet: CSSStyleSheet | null = null;\n\nfunction getHighlightSheet(): CSSStyleSheet {\n if (!highlightSheet) {\n highlightSheet = new CSSStyleSheet();\n highlightSheet.replaceSync(`\n ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }\n ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }\n `);\n }\n return highlightSheet;\n}\n\ntype SpeechState = 'idle' | 'playing' | 'paused';\n\n// ─── TTS Context ──────────────────────────────────────────────────────────────\n\nexport interface TtsContext {\n state: SpeechState;\n /** True while every reading element is highlighted and a click on one starts reading there. */\n picking: boolean;\n /** Index of the currently highlighted reading element (0-based). */\n currentElementIndex: number;\n /** Total number of navigable reading elements in the current item. */\n elementCount: number;\n play(): void;\n pause(): void;\n resume(): void;\n stop(): void;\n prevElement(): void;\n nextElement(): void;\n /** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */\n togglePick(): void;\n}\n\nexport { SpeechState };\nexport const ttsContext = createContext<TtsContext>(Symbol('tts-context'));\n\n// ─── Icons ────────────────────────────────────────────────────────────────────\n\n// Plain geometric glyphs on a 24-unit grid, painted in currentColor. SVG rather than text so\n// every button gets the same box: text glyphs (◀◀ ▶ ⏸ ■ ☞) differ in width, and some fall back\n// to an emoji font with different line metrics.\nconst ICONS = {\n play: 'M8 5v14l11-7z',\n pause: 'M6 5h4v14H6zM14 5h4v14h-4z',\n stop: 'M6 6h12v12H6z',\n prev: 'M6 5h2v14H6zM20 5v14L9 12z',\n next: 'M16 5h2v14h-2zM4 5v14l11-7z',\n pick: 'M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z'\n} as const;\n\n/** Default button content: the icon, plus a visually hidden label as the accessible name. */\nconst iconContent = (icon: keyof typeof ICONS, label: string) => {\n const svg = html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"${ICONS[icon]}\"></path>\n </svg>`;\n return html`${svg}<span class=\"label\">${label}</span>`;\n};\n\n// ─── Shared base for child button elements ────────────────────────────────────\n\n/**\n * Base class shared by all TTS control elements. Consumes `ttsContext` and\n * mirrors the current speech state onto CSS custom states so each child can\n * be styled with `:state(playing)`, `:state(paused)`, `:state(idle)`.\n */\nabstract class TtsButtonBase extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n }\n button {\n ${styles.btn};\n min-inline-size: var(--test-button-size, 2.25rem);\n padding-inline: 0.5rem;\n /* Containing block for the visually hidden .label. Without it the label is placed against\n the nearest positioned ancestor, which can sit outside a scroll container and make the\n page as tall as the scrolled content. */\n position: relative;\n }\n button:hover:not(:disabled) {\n ${styles.btnInteractive};\n }\n button:focus-visible {\n ${styles.focusRing};\n }\n button:disabled {\n ${styles.dis};\n }\n button[aria-pressed='true'],\n button[aria-pressed='true']:hover {\n background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));\n color: var(--test-button-selected-color, var(--qti-selected-color, #fff));\n }\n svg,\n ::slotted(svg) {\n flex: none;\n inline-size: var(--test-tts-icon-size, 1.125rem);\n block-size: var(--test-tts-icon-size, 1.125rem);\n }\n svg {\n fill: currentColor;\n }\n /* The default content is icon-only; this keeps the button's accessible name. */\n .label {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n `;\n\n /**\n * Accessible name of the button. Without it the default icon carries an English name, and\n * slotted content names the button by its text; set it when you slot an icon of your own,\n * which has no text to be named by.\n */\n @property({ type: String }) label?: string;\n\n #internals = this.attachInternals();\n\n @consume({ context: ttsContext, subscribe: true })\n protected _tts?: TtsContext;\n\n #mirroredState: SpeechState | undefined;\n #mirroredPicking = false;\n\n override updated(_changed: PropertyValues) {\n // `_tts` is a context field, not a reactive property, so it never shows up in `changed`:\n // compare against what was last mirrored instead.\n const state = this._tts?.state;\n const picking = this._tts?.picking ?? false;\n if (state === this.#mirroredState && picking === this.#mirroredPicking) return;\n this.#mirroredState = state;\n this.#mirroredPicking = picking;\n this.#internals.states.clear();\n if (state) this.#internals.states.add(state);\n if (picking) this.#internals.states.add('picking');\n }\n}\n\n// ─── Controller element ───────────────────────────────────────────────────────\n\n/**\n * `<test-item-to-speech>` is the controller and context provider. It manages\n * speech synthesis, word highlighting, and item element lookup. Compose your\n * own player by placing control elements as children.\n *\n * @example\n * ```html\n * <test-item-to-speech language=\"nl-NL\">\n * <test-tts-play></test-tts-play>\n * <test-tts-prev></test-tts-prev>\n * <test-tts-next></test-tts-next>\n * <test-tts-stop></test-tts-stop>\n * </test-item-to-speech>\n * ```\n *\n * The controller lays its controls out as a wrapping row; each control draws an icon button,\n * and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a\n * 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\n * defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.\n *\n * ### Language resolution\n *\n * Each reading element is spoken in the language of the nearest `lang` attribute:\n *\n * 1. `lang` (or `xml:lang`) on the element itself\n * 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across\n * shadow roots, anything wrapping the test\n * 3. `lang` on the document's `<html>` element\n * 4. the `language` attribute on `<test-item-to-speech>`\n *\n * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with\n * `xml:lang=\"en-GB\"` on a `<p>` or on the item root is honoured without further work.\n *\n * ### What is read\n *\n * Decided once per connect, by where the player is placed. The first rule that matches wins:\n *\n * 1. **Next to a stimulus placeholder** — the player shares its parent with a\n * `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the\n * player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the\n * placeholder: loading a stimulus replaces the placeholder's content. Items and navigation\n * are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts\n * over on the new content.\n * 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked\n * `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes\n * on one container; the player reads the readable elements inside it. Navigation is ignored.\n * The reading list is rebuilt when the player starts from the top, and when an element in it\n * has left the page — so a re-render of the content never interrupts speech.\n * 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,\n * so every item gets a player of its own: the player reads that item, and only that item.\n * The navigation cursor is ignored; speech stops when the player leaves the page with its item.\n * 4. **Anywhere else inside `<test-navigation>`** — e.g. a toolbar: the player follows the\n * navigation cursor and reads the active item of the computed context. Navigating stops\n * speech and starts the next item from the top.\n *\n * ```html\n * <!-- 1. a player for the shared reading text -->\n * <aside>\n * <test-item-to-speech>…</test-item-to-speech>\n * <div data-stimulus-idref=\"Stimulus1\"></div>\n * </aside>\n *\n * <!-- 2. a player for any other HTML -->\n * <div>\n * <test-item-to-speech>…</test-item-to-speech>\n * <section data-tts-content lang=\"nl-NL\">…</section>\n * </div>\n *\n * <!-- 3. one player per item -->\n * <qti-test>\n * <template item-ref>\n * <test-item-to-speech>…</test-item-to-speech>\n * {{ xmlDoc }}\n * </template>\n * …\n * </qti-test>\n *\n * <!-- 4. one player in the toolbar, following navigation -->\n * <test-navigation>\n * <header><test-item-to-speech>…</test-item-to-speech></header>\n * <test-container test-url=\"…\"></test-container>\n * </test-navigation>\n * ```\n *\n * In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the\n * player on the fresh content. An item player reads the item body as rendered: a stimulus\n * placed inside the item is read with it, one placed outside (mode 1) is not. Only one player\n * can speak at a time; starting one stops any other.\n *\n * Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,\n * `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)\n * or inside `aria-hidden=\"true\"`.\n *\n * ### Starting somewhere in the middle\n *\n * `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue\n * cursor highlight, and the first click on one of them leaves pick mode and starts reading\n * from that element. Pressing the button again leaves pick mode without reading.\n *\n * @cssstate idle - No speech active\n * @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click\n * @cssstate playing - Speech is playing\n * @cssstate paused - Speech is paused\n */\n\nexport class TestItemToSpeech extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--test-tts-gap, 0.25rem);\n }\n `;\n\n /** Fallback language when neither the item content nor the document declares one. */\n @property({ type: String }) language = 'nl-NL';\n\n /**\n * The test as `test-navigation` computes it: which item is active, and where it is rendered\n * (`itemElement`). Updated on navigation and whenever an item is rendered.\n */\n @consume({ context: computedContext, subscribe: true })\n protected _computedContext?: ComputedContext;\n\n @state()\n @provide({ context: ttsContext })\n _ttsContext!: TtsContext;\n\n #internals = this.attachInternals();\n\n // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The\n // placeholder itself is looked up on every use — a host may swap the element.\n #stimulusMode = false;\n // Stimulus mode: resets the player when the stimulus content next to it is replaced.\n #stimulusObserver: MutationObserver | null = null;\n // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.\n // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).\n #contentMode = false;\n // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.\n #itemRef: QtiAssessmentItemRef | null = null;\n // Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's\n // navigation request is heard.\n #eventHost: EventTarget | null = null;\n #boundHandleItemConnected = this.#handleItemConnected.bind(this);\n #boundHandleNavigation = () => this.#stop();\n\n // Cursor mode: the previous navigation position, to detect moving to another item or section.\n #prevNavItemRefId: string | null | undefined = undefined;\n #prevNavSectionId: string | null | undefined = undefined;\n\n // Current set of block-level reading elements for the item, and the root they were collected from\n #readingElements: Element[] | null = null;\n #readingRoot: Element | null = null;\n #currentElementIndex = 0;\n\n // Text nodes of the element currently being spoken (for word-boundary highlight)\n #textNodes: Text[] = [];\n\n // The utterance this player is speaking; lets the error handler tell \"our speech was\n // cancelled by another player\" apart from a cancel we issued ourselves.\n #currentUtterance: SpeechSynthesisUtterance | null = null;\n\n // Pick mode: all elements highlighted, a click on one starts reading from there.\n #picking = false;\n #pickRoot: EventTarget | null = null;\n #boundHandlePickClick = this.#handlePickClick.bind(this);\n\n // Set when the last element has been read: the cursor stays on it (so prev still works),\n // but the next play starts the item over instead of repeating that last element.\n #finished = false;\n\n // Two separate CSS Highlight objects\n #elementHighlight = new Highlight(); // whole-element cursor\n #wordHighlight = new Highlight(); // current word during speech\n\n constructor() {\n super();\n this._ttsContext = {\n state: 'idle',\n currentElementIndex: 0,\n elementCount: 0,\n play: () => this.#playSpeech(),\n pause: () => this.#pause(),\n resume: () => this.#resume(),\n stop: () => {\n this.#stopPicking();\n this.#stop();\n },\n prevElement: () => this.#prevElement(),\n nextElement: () => this.#nextElement(),\n togglePick: () => this.#togglePick(),\n picking: false\n };\n }\n\n // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the\n // render already under way instead of scheduling a second one (Lit's change-in-update).\n override willUpdate(changed: PropertyValues) {\n super.willUpdate(changed);\n // Stimulus, content and item-ref mode: the navigation cursor does not change what this player reads.\n if (this.#stimulusMode || this.#contentMode || this.#itemRef) return;\n // Cursor mode: moving to another item or section stops speech and starts over (ignore the\n // initial undefined → value transition). Section navigation leaves no item active, so it\n // needs its own check.\n const { item, section } = this.#activePosition();\n const itemChanged = this.#prevNavItemRefId !== undefined && this.#prevNavItemRefId !== item;\n const sectionChanged = this.#prevNavSectionId !== undefined && this.#prevNavSectionId !== section;\n // The same item rendered again (e.g. linking to the item already shown): the elements\n // collected earlier are detached. The context updates when an item renders, so check here.\n const rerendered =\n this.#readingElements !== null && this.#readingRoot !== null && this.#readingRoot !== this.#resolveReadingRoot();\n if (itemChanged || sectionChanged || rerendered) this.#resetReadingPosition();\n this.#prevNavItemRefId = item;\n this.#prevNavSectionId = section;\n }\n\n /** Stop speech and forget the collected reading elements, so the next play starts afresh. */\n #resetReadingPosition() {\n this.#stopPicking();\n this.#stop();\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#setSpeechState('idle');\n // NOTE: #ensureHighlightStyles() is called lazily on first highlight use\n // because the item to read may not be in the DOM yet at this point.\n this.#stimulusMode = this.#stimulusPlaceholder() !== null;\n if (this.#stimulusMode) {\n // Stimulus mode: neither items nor navigation decide what is read, only the content of the\n // placeholder. qti-components replaces it whenever it loads a stimulus (innerHTML, then\n // append), so watch the parent — that also catches a host swapping the placeholder itself.\n this.#stimulusObserver = new MutationObserver(records => {\n if (records.some(record => !this.contains(record.target))) this.#handleStimulusReplaced();\n });\n this.#stimulusObserver.observe(this.parentElement!, { childList: true, subtree: true });\n return;\n }\n // Content mode: plain HTML next to the player. Nothing to listen for: what is read only\n // depends on that element, and the reading list is rebuilt when it goes stale.\n this.#contentMode = this.#contentElement() !== null;\n if (this.#contentMode) return;\n this.#itemRef = this.closest<QtiAssessmentItemRef>('qti-assessment-item-ref');\n if (this.#itemRef) {\n // Item-ref mode: qti-assessment-item-connected (bubbles+composed) passes our own item-ref\n // when our item renders again.\n this.#eventHost = this.#itemRef;\n this.#eventHost.addEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n } else {\n // Cursor mode: cito-test-navigate fires synchronously on prev/next — stop right away\n // instead of waiting for the new position to arrive through the computed context.\n this.#eventHost = this.closest('test-navigation') ?? (this.getRootNode() as EventTarget);\n this.#eventHost.addEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost.addEventListener('qti-request-navigation', this.#boundHandleNavigation); // deprecated name, still sent by hosts\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n // Only silence the synthesizer if it is speaking for this player.\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#eventHost?.removeEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n this.#eventHost?.removeEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost?.removeEventListener('qti-request-navigation', this.#boundHandleNavigation);\n this.#eventHost = null;\n this.#itemRef = null;\n this.#stimulusObserver?.disconnect();\n this.#stimulusObserver = null;\n this.#stimulusMode = false;\n this.#contentMode = false;\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /** Item-ref mode: our item rendered again, so the elements collected earlier are detached. */\n #handleItemConnected() {\n if (this.#readingElements !== null) this.#resetReadingPosition();\n }\n\n /** Cursor mode: the active item and section, from the computed context. */\n #activePosition(): { item: string | null; section: string | null } {\n for (const part of this._computedContext?.testParts ?? []) {\n for (const section of part.sections) {\n if (!section.active) continue;\n return { item: section.items.find(item => item.active)?.identifier ?? null, section: section.identifier };\n }\n }\n return { item: null, section: null };\n }\n\n /**\n * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was\n * collected, so the next play reads the new content from the top. Unlike\n * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading\n * while an item player on the same page is speaking.\n */\n #handleStimulusReplaced() {\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n /**\n * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or\n * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because\n * loading replaces the placeholder's content.\n */\n #stimulusPlaceholder(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-stimulus-idref]') ?? null;\n }\n\n /**\n * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.\n * The marker goes on one container; the player finds the readable elements inside it.\n */\n #contentElement(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-tts-content]') ?? null;\n }\n\n /**\n * The element whose text is read: the stimulus body next to the player (stimulus mode), the\n * marked content next to it (content mode), or the item body of the item to read.\n */\n #resolveReadingRoot(): Element | null {\n if (this.#stimulusMode) return this.#stimulusPlaceholder()?.querySelector('qti-stimulus-body') ?? null;\n if (this.#contentMode) return this.#contentElement();\n return this.#resolveItem()?.querySelector('qti-item-body') ?? null;\n }\n\n /**\n * The item to read: our item-ref's (item-ref mode), or the active one (cursor mode). The test\n * looks the active one up in its own items (`computedContext.itemElement`), so a page with\n * several tests showing the same item still reads the right one.\n */\n #resolveItem(): QtiAssessmentItem | null {\n if (this.#itemRef) return this.#itemRef.assessmentItem;\n const { item } = this.#activePosition();\n return item ? ((this._computedContext?.itemElement?.(item) as QtiAssessmentItem | null) ?? null) : null;\n }\n\n /** Update speech state on both the context (notifies children) and the host's CSS custom states. */\n #setSpeechState(state: SpeechState) {\n this._ttsContext = { ...this._ttsContext, state };\n this.#internals.states.delete('idle');\n this.#internals.states.delete('playing');\n this.#internals.states.delete('paused');\n this.#internals.states.add(state);\n }\n\n /** Push currentElementIndex and elementCount into context so children can react. */\n #updateContext() {\n this._ttsContext = {\n ...this._ttsContext,\n currentElementIndex: this.#currentElementIndex,\n elementCount: this.#getReadingElements().length\n };\n }\n\n /**\n * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on\n * first call), filtered live for visibility on every call. Feedback and other\n * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a\n * CSS custom state reveals it) is excluded while hidden and picked up again once shown,\n * without needing to re-collect the candidate set.\n */\n #getReadingElements(): Element[] {\n // Content mode has no events or observer telling it the content changed (a framework like\n // React re-renders it at will). Rebuild the list once an element in it has left the page;\n // text changed inside an element needs nothing, it is read when that element is spoken.\n if (this.#contentMode && this.#readingElements?.some(el => !el.isConnected)) {\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n }\n if (this.#readingElements === null) {\n const root = this.#resolveReadingRoot();\n // Leave the cache empty (rather than `[]`) while the item or stimulus has not rendered yet,\n // so the next call retries instead of getting stuck on an empty result forever.\n if (!root) return [];\n this.#readingRoot = root;\n\n // Collect block-level elements (and QTI prompt / choice elements) that contain readable text.\n // Keep only the innermost matches so `<li><p>…</p></li>` is not read twice. Content hidden\n // from assistive technology (`aria-hidden=\"true\"`, e.g. decorative icons) is not read either.\n const selector =\n 'p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice';\n this.#readingElements = Array.from(root.querySelectorAll(selector)).filter(\n el =>\n (el.textContent ?? '').trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden=\"true\"]')\n );\n }\n\n return this.#readingElements.filter(el => this.#isVisible(el));\n }\n\n /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */\n #isVisible(element: Element): boolean {\n if (typeof element.checkVisibility === 'function') {\n return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });\n }\n // Older Safari (< 17.4) fallback: display:none leaves no client rects. Doesn't catch\n // visibility:hidden, which still occupies layout, but display:none is what QTI feedback\n // elements actually use (see qti-feedback-block/qti-feedback-inline default styles).\n return element.getClientRects().length > 0;\n }\n\n /**\n * Resolve the speech language for a reading element.\n * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.\n * Empty `lang=\"\"` is treated as absent.\n */\n #resolveLang(element: Element): string {\n let node: Element | null = element;\n while (node) {\n const lang = node.getAttribute('lang') || node.getAttribute('xml:lang');\n if (lang?.trim()) return lang.trim();\n node = node.parentElement ?? (node.getRootNode() as ShadowRoot).host ?? null;\n }\n const documentLang = document.documentElement.getAttribute('lang');\n if (documentLang?.trim()) return documentLang.trim();\n return this.language;\n }\n\n #playSpeech() {\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stopPicking();\n // speechSynthesis is one global queue: another player mid-sentence would otherwise\n // finish first and this one would silently wait its turn.\n speechSynthesis.cancel();\n if (this.#finished) {\n this.#finished = false;\n this.#currentElementIndex = 0;\n }\n // Content mode: starting from the top rebuilds the list, so elements the page added since\n // the last read (a framework re-render) are included.\n if (this.#contentMode && this.#currentElementIndex === 0) this.#readingElements = null;\n this.#speakElement(this.#currentElementIndex);\n }\n\n /** Speak the element at the given index, then auto-advance when it ends. */\n #speakElement(index: number) {\n const elements = this.#getReadingElements();\n\n if (index >= elements.length) {\n // Finished all elements — stay on the last element so the user can walk back with prev\n this.#clearWordHighlight();\n this.#currentElementIndex = elements.length - 1;\n if (elements.length > 0) this.#highlightElement(elements[this.#currentElementIndex]);\n this.#finished = true;\n this.#setSpeechState('idle');\n this.#updateContext();\n return;\n }\n\n this.#currentElementIndex = index;\n this.#finished = false;\n this.#updateContext();\n\n const element = elements[index];\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(element);\n\n // Collect text nodes of this element for word-boundary mapping\n this.#textNodes = this.#collectTextNodes(element);\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n\n if (!text.trim()) {\n // Skip blank element and move to next\n this.#speakElement(index + 1);\n return;\n }\n\n const utterance = new SpeechSynthesisUtterance(text);\n utterance.lang = this.#resolveLang(element);\n utterance.rate = 1;\n\n utterance.onboundary = (event: SpeechSynthesisEvent) => {\n if (event.name !== 'word') return;\n this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);\n };\n\n utterance.onend = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearWordHighlight();\n this.#speakElement(this.#currentElementIndex + 1);\n };\n\n // Fires when speech is cancelled from outside this player (another player starting,\n // or the browser); a cancel we issued ourselves has already cleared #currentUtterance.\n utterance.onerror = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n };\n\n this.#currentUtterance = utterance;\n speechSynthesis.speak(utterance);\n this.#setSpeechState('playing');\n }\n\n #pause() {\n speechSynthesis.pause();\n this.#setSpeechState('paused');\n }\n\n #resume() {\n speechSynthesis.resume();\n this.#setSpeechState('playing');\n }\n\n #stop() {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n }\n\n // ─── Pick mode ────────────────────────────────────────────────────────────\n\n #togglePick() {\n if (this.#picking) this.#stopPicking();\n else this.#startPicking();\n }\n\n /** Highlight every reading element and wait for a click on one of them. */\n #startPicking() {\n // Content mode: pick from the page as it is now, like starting from the top does.\n if (this.#contentMode) this.#readingElements = null;\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stop();\n this.#picking = true;\n this.#internals.states.add('picking');\n this.#highlightElements(elements);\n // Listen on the item's root so the click is seen before any interaction handles it — in\n // pick mode a click on a choice picks the sentence, it does not answer the question.\n this.#pickRoot = elements[0].getRootNode();\n this.#pickRoot.addEventListener('click', this.#boundHandlePickClick, true);\n this._ttsContext = { ...this._ttsContext, picking: true };\n }\n\n #stopPicking() {\n if (!this.#picking) return;\n this.#picking = false;\n this.#internals.states.delete('picking');\n this.#pickRoot?.removeEventListener('click', this.#boundHandlePickClick, true);\n this.#pickRoot = null;\n this.#clearAllHighlights();\n this._ttsContext = { ...this._ttsContext, picking: false };\n }\n\n #handlePickClick(event: Event) {\n const elements = this.#getReadingElements();\n const path = event.composedPath();\n let index = elements.findIndex(el => path.includes(el));\n if (index < 0) {\n // Not on the text itself. A click on the choice or list item around it (its radio button,\n // the padding) still means \"this one\": take the first reading element inside it.\n const container = path.find(\n (node): node is Element => node instanceof Element && node.matches('qti-simple-choice, li, qti-prompt')\n );\n if (container) index = elements.findIndex(el => container.contains(el));\n }\n if (index < 0) return; // not on a highlighted element — stay in pick mode\n event.preventDefault();\n event.stopPropagation();\n this.#stopPicking();\n speechSynthesis.cancel();\n this.#speakElement(index);\n }\n\n #prevElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n #nextElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n /** Walk text nodes without crossing shadow DOM boundaries. */\n #collectTextNodes(root: Element): Text[] {\n const nodes: Text[] = [];\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n let node: Node | null;\n while ((node = walker.nextNode())) {\n // Text hidden from assistive technology inside a read element — a decorative icon in a\n // list item — is not spoken either. Skipped here, so speech and word highlight agree.\n if ((node.textContent ?? '').length > 0 && !node.parentElement?.closest('[aria-hidden=\"true\"]')) {\n nodes.push(node as Text);\n }\n }\n return nodes;\n }\n\n /** Highlight the whole element as the navigation cursor (blue). */\n #highlightElement(element: Element) {\n this.#highlightElements([element]);\n }\n\n /** Put the blue cursor highlight on several elements at once (pick mode). */\n #highlightElements(elements: Element[]) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#elementHighlight.clear();\n for (const element of elements) {\n const range = new Range();\n range.selectNodeContents(element);\n this.#elementHighlight.add(range);\n }\n CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);\n }\n\n /** Highlight the current word within #textNodes (yellow, during speech). */\n #updateWordHighlight(charIndex: number, charLength: number) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#wordHighlight.clear();\n\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));\n let offset = 0;\n let startNode: Text | null = null;\n let startOffset = 0;\n let endNode: Text | null = null;\n let endOffset = 0;\n\n for (const node of this.#textNodes) {\n const len = node.textContent?.length ?? 0;\n if (!startNode && offset + len > charIndex) {\n startNode = node;\n startOffset = charIndex - offset;\n }\n if (startNode && offset + len >= endIndex) {\n endNode = node;\n endOffset = endIndex - offset;\n break;\n }\n offset += len;\n }\n\n if (startNode && endNode) {\n const range = new Range();\n range.setStart(startNode, startOffset);\n range.setEnd(endNode, endOffset);\n this.#wordHighlight.add(range);\n CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);\n }\n }\n\n #clearWordHighlight() {\n if (!('highlights' in CSS)) return;\n this.#wordHighlight.clear();\n // The registry is shared by every player on the page: only drop the entry if it is ours.\n if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight) CSS.highlights.delete(HIGHLIGHT_WORD);\n }\n\n #clearAllHighlights() {\n if (!('highlights' in CSS)) return;\n this.#clearWordHighlight();\n this.#elementHighlight.clear();\n if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight) CSS.highlights.delete(HIGHLIGHT_ELEMENT);\n }\n\n /** Fallback word-length when charLength is 0. */\n #wordLengthAt(charIndex: number, text: string): number {\n const right = text.slice(charIndex).search(/\\s/);\n return right < 0 ? text.length - charIndex : right;\n }\n\n /**\n * Add ::highlight() rules both to the shadow root the highlighted text lives in and to the\n * document (safety net — spec allows document rules to apply across shadow DOM). Called lazily\n * on first highlight use, once the reading elements have been collected.\n */\n #ensureHighlightStyles() {\n if (!('highlights' in CSS)) return;\n const sheet = getHighlightSheet();\n\n // 1. Document-level rule — applies broadly regardless of shadow DOM depth\n if (!document.adoptedStyleSheets.includes(sheet)) {\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n }\n\n // 2. Shadow roots the highlighted text may live in: the item's (e.g. test-container's), and\n // the player's own root when the player itself sits inside a shadow tree (e.g. built into\n // an item card).\n const roots = new Set<ShadowRoot>();\n const ownRoot = this.getRootNode();\n if (ownRoot instanceof ShadowRoot) roots.add(ownRoot);\n const itemRoot = this.#readingElements?.[0]?.getRootNode();\n if (itemRoot instanceof ShadowRoot) roots.add(itemRoot);\n for (const root of roots) {\n if (!root.adoptedStyleSheets.includes(sheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n }\n }\n }\n}\n\n// ─── Child control elements ───────────────────────────────────────────────────\n\n/**\n * Play/pause/resume toggle button — always enabled, cycles through states.\n * Use named slots `play` and `pause` to customise the icons/labels independently; `label` and\n * `pause-label` name the button in each state (set them when the slotted content is an icon).\n *\n * @example\n * ```html\n * <test-tts-play>\n * <span slot=\"play\">Voorlezen</span>\n * <span slot=\"pause\">Pauzeren</span>\n * </test-tts-play>\n * ```\n *\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPlay extends TtsButtonBase {\n /** Accessible name of the button while speech is playing; see `label`. */\n @property({ type: String, attribute: 'pause-label' }) pauseLabel?: string;\n\n #toggle() {\n if (!this._tts) return;\n if (this._tts.state === 'idle') this._tts.play();\n else if (this._tts.state === 'playing') this._tts.pause();\n else this._tts.resume();\n }\n\n override render() {\n const playing = this._tts?.state === 'playing';\n return html`\n <button part=\"button\" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>\n ${playing\n ? html`<slot name=\"pause\">${iconContent('pause', this.pauseLabel ?? 'Pause')}</slot>`\n : html`<slot name=\"play\">${iconContent('play', this.label ?? 'Play')}</slot>`}\n </button>\n `;\n }\n}\n\n/**\n * Pause button — enabled only when playing.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPause extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'playing'}\n @click=${() => this._tts?.pause()}\n >\n <slot>${iconContent('pause', this.label ?? 'Pause')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Resume button — enabled only when paused.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsResume extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'paused'}\n @click=${() => this._tts?.resume()}\n >\n <slot>${iconContent('play', this.label ?? 'Resume')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsStop extends TtsButtonBase {\n override render() {\n const idle = this._tts?.state === 'idle' && !this._tts?.picking;\n return html`\n <button part=\"button\" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>\n <slot>${iconContent('stop', this.label ?? 'Stop')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Prev-element button — moves cursor to the previous reading element and pauses.\n * Disabled at the first element. Reading elements are collected lazily, so an element count\n * of 0 means \"not looked yet\" rather than \"nothing to read\": the button stays enabled and the\n * first click collects them.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPrev extends TtsButtonBase {\n override render() {\n const collected = (this._tts?.elementCount ?? 0) > 0;\n const atStart = (this._tts?.currentElementIndex ?? 0) === 0;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${collected && atStart}\n @click=${() => this._tts?.prevElement()}\n >\n <slot>${iconContent('prev', this.label ?? 'Previous sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Next-element button — moves cursor to the next reading element and pauses.\n * Disabled at the last element; enabled while the elements have not been collected yet\n * (see `TestTtsPrev`).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsNext extends TtsButtonBase {\n override render() {\n const count = this._tts?.elementCount ?? 0;\n const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${atEnd}\n @click=${() => this._tts?.nextElement()}\n >\n <slot>${iconContent('next', this.label ?? 'Next sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Pick button — toggles pick mode on the controller: every reading element is highlighted and\n * a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.\n * @cssstate idle / playing / paused\n * @cssstate picking\n * @csspart button\n */\n\nexport class TestTtsPick extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n aria-pressed=${this._tts?.picking ? 'true' : 'false'}\n @click=${() => this._tts?.togglePick()}\n >\n <slot>${iconContent('pick', this.label ?? 'Read from here')}</slot>\n </button>\n `;\n }\n}\n\n// ─── Global type declarations ─────────────────────────────────────────────────\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-to-speech': TestItemToSpeech;\n 'test-tts-play': TestTtsPlay;\n 'test-tts-pause': TestTtsPause;\n 'test-tts-resume': TestTtsResume;\n 'test-tts-stop': TestTtsStop;\n 'test-tts-prev': TestTtsPrev;\n 'test-tts-next': TestTtsNext;\n 'test-tts-pick': TestTtsPick;\n }\n}\n"]}
|
|
@@ -36,8 +36,19 @@ export interface QtiTestStateValue {
|
|
|
36
36
|
identifier: string;
|
|
37
37
|
value: string | string[] | null;
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* What each plugin keeps in the state, by plugin name. Empty here: a plugin adds its own entry by
|
|
41
|
+
* augmenting this interface (`declare module` on the module that declares it, with
|
|
42
|
+
* `interface QtiTestPluginState { bookmarks: string[] }`), and reads it with
|
|
43
|
+
* `pluginState(computedContext, 'bookmarks')`. The test never reads an entry; it
|
|
44
|
+
* stores and restores it, so a value must survive `JSON.stringify`.
|
|
45
|
+
*/
|
|
46
|
+
export interface QtiTestPluginState {
|
|
47
|
+
}
|
|
48
|
+
/** Where the candidate is, and what plugins keep. */
|
|
40
49
|
export interface QtiTestStateSession {
|
|
50
|
+
/** Plugin entries by plugin name. Entries of plugins that are not loaded are kept as they are. */
|
|
51
|
+
plugins?: Partial<QtiTestPluginState> & Record<string, unknown>;
|
|
41
52
|
navPartId?: string | null;
|
|
42
53
|
navSectionId?: string | null;
|
|
43
54
|
navItemRefId?: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qti-test-state.js","sourceRoot":"","sources":["../../src/types/qti-test-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"qti-test-state.js","sourceRoot":"","sources":["../../src/types/qti-test-state.ts"],"names":[],"mappings":"AA0DA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC","sourcesContent":["/**\n * Everything a host needs to persist to resume a candidate's test session, and nothing else.\n *\n * Read it from `qtiTest.state` or the `qti-state-changed` event, store it wherever you like —\n * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.\n *\n * Deliberately not here:\n * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes\n * from the item XML on every load, and persisting the answer key with the candidate's data is\n * both bloat and a leak;\n * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.\n * The shuffle `seed` in particular must be passed in again, or the restored order changes;\n * - `view`: a role the host decides, not something the candidate produced;\n * - anything computed — scores per section, `done`, `active` — which is rederived from this.\n */\nexport interface QtiTestState {\n /** Bumped on any incompatible change to this shape. A state with another version is ignored. */\n version: 1;\n test: {\n items: QtiTestStateItem[];\n /** Test-level outcome values. Only outcomes the test declares are restored. */\n outcomes: QtiTestStateValue[];\n };\n session: QtiTestStateSession;\n}\n\nexport interface QtiTestStateItem {\n /** The `qti-assessment-item-ref` identifier. */\n identifier: string;\n variables: (QtiTestStateValue & { type?: 'response' | 'outcome' | 'template' | 'context' })[];\n /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */\n state?: Record<string, string | null>;\n}\n\nexport interface QtiTestStateValue {\n identifier: string;\n value: string | string[] | null;\n}\n\n/**\n * What each plugin keeps in the state, by plugin name. Empty here: a plugin adds its own entry by\n * augmenting this interface (`declare module` on the module that declares it, with\n * `interface QtiTestPluginState { bookmarks: string[] }`), and reads it with\n * `pluginState(computedContext, 'bookmarks')`. The test never reads an entry; it\n * stores and restores it, so a value must survive `JSON.stringify`.\n */\n \nexport interface QtiTestPluginState {}\n\n/** Where the candidate is, and what plugins keep. */\nexport interface QtiTestStateSession {\n /** Plugin entries by plugin name. Entries of plugins that are not loaded are kept as they are. */\n plugins?: Partial<QtiTestPluginState> & Record<string, unknown>;\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n}\n\nexport const QTI_TEST_STATE_VERSION = 1;\n"]}
|