@citolab/qti-components 9.2.0 → 9.4.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/cdn/index.global.js +1 -1
- package/cdn/index.js +359 -229
- package/dist/base.d.ts +10 -10
- package/dist/base.js +1 -1
- package/dist/{chunk-G5RQ5GKG.js → chunk-3BAQWO5C.js} +2 -2
- package/dist/{chunk-ZG7FBQFP.js → chunk-ACRN7YJM.js} +2 -2
- package/dist/{chunk-JLZCZVRX.js → chunk-B5XHZI2P.js} +2 -2
- package/dist/{chunk-RAJQKCQ3.js → chunk-B74SYQB2.js} +2 -2
- package/dist/{chunk-YIYHCHHM.js → chunk-BMXG7D2N.js} +2 -2
- package/dist/{chunk-FG5JAWSN.js → chunk-C3JPUV36.js} +2 -2
- package/dist/{chunk-7PXUE2GR.js → chunk-GNTO3IFM.js} +976 -296
- package/dist/chunk-GNTO3IFM.js.map +1 -0
- package/dist/{chunk-ZOQVTG5L.js → chunk-JHPQJDAV.js} +2 -2
- package/dist/{chunk-GPGUXZ3X.js → chunk-LKHRHFXO.js} +6 -6
- package/dist/{chunk-JGPWBIVD.js → chunk-MSGYZE6L.js} +2 -2
- package/dist/{chunk-YVZWNLF4.js → chunk-R7MMMDP7.js} +139 -18
- package/dist/chunk-R7MMMDP7.js.map +1 -0
- package/dist/{chunk-REKCRWJV.js → chunk-XEWGFAS4.js} +166 -104
- package/dist/chunk-XEWGFAS4.js.map +1 -0
- package/dist/{computed.types.d-DB5gfOh9.d.ts → computed.types.d-gJrBeUMG.d.ts} +1 -1
- package/dist/corrections.d.ts +9 -9
- package/dist/corrections.js +7 -7
- package/dist/elements.d.ts +46 -6
- package/dist/elements.js +5 -3
- package/dist/index.d.ts +12 -12
- package/dist/index.js +18 -12
- package/dist/{interaction.d-DegNJ5ZA.d.ts → interaction.d-g6XG0T0Z.d.ts} +2 -2
- package/dist/interactions.d.ts +4 -4
- package/dist/interactions.js +3 -3
- package/dist/item.d.ts +4 -4
- package/dist/item.js +3 -3
- package/dist/{item.types.d-BDFrq19E.d.ts → item.types.d-B55QkJ92.d.ts} +10 -0
- package/dist/loader.d.ts +2 -2
- package/dist/processing.d.ts +3 -3
- package/dist/processing.js +3 -3
- package/dist/qti-components-jsx.d.ts +628 -268
- package/dist/{qti-condition-expression.d-DLboq8bR.d.ts → qti-condition-expression.d-L7yb3Rzy.d.ts} +1 -1
- package/dist/{qti-expression.d-BksT9iLB.d.ts → qti-expression.d-CuaLjZ6g.d.ts} +1 -1
- package/dist/{qti-feedback.d-D-w6-mJv.d.ts → qti-feedback.d-wMYNVkkj.d.ts} +2 -3
- package/dist/{qti-item.d-D_-9_0e6.d.ts → qti-item.d-DgC1AQbY.d.ts} +1 -1
- package/dist/{qti-test.d-BfAZE6UF.d.ts → qti-test.d-Cud5Gvy0.d.ts} +278 -38
- package/dist/{qti-text-entry-interaction.d-CATtcPyX.d.ts → qti-text-entry-interaction.d-DKvz9ncv.d.ts} +2 -2
- package/dist/{session.context.d-Cjs0BkJB.d.ts → session.context.d-D5080LVx.d.ts} +3 -1
- package/dist/test.d.ts +58 -11
- package/dist/test.js +8 -4
- package/package.json +4 -4
- package/dist/chunk-7PXUE2GR.js.map +0 -1
- package/dist/chunk-REKCRWJV.js.map +0 -1
- package/dist/chunk-YVZWNLF4.js.map +0 -1
- /package/dist/{chunk-G5RQ5GKG.js.map → chunk-3BAQWO5C.js.map} +0 -0
- /package/dist/{chunk-ZG7FBQFP.js.map → chunk-ACRN7YJM.js.map} +0 -0
- /package/dist/{chunk-JLZCZVRX.js.map → chunk-B5XHZI2P.js.map} +0 -0
- /package/dist/{chunk-RAJQKCQ3.js.map → chunk-B74SYQB2.js.map} +0 -0
- /package/dist/{chunk-YIYHCHHM.js.map → chunk-BMXG7D2N.js.map} +0 -0
- /package/dist/{chunk-FG5JAWSN.js.map → chunk-C3JPUV36.js.map} +0 -0
- /package/dist/{chunk-ZOQVTG5L.js.map → chunk-JHPQJDAV.js.map} +0 -0
- /package/dist/{chunk-GPGUXZ3X.js.map → chunk-LKHRHFXO.js.map} +0 -0
- /package/dist/{chunk-JGPWBIVD.js.map → chunk-MSGYZE6L.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
QtiModalFeedback
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XEWGFAS4.js";
|
|
4
4
|
import {
|
|
5
5
|
item_css_default
|
|
6
6
|
} from "./chunk-A32YH4H5.js";
|
|
@@ -21,11 +21,12 @@ import {
|
|
|
21
21
|
qtiContext,
|
|
22
22
|
sessionContext,
|
|
23
23
|
testContext
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-R7MMMDP7.js";
|
|
25
25
|
|
|
26
26
|
// ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
|
|
27
27
|
import { LitElement, nothing as nothing2 } from "lit";
|
|
28
|
-
import { property } from "lit/decorators.js";
|
|
28
|
+
import { property, state } from "lit/decorators.js";
|
|
29
|
+
import { consume } from "@lit/context";
|
|
29
30
|
|
|
30
31
|
// ../../node_modules/.pnpm/@heximal+templates@0.1.5/node_modules/@heximal/templates/index.js
|
|
31
32
|
import { render as renderLit, nothing } from "lit-html";
|
|
@@ -1095,6 +1096,10 @@ var makeLitTemplate = (template) => {
|
|
|
1095
1096
|
return litTemplate;
|
|
1096
1097
|
};
|
|
1097
1098
|
|
|
1099
|
+
// ../qti-test/dist/internal/test-host.context.js
|
|
1100
|
+
import { createContext } from "@lit/context";
|
|
1101
|
+
var testHostContext = createContext(/* @__PURE__ */ Symbol("testHost"));
|
|
1102
|
+
|
|
1098
1103
|
// ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
|
|
1099
1104
|
var __decorate = function(decorators, target, key, desc) {
|
|
1100
1105
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1115,9 +1120,8 @@ var QtiAssessmentItemRef = class extends LitElement {
|
|
|
1115
1120
|
super(...arguments);
|
|
1116
1121
|
this.xmlDoc = null;
|
|
1117
1122
|
this.myTemplate = null;
|
|
1123
|
+
this.#rendered = null;
|
|
1118
1124
|
}
|
|
1119
|
-
// @consume({ context: computedContext, subscribe: true })
|
|
1120
|
-
// private computedContext: ComputedContext;
|
|
1121
1125
|
/**
|
|
1122
1126
|
* The `<qti-weight>` children of this ref, keyed by identifier — what
|
|
1123
1127
|
* `qti-test-variables`' `weight-identifier` resolves against.
|
|
@@ -1147,31 +1151,13 @@ var QtiAssessmentItemRef = class extends LitElement {
|
|
|
1147
1151
|
get assessmentItem() {
|
|
1148
1152
|
return this.renderRoot?.querySelector("qti-assessment-item");
|
|
1149
1153
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
*
|
|
1154
|
-
* `<test-container>` renders its items into a shadow root, so an item-ref is
|
|
1155
|
-
* usually one hop below one; but it is also valid in plain light DOM, and a
|
|
1156
|
-
* host is free to nest it deeper. Climbing root by root covers all three
|
|
1157
|
-
* without assuming any of them.
|
|
1158
|
-
*/
|
|
1159
|
-
#findTestElement() {
|
|
1160
|
-
const own = this.closest("qti-test");
|
|
1161
|
-
if (own)
|
|
1162
|
-
return own;
|
|
1163
|
-
let root = this.getRootNode();
|
|
1164
|
-
while (root instanceof ShadowRoot) {
|
|
1165
|
-
const test = root.host.closest("qti-test");
|
|
1166
|
-
if (test)
|
|
1167
|
-
return test;
|
|
1168
|
-
root = root.host.getRootNode();
|
|
1169
|
-
}
|
|
1170
|
-
return null;
|
|
1154
|
+
disconnectedCallback() {
|
|
1155
|
+
super.disconnectedCallback();
|
|
1156
|
+
this.testHost = void 0;
|
|
1171
1157
|
}
|
|
1172
1158
|
async connectedCallback() {
|
|
1173
1159
|
super.connectedCallback();
|
|
1174
|
-
const templateElement = this
|
|
1160
|
+
const templateElement = this.testHost?.querySelector("template[item-ref]");
|
|
1175
1161
|
this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;
|
|
1176
1162
|
this.requestUpdate();
|
|
1177
1163
|
await this.updateComplete;
|
|
@@ -1181,10 +1167,37 @@ var QtiAssessmentItemRef = class extends LitElement {
|
|
|
1181
1167
|
detail: { identifier: this.identifier, href: this.href, category: this.category }
|
|
1182
1168
|
}));
|
|
1183
1169
|
}
|
|
1170
|
+
#computedItem() {
|
|
1171
|
+
for (const testPart of this.computedContext?.testParts ?? []) {
|
|
1172
|
+
for (const section of testPart.sections) {
|
|
1173
|
+
const item = section.items.find((i) => i.identifier === this.identifier);
|
|
1174
|
+
if (item)
|
|
1175
|
+
return item;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
return void 0;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned
|
|
1182
|
+
* once per document and template, not per render: re-renders from
|
|
1183
|
+
* computed-context changes then hand Lit the same fragment, which it leaves
|
|
1184
|
+
* alone, instead of rebuilding the item (and reloading its PCIs, which
|
|
1185
|
+
* changes the context again).
|
|
1186
|
+
*/
|
|
1187
|
+
#rendered;
|
|
1184
1188
|
render() {
|
|
1185
|
-
if (!this.xmlDoc)
|
|
1189
|
+
if (!this.xmlDoc) {
|
|
1190
|
+
this.#rendered = null;
|
|
1186
1191
|
return nothing2;
|
|
1187
|
-
|
|
1192
|
+
}
|
|
1193
|
+
if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {
|
|
1194
|
+
this.#rendered = {
|
|
1195
|
+
source: this.xmlDoc,
|
|
1196
|
+
template: this.myTemplate,
|
|
1197
|
+
doc: this.xmlDoc.cloneNode(true)
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
const xmlDoc = this.#rendered.doc;
|
|
1188
1201
|
if (!this.myTemplate)
|
|
1189
1202
|
return xmlDoc;
|
|
1190
1203
|
const model = {
|
|
@@ -1192,6 +1205,7 @@ var QtiAssessmentItemRef = class extends LitElement {
|
|
|
1192
1205
|
identifier: this.identifier,
|
|
1193
1206
|
href: this.href,
|
|
1194
1207
|
category: this.category,
|
|
1208
|
+
item: this.#computedItem(),
|
|
1195
1209
|
itemRef: this
|
|
1196
1210
|
};
|
|
1197
1211
|
return this.myTemplate(model);
|
|
@@ -1212,12 +1226,19 @@ __decorate([
|
|
|
1212
1226
|
__decorate([
|
|
1213
1227
|
property({ type: String })
|
|
1214
1228
|
], QtiAssessmentItemRef.prototype, "href", void 0);
|
|
1229
|
+
__decorate([
|
|
1230
|
+
state(),
|
|
1231
|
+
consume({ context: computedContext, subscribe: true })
|
|
1232
|
+
], QtiAssessmentItemRef.prototype, "computedContext", void 0);
|
|
1215
1233
|
__decorate([
|
|
1216
1234
|
property({ type: Object, attribute: false })
|
|
1217
1235
|
], QtiAssessmentItemRef.prototype, "xmlDoc", void 0);
|
|
1236
|
+
__decorate([
|
|
1237
|
+
consume({ context: testHostContext, subscribe: true })
|
|
1238
|
+
], QtiAssessmentItemRef.prototype, "testHost", void 0);
|
|
1218
1239
|
|
|
1219
1240
|
// ../qti-test/dist/components/qti-assessment-section/qti-assessment-section.js
|
|
1220
|
-
import { consume } from "@lit/context";
|
|
1241
|
+
import { consume as consume2 } from "@lit/context";
|
|
1221
1242
|
import { html, LitElement as LitElement2 } from "lit";
|
|
1222
1243
|
import { property as property2 } from "lit/decorators.js";
|
|
1223
1244
|
var __decorate2 = function(decorators, target, key, desc) {
|
|
@@ -1279,11 +1300,11 @@ __decorate2([
|
|
|
1279
1300
|
property2({ type: String, attribute: "submission-mode" })
|
|
1280
1301
|
], QtiAssessmentSection.prototype, "submissionMode", void 0);
|
|
1281
1302
|
__decorate2([
|
|
1282
|
-
|
|
1303
|
+
consume2({ context: testContext, subscribe: true })
|
|
1283
1304
|
], QtiAssessmentSection.prototype, "_testContext", void 0);
|
|
1284
1305
|
|
|
1285
1306
|
// ../qti-test/dist/components/qti-assessment-test/qti-assessment-test.js
|
|
1286
|
-
import { consume as
|
|
1307
|
+
import { consume as consume3 } from "@lit/context";
|
|
1287
1308
|
import { html as html2, LitElement as LitElement3 } from "lit";
|
|
1288
1309
|
import { property as property3 } from "lit/decorators.js";
|
|
1289
1310
|
var __decorate3 = function(decorators, target, key, desc) {
|
|
@@ -1322,7 +1343,7 @@ __decorate3([
|
|
|
1322
1343
|
property3({ type: String })
|
|
1323
1344
|
], QtiAssessmentTest.prototype, "title", null);
|
|
1324
1345
|
__decorate3([
|
|
1325
|
-
|
|
1346
|
+
consume3({ context: testContext, subscribe: true })
|
|
1326
1347
|
], QtiAssessmentTest.prototype, "_testContext", void 0);
|
|
1327
1348
|
|
|
1328
1349
|
// ../qti-test/dist/components/qti-item-session-control/qti-item-session-control.js
|
|
@@ -1544,7 +1565,7 @@ __decorate5([
|
|
|
1544
1565
|
], QtiTestPart.prototype, "submissionMode", void 0);
|
|
1545
1566
|
|
|
1546
1567
|
// ../qti-test/dist/components/qti-test-variables/qti-test-variables.js
|
|
1547
|
-
import { consume as
|
|
1568
|
+
import { consume as consume4 } from "@lit/context";
|
|
1548
1569
|
var __decorate6 = function(decorators, target, key, desc) {
|
|
1549
1570
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1550
1571
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1587,7 +1608,7 @@ var QtiTestVariables = class extends QtiExpression {
|
|
|
1587
1608
|
}
|
|
1588
1609
|
};
|
|
1589
1610
|
__decorate6([
|
|
1590
|
-
|
|
1611
|
+
consume4({ context: testContext, subscribe: true })
|
|
1591
1612
|
], QtiTestVariables.prototype, "_testContext", void 0);
|
|
1592
1613
|
var QtiTestVariablesExpression = class {
|
|
1593
1614
|
constructor(testContext2, itemVariable, includedItems) {
|
|
@@ -1615,10 +1636,13 @@ var QtiTestVariablesExpression = class {
|
|
|
1615
1636
|
}
|
|
1616
1637
|
};
|
|
1617
1638
|
|
|
1639
|
+
// ../qti-test/dist/types/qti-test-state.js
|
|
1640
|
+
var QTI_TEST_STATE_VERSION = 1;
|
|
1641
|
+
|
|
1618
1642
|
// ../qti-test/dist/components/qti-test/qti-test.js
|
|
1619
|
-
import { provide as provide2 } from "@lit/context";
|
|
1643
|
+
import { ContextProvider, provide as provide2 } from "@lit/context";
|
|
1620
1644
|
import { html as html7, LitElement as LitElement8 } from "lit";
|
|
1621
|
-
import { state } from "lit/decorators.js";
|
|
1645
|
+
import { state as state2 } from "lit/decorators.js";
|
|
1622
1646
|
|
|
1623
1647
|
// ../qti-test/dist/mixins/test-navigation.mixin.js
|
|
1624
1648
|
import { property as property6 } from "lit/decorators.js";
|
|
@@ -1656,7 +1680,7 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1656
1680
|
/**
|
|
1657
1681
|
* Navigate to a specific item or section
|
|
1658
1682
|
* @param type - Navigation type ('item' or 'section')
|
|
1659
|
-
* @param id - Target identifier (optional, falls back to first
|
|
1683
|
+
* @param id - Target identifier (optional, falls back to the current position, or the first one before there is any)
|
|
1660
1684
|
*/
|
|
1661
1685
|
navigateTo(type, id) {
|
|
1662
1686
|
const targetId = id || this._getDefaultNavigationId(type);
|
|
@@ -1737,7 +1761,7 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1737
1761
|
// ===========================================
|
|
1738
1762
|
_getDefaultNavigationId(type) {
|
|
1739
1763
|
if (type === "section") {
|
|
1740
|
-
return this._testElement?.querySelector("qti-assessment-section")?.identifier;
|
|
1764
|
+
return this.sessionContext?.navSectionId ?? this._testElement?.querySelector("qti-assessment-section")?.identifier;
|
|
1741
1765
|
}
|
|
1742
1766
|
return this.sessionContext?.navItemRefId ?? this._testElement?.querySelector("qti-assessment-item-ref")?.identifier;
|
|
1743
1767
|
}
|
|
@@ -1903,10 +1927,9 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1903
1927
|
console.warn("No stimulus content to apply");
|
|
1904
1928
|
return;
|
|
1905
1929
|
}
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");
|
|
1930
|
+
const root = stimulus.querySelector("qti-assessment-stimulus");
|
|
1931
|
+
if (!root) {
|
|
1932
|
+
console.warn("No qti-assessment-stimulus element found in stimulus");
|
|
1910
1933
|
return;
|
|
1911
1934
|
}
|
|
1912
1935
|
let targets = [];
|
|
@@ -1931,8 +1954,7 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1931
1954
|
}
|
|
1932
1955
|
targets.forEach((target, index) => {
|
|
1933
1956
|
target.innerHTML = "";
|
|
1934
|
-
|
|
1935
|
-
target.append(...clonedElements);
|
|
1957
|
+
target.append(root.cloneNode(true));
|
|
1936
1958
|
console.info(`Applied stimulus content to target ${index + 1}/${targets.length}`);
|
|
1937
1959
|
});
|
|
1938
1960
|
}
|
|
@@ -1989,7 +2011,7 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1989
2011
|
}
|
|
1990
2012
|
async _loadSingleItem(itemRef, navigationId, controller) {
|
|
1991
2013
|
try {
|
|
1992
|
-
const seed = this.
|
|
2014
|
+
const seed = this.qtiContext?.QTI_CONTEXT?.seed;
|
|
1993
2015
|
let transformer = (await qtiTransformItem().load(itemRef.href, controller.signal)).shuffleInteractions(seed);
|
|
1994
2016
|
if (this.postLoadTransformCallback) {
|
|
1995
2017
|
transformer = await this.postLoadTransformCallback(transformer, itemRef);
|
|
@@ -2180,7 +2202,7 @@ var TestBaseMixin = (superClass) => {
|
|
|
2180
2202
|
this.testContext = INITIAL_TEST_CONTEXT;
|
|
2181
2203
|
this.sessionContext = INITIAL_SESSION_CONTEXT;
|
|
2182
2204
|
this._updateItemInTestContext = (assessmentItem) => {
|
|
2183
|
-
const context = assessmentItem.
|
|
2205
|
+
const context = assessmentItem.itemContext;
|
|
2184
2206
|
const identifier = context.identifier;
|
|
2185
2207
|
const fullVariables = context.variables;
|
|
2186
2208
|
const itemContext = this.testContext.items.find((i) => i?.identifier === identifier);
|
|
@@ -2189,7 +2211,7 @@ var TestBaseMixin = (superClass) => {
|
|
|
2189
2211
|
return;
|
|
2190
2212
|
}
|
|
2191
2213
|
if (itemContext.variables?.length === 1) {
|
|
2192
|
-
this._updateItemVariablesInTestContext(identifier, fullVariables);
|
|
2214
|
+
this._updateItemVariablesInTestContext(identifier, fullVariables, void 0, context.valid);
|
|
2193
2215
|
} else {
|
|
2194
2216
|
const newVariables = [...assessmentItem.variables];
|
|
2195
2217
|
for (const variable of itemContext.variables) {
|
|
@@ -2201,22 +2223,54 @@ var TestBaseMixin = (superClass) => {
|
|
|
2201
2223
|
}
|
|
2202
2224
|
}
|
|
2203
2225
|
assessmentItem.variables = newVariables;
|
|
2226
|
+
if (itemContext.state) {
|
|
2227
|
+
assessmentItem.state = itemContext.state;
|
|
2228
|
+
}
|
|
2204
2229
|
}
|
|
2205
2230
|
};
|
|
2206
2231
|
this._initializeEventListeners();
|
|
2207
2232
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2233
|
+
/**
|
|
2234
|
+
* Sets values on one item from outside the candidate's session, e.g. a score from manual
|
|
2235
|
+
* scoring. Values are merged into the item's entry in the test context, and into the item
|
|
2236
|
+
* itself if it is on screen; a value the item has not seen yet is added, so this also works
|
|
2237
|
+
* before the item has loaded. To restore a whole session, assign `state` instead.
|
|
2238
|
+
*
|
|
2239
|
+
* The test context is replaced rather than changed in place, so its consumers update and
|
|
2240
|
+
* `qti-state-changed` fires.
|
|
2241
|
+
*
|
|
2242
|
+
* @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.
|
|
2243
|
+
* @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.
|
|
2244
|
+
*/
|
|
2245
|
+
updateItemVariables(itemRefID, values, state9) {
|
|
2246
|
+
this.testContext = {
|
|
2247
|
+
...this.testContext,
|
|
2248
|
+
items: this.testContext.items.map((item) => {
|
|
2249
|
+
if (item.identifier !== itemRefID)
|
|
2250
|
+
return item;
|
|
2251
|
+
const variables = [...item.variables ?? []];
|
|
2252
|
+
for (const { identifier, type, value } of values) {
|
|
2253
|
+
const index = variables.findIndex((v) => v.identifier === identifier);
|
|
2254
|
+
const updated = {
|
|
2255
|
+
...index >= 0 ? variables[index] : {},
|
|
2256
|
+
identifier,
|
|
2257
|
+
...type ? { type } : {},
|
|
2258
|
+
value: Array.isArray(value) ? [...value] : value
|
|
2259
|
+
};
|
|
2260
|
+
if (index >= 0)
|
|
2261
|
+
variables[index] = updated;
|
|
2262
|
+
else
|
|
2263
|
+
variables.push(updated);
|
|
2264
|
+
}
|
|
2265
|
+
return { ...item, variables, ...state9 ? { state: { ...state9 } } : {} };
|
|
2266
|
+
})
|
|
2267
|
+
};
|
|
2268
|
+
const assessmentItem = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(itemRefID)}"]`)?.assessmentItem;
|
|
2269
|
+
if (!assessmentItem)
|
|
2270
|
+
return;
|
|
2271
|
+
assessmentItem.variables = [...this.testContext.items.find((i) => i.identifier === itemRefID)?.variables ?? []];
|
|
2272
|
+
if (state9)
|
|
2273
|
+
assessmentItem.state = state9;
|
|
2220
2274
|
}
|
|
2221
2275
|
_initializeEventListeners() {
|
|
2222
2276
|
this.addEventListener("qti-testdoc-loaded", () => {
|
|
@@ -2250,10 +2304,10 @@ var TestBaseMixin = (superClass) => {
|
|
|
2250
2304
|
this._updateItemInTestContext(e.detail);
|
|
2251
2305
|
});
|
|
2252
2306
|
this.addEventListener("qti-item-context-updated", (e) => {
|
|
2253
|
-
this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state);
|
|
2307
|
+
this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state, e.detail.itemContext.valid);
|
|
2254
2308
|
});
|
|
2255
2309
|
}
|
|
2256
|
-
_updateItemVariablesInTestContext(identifier, variables,
|
|
2310
|
+
_updateItemVariablesInTestContext(identifier, variables, state9, valid) {
|
|
2257
2311
|
this.testContext = {
|
|
2258
2312
|
...this.testContext,
|
|
2259
2313
|
// Spread existing test context properties
|
|
@@ -2268,7 +2322,8 @@ var TestBaseMixin = (superClass) => {
|
|
|
2268
2322
|
const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
|
|
2269
2323
|
return matchingVariable ? { ...matchingVariable, ...variable } : variable;
|
|
2270
2324
|
}),
|
|
2271
|
-
...
|
|
2325
|
+
...state9 !== void 0 ? { state: state9 ? { ...state9 } : void 0 } : {},
|
|
2326
|
+
...valid !== void 0 ? { valid } : {}
|
|
2272
2327
|
};
|
|
2273
2328
|
})
|
|
2274
2329
|
};
|
|
@@ -2288,6 +2343,115 @@ var TestBaseMixin = (superClass) => {
|
|
|
2288
2343
|
var TestBase = class extends TestBaseMixin(LitElement7) {
|
|
2289
2344
|
};
|
|
2290
2345
|
|
|
2346
|
+
// ../qti-test/dist/mixins/test-state.mixin.js
|
|
2347
|
+
var copy = (value) => Array.isArray(value) ? [...value] : value ?? null;
|
|
2348
|
+
var isQtiTestState = (value) => {
|
|
2349
|
+
const state9 = value;
|
|
2350
|
+
return state9?.version === QTI_TEST_STATE_VERSION && Array.isArray(state9.test?.items) && Array.isArray(state9.test?.outcomes) && typeof state9.session === "object" && state9.session !== null;
|
|
2351
|
+
};
|
|
2352
|
+
var toState = (test, session) => ({
|
|
2353
|
+
version: QTI_TEST_STATE_VERSION,
|
|
2354
|
+
test: {
|
|
2355
|
+
items: (test?.items ?? []).filter((item) => item.identifier).map((item) => ({
|
|
2356
|
+
identifier: item.identifier,
|
|
2357
|
+
variables: (item.variables ?? []).map((v) => ({
|
|
2358
|
+
identifier: v.identifier,
|
|
2359
|
+
...v.type ? { type: v.type } : {},
|
|
2360
|
+
value: copy(v.value)
|
|
2361
|
+
})),
|
|
2362
|
+
...item.state ? { state: { ...item.state } } : {}
|
|
2363
|
+
})),
|
|
2364
|
+
outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
|
|
2365
|
+
},
|
|
2366
|
+
session: {
|
|
2367
|
+
...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
|
|
2368
|
+
...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
|
|
2369
|
+
...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
var TestStateMixin = (superClass) => {
|
|
2373
|
+
class TestStateClass extends superClass {
|
|
2374
|
+
/** A state assigned before the test connected, applied when it does. */
|
|
2375
|
+
#pending = null;
|
|
2376
|
+
/**
|
|
2377
|
+
* False while a test document is loading. Loading resets both contexts and rebuilds them, so
|
|
2378
|
+
* the intermediate states are empty — emitting one would invite a host to save it over the
|
|
2379
|
+
* real one.
|
|
2380
|
+
*/
|
|
2381
|
+
#ready = false;
|
|
2382
|
+
#lastEmitted = null;
|
|
2383
|
+
constructor(...args) {
|
|
2384
|
+
super(...args);
|
|
2385
|
+
this.addEventListener("qti-testdoc-loaded", () => {
|
|
2386
|
+
this.#ready = false;
|
|
2387
|
+
this.#lastEmitted = null;
|
|
2388
|
+
});
|
|
2389
|
+
this.addEventListener("qti-assessment-test-connected", () => {
|
|
2390
|
+
if (this.#pending) {
|
|
2391
|
+
this.#apply(this.#pending);
|
|
2392
|
+
this.#pending = null;
|
|
2393
|
+
}
|
|
2394
|
+
this.#ready = true;
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
get state() {
|
|
2398
|
+
return toState(this.testContext, this.sessionContext);
|
|
2399
|
+
}
|
|
2400
|
+
set state(value) {
|
|
2401
|
+
if (!isQtiTestState(value)) {
|
|
2402
|
+
console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);
|
|
2403
|
+
return;
|
|
2404
|
+
}
|
|
2405
|
+
if (!this.#ready) {
|
|
2406
|
+
this.#pending = value;
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
const { navItemRefId, navSectionId } = this.sessionContext;
|
|
2410
|
+
this.#apply(value);
|
|
2411
|
+
const restored = this.sessionContext;
|
|
2412
|
+
if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {
|
|
2413
|
+
this.#requestNavigation("item", restored.navItemRefId);
|
|
2414
|
+
} else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {
|
|
2415
|
+
this.#requestNavigation("section", restored.navSectionId);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
updated(changed) {
|
|
2419
|
+
super.updated(changed);
|
|
2420
|
+
if (!this.#ready || !(changed.has("testContext") || changed.has("sessionContext")))
|
|
2421
|
+
return;
|
|
2422
|
+
const state9 = this.state;
|
|
2423
|
+
const serialized = JSON.stringify(state9);
|
|
2424
|
+
if (serialized === this.#lastEmitted)
|
|
2425
|
+
return;
|
|
2426
|
+
this.#lastEmitted = serialized;
|
|
2427
|
+
this.dispatchEvent(new CustomEvent("qti-state-changed", { detail: state9, bubbles: true, composed: true }));
|
|
2428
|
+
}
|
|
2429
|
+
#apply(state9) {
|
|
2430
|
+
for (const saved of state9.test.items)
|
|
2431
|
+
this.updateItemVariables(saved.identifier, saved.variables, saved.state);
|
|
2432
|
+
const savedOutcomes = new Map(state9.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
|
|
2433
|
+
this.testContext = {
|
|
2434
|
+
...this.testContext,
|
|
2435
|
+
testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
|
|
2436
|
+
};
|
|
2437
|
+
this.sessionContext = { ...this.sessionContext, ...this.#validSession(state9.session) };
|
|
2438
|
+
}
|
|
2439
|
+
/** A stored position may point at an item or section a revised test no longer has. */
|
|
2440
|
+
#validSession(session) {
|
|
2441
|
+
const exists = (selector, id) => !!id && !!this._testElement?.querySelector(`${selector}[identifier="${CSS.escape(id)}"]`);
|
|
2442
|
+
return {
|
|
2443
|
+
...exists("qti-test-part", session.navPartId) ? { navPartId: session.navPartId } : {},
|
|
2444
|
+
...exists("qti-assessment-section", session.navSectionId) ? { navSectionId: session.navSectionId } : {},
|
|
2445
|
+
...this.testContext.items.some((i) => i.identifier === session.navItemRefId) ? { navItemRefId: session.navItemRefId } : {}
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
#requestNavigation(type, id) {
|
|
2449
|
+
this.dispatchEvent(new CustomEvent("qti-request-navigation", { detail: { type, id }, bubbles: true, composed: true }));
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
return TestStateClass;
|
|
2453
|
+
};
|
|
2454
|
+
|
|
2291
2455
|
// ../qti-test/dist/mixins/test-processing.mixin.js
|
|
2292
2456
|
var TestProcessingMixin = (superClass) => {
|
|
2293
2457
|
class TestProcessingElement extends superClass {
|
|
@@ -2307,7 +2471,7 @@ var TestProcessingMixin = (superClass) => {
|
|
|
2307
2471
|
});
|
|
2308
2472
|
}
|
|
2309
2473
|
outcomeProcessing() {
|
|
2310
|
-
const outcomeProcessor = this.querySelector("qti-outcome-processing");
|
|
2474
|
+
const outcomeProcessor = (this._testElement ?? this).querySelector("qti-outcome-processing");
|
|
2311
2475
|
if (!outcomeProcessor)
|
|
2312
2476
|
return false;
|
|
2313
2477
|
outcomeProcessor?.process();
|
|
@@ -2350,10 +2514,20 @@ var __decorate9 = function(decorators, target, key, desc) {
|
|
|
2350
2514
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2351
2515
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2352
2516
|
};
|
|
2353
|
-
var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixin(TestBaseMixin(LitElement8)))) {
|
|
2517
|
+
var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement8))))) {
|
|
2518
|
+
// TODO: Properly implement IQtiTest interface
|
|
2519
|
+
// export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {
|
|
2354
2520
|
constructor() {
|
|
2355
|
-
super(
|
|
2521
|
+
super();
|
|
2356
2522
|
this.configContext = {};
|
|
2523
|
+
this.qtiContext = {
|
|
2524
|
+
QTI_CONTEXT: {
|
|
2525
|
+
testIdentifier: "",
|
|
2526
|
+
candidateIdentifier: "",
|
|
2527
|
+
environmentIdentifier: "default"
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
new ContextProvider(this, { context: testHostContext, initialValue: this });
|
|
2357
2531
|
}
|
|
2358
2532
|
/**
|
|
2359
2533
|
* Renders the component's template.
|
|
@@ -2369,11 +2543,16 @@ var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixi
|
|
|
2369
2543
|
}
|
|
2370
2544
|
};
|
|
2371
2545
|
__decorate9([
|
|
2372
|
-
|
|
2546
|
+
state2(),
|
|
2373
2547
|
provide2({ context: configContext })
|
|
2374
2548
|
], QtiTest.prototype, "configContext", void 0);
|
|
2549
|
+
__decorate9([
|
|
2550
|
+
state2(),
|
|
2551
|
+
provide2({ context: qtiContext })
|
|
2552
|
+
], QtiTest.prototype, "qtiContext", void 0);
|
|
2375
2553
|
|
|
2376
2554
|
// ../qti-test/dist/components/test-check-item/test-check-item.js
|
|
2555
|
+
import { consume as consume5 } from "@lit/context";
|
|
2377
2556
|
import { css as css4, html as html8, LitElement as LitElement9 } from "lit";
|
|
2378
2557
|
|
|
2379
2558
|
// ../qti-test/dist/components/styles.js
|
|
@@ -2381,18 +2560,34 @@ import { css as css3 } from "lit";
|
|
|
2381
2560
|
var form = css3`
|
|
2382
2561
|
display: inline-flex;
|
|
2383
2562
|
align-items: center;
|
|
2563
|
+
justify-content: center;
|
|
2564
|
+
gap: 0.375em;
|
|
2565
|
+
box-sizing: border-box;
|
|
2566
|
+
min-block-size: var(--test-button-size, 2.25rem);
|
|
2567
|
+
padding: 0 0.875rem;
|
|
2568
|
+
font: inherit;
|
|
2569
|
+
line-height: 1.25;
|
|
2384
2570
|
cursor: pointer;
|
|
2385
|
-
padding: 0.5rem 1rem;
|
|
2386
|
-
border-radius: 0.25rem;
|
|
2387
2571
|
user-select: none;
|
|
2572
|
+
border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
|
|
2388
2573
|
`;
|
|
2389
2574
|
var btn = css3`
|
|
2390
|
-
background-color: lightgray;
|
|
2391
2575
|
${form};
|
|
2576
|
+
background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
|
|
2577
|
+
color: var(--test-button-color, var(--qti-component-color, inherit));
|
|
2578
|
+
border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
|
|
2579
|
+
var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
|
|
2580
|
+
`;
|
|
2581
|
+
var btnInteractive = css3`
|
|
2582
|
+
background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
|
|
2583
|
+
`;
|
|
2584
|
+
var focusRing = css3`
|
|
2585
|
+
outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
|
|
2586
|
+
outline-offset: 2px;
|
|
2392
2587
|
`;
|
|
2393
2588
|
var dis = css3`
|
|
2394
2589
|
cursor: not-allowed;
|
|
2395
|
-
opacity: 0.
|
|
2590
|
+
opacity: 0.45;
|
|
2396
2591
|
`;
|
|
2397
2592
|
var ind = css3`
|
|
2398
2593
|
${form};
|
|
@@ -2400,12 +2595,24 @@ var ind = css3`
|
|
|
2400
2595
|
`;
|
|
2401
2596
|
|
|
2402
2597
|
// ../qti-test/dist/components/test-check-item/test-check-item.js
|
|
2598
|
+
var __decorate10 = function(decorators, target, key, desc) {
|
|
2599
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2600
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2601
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2602
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2603
|
+
};
|
|
2403
2604
|
var TestCheckItem = class extends LitElement9 {
|
|
2404
2605
|
static {
|
|
2405
2606
|
this.styles = css4`
|
|
2406
2607
|
:host {
|
|
2407
2608
|
${btn};
|
|
2408
2609
|
}
|
|
2610
|
+
:host(:hover:not([disabled])) {
|
|
2611
|
+
${btnInteractive};
|
|
2612
|
+
}
|
|
2613
|
+
:host(:focus-visible) {
|
|
2614
|
+
${focusRing};
|
|
2615
|
+
}
|
|
2409
2616
|
:host([disabled]) {
|
|
2410
2617
|
${dis};
|
|
2411
2618
|
}
|
|
@@ -2415,8 +2622,9 @@ var TestCheckItem = class extends LitElement9 {
|
|
|
2415
2622
|
super();
|
|
2416
2623
|
this.addEventListener("click", () => {
|
|
2417
2624
|
this.dispatchEvent(new CustomEvent("test-end-attempt", { bubbles: true }));
|
|
2418
|
-
const
|
|
2419
|
-
|
|
2625
|
+
const testContainer = this.testHost?.querySelector("test-container");
|
|
2626
|
+
if (!testContainer)
|
|
2627
|
+
return;
|
|
2420
2628
|
const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
|
|
2421
2629
|
viewElements.forEach((element) => {
|
|
2422
2630
|
element.classList.toggle("show", true);
|
|
@@ -2427,13 +2635,16 @@ var TestCheckItem = class extends LitElement9 {
|
|
|
2427
2635
|
return html8` <slot></slot> `;
|
|
2428
2636
|
}
|
|
2429
2637
|
};
|
|
2638
|
+
__decorate10([
|
|
2639
|
+
consume5({ context: testHostContext, subscribe: true })
|
|
2640
|
+
], TestCheckItem.prototype, "testHost", void 0);
|
|
2430
2641
|
|
|
2431
2642
|
// ../qti-test/dist/components/test-container/test-container.js
|
|
2432
|
-
import { consume as
|
|
2643
|
+
import { consume as consume6 } from "@lit/context";
|
|
2433
2644
|
import { LitElement as LitElement10, html as html9 } from "lit";
|
|
2434
|
-
import { property as property8, state as
|
|
2645
|
+
import { property as property8, state as state3 } from "lit/decorators.js";
|
|
2435
2646
|
import { until } from "lit/directives/until.js";
|
|
2436
|
-
var
|
|
2647
|
+
var __decorate11 = function(decorators, target, key, desc) {
|
|
2437
2648
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2438
2649
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2439
2650
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2471,7 +2682,7 @@ var TestContainer = class extends LitElement10 {
|
|
|
2471
2682
|
try {
|
|
2472
2683
|
const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
|
|
2473
2684
|
let api = (await qtiTransformTest().load(this.testURL)).shuffleOrdering(explicitSeed);
|
|
2474
|
-
const qtiTest = this.
|
|
2685
|
+
const qtiTest = this.testHost;
|
|
2475
2686
|
if (qtiTest?.postLoadTestTransformCallback) {
|
|
2476
2687
|
const tempDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
|
|
2477
2688
|
const testElement = tempDoc.querySelector("qti-assessment-test");
|
|
@@ -2539,34 +2750,37 @@ var TestContainer = class extends LitElement10 {
|
|
|
2539
2750
|
`;
|
|
2540
2751
|
}
|
|
2541
2752
|
};
|
|
2542
|
-
|
|
2753
|
+
__decorate11([
|
|
2543
2754
|
property8({ attribute: false })
|
|
2544
2755
|
], TestContainer.prototype, "customElementRegistry", void 0);
|
|
2545
|
-
|
|
2756
|
+
__decorate11([
|
|
2546
2757
|
property8({ type: String, attribute: "test-url" })
|
|
2547
2758
|
], TestContainer.prototype, "testURL", void 0);
|
|
2548
|
-
|
|
2549
|
-
|
|
2759
|
+
__decorate11([
|
|
2760
|
+
state3()
|
|
2550
2761
|
], TestContainer.prototype, "testDoc", void 0);
|
|
2551
|
-
|
|
2552
|
-
|
|
2762
|
+
__decorate11([
|
|
2763
|
+
state3()
|
|
2553
2764
|
], TestContainer.prototype, "testXML", void 0);
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2765
|
+
__decorate11([
|
|
2766
|
+
consume6({ context: testHostContext, subscribe: true })
|
|
2767
|
+
], TestContainer.prototype, "testHost", void 0);
|
|
2768
|
+
__decorate11([
|
|
2769
|
+
state3(),
|
|
2770
|
+
consume6({ context: qtiContext, subscribe: true })
|
|
2557
2771
|
], TestContainer.prototype, "qtiContext", void 0);
|
|
2558
|
-
|
|
2772
|
+
__decorate11([
|
|
2559
2773
|
watch("testURL", { waitUntilFirstUpdate: true })
|
|
2560
2774
|
], TestContainer.prototype, "handleTestURLChange", null);
|
|
2561
|
-
|
|
2775
|
+
__decorate11([
|
|
2562
2776
|
watch("testXML", { waitUntilFirstUpdate: true })
|
|
2563
2777
|
], TestContainer.prototype, "handleTestXMLChange", null);
|
|
2564
2778
|
|
|
2565
2779
|
// ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
|
|
2566
2780
|
import { css as css5, html as html10, LitElement as LitElement11 } from "lit";
|
|
2567
2781
|
import { property as property9 } from "lit/decorators.js";
|
|
2568
|
-
import { consume as
|
|
2569
|
-
var
|
|
2782
|
+
import { consume as consume7 } from "@lit/context";
|
|
2783
|
+
var __decorate12 = function(decorators, target, key, desc) {
|
|
2570
2784
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2571
2785
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2572
2786
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2583,6 +2797,12 @@ var TestEndAttempt = class extends LitElement11 {
|
|
|
2583
2797
|
:host {
|
|
2584
2798
|
${btn};
|
|
2585
2799
|
}
|
|
2800
|
+
:host(:hover:not([disabled])) {
|
|
2801
|
+
${btnInteractive};
|
|
2802
|
+
}
|
|
2803
|
+
:host(:focus-visible) {
|
|
2804
|
+
${focusRing};
|
|
2805
|
+
}
|
|
2586
2806
|
:host([disabled]) {
|
|
2587
2807
|
${dis};
|
|
2588
2808
|
}
|
|
@@ -2632,21 +2852,21 @@ var TestEndAttempt = class extends LitElement11 {
|
|
|
2632
2852
|
return html10` <slot></slot> `;
|
|
2633
2853
|
}
|
|
2634
2854
|
};
|
|
2635
|
-
|
|
2636
|
-
|
|
2855
|
+
__decorate12([
|
|
2856
|
+
consume7({ context: computedContext, subscribe: true }),
|
|
2637
2857
|
property9({ attribute: false })
|
|
2638
2858
|
], TestEndAttempt.prototype, "computedContext", void 0);
|
|
2639
|
-
|
|
2859
|
+
__decorate12([
|
|
2640
2860
|
property9({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
2641
2861
|
], TestEndAttempt.prototype, "_internalDisabled", void 0);
|
|
2642
|
-
|
|
2862
|
+
__decorate12([
|
|
2643
2863
|
watch("computedContext")
|
|
2644
2864
|
], TestEndAttempt.prototype, "_handleTestElementChange", null);
|
|
2645
2865
|
|
|
2646
2866
|
// ../qti-test/dist/components/test-item-link/test-item-link.js
|
|
2647
2867
|
import { css as css6, html as html11, LitElement as LitElement12 } from "lit";
|
|
2648
2868
|
import { property as property10 } from "lit/decorators.js";
|
|
2649
|
-
var
|
|
2869
|
+
var __decorate13 = function(decorators, target, key, desc) {
|
|
2650
2870
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2651
2871
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2652
2872
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2658,6 +2878,12 @@ var TestItemLink = class extends LitElement12 {
|
|
|
2658
2878
|
:host {
|
|
2659
2879
|
${btn};
|
|
2660
2880
|
}
|
|
2881
|
+
:host(:hover:not([disabled])) {
|
|
2882
|
+
${btnInteractive};
|
|
2883
|
+
}
|
|
2884
|
+
:host(:focus-visible) {
|
|
2885
|
+
${focusRing};
|
|
2886
|
+
}
|
|
2661
2887
|
:host([disabled]) {
|
|
2662
2888
|
${dis};
|
|
2663
2889
|
}
|
|
@@ -2682,15 +2908,16 @@ var TestItemLink = class extends LitElement12 {
|
|
|
2682
2908
|
return html11` <slot></slot> `;
|
|
2683
2909
|
}
|
|
2684
2910
|
};
|
|
2685
|
-
|
|
2911
|
+
__decorate13([
|
|
2686
2912
|
property10({ type: String, attribute: "item-id" })
|
|
2687
2913
|
], TestItemLink.prototype, "itemId", void 0);
|
|
2688
2914
|
|
|
2689
2915
|
// ../qti-test/dist/components/test-item-to-speech/test-item-to-speech.js
|
|
2690
2916
|
import { html as html12, LitElement as LitElement13, css as css7 } from "lit";
|
|
2691
|
-
import { consume as
|
|
2692
|
-
import { property as property11, state as
|
|
2693
|
-
|
|
2917
|
+
import { consume as consume8, provide as provide3, createContext as createContext2 } from "@lit/context";
|
|
2918
|
+
import { property as property11, state as state4 } from "lit/decorators.js";
|
|
2919
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
2920
|
+
var __decorate14 = function(decorators, target, key, desc) {
|
|
2694
2921
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2695
2922
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2696
2923
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2709,66 +2936,165 @@ function getHighlightSheet() {
|
|
|
2709
2936
|
}
|
|
2710
2937
|
return highlightSheet;
|
|
2711
2938
|
}
|
|
2712
|
-
var ttsContext =
|
|
2939
|
+
var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
|
|
2940
|
+
var ICONS = {
|
|
2941
|
+
play: "M8 5v14l11-7z",
|
|
2942
|
+
pause: "M6 5h4v14H6zM14 5h4v14h-4z",
|
|
2943
|
+
stop: "M6 6h12v12H6z",
|
|
2944
|
+
prev: "M6 5h2v14H6zM20 5v14L9 12z",
|
|
2945
|
+
next: "M16 5h2v14h-2zM4 5v14l11-7z",
|
|
2946
|
+
pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
|
|
2947
|
+
};
|
|
2948
|
+
var iconContent = (icon, label) => {
|
|
2949
|
+
const svg = html12`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2950
|
+
<path d="${ICONS[icon]}"></path>
|
|
2951
|
+
</svg>`;
|
|
2952
|
+
return html12`${svg}<span class="label">${label}</span>`;
|
|
2953
|
+
};
|
|
2713
2954
|
var TtsButtonBase = class extends LitElement13 {
|
|
2714
2955
|
static {
|
|
2715
2956
|
this.styles = css7`
|
|
2716
2957
|
:host {
|
|
2717
|
-
display: inline-
|
|
2958
|
+
display: inline-flex;
|
|
2718
2959
|
}
|
|
2719
2960
|
button {
|
|
2720
|
-
|
|
2961
|
+
${btn};
|
|
2962
|
+
min-inline-size: var(--test-button-size, 2.25rem);
|
|
2963
|
+
padding-inline: 0.5rem;
|
|
2964
|
+
/* Containing block for the visually hidden .label. Without it the label is placed against
|
|
2965
|
+
the nearest positioned ancestor, which can sit outside a scroll container and make the
|
|
2966
|
+
page as tall as the scrolled content. */
|
|
2967
|
+
position: relative;
|
|
2968
|
+
}
|
|
2969
|
+
button:hover:not(:disabled) {
|
|
2970
|
+
${btnInteractive};
|
|
2971
|
+
}
|
|
2972
|
+
button:focus-visible {
|
|
2973
|
+
${focusRing};
|
|
2721
2974
|
}
|
|
2722
2975
|
button:disabled {
|
|
2723
|
-
|
|
2724
|
-
|
|
2976
|
+
${dis};
|
|
2977
|
+
}
|
|
2978
|
+
button[aria-pressed='true'],
|
|
2979
|
+
button[aria-pressed='true']:hover {
|
|
2980
|
+
background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
|
|
2981
|
+
color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
|
|
2982
|
+
}
|
|
2983
|
+
svg,
|
|
2984
|
+
::slotted(svg) {
|
|
2985
|
+
flex: none;
|
|
2986
|
+
inline-size: var(--test-tts-icon-size, 1.125rem);
|
|
2987
|
+
block-size: var(--test-tts-icon-size, 1.125rem);
|
|
2988
|
+
}
|
|
2989
|
+
svg {
|
|
2990
|
+
fill: currentColor;
|
|
2991
|
+
}
|
|
2992
|
+
/* The default content is icon-only; this keeps the button's accessible name. */
|
|
2993
|
+
.label {
|
|
2994
|
+
position: absolute;
|
|
2995
|
+
inline-size: 1px;
|
|
2996
|
+
block-size: 1px;
|
|
2997
|
+
overflow: hidden;
|
|
2998
|
+
clip-path: inset(50%);
|
|
2999
|
+
white-space: nowrap;
|
|
2725
3000
|
}
|
|
2726
3001
|
`;
|
|
2727
3002
|
}
|
|
2728
3003
|
#internals = this.attachInternals();
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
3004
|
+
#mirroredState;
|
|
3005
|
+
#mirroredPicking = false;
|
|
3006
|
+
updated(_changed) {
|
|
3007
|
+
const state9 = this._tts?.state;
|
|
3008
|
+
const picking = this._tts?.picking ?? false;
|
|
3009
|
+
if (state9 === this.#mirroredState && picking === this.#mirroredPicking)
|
|
3010
|
+
return;
|
|
3011
|
+
this.#mirroredState = state9;
|
|
3012
|
+
this.#mirroredPicking = picking;
|
|
3013
|
+
this.#internals.states.clear();
|
|
3014
|
+
if (state9)
|
|
3015
|
+
this.#internals.states.add(state9);
|
|
3016
|
+
if (picking)
|
|
3017
|
+
this.#internals.states.add("picking");
|
|
2735
3018
|
}
|
|
2736
3019
|
};
|
|
2737
|
-
|
|
2738
|
-
|
|
3020
|
+
__decorate14([
|
|
3021
|
+
property11({ type: String })
|
|
3022
|
+
], TtsButtonBase.prototype, "label", void 0);
|
|
3023
|
+
__decorate14([
|
|
3024
|
+
consume8({ context: ttsContext, subscribe: true })
|
|
2739
3025
|
], TtsButtonBase.prototype, "_tts", void 0);
|
|
2740
3026
|
var TestItemToSpeech = class extends LitElement13 {
|
|
3027
|
+
static {
|
|
3028
|
+
this.styles = css7`
|
|
3029
|
+
:host {
|
|
3030
|
+
display: inline-flex;
|
|
3031
|
+
flex-wrap: wrap;
|
|
3032
|
+
align-items: center;
|
|
3033
|
+
gap: var(--test-tts-gap, 0.25rem);
|
|
3034
|
+
}
|
|
3035
|
+
`;
|
|
3036
|
+
}
|
|
2741
3037
|
#internals;
|
|
2742
|
-
|
|
2743
|
-
|
|
3038
|
+
// Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
|
|
3039
|
+
// placeholder itself is looked up on every use — a host may swap the element.
|
|
3040
|
+
#stimulusMode;
|
|
3041
|
+
// Stimulus mode: resets the player when the stimulus content next to it is replaced.
|
|
3042
|
+
#stimulusObserver;
|
|
3043
|
+
// Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
|
|
3044
|
+
// Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
|
|
3045
|
+
#contentMode;
|
|
3046
|
+
// Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
|
|
3047
|
+
#itemRef;
|
|
3048
|
+
// Where the item-connected (and, in cursor mode, navigation) events are listened for.
|
|
2744
3049
|
#eventHost;
|
|
2745
|
-
|
|
3050
|
+
#boundHandleItemConnected;
|
|
3051
|
+
#boundHandleNavigation;
|
|
3052
|
+
// Cursor mode: the previous navigation position, to detect moving to another item or section.
|
|
3053
|
+
#prevNavItemRefId;
|
|
3054
|
+
#prevNavSectionId;
|
|
3055
|
+
// Current set of block-level reading elements for the item
|
|
2746
3056
|
#readingElements;
|
|
2747
3057
|
#currentElementIndex;
|
|
2748
3058
|
// Text nodes of the element currently being spoken (for word-boundary highlight)
|
|
2749
3059
|
#textNodes;
|
|
3060
|
+
// The utterance this player is speaking; lets the error handler tell "our speech was
|
|
3061
|
+
// cancelled by another player" apart from a cancel we issued ourselves.
|
|
3062
|
+
#currentUtterance;
|
|
3063
|
+
// Pick mode: all elements highlighted, a click on one starts reading from there.
|
|
3064
|
+
#picking;
|
|
3065
|
+
#pickRoot;
|
|
3066
|
+
#boundHandlePickClick;
|
|
3067
|
+
// Set when the last element has been read: the cursor stays on it (so prev still works),
|
|
3068
|
+
// but the next play starts the item over instead of repeating that last element.
|
|
3069
|
+
#finished;
|
|
2750
3070
|
// Two separate CSS Highlight objects
|
|
2751
3071
|
#elementHighlight;
|
|
2752
3072
|
// whole-element cursor
|
|
2753
3073
|
#wordHighlight;
|
|
2754
3074
|
// current word during speech
|
|
2755
|
-
// Tracks previous navItemRefId to detect item switches
|
|
2756
|
-
#prevNavItemRefId;
|
|
2757
|
-
#boundHandleNavigation;
|
|
2758
3075
|
constructor() {
|
|
2759
3076
|
super();
|
|
2760
3077
|
this.language = "nl-NL";
|
|
2761
3078
|
this.#internals = this.attachInternals();
|
|
2762
|
-
this.#
|
|
2763
|
-
this.#
|
|
3079
|
+
this.#stimulusMode = false;
|
|
3080
|
+
this.#stimulusObserver = null;
|
|
3081
|
+
this.#contentMode = false;
|
|
3082
|
+
this.#itemRef = null;
|
|
2764
3083
|
this.#eventHost = null;
|
|
3084
|
+
this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
|
|
3085
|
+
this.#boundHandleNavigation = () => this.#stop();
|
|
3086
|
+
this.#prevNavItemRefId = void 0;
|
|
3087
|
+
this.#prevNavSectionId = void 0;
|
|
2765
3088
|
this.#readingElements = null;
|
|
2766
3089
|
this.#currentElementIndex = 0;
|
|
2767
3090
|
this.#textNodes = [];
|
|
3091
|
+
this.#currentUtterance = null;
|
|
3092
|
+
this.#picking = false;
|
|
3093
|
+
this.#pickRoot = null;
|
|
3094
|
+
this.#boundHandlePickClick = this.#handlePickClick.bind(this);
|
|
3095
|
+
this.#finished = false;
|
|
2768
3096
|
this.#elementHighlight = new Highlight();
|
|
2769
3097
|
this.#wordHighlight = new Highlight();
|
|
2770
|
-
this.#prevNavItemRefId = void 0;
|
|
2771
|
-
this.#boundHandleNavigation = () => this.#stop();
|
|
2772
3098
|
this._ttsContext = {
|
|
2773
3099
|
state: "idle",
|
|
2774
3100
|
currentElementIndex: 0,
|
|
@@ -2776,103 +3102,273 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2776
3102
|
play: () => this.#playSpeech(),
|
|
2777
3103
|
pause: () => this.#pause(),
|
|
2778
3104
|
resume: () => this.#resume(),
|
|
2779
|
-
stop: () =>
|
|
3105
|
+
stop: () => {
|
|
3106
|
+
this.#stopPicking();
|
|
3107
|
+
this.#stop();
|
|
3108
|
+
},
|
|
2780
3109
|
prevElement: () => this.#prevElement(),
|
|
2781
|
-
nextElement: () => this.#nextElement()
|
|
3110
|
+
nextElement: () => this.#nextElement(),
|
|
3111
|
+
togglePick: () => this.#togglePick(),
|
|
3112
|
+
picking: false
|
|
2782
3113
|
};
|
|
2783
3114
|
}
|
|
3115
|
+
// willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
|
|
3116
|
+
// render already under way instead of scheduling a second one (Lit's change-in-update).
|
|
2784
3117
|
willUpdate(changed) {
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
const
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
this.#
|
|
2794
|
-
|
|
2795
|
-
this.#
|
|
3118
|
+
super.willUpdate(changed);
|
|
3119
|
+
if (this.#stimulusMode || this.#contentMode || this.#itemRef)
|
|
3120
|
+
return;
|
|
3121
|
+
const item = this._sessionContext?.navItemRefId ?? null;
|
|
3122
|
+
const section = this._sessionContext?.navSectionId ?? null;
|
|
3123
|
+
const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
|
|
3124
|
+
const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
|
|
3125
|
+
if (itemChanged || sectionChanged)
|
|
3126
|
+
this.#resetReadingPosition();
|
|
3127
|
+
this.#prevNavItemRefId = item;
|
|
3128
|
+
this.#prevNavSectionId = section;
|
|
3129
|
+
}
|
|
3130
|
+
/** Stop speech and forget the collected reading elements, so the next play starts afresh. */
|
|
3131
|
+
#resetReadingPosition() {
|
|
3132
|
+
this.#stopPicking();
|
|
3133
|
+
this.#stop();
|
|
3134
|
+
this.#readingElements = null;
|
|
3135
|
+
this.#currentElementIndex = 0;
|
|
3136
|
+
this.#finished = false;
|
|
3137
|
+
this.#updateContext();
|
|
2796
3138
|
}
|
|
2797
3139
|
connectedCallback() {
|
|
2798
3140
|
super.connectedCallback();
|
|
2799
3141
|
this.#setSpeechState("idle");
|
|
2800
|
-
this.#
|
|
3142
|
+
this.#stimulusMode = this.#stimulusPlaceholder() !== null;
|
|
3143
|
+
if (this.#stimulusMode) {
|
|
3144
|
+
this.#stimulusObserver = new MutationObserver((records) => {
|
|
3145
|
+
if (records.some((record) => !this.contains(record.target)))
|
|
3146
|
+
this.#handleStimulusReplaced();
|
|
3147
|
+
});
|
|
3148
|
+
this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
|
|
3149
|
+
return;
|
|
3150
|
+
}
|
|
3151
|
+
this.#contentMode = this.#contentElement() !== null;
|
|
3152
|
+
if (this.#contentMode)
|
|
3153
|
+
return;
|
|
3154
|
+
this.#itemRef = this.closest("qti-assessment-item-ref");
|
|
3155
|
+
this.#eventHost = this.#itemRef ?? this.closest("test-navigation") ?? this.testHost ?? this.getRootNode();
|
|
2801
3156
|
this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
2802
|
-
|
|
3157
|
+
if (!this.#itemRef) {
|
|
3158
|
+
this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
3159
|
+
}
|
|
2803
3160
|
}
|
|
2804
3161
|
disconnectedCallback() {
|
|
2805
3162
|
super.disconnectedCallback();
|
|
2806
|
-
|
|
3163
|
+
if (this.#currentUtterance) {
|
|
3164
|
+
this.#currentUtterance = null;
|
|
3165
|
+
speechSynthesis.cancel();
|
|
3166
|
+
}
|
|
3167
|
+
this.#stopPicking();
|
|
2807
3168
|
this.#clearAllHighlights();
|
|
2808
3169
|
this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
2809
3170
|
this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
2810
3171
|
this.#eventHost = null;
|
|
2811
|
-
this.#
|
|
3172
|
+
this.#itemRef = null;
|
|
3173
|
+
this.#stimulusObserver?.disconnect();
|
|
3174
|
+
this.#stimulusObserver = null;
|
|
3175
|
+
this.#stimulusMode = false;
|
|
3176
|
+
this.#contentMode = false;
|
|
2812
3177
|
}
|
|
2813
3178
|
render() {
|
|
2814
3179
|
return html12`<slot></slot>`;
|
|
2815
3180
|
}
|
|
3181
|
+
/**
|
|
3182
|
+
* An item (re)rendered. If it is ours — e.g. after navigating to the item already shown — the
|
|
3183
|
+
* elements collected earlier are detached now. That does not move the navigation cursor, so
|
|
3184
|
+
* the check in updated() does not catch it.
|
|
3185
|
+
*/
|
|
2816
3186
|
#handleItemConnected(event) {
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
3187
|
+
if (this.#readingElements === null)
|
|
3188
|
+
return;
|
|
3189
|
+
const identifier = event.detail?.identifier;
|
|
3190
|
+
if (this.#itemRef || identifier === this._sessionContext?.navItemRefId)
|
|
3191
|
+
this.#resetReadingPosition();
|
|
3192
|
+
}
|
|
3193
|
+
/**
|
|
3194
|
+
* Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
|
|
3195
|
+
* collected, so the next play reads the new content from the top. Unlike
|
|
3196
|
+
* #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
|
|
3197
|
+
* while an item player on the same page is speaking.
|
|
3198
|
+
*/
|
|
3199
|
+
#handleStimulusReplaced() {
|
|
3200
|
+
if (this.#currentUtterance) {
|
|
3201
|
+
this.#currentUtterance = null;
|
|
3202
|
+
speechSynthesis.cancel();
|
|
3203
|
+
}
|
|
3204
|
+
this.#stopPicking();
|
|
3205
|
+
this.#clearAllHighlights();
|
|
3206
|
+
this.#setSpeechState("idle");
|
|
3207
|
+
this.#readingElements = null;
|
|
3208
|
+
this.#currentElementIndex = 0;
|
|
3209
|
+
this.#finished = false;
|
|
3210
|
+
this.#updateContext();
|
|
3211
|
+
}
|
|
3212
|
+
/**
|
|
3213
|
+
* Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
|
|
3214
|
+
* null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
|
|
3215
|
+
* loading replaces the placeholder's content.
|
|
3216
|
+
*/
|
|
3217
|
+
#stimulusPlaceholder() {
|
|
3218
|
+
return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
|
|
3219
|
+
}
|
|
3220
|
+
/**
|
|
3221
|
+
* Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
|
|
3222
|
+
* The marker goes on one container; the player finds the readable elements inside it.
|
|
3223
|
+
*/
|
|
3224
|
+
#contentElement() {
|
|
3225
|
+
return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
|
|
3226
|
+
}
|
|
3227
|
+
/**
|
|
3228
|
+
* The element whose text is read: the stimulus body next to the player (stimulus mode), the
|
|
3229
|
+
* marked content next to it (content mode), or the item body of the item to read.
|
|
3230
|
+
*/
|
|
3231
|
+
#resolveReadingRoot() {
|
|
3232
|
+
if (this.#stimulusMode)
|
|
3233
|
+
return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
|
|
3234
|
+
if (this.#contentMode)
|
|
3235
|
+
return this.#contentElement();
|
|
3236
|
+
return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
|
|
3237
|
+
}
|
|
3238
|
+
/** The item to read: our item-ref's (item-ref mode), or the navigated one (cursor mode). */
|
|
3239
|
+
#resolveItem() {
|
|
3240
|
+
if (this.#itemRef)
|
|
3241
|
+
return this.#itemRef.assessmentItem;
|
|
3242
|
+
const identifier = this._sessionContext?.navItemRefId;
|
|
3243
|
+
return identifier ? this.#findItemInDom(identifier) : null;
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Cursor mode: find the rendered item for an item-ref identifier. Our own `<qti-test>` first —
|
|
3247
|
+
* a page can hold several tests showing the same item — then every root from here up to the
|
|
3248
|
+
* document; each scope directly and in the `test-container` shadow roots inside it.
|
|
3249
|
+
*/
|
|
3250
|
+
#findItemInDom(identifier) {
|
|
3251
|
+
const selector = `qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"] qti-assessment-item`;
|
|
3252
|
+
const search = (scope) => {
|
|
3253
|
+
const direct = scope.querySelector(selector);
|
|
3254
|
+
if (direct)
|
|
3255
|
+
return direct;
|
|
3256
|
+
for (const container of Array.from(scope.querySelectorAll("test-container"))) {
|
|
3257
|
+
const inShadow = container.shadowRoot?.querySelector(selector);
|
|
3258
|
+
if (inShadow)
|
|
3259
|
+
return inShadow;
|
|
3260
|
+
}
|
|
3261
|
+
return null;
|
|
3262
|
+
};
|
|
3263
|
+
const test = this.closest("qti-test");
|
|
3264
|
+
const inTest = test && search(test);
|
|
3265
|
+
if (inTest)
|
|
3266
|
+
return inTest;
|
|
3267
|
+
let root = this.getRootNode();
|
|
3268
|
+
for (; ; ) {
|
|
3269
|
+
const found = search(root);
|
|
3270
|
+
if (found)
|
|
3271
|
+
return found;
|
|
3272
|
+
const host = root.host;
|
|
3273
|
+
if (!host)
|
|
3274
|
+
return null;
|
|
3275
|
+
root = host.getRootNode();
|
|
2820
3276
|
}
|
|
2821
3277
|
}
|
|
2822
3278
|
/** Update speech state on both the context (notifies children) and the host's CSS custom states. */
|
|
2823
|
-
#setSpeechState(
|
|
2824
|
-
this._ttsContext = { ...this._ttsContext, state:
|
|
3279
|
+
#setSpeechState(state9) {
|
|
3280
|
+
this._ttsContext = { ...this._ttsContext, state: state9 };
|
|
2825
3281
|
this.#internals.states.delete("idle");
|
|
2826
3282
|
this.#internals.states.delete("playing");
|
|
2827
3283
|
this.#internals.states.delete("paused");
|
|
2828
|
-
this.#internals.states.add(
|
|
3284
|
+
this.#internals.states.add(state9);
|
|
2829
3285
|
}
|
|
2830
3286
|
/** Push currentElementIndex and elementCount into context so children can react. */
|
|
2831
3287
|
#updateContext() {
|
|
2832
3288
|
this._ttsContext = {
|
|
2833
3289
|
...this._ttsContext,
|
|
2834
3290
|
currentElementIndex: this.#currentElementIndex,
|
|
2835
|
-
elementCount: this.#
|
|
3291
|
+
elementCount: this.#getReadingElements().length
|
|
2836
3292
|
};
|
|
2837
3293
|
}
|
|
2838
|
-
/**
|
|
3294
|
+
/**
|
|
3295
|
+
* Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
|
|
3296
|
+
* first call), filtered live for visibility on every call. Feedback and other
|
|
3297
|
+
* conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
|
|
3298
|
+
* CSS custom state reveals it) is excluded while hidden and picked up again once shown,
|
|
3299
|
+
* without needing to re-collect the candidate set.
|
|
3300
|
+
*/
|
|
2839
3301
|
#getReadingElements() {
|
|
2840
|
-
if (this.#readingElements
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
this.#readingElements
|
|
2853
|
-
|
|
3302
|
+
if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
|
|
3303
|
+
this.#readingElements = null;
|
|
3304
|
+
this.#currentElementIndex = 0;
|
|
3305
|
+
this.#finished = false;
|
|
3306
|
+
}
|
|
3307
|
+
if (this.#readingElements === null) {
|
|
3308
|
+
const root = this.#resolveReadingRoot();
|
|
3309
|
+
if (!root)
|
|
3310
|
+
return [];
|
|
3311
|
+
const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
|
|
3312
|
+
this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
|
|
3313
|
+
}
|
|
3314
|
+
return this.#readingElements.filter((el) => this.#isVisible(el));
|
|
3315
|
+
}
|
|
3316
|
+
/** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
|
|
3317
|
+
#isVisible(element) {
|
|
3318
|
+
if (typeof element.checkVisibility === "function") {
|
|
3319
|
+
return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
|
|
3320
|
+
}
|
|
3321
|
+
return element.getClientRects().length > 0;
|
|
3322
|
+
}
|
|
3323
|
+
/**
|
|
3324
|
+
* Resolve the speech language for a reading element.
|
|
3325
|
+
* Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
|
|
3326
|
+
* Empty `lang=""` is treated as absent.
|
|
3327
|
+
*/
|
|
3328
|
+
#resolveLang(element) {
|
|
3329
|
+
let node = element;
|
|
3330
|
+
while (node) {
|
|
3331
|
+
const lang = node.getAttribute("lang") || node.getAttribute("xml:lang");
|
|
3332
|
+
if (lang?.trim())
|
|
3333
|
+
return lang.trim();
|
|
3334
|
+
node = node.parentElement ?? node.getRootNode().host ?? null;
|
|
3335
|
+
}
|
|
3336
|
+
const documentLang = document.documentElement.getAttribute("lang");
|
|
3337
|
+
if (documentLang?.trim())
|
|
3338
|
+
return documentLang.trim();
|
|
3339
|
+
return this.language;
|
|
2854
3340
|
}
|
|
2855
3341
|
#playSpeech() {
|
|
2856
3342
|
const elements = this.#getReadingElements();
|
|
2857
3343
|
if (!elements.length) {
|
|
2858
|
-
console.warn("test-item-to-speech: no readable elements found
|
|
3344
|
+
console.warn("test-item-to-speech: no readable elements found");
|
|
2859
3345
|
return;
|
|
2860
3346
|
}
|
|
3347
|
+
this.#stopPicking();
|
|
3348
|
+
speechSynthesis.cancel();
|
|
3349
|
+
if (this.#finished) {
|
|
3350
|
+
this.#finished = false;
|
|
3351
|
+
this.#currentElementIndex = 0;
|
|
3352
|
+
}
|
|
3353
|
+
if (this.#contentMode && this.#currentElementIndex === 0)
|
|
3354
|
+
this.#readingElements = null;
|
|
2861
3355
|
this.#speakElement(this.#currentElementIndex);
|
|
2862
3356
|
}
|
|
2863
3357
|
/** Speak the element at the given index, then auto-advance when it ends. */
|
|
2864
3358
|
#speakElement(index) {
|
|
2865
|
-
const elements = this.#
|
|
3359
|
+
const elements = this.#getReadingElements();
|
|
2866
3360
|
if (index >= elements.length) {
|
|
2867
3361
|
this.#clearWordHighlight();
|
|
2868
3362
|
this.#currentElementIndex = elements.length - 1;
|
|
2869
3363
|
if (elements.length > 0)
|
|
2870
3364
|
this.#highlightElement(elements[this.#currentElementIndex]);
|
|
3365
|
+
this.#finished = true;
|
|
2871
3366
|
this.#setSpeechState("idle");
|
|
2872
3367
|
this.#updateContext();
|
|
2873
3368
|
return;
|
|
2874
3369
|
}
|
|
2875
3370
|
this.#currentElementIndex = index;
|
|
3371
|
+
this.#finished = false;
|
|
2876
3372
|
this.#updateContext();
|
|
2877
3373
|
const element = elements[index];
|
|
2878
3374
|
element.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
@@ -2884,7 +3380,7 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2884
3380
|
return;
|
|
2885
3381
|
}
|
|
2886
3382
|
const utterance = new SpeechSynthesisUtterance(text);
|
|
2887
|
-
utterance.lang = this
|
|
3383
|
+
utterance.lang = this.#resolveLang(element);
|
|
2888
3384
|
utterance.rate = 1;
|
|
2889
3385
|
utterance.onboundary = (event) => {
|
|
2890
3386
|
if (event.name !== "word")
|
|
@@ -2892,9 +3388,20 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2892
3388
|
this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
|
|
2893
3389
|
};
|
|
2894
3390
|
utterance.onend = () => {
|
|
3391
|
+
if (this.#currentUtterance !== utterance)
|
|
3392
|
+
return;
|
|
3393
|
+
this.#currentUtterance = null;
|
|
2895
3394
|
this.#clearWordHighlight();
|
|
2896
3395
|
this.#speakElement(this.#currentElementIndex + 1);
|
|
2897
3396
|
};
|
|
3397
|
+
utterance.onerror = () => {
|
|
3398
|
+
if (this.#currentUtterance !== utterance)
|
|
3399
|
+
return;
|
|
3400
|
+
this.#currentUtterance = null;
|
|
3401
|
+
this.#clearAllHighlights();
|
|
3402
|
+
this.#setSpeechState("idle");
|
|
3403
|
+
};
|
|
3404
|
+
this.#currentUtterance = utterance;
|
|
2898
3405
|
speechSynthesis.speak(utterance);
|
|
2899
3406
|
this.#setSpeechState("playing");
|
|
2900
3407
|
}
|
|
@@ -2907,17 +3414,71 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2907
3414
|
this.#setSpeechState("playing");
|
|
2908
3415
|
}
|
|
2909
3416
|
#stop() {
|
|
3417
|
+
this.#currentUtterance = null;
|
|
2910
3418
|
speechSynthesis.cancel();
|
|
2911
3419
|
this.#clearAllHighlights();
|
|
2912
3420
|
this.#setSpeechState("idle");
|
|
2913
3421
|
}
|
|
3422
|
+
// ─── Pick mode ────────────────────────────────────────────────────────────
|
|
3423
|
+
#togglePick() {
|
|
3424
|
+
if (this.#picking)
|
|
3425
|
+
this.#stopPicking();
|
|
3426
|
+
else
|
|
3427
|
+
this.#startPicking();
|
|
3428
|
+
}
|
|
3429
|
+
/** Highlight every reading element and wait for a click on one of them. */
|
|
3430
|
+
#startPicking() {
|
|
3431
|
+
if (this.#contentMode)
|
|
3432
|
+
this.#readingElements = null;
|
|
3433
|
+
const elements = this.#getReadingElements();
|
|
3434
|
+
if (!elements.length) {
|
|
3435
|
+
console.warn("test-item-to-speech: no readable elements found");
|
|
3436
|
+
return;
|
|
3437
|
+
}
|
|
3438
|
+
this.#stop();
|
|
3439
|
+
this.#picking = true;
|
|
3440
|
+
this.#internals.states.add("picking");
|
|
3441
|
+
this.#highlightElements(elements);
|
|
3442
|
+
this.#pickRoot = elements[0].getRootNode();
|
|
3443
|
+
this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
|
|
3444
|
+
this._ttsContext = { ...this._ttsContext, picking: true };
|
|
3445
|
+
}
|
|
3446
|
+
#stopPicking() {
|
|
3447
|
+
if (!this.#picking)
|
|
3448
|
+
return;
|
|
3449
|
+
this.#picking = false;
|
|
3450
|
+
this.#internals.states.delete("picking");
|
|
3451
|
+
this.#pickRoot?.removeEventListener("click", this.#boundHandlePickClick, true);
|
|
3452
|
+
this.#pickRoot = null;
|
|
3453
|
+
this.#clearAllHighlights();
|
|
3454
|
+
this._ttsContext = { ...this._ttsContext, picking: false };
|
|
3455
|
+
}
|
|
3456
|
+
#handlePickClick(event) {
|
|
3457
|
+
const elements = this.#getReadingElements();
|
|
3458
|
+
const path = event.composedPath();
|
|
3459
|
+
let index = elements.findIndex((el) => path.includes(el));
|
|
3460
|
+
if (index < 0) {
|
|
3461
|
+
const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
|
|
3462
|
+
if (container)
|
|
3463
|
+
index = elements.findIndex((el) => container.contains(el));
|
|
3464
|
+
}
|
|
3465
|
+
if (index < 0)
|
|
3466
|
+
return;
|
|
3467
|
+
event.preventDefault();
|
|
3468
|
+
event.stopPropagation();
|
|
3469
|
+
this.#stopPicking();
|
|
3470
|
+
speechSynthesis.cancel();
|
|
3471
|
+
this.#speakElement(index);
|
|
3472
|
+
}
|
|
2914
3473
|
#prevElement() {
|
|
2915
3474
|
const elements = this.#getReadingElements();
|
|
2916
3475
|
if (!elements.length)
|
|
2917
3476
|
return;
|
|
3477
|
+
this.#currentUtterance = null;
|
|
2918
3478
|
speechSynthesis.cancel();
|
|
2919
3479
|
this.#clearWordHighlight();
|
|
2920
3480
|
this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
|
|
3481
|
+
this.#finished = false;
|
|
2921
3482
|
this.#updateContext();
|
|
2922
3483
|
const el = elements[this.#currentElementIndex];
|
|
2923
3484
|
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
@@ -2928,9 +3489,11 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2928
3489
|
const elements = this.#getReadingElements();
|
|
2929
3490
|
if (!elements.length)
|
|
2930
3491
|
return;
|
|
3492
|
+
this.#currentUtterance = null;
|
|
2931
3493
|
speechSynthesis.cancel();
|
|
2932
3494
|
this.#clearWordHighlight();
|
|
2933
3495
|
this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
|
|
3496
|
+
this.#finished = false;
|
|
2934
3497
|
this.#updateContext();
|
|
2935
3498
|
const el = elements[this.#currentElementIndex];
|
|
2936
3499
|
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
@@ -2943,7 +3506,7 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2943
3506
|
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
2944
3507
|
let node;
|
|
2945
3508
|
while (node = walker.nextNode()) {
|
|
2946
|
-
if ((node.textContent ?? "").length > 0) {
|
|
3509
|
+
if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
|
|
2947
3510
|
nodes.push(node);
|
|
2948
3511
|
}
|
|
2949
3512
|
}
|
|
@@ -2951,13 +3514,19 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2951
3514
|
}
|
|
2952
3515
|
/** Highlight the whole element as the navigation cursor (blue). */
|
|
2953
3516
|
#highlightElement(element) {
|
|
3517
|
+
this.#highlightElements([element]);
|
|
3518
|
+
}
|
|
3519
|
+
/** Put the blue cursor highlight on several elements at once (pick mode). */
|
|
3520
|
+
#highlightElements(elements) {
|
|
2954
3521
|
if (!("highlights" in CSS))
|
|
2955
3522
|
return;
|
|
2956
3523
|
this.#ensureHighlightStyles();
|
|
2957
3524
|
this.#elementHighlight.clear();
|
|
2958
|
-
const
|
|
2959
|
-
|
|
2960
|
-
|
|
3525
|
+
for (const element of elements) {
|
|
3526
|
+
const range = new Range();
|
|
3527
|
+
range.selectNodeContents(element);
|
|
3528
|
+
this.#elementHighlight.add(range);
|
|
3529
|
+
}
|
|
2961
3530
|
CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
|
|
2962
3531
|
}
|
|
2963
3532
|
/** Highlight the current word within #textNodes (yellow, during speech). */
|
|
@@ -2998,15 +3567,16 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
2998
3567
|
if (!("highlights" in CSS))
|
|
2999
3568
|
return;
|
|
3000
3569
|
this.#wordHighlight.clear();
|
|
3001
|
-
CSS.highlights.
|
|
3570
|
+
if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight)
|
|
3571
|
+
CSS.highlights.delete(HIGHLIGHT_WORD);
|
|
3002
3572
|
}
|
|
3003
3573
|
#clearAllHighlights() {
|
|
3004
3574
|
if (!("highlights" in CSS))
|
|
3005
3575
|
return;
|
|
3006
|
-
this.#
|
|
3007
|
-
CSS.highlights.delete(HIGHLIGHT_WORD);
|
|
3576
|
+
this.#clearWordHighlight();
|
|
3008
3577
|
this.#elementHighlight.clear();
|
|
3009
|
-
CSS.highlights.
|
|
3578
|
+
if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
|
|
3579
|
+
CSS.highlights.delete(HIGHLIGHT_ELEMENT);
|
|
3010
3580
|
}
|
|
3011
3581
|
/** Fallback word-length when charLength is 0. */
|
|
3012
3582
|
#wordLengthAt(charIndex, text) {
|
|
@@ -3026,21 +3596,34 @@ var TestItemToSpeech = class extends LitElement13 {
|
|
|
3026
3596
|
if (!document.adoptedStyleSheets.includes(sheet)) {
|
|
3027
3597
|
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
3028
3598
|
}
|
|
3029
|
-
const
|
|
3030
|
-
const
|
|
3031
|
-
if (
|
|
3032
|
-
|
|
3599
|
+
const roots = /* @__PURE__ */ new Set();
|
|
3600
|
+
const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.testHost?.querySelector("test-container");
|
|
3601
|
+
if (testContainer?.shadowRoot)
|
|
3602
|
+
roots.add(testContainer.shadowRoot);
|
|
3603
|
+
const ownRoot = this.getRootNode();
|
|
3604
|
+
if (ownRoot instanceof ShadowRoot)
|
|
3605
|
+
roots.add(ownRoot);
|
|
3606
|
+
const itemRoot = this.#readingElements?.[0]?.getRootNode();
|
|
3607
|
+
if (itemRoot instanceof ShadowRoot)
|
|
3608
|
+
roots.add(itemRoot);
|
|
3609
|
+
for (const root of roots) {
|
|
3610
|
+
if (!root.adoptedStyleSheets.includes(sheet)) {
|
|
3611
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
3612
|
+
}
|
|
3033
3613
|
}
|
|
3034
3614
|
}
|
|
3035
3615
|
};
|
|
3036
|
-
|
|
3616
|
+
__decorate14([
|
|
3037
3617
|
property11({ type: String })
|
|
3038
3618
|
], TestItemToSpeech.prototype, "language", void 0);
|
|
3039
|
-
|
|
3040
|
-
|
|
3619
|
+
__decorate14([
|
|
3620
|
+
consume8({ context: sessionContext, subscribe: true })
|
|
3041
3621
|
], TestItemToSpeech.prototype, "_sessionContext", void 0);
|
|
3042
|
-
|
|
3043
|
-
|
|
3622
|
+
__decorate14([
|
|
3623
|
+
consume8({ context: testHostContext, subscribe: true })
|
|
3624
|
+
], TestItemToSpeech.prototype, "testHost", void 0);
|
|
3625
|
+
__decorate14([
|
|
3626
|
+
state4(),
|
|
3044
3627
|
provide3({ context: ttsContext })
|
|
3045
3628
|
], TestItemToSpeech.prototype, "_ttsContext", void 0);
|
|
3046
3629
|
var TestTtsPlay = class extends TtsButtonBase {
|
|
@@ -3057,17 +3640,25 @@ var TestTtsPlay = class extends TtsButtonBase {
|
|
|
3057
3640
|
render() {
|
|
3058
3641
|
const playing = this._tts?.state === "playing";
|
|
3059
3642
|
return html12`
|
|
3060
|
-
<button part="button" @click=${this.#toggle}>
|
|
3061
|
-
${playing ? html12`<slot name="pause"
|
|
3643
|
+
<button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
|
|
3644
|
+
${playing ? html12`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html12`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
|
|
3062
3645
|
</button>
|
|
3063
3646
|
`;
|
|
3064
3647
|
}
|
|
3065
3648
|
};
|
|
3649
|
+
__decorate14([
|
|
3650
|
+
property11({ type: String, attribute: "pause-label" })
|
|
3651
|
+
], TestTtsPlay.prototype, "pauseLabel", void 0);
|
|
3066
3652
|
var TestTtsPause = class extends TtsButtonBase {
|
|
3067
3653
|
render() {
|
|
3068
3654
|
return html12`
|
|
3069
|
-
<button
|
|
3070
|
-
|
|
3655
|
+
<button
|
|
3656
|
+
part="button"
|
|
3657
|
+
aria-label=${ifDefined(this.label)}
|
|
3658
|
+
?disabled=${this._tts?.state !== "playing"}
|
|
3659
|
+
@click=${() => this._tts?.pause()}
|
|
3660
|
+
>
|
|
3661
|
+
<slot>${iconContent("pause", this.label ?? "Pause")}</slot>
|
|
3071
3662
|
</button>
|
|
3072
3663
|
`;
|
|
3073
3664
|
}
|
|
@@ -3075,55 +3666,123 @@ var TestTtsPause = class extends TtsButtonBase {
|
|
|
3075
3666
|
var TestTtsResume = class extends TtsButtonBase {
|
|
3076
3667
|
render() {
|
|
3077
3668
|
return html12`
|
|
3078
|
-
<button
|
|
3079
|
-
|
|
3669
|
+
<button
|
|
3670
|
+
part="button"
|
|
3671
|
+
aria-label=${ifDefined(this.label)}
|
|
3672
|
+
?disabled=${this._tts?.state !== "paused"}
|
|
3673
|
+
@click=${() => this._tts?.resume()}
|
|
3674
|
+
>
|
|
3675
|
+
<slot>${iconContent("play", this.label ?? "Resume")}</slot>
|
|
3080
3676
|
</button>
|
|
3081
3677
|
`;
|
|
3082
3678
|
}
|
|
3083
3679
|
};
|
|
3084
3680
|
var TestTtsStop = class extends TtsButtonBase {
|
|
3085
3681
|
render() {
|
|
3682
|
+
const idle = this._tts?.state === "idle" && !this._tts?.picking;
|
|
3086
3683
|
return html12`
|
|
3087
|
-
<button part="button"
|
|
3088
|
-
<slot
|
|
3684
|
+
<button part="button" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>
|
|
3685
|
+
<slot>${iconContent("stop", this.label ?? "Stop")}</slot>
|
|
3089
3686
|
</button>
|
|
3090
3687
|
`;
|
|
3091
3688
|
}
|
|
3092
3689
|
};
|
|
3093
3690
|
var TestTtsPrev = class extends TtsButtonBase {
|
|
3094
3691
|
render() {
|
|
3692
|
+
const collected = (this._tts?.elementCount ?? 0) > 0;
|
|
3095
3693
|
const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
|
|
3096
|
-
const noElements = (this._tts?.elementCount ?? 0) === 0;
|
|
3097
3694
|
return html12`
|
|
3098
|
-
<button
|
|
3099
|
-
|
|
3695
|
+
<button
|
|
3696
|
+
part="button"
|
|
3697
|
+
aria-label=${ifDefined(this.label)}
|
|
3698
|
+
?disabled=${collected && atStart}
|
|
3699
|
+
@click=${() => this._tts?.prevElement()}
|
|
3700
|
+
>
|
|
3701
|
+
<slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
|
|
3100
3702
|
</button>
|
|
3101
3703
|
`;
|
|
3102
3704
|
}
|
|
3103
3705
|
};
|
|
3104
3706
|
var TestTtsNext = class extends TtsButtonBase {
|
|
3105
3707
|
render() {
|
|
3106
|
-
const
|
|
3107
|
-
const
|
|
3708
|
+
const count = this._tts?.elementCount ?? 0;
|
|
3709
|
+
const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
|
|
3108
3710
|
return html12`
|
|
3109
|
-
<button
|
|
3110
|
-
|
|
3711
|
+
<button
|
|
3712
|
+
part="button"
|
|
3713
|
+
aria-label=${ifDefined(this.label)}
|
|
3714
|
+
?disabled=${atEnd}
|
|
3715
|
+
@click=${() => this._tts?.nextElement()}
|
|
3716
|
+
>
|
|
3717
|
+
<slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
|
|
3718
|
+
</button>
|
|
3719
|
+
`;
|
|
3720
|
+
}
|
|
3721
|
+
};
|
|
3722
|
+
var TestTtsPick = class extends TtsButtonBase {
|
|
3723
|
+
render() {
|
|
3724
|
+
return html12`
|
|
3725
|
+
<button
|
|
3726
|
+
part="button"
|
|
3727
|
+
aria-label=${ifDefined(this.label)}
|
|
3728
|
+
aria-pressed=${this._tts?.picking ? "true" : "false"}
|
|
3729
|
+
@click=${() => this._tts?.togglePick()}
|
|
3730
|
+
>
|
|
3731
|
+
<slot>${iconContent("pick", this.label ?? "Read from here")}</slot>
|
|
3111
3732
|
</button>
|
|
3112
3733
|
`;
|
|
3113
3734
|
}
|
|
3114
3735
|
};
|
|
3115
3736
|
|
|
3116
3737
|
// ../qti-test/dist/components/test-navigation/test-navigation.js
|
|
3117
|
-
import { consume as
|
|
3738
|
+
import { ContextConsumer, consume as consume9, provide as provide4 } from "@lit/context";
|
|
3118
3739
|
import { html as html13, LitElement as LitElement14 } from "lit";
|
|
3119
|
-
import { property as property12, state as
|
|
3120
|
-
var
|
|
3740
|
+
import { property as property12, state as state5 } from "lit/decorators.js";
|
|
3741
|
+
var __decorate15 = function(decorators, target, key, desc) {
|
|
3121
3742
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3122
3743
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3123
3744
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3124
3745
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3125
3746
|
};
|
|
3747
|
+
var newQtiContext = () => ({
|
|
3748
|
+
QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
|
|
3749
|
+
});
|
|
3126
3750
|
var TestNavigation = class extends LitElement14 {
|
|
3751
|
+
/**
|
|
3752
|
+
* @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
|
|
3753
|
+
* enclosing test's: reading returns it, writing replaces it, so a host that has always set the
|
|
3754
|
+
* shuffle seed here keeps working. Removed in the next major.
|
|
3755
|
+
*
|
|
3756
|
+
* Written before the navigation is inside a test, it waits and is handed over on connect.
|
|
3757
|
+
*/
|
|
3758
|
+
get qtiContext() {
|
|
3759
|
+
return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
|
|
3760
|
+
}
|
|
3761
|
+
set qtiContext(value) {
|
|
3762
|
+
if (!this.#warnedQtiContext) {
|
|
3763
|
+
this.#warnedQtiContext = true;
|
|
3764
|
+
console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.");
|
|
3765
|
+
}
|
|
3766
|
+
this.#writeQtiContext(value);
|
|
3767
|
+
}
|
|
3768
|
+
#pendingQtiContext;
|
|
3769
|
+
#warnedQtiContext;
|
|
3770
|
+
/** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */
|
|
3771
|
+
#writeQtiContext(value) {
|
|
3772
|
+
const owner = this.#owner();
|
|
3773
|
+
if (owner)
|
|
3774
|
+
owner.qtiContext = value;
|
|
3775
|
+
else
|
|
3776
|
+
this.#pendingQtiContext = value;
|
|
3777
|
+
}
|
|
3778
|
+
/**
|
|
3779
|
+
* The `qti-test` this navigation is in, found through context so it works across shadow roots.
|
|
3780
|
+
* A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.
|
|
3781
|
+
*/
|
|
3782
|
+
#testHost;
|
|
3783
|
+
#owner() {
|
|
3784
|
+
return this.#testHost.value ?? null;
|
|
3785
|
+
}
|
|
3127
3786
|
#testElement;
|
|
3128
3787
|
/**
|
|
3129
3788
|
* Whether each item's last *ended attempt* reached the optimal outcome, keyed
|
|
@@ -3137,13 +3796,17 @@ var TestNavigation = class extends LitElement14 {
|
|
|
3137
3796
|
super();
|
|
3138
3797
|
this.identifier = void 0;
|
|
3139
3798
|
this.initContext = [];
|
|
3140
|
-
this
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3799
|
+
this.#warnedQtiContext = false;
|
|
3800
|
+
this.#testHost = new ContextConsumer(this, {
|
|
3801
|
+
context: testHostContext,
|
|
3802
|
+
subscribe: true,
|
|
3803
|
+
callback: (host) => {
|
|
3804
|
+
if (host && this.#pendingQtiContext) {
|
|
3805
|
+
host.qtiContext = this.#pendingQtiContext;
|
|
3806
|
+
this.#pendingQtiContext = void 0;
|
|
3807
|
+
}
|
|
3145
3808
|
}
|
|
3146
|
-
};
|
|
3809
|
+
});
|
|
3147
3810
|
this.configContext = {};
|
|
3148
3811
|
this.autoScoreItems = false;
|
|
3149
3812
|
this.#optimality = /* @__PURE__ */ new Map();
|
|
@@ -3242,26 +3905,26 @@ var TestNavigation = class extends LitElement14 {
|
|
|
3242
3905
|
candidateIdentifier: "not set",
|
|
3243
3906
|
environmentIdentifier: "default"
|
|
3244
3907
|
};
|
|
3245
|
-
this
|
|
3908
|
+
this.#writeQtiContext({
|
|
3246
3909
|
QTI_CONTEXT: {
|
|
3247
3910
|
...currentContext,
|
|
3248
3911
|
testIdentifier: this.#testElement.identifier,
|
|
3249
3912
|
environmentIdentifier: currentContext.environmentIdentifier || "default"
|
|
3250
3913
|
}
|
|
3251
|
-
};
|
|
3914
|
+
});
|
|
3252
3915
|
}
|
|
3253
3916
|
const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
|
|
3254
3917
|
contextDeclarations.forEach((declaration) => {
|
|
3255
3918
|
const defaultValues = this.#extractDefaultValues(declaration);
|
|
3256
3919
|
if (Object.keys(defaultValues).length > 0) {
|
|
3257
|
-
this
|
|
3920
|
+
this.#writeQtiContext({
|
|
3258
3921
|
QTI_CONTEXT: {
|
|
3259
3922
|
...defaultValues,
|
|
3260
3923
|
// Default values first
|
|
3261
3924
|
...this.qtiContext.QTI_CONTEXT
|
|
3262
3925
|
// Runtime values override defaults
|
|
3263
3926
|
}
|
|
3264
|
-
};
|
|
3927
|
+
});
|
|
3265
3928
|
}
|
|
3266
3929
|
});
|
|
3267
3930
|
const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
|
|
@@ -3433,7 +4096,7 @@ var TestNavigation = class extends LitElement14 {
|
|
|
3433
4096
|
const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
|
|
3434
4097
|
const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
|
|
3435
4098
|
const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
|
|
3436
|
-
const valid =
|
|
4099
|
+
const valid = itemContext?.valid ?? true;
|
|
3437
4100
|
const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
|
|
3438
4101
|
const isDefaultResponse = responseVars.every((v) => {
|
|
3439
4102
|
if (v.value === void 0 || v.value === null) {
|
|
@@ -3585,41 +4248,37 @@ var TestNavigation = class extends LitElement14 {
|
|
|
3585
4248
|
return Number.isNaN(parsed) ? null : parsed;
|
|
3586
4249
|
}
|
|
3587
4250
|
};
|
|
3588
|
-
|
|
4251
|
+
__decorate15([
|
|
3589
4252
|
property12({ type: String })
|
|
3590
4253
|
], TestNavigation.prototype, "identifier", void 0);
|
|
3591
|
-
|
|
3592
|
-
|
|
4254
|
+
__decorate15([
|
|
4255
|
+
state5()
|
|
3593
4256
|
], TestNavigation.prototype, "initContext", void 0);
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
], TestNavigation.prototype, "qtiContext", void 0);
|
|
3598
|
-
__decorate14([
|
|
3599
|
-
state4(),
|
|
3600
|
-
consume7({ context: configContext, subscribe: true })
|
|
4257
|
+
__decorate15([
|
|
4258
|
+
state5(),
|
|
4259
|
+
consume9({ context: configContext, subscribe: true })
|
|
3601
4260
|
], TestNavigation.prototype, "configContext", void 0);
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
4261
|
+
__decorate15([
|
|
4262
|
+
state5(),
|
|
4263
|
+
consume9({ context: testContext, subscribe: true })
|
|
3605
4264
|
], TestNavigation.prototype, "_testContext", void 0);
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
4265
|
+
__decorate15([
|
|
4266
|
+
state5(),
|
|
4267
|
+
consume9({ context: sessionContext, subscribe: true })
|
|
3609
4268
|
], TestNavigation.prototype, "_sessionContext", void 0);
|
|
3610
|
-
|
|
3611
|
-
|
|
4269
|
+
__decorate15([
|
|
4270
|
+
state5(),
|
|
3612
4271
|
provide4({ context: computedContext })
|
|
3613
4272
|
], TestNavigation.prototype, "computedContext", void 0);
|
|
3614
|
-
|
|
4273
|
+
__decorate15([
|
|
3615
4274
|
property12({ type: Boolean, attribute: "auto-score-items" })
|
|
3616
4275
|
], TestNavigation.prototype, "autoScoreItems", void 0);
|
|
3617
4276
|
|
|
3618
4277
|
// ../qti-test/dist/components/test-next/test-next.js
|
|
3619
4278
|
import { css as css8, html as html14, LitElement as LitElement15 } from "lit";
|
|
3620
4279
|
import { property as property13 } from "lit/decorators.js";
|
|
3621
|
-
import { consume as
|
|
3622
|
-
var
|
|
4280
|
+
import { consume as consume10 } from "@lit/context";
|
|
4281
|
+
var __decorate16 = function(decorators, target, key, desc) {
|
|
3623
4282
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3624
4283
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3625
4284
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -3636,6 +4295,12 @@ var TestNext = class extends LitElement15 {
|
|
|
3636
4295
|
:host {
|
|
3637
4296
|
${btn};
|
|
3638
4297
|
}
|
|
4298
|
+
:host(:hover:not([disabled])) {
|
|
4299
|
+
${btnInteractive};
|
|
4300
|
+
}
|
|
4301
|
+
:host(:focus-visible) {
|
|
4302
|
+
${focusRing};
|
|
4303
|
+
}
|
|
3639
4304
|
:host([disabled]) {
|
|
3640
4305
|
${dis};
|
|
3641
4306
|
}
|
|
@@ -3693,20 +4358,20 @@ var TestNext = class extends LitElement15 {
|
|
|
3693
4358
|
return html14`<slot></slot>`;
|
|
3694
4359
|
}
|
|
3695
4360
|
};
|
|
3696
|
-
|
|
4361
|
+
__decorate16([
|
|
3697
4362
|
property13({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
3698
4363
|
], TestNext.prototype, "_internalDisabled", void 0);
|
|
3699
|
-
|
|
3700
|
-
|
|
4364
|
+
__decorate16([
|
|
4365
|
+
consume10({ context: computedContext, subscribe: true })
|
|
3701
4366
|
], TestNext.prototype, "computedContext", void 0);
|
|
3702
|
-
|
|
4367
|
+
__decorate16([
|
|
3703
4368
|
watch("computedContext")
|
|
3704
4369
|
], TestNext.prototype, "_handleTestElementChange", null);
|
|
3705
4370
|
|
|
3706
4371
|
// ../qti-test/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js
|
|
3707
4372
|
import { html as html15, LitElement as LitElement16 } from "lit";
|
|
3708
|
-
import { consume as
|
|
3709
|
-
var
|
|
4373
|
+
import { consume as consume11 } from "@lit/context";
|
|
4374
|
+
var __decorate17 = function(decorators, target, key, desc) {
|
|
3710
4375
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3711
4376
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3712
4377
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -3734,15 +4399,15 @@ var TestPagingButtonsStamp = class extends LitElement16 {
|
|
|
3734
4399
|
return html15` ${items.map((item) => this.myTemplate({ item, view: this.computedContext.view }))} `;
|
|
3735
4400
|
}
|
|
3736
4401
|
};
|
|
3737
|
-
|
|
3738
|
-
|
|
4402
|
+
__decorate17([
|
|
4403
|
+
consume11({ context: computedContext, subscribe: true })
|
|
3739
4404
|
], TestPagingButtonsStamp.prototype, "computedContext", void 0);
|
|
3740
4405
|
|
|
3741
4406
|
// ../qti-test/dist/components/test-prev/test-prev.js
|
|
3742
4407
|
import { css as css9, html as html16, LitElement as LitElement17 } from "lit";
|
|
3743
4408
|
import { property as property14 } from "lit/decorators.js";
|
|
3744
|
-
import { consume as
|
|
3745
|
-
var
|
|
4409
|
+
import { consume as consume12 } from "@lit/context";
|
|
4410
|
+
var __decorate18 = function(decorators, target, key, desc) {
|
|
3746
4411
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3747
4412
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3748
4413
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -3759,6 +4424,12 @@ var TestPrev = class extends LitElement17 {
|
|
|
3759
4424
|
:host {
|
|
3760
4425
|
${btn};
|
|
3761
4426
|
}
|
|
4427
|
+
:host(:hover:not([disabled])) {
|
|
4428
|
+
${btnInteractive};
|
|
4429
|
+
}
|
|
4430
|
+
:host(:focus-visible) {
|
|
4431
|
+
${focusRing};
|
|
4432
|
+
}
|
|
3762
4433
|
:host([disabled]) {
|
|
3763
4434
|
${dis};
|
|
3764
4435
|
}
|
|
@@ -3803,21 +4474,21 @@ var TestPrev = class extends LitElement17 {
|
|
|
3803
4474
|
return html16`<slot></slot>`;
|
|
3804
4475
|
}
|
|
3805
4476
|
};
|
|
3806
|
-
|
|
4477
|
+
__decorate18([
|
|
3807
4478
|
property14({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
3808
4479
|
], TestPrev.prototype, "_internalDisabled", void 0);
|
|
3809
|
-
|
|
3810
|
-
|
|
4480
|
+
__decorate18([
|
|
4481
|
+
consume12({ context: computedContext, subscribe: true })
|
|
3811
4482
|
], TestPrev.prototype, "computedContext", void 0);
|
|
3812
|
-
|
|
4483
|
+
__decorate18([
|
|
3813
4484
|
watch("computedContext")
|
|
3814
4485
|
], TestPrev.prototype, "_handleTestElementChange", null);
|
|
3815
4486
|
|
|
3816
4487
|
// ../qti-test/dist/components/test-print-context/test-print-context.js
|
|
3817
4488
|
import { html as html17, LitElement as LitElement18 } from "lit";
|
|
3818
|
-
import { consume as
|
|
3819
|
-
import { state as
|
|
3820
|
-
var
|
|
4489
|
+
import { consume as consume13 } from "@lit/context";
|
|
4490
|
+
import { state as state6 } from "lit/decorators.js";
|
|
4491
|
+
var __decorate19 = function(decorators, target, key, desc) {
|
|
3821
4492
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3822
4493
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3823
4494
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -3828,15 +4499,15 @@ var TestPrintContext = class extends LitElement18 {
|
|
|
3828
4499
|
return html17` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
|
|
3829
4500
|
}
|
|
3830
4501
|
};
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
4502
|
+
__decorate19([
|
|
4503
|
+
state6(),
|
|
4504
|
+
consume13({ context: computedContext, subscribe: true })
|
|
3834
4505
|
], TestPrintContext.prototype, "computedContext", void 0);
|
|
3835
4506
|
|
|
3836
4507
|
// ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
|
|
3837
4508
|
import { html as html18, css as css10, LitElement as LitElement19 } from "lit";
|
|
3838
|
-
import { consume as
|
|
3839
|
-
var
|
|
4509
|
+
import { consume as consume14 } from "@lit/context";
|
|
4510
|
+
var __decorate20 = function(decorators, target, key, desc) {
|
|
3840
4511
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3841
4512
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3842
4513
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -3908,15 +4579,15 @@ var TestPrintVariables = class extends LitElement19 {
|
|
|
3908
4579
|
`;
|
|
3909
4580
|
}
|
|
3910
4581
|
};
|
|
3911
|
-
|
|
3912
|
-
|
|
4582
|
+
__decorate20([
|
|
4583
|
+
consume14({ context: computedContext, subscribe: true })
|
|
3913
4584
|
], TestPrintVariables.prototype, "computedContext", void 0);
|
|
3914
4585
|
|
|
3915
4586
|
// ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
|
|
3916
4587
|
import { html as html19, LitElement as LitElement20, nothing as nothing3 } from "lit";
|
|
3917
|
-
import { consume as
|
|
4588
|
+
import { consume as consume15 } from "@lit/context";
|
|
3918
4589
|
import { property as property15 } from "lit/decorators.js";
|
|
3919
|
-
var
|
|
4590
|
+
var __decorate21 = function(decorators, target, key, desc) {
|
|
3920
4591
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3921
4592
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3922
4593
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -3975,21 +4646,21 @@ var TestScoringButtons = class extends LitElement20 {
|
|
|
3975
4646
|
});
|
|
3976
4647
|
}
|
|
3977
4648
|
};
|
|
3978
|
-
|
|
4649
|
+
__decorate21([
|
|
3979
4650
|
property15({ type: String, attribute: "view" })
|
|
3980
4651
|
], TestScoringButtons.prototype, "view", void 0);
|
|
3981
|
-
|
|
4652
|
+
__decorate21([
|
|
3982
4653
|
property15({ type: Boolean })
|
|
3983
4654
|
], TestScoringButtons.prototype, "disabled", void 0);
|
|
3984
|
-
|
|
3985
|
-
|
|
4655
|
+
__decorate21([
|
|
4656
|
+
consume15({ context: computedContext, subscribe: true })
|
|
3986
4657
|
], TestScoringButtons.prototype, "computedContext", void 0);
|
|
3987
4658
|
|
|
3988
4659
|
// ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
|
|
3989
|
-
import { consume as
|
|
4660
|
+
import { consume as consume16 } from "@lit/context";
|
|
3990
4661
|
import { html as html20, LitElement as LitElement21 } from "lit";
|
|
3991
4662
|
import { property as property16 } from "lit/decorators.js";
|
|
3992
|
-
var
|
|
4663
|
+
var __decorate22 = function(decorators, target, key, desc) {
|
|
3993
4664
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3994
4665
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3995
4666
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -4028,17 +4699,17 @@ var TestScoringFeedback = class extends LitElement21 {
|
|
|
4028
4699
|
return html20`<div>${feedbackText()}</div>`;
|
|
4029
4700
|
}
|
|
4030
4701
|
};
|
|
4031
|
-
|
|
4032
|
-
|
|
4702
|
+
__decorate22([
|
|
4703
|
+
consume16({ context: computedContext, subscribe: true })
|
|
4033
4704
|
], TestScoringFeedback.prototype, "computedContext", void 0);
|
|
4034
|
-
|
|
4705
|
+
__decorate22([
|
|
4035
4706
|
property16({ type: String, attribute: "view" })
|
|
4036
4707
|
], TestScoringFeedback.prototype, "view", void 0);
|
|
4037
4708
|
|
|
4038
4709
|
// ../qti-test/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js
|
|
4039
4710
|
import { html as html21, LitElement as LitElement22 } from "lit";
|
|
4040
|
-
import { consume as
|
|
4041
|
-
var
|
|
4711
|
+
import { consume as consume17 } from "@lit/context";
|
|
4712
|
+
var __decorate23 = function(decorators, target, key, desc) {
|
|
4042
4713
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4043
4714
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4044
4715
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -4066,14 +4737,14 @@ var TestSectionButtonsStamp = class extends LitElement22 {
|
|
|
4066
4737
|
return html21` ${sections.map((item) => this.myTemplate({ item }))} `;
|
|
4067
4738
|
}
|
|
4068
4739
|
};
|
|
4069
|
-
|
|
4070
|
-
|
|
4740
|
+
__decorate23([
|
|
4741
|
+
consume17({ context: computedContext, subscribe: true })
|
|
4071
4742
|
], TestSectionButtonsStamp.prototype, "computedContext", void 0);
|
|
4072
4743
|
|
|
4073
4744
|
// ../qti-test/dist/components/test-section-link/test-section-link.js
|
|
4074
4745
|
import { css as css11, html as html22, LitElement as LitElement23 } from "lit";
|
|
4075
4746
|
import { property as property17 } from "lit/decorators.js";
|
|
4076
|
-
var
|
|
4747
|
+
var __decorate24 = function(decorators, target, key, desc) {
|
|
4077
4748
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4078
4749
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4079
4750
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -4085,6 +4756,12 @@ var TestSectionLink = class extends LitElement23 {
|
|
|
4085
4756
|
:host {
|
|
4086
4757
|
${btn};
|
|
4087
4758
|
}
|
|
4759
|
+
:host(:hover:not([disabled])) {
|
|
4760
|
+
${btnInteractive};
|
|
4761
|
+
}
|
|
4762
|
+
:host(:focus-visible) {
|
|
4763
|
+
${focusRing};
|
|
4764
|
+
}
|
|
4088
4765
|
:host([disabled]) {
|
|
4089
4766
|
${dis};
|
|
4090
4767
|
}
|
|
@@ -4109,15 +4786,15 @@ var TestSectionLink = class extends LitElement23 {
|
|
|
4109
4786
|
return html22` <slot></slot> `;
|
|
4110
4787
|
}
|
|
4111
4788
|
};
|
|
4112
|
-
|
|
4789
|
+
__decorate24([
|
|
4113
4790
|
property17({ type: String, attribute: "section-id" })
|
|
4114
4791
|
], TestSectionLink.prototype, "sectionId", void 0);
|
|
4115
4792
|
|
|
4116
4793
|
// ../qti-test/dist/components/test-stamp/test-stamp.js
|
|
4117
4794
|
import { html as html23, LitElement as LitElement24, nothing as nothing4 } from "lit";
|
|
4118
|
-
import { property as property18, state as
|
|
4119
|
-
import { consume as
|
|
4120
|
-
var
|
|
4795
|
+
import { property as property18, state as state7 } from "lit/decorators.js";
|
|
4796
|
+
import { consume as consume18 } from "@lit/context";
|
|
4797
|
+
var __decorate25 = function(decorators, target, key, desc) {
|
|
4121
4798
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4122
4799
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4123
4800
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -4190,22 +4867,22 @@ var TestStamp = class extends LitElement24 {
|
|
|
4190
4867
|
${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
|
|
4191
4868
|
}
|
|
4192
4869
|
};
|
|
4193
|
-
|
|
4870
|
+
__decorate25([
|
|
4194
4871
|
property18({ type: Boolean, reflect: true })
|
|
4195
4872
|
], TestStamp.prototype, "debug", void 0);
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4873
|
+
__decorate25([
|
|
4874
|
+
state7(),
|
|
4875
|
+
consume18({ context: computedContext, subscribe: true })
|
|
4199
4876
|
], TestStamp.prototype, "computedContext", void 0);
|
|
4200
|
-
|
|
4201
|
-
|
|
4877
|
+
__decorate25([
|
|
4878
|
+
state7()
|
|
4202
4879
|
], TestStamp.prototype, "stampContext", void 0);
|
|
4203
4880
|
|
|
4204
4881
|
// ../qti-test/dist/components/test-view-toggle/test-view.js
|
|
4205
4882
|
import { html as html24, LitElement as LitElement25 } from "lit";
|
|
4206
|
-
import { property as property19, state as
|
|
4207
|
-
import { consume as
|
|
4208
|
-
var
|
|
4883
|
+
import { property as property19, state as state8 } from "lit/decorators.js";
|
|
4884
|
+
import { consume as consume19 } from "@lit/context";
|
|
4885
|
+
var __decorate26 = function(decorators, target, key, desc) {
|
|
4209
4886
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4210
4887
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4211
4888
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -4260,26 +4937,26 @@ var TestView = class extends LitElement25 {
|
|
|
4260
4937
|
}
|
|
4261
4938
|
};
|
|
4262
4939
|
_a = TestView;
|
|
4263
|
-
|
|
4264
|
-
|
|
4940
|
+
__decorate26([
|
|
4941
|
+
consume19({ context: sessionContext, subscribe: true })
|
|
4265
4942
|
], TestView.prototype, "sessionContext", void 0);
|
|
4266
|
-
|
|
4943
|
+
__decorate26([
|
|
4267
4944
|
property19({ type: String })
|
|
4268
4945
|
], TestView.prototype, "label", void 0);
|
|
4269
|
-
|
|
4946
|
+
__decorate26([
|
|
4270
4947
|
property19({ type: String, attribute: "view-options" })
|
|
4271
4948
|
], TestView.prototype, "viewOptions", void 0);
|
|
4272
|
-
|
|
4949
|
+
__decorate26([
|
|
4273
4950
|
watch("viewOptions", { waitUntilFirstUpdate: true })
|
|
4274
4951
|
], TestView.prototype, "_handleViewOptionsChange", void 0);
|
|
4275
|
-
|
|
4276
|
-
|
|
4952
|
+
__decorate26([
|
|
4953
|
+
state8()
|
|
4277
4954
|
], TestView.prototype, "_viewOptions", void 0);
|
|
4278
4955
|
|
|
4279
4956
|
// ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
|
|
4280
|
-
import { consume as
|
|
4957
|
+
import { consume as consume20 } from "@lit/context";
|
|
4281
4958
|
import { html as html25, LitElement as LitElement26, nothing as nothing5 } from "lit";
|
|
4282
|
-
var
|
|
4959
|
+
var __decorate27 = function(decorators, target, key, desc) {
|
|
4283
4960
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4284
4961
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4285
4962
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -4320,8 +4997,8 @@ var TestViewToggle = class extends LitElement26 {
|
|
|
4320
4997
|
}) : nothing5}`;
|
|
4321
4998
|
}
|
|
4322
4999
|
};
|
|
4323
|
-
|
|
4324
|
-
|
|
5000
|
+
__decorate27([
|
|
5001
|
+
consume20({ context: sessionContext, subscribe: true })
|
|
4325
5002
|
], TestViewToggle.prototype, "sessionContext", void 0);
|
|
4326
5003
|
|
|
4327
5004
|
// ../qti-test/dist/elements.js
|
|
@@ -4354,6 +5031,7 @@ var qtiTestElements = [
|
|
|
4354
5031
|
{ tag: "test-stamp", ctor: TestStamp },
|
|
4355
5032
|
{ tag: "test-tts-next", ctor: TestTtsNext },
|
|
4356
5033
|
{ tag: "test-tts-pause", ctor: TestTtsPause },
|
|
5034
|
+
{ tag: "test-tts-pick", ctor: TestTtsPick },
|
|
4357
5035
|
{ tag: "test-tts-play", ctor: TestTtsPlay },
|
|
4358
5036
|
{ tag: "test-tts-prev", ctor: TestTtsPrev },
|
|
4359
5037
|
{ tag: "test-tts-resume", ctor: TestTtsResume },
|
|
@@ -4374,6 +5052,7 @@ export {
|
|
|
4374
5052
|
QtiTestPart,
|
|
4375
5053
|
QtiTestVariables,
|
|
4376
5054
|
QtiTestVariablesExpression,
|
|
5055
|
+
QTI_TEST_STATE_VERSION,
|
|
4377
5056
|
QtiTest,
|
|
4378
5057
|
TestCheckItem,
|
|
4379
5058
|
TestContainer,
|
|
@@ -4387,6 +5066,7 @@ export {
|
|
|
4387
5066
|
TestTtsStop,
|
|
4388
5067
|
TestTtsPrev,
|
|
4389
5068
|
TestTtsNext,
|
|
5069
|
+
TestTtsPick,
|
|
4390
5070
|
TestNavigation,
|
|
4391
5071
|
TestNext,
|
|
4392
5072
|
TestPagingButtonsStamp,
|
|
@@ -4414,4 +5094,4 @@ export {
|
|
|
4414
5094
|
* Portions Copyright (c) 2013, the Dart project authors.
|
|
4415
5095
|
*)
|
|
4416
5096
|
*/
|
|
4417
|
-
//# sourceMappingURL=chunk-
|
|
5097
|
+
//# sourceMappingURL=chunk-GNTO3IFM.js.map
|