@qti-components/test 1.7.0 → 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/qti-assessment-item-ref/qti-assessment-item-ref.d.ts +8 -0
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +45 -5
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.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-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 +5 -2
- package/dist/elements.js +3 -2
- package/dist/elements.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
+
import type { ComputedContext, ComputedItem } from '@qti-components/base';
|
|
2
3
|
import type { QtiAssessmentItem } from '@qti-components/elements';
|
|
3
4
|
import type { TemplateFunction } from '@heximal/templates';
|
|
4
5
|
/**
|
|
@@ -16,6 +17,12 @@ export interface ItemRefTemplateModel {
|
|
|
16
17
|
identifier?: string;
|
|
17
18
|
href?: string;
|
|
18
19
|
category?: string;
|
|
20
|
+
/**
|
|
21
|
+
* This item's entry in the computed context, the same object the stamps
|
|
22
|
+
* iterate as `item`: `index` (1-based, null for info items), `score`,
|
|
23
|
+
* `maxScore`, `completed`, `active`, … Undefined until the test has computed it.
|
|
24
|
+
*/
|
|
25
|
+
item?: ComputedItem;
|
|
19
26
|
/** The element being rendered. */
|
|
20
27
|
itemRef: QtiAssessmentItemRef;
|
|
21
28
|
}
|
|
@@ -26,6 +33,7 @@ export declare class QtiAssessmentItemRef extends LitElement {
|
|
|
26
33
|
required?: boolean;
|
|
27
34
|
fixed?: boolean;
|
|
28
35
|
href?: string;
|
|
36
|
+
protected computedContext?: ComputedContext;
|
|
29
37
|
/**
|
|
30
38
|
* The `<qti-weight>` children of this ref, keyed by identifier — what
|
|
31
39
|
* `qti-test-variables`' `weight-identifier` resolves against.
|
|
@@ -5,8 +5,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { LitElement, nothing } from 'lit';
|
|
8
|
-
import { property } from 'lit/decorators.js';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { consume } from '@lit/context';
|
|
9
10
|
import { prepareTemplate } from '@heximal/templates';
|
|
11
|
+
import { computedContext } from '@qti-components/base';
|
|
10
12
|
// Converter function to interpret "true" and "false" as booleans
|
|
11
13
|
const stringToBooleanConverter = {
|
|
12
14
|
fromAttribute(value) {
|
|
@@ -22,9 +24,15 @@ export class QtiAssessmentItemRef extends LitElement {
|
|
|
22
24
|
super(...arguments);
|
|
23
25
|
this.xmlDoc = null;
|
|
24
26
|
this.myTemplate = null;
|
|
27
|
+
/**
|
|
28
|
+
* The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned
|
|
29
|
+
* once per document and template, not per render: re-renders from
|
|
30
|
+
* computed-context changes then hand Lit the same fragment, which it leaves
|
|
31
|
+
* alone, instead of rebuilding the item (and reloading its PCIs, which
|
|
32
|
+
* changes the context again).
|
|
33
|
+
*/
|
|
34
|
+
this.#rendered = null;
|
|
25
35
|
}
|
|
26
|
-
// @consume({ context: computedContext, subscribe: true })
|
|
27
|
-
// private computedContext: ComputedContext;
|
|
28
36
|
/**
|
|
29
37
|
* The `<qti-weight>` children of this ref, keyed by identifier — what
|
|
30
38
|
* `qti-test-variables`' `weight-identifier` resolves against.
|
|
@@ -109,11 +117,38 @@ export class QtiAssessmentItemRef extends LitElement {
|
|
|
109
117
|
detail: { identifier: this.identifier, href: this.href, category: this.category }
|
|
110
118
|
}));
|
|
111
119
|
}
|
|
120
|
+
#computedItem() {
|
|
121
|
+
for (const testPart of this.computedContext?.testParts ?? []) {
|
|
122
|
+
for (const section of testPart.sections) {
|
|
123
|
+
const item = section.items.find(i => i.identifier === this.identifier);
|
|
124
|
+
if (item)
|
|
125
|
+
return item;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned
|
|
132
|
+
* once per document and template, not per render: re-renders from
|
|
133
|
+
* computed-context changes then hand Lit the same fragment, which it leaves
|
|
134
|
+
* alone, instead of rebuilding the item (and reloading its PCIs, which
|
|
135
|
+
* changes the context again).
|
|
136
|
+
*/
|
|
137
|
+
#rendered;
|
|
112
138
|
render() {
|
|
113
139
|
// Item refs connect before loading, and navigation clears their documents.
|
|
114
|
-
if (!this.xmlDoc)
|
|
140
|
+
if (!this.xmlDoc) {
|
|
141
|
+
this.#rendered = null;
|
|
115
142
|
return nothing;
|
|
116
|
-
|
|
143
|
+
}
|
|
144
|
+
if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {
|
|
145
|
+
this.#rendered = {
|
|
146
|
+
source: this.xmlDoc,
|
|
147
|
+
template: this.myTemplate,
|
|
148
|
+
doc: this.xmlDoc.cloneNode(true)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const xmlDoc = this.#rendered.doc;
|
|
117
152
|
if (!this.myTemplate)
|
|
118
153
|
return xmlDoc;
|
|
119
154
|
const model = {
|
|
@@ -121,6 +156,7 @@ export class QtiAssessmentItemRef extends LitElement {
|
|
|
121
156
|
identifier: this.identifier,
|
|
122
157
|
href: this.href,
|
|
123
158
|
category: this.category,
|
|
159
|
+
item: this.#computedItem(),
|
|
124
160
|
itemRef: this
|
|
125
161
|
};
|
|
126
162
|
return this.myTemplate(model);
|
|
@@ -141,6 +177,10 @@ __decorate([
|
|
|
141
177
|
__decorate([
|
|
142
178
|
property({ type: String })
|
|
143
179
|
], QtiAssessmentItemRef.prototype, "href", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
state(),
|
|
182
|
+
consume({ context: computedContext, subscribe: true })
|
|
183
|
+
], QtiAssessmentItemRef.prototype, "computedContext", void 0);
|
|
144
184
|
__decorate([
|
|
145
185
|
property({ type: Object, attribute: false })
|
|
146
186
|
], QtiAssessmentItemRef.prototype, "xmlDoc", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qti-assessment-item-ref.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAKrD,iEAAiE;AACjE,MAAM,wBAAwB,GAAG;IAC/B,aAAa,CAAC,KAAa;QACzB,OAAO,KAAK,KAAK,MAAM,CAAC;IAC1B,CAAC;IACD,WAAW,CAAC,KAAc;QACxB,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAClC,CAAC;CACF,CAAC;AAqBF,4CAA4C;AAC5C,MAAM,OAAO,oBAAqB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UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF;AA1H6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAmB;AAClB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAqB;AACkB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;sDAAoB;AACnB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;mDAAiB;AACtD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAe;AA6B1C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACN","sourcesContent":["import { LitElement, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TemplateFunction } from '@heximal/templates';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * The model a `<template item-ref>` is rendered with.\n *\n * Only what this element already knows: the item's parsed document and the\n * attributes off the item-ref itself. `itemRef` is the escape hatch — a\n * template that needs anything else (a click handler, a value from the host\n * app) reaches it through a property on the element, which the host is free to\n * set.\n */\nexport interface ItemRefTemplateModel {\n /** The item's parsed document, i.e. what the element renders by default. */\n xmlDoc: DocumentFragment;\n identifier?: string;\n href?: string;\n category?: string;\n /** The element being rendered. */\n itemRef: QtiAssessmentItemRef;\n}\n\n// @customElement('qti-assessment-item-ref')\nexport class QtiAssessmentItemRef extends LitElement {\n @property({ type: String }) category?: string;\n @property({ type: String }) identifier?: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) required?: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed?: boolean;\n @property({ type: String }) href?: string;\n\n // @consume({ context: computedContext, subscribe: true })\n // private computedContext: ComputedContext;\n\n /**\n * The `<qti-weight>` children of this ref, keyed by identifier — what\n * `qti-test-variables`' `weight-identifier` resolves against.\n *\n * Read on access rather than cached: the test document is rendered into this\n * element's light DOM, so the weights are not in place at construction time,\n * and outcome processing runs long after they are.\n */\n get weights(): Map<string, number> {\n const weights = new Map<string, number>();\n for (const weight of this.querySelectorAll(':scope > qti-weight')) {\n const identifier = weight.getAttribute('identifier');\n if (!identifier) continue;\n const value = Number(weight.getAttribute('value'));\n if (Number.isNaN(value)) {\n console.warn(`qti-weight \"${identifier}\" has a non-numeric value, ignoring it`);\n continue;\n }\n weights.set(identifier, value);\n }\n return weights;\n }\n\n @property({ type: Object, attribute: false })\n xmlDoc: DocumentFragment | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n get assessmentItem(): QtiAssessmentItem | null {\n return this.renderRoot?.querySelector('qti-assessment-item');\n }\n\n myTemplate: TemplateFunction | null = null;\n\n /**\n * The `<qti-test>` this ref belongs to, crossing shadow boundaries on the way\n * up.\n *\n * `<test-container>` renders its items into a shadow root, so an item-ref is\n * usually one hop below one; but it is also valid in plain light DOM, and a\n * host is free to nest it deeper. Climbing root by root covers all three\n * without assuming any of them.\n */\n #findTestElement(): Element | null {\n const own = this.closest('qti-test');\n if (own) return own;\n\n let root: Node = this.getRootNode();\n while (root instanceof ShadowRoot) {\n const test = root.host.closest('qti-test');\n if (test) return test;\n root = root.host.getRootNode();\n }\n // A Document, or a fragment that is not attached to one: nowhere left to climb.\n return null;\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n\n /*\n Optional per-item template, used to render extra things around an item —\n a bookmark, an index number, a score badge. Put it in the light DOM of\n your qti-test, and every item-ref in the test renders with it:\n\n <qti-test>\n <template item-ref>\n <div class=\"badge\">{{ identifier }}</div>\n {{ xmlDoc }}\n </template>\n …\n </qti-test>\n\n The template is the WHOLE render, so it has to place {{ xmlDoc }} itself;\n leaving it out renders the chrome and no item. Without a template the\n element renders the item on its own, exactly as before.\n\n Resolved once, on connect: one template serves every item, and everything\n that varies per item comes through the model (see ItemRefTemplateModel).\n */\n const templateElement = this.#findTestElement()?.querySelector<HTMLTemplateElement>('template[item-ref]');\n this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;\n this.requestUpdate();\n\n await this.updateComplete;\n\n this.dispatchEvent(\n new CustomEvent('qti-assessment-item-ref-connected', {\n bubbles: true,\n composed: true,\n detail: { identifier: this.identifier, href: this.href, category: this.category }\n })\n );\n }\n\n override render() {\n // Item refs connect before loading, and navigation clears their documents.\n if (!this.xmlDoc) return nothing;\n\n const xmlDoc = this.xmlDoc.cloneNode(true) as DocumentFragment;\n if (!this.myTemplate) return xmlDoc;\n\n const model: ItemRefTemplateModel = {\n xmlDoc,\n identifier: this.identifier,\n href: this.href,\n category: this.category,\n itemRef: this\n };\n return this.myTemplate(model);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item-ref': QtiAssessmentItemRef;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"qti-assessment-item-ref.js","sourceRoot":"","sources":["../../../src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,iEAAiE;AACjE,MAAM,wBAAwB,GAAG;IAC/B,aAAa,CAAC,KAAa;QACzB,O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E,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAqB;AACkB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;sDAAoB;AACnB;IAAjE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;mDAAiB;AACtD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAe;AAKhC;IAFT,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6DACX;AA0B5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACN","sourcesContent":["import { LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TemplateFunction } from '@heximal/templates';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * The model a `<template item-ref>` is rendered with.\n *\n * Only what this element already knows: the item's parsed document and the\n * attributes off the item-ref itself. `itemRef` is the escape hatch — a\n * template that needs anything else (a click handler, a value from the host\n * app) reaches it through a property on the element, which the host is free to\n * set.\n */\nexport interface ItemRefTemplateModel {\n /** The item's parsed document, i.e. what the element renders by default. */\n xmlDoc: DocumentFragment;\n identifier?: string;\n href?: string;\n category?: string;\n /**\n * This item's entry in the computed context, the same object the stamps\n * iterate as `item`: `index` (1-based, null for info items), `score`,\n * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.\n */\n item?: ComputedItem;\n /** The element being rendered. */\n itemRef: QtiAssessmentItemRef;\n}\n\n// @customElement('qti-assessment-item-ref')\nexport class QtiAssessmentItemRef extends LitElement {\n @property({ type: String }) category?: string;\n @property({ type: String }) identifier?: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) required?: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed?: boolean;\n @property({ type: String }) href?: string;\n\n // Only read by a <template item-ref>; subscribing re-renders it as scores come in\n @state()\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n /**\n * The `<qti-weight>` children of this ref, keyed by identifier — what\n * `qti-test-variables`' `weight-identifier` resolves against.\n *\n * Read on access rather than cached: the test document is rendered into this\n * element's light DOM, so the weights are not in place at construction time,\n * and outcome processing runs long after they are.\n */\n get weights(): Map<string, number> {\n const weights = new Map<string, number>();\n for (const weight of this.querySelectorAll(':scope > qti-weight')) {\n const identifier = weight.getAttribute('identifier');\n if (!identifier) continue;\n const value = Number(weight.getAttribute('value'));\n if (Number.isNaN(value)) {\n console.warn(`qti-weight \"${identifier}\" has a non-numeric value, ignoring it`);\n continue;\n }\n weights.set(identifier, value);\n }\n return weights;\n }\n\n @property({ type: Object, attribute: false })\n xmlDoc: DocumentFragment | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n get assessmentItem(): QtiAssessmentItem | null {\n return this.renderRoot?.querySelector('qti-assessment-item');\n }\n\n myTemplate: TemplateFunction | null = null;\n\n /**\n * The `<qti-test>` this ref belongs to, crossing shadow boundaries on the way\n * up.\n *\n * `<test-container>` renders its items into a shadow root, so an item-ref is\n * usually one hop below one; but it is also valid in plain light DOM, and a\n * host is free to nest it deeper. Climbing root by root covers all three\n * without assuming any of them.\n */\n #findTestElement(): Element | null {\n const own = this.closest('qti-test');\n if (own) return own;\n\n let root: Node = this.getRootNode();\n while (root instanceof ShadowRoot) {\n const test = root.host.closest('qti-test');\n if (test) return test;\n root = root.host.getRootNode();\n }\n // A Document, or a fragment that is not attached to one: nowhere left to climb.\n return null;\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n\n /*\n Optional per-item template, used to render extra things around an item —\n a bookmark, an index number, a score badge. Put it in the light DOM of\n your qti-test, and every item-ref in the test renders with it:\n\n <qti-test>\n <template item-ref>\n <div class=\"badge\">{{ identifier }}</div>\n {{ xmlDoc }}\n </template>\n …\n </qti-test>\n\n The template is the WHOLE render, so it has to place {{ xmlDoc }} itself;\n leaving it out renders the chrome and no item. Without a template the\n element renders the item on its own, exactly as before.\n\n Resolved once, on connect: one template serves every item, and everything\n that varies per item comes through the model (see ItemRefTemplateModel).\n */\n const templateElement = this.#findTestElement()?.querySelector<HTMLTemplateElement>('template[item-ref]');\n this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;\n this.requestUpdate();\n\n await this.updateComplete;\n\n this.dispatchEvent(\n new CustomEvent('qti-assessment-item-ref-connected', {\n bubbles: true,\n composed: true,\n detail: { identifier: this.identifier, href: this.href, category: this.category }\n })\n );\n }\n\n #computedItem(): ComputedItem | undefined {\n for (const testPart of this.computedContext?.testParts ?? []) {\n for (const section of testPart.sections) {\n const item = section.items.find(i => i.identifier === this.identifier);\n if (item) return item;\n }\n }\n return undefined;\n }\n\n /**\n * The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned\n * once per document and template, not per render: re-renders from\n * computed-context changes then hand Lit the same fragment, which it leaves\n * alone, instead of rebuilding the item (and reloading its PCIs, which\n * changes the context again).\n */\n #rendered: { source: DocumentFragment; template: TemplateFunction | null; doc: DocumentFragment } | null = null;\n\n override render() {\n // Item refs connect before loading, and navigation clears their documents.\n if (!this.xmlDoc) {\n this.#rendered = null;\n return nothing;\n }\n\n if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {\n this.#rendered = {\n source: this.xmlDoc,\n template: this.myTemplate,\n doc: this.xmlDoc.cloneNode(true) as DocumentFragment\n };\n }\n const xmlDoc = this.#rendered.doc;\n if (!this.myTemplate) return xmlDoc;\n\n const model: ItemRefTemplateModel = {\n xmlDoc,\n identifier: this.identifier,\n href: this.href,\n category: this.category,\n item: this.#computedItem(),\n itemRef: this\n };\n return this.myTemplate(model);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item-ref': QtiAssessmentItemRef;\n }\n}\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const form: import("lit").CSSResult;
|
|
2
2
|
export declare const btn: import("lit").CSSResult;
|
|
3
|
+
/** Hover and keyboard focus; paint only, so the box never moves. */
|
|
4
|
+
export declare const btnInteractive: import("lit").CSSResult;
|
|
5
|
+
export declare const focusRing: import("lit").CSSResult;
|
|
3
6
|
export declare const dis: import("lit").CSSResult;
|
|
4
7
|
export declare const ind: import("lit").CSSResult;
|
|
@@ -1,20 +1,45 @@
|
|
|
1
1
|
// /* eslint-disable lit-plugin(no-invalid-css) */
|
|
2
2
|
import { css } from 'lit';
|
|
3
|
+
/*
|
|
4
|
+
* The resting look of the test controls (next, prev, item/section links, TTS buttons).
|
|
5
|
+
*
|
|
6
|
+
* Paint reads the qti-theme tokens, so a theme or brand that re-values them repaints the test
|
|
7
|
+
* chrome along with the items; every token has a literal fallback equal to the theme's own
|
|
8
|
+
* default, so the controls look the same without qti-theme loaded. A `--test-button-*` slot
|
|
9
|
+
* in front of each token repaints the test controls alone.
|
|
10
|
+
*/
|
|
3
11
|
export const form = css `
|
|
4
12
|
display: inline-flex;
|
|
5
13
|
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
gap: 0.375em;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
min-block-size: var(--test-button-size, 2.25rem);
|
|
18
|
+
padding: 0 0.875rem;
|
|
19
|
+
font: inherit;
|
|
20
|
+
line-height: 1.25;
|
|
6
21
|
cursor: pointer;
|
|
7
|
-
padding: 0.5rem 1rem;
|
|
8
|
-
border-radius: 0.25rem;
|
|
9
22
|
user-select: none;
|
|
23
|
+
border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
|
|
10
24
|
`;
|
|
11
25
|
export const btn = css `
|
|
12
|
-
background-color: lightgray;
|
|
13
26
|
${form};
|
|
27
|
+
background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
|
|
28
|
+
color: var(--test-button-color, var(--qti-component-color, inherit));
|
|
29
|
+
border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
|
|
30
|
+
var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
|
|
31
|
+
`;
|
|
32
|
+
/** Hover and keyboard focus; paint only, so the box never moves. */
|
|
33
|
+
export const btnInteractive = css `
|
|
34
|
+
background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
|
|
35
|
+
`;
|
|
36
|
+
export const focusRing = css `
|
|
37
|
+
outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
|
|
38
|
+
outline-offset: 2px;
|
|
14
39
|
`;
|
|
15
40
|
export const dis = css `
|
|
16
41
|
cursor: not-allowed;
|
|
17
|
-
opacity: 0.
|
|
42
|
+
opacity: 0.45;
|
|
18
43
|
`;
|
|
19
44
|
export const ind = css `
|
|
20
45
|
${form};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAatB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;;;;CAKP,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;CAEhC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;CAG3B,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;;;CAGrB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;CAEP,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\n/*\n * The resting look of the test controls (next, prev, item/section links, TTS buttons).\n *\n * Paint reads the qti-theme tokens, so a theme or brand that re-values them repaints the test\n * chrome along with the items; every token has a literal fallback equal to the theme's own\n * default, so the controls look the same without qti-theme loaded. A `--test-button-*` slot\n * in front of each token repaints the test controls alone.\n */\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--test-button-size, 2.25rem);\n padding: 0 0.875rem;\n font: inherit;\n line-height: 1.25;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));\n color: var(--test-button-color, var(--qti-component-color, inherit));\n border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)\n var(--test-button-border-color, var(--qti-component-border-color, #0175aa));\n`;\n\n/** Hover and keyboard focus; paint only, so the box never moves. */\nexport const btnInteractive = css`\n background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));\n`;\n\nexport const focusRing = css`\n outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);\n outline-offset: 2px;\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.45;\n`;\n\nexport const ind = css`\n ${form};\n border: 1px solid gray;\n`;\n"]}
|
|
@@ -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,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;Q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AI,CAAC,CAAC;QAChD,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,CAAC,CAAC;QAEhD,6EAA6E;QAC7E,+EAA+E;QAC/E,4EAA4E;QAC5E,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YAC/C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,sEAAsE;QACtE,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;YAC1E,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,UAAU,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,KAAK,KAAK,IAAI,UAAU,CAAC,iBAAiB,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AA/ES;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDACY;AAGpC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAGjC;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n this.dispatchEvent(new CustomEvent('test-end-attempt', { bubbles: true }));\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
|
|
@@ -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
|
}
|