@qti-components/test 1.6.2 → 1.8.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.
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.d.ts +38 -3
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +128 -16
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
- package/dist/components/qti-number-selected/qti-number-selected.d.ts +24 -0
- package/dist/components/qti-number-selected/qti-number-selected.js +42 -0
- package/dist/components/qti-number-selected/qti-number-selected.js.map +1 -0
- package/dist/components/qti-outcome-processing/qti-outcome-processing.js +12 -2
- package/dist/components/qti-outcome-processing/qti-outcome-processing.js.map +1 -1
- package/dist/components/qti-test-variables/qti-test-variables.js +28 -30
- package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -1
- package/dist/components/styles.d.ts +3 -0
- package/dist/components/styles.js +29 -4
- package/dist/components/styles.js.map +1 -1
- package/dist/components/test-check-item/test-check-item.js +6 -0
- package/dist/components/test-check-item/test-check-item.js.map +1 -1
- package/dist/components/test-end-attempt/test-end-attempt.js +6 -0
- package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
- package/dist/components/test-item-link/test-item-link.js +6 -0
- package/dist/components/test-item-link/test-item-link.js.map +1 -1
- package/dist/components/test-item-to-speech/test-item-to-speech.d.ts +82 -11
- package/dist/components/test-item-to-speech/test-item-to-speech.js +429 -62
- package/dist/components/test-item-to-speech/test-item-to-speech.js.map +1 -1
- package/dist/components/test-next/test-next.js +6 -0
- package/dist/components/test-next/test-next.js.map +1 -1
- package/dist/components/test-prev/test-prev.js +6 -0
- package/dist/components/test-prev/test-prev.js.map +1 -1
- package/dist/components/test-scoring-buttons/test-scoring-buttons.d.ts +1 -1
- package/dist/components/test-section-link/test-section-link.js +6 -0
- package/dist/components/test-section-link/test-section-link.js.map +1 -1
- package/dist/elements.d.ts +9 -2
- package/dist/elements.js +5 -2
- package/dist/elements.js.map +1 -1
- package/dist/internal/item-ref-selection.d.ts +27 -0
- package/dist/internal/item-ref-selection.js +44 -0
- package/dist/internal/item-ref-selection.js.map +1 -0
- package/dist/mixins/test-base.js +0 -1
- package/dist/mixins/test-base.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAKpC,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAU,UAAU,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAgB,gBAAgB,CAAC,CAAC;YAE7E,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAErF,YAAY,CAAC,OAAO,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\n\nimport * as styles from '../styles';\n\nimport type { QtiTest } from '../qti-test/qti-test';\nimport type { TestContainer } from '../test-container/test-container';\n\nexport class TestCheckItem extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n this.dispatchEvent(new CustomEvent('test-end-attempt', { bubbles: true }));\n const qtiTest = this.closest<QtiTest>('qti-test');\n const testContainer = qtiTest.querySelector<TestContainer>('test-container');\n\n const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', true);\n });\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAKpC,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAU,UAAU,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAgB,gBAAgB,CAAC,CAAC;YAE7E,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAErF,YAAY,CAAC,OAAO,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\n\nimport * as styles from '../styles';\n\nimport type { QtiTest } from '../qti-test/qti-test';\nimport type { TestContainer } from '../test-container/test-container';\n\nexport class TestCheckItem 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 constructor() {\n super();\n this.addEventListener('click', () => {\n this.dispatchEvent(new CustomEvent('test-end-attempt', { bubbles: true }));\n const qtiTest = this.closest<QtiTest>('qti-test');\n const testContainer = qtiTest.querySelector<TestContainer>('test-container');\n\n const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', true);\n });\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
|
|
@@ -20,6 +20,12 @@ export class TestEndAttempt extends LitElement {
|
|
|
20
20
|
:host {
|
|
21
21
|
${styles.btn};
|
|
22
22
|
}
|
|
23
|
+
:host(:hover:not([disabled])) {
|
|
24
|
+
${styles.btnInteractive};
|
|
25
|
+
}
|
|
26
|
+
:host(:focus-visible) {
|
|
27
|
+
${styles.focusRing};
|
|
28
|
+
}
|
|
23
29
|
:host([disabled]) {
|
|
24
30
|
${styles.dis};
|
|
25
31
|
}
|
|
@@ -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,GAAG;;GAEf,
|
|
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,KA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jC;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"]}
|
|
@@ -12,6 +12,12 @@ export class TestItemLink extends LitElement {
|
|
|
12
12
|
:host {
|
|
13
13
|
${styles.btn};
|
|
14
14
|
}
|
|
15
|
+
:host(:hover:not([disabled])) {
|
|
16
|
+
${styles.btnInteractive};
|
|
17
|
+
}
|
|
18
|
+
:host(:focus-visible) {
|
|
19
|
+
${styles.focusRing};
|
|
20
|
+
}
|
|
15
21
|
:host([disabled]) {
|
|
16
22
|
${styles.dis};
|
|
17
23
|
}
|
|
@@ -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,GAAG;;GAEf,
|
|
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"]}
|
|
@@ -4,6 +4,8 @@ import type { SessionContext } from '@qti-components/base';
|
|
|
4
4
|
type SpeechState = 'idle' | 'playing' | 'paused';
|
|
5
5
|
export interface TtsContext {
|
|
6
6
|
state: SpeechState;
|
|
7
|
+
/** True while every reading element is highlighted and a click on one starts reading there. */
|
|
8
|
+
picking: boolean;
|
|
7
9
|
/** Index of the currently highlighted reading element (0-based). */
|
|
8
10
|
currentElementIndex: number;
|
|
9
11
|
/** Total number of navigable reading elements in the current item. */
|
|
@@ -14,6 +16,8 @@ export interface TtsContext {
|
|
|
14
16
|
stop(): void;
|
|
15
17
|
prevElement(): void;
|
|
16
18
|
nextElement(): void;
|
|
19
|
+
/** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */
|
|
20
|
+
togglePick(): void;
|
|
17
21
|
}
|
|
18
22
|
export { SpeechState };
|
|
19
23
|
export declare const ttsContext: {
|
|
@@ -27,8 +31,14 @@ export declare const ttsContext: {
|
|
|
27
31
|
declare abstract class TtsButtonBase extends LitElement {
|
|
28
32
|
#private;
|
|
29
33
|
static styles: import("lit").CSSResult;
|
|
34
|
+
/**
|
|
35
|
+
* Accessible name of the button. Without it the default icon carries an English name, and
|
|
36
|
+
* slotted content names the button by its text; set it when you slot an icon of your own,
|
|
37
|
+
* which has no text to be named by.
|
|
38
|
+
*/
|
|
39
|
+
label?: string;
|
|
30
40
|
protected _tts?: TtsContext;
|
|
31
|
-
updated(
|
|
41
|
+
updated(_changed: PropertyValues): void;
|
|
32
42
|
}
|
|
33
43
|
/**
|
|
34
44
|
* `<test-item-to-speech>` is the controller and context provider. It manages
|
|
@@ -39,37 +49,82 @@ declare abstract class TtsButtonBase extends LitElement {
|
|
|
39
49
|
* ```html
|
|
40
50
|
* <test-item-to-speech language="nl-NL">
|
|
41
51
|
* <test-tts-play></test-tts-play>
|
|
42
|
-
* <test-tts-prev
|
|
43
|
-
* <test-tts-next
|
|
44
|
-
* <test-tts-stop
|
|
52
|
+
* <test-tts-prev></test-tts-prev>
|
|
53
|
+
* <test-tts-next></test-tts-next>
|
|
54
|
+
* <test-tts-stop></test-tts-stop>
|
|
45
55
|
* </test-item-to-speech>
|
|
46
56
|
* ```
|
|
47
57
|
*
|
|
58
|
+
* The controller lays its controls out as a wrapping row; each control draws an icon button,
|
|
59
|
+
* and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a
|
|
60
|
+
* 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
|
|
61
|
+
* defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.
|
|
62
|
+
*
|
|
63
|
+
* ### Language resolution
|
|
64
|
+
*
|
|
65
|
+
* Each reading element is spoken in the language of the nearest `lang` attribute:
|
|
66
|
+
*
|
|
67
|
+
* 1. `lang` (or `xml:lang`) on the element itself
|
|
68
|
+
* 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across
|
|
69
|
+
* shadow roots, anything wrapping the test
|
|
70
|
+
* 3. `lang` on the document's `<html>` element
|
|
71
|
+
* 4. the `language` attribute on `<test-item-to-speech>`
|
|
72
|
+
*
|
|
73
|
+
* The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with
|
|
74
|
+
* `xml:lang="en-GB"` on a `<p>` or on the item root is honoured without further work.
|
|
75
|
+
*
|
|
76
|
+
* ### Which item is read
|
|
77
|
+
*
|
|
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.
|
|
85
|
+
*
|
|
86
|
+
* Only one item can be spoken at a time; starting one player stops any other.
|
|
87
|
+
*
|
|
88
|
+
* ### Starting somewhere in the middle
|
|
89
|
+
*
|
|
90
|
+
* `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue
|
|
91
|
+
* cursor highlight, and the first click on one of them leaves pick mode and starts reading
|
|
92
|
+
* from that element. Pressing the button again leaves pick mode without reading.
|
|
93
|
+
*
|
|
48
94
|
* @cssstate idle - No speech active
|
|
95
|
+
* @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click
|
|
49
96
|
* @cssstate playing - Speech is playing
|
|
50
97
|
* @cssstate paused - Speech is paused
|
|
51
98
|
*/
|
|
52
99
|
export declare class TestItemToSpeech extends LitElement {
|
|
53
100
|
#private;
|
|
101
|
+
static styles: import("lit").CSSResult;
|
|
102
|
+
/** Fallback language when neither the item content nor the document declares one. */
|
|
54
103
|
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;
|
|
55
109
|
protected _sessionContext?: SessionContext;
|
|
56
110
|
_ttsContext: TtsContext;
|
|
57
111
|
constructor();
|
|
58
112
|
willUpdate(changed: PropertyValues): void;
|
|
59
|
-
updated(
|
|
113
|
+
updated(changed: PropertyValues): void;
|
|
60
114
|
connectedCallback(): void;
|
|
61
115
|
disconnectedCallback(): void;
|
|
62
116
|
render(): import("lit").TemplateResult<1>;
|
|
63
117
|
}
|
|
64
118
|
/**
|
|
65
119
|
* Play/pause/resume toggle button — always enabled, cycles through states.
|
|
66
|
-
* Use named slots `play` and `pause` to customise the icons/labels independently
|
|
120
|
+
* Use named slots `play` and `pause` to customise the icons/labels independently; `label` and
|
|
121
|
+
* `pause-label` name the button in each state (set them when the slotted content is an icon).
|
|
67
122
|
*
|
|
68
123
|
* @example
|
|
69
124
|
* ```html
|
|
70
125
|
* <test-tts-play>
|
|
71
|
-
* <span slot="play"
|
|
72
|
-
* <span slot="pause"
|
|
126
|
+
* <span slot="play">Voorlezen</span>
|
|
127
|
+
* <span slot="pause">Pauzeren</span>
|
|
73
128
|
* </test-tts-play>
|
|
74
129
|
* ```
|
|
75
130
|
*
|
|
@@ -78,6 +133,8 @@ export declare class TestItemToSpeech extends LitElement {
|
|
|
78
133
|
*/
|
|
79
134
|
export declare class TestTtsPlay extends TtsButtonBase {
|
|
80
135
|
#private;
|
|
136
|
+
/** Accessible name of the button while speech is playing; see `label`. */
|
|
137
|
+
pauseLabel?: string;
|
|
81
138
|
render(): import("lit").TemplateResult<1>;
|
|
82
139
|
}
|
|
83
140
|
/**
|
|
@@ -97,7 +154,7 @@ export declare class TestTtsResume extends TtsButtonBase {
|
|
|
97
154
|
render(): import("lit").TemplateResult<1>;
|
|
98
155
|
}
|
|
99
156
|
/**
|
|
100
|
-
* Stop button — enabled when playing or
|
|
157
|
+
* Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).
|
|
101
158
|
* @cssstate idle / playing / paused
|
|
102
159
|
* @csspart button
|
|
103
160
|
*/
|
|
@@ -106,7 +163,9 @@ export declare class TestTtsStop extends TtsButtonBase {
|
|
|
106
163
|
}
|
|
107
164
|
/**
|
|
108
165
|
* Prev-element button — moves cursor to the previous reading element and pauses.
|
|
109
|
-
* Disabled at the first element
|
|
166
|
+
* Disabled at the first element. Reading elements are collected lazily, so an element count
|
|
167
|
+
* of 0 means "not looked yet" rather than "nothing to read": the button stays enabled and the
|
|
168
|
+
* first click collects them.
|
|
110
169
|
* @cssstate idle / playing / paused
|
|
111
170
|
* @csspart button
|
|
112
171
|
*/
|
|
@@ -115,13 +174,24 @@ export declare class TestTtsPrev extends TtsButtonBase {
|
|
|
115
174
|
}
|
|
116
175
|
/**
|
|
117
176
|
* Next-element button — moves cursor to the next reading element and pauses.
|
|
118
|
-
* Disabled at the last element
|
|
177
|
+
* Disabled at the last element; enabled while the elements have not been collected yet
|
|
178
|
+
* (see `TestTtsPrev`).
|
|
119
179
|
* @cssstate idle / playing / paused
|
|
120
180
|
* @csspart button
|
|
121
181
|
*/
|
|
122
182
|
export declare class TestTtsNext extends TtsButtonBase {
|
|
123
183
|
render(): import("lit").TemplateResult<1>;
|
|
124
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Pick button — toggles pick mode on the controller: every reading element is highlighted and
|
|
187
|
+
* a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.
|
|
188
|
+
* @cssstate idle / playing / paused
|
|
189
|
+
* @cssstate picking
|
|
190
|
+
* @csspart button
|
|
191
|
+
*/
|
|
192
|
+
export declare class TestTtsPick extends TtsButtonBase {
|
|
193
|
+
render(): import("lit").TemplateResult<1>;
|
|
194
|
+
}
|
|
125
195
|
declare global {
|
|
126
196
|
interface HTMLElementTagNameMap {
|
|
127
197
|
'test-item-to-speech': TestItemToSpeech;
|
|
@@ -131,5 +201,6 @@ declare global {
|
|
|
131
201
|
'test-tts-stop': TestTtsStop;
|
|
132
202
|
'test-tts-prev': TestTtsPrev;
|
|
133
203
|
'test-tts-next': TestTtsNext;
|
|
204
|
+
'test-tts-pick': TestTtsPick;
|
|
134
205
|
}
|
|
135
206
|
}
|