@citolab/qti-components 10.0.0-next.2 → 10.0.0-next.21
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 +4334 -2688
- package/dist/base.d.ts +39 -13
- package/dist/base.js +14 -1
- package/dist/{chunk-RU6332MD.js → chunk-2A52V5TQ.js} +4 -4
- package/dist/{chunk-2KP5UU5A.js → chunk-55WWIRLN.js} +117 -92
- package/dist/chunk-55WWIRLN.js.map +1 -0
- package/dist/{chunk-MI7774NV.js → chunk-5BP2A7BI.js} +2 -2
- package/dist/{chunk-35WWWFS6.js → chunk-DAESCCLR.js} +2 -2
- package/dist/chunk-DJ7PB252.js +7 -0
- package/dist/chunk-DJ7PB252.js.map +1 -0
- package/dist/{chunk-TDWJ6WZA.js → chunk-GPC53O7P.js} +166 -10
- package/dist/chunk-GPC53O7P.js.map +1 -0
- package/dist/{chunk-6U3YPHXU.js → chunk-H6DO5UHC.js} +277 -154
- package/dist/chunk-H6DO5UHC.js.map +1 -0
- package/dist/chunk-J6VX4N7M.js +197 -0
- package/dist/chunk-J6VX4N7M.js.map +1 -0
- package/dist/{chunk-3ZNECUPV.js → chunk-JIDSFFFD.js} +2 -2
- package/dist/{chunk-FD4AB6TM.js → chunk-KQ2LED4X.js} +2 -2
- package/dist/{chunk-6K3QWJHH.js → chunk-LPYZVKHX.js} +48 -7
- package/dist/chunk-LPYZVKHX.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/{chunk-K3VKQ6QF.js → chunk-TB2OI3ED.js} +677 -1894
- package/dist/chunk-TB2OI3ED.js.map +1 -0
- package/dist/{chunk-GBZNFSFY.js → chunk-TSJGL6FI.js} +2 -2
- package/dist/{chunk-RSMYGGQK.js → chunk-TZCOXFPB.js} +1590 -610
- package/dist/chunk-TZCOXFPB.js.map +1 -0
- package/dist/chunk-UCXLDQYA.js +56 -0
- package/dist/chunk-UCXLDQYA.js.map +1 -0
- package/dist/chunk-WWY2H2YO.js +7 -0
- package/dist/chunk-WWY2H2YO.js.map +1 -0
- package/dist/{chunk-LFVPS7KB.js → chunk-XWRZP2RM.js} +2 -2
- package/dist/{chunk-TLAVOBEM.js → chunk-ZRORBAHB.js} +122 -3
- package/dist/chunk-ZRORBAHB.js.map +1 -0
- package/dist/computed.types.d-6Ht-HNRx.d.ts +80 -0
- package/dist/{config.context.d-BvU9r-Mg.d.ts → config.context.d-Dm11aAuw.d.ts} +21 -3
- package/dist/corrections.d.ts +137 -24
- package/dist/corrections.js +12 -12
- package/dist/corrections.js.map +1 -1
- package/dist/elements.d.ts +66 -73
- package/dist/elements.js +9 -6
- package/dist/index.d.ts +21 -17
- package/dist/index.js +47 -61
- package/dist/interactions.d.ts +98 -19
- package/dist/interactions.js +8 -3
- package/dist/item.css +1948 -1946
- package/dist/item.d.ts +8 -6
- package/dist/item.js +6 -5
- package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
- package/dist/loader.d.ts +5 -3
- package/dist/loader.js +3 -2
- package/dist/processing.d.ts +19 -7
- package/dist/processing.js +4 -3
- package/dist/public-events.d-3dGip9pd.d.ts +105 -0
- package/dist/qti-components-jsx.d.ts +1780 -1727
- package/dist/{qti-condition-expression.d-VJH6cWxf.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
- package/dist/{qti-expression.d-BPxEp8HU.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
- package/dist/{qti-feedback.d-wMYNVkkj.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +8 -1
- package/dist/{qti-item.d-DgC1AQbY.d.ts → qti-item.d-CxP6KtCH.d.ts} +3 -2
- package/dist/{qti-rule-base.d-Bdzg8eGH.d.ts → qti-rule-base.d-CeKP0Ooi.d.ts} +2 -2
- package/dist/qti-test-state-CF9S8X9C.d.ts +68 -0
- package/dist/qti-test-state.d-D8Q89RzZ.d.ts +57 -0
- package/dist/{qti-test.d-DkpBNcsv.d.ts → qti-test.d-DBT-YpRu.d.ts} +124 -485
- package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-m0EFv9no.d.ts} +221 -73
- package/dist/{qti-transform-test.d-BL7GGFJj.d.ts → qti-transform-test.d-Bb9vnLzP.d.ts} +1 -0
- package/dist/{interaction.d-g6XG0T0Z.d.ts → record.d-N1Bq7e1f.d.ts} +67 -4
- package/dist/{session.context.d-D5080LVx.d.ts → session.context.d-9gRdGK4T.d.ts} +7 -1
- package/dist/test-plugin-api.d.ts +134 -0
- package/dist/test-plugin-api.js +19 -0
- package/dist/test-plugin-api.js.map +1 -0
- package/dist/test.d.ts +26 -57
- package/dist/test.js +19 -48
- package/dist/transformers.d.ts +1 -1
- package/dist/transformers.js +2 -1
- package/dist/{item.types.d-B55QkJ92.d.ts → variables.d-DWHlTszN.d.ts} +8 -24
- package/package.json +16 -11
- package/dist/chunk-2KP5UU5A.js.map +0 -1
- package/dist/chunk-6K3QWJHH.js.map +0 -1
- package/dist/chunk-6U3YPHXU.js.map +0 -1
- package/dist/chunk-K3VKQ6QF.js.map +0 -1
- package/dist/chunk-RSMYGGQK.js.map +0 -1
- package/dist/chunk-TDWJ6WZA.js.map +0 -1
- package/dist/chunk-TLAVOBEM.js.map +0 -1
- package/dist/chunk-ZP6QQYSU.js +0 -7
- package/dist/chunk-ZP6QQYSU.js.map +0 -1
- package/dist/computed.types.d-gJrBeUMG.d.ts +0 -42
- /package/dist/{chunk-RU6332MD.js.map → chunk-2A52V5TQ.js.map} +0 -0
- /package/dist/{chunk-MI7774NV.js.map → chunk-5BP2A7BI.js.map} +0 -0
- /package/dist/{chunk-35WWWFS6.js.map → chunk-DAESCCLR.js.map} +0 -0
- /package/dist/{chunk-3ZNECUPV.js.map → chunk-JIDSFFFD.js.map} +0 -0
- /package/dist/{chunk-FD4AB6TM.js.map → chunk-KQ2LED4X.js.map} +0 -0
- /package/dist/{chunk-GBZNFSFY.js.map → chunk-TSJGL6FI.js.map} +0 -0
- /package/dist/{chunk-LFVPS7KB.js.map → chunk-XWRZP2RM.js.map} +0 -0
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
button,
|
|
3
|
+
buttonPrimary,
|
|
4
|
+
control,
|
|
5
|
+
dispatchPublic,
|
|
6
|
+
listenPublic as listenPublic2
|
|
7
|
+
} from "./chunk-J6VX4N7M.js";
|
|
8
|
+
import {
|
|
9
|
+
QtiModalFeedback
|
|
10
|
+
} from "./chunk-H6DO5UHC.js";
|
|
11
|
+
import {
|
|
5
12
|
listenPublic
|
|
6
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UCXLDQYA.js";
|
|
7
14
|
import {
|
|
8
15
|
item_css_default
|
|
9
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WWY2H2YO.js";
|
|
10
17
|
import {
|
|
11
18
|
watch
|
|
12
19
|
} from "./chunk-4DB4SC5K.js";
|
|
13
20
|
import {
|
|
14
21
|
qtiTransformItem,
|
|
15
22
|
qtiTransformTest
|
|
16
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ZRORBAHB.js";
|
|
17
24
|
import {
|
|
18
25
|
INITIAL_SESSION_CONTEXT,
|
|
19
26
|
INITIAL_TEST_CONTEXT,
|
|
@@ -24,7 +31,7 @@ import {
|
|
|
24
31
|
qtiContext,
|
|
25
32
|
sessionContext,
|
|
26
33
|
testContext
|
|
27
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-GPC53O7P.js";
|
|
28
35
|
|
|
29
36
|
// ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
|
|
30
37
|
import { LitElement, nothing as nothing2 } from "lit";
|
|
@@ -636,18 +643,18 @@ var EvalAstFactory = class {
|
|
|
636
643
|
}
|
|
637
644
|
const value = this.right.evaluate(scope);
|
|
638
645
|
let receiver = void 0;
|
|
639
|
-
let
|
|
646
|
+
let property15;
|
|
640
647
|
if (this.left.type === "Getter") {
|
|
641
648
|
receiver = this.left.receiver.evaluate(scope);
|
|
642
|
-
|
|
649
|
+
property15 = this.left.name;
|
|
643
650
|
} else if (this.left.type === "Index") {
|
|
644
651
|
receiver = this.left.receiver.evaluate(scope);
|
|
645
|
-
|
|
652
|
+
property15 = this.left.argument.evaluate(scope);
|
|
646
653
|
} else if (this.left.type === "ID") {
|
|
647
654
|
receiver = scope;
|
|
648
|
-
|
|
655
|
+
property15 = this.left.value;
|
|
649
656
|
}
|
|
650
|
-
return receiver === void 0 ? void 0 : receiver[
|
|
657
|
+
return receiver === void 0 ? void 0 : receiver[property15] = value;
|
|
651
658
|
}
|
|
652
659
|
return f(this.left.evaluate(scope), this.right.evaluate(scope));
|
|
653
660
|
},
|
|
@@ -1103,33 +1110,6 @@ var makeLitTemplate = (template) => {
|
|
|
1103
1110
|
import { createContext } from "@lit/context";
|
|
1104
1111
|
var testHostContext = createContext(/* @__PURE__ */ Symbol("testHost"));
|
|
1105
1112
|
|
|
1106
|
-
// ../qti-test/dist/public-events.js
|
|
1107
|
-
var PUBLIC_EVENTS = {
|
|
1108
|
-
"cito-test-navigate": { kind: "request", scope: "test", deprecated: "qti-request-navigation" },
|
|
1109
|
-
"cito-test-end-attempt": { kind: "request", scope: "test", deprecated: "test-end-attempt" },
|
|
1110
|
-
"cito-test-update-outcome": { kind: "request", scope: "test", deprecated: "test-update-outcome-variable" },
|
|
1111
|
-
"cito-test-switch-view": { kind: "request", scope: "test", deprecated: "on-test-switch-view" },
|
|
1112
|
-
"cito-test-navigated": { kind: "notification", scope: "test" },
|
|
1113
|
-
"cito-test-navigation-started": {
|
|
1114
|
-
kind: "notification",
|
|
1115
|
-
scope: "test",
|
|
1116
|
-
deprecated: "qti-navigation-loading-started"
|
|
1117
|
-
},
|
|
1118
|
-
"cito-test-navigation-failed": { kind: "notification", scope: "test", deprecated: "qti-navigation-error" },
|
|
1119
|
-
"cito-test-rendered": { kind: "notification", scope: "test", deprecated: "qti-test-loaded" },
|
|
1120
|
-
"cito-test-loaded": { kind: "notification", scope: "test", deprecated: "qti-assessment-test-connected" },
|
|
1121
|
-
"cito-test-state-changed": { kind: "notification", scope: "test", deprecated: "qti-state-changed" },
|
|
1122
|
-
"cito-test-items-skipped": { kind: "notification", scope: "test" },
|
|
1123
|
-
"cito-test-end-reached": { kind: "notification", scope: "test" },
|
|
1124
|
-
"cito-item-ref-connected": { kind: "notification", scope: "item", deprecated: "qti-assessment-item-ref-connected" }
|
|
1125
|
-
};
|
|
1126
|
-
function dispatchPublic(target, name, detail) {
|
|
1127
|
-
dispatchDeclared(target, PUBLIC_EVENTS, name, detail);
|
|
1128
|
-
}
|
|
1129
|
-
function listenPublic2(target, name, handler) {
|
|
1130
|
-
listenDeclared(target, PUBLIC_EVENTS, name, handler);
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
1113
|
// ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
|
|
1134
1114
|
var __decorate = function(decorators, target, key, desc) {
|
|
1135
1115
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1191,7 +1171,7 @@ var QtiAssessmentItemRef = class extends LitElement {
|
|
|
1191
1171
|
this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;
|
|
1192
1172
|
this.requestUpdate();
|
|
1193
1173
|
await this.updateComplete;
|
|
1194
|
-
dispatchPublic(this, "
|
|
1174
|
+
dispatchPublic(this, "qc-item-ref-connected", {
|
|
1195
1175
|
identifier: this.identifier,
|
|
1196
1176
|
href: this.href,
|
|
1197
1177
|
category: this.category
|
|
@@ -1356,7 +1336,7 @@ var QtiAssessmentTest = class extends LitElement3 {
|
|
|
1356
1336
|
async connectedCallback() {
|
|
1357
1337
|
super.connectedCallback();
|
|
1358
1338
|
await this.updateComplete;
|
|
1359
|
-
dispatchPublic(this, "
|
|
1339
|
+
dispatchPublic(this, "qc-test-loaded", this);
|
|
1360
1340
|
}
|
|
1361
1341
|
render() {
|
|
1362
1342
|
return html2` <slot></slot>`;
|
|
@@ -1495,6 +1475,9 @@ __decorate5([
|
|
|
1495
1475
|
property5({ type: Boolean, converter: stringToBooleanConverter3, attribute: "validate-responses" })
|
|
1496
1476
|
], QtiItemSessionControl.prototype, "validateResponses", void 0);
|
|
1497
1477
|
|
|
1478
|
+
// ../qti-test/dist/components/qti-number-presented/qti-number-presented.js
|
|
1479
|
+
import { consume as consume4 } from "@lit/context";
|
|
1480
|
+
|
|
1498
1481
|
// ../qti-test/dist/internal/item-ref-selection.js
|
|
1499
1482
|
var categoryList = (value) => value?.split(/\s+/).filter(Boolean) ?? [];
|
|
1500
1483
|
var selectionFrom = (element) => ({
|
|
@@ -1520,15 +1503,52 @@ var selectItemRefs = (testElement, { sectionIdentifier, includeCategories, exclu
|
|
|
1520
1503
|
});
|
|
1521
1504
|
};
|
|
1522
1505
|
|
|
1506
|
+
// ../qti-test/dist/components/qti-number-presented/qti-number-presented.js
|
|
1507
|
+
var __decorate6 = function(decorators, target, key, desc) {
|
|
1508
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1509
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1510
|
+
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;
|
|
1511
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1512
|
+
};
|
|
1513
|
+
var QtiNumberPresented = class extends QtiExpression {
|
|
1514
|
+
#connectedTest = null;
|
|
1515
|
+
constructor() {
|
|
1516
|
+
super();
|
|
1517
|
+
listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
|
|
1518
|
+
}
|
|
1519
|
+
/** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */
|
|
1520
|
+
get #testElement() {
|
|
1521
|
+
return this.#connectedTest ?? this.closest("qti-assessment-test");
|
|
1522
|
+
}
|
|
1523
|
+
getResult() {
|
|
1524
|
+
const testElement = this.#testElement;
|
|
1525
|
+
if (!testElement) {
|
|
1526
|
+
console.warn("qti-number-presented: no enclosing qti-assessment-test, nothing to count");
|
|
1527
|
+
return 0;
|
|
1528
|
+
}
|
|
1529
|
+
const presented = new Set((this._testContext?.items ?? []).filter((item) => {
|
|
1530
|
+
const status = item.variables?.find((v) => v.identifier === "completionStatus")?.value;
|
|
1531
|
+
return status != null && status !== "not_attempted";
|
|
1532
|
+
}).map((item) => item.identifier));
|
|
1533
|
+
return selectItemRefs(testElement, selectionFrom(this)).filter((itemRef) => presented.has(itemRef.identifier)).length;
|
|
1534
|
+
}
|
|
1535
|
+
calculate() {
|
|
1536
|
+
return this.getResult();
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
__decorate6([
|
|
1540
|
+
consume4({ context: testContext, subscribe: true })
|
|
1541
|
+
], QtiNumberPresented.prototype, "_testContext", void 0);
|
|
1542
|
+
|
|
1523
1543
|
// ../qti-test/dist/components/qti-number-selected/qti-number-selected.js
|
|
1524
1544
|
var QtiNumberSelected = class extends QtiExpression {
|
|
1525
1545
|
#connectedTest = null;
|
|
1526
1546
|
constructor() {
|
|
1527
1547
|
super();
|
|
1528
|
-
listenPublic2(this, "
|
|
1548
|
+
listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
|
|
1529
1549
|
}
|
|
1530
1550
|
/**
|
|
1531
|
-
* `
|
|
1551
|
+
* `qc-test-loaded` bubbles *up* from the test element, and this
|
|
1532
1552
|
* expression lives inside that test's `qti-outcome-processing` — so the
|
|
1533
1553
|
* listener above only ever fires for a test handed to us directly (a test
|
|
1534
1554
|
* harness). Walking up the tree is what resolves the test in a real document.
|
|
@@ -1604,7 +1624,160 @@ var QtiOutcomeProcessingProcessor = class {
|
|
|
1604
1624
|
|
|
1605
1625
|
// ../qti-test/dist/components/qti-test-feedback/qti-test-feedback.js
|
|
1606
1626
|
import { css as css4, html as html7 } from "lit";
|
|
1627
|
+
import { property as property6 } from "lit/decorators.js";
|
|
1628
|
+
|
|
1629
|
+
// ../qti-delivery/dist/model/xml-node.js
|
|
1630
|
+
var ELEMENT_NODE = 1;
|
|
1631
|
+
function childElements(parent, ...localNames) {
|
|
1632
|
+
const nodes = parent.childNodes;
|
|
1633
|
+
const children = [];
|
|
1634
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
1635
|
+
const node = nodes[index];
|
|
1636
|
+
if (node.nodeType === ELEMENT_NODE && localNames.includes(node.localName ?? "")) {
|
|
1637
|
+
children.push(node);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
return children;
|
|
1641
|
+
}
|
|
1642
|
+
var childElement = (parent, localName) => childElements(parent, localName)[0] ?? null;
|
|
1643
|
+
function booleanAttribute(element, name) {
|
|
1644
|
+
const value = element.getAttribute(name)?.trim();
|
|
1645
|
+
if (value === "true" || value === "1")
|
|
1646
|
+
return true;
|
|
1647
|
+
if (value === "false" || value === "0")
|
|
1648
|
+
return false;
|
|
1649
|
+
return void 0;
|
|
1650
|
+
}
|
|
1651
|
+
function integerAttribute(element, name) {
|
|
1652
|
+
const value = element.getAttribute(name)?.trim();
|
|
1653
|
+
return value && /^[+-]?\d+$/.test(value) ? Number(value) : void 0;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
// ../qti-delivery/dist/model/test-model.js
|
|
1657
|
+
var DEFAULT_SESSION_CONTROL = Object.freeze({
|
|
1658
|
+
maxAttempts: 1,
|
|
1659
|
+
showFeedback: false,
|
|
1660
|
+
allowReview: true,
|
|
1661
|
+
showSolution: false,
|
|
1662
|
+
allowComment: false,
|
|
1663
|
+
allowSkipping: true,
|
|
1664
|
+
validateResponses: false
|
|
1665
|
+
});
|
|
1666
|
+
function buildTestModel(test) {
|
|
1667
|
+
if (test.localName !== "qti-assessment-test") {
|
|
1668
|
+
throw new TypeError(`Expected a qti-assessment-test element, not ${String(test.localName)}.`);
|
|
1669
|
+
}
|
|
1670
|
+
return {
|
|
1671
|
+
identifier: test.getAttribute("identifier") ?? "",
|
|
1672
|
+
title: test.getAttribute("title") ?? "",
|
|
1673
|
+
testParts: childElements(test, "qti-test-part").map(buildTestPart)
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
function buildTestPart(part) {
|
|
1677
|
+
const sessionControl = resolveSessionControl(DEFAULT_SESSION_CONTROL, part);
|
|
1678
|
+
return {
|
|
1679
|
+
identifier: part.getAttribute("identifier") ?? "",
|
|
1680
|
+
navigationMode: part.getAttribute("navigation-mode") === "linear" ? "linear" : "nonlinear",
|
|
1681
|
+
submissionMode: part.getAttribute("submission-mode") === "simultaneous" ? "simultaneous" : "individual",
|
|
1682
|
+
sessionControl,
|
|
1683
|
+
sections: childElements(part, "qti-assessment-section").map((section) => buildSection(section, sessionControl))
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function buildSection(section, inherited) {
|
|
1687
|
+
const sessionControl = resolveSessionControl(inherited, section);
|
|
1688
|
+
return {
|
|
1689
|
+
kind: "section",
|
|
1690
|
+
identifier: section.getAttribute("identifier") ?? "",
|
|
1691
|
+
title: section.getAttribute("title") ?? "",
|
|
1692
|
+
visible: booleanAttribute(section, "visible") ?? true,
|
|
1693
|
+
sessionControl,
|
|
1694
|
+
content: childElements(section, "qti-assessment-section", "qti-assessment-item-ref").map((child) => child.localName === "qti-assessment-section" ? buildSection(child, sessionControl) : buildItemRef(child, sessionControl))
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
function buildItemRef(itemRef, inherited) {
|
|
1698
|
+
const category = itemRef.getAttribute("category")?.trim();
|
|
1699
|
+
return {
|
|
1700
|
+
kind: "itemRef",
|
|
1701
|
+
identifier: itemRef.getAttribute("identifier") ?? "",
|
|
1702
|
+
href: itemRef.getAttribute("href") ?? "",
|
|
1703
|
+
categories: category ? category.split(/\s+/) : [],
|
|
1704
|
+
sessionControl: resolveSessionControl(inherited, itemRef),
|
|
1705
|
+
declaredSessionControl: declaredSessionControl(itemRef)
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
function resolveSessionControl(inherited, owner) {
|
|
1709
|
+
return { ...inherited, ...declaredSessionControl(owner) };
|
|
1710
|
+
}
|
|
1711
|
+
function declaredSessionControl(owner) {
|
|
1712
|
+
const element = childElement(owner, "qti-item-session-control");
|
|
1713
|
+
if (!element)
|
|
1714
|
+
return {};
|
|
1715
|
+
const declared = {
|
|
1716
|
+
maxAttempts: integerAttribute(element, "max-attempts"),
|
|
1717
|
+
showFeedback: booleanAttribute(element, "show-feedback"),
|
|
1718
|
+
allowReview: booleanAttribute(element, "allow-review"),
|
|
1719
|
+
showSolution: booleanAttribute(element, "show-solution"),
|
|
1720
|
+
allowComment: booleanAttribute(element, "allow-comment"),
|
|
1721
|
+
allowSkipping: booleanAttribute(element, "allow-skipping"),
|
|
1722
|
+
validateResponses: booleanAttribute(element, "validate-responses")
|
|
1723
|
+
};
|
|
1724
|
+
return Object.fromEntries(Object.entries(declared).filter(([, value]) => value !== void 0));
|
|
1725
|
+
}
|
|
1726
|
+
var ownItemRefs = (section) => section.content.filter((child) => child.kind === "itemRef");
|
|
1727
|
+
function sectionsInOrder(sections) {
|
|
1728
|
+
return sections.flatMap((section) => [
|
|
1729
|
+
section,
|
|
1730
|
+
...sectionsInOrder(section.content.filter((child) => child.kind === "section"))
|
|
1731
|
+
]);
|
|
1732
|
+
}
|
|
1733
|
+
function itemRefsInOrder(sections) {
|
|
1734
|
+
return sections.flatMap((child) => child.kind === "itemRef" ? [child] : itemRefsInOrder(child.content));
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
// ../qti-delivery/dist/model/item-facts.js
|
|
1738
|
+
function readItemFacts(item) {
|
|
1739
|
+
if (item.localName !== "qti-assessment-item") {
|
|
1740
|
+
throw new TypeError(`Expected a qti-assessment-item element, not ${String(item.localName)}.`);
|
|
1741
|
+
}
|
|
1742
|
+
const responseDeclarations = childElements(item, "qti-response-declaration");
|
|
1743
|
+
const score = childElements(item, "qti-outcome-declaration").find((declaration) => declaration.getAttribute("identifier") === "SCORE");
|
|
1744
|
+
return {
|
|
1745
|
+
identifier: item.getAttribute("identifier") ?? "",
|
|
1746
|
+
adaptive: booleanAttribute(item, "adaptive") ?? false,
|
|
1747
|
+
timeDependent: booleanAttribute(item, "time-dependent") ?? false,
|
|
1748
|
+
hasCorrectResponse: responseDeclarations.some(hasSomethingToCompareWith),
|
|
1749
|
+
hasResponseProcessing: childElement(item, "qti-response-processing") !== null,
|
|
1750
|
+
externalScored: externalScored(score),
|
|
1751
|
+
label: item.getAttribute("label"),
|
|
1752
|
+
title: item.getAttribute("title") ?? ""
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
function hasSomethingToCompareWith(declaration) {
|
|
1756
|
+
if (childElement(declaration, "qti-correct-response"))
|
|
1757
|
+
return true;
|
|
1758
|
+
const mapping = childElement(declaration, "qti-mapping");
|
|
1759
|
+
if (mapping && childElement(mapping, "qti-map-entry"))
|
|
1760
|
+
return true;
|
|
1761
|
+
const areaMapping = childElement(declaration, "qti-area-mapping");
|
|
1762
|
+
return areaMapping !== null && childElement(areaMapping, "qti-area-map-entry") !== null;
|
|
1763
|
+
}
|
|
1764
|
+
function externalScored(declaration) {
|
|
1765
|
+
const value = declaration?.getAttribute("external-scored")?.trim();
|
|
1766
|
+
return value === "human" || value === "externalMachine" ? value : null;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// ../qti-test/dist/components/qti-test-feedback/qti-test-feedback.js
|
|
1770
|
+
var __decorate7 = function(decorators, target, key, desc) {
|
|
1771
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1772
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1773
|
+
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;
|
|
1774
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1775
|
+
};
|
|
1607
1776
|
var QtiTestFeedback = class extends QtiModalFeedback {
|
|
1777
|
+
constructor() {
|
|
1778
|
+
super(...arguments);
|
|
1779
|
+
this.access = "atEnd";
|
|
1780
|
+
}
|
|
1608
1781
|
static {
|
|
1609
1782
|
this.styles = css4`
|
|
1610
1783
|
:host {
|
|
@@ -1612,15 +1785,26 @@ var QtiTestFeedback = class extends QtiModalFeedback {
|
|
|
1612
1785
|
}
|
|
1613
1786
|
`;
|
|
1614
1787
|
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Whether this feedback applies for a value of its `outcome-identifier`: with `show-hide="show"`
|
|
1790
|
+
* when the value is (or, for a container, holds) its `identifier`; with `hide` when it is not.
|
|
1791
|
+
*/
|
|
1792
|
+
matches(value) {
|
|
1793
|
+
const found = Array.isArray(value) ? value.includes(this.identifier) : value != null && value === this.identifier;
|
|
1794
|
+
return this.showHide === "hide" ? !found : found;
|
|
1795
|
+
}
|
|
1615
1796
|
render() {
|
|
1616
1797
|
return html7``;
|
|
1617
1798
|
}
|
|
1618
1799
|
};
|
|
1800
|
+
__decorate7([
|
|
1801
|
+
property6({ type: String })
|
|
1802
|
+
], QtiTestFeedback.prototype, "access", void 0);
|
|
1619
1803
|
|
|
1620
1804
|
// ../qti-test/dist/components/qti-test-part/qti-test-part.js
|
|
1621
1805
|
import { html as html8, LitElement as LitElement8 } from "lit";
|
|
1622
|
-
import { property as
|
|
1623
|
-
var
|
|
1806
|
+
import { property as property7 } from "lit/decorators.js";
|
|
1807
|
+
var __decorate8 = function(decorators, target, key, desc) {
|
|
1624
1808
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1625
1809
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1626
1810
|
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;
|
|
@@ -1656,22 +1840,22 @@ var QtiTestPart = class extends LitElement8 {
|
|
|
1656
1840
|
return html8` <slot></slot>`;
|
|
1657
1841
|
}
|
|
1658
1842
|
};
|
|
1659
|
-
|
|
1660
|
-
|
|
1843
|
+
__decorate8([
|
|
1844
|
+
property7({ type: String })
|
|
1661
1845
|
], QtiTestPart.prototype, "identifier", void 0);
|
|
1662
|
-
|
|
1663
|
-
|
|
1846
|
+
__decorate8([
|
|
1847
|
+
property7({ type: String })
|
|
1664
1848
|
], QtiTestPart.prototype, "class", void 0);
|
|
1665
|
-
|
|
1666
|
-
|
|
1849
|
+
__decorate8([
|
|
1850
|
+
property7({ type: String, attribute: "navigation-mode" })
|
|
1667
1851
|
], QtiTestPart.prototype, "navigationMode", void 0);
|
|
1668
|
-
|
|
1669
|
-
|
|
1852
|
+
__decorate8([
|
|
1853
|
+
property7({ type: String, attribute: "submission-mode" })
|
|
1670
1854
|
], QtiTestPart.prototype, "submissionMode", void 0);
|
|
1671
1855
|
|
|
1672
1856
|
// ../qti-test/dist/components/qti-test-variables/qti-test-variables.js
|
|
1673
|
-
import { consume as
|
|
1674
|
-
var
|
|
1857
|
+
import { consume as consume5 } from "@lit/context";
|
|
1858
|
+
var __decorate9 = function(decorators, target, key, desc) {
|
|
1675
1859
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1676
1860
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1677
1861
|
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;
|
|
@@ -1681,10 +1865,10 @@ var QtiTestVariables = class extends QtiExpression {
|
|
|
1681
1865
|
#connectedTest = null;
|
|
1682
1866
|
constructor() {
|
|
1683
1867
|
super();
|
|
1684
|
-
listenPublic2(this, "
|
|
1868
|
+
listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
|
|
1685
1869
|
}
|
|
1686
1870
|
/**
|
|
1687
|
-
* `
|
|
1871
|
+
* `qc-test-loaded` bubbles *up* from the test element, and this
|
|
1688
1872
|
* expression lives inside that test's `qti-outcome-processing` — so the
|
|
1689
1873
|
* listener above only ever fires for a test handed to us directly (a test
|
|
1690
1874
|
* harness). Walking up the tree is what resolves the test in a real document.
|
|
@@ -1712,8 +1896,8 @@ var QtiTestVariables = class extends QtiExpression {
|
|
|
1712
1896
|
return this.getResult();
|
|
1713
1897
|
}
|
|
1714
1898
|
};
|
|
1715
|
-
|
|
1716
|
-
|
|
1899
|
+
__decorate9([
|
|
1900
|
+
consume5({ context: testContext, subscribe: true })
|
|
1717
1901
|
], QtiTestVariables.prototype, "_testContext", void 0);
|
|
1718
1902
|
var QtiTestVariablesExpression = class {
|
|
1719
1903
|
constructor(testContext2, itemVariable, includedItems) {
|
|
@@ -1745,12 +1929,17 @@ var QtiTestVariablesExpression = class {
|
|
|
1745
1929
|
var QTI_TEST_STATE_VERSION = 1;
|
|
1746
1930
|
|
|
1747
1931
|
// ../qti-test/dist/components/qti-test/qti-test.js
|
|
1748
|
-
import { ContextProvider, provide as
|
|
1932
|
+
import { ContextProvider, provide as provide3 } from "@lit/context";
|
|
1749
1933
|
import { html as html9, LitElement as LitElement10 } from "lit";
|
|
1750
|
-
import { state as
|
|
1934
|
+
import { state as state3 } from "lit/decorators.js";
|
|
1751
1935
|
|
|
1752
1936
|
// ../qti-test/dist/mixins/test-navigation.mixin.js
|
|
1753
|
-
import {
|
|
1937
|
+
import { provide } from "@lit/context";
|
|
1938
|
+
import { property as property8, state as state2 } from "lit/decorators.js";
|
|
1939
|
+
|
|
1940
|
+
// ../qti-test/dist/internal/item-facts.context.js
|
|
1941
|
+
import { createContext as createContext2 } from "@lit/context";
|
|
1942
|
+
var itemFactsContext = createContext2(/* @__PURE__ */ Symbol("itemFacts"));
|
|
1754
1943
|
|
|
1755
1944
|
// ../qti-test/dist/internal/item-sequencing.js
|
|
1756
1945
|
var SECTION = "qti-assessment-section";
|
|
@@ -1843,7 +2032,7 @@ function preConditionsPass(itemRef, from) {
|
|
|
1843
2032
|
}
|
|
1844
2033
|
|
|
1845
2034
|
// ../qti-test/dist/mixins/test-navigation.mixin.js
|
|
1846
|
-
var
|
|
2035
|
+
var __decorate10 = function(decorators, target, key, desc) {
|
|
1847
2036
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1848
2037
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1849
2038
|
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;
|
|
@@ -1857,6 +2046,7 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1857
2046
|
this.requestTimeout = 3e4;
|
|
1858
2047
|
this.postLoadTransformCallback = null;
|
|
1859
2048
|
this.postLoadTestTransformCallback = null;
|
|
2049
|
+
this.itemFacts = /* @__PURE__ */ new Map();
|
|
1860
2050
|
this._activeController = null;
|
|
1861
2051
|
this._loadResults = [];
|
|
1862
2052
|
this._navigationId = 0;
|
|
@@ -1882,20 +2072,21 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1882
2072
|
navigateTo(type, id) {
|
|
1883
2073
|
const targetId = id || this._getDefaultNavigationId(type);
|
|
1884
2074
|
if (targetId) {
|
|
1885
|
-
dispatchPublic(this, "
|
|
2075
|
+
dispatchPublic(this, "qc-test-navigate", { type, id: targetId });
|
|
1886
2076
|
}
|
|
1887
2077
|
}
|
|
1888
2078
|
// ===========================================
|
|
1889
2079
|
// EVENT HANDLER SETUP
|
|
1890
2080
|
// ===========================================
|
|
1891
2081
|
_bindEventHandlers() {
|
|
1892
|
-
listenPublic2(this, "
|
|
1893
|
-
listenPublic2(this, "
|
|
2082
|
+
listenPublic2(this, "qc-test-navigate", this._handleNavigationRequest.bind(this));
|
|
2083
|
+
listenPublic2(this, "qc-test-loaded", this._handleTestConnected.bind(this));
|
|
1894
2084
|
this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
|
|
1895
2085
|
this.addEventListener("qti-assessment-stimulus-ref-connected", this._handleStimulusRefConnected.bind(this));
|
|
1896
2086
|
}
|
|
1897
2087
|
_handleTestConnected(e) {
|
|
1898
2088
|
this._testElement = e.detail;
|
|
2089
|
+
this.itemFacts = /* @__PURE__ */ new Map();
|
|
1899
2090
|
this._initializeNavigation();
|
|
1900
2091
|
}
|
|
1901
2092
|
/**
|
|
@@ -1967,9 +2158,9 @@ var TestNavigationMixin = (superClass) => {
|
|
|
1967
2158
|
if (refs[0]?.closest("qti-test-part")?.getAttribute("navigation-mode") === "linear") {
|
|
1968
2159
|
const first = resolveFirstItem(refs);
|
|
1969
2160
|
if (first.skipped.length)
|
|
1970
|
-
dispatchPublic(this, "
|
|
2161
|
+
dispatchPublic(this, "qc-test-items-skipped", { ids: first.skipped });
|
|
1971
2162
|
if (first.id === null) {
|
|
1972
|
-
dispatchPublic(this, "
|
|
2163
|
+
dispatchPublic(this, "qc-test-end-reached", {});
|
|
1973
2164
|
return;
|
|
1974
2165
|
}
|
|
1975
2166
|
id = first.id;
|
|
@@ -2034,8 +2225,8 @@ var TestNavigationMixin = (superClass) => {
|
|
|
2034
2225
|
const resolved = this._resolveLinearNext(detail.type, detail.id);
|
|
2035
2226
|
if (resolved?.id === null) {
|
|
2036
2227
|
if (resolved.skipped.length)
|
|
2037
|
-
dispatchPublic(this, "
|
|
2038
|
-
dispatchPublic(this, "
|
|
2228
|
+
dispatchPublic(this, "qc-test-items-skipped", { ids: resolved.skipped });
|
|
2229
|
+
dispatchPublic(this, "qc-test-end-reached", {});
|
|
2039
2230
|
return;
|
|
2040
2231
|
}
|
|
2041
2232
|
const target = resolved?.id ?? detail.id;
|
|
@@ -2051,7 +2242,7 @@ var TestNavigationMixin = (superClass) => {
|
|
|
2051
2242
|
this._activeController = controller;
|
|
2052
2243
|
await this._executeNavigation(detail.type, target, navigationId, controller);
|
|
2053
2244
|
if (resolved?.skipped.length && navigationId === this._navigationId && !controller.signal.aborted) {
|
|
2054
|
-
dispatchPublic(this, "
|
|
2245
|
+
dispatchPublic(this, "qc-test-items-skipped", { ids: resolved.skipped });
|
|
2055
2246
|
}
|
|
2056
2247
|
} catch (error) {
|
|
2057
2248
|
this._handleNavigationError(error, detail.type, target);
|
|
@@ -2094,13 +2285,15 @@ var TestNavigationMixin = (superClass) => {
|
|
|
2094
2285
|
async _navigateToSection(sectionId, navigationId, controller) {
|
|
2095
2286
|
const sectionEl = this._findSection(sectionId);
|
|
2096
2287
|
const navPartId = sectionEl?.closest("qti-test-part")?.identifier;
|
|
2288
|
+
const itemIds = this._getSectionItemIds(sectionId);
|
|
2097
2289
|
this.sessionContext = {
|
|
2098
2290
|
...this.sessionContext,
|
|
2099
2291
|
navPartId,
|
|
2100
2292
|
navSectionId: sectionId,
|
|
2101
|
-
|
|
2293
|
+
// with navigate="item", the section's first item is the current position, so test-next/test-prev
|
|
2294
|
+
// and item highlights have an item to work from
|
|
2295
|
+
navItemRefId: this.navigate === "item" ? itemIds[0] ?? null : null
|
|
2102
2296
|
};
|
|
2103
|
-
const itemIds = this._getSectionItemIds(sectionId);
|
|
2104
2297
|
this._resetLoadingState();
|
|
2105
2298
|
this._loadingState.expectedItems = itemIds.length;
|
|
2106
2299
|
await this._loadItems(itemIds, navigationId, controller);
|
|
@@ -2228,10 +2421,14 @@ var TestNavigationMixin = (superClass) => {
|
|
|
2228
2421
|
const validResults = results.filter(Boolean);
|
|
2229
2422
|
if (this._isStaleNavigation(navigationId, controller))
|
|
2230
2423
|
return;
|
|
2231
|
-
|
|
2424
|
+
const itemFacts = new Map(this.itemFacts);
|
|
2425
|
+
validResults.forEach(({ itemRef, doc, facts }) => {
|
|
2232
2426
|
if (itemRef && doc)
|
|
2233
2427
|
itemRef.xmlDoc = doc;
|
|
2428
|
+
if (itemRef && facts)
|
|
2429
|
+
itemFacts.set(itemRef.identifier, facts);
|
|
2234
2430
|
});
|
|
2431
|
+
this.itemFacts = itemFacts;
|
|
2235
2432
|
validResults.forEach(({ itemRef }) => {
|
|
2236
2433
|
const itemId = itemRef?.identifier;
|
|
2237
2434
|
if (!itemRef || !itemId)
|
|
@@ -2258,7 +2455,9 @@ var TestNavigationMixin = (superClass) => {
|
|
|
2258
2455
|
if (this._isStaleNavigation(navigationId, controller)) {
|
|
2259
2456
|
return null;
|
|
2260
2457
|
}
|
|
2261
|
-
|
|
2458
|
+
const item = transformer.xmlDoc().documentElement;
|
|
2459
|
+
const facts = item?.localName === "qti-assessment-item" ? readItemFacts(item) : null;
|
|
2460
|
+
return { itemRef, doc: transformer.htmlDoc(this._customElementRegistry()), facts };
|
|
2262
2461
|
} catch (error) {
|
|
2263
2462
|
if (error.name === "AbortError") {
|
|
2264
2463
|
console.info(`Item load for ${itemRef.identifier} was aborted`);
|
|
@@ -2328,7 +2527,7 @@ var TestNavigationMixin = (superClass) => {
|
|
|
2328
2527
|
// EVENT DISPATCHING
|
|
2329
2528
|
// ===========================================
|
|
2330
2529
|
_dispatchLoadingStarted(type, id) {
|
|
2331
|
-
dispatchPublic(this, "
|
|
2530
|
+
dispatchPublic(this, "qc-test-navigation-started", { type, id });
|
|
2332
2531
|
}
|
|
2333
2532
|
_dispatchLoadingEnded(type, id) {
|
|
2334
2533
|
this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended", {
|
|
@@ -2338,31 +2537,35 @@ var TestNavigationMixin = (superClass) => {
|
|
|
2338
2537
|
}));
|
|
2339
2538
|
}
|
|
2340
2539
|
_dispatchError(error) {
|
|
2341
|
-
dispatchPublic(this, "
|
|
2540
|
+
dispatchPublic(this, "qc-test-navigation-failed", error);
|
|
2342
2541
|
}
|
|
2343
|
-
/** The items are in the DOM: tell hosts the new position rendered (`
|
|
2542
|
+
/** The items are in the DOM: tell hosts the new position rendered (`qc-test-navigated`) and which items it holds. */
|
|
2344
2543
|
_dispatchTestLoaded(results, type, id) {
|
|
2345
2544
|
requestAnimationFrame(() => {
|
|
2346
|
-
dispatchPublic(this, "
|
|
2545
|
+
dispatchPublic(this, "qc-test-rendered", results.map(({ itemRef }) => ({
|
|
2347
2546
|
identifier: itemRef?.identifier,
|
|
2348
2547
|
element: itemRef
|
|
2349
2548
|
})));
|
|
2350
|
-
dispatchPublic(this, "
|
|
2549
|
+
dispatchPublic(this, "qc-test-navigated", { type, id });
|
|
2351
2550
|
});
|
|
2352
2551
|
}
|
|
2353
2552
|
}
|
|
2354
|
-
|
|
2355
|
-
|
|
2553
|
+
__decorate10([
|
|
2554
|
+
property8({ type: String })
|
|
2356
2555
|
], TestNavigationClass.prototype, "navigate", void 0);
|
|
2357
|
-
|
|
2358
|
-
|
|
2556
|
+
__decorate10([
|
|
2557
|
+
property8({ type: Number })
|
|
2359
2558
|
], TestNavigationClass.prototype, "requestTimeout", void 0);
|
|
2360
|
-
|
|
2361
|
-
|
|
2559
|
+
__decorate10([
|
|
2560
|
+
property8({ attribute: false })
|
|
2362
2561
|
], TestNavigationClass.prototype, "postLoadTransformCallback", void 0);
|
|
2363
|
-
|
|
2364
|
-
|
|
2562
|
+
__decorate10([
|
|
2563
|
+
property8({ attribute: false })
|
|
2365
2564
|
], TestNavigationClass.prototype, "postLoadTestTransformCallback", void 0);
|
|
2565
|
+
__decorate10([
|
|
2566
|
+
state2(),
|
|
2567
|
+
provide({ context: itemFactsContext })
|
|
2568
|
+
], TestNavigationClass.prototype, "itemFacts", void 0);
|
|
2366
2569
|
return TestNavigationClass;
|
|
2367
2570
|
};
|
|
2368
2571
|
|
|
@@ -2372,11 +2575,11 @@ var TestViewMixin = (superClass) => {
|
|
|
2372
2575
|
constructor(...args) {
|
|
2373
2576
|
super(...args);
|
|
2374
2577
|
this.sessionContext = { ...this.sessionContext, view: "candidate" };
|
|
2375
|
-
listenPublic2(this, "
|
|
2578
|
+
listenPublic2(this, "qc-test-switch-view", (e) => {
|
|
2376
2579
|
this.sessionContext = { ...this.sessionContext, view: e.detail };
|
|
2377
2580
|
this._updateElementView();
|
|
2378
2581
|
});
|
|
2379
|
-
listenPublic2(this, "
|
|
2582
|
+
listenPublic2(this, "qc-test-loaded", () => {
|
|
2380
2583
|
this._updateElementView();
|
|
2381
2584
|
});
|
|
2382
2585
|
this.addEventListener("qti-assessment-item-connected", (e) => {
|
|
@@ -2415,10 +2618,10 @@ var TestViewMixin = (superClass) => {
|
|
|
2415
2618
|
};
|
|
2416
2619
|
|
|
2417
2620
|
// ../qti-test/dist/mixins/test-base.js
|
|
2418
|
-
import { provide } from "@lit/context";
|
|
2621
|
+
import { provide as provide2 } from "@lit/context";
|
|
2419
2622
|
import { LitElement as LitElement9 } from "lit";
|
|
2420
|
-
import { property as
|
|
2421
|
-
var
|
|
2623
|
+
import { property as property9 } from "lit/decorators.js";
|
|
2624
|
+
var __decorate11 = function(decorators, target, key, desc) {
|
|
2422
2625
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2423
2626
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2424
2627
|
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;
|
|
@@ -2444,6 +2647,8 @@ var TestBaseMixin = (superClass) => {
|
|
|
2444
2647
|
} else {
|
|
2445
2648
|
const newVariables = [...assessmentItem.variables];
|
|
2446
2649
|
for (const variable of itemContext.variables) {
|
|
2650
|
+
if (variable.identifier === "completionStatus" && variable.value === "not_attempted")
|
|
2651
|
+
continue;
|
|
2447
2652
|
const currentVariable = newVariables.find((v) => v.identifier === variable.identifier);
|
|
2448
2653
|
if (currentVariable) {
|
|
2449
2654
|
currentVariable.value = variable.value;
|
|
@@ -2452,6 +2657,7 @@ var TestBaseMixin = (superClass) => {
|
|
|
2452
2657
|
}
|
|
2453
2658
|
}
|
|
2454
2659
|
assessmentItem.variables = newVariables;
|
|
2660
|
+
this.#leaveNotAttempted(identifier, newVariables.find((v) => v.identifier === "completionStatus")?.value);
|
|
2455
2661
|
if (itemContext.state) {
|
|
2456
2662
|
assessmentItem.state = itemContext.state;
|
|
2457
2663
|
}
|
|
@@ -2466,12 +2672,12 @@ var TestBaseMixin = (superClass) => {
|
|
|
2466
2672
|
* before the item has loaded. To restore a whole session, assign `state` instead.
|
|
2467
2673
|
*
|
|
2468
2674
|
* The test context is replaced rather than changed in place, so its consumers update and
|
|
2469
|
-
* `
|
|
2675
|
+
* `qc-test-state-changed` fires.
|
|
2470
2676
|
*
|
|
2471
2677
|
* @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.
|
|
2472
2678
|
* @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.
|
|
2473
2679
|
*/
|
|
2474
|
-
updateItemVariables(itemRefID, values,
|
|
2680
|
+
updateItemVariables(itemRefID, values, state6) {
|
|
2475
2681
|
this.testContext = {
|
|
2476
2682
|
...this.testContext,
|
|
2477
2683
|
items: this.testContext.items.map((item) => {
|
|
@@ -2491,22 +2697,22 @@ var TestBaseMixin = (superClass) => {
|
|
|
2491
2697
|
else
|
|
2492
2698
|
variables.push(updated);
|
|
2493
2699
|
}
|
|
2494
|
-
return { ...item, variables, ...
|
|
2700
|
+
return { ...item, variables, ...state6 ? { state: { ...state6 } } : {} };
|
|
2495
2701
|
})
|
|
2496
2702
|
};
|
|
2497
2703
|
const assessmentItem = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(itemRefID)}"]`)?.assessmentItem;
|
|
2498
2704
|
if (!assessmentItem)
|
|
2499
2705
|
return;
|
|
2500
2706
|
assessmentItem.variables = [...this.testContext.items.find((i) => i.identifier === itemRefID)?.variables ?? []];
|
|
2501
|
-
if (
|
|
2502
|
-
assessmentItem.state =
|
|
2707
|
+
if (state6)
|
|
2708
|
+
assessmentItem.state = state6;
|
|
2503
2709
|
}
|
|
2504
2710
|
_initializeEventListeners() {
|
|
2505
2711
|
this.addEventListener("qti-testdoc-loaded", () => {
|
|
2506
2712
|
this.testContext = INITIAL_TEST_CONTEXT;
|
|
2507
2713
|
this.sessionContext = INITIAL_SESSION_CONTEXT;
|
|
2508
2714
|
});
|
|
2509
|
-
listenPublic2(this, "
|
|
2715
|
+
listenPublic2(this, "qc-test-loaded", (e) => {
|
|
2510
2716
|
this._testElement = e.detail;
|
|
2511
2717
|
const items = Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map((itemRef) => {
|
|
2512
2718
|
return {
|
|
@@ -2536,7 +2742,7 @@ var TestBaseMixin = (superClass) => {
|
|
|
2536
2742
|
this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state, e.detail.itemContext.valid);
|
|
2537
2743
|
});
|
|
2538
2744
|
}
|
|
2539
|
-
_updateItemVariablesInTestContext(identifier, variables,
|
|
2745
|
+
_updateItemVariablesInTestContext(identifier, variables, state6, valid) {
|
|
2540
2746
|
this.testContext = {
|
|
2541
2747
|
...this.testContext,
|
|
2542
2748
|
// Spread existing test context properties
|
|
@@ -2551,21 +2757,37 @@ var TestBaseMixin = (superClass) => {
|
|
|
2551
2757
|
const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
|
|
2552
2758
|
return matchingVariable ? { ...matchingVariable, ...variable } : variable;
|
|
2553
2759
|
}),
|
|
2554
|
-
...
|
|
2760
|
+
...state6 !== void 0 ? { state: state6 ? { ...state6 } : void 0 } : {},
|
|
2555
2761
|
...valid !== void 0 ? { valid } : {}
|
|
2556
2762
|
};
|
|
2557
2763
|
})
|
|
2558
2764
|
};
|
|
2559
2765
|
this.dispatchEvent(new CustomEvent("qti-test-context-updated", { detail: this.testContext, bubbles: false, composed: false }));
|
|
2560
2766
|
}
|
|
2767
|
+
/** Write the presented item's own status over a `not_attempted` the test context still holds for it. */
|
|
2768
|
+
#leaveNotAttempted(identifier, status) {
|
|
2769
|
+
if (typeof status !== "string" || status === "not_attempted")
|
|
2770
|
+
return;
|
|
2771
|
+
const item = this.testContext.items.find((i) => i.identifier === identifier);
|
|
2772
|
+
const current = item?.variables.find((v) => v.identifier === "completionStatus");
|
|
2773
|
+
if (current?.value !== "not_attempted")
|
|
2774
|
+
return;
|
|
2775
|
+
this.testContext = {
|
|
2776
|
+
...this.testContext,
|
|
2777
|
+
items: this.testContext.items.map((i) => i.identifier !== identifier ? i : {
|
|
2778
|
+
...i,
|
|
2779
|
+
variables: i.variables.map((v) => v.identifier === "completionStatus" ? { ...v, value: status } : v)
|
|
2780
|
+
})
|
|
2781
|
+
};
|
|
2782
|
+
}
|
|
2561
2783
|
}
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2784
|
+
__decorate11([
|
|
2785
|
+
property9({ attribute: false, type: Object }),
|
|
2786
|
+
provide2({ context: testContext })
|
|
2565
2787
|
], TestBaseClass.prototype, "testContext", void 0);
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2788
|
+
__decorate11([
|
|
2789
|
+
property9({ attribute: false, type: Object }),
|
|
2790
|
+
provide2({ context: sessionContext })
|
|
2569
2791
|
], TestBaseClass.prototype, "sessionContext", void 0);
|
|
2570
2792
|
return TestBaseClass;
|
|
2571
2793
|
};
|
|
@@ -2575,8 +2797,8 @@ var TestBase = class extends TestBaseMixin(LitElement9) {
|
|
|
2575
2797
|
// ../qti-test/dist/mixins/test-state.mixin.js
|
|
2576
2798
|
var copy = (value) => Array.isArray(value) ? [...value] : value ?? null;
|
|
2577
2799
|
var isQtiTestState = (value) => {
|
|
2578
|
-
const
|
|
2579
|
-
return
|
|
2800
|
+
const state6 = value;
|
|
2801
|
+
return state6?.version === QTI_TEST_STATE_VERSION && Array.isArray(state6.test?.items) && Array.isArray(state6.test?.outcomes) && typeof state6.session === "object" && state6.session !== null;
|
|
2580
2802
|
};
|
|
2581
2803
|
var toState = (test, session) => ({
|
|
2582
2804
|
version: QTI_TEST_STATE_VERSION,
|
|
@@ -2593,6 +2815,7 @@ var toState = (test, session) => ({
|
|
|
2593
2815
|
outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
|
|
2594
2816
|
},
|
|
2595
2817
|
session: {
|
|
2818
|
+
...session?.plugins && Object.keys(session.plugins).length > 0 ? { plugins: { ...session.plugins } } : {},
|
|
2596
2819
|
...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
|
|
2597
2820
|
...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
|
|
2598
2821
|
...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
|
|
@@ -2615,7 +2838,8 @@ var TestStateMixin = (superClass) => {
|
|
|
2615
2838
|
this.#ready = false;
|
|
2616
2839
|
this.#lastEmitted = null;
|
|
2617
2840
|
});
|
|
2618
|
-
listenPublic2(this, "
|
|
2841
|
+
listenPublic2(this, "qc-test-update-plugin-state", ({ detail }) => this.#updatePluginState(detail));
|
|
2842
|
+
listenPublic2(this, "qc-test-loaded", () => {
|
|
2619
2843
|
if (this.#pending) {
|
|
2620
2844
|
this.#apply(this.#pending);
|
|
2621
2845
|
this.#pending = null;
|
|
@@ -2623,6 +2847,22 @@ var TestStateMixin = (superClass) => {
|
|
|
2623
2847
|
this.#ready = true;
|
|
2624
2848
|
});
|
|
2625
2849
|
}
|
|
2850
|
+
/** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */
|
|
2851
|
+
#updatePluginState({ plugin, value }) {
|
|
2852
|
+
if (typeof plugin !== "string" || plugin === "")
|
|
2853
|
+
return;
|
|
2854
|
+
const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};
|
|
2855
|
+
let next = others;
|
|
2856
|
+
if (value !== null && value !== void 0) {
|
|
2857
|
+
try {
|
|
2858
|
+
next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };
|
|
2859
|
+
} catch {
|
|
2860
|
+
console.warn(`[qti-test] Ignoring plugin state for "${plugin}": it is not JSON.`);
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
this.sessionContext = { ...this.sessionContext, plugins: next };
|
|
2865
|
+
}
|
|
2626
2866
|
get state() {
|
|
2627
2867
|
return toState(this.testContext, this.sessionContext);
|
|
2628
2868
|
}
|
|
@@ -2648,22 +2888,26 @@ var TestStateMixin = (superClass) => {
|
|
|
2648
2888
|
super.updated(changed);
|
|
2649
2889
|
if (!this.#ready || !(changed.has("testContext") || changed.has("sessionContext")))
|
|
2650
2890
|
return;
|
|
2651
|
-
const
|
|
2652
|
-
const serialized = JSON.stringify(
|
|
2891
|
+
const state6 = this.state;
|
|
2892
|
+
const serialized = JSON.stringify(state6);
|
|
2653
2893
|
if (serialized === this.#lastEmitted)
|
|
2654
2894
|
return;
|
|
2655
2895
|
this.#lastEmitted = serialized;
|
|
2656
|
-
dispatchPublic(this, "
|
|
2896
|
+
dispatchPublic(this, "qc-test-state-changed", state6);
|
|
2657
2897
|
}
|
|
2658
|
-
#apply(
|
|
2659
|
-
for (const saved of
|
|
2898
|
+
#apply(state6) {
|
|
2899
|
+
for (const saved of state6.test.items)
|
|
2660
2900
|
this.updateItemVariables(saved.identifier, saved.variables, saved.state);
|
|
2661
|
-
const savedOutcomes = new Map(
|
|
2901
|
+
const savedOutcomes = new Map(state6.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
|
|
2662
2902
|
this.testContext = {
|
|
2663
2903
|
...this.testContext,
|
|
2664
2904
|
testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
|
|
2665
2905
|
};
|
|
2666
|
-
this.sessionContext = {
|
|
2906
|
+
this.sessionContext = {
|
|
2907
|
+
...this.sessionContext,
|
|
2908
|
+
...this.#validSession(state6.session),
|
|
2909
|
+
plugins: state6.session.plugins && typeof state6.session.plugins === "object" ? { ...state6.session.plugins } : {}
|
|
2910
|
+
};
|
|
2667
2911
|
}
|
|
2668
2912
|
/** A stored position may point at an item or section a revised test no longer has. */
|
|
2669
2913
|
#validSession(session) {
|
|
@@ -2675,7 +2919,7 @@ var TestStateMixin = (superClass) => {
|
|
|
2675
2919
|
};
|
|
2676
2920
|
}
|
|
2677
2921
|
#requestNavigation(type, id) {
|
|
2678
|
-
dispatchPublic(this, "
|
|
2922
|
+
dispatchPublic(this, "qc-test-navigate", { type, id });
|
|
2679
2923
|
}
|
|
2680
2924
|
}
|
|
2681
2925
|
return TestStateClass;
|
|
@@ -2693,6 +2937,7 @@ var TestProcessingMixin = (superClass) => {
|
|
|
2693
2937
|
};
|
|
2694
2938
|
e.stopPropagation();
|
|
2695
2939
|
});
|
|
2940
|
+
listenPublic2(this, "qc-test-submit", () => this.submit());
|
|
2696
2941
|
this.addEventListener("qti-set-outcome-value", (e) => {
|
|
2697
2942
|
const { outcomeIdentifier, value } = e.detail;
|
|
2698
2943
|
this.updateOutcomeVariable(outcomeIdentifier, value);
|
|
@@ -2703,9 +2948,35 @@ var TestProcessingMixin = (superClass) => {
|
|
|
2703
2948
|
const outcomeProcessor = (this._testElement ?? this).querySelector("qti-outcome-processing");
|
|
2704
2949
|
if (!outcomeProcessor)
|
|
2705
2950
|
return false;
|
|
2706
|
-
|
|
2951
|
+
this.testContext = {
|
|
2952
|
+
...this.testContext,
|
|
2953
|
+
testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => ({
|
|
2954
|
+
...v,
|
|
2955
|
+
value: v.defaultValue ?? null
|
|
2956
|
+
}))
|
|
2957
|
+
};
|
|
2958
|
+
outcomeProcessor.process();
|
|
2959
|
+
return true;
|
|
2960
|
+
}
|
|
2961
|
+
/**
|
|
2962
|
+
* Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with
|
|
2963
|
+
* `qc-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.
|
|
2964
|
+
*/
|
|
2965
|
+
submit() {
|
|
2966
|
+
if (!this.outcomeProcessing())
|
|
2967
|
+
return false;
|
|
2968
|
+
dispatchPublic(this, "qc-test-submitted", {});
|
|
2707
2969
|
return true;
|
|
2708
2970
|
}
|
|
2971
|
+
/**
|
|
2972
|
+
* The `qti-test-feedback` elements that apply now, read from the test outcomes: run
|
|
2973
|
+
* `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to
|
|
2974
|
+
* while it runs (`during`); without it, both.
|
|
2975
|
+
*/
|
|
2976
|
+
getTestFeedback(access) {
|
|
2977
|
+
const feedback = Array.from((this._testElement ?? this).querySelectorAll("qti-test-feedback") ?? []);
|
|
2978
|
+
return feedback.filter((fb) => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value));
|
|
2979
|
+
}
|
|
2709
2980
|
/* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */
|
|
2710
2981
|
updateOutcomeVariable(identifier, value) {
|
|
2711
2982
|
const outcomeVariable = this.getOutcome(identifier);
|
|
@@ -2737,7 +3008,7 @@ var TestProcessingMixin = (superClass) => {
|
|
|
2737
3008
|
};
|
|
2738
3009
|
|
|
2739
3010
|
// ../qti-test/dist/components/qti-test/qti-test.js
|
|
2740
|
-
var
|
|
3011
|
+
var __decorate12 = function(decorators, target, key, desc) {
|
|
2741
3012
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2742
3013
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2743
3014
|
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;
|
|
@@ -2771,115 +3042,27 @@ var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixi
|
|
|
2771
3042
|
return html9`<slot></slot>`;
|
|
2772
3043
|
}
|
|
2773
3044
|
};
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
3045
|
+
__decorate12([
|
|
3046
|
+
state3(),
|
|
3047
|
+
provide3({ context: configContext })
|
|
2777
3048
|
], QtiTest.prototype, "configContext", void 0);
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
3049
|
+
__decorate12([
|
|
3050
|
+
state3(),
|
|
3051
|
+
provide3({ context: qtiContext })
|
|
2781
3052
|
], QtiTest.prototype, "qtiContext", void 0);
|
|
2782
3053
|
|
|
2783
|
-
// ../qti-test/dist/components/test-check-item/test-check-item.js
|
|
2784
|
-
import { consume as consume5 } from "@lit/context";
|
|
2785
|
-
import { css as css6, html as html10, LitElement as LitElement11 } from "lit";
|
|
2786
|
-
|
|
2787
|
-
// ../qti-test/dist/components/styles.js
|
|
2788
|
-
import { css as css5 } from "lit";
|
|
2789
|
-
var form = css5`
|
|
2790
|
-
display: inline-flex;
|
|
2791
|
-
align-items: center;
|
|
2792
|
-
justify-content: center;
|
|
2793
|
-
gap: 0.375em;
|
|
2794
|
-
box-sizing: border-box;
|
|
2795
|
-
min-block-size: var(--test-button-size, 2.25rem);
|
|
2796
|
-
padding: 0 0.875rem;
|
|
2797
|
-
font: inherit;
|
|
2798
|
-
line-height: 1.25;
|
|
2799
|
-
cursor: pointer;
|
|
2800
|
-
user-select: none;
|
|
2801
|
-
border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
|
|
2802
|
-
`;
|
|
2803
|
-
var btn = css5`
|
|
2804
|
-
${form};
|
|
2805
|
-
background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
|
|
2806
|
-
color: var(--test-button-color, var(--qti-component-color, inherit));
|
|
2807
|
-
border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
|
|
2808
|
-
var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
|
|
2809
|
-
`;
|
|
2810
|
-
var btnInteractive = css5`
|
|
2811
|
-
background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
|
|
2812
|
-
`;
|
|
2813
|
-
var focusRing = css5`
|
|
2814
|
-
outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
|
|
2815
|
-
outline-offset: 2px;
|
|
2816
|
-
`;
|
|
2817
|
-
var dis = css5`
|
|
2818
|
-
cursor: not-allowed;
|
|
2819
|
-
opacity: 0.45;
|
|
2820
|
-
`;
|
|
2821
|
-
var ind = css5`
|
|
2822
|
-
${form};
|
|
2823
|
-
border: 1px solid gray;
|
|
2824
|
-
`;
|
|
2825
|
-
|
|
2826
|
-
// ../qti-test/dist/components/test-check-item/test-check-item.js
|
|
2827
|
-
var __decorate11 = function(decorators, target, key, desc) {
|
|
2828
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2829
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2830
|
-
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;
|
|
2831
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2832
|
-
};
|
|
2833
|
-
var TestCheckItem = class extends LitElement11 {
|
|
2834
|
-
static {
|
|
2835
|
-
this.styles = css6`
|
|
2836
|
-
:host {
|
|
2837
|
-
${btn};
|
|
2838
|
-
}
|
|
2839
|
-
:host(:hover:not([disabled])) {
|
|
2840
|
-
${btnInteractive};
|
|
2841
|
-
}
|
|
2842
|
-
:host(:focus-visible) {
|
|
2843
|
-
${focusRing};
|
|
2844
|
-
}
|
|
2845
|
-
:host([disabled]) {
|
|
2846
|
-
${dis};
|
|
2847
|
-
}
|
|
2848
|
-
`;
|
|
2849
|
-
}
|
|
2850
|
-
constructor() {
|
|
2851
|
-
super();
|
|
2852
|
-
this.addEventListener("click", () => {
|
|
2853
|
-
dispatchPublic(this, "cito-test-end-attempt", {});
|
|
2854
|
-
const testContainer = this.testHost?.querySelector("test-container");
|
|
2855
|
-
if (!testContainer)
|
|
2856
|
-
return;
|
|
2857
|
-
const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
|
|
2858
|
-
viewElements.forEach((element) => {
|
|
2859
|
-
element.classList.toggle("show", true);
|
|
2860
|
-
});
|
|
2861
|
-
});
|
|
2862
|
-
}
|
|
2863
|
-
render() {
|
|
2864
|
-
return html10` <slot></slot> `;
|
|
2865
|
-
}
|
|
2866
|
-
};
|
|
2867
|
-
__decorate11([
|
|
2868
|
-
consume5({ context: testHostContext, subscribe: true })
|
|
2869
|
-
], TestCheckItem.prototype, "testHost", void 0);
|
|
2870
|
-
|
|
2871
3054
|
// ../qti-test/dist/components/test-container/test-container.js
|
|
2872
3055
|
import { consume as consume6 } from "@lit/context";
|
|
2873
|
-
import { LitElement as
|
|
2874
|
-
import { property as
|
|
3056
|
+
import { LitElement as LitElement11, html as html10 } from "lit";
|
|
3057
|
+
import { property as property10, state as state4 } from "lit/decorators.js";
|
|
2875
3058
|
import { until } from "lit/directives/until.js";
|
|
2876
|
-
var
|
|
3059
|
+
var __decorate13 = function(decorators, target, key, desc) {
|
|
2877
3060
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2878
3061
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2879
3062
|
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;
|
|
2880
3063
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2881
3064
|
};
|
|
2882
|
-
var TestContainer = class extends
|
|
3065
|
+
var TestContainer = class extends LitElement11 {
|
|
2883
3066
|
constructor() {
|
|
2884
3067
|
super(...arguments);
|
|
2885
3068
|
this.customElementRegistry = null;
|
|
@@ -2928,7 +3111,7 @@ var TestContainer = class extends LitElement12 {
|
|
|
2928
3111
|
* Assign a new test document and announce it.
|
|
2929
3112
|
*
|
|
2930
3113
|
* The announcement has to happen here rather than on
|
|
2931
|
-
* `
|
|
3114
|
+
* `qc-test-loaded`, because by then the new document's
|
|
2932
3115
|
* children have already connected and registered themselves — a host that
|
|
2933
3116
|
* resets its context on that event throws those registrations away. Lit's
|
|
2934
3117
|
* re-render is async, so a handler running now still gets in before any child
|
|
@@ -2964,7 +3147,7 @@ var TestContainer = class extends LitElement12 {
|
|
|
2964
3147
|
}
|
|
2965
3148
|
#initializeTemplateContent() {
|
|
2966
3149
|
const template = this.querySelector("template");
|
|
2967
|
-
this.#templateContent = template ? template.content :
|
|
3150
|
+
this.#templateContent = template ? template.content : html10``;
|
|
2968
3151
|
}
|
|
2969
3152
|
#applyStyles() {
|
|
2970
3153
|
const sheet = new CSSStyleSheet();
|
|
@@ -2972,96 +3155,96 @@ var TestContainer = class extends LitElement12 {
|
|
|
2972
3155
|
this.shadowRoot.adoptedStyleSheets = [sheet];
|
|
2973
3156
|
}
|
|
2974
3157
|
render() {
|
|
2975
|
-
return
|
|
3158
|
+
return html10`
|
|
2976
3159
|
${this.#templateContent}
|
|
2977
3160
|
<slot></slot>
|
|
2978
|
-
${until(this.testDoc,
|
|
3161
|
+
${until(this.testDoc, html10`<span>Loading...</span>`)}
|
|
2979
3162
|
`;
|
|
2980
3163
|
}
|
|
2981
3164
|
};
|
|
2982
|
-
|
|
2983
|
-
|
|
3165
|
+
__decorate13([
|
|
3166
|
+
property10({ attribute: false })
|
|
2984
3167
|
], TestContainer.prototype, "customElementRegistry", void 0);
|
|
2985
|
-
|
|
2986
|
-
|
|
3168
|
+
__decorate13([
|
|
3169
|
+
property10({ type: String, attribute: "test-url" })
|
|
2987
3170
|
], TestContainer.prototype, "testURL", void 0);
|
|
2988
|
-
|
|
2989
|
-
|
|
3171
|
+
__decorate13([
|
|
3172
|
+
state4()
|
|
2990
3173
|
], TestContainer.prototype, "testDoc", void 0);
|
|
2991
|
-
|
|
2992
|
-
|
|
3174
|
+
__decorate13([
|
|
3175
|
+
state4()
|
|
2993
3176
|
], TestContainer.prototype, "testXML", void 0);
|
|
2994
|
-
|
|
3177
|
+
__decorate13([
|
|
2995
3178
|
consume6({ context: testHostContext, subscribe: true })
|
|
2996
3179
|
], TestContainer.prototype, "testHost", void 0);
|
|
2997
|
-
|
|
2998
|
-
|
|
3180
|
+
__decorate13([
|
|
3181
|
+
state4(),
|
|
2999
3182
|
consume6({ context: qtiContext, subscribe: true })
|
|
3000
3183
|
], TestContainer.prototype, "qtiContext", void 0);
|
|
3001
|
-
|
|
3184
|
+
__decorate13([
|
|
3002
3185
|
watch("testURL", { waitUntilFirstUpdate: true })
|
|
3003
3186
|
], TestContainer.prototype, "handleTestURLChange", null);
|
|
3004
|
-
|
|
3187
|
+
__decorate13([
|
|
3005
3188
|
watch("testXML", { waitUntilFirstUpdate: true })
|
|
3006
3189
|
], TestContainer.prototype, "handleTestXMLChange", null);
|
|
3007
3190
|
|
|
3008
3191
|
// ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
|
|
3009
|
-
import {
|
|
3010
|
-
import { property as
|
|
3192
|
+
import { LitElement as LitElement12 } from "lit";
|
|
3193
|
+
import { property as property11 } from "lit/decorators.js";
|
|
3011
3194
|
import { consume as consume7 } from "@lit/context";
|
|
3012
|
-
var
|
|
3195
|
+
var __decorate14 = function(decorators, target, key, desc) {
|
|
3013
3196
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3014
3197
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3015
3198
|
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;
|
|
3016
3199
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3017
3200
|
};
|
|
3018
|
-
var
|
|
3201
|
+
var itemRefOf = (element) => {
|
|
3202
|
+
const itemRef = element.closest("qti-assessment-item-ref");
|
|
3203
|
+
if (itemRef)
|
|
3204
|
+
return itemRef.getAttribute("identifier") ?? void 0;
|
|
3205
|
+
const root = element.getRootNode();
|
|
3206
|
+
return root instanceof ShadowRoot ? itemRefOf(root.host) : void 0;
|
|
3207
|
+
};
|
|
3208
|
+
var TestEndAttempt = class extends LitElement12 {
|
|
3019
3209
|
_handleTestElementChange(_oldValue, newValue) {
|
|
3020
3210
|
if (newValue) {
|
|
3021
3211
|
this.requestUpdate();
|
|
3022
3212
|
}
|
|
3023
3213
|
}
|
|
3024
3214
|
static {
|
|
3025
|
-
this.styles =
|
|
3026
|
-
:host {
|
|
3027
|
-
${btn};
|
|
3028
|
-
}
|
|
3029
|
-
:host(:hover:not([disabled])) {
|
|
3030
|
-
${btnInteractive};
|
|
3031
|
-
}
|
|
3032
|
-
:host(:focus-visible) {
|
|
3033
|
-
${focusRing};
|
|
3034
|
-
}
|
|
3035
|
-
:host([disabled]) {
|
|
3036
|
-
${dis};
|
|
3037
|
-
}
|
|
3038
|
-
`;
|
|
3215
|
+
this.styles = button;
|
|
3039
3216
|
}
|
|
3040
3217
|
constructor() {
|
|
3041
3218
|
super();
|
|
3042
3219
|
this._internalDisabled = false;
|
|
3220
|
+
this.requireAnswer = false;
|
|
3043
3221
|
this.addEventListener("click", (e) => {
|
|
3044
3222
|
e.preventDefault();
|
|
3045
3223
|
if (!this._internalDisabled) {
|
|
3046
|
-
|
|
3224
|
+
const itemId = this.#ownItem;
|
|
3225
|
+
dispatchPublic(this, "qc-test-end-attempt", itemId ? { itemId } : {});
|
|
3047
3226
|
}
|
|
3048
3227
|
});
|
|
3049
3228
|
}
|
|
3229
|
+
/** The item named by `item`, or else the item-ref it is stamped into. */
|
|
3230
|
+
get #ownItem() {
|
|
3231
|
+
return this.item || itemRefOf(this);
|
|
3232
|
+
}
|
|
3050
3233
|
willUpdate(_changedProperties) {
|
|
3051
3234
|
this.checkDisabled();
|
|
3052
3235
|
}
|
|
3053
3236
|
checkDisabled() {
|
|
3054
|
-
const
|
|
3055
|
-
|
|
3237
|
+
const testParts = this.computedContext?.testParts;
|
|
3238
|
+
const ownItem = this.#ownItem;
|
|
3239
|
+
const testPart = testParts?.find((testPart2) => testPart2.active);
|
|
3240
|
+
if (!testParts || !ownItem && !testPart)
|
|
3056
3241
|
return;
|
|
3057
|
-
const
|
|
3058
|
-
const itemIndex = sectionItems.findIndex((item) => item.active);
|
|
3059
|
-
const activeItem = sectionItems[itemIndex];
|
|
3242
|
+
const activeItem = ownItem ? testParts.flatMap((part) => part.sections.flatMap((section) => section.items)).find((i) => i.identifier === ownItem) : testPart.sections.flatMap((section) => section.items).find((item) => item.active);
|
|
3060
3243
|
if (!activeItem) {
|
|
3061
3244
|
this._internalDisabled = false;
|
|
3062
3245
|
return;
|
|
3063
3246
|
}
|
|
3064
|
-
const maxAttempts = activeItem.maxAttempts ?? 1;
|
|
3247
|
+
const maxAttempts = activeItem.sessionControl?.maxAttempts ?? 1;
|
|
3065
3248
|
const numAttempts = activeItem.numAttempts || 0;
|
|
3066
3249
|
if (!activeItem.adaptive && activeItem.optimal) {
|
|
3067
3250
|
this._internalDisabled = true;
|
|
@@ -3075,916 +3258,70 @@ var TestEndAttempt = class extends LitElement13 {
|
|
|
3075
3258
|
this._internalDisabled = true;
|
|
3076
3259
|
return;
|
|
3077
3260
|
}
|
|
3078
|
-
if (activeItem.allowSkipping === false) {
|
|
3261
|
+
if (this.requireAnswer || activeItem.sessionControl?.allowSkipping === false) {
|
|
3079
3262
|
this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;
|
|
3080
3263
|
} else {
|
|
3081
3264
|
this._internalDisabled = false;
|
|
3082
3265
|
}
|
|
3083
3266
|
}
|
|
3084
3267
|
render() {
|
|
3085
|
-
return
|
|
3268
|
+
return control;
|
|
3086
3269
|
}
|
|
3087
3270
|
};
|
|
3088
|
-
|
|
3271
|
+
__decorate14([
|
|
3089
3272
|
consume7({ context: computedContext, subscribe: true }),
|
|
3090
|
-
|
|
3273
|
+
property11({ attribute: false })
|
|
3091
3274
|
], TestEndAttempt.prototype, "computedContext", void 0);
|
|
3092
|
-
|
|
3093
|
-
|
|
3275
|
+
__decorate14([
|
|
3276
|
+
property11({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
3094
3277
|
], TestEndAttempt.prototype, "_internalDisabled", void 0);
|
|
3095
|
-
|
|
3278
|
+
__decorate14([
|
|
3279
|
+
property11({ reflect: true })
|
|
3280
|
+
], TestEndAttempt.prototype, "item", void 0);
|
|
3281
|
+
__decorate14([
|
|
3282
|
+
property11({ type: Boolean, reflect: true, attribute: "require-answer" })
|
|
3283
|
+
], TestEndAttempt.prototype, "requireAnswer", void 0);
|
|
3284
|
+
__decorate14([
|
|
3096
3285
|
watch("computedContext")
|
|
3097
3286
|
], TestEndAttempt.prototype, "_handleTestElementChange", null);
|
|
3098
3287
|
|
|
3099
|
-
// ../qti-test/dist/components/test-
|
|
3100
|
-
import {
|
|
3101
|
-
import {
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
return
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
${btnInteractive};
|
|
3116
|
-
}
|
|
3117
|
-
:host(:focus-visible) {
|
|
3118
|
-
${focusRing};
|
|
3119
|
-
}
|
|
3120
|
-
:host([disabled]) {
|
|
3121
|
-
${dis};
|
|
3122
|
-
}
|
|
3123
|
-
`;
|
|
3124
|
-
}
|
|
3125
|
-
constructor() {
|
|
3126
|
-
super();
|
|
3127
|
-
this.itemId = null;
|
|
3128
|
-
this.addEventListener("click", () => this._requestItem(this.itemId));
|
|
3129
|
-
}
|
|
3130
|
-
_requestItem(identifier) {
|
|
3131
|
-
dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
|
|
3132
|
-
}
|
|
3133
|
-
render() {
|
|
3134
|
-
return html13` <slot></slot> `;
|
|
3135
|
-
}
|
|
3136
|
-
};
|
|
3137
|
-
__decorate14([
|
|
3138
|
-
property11({ type: String, attribute: "item-id" })
|
|
3139
|
-
], TestItemLink.prototype, "itemId", void 0);
|
|
3288
|
+
// ../qti-test/dist/components/test-navigation/test-navigation.js
|
|
3289
|
+
import { ContextConsumer, consume as consume8, provide as provide4 } from "@lit/context";
|
|
3290
|
+
import { html as html11, LitElement as LitElement13 } from "lit";
|
|
3291
|
+
import { property as property12, state as state5 } from "lit/decorators.js";
|
|
3292
|
+
|
|
3293
|
+
// ../qti-test/dist/internal/rendered-markup.js
|
|
3294
|
+
function renderedMarkup(element) {
|
|
3295
|
+
return {
|
|
3296
|
+
nodeType: element.nodeType,
|
|
3297
|
+
localName: element.localName,
|
|
3298
|
+
get childNodes() {
|
|
3299
|
+
return Array.from(element.children, renderedMarkup);
|
|
3300
|
+
},
|
|
3301
|
+
getAttribute: (name) => element.getAttribute(name) ?? (name === "title" ? element.getAttribute("data-title") : null)
|
|
3302
|
+
};
|
|
3303
|
+
}
|
|
3140
3304
|
|
|
3141
|
-
// ../qti-test/dist/components/test-
|
|
3142
|
-
import { html as html14, LitElement as LitElement15, css as css9 } from "lit";
|
|
3143
|
-
import { consume as consume8, provide as provide3, createContext as createContext2 } from "@lit/context";
|
|
3144
|
-
import { property as property12, state as state4 } from "lit/decorators.js";
|
|
3145
|
-
import { ifDefined } from "lit/directives/if-defined.js";
|
|
3305
|
+
// ../qti-test/dist/components/test-navigation/test-navigation.js
|
|
3146
3306
|
var __decorate15 = function(decorators, target, key, desc) {
|
|
3147
3307
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3148
3308
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3149
3309
|
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;
|
|
3150
3310
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3151
3311
|
};
|
|
3152
|
-
var
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
|
|
3166
|
-
var ICONS = {
|
|
3167
|
-
play: "M8 5v14l11-7z",
|
|
3168
|
-
pause: "M6 5h4v14H6zM14 5h4v14h-4z",
|
|
3169
|
-
stop: "M6 6h12v12H6z",
|
|
3170
|
-
prev: "M6 5h2v14H6zM20 5v14L9 12z",
|
|
3171
|
-
next: "M16 5h2v14h-2zM4 5v14l11-7z",
|
|
3172
|
-
pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
|
|
3173
|
-
};
|
|
3174
|
-
var iconContent = (icon, label) => {
|
|
3175
|
-
const svg = html14`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3176
|
-
<path d="${ICONS[icon]}"></path>
|
|
3177
|
-
</svg>`;
|
|
3178
|
-
return html14`${svg}<span class="label">${label}</span>`;
|
|
3179
|
-
};
|
|
3180
|
-
var TtsButtonBase = class extends LitElement15 {
|
|
3181
|
-
static {
|
|
3182
|
-
this.styles = css9`
|
|
3183
|
-
:host {
|
|
3184
|
-
display: inline-flex;
|
|
3185
|
-
}
|
|
3186
|
-
button {
|
|
3187
|
-
${btn};
|
|
3188
|
-
min-inline-size: var(--test-button-size, 2.25rem);
|
|
3189
|
-
padding-inline: 0.5rem;
|
|
3190
|
-
/* Containing block for the visually hidden .label. Without it the label is placed against
|
|
3191
|
-
the nearest positioned ancestor, which can sit outside a scroll container and make the
|
|
3192
|
-
page as tall as the scrolled content. */
|
|
3193
|
-
position: relative;
|
|
3194
|
-
}
|
|
3195
|
-
button:hover:not(:disabled) {
|
|
3196
|
-
${btnInteractive};
|
|
3197
|
-
}
|
|
3198
|
-
button:focus-visible {
|
|
3199
|
-
${focusRing};
|
|
3200
|
-
}
|
|
3201
|
-
button:disabled {
|
|
3202
|
-
${dis};
|
|
3203
|
-
}
|
|
3204
|
-
button[aria-pressed='true'],
|
|
3205
|
-
button[aria-pressed='true']:hover {
|
|
3206
|
-
background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
|
|
3207
|
-
color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
|
|
3208
|
-
}
|
|
3209
|
-
svg,
|
|
3210
|
-
::slotted(svg) {
|
|
3211
|
-
flex: none;
|
|
3212
|
-
inline-size: var(--test-tts-icon-size, 1.125rem);
|
|
3213
|
-
block-size: var(--test-tts-icon-size, 1.125rem);
|
|
3214
|
-
}
|
|
3215
|
-
svg {
|
|
3216
|
-
fill: currentColor;
|
|
3217
|
-
}
|
|
3218
|
-
/* The default content is icon-only; this keeps the button's accessible name. */
|
|
3219
|
-
.label {
|
|
3220
|
-
position: absolute;
|
|
3221
|
-
inline-size: 1px;
|
|
3222
|
-
block-size: 1px;
|
|
3223
|
-
overflow: hidden;
|
|
3224
|
-
clip-path: inset(50%);
|
|
3225
|
-
white-space: nowrap;
|
|
3226
|
-
}
|
|
3227
|
-
`;
|
|
3228
|
-
}
|
|
3229
|
-
#internals = this.attachInternals();
|
|
3230
|
-
#mirroredState;
|
|
3231
|
-
#mirroredPicking = false;
|
|
3232
|
-
updated(_changed) {
|
|
3233
|
-
const state9 = this._tts?.state;
|
|
3234
|
-
const picking = this._tts?.picking ?? false;
|
|
3235
|
-
if (state9 === this.#mirroredState && picking === this.#mirroredPicking)
|
|
3236
|
-
return;
|
|
3237
|
-
this.#mirroredState = state9;
|
|
3238
|
-
this.#mirroredPicking = picking;
|
|
3239
|
-
this.#internals.states.clear();
|
|
3240
|
-
if (state9)
|
|
3241
|
-
this.#internals.states.add(state9);
|
|
3242
|
-
if (picking)
|
|
3243
|
-
this.#internals.states.add("picking");
|
|
3244
|
-
}
|
|
3245
|
-
};
|
|
3246
|
-
__decorate15([
|
|
3247
|
-
property12({ type: String })
|
|
3248
|
-
], TtsButtonBase.prototype, "label", void 0);
|
|
3249
|
-
__decorate15([
|
|
3250
|
-
consume8({ context: ttsContext, subscribe: true })
|
|
3251
|
-
], TtsButtonBase.prototype, "_tts", void 0);
|
|
3252
|
-
var TestItemToSpeech = class extends LitElement15 {
|
|
3253
|
-
static {
|
|
3254
|
-
this.styles = css9`
|
|
3255
|
-
:host {
|
|
3256
|
-
display: inline-flex;
|
|
3257
|
-
flex-wrap: wrap;
|
|
3258
|
-
align-items: center;
|
|
3259
|
-
gap: var(--test-tts-gap, 0.25rem);
|
|
3260
|
-
}
|
|
3261
|
-
`;
|
|
3262
|
-
}
|
|
3263
|
-
#internals;
|
|
3264
|
-
// Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
|
|
3265
|
-
// placeholder itself is looked up on every use — a host may swap the element.
|
|
3266
|
-
#stimulusMode;
|
|
3267
|
-
// Stimulus mode: resets the player when the stimulus content next to it is replaced.
|
|
3268
|
-
#stimulusObserver;
|
|
3269
|
-
// Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
|
|
3270
|
-
// Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
|
|
3271
|
-
#contentMode;
|
|
3272
|
-
// Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
|
|
3273
|
-
#itemRef;
|
|
3274
|
-
// Where the item-connected (and, in cursor mode, navigation) events are listened for.
|
|
3275
|
-
#eventHost;
|
|
3276
|
-
#boundHandleItemConnected;
|
|
3277
|
-
#boundHandleNavigation;
|
|
3278
|
-
// Cursor mode: the previous navigation position, to detect moving to another item or section.
|
|
3279
|
-
#prevNavItemRefId;
|
|
3280
|
-
#prevNavSectionId;
|
|
3281
|
-
// Current set of block-level reading elements for the item
|
|
3282
|
-
#readingElements;
|
|
3283
|
-
#currentElementIndex;
|
|
3284
|
-
// Text nodes of the element currently being spoken (for word-boundary highlight)
|
|
3285
|
-
#textNodes;
|
|
3286
|
-
// The utterance this player is speaking; lets the error handler tell "our speech was
|
|
3287
|
-
// cancelled by another player" apart from a cancel we issued ourselves.
|
|
3288
|
-
#currentUtterance;
|
|
3289
|
-
// Pick mode: all elements highlighted, a click on one starts reading from there.
|
|
3290
|
-
#picking;
|
|
3291
|
-
#pickRoot;
|
|
3292
|
-
#boundHandlePickClick;
|
|
3293
|
-
// Set when the last element has been read: the cursor stays on it (so prev still works),
|
|
3294
|
-
// but the next play starts the item over instead of repeating that last element.
|
|
3295
|
-
#finished;
|
|
3296
|
-
// Two separate CSS Highlight objects
|
|
3297
|
-
#elementHighlight;
|
|
3298
|
-
// whole-element cursor
|
|
3299
|
-
#wordHighlight;
|
|
3300
|
-
// current word during speech
|
|
3301
|
-
constructor() {
|
|
3302
|
-
super();
|
|
3303
|
-
this.language = "nl-NL";
|
|
3304
|
-
this.#internals = this.attachInternals();
|
|
3305
|
-
this.#stimulusMode = false;
|
|
3306
|
-
this.#stimulusObserver = null;
|
|
3307
|
-
this.#contentMode = false;
|
|
3308
|
-
this.#itemRef = null;
|
|
3309
|
-
this.#eventHost = null;
|
|
3310
|
-
this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
|
|
3311
|
-
this.#boundHandleNavigation = () => this.#stop();
|
|
3312
|
-
this.#prevNavItemRefId = void 0;
|
|
3313
|
-
this.#prevNavSectionId = void 0;
|
|
3314
|
-
this.#readingElements = null;
|
|
3315
|
-
this.#currentElementIndex = 0;
|
|
3316
|
-
this.#textNodes = [];
|
|
3317
|
-
this.#currentUtterance = null;
|
|
3318
|
-
this.#picking = false;
|
|
3319
|
-
this.#pickRoot = null;
|
|
3320
|
-
this.#boundHandlePickClick = this.#handlePickClick.bind(this);
|
|
3321
|
-
this.#finished = false;
|
|
3322
|
-
this.#elementHighlight = new Highlight();
|
|
3323
|
-
this.#wordHighlight = new Highlight();
|
|
3324
|
-
this._ttsContext = {
|
|
3325
|
-
state: "idle",
|
|
3326
|
-
currentElementIndex: 0,
|
|
3327
|
-
elementCount: 0,
|
|
3328
|
-
play: () => this.#playSpeech(),
|
|
3329
|
-
pause: () => this.#pause(),
|
|
3330
|
-
resume: () => this.#resume(),
|
|
3331
|
-
stop: () => {
|
|
3332
|
-
this.#stopPicking();
|
|
3333
|
-
this.#stop();
|
|
3334
|
-
},
|
|
3335
|
-
prevElement: () => this.#prevElement(),
|
|
3336
|
-
nextElement: () => this.#nextElement(),
|
|
3337
|
-
togglePick: () => this.#togglePick(),
|
|
3338
|
-
picking: false
|
|
3339
|
-
};
|
|
3340
|
-
}
|
|
3341
|
-
// willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
|
|
3342
|
-
// render already under way instead of scheduling a second one (Lit's change-in-update).
|
|
3343
|
-
willUpdate(changed) {
|
|
3344
|
-
super.willUpdate(changed);
|
|
3345
|
-
if (this.#stimulusMode || this.#contentMode || this.#itemRef)
|
|
3346
|
-
return;
|
|
3347
|
-
const item = this._sessionContext?.navItemRefId ?? null;
|
|
3348
|
-
const section = this._sessionContext?.navSectionId ?? null;
|
|
3349
|
-
const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
|
|
3350
|
-
const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
|
|
3351
|
-
if (itemChanged || sectionChanged)
|
|
3352
|
-
this.#resetReadingPosition();
|
|
3353
|
-
this.#prevNavItemRefId = item;
|
|
3354
|
-
this.#prevNavSectionId = section;
|
|
3355
|
-
}
|
|
3356
|
-
/** Stop speech and forget the collected reading elements, so the next play starts afresh. */
|
|
3357
|
-
#resetReadingPosition() {
|
|
3358
|
-
this.#stopPicking();
|
|
3359
|
-
this.#stop();
|
|
3360
|
-
this.#readingElements = null;
|
|
3361
|
-
this.#currentElementIndex = 0;
|
|
3362
|
-
this.#finished = false;
|
|
3363
|
-
this.#updateContext();
|
|
3364
|
-
}
|
|
3365
|
-
connectedCallback() {
|
|
3366
|
-
super.connectedCallback();
|
|
3367
|
-
this.#setSpeechState("idle");
|
|
3368
|
-
this.#stimulusMode = this.#stimulusPlaceholder() !== null;
|
|
3369
|
-
if (this.#stimulusMode) {
|
|
3370
|
-
this.#stimulusObserver = new MutationObserver((records) => {
|
|
3371
|
-
if (records.some((record) => !this.contains(record.target)))
|
|
3372
|
-
this.#handleStimulusReplaced();
|
|
3373
|
-
});
|
|
3374
|
-
this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
|
|
3375
|
-
return;
|
|
3376
|
-
}
|
|
3377
|
-
this.#contentMode = this.#contentElement() !== null;
|
|
3378
|
-
if (this.#contentMode)
|
|
3379
|
-
return;
|
|
3380
|
-
this.#itemRef = this.closest("qti-assessment-item-ref");
|
|
3381
|
-
this.#eventHost = this.#itemRef ?? this.closest("test-navigation") ?? this.testHost ?? this.getRootNode();
|
|
3382
|
-
this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
3383
|
-
if (!this.#itemRef) {
|
|
3384
|
-
this.#eventHost.addEventListener("cito-test-navigate", this.#boundHandleNavigation);
|
|
3385
|
-
this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
3386
|
-
}
|
|
3387
|
-
}
|
|
3388
|
-
disconnectedCallback() {
|
|
3389
|
-
super.disconnectedCallback();
|
|
3390
|
-
if (this.#currentUtterance) {
|
|
3391
|
-
this.#currentUtterance = null;
|
|
3392
|
-
speechSynthesis.cancel();
|
|
3393
|
-
}
|
|
3394
|
-
this.#stopPicking();
|
|
3395
|
-
this.#clearAllHighlights();
|
|
3396
|
-
this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
|
|
3397
|
-
this.#eventHost?.removeEventListener("cito-test-navigate", this.#boundHandleNavigation);
|
|
3398
|
-
this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
|
|
3399
|
-
this.#eventHost = null;
|
|
3400
|
-
this.#itemRef = null;
|
|
3401
|
-
this.#stimulusObserver?.disconnect();
|
|
3402
|
-
this.#stimulusObserver = null;
|
|
3403
|
-
this.#stimulusMode = false;
|
|
3404
|
-
this.#contentMode = false;
|
|
3405
|
-
}
|
|
3406
|
-
render() {
|
|
3407
|
-
return html14`<slot></slot>`;
|
|
3408
|
-
}
|
|
3409
|
-
/**
|
|
3410
|
-
* An item (re)rendered. If it is ours — e.g. after navigating to the item already shown — the
|
|
3411
|
-
* elements collected earlier are detached now. That does not move the navigation cursor, so
|
|
3412
|
-
* the check in updated() does not catch it.
|
|
3413
|
-
*/
|
|
3414
|
-
#handleItemConnected(event) {
|
|
3415
|
-
if (this.#readingElements === null)
|
|
3416
|
-
return;
|
|
3417
|
-
const identifier = event.detail?.identifier;
|
|
3418
|
-
if (this.#itemRef || identifier === this._sessionContext?.navItemRefId)
|
|
3419
|
-
this.#resetReadingPosition();
|
|
3420
|
-
}
|
|
3421
|
-
/**
|
|
3422
|
-
* Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
|
|
3423
|
-
* collected, so the next play reads the new content from the top. Unlike
|
|
3424
|
-
* #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
|
|
3425
|
-
* while an item player on the same page is speaking.
|
|
3426
|
-
*/
|
|
3427
|
-
#handleStimulusReplaced() {
|
|
3428
|
-
if (this.#currentUtterance) {
|
|
3429
|
-
this.#currentUtterance = null;
|
|
3430
|
-
speechSynthesis.cancel();
|
|
3431
|
-
}
|
|
3432
|
-
this.#stopPicking();
|
|
3433
|
-
this.#clearAllHighlights();
|
|
3434
|
-
this.#setSpeechState("idle");
|
|
3435
|
-
this.#readingElements = null;
|
|
3436
|
-
this.#currentElementIndex = 0;
|
|
3437
|
-
this.#finished = false;
|
|
3438
|
-
this.#updateContext();
|
|
3439
|
-
}
|
|
3440
|
-
/**
|
|
3441
|
-
* Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
|
|
3442
|
-
* null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
|
|
3443
|
-
* loading replaces the placeholder's content.
|
|
3444
|
-
*/
|
|
3445
|
-
#stimulusPlaceholder() {
|
|
3446
|
-
return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
|
|
3447
|
-
}
|
|
3448
|
-
/**
|
|
3449
|
-
* Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
|
|
3450
|
-
* The marker goes on one container; the player finds the readable elements inside it.
|
|
3451
|
-
*/
|
|
3452
|
-
#contentElement() {
|
|
3453
|
-
return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
|
|
3454
|
-
}
|
|
3455
|
-
/**
|
|
3456
|
-
* The element whose text is read: the stimulus body next to the player (stimulus mode), the
|
|
3457
|
-
* marked content next to it (content mode), or the item body of the item to read.
|
|
3458
|
-
*/
|
|
3459
|
-
#resolveReadingRoot() {
|
|
3460
|
-
if (this.#stimulusMode)
|
|
3461
|
-
return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
|
|
3462
|
-
if (this.#contentMode)
|
|
3463
|
-
return this.#contentElement();
|
|
3464
|
-
return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
|
|
3465
|
-
}
|
|
3466
|
-
/** The item to read: our item-ref's (item-ref mode), or the navigated one (cursor mode). */
|
|
3467
|
-
#resolveItem() {
|
|
3468
|
-
if (this.#itemRef)
|
|
3469
|
-
return this.#itemRef.assessmentItem;
|
|
3470
|
-
const identifier = this._sessionContext?.navItemRefId;
|
|
3471
|
-
return identifier ? this.#findItemInDom(identifier) : null;
|
|
3472
|
-
}
|
|
3473
|
-
/**
|
|
3474
|
-
* Cursor mode: find the rendered item for an item-ref identifier. Our own `<qti-test>` first —
|
|
3475
|
-
* a page can hold several tests showing the same item — then every root from here up to the
|
|
3476
|
-
* document; each scope directly and in the `test-container` shadow roots inside it.
|
|
3477
|
-
*/
|
|
3478
|
-
#findItemInDom(identifier) {
|
|
3479
|
-
const selector = `qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"] qti-assessment-item`;
|
|
3480
|
-
const search = (scope) => {
|
|
3481
|
-
const direct = scope.querySelector(selector);
|
|
3482
|
-
if (direct)
|
|
3483
|
-
return direct;
|
|
3484
|
-
for (const container of Array.from(scope.querySelectorAll("test-container"))) {
|
|
3485
|
-
const inShadow = container.shadowRoot?.querySelector(selector);
|
|
3486
|
-
if (inShadow)
|
|
3487
|
-
return inShadow;
|
|
3488
|
-
}
|
|
3489
|
-
return null;
|
|
3490
|
-
};
|
|
3491
|
-
const test = this.closest("qti-test");
|
|
3492
|
-
const inTest = test && search(test);
|
|
3493
|
-
if (inTest)
|
|
3494
|
-
return inTest;
|
|
3495
|
-
let root = this.getRootNode();
|
|
3496
|
-
for (; ; ) {
|
|
3497
|
-
const found = search(root);
|
|
3498
|
-
if (found)
|
|
3499
|
-
return found;
|
|
3500
|
-
const host = root.host;
|
|
3501
|
-
if (!host)
|
|
3502
|
-
return null;
|
|
3503
|
-
root = host.getRootNode();
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
/** Update speech state on both the context (notifies children) and the host's CSS custom states. */
|
|
3507
|
-
#setSpeechState(state9) {
|
|
3508
|
-
this._ttsContext = { ...this._ttsContext, state: state9 };
|
|
3509
|
-
this.#internals.states.delete("idle");
|
|
3510
|
-
this.#internals.states.delete("playing");
|
|
3511
|
-
this.#internals.states.delete("paused");
|
|
3512
|
-
this.#internals.states.add(state9);
|
|
3513
|
-
}
|
|
3514
|
-
/** Push currentElementIndex and elementCount into context so children can react. */
|
|
3515
|
-
#updateContext() {
|
|
3516
|
-
this._ttsContext = {
|
|
3517
|
-
...this._ttsContext,
|
|
3518
|
-
currentElementIndex: this.#currentElementIndex,
|
|
3519
|
-
elementCount: this.#getReadingElements().length
|
|
3520
|
-
};
|
|
3521
|
-
}
|
|
3522
|
-
/**
|
|
3523
|
-
* Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
|
|
3524
|
-
* first call), filtered live for visibility on every call. Feedback and other
|
|
3525
|
-
* conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
|
|
3526
|
-
* CSS custom state reveals it) is excluded while hidden and picked up again once shown,
|
|
3527
|
-
* without needing to re-collect the candidate set.
|
|
3528
|
-
*/
|
|
3529
|
-
#getReadingElements() {
|
|
3530
|
-
if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
|
|
3531
|
-
this.#readingElements = null;
|
|
3532
|
-
this.#currentElementIndex = 0;
|
|
3533
|
-
this.#finished = false;
|
|
3534
|
-
}
|
|
3535
|
-
if (this.#readingElements === null) {
|
|
3536
|
-
const root = this.#resolveReadingRoot();
|
|
3537
|
-
if (!root)
|
|
3538
|
-
return [];
|
|
3539
|
-
const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
|
|
3540
|
-
this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
|
|
3541
|
-
}
|
|
3542
|
-
return this.#readingElements.filter((el) => this.#isVisible(el));
|
|
3543
|
-
}
|
|
3544
|
-
/** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
|
|
3545
|
-
#isVisible(element) {
|
|
3546
|
-
if (typeof element.checkVisibility === "function") {
|
|
3547
|
-
return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
|
|
3548
|
-
}
|
|
3549
|
-
return element.getClientRects().length > 0;
|
|
3550
|
-
}
|
|
3551
|
-
/**
|
|
3552
|
-
* Resolve the speech language for a reading element.
|
|
3553
|
-
* Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
|
|
3554
|
-
* Empty `lang=""` is treated as absent.
|
|
3555
|
-
*/
|
|
3556
|
-
#resolveLang(element) {
|
|
3557
|
-
let node = element;
|
|
3558
|
-
while (node) {
|
|
3559
|
-
const lang = node.getAttribute("lang") || node.getAttribute("xml:lang");
|
|
3560
|
-
if (lang?.trim())
|
|
3561
|
-
return lang.trim();
|
|
3562
|
-
node = node.parentElement ?? node.getRootNode().host ?? null;
|
|
3563
|
-
}
|
|
3564
|
-
const documentLang = document.documentElement.getAttribute("lang");
|
|
3565
|
-
if (documentLang?.trim())
|
|
3566
|
-
return documentLang.trim();
|
|
3567
|
-
return this.language;
|
|
3568
|
-
}
|
|
3569
|
-
#playSpeech() {
|
|
3570
|
-
const elements = this.#getReadingElements();
|
|
3571
|
-
if (!elements.length) {
|
|
3572
|
-
console.warn("test-item-to-speech: no readable elements found");
|
|
3573
|
-
return;
|
|
3574
|
-
}
|
|
3575
|
-
this.#stopPicking();
|
|
3576
|
-
speechSynthesis.cancel();
|
|
3577
|
-
if (this.#finished) {
|
|
3578
|
-
this.#finished = false;
|
|
3579
|
-
this.#currentElementIndex = 0;
|
|
3580
|
-
}
|
|
3581
|
-
if (this.#contentMode && this.#currentElementIndex === 0)
|
|
3582
|
-
this.#readingElements = null;
|
|
3583
|
-
this.#speakElement(this.#currentElementIndex);
|
|
3584
|
-
}
|
|
3585
|
-
/** Speak the element at the given index, then auto-advance when it ends. */
|
|
3586
|
-
#speakElement(index) {
|
|
3587
|
-
const elements = this.#getReadingElements();
|
|
3588
|
-
if (index >= elements.length) {
|
|
3589
|
-
this.#clearWordHighlight();
|
|
3590
|
-
this.#currentElementIndex = elements.length - 1;
|
|
3591
|
-
if (elements.length > 0)
|
|
3592
|
-
this.#highlightElement(elements[this.#currentElementIndex]);
|
|
3593
|
-
this.#finished = true;
|
|
3594
|
-
this.#setSpeechState("idle");
|
|
3595
|
-
this.#updateContext();
|
|
3596
|
-
return;
|
|
3597
|
-
}
|
|
3598
|
-
this.#currentElementIndex = index;
|
|
3599
|
-
this.#finished = false;
|
|
3600
|
-
this.#updateContext();
|
|
3601
|
-
const element = elements[index];
|
|
3602
|
-
element.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3603
|
-
this.#highlightElement(element);
|
|
3604
|
-
this.#textNodes = this.#collectTextNodes(element);
|
|
3605
|
-
const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
|
|
3606
|
-
if (!text.trim()) {
|
|
3607
|
-
this.#speakElement(index + 1);
|
|
3608
|
-
return;
|
|
3609
|
-
}
|
|
3610
|
-
const utterance = new SpeechSynthesisUtterance(text);
|
|
3611
|
-
utterance.lang = this.#resolveLang(element);
|
|
3612
|
-
utterance.rate = 1;
|
|
3613
|
-
utterance.onboundary = (event) => {
|
|
3614
|
-
if (event.name !== "word")
|
|
3615
|
-
return;
|
|
3616
|
-
this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
|
|
3617
|
-
};
|
|
3618
|
-
utterance.onend = () => {
|
|
3619
|
-
if (this.#currentUtterance !== utterance)
|
|
3620
|
-
return;
|
|
3621
|
-
this.#currentUtterance = null;
|
|
3622
|
-
this.#clearWordHighlight();
|
|
3623
|
-
this.#speakElement(this.#currentElementIndex + 1);
|
|
3624
|
-
};
|
|
3625
|
-
utterance.onerror = () => {
|
|
3626
|
-
if (this.#currentUtterance !== utterance)
|
|
3627
|
-
return;
|
|
3628
|
-
this.#currentUtterance = null;
|
|
3629
|
-
this.#clearAllHighlights();
|
|
3630
|
-
this.#setSpeechState("idle");
|
|
3631
|
-
};
|
|
3632
|
-
this.#currentUtterance = utterance;
|
|
3633
|
-
speechSynthesis.speak(utterance);
|
|
3634
|
-
this.#setSpeechState("playing");
|
|
3635
|
-
}
|
|
3636
|
-
#pause() {
|
|
3637
|
-
speechSynthesis.pause();
|
|
3638
|
-
this.#setSpeechState("paused");
|
|
3639
|
-
}
|
|
3640
|
-
#resume() {
|
|
3641
|
-
speechSynthesis.resume();
|
|
3642
|
-
this.#setSpeechState("playing");
|
|
3643
|
-
}
|
|
3644
|
-
#stop() {
|
|
3645
|
-
this.#currentUtterance = null;
|
|
3646
|
-
speechSynthesis.cancel();
|
|
3647
|
-
this.#clearAllHighlights();
|
|
3648
|
-
this.#setSpeechState("idle");
|
|
3649
|
-
}
|
|
3650
|
-
// ─── Pick mode ────────────────────────────────────────────────────────────
|
|
3651
|
-
#togglePick() {
|
|
3652
|
-
if (this.#picking)
|
|
3653
|
-
this.#stopPicking();
|
|
3654
|
-
else
|
|
3655
|
-
this.#startPicking();
|
|
3656
|
-
}
|
|
3657
|
-
/** Highlight every reading element and wait for a click on one of them. */
|
|
3658
|
-
#startPicking() {
|
|
3659
|
-
if (this.#contentMode)
|
|
3660
|
-
this.#readingElements = null;
|
|
3661
|
-
const elements = this.#getReadingElements();
|
|
3662
|
-
if (!elements.length) {
|
|
3663
|
-
console.warn("test-item-to-speech: no readable elements found");
|
|
3664
|
-
return;
|
|
3665
|
-
}
|
|
3666
|
-
this.#stop();
|
|
3667
|
-
this.#picking = true;
|
|
3668
|
-
this.#internals.states.add("picking");
|
|
3669
|
-
this.#highlightElements(elements);
|
|
3670
|
-
this.#pickRoot = elements[0].getRootNode();
|
|
3671
|
-
this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
|
|
3672
|
-
this._ttsContext = { ...this._ttsContext, picking: true };
|
|
3673
|
-
}
|
|
3674
|
-
#stopPicking() {
|
|
3675
|
-
if (!this.#picking)
|
|
3676
|
-
return;
|
|
3677
|
-
this.#picking = false;
|
|
3678
|
-
this.#internals.states.delete("picking");
|
|
3679
|
-
this.#pickRoot?.removeEventListener("click", this.#boundHandlePickClick, true);
|
|
3680
|
-
this.#pickRoot = null;
|
|
3681
|
-
this.#clearAllHighlights();
|
|
3682
|
-
this._ttsContext = { ...this._ttsContext, picking: false };
|
|
3683
|
-
}
|
|
3684
|
-
#handlePickClick(event) {
|
|
3685
|
-
const elements = this.#getReadingElements();
|
|
3686
|
-
const path = event.composedPath();
|
|
3687
|
-
let index = elements.findIndex((el) => path.includes(el));
|
|
3688
|
-
if (index < 0) {
|
|
3689
|
-
const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
|
|
3690
|
-
if (container)
|
|
3691
|
-
index = elements.findIndex((el) => container.contains(el));
|
|
3692
|
-
}
|
|
3693
|
-
if (index < 0)
|
|
3694
|
-
return;
|
|
3695
|
-
event.preventDefault();
|
|
3696
|
-
event.stopPropagation();
|
|
3697
|
-
this.#stopPicking();
|
|
3698
|
-
speechSynthesis.cancel();
|
|
3699
|
-
this.#speakElement(index);
|
|
3700
|
-
}
|
|
3701
|
-
#prevElement() {
|
|
3702
|
-
const elements = this.#getReadingElements();
|
|
3703
|
-
if (!elements.length)
|
|
3704
|
-
return;
|
|
3705
|
-
this.#currentUtterance = null;
|
|
3706
|
-
speechSynthesis.cancel();
|
|
3707
|
-
this.#clearWordHighlight();
|
|
3708
|
-
this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
|
|
3709
|
-
this.#finished = false;
|
|
3710
|
-
this.#updateContext();
|
|
3711
|
-
const el = elements[this.#currentElementIndex];
|
|
3712
|
-
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3713
|
-
this.#highlightElement(el);
|
|
3714
|
-
this.#setSpeechState("idle");
|
|
3715
|
-
}
|
|
3716
|
-
#nextElement() {
|
|
3717
|
-
const elements = this.#getReadingElements();
|
|
3718
|
-
if (!elements.length)
|
|
3719
|
-
return;
|
|
3720
|
-
this.#currentUtterance = null;
|
|
3721
|
-
speechSynthesis.cancel();
|
|
3722
|
-
this.#clearWordHighlight();
|
|
3723
|
-
this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
|
|
3724
|
-
this.#finished = false;
|
|
3725
|
-
this.#updateContext();
|
|
3726
|
-
const el = elements[this.#currentElementIndex];
|
|
3727
|
-
el.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3728
|
-
this.#highlightElement(el);
|
|
3729
|
-
this.#setSpeechState("idle");
|
|
3730
|
-
}
|
|
3731
|
-
/** Walk text nodes without crossing shadow DOM boundaries. */
|
|
3732
|
-
#collectTextNodes(root) {
|
|
3733
|
-
const nodes = [];
|
|
3734
|
-
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
3735
|
-
let node;
|
|
3736
|
-
while (node = walker.nextNode()) {
|
|
3737
|
-
if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
|
|
3738
|
-
nodes.push(node);
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
return nodes;
|
|
3742
|
-
}
|
|
3743
|
-
/** Highlight the whole element as the navigation cursor (blue). */
|
|
3744
|
-
#highlightElement(element) {
|
|
3745
|
-
this.#highlightElements([element]);
|
|
3746
|
-
}
|
|
3747
|
-
/** Put the blue cursor highlight on several elements at once (pick mode). */
|
|
3748
|
-
#highlightElements(elements) {
|
|
3749
|
-
if (!("highlights" in CSS))
|
|
3750
|
-
return;
|
|
3751
|
-
this.#ensureHighlightStyles();
|
|
3752
|
-
this.#elementHighlight.clear();
|
|
3753
|
-
for (const element of elements) {
|
|
3754
|
-
const range = new Range();
|
|
3755
|
-
range.selectNodeContents(element);
|
|
3756
|
-
this.#elementHighlight.add(range);
|
|
3757
|
-
}
|
|
3758
|
-
CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
|
|
3759
|
-
}
|
|
3760
|
-
/** Highlight the current word within #textNodes (yellow, during speech). */
|
|
3761
|
-
#updateWordHighlight(charIndex, charLength) {
|
|
3762
|
-
if (!("highlights" in CSS))
|
|
3763
|
-
return;
|
|
3764
|
-
this.#ensureHighlightStyles();
|
|
3765
|
-
this.#wordHighlight.clear();
|
|
3766
|
-
const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
|
|
3767
|
-
const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));
|
|
3768
|
-
let offset = 0;
|
|
3769
|
-
let startNode = null;
|
|
3770
|
-
let startOffset = 0;
|
|
3771
|
-
let endNode = null;
|
|
3772
|
-
let endOffset = 0;
|
|
3773
|
-
for (const node of this.#textNodes) {
|
|
3774
|
-
const len = node.textContent?.length ?? 0;
|
|
3775
|
-
if (!startNode && offset + len > charIndex) {
|
|
3776
|
-
startNode = node;
|
|
3777
|
-
startOffset = charIndex - offset;
|
|
3778
|
-
}
|
|
3779
|
-
if (startNode && offset + len >= endIndex) {
|
|
3780
|
-
endNode = node;
|
|
3781
|
-
endOffset = endIndex - offset;
|
|
3782
|
-
break;
|
|
3783
|
-
}
|
|
3784
|
-
offset += len;
|
|
3785
|
-
}
|
|
3786
|
-
if (startNode && endNode) {
|
|
3787
|
-
const range = new Range();
|
|
3788
|
-
range.setStart(startNode, startOffset);
|
|
3789
|
-
range.setEnd(endNode, endOffset);
|
|
3790
|
-
this.#wordHighlight.add(range);
|
|
3791
|
-
CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);
|
|
3792
|
-
}
|
|
3793
|
-
}
|
|
3794
|
-
#clearWordHighlight() {
|
|
3795
|
-
if (!("highlights" in CSS))
|
|
3796
|
-
return;
|
|
3797
|
-
this.#wordHighlight.clear();
|
|
3798
|
-
if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight)
|
|
3799
|
-
CSS.highlights.delete(HIGHLIGHT_WORD);
|
|
3800
|
-
}
|
|
3801
|
-
#clearAllHighlights() {
|
|
3802
|
-
if (!("highlights" in CSS))
|
|
3803
|
-
return;
|
|
3804
|
-
this.#clearWordHighlight();
|
|
3805
|
-
this.#elementHighlight.clear();
|
|
3806
|
-
if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
|
|
3807
|
-
CSS.highlights.delete(HIGHLIGHT_ELEMENT);
|
|
3808
|
-
}
|
|
3809
|
-
/** Fallback word-length when charLength is 0. */
|
|
3810
|
-
#wordLengthAt(charIndex, text) {
|
|
3811
|
-
const right = text.slice(charIndex).search(/\s/);
|
|
3812
|
-
return right < 0 ? text.length - charIndex : right;
|
|
3813
|
-
}
|
|
3814
|
-
/**
|
|
3815
|
-
* Add ::highlight() rules both to test-container's shadow root (where highlighted
|
|
3816
|
-
* text lives) and to the document (safety net — spec allows document rules to apply
|
|
3817
|
-
* across shadow DOM). Called lazily on first highlight use so test-container is
|
|
3818
|
-
* guaranteed to be in the DOM by the time navigation or speech starts.
|
|
3819
|
-
*/
|
|
3820
|
-
#ensureHighlightStyles() {
|
|
3821
|
-
if (!("highlights" in CSS))
|
|
3822
|
-
return;
|
|
3823
|
-
const sheet = getHighlightSheet();
|
|
3824
|
-
if (!document.adoptedStyleSheets.includes(sheet)) {
|
|
3825
|
-
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
3826
|
-
}
|
|
3827
|
-
const roots = /* @__PURE__ */ new Set();
|
|
3828
|
-
const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.testHost?.querySelector("test-container");
|
|
3829
|
-
if (testContainer?.shadowRoot)
|
|
3830
|
-
roots.add(testContainer.shadowRoot);
|
|
3831
|
-
const ownRoot = this.getRootNode();
|
|
3832
|
-
if (ownRoot instanceof ShadowRoot)
|
|
3833
|
-
roots.add(ownRoot);
|
|
3834
|
-
const itemRoot = this.#readingElements?.[0]?.getRootNode();
|
|
3835
|
-
if (itemRoot instanceof ShadowRoot)
|
|
3836
|
-
roots.add(itemRoot);
|
|
3837
|
-
for (const root of roots) {
|
|
3838
|
-
if (!root.adoptedStyleSheets.includes(sheet)) {
|
|
3839
|
-
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
}
|
|
3843
|
-
};
|
|
3844
|
-
__decorate15([
|
|
3845
|
-
property12({ type: String })
|
|
3846
|
-
], TestItemToSpeech.prototype, "language", void 0);
|
|
3847
|
-
__decorate15([
|
|
3848
|
-
consume8({ context: sessionContext, subscribe: true })
|
|
3849
|
-
], TestItemToSpeech.prototype, "_sessionContext", void 0);
|
|
3850
|
-
__decorate15([
|
|
3851
|
-
consume8({ context: testHostContext, subscribe: true })
|
|
3852
|
-
], TestItemToSpeech.prototype, "testHost", void 0);
|
|
3853
|
-
__decorate15([
|
|
3854
|
-
state4(),
|
|
3855
|
-
provide3({ context: ttsContext })
|
|
3856
|
-
], TestItemToSpeech.prototype, "_ttsContext", void 0);
|
|
3857
|
-
var TestTtsPlay = class extends TtsButtonBase {
|
|
3858
|
-
#toggle() {
|
|
3859
|
-
if (!this._tts)
|
|
3860
|
-
return;
|
|
3861
|
-
if (this._tts.state === "idle")
|
|
3862
|
-
this._tts.play();
|
|
3863
|
-
else if (this._tts.state === "playing")
|
|
3864
|
-
this._tts.pause();
|
|
3865
|
-
else
|
|
3866
|
-
this._tts.resume();
|
|
3867
|
-
}
|
|
3868
|
-
render() {
|
|
3869
|
-
const playing = this._tts?.state === "playing";
|
|
3870
|
-
return html14`
|
|
3871
|
-
<button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
|
|
3872
|
-
${playing ? html14`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html14`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
|
|
3873
|
-
</button>
|
|
3874
|
-
`;
|
|
3875
|
-
}
|
|
3876
|
-
};
|
|
3877
|
-
__decorate15([
|
|
3878
|
-
property12({ type: String, attribute: "pause-label" })
|
|
3879
|
-
], TestTtsPlay.prototype, "pauseLabel", void 0);
|
|
3880
|
-
var TestTtsPause = class extends TtsButtonBase {
|
|
3881
|
-
render() {
|
|
3882
|
-
return html14`
|
|
3883
|
-
<button
|
|
3884
|
-
part="button"
|
|
3885
|
-
aria-label=${ifDefined(this.label)}
|
|
3886
|
-
?disabled=${this._tts?.state !== "playing"}
|
|
3887
|
-
@click=${() => this._tts?.pause()}
|
|
3888
|
-
>
|
|
3889
|
-
<slot>${iconContent("pause", this.label ?? "Pause")}</slot>
|
|
3890
|
-
</button>
|
|
3891
|
-
`;
|
|
3892
|
-
}
|
|
3893
|
-
};
|
|
3894
|
-
var TestTtsResume = class extends TtsButtonBase {
|
|
3895
|
-
render() {
|
|
3896
|
-
return html14`
|
|
3897
|
-
<button
|
|
3898
|
-
part="button"
|
|
3899
|
-
aria-label=${ifDefined(this.label)}
|
|
3900
|
-
?disabled=${this._tts?.state !== "paused"}
|
|
3901
|
-
@click=${() => this._tts?.resume()}
|
|
3902
|
-
>
|
|
3903
|
-
<slot>${iconContent("play", this.label ?? "Resume")}</slot>
|
|
3904
|
-
</button>
|
|
3905
|
-
`;
|
|
3906
|
-
}
|
|
3907
|
-
};
|
|
3908
|
-
var TestTtsStop = class extends TtsButtonBase {
|
|
3909
|
-
render() {
|
|
3910
|
-
const idle = this._tts?.state === "idle" && !this._tts?.picking;
|
|
3911
|
-
return html14`
|
|
3912
|
-
<button part="button" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>
|
|
3913
|
-
<slot>${iconContent("stop", this.label ?? "Stop")}</slot>
|
|
3914
|
-
</button>
|
|
3915
|
-
`;
|
|
3916
|
-
}
|
|
3917
|
-
};
|
|
3918
|
-
var TestTtsPrev = class extends TtsButtonBase {
|
|
3919
|
-
render() {
|
|
3920
|
-
const collected = (this._tts?.elementCount ?? 0) > 0;
|
|
3921
|
-
const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
|
|
3922
|
-
return html14`
|
|
3923
|
-
<button
|
|
3924
|
-
part="button"
|
|
3925
|
-
aria-label=${ifDefined(this.label)}
|
|
3926
|
-
?disabled=${collected && atStart}
|
|
3927
|
-
@click=${() => this._tts?.prevElement()}
|
|
3928
|
-
>
|
|
3929
|
-
<slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
|
|
3930
|
-
</button>
|
|
3931
|
-
`;
|
|
3932
|
-
}
|
|
3933
|
-
};
|
|
3934
|
-
var TestTtsNext = class extends TtsButtonBase {
|
|
3935
|
-
render() {
|
|
3936
|
-
const count = this._tts?.elementCount ?? 0;
|
|
3937
|
-
const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
|
|
3938
|
-
return html14`
|
|
3939
|
-
<button
|
|
3940
|
-
part="button"
|
|
3941
|
-
aria-label=${ifDefined(this.label)}
|
|
3942
|
-
?disabled=${atEnd}
|
|
3943
|
-
@click=${() => this._tts?.nextElement()}
|
|
3944
|
-
>
|
|
3945
|
-
<slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
|
|
3946
|
-
</button>
|
|
3947
|
-
`;
|
|
3948
|
-
}
|
|
3949
|
-
};
|
|
3950
|
-
var TestTtsPick = class extends TtsButtonBase {
|
|
3951
|
-
render() {
|
|
3952
|
-
return html14`
|
|
3953
|
-
<button
|
|
3954
|
-
part="button"
|
|
3955
|
-
aria-label=${ifDefined(this.label)}
|
|
3956
|
-
aria-pressed=${this._tts?.picking ? "true" : "false"}
|
|
3957
|
-
@click=${() => this._tts?.togglePick()}
|
|
3958
|
-
>
|
|
3959
|
-
<slot>${iconContent("pick", this.label ?? "Read from here")}</slot>
|
|
3960
|
-
</button>
|
|
3961
|
-
`;
|
|
3962
|
-
}
|
|
3963
|
-
};
|
|
3964
|
-
|
|
3965
|
-
// ../qti-test/dist/components/test-navigation/test-navigation.js
|
|
3966
|
-
import { ContextConsumer, consume as consume9, provide as provide4 } from "@lit/context";
|
|
3967
|
-
import { html as html15, LitElement as LitElement16 } from "lit";
|
|
3968
|
-
import { property as property13, state as state5 } from "lit/decorators.js";
|
|
3969
|
-
var __decorate16 = function(decorators, target, key, desc) {
|
|
3970
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3971
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3972
|
-
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;
|
|
3973
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3974
|
-
};
|
|
3975
|
-
var newQtiContext = () => ({
|
|
3976
|
-
QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
|
|
3977
|
-
});
|
|
3978
|
-
var TestNavigation = class extends LitElement16 {
|
|
3979
|
-
/**
|
|
3980
|
-
* @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
|
|
3981
|
-
* enclosing test's: reading returns it, writing replaces it, so a host that has always set the
|
|
3982
|
-
* shuffle seed here keeps working. Removed in the next major.
|
|
3983
|
-
*
|
|
3984
|
-
* Written before the navigation is inside a test, it waits and is handed over on connect.
|
|
3985
|
-
*/
|
|
3986
|
-
get qtiContext() {
|
|
3987
|
-
return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
|
|
3312
|
+
var newQtiContext = () => ({
|
|
3313
|
+
QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
|
|
3314
|
+
});
|
|
3315
|
+
var TestNavigation = class extends LitElement13 {
|
|
3316
|
+
/**
|
|
3317
|
+
* @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
|
|
3318
|
+
* enclosing test's: reading returns it, writing replaces it, so a host that has always set the
|
|
3319
|
+
* shuffle seed here keeps working. Removed in the next major.
|
|
3320
|
+
*
|
|
3321
|
+
* Written before the navigation is inside a test, it waits and is handed over on connect.
|
|
3322
|
+
*/
|
|
3323
|
+
get qtiContext() {
|
|
3324
|
+
return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
|
|
3988
3325
|
}
|
|
3989
3326
|
set qtiContext(value) {
|
|
3990
3327
|
if (!this.#warnedQtiContext) {
|
|
@@ -4038,12 +3375,15 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4038
3375
|
this.configContext = {};
|
|
4039
3376
|
this.autoScoreItems = false;
|
|
4040
3377
|
this.#optimality = /* @__PURE__ */ new Map();
|
|
4041
|
-
|
|
4042
|
-
this
|
|
4043
|
-
|
|
3378
|
+
this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
|
|
3379
|
+
this.#sectionItems = /* @__PURE__ */ new Map();
|
|
3380
|
+
this.#itemOrder = [];
|
|
3381
|
+
this.#lockedItems = /* @__PURE__ */ new WeakSet();
|
|
3382
|
+
listenPublic2(this, "qc-test-loaded", this.#handleTestConnected.bind(this));
|
|
3383
|
+
listenPublic(this, "qc-item-response-changed", this.#handleInteractionChanged.bind(this));
|
|
4044
3384
|
this.addEventListener("qti-item-context-updated", this.#handleItemContextUpdated.bind(this));
|
|
4045
|
-
listenPublic2(this, "
|
|
4046
|
-
listenPublic2(this, "
|
|
3385
|
+
listenPublic2(this, "qc-test-end-attempt", this.#handleTestEndAttempt.bind(this));
|
|
3386
|
+
listenPublic2(this, "qc-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
|
|
4047
3387
|
}
|
|
4048
3388
|
/**
|
|
4049
3389
|
* Latch whether an item reached its optimal outcome whenever it has just ended
|
|
@@ -4063,7 +3403,7 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4063
3403
|
const computedItem = this.computedItemFor(itemContext.identifier);
|
|
4064
3404
|
const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
|
|
4065
3405
|
const completionStatus = itemContext.variables?.find((v) => v.identifier === "completionStatus")?.value;
|
|
4066
|
-
this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.maxAttempts, computedItem?.adaptive, completionStatus));
|
|
3406
|
+
this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.sessionControl?.maxAttempts, computedItem?.adaptive, completionStatus));
|
|
4067
3407
|
}
|
|
4068
3408
|
/**
|
|
4069
3409
|
* Extension point for presentation packages reacting to an ended attempt.
|
|
@@ -4081,9 +3421,11 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4081
3421
|
#assessmentItemFor(identifier) {
|
|
4082
3422
|
if (!identifier)
|
|
4083
3423
|
return void 0;
|
|
4084
|
-
const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${identifier}"]`);
|
|
3424
|
+
const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"]`);
|
|
4085
3425
|
return itemRef?.assessmentItem ?? void 0;
|
|
4086
3426
|
}
|
|
3427
|
+
/** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
|
|
3428
|
+
#itemElement;
|
|
4087
3429
|
/** The currently active assessment item, exposed for optional presentation extensions. */
|
|
4088
3430
|
get activeAssessmentItem() {
|
|
4089
3431
|
if (!this.#testElement || !this._sessionContext?.navItemRefId)
|
|
@@ -4091,13 +3433,12 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4091
3433
|
return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
|
|
4092
3434
|
}
|
|
4093
3435
|
/**
|
|
4094
|
-
*
|
|
4095
|
-
*
|
|
4096
|
-
* @listens TestNavigation#test-end-attempt
|
|
4097
|
-
* @param {CustomEvent} event - The custom event object.
|
|
3436
|
+
* Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or
|
|
3437
|
+
* given an `item`), or else the item on screen.
|
|
4098
3438
|
*/
|
|
4099
|
-
#handleTestEndAttempt(
|
|
4100
|
-
const
|
|
3439
|
+
#handleTestEndAttempt(event) {
|
|
3440
|
+
const itemId = event.detail?.itemId;
|
|
3441
|
+
const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;
|
|
4101
3442
|
if (!qtiAssessmentItemEl)
|
|
4102
3443
|
return;
|
|
4103
3444
|
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
@@ -4122,7 +3463,7 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4122
3463
|
}
|
|
4123
3464
|
}
|
|
4124
3465
|
render() {
|
|
4125
|
-
return
|
|
3466
|
+
return html11`<slot></slot>`;
|
|
4126
3467
|
}
|
|
4127
3468
|
/* PK: on test connected we can build the computed context */
|
|
4128
3469
|
#handleTestConnected(event) {
|
|
@@ -4156,61 +3497,65 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4156
3497
|
});
|
|
4157
3498
|
}
|
|
4158
3499
|
});
|
|
4159
|
-
const
|
|
3500
|
+
const model = buildTestModel(renderedMarkup(this.#testElement));
|
|
3501
|
+
this.#sectionItems = new Map(model.testParts.flatMap((part) => sectionsInOrder(part.sections).map((section) => [section.identifier, itemRefsInOrder(section.content).map((item) => item.identifier)])));
|
|
3502
|
+
this.#itemOrder = model.testParts.flatMap((part) => itemRefsInOrder(part.sections));
|
|
4160
3503
|
this.computedContext = {
|
|
4161
|
-
|
|
4162
|
-
|
|
3504
|
+
itemElement: this.#itemElement,
|
|
3505
|
+
identifier: model.identifier,
|
|
3506
|
+
title: model.title,
|
|
4163
3507
|
view: this._sessionContext?.view,
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
3508
|
+
plugins: this._sessionContext?.plugins ?? {},
|
|
3509
|
+
testParts: model.testParts.map((testPart) => ({
|
|
3510
|
+
active: false,
|
|
3511
|
+
identifier: testPart.identifier,
|
|
3512
|
+
navigationMode: testPart.navigationMode,
|
|
3513
|
+
submissionMode: testPart.submissionMode,
|
|
3514
|
+
allowSkipping: testPart.sessionControl.allowSkipping,
|
|
3515
|
+
// Flat, depth first: every section once, each with only its own item-refs, so every item is
|
|
3516
|
+
// listed once. Where a section's item-refs and subsections interleave, this list is not in
|
|
3517
|
+
// document order; `index` is.
|
|
3518
|
+
sections: sectionsInOrder(testPart.sections).map((section) => ({
|
|
4172
3519
|
active: false,
|
|
4173
|
-
identifier:
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
};
|
|
4213
|
-
})
|
|
3520
|
+
identifier: section.identifier,
|
|
3521
|
+
title: section.title,
|
|
3522
|
+
// QTI defines both modes on the test part only; the section attributes go in roadmap T1d.
|
|
3523
|
+
...this.#sectionModes(section.identifier),
|
|
3524
|
+
allowSkipping: section.sessionControl.allowSkipping,
|
|
3525
|
+
items: ownItemRefs(section).map((item) => ({
|
|
3526
|
+
...this.initContext?.find((i) => i.identifier === item.identifier),
|
|
3527
|
+
active: false,
|
|
3528
|
+
identifier: item.identifier,
|
|
3529
|
+
categories: item.categories,
|
|
3530
|
+
href: item.href,
|
|
3531
|
+
variables: [],
|
|
3532
|
+
sessionControl: { ...item.sessionControl }
|
|
3533
|
+
}))
|
|
3534
|
+
}))
|
|
3535
|
+
}))
|
|
3536
|
+
};
|
|
3537
|
+
}
|
|
3538
|
+
/**
|
|
3539
|
+
* The item-refs of each section, its subsections' included, by section identifier: a section that
|
|
3540
|
+
* only holds subsections is completed when theirs are.
|
|
3541
|
+
*/
|
|
3542
|
+
#sectionItems;
|
|
3543
|
+
/** Every item-ref of the test in document order, which item numbers follow. */
|
|
3544
|
+
#itemOrder;
|
|
3545
|
+
/** Item numbers in document order, skipping info items; null for an info item. */
|
|
3546
|
+
#itemIndexes() {
|
|
3547
|
+
let index = 1;
|
|
3548
|
+
return new Map(this.#itemOrder.map((item) => [
|
|
3549
|
+
item.identifier,
|
|
3550
|
+
item.categories.includes(this.configContext?.infoItemCategory) ? null : index++
|
|
3551
|
+
]));
|
|
3552
|
+
}
|
|
3553
|
+
/** The non-QTI `navigation-mode` / `submission-mode` a section declares, as before; removed in T1d. */
|
|
3554
|
+
#sectionModes(identifier) {
|
|
3555
|
+
const section = this.#testElement.querySelector(`qti-assessment-section[identifier="${CSS.escape(identifier)}"]`);
|
|
3556
|
+
return {
|
|
3557
|
+
navigationMode: section?.getAttribute("navigation-mode") ?? void 0,
|
|
3558
|
+
submissionMode: section?.getAttribute("submission-mode") ?? void 0
|
|
4214
3559
|
};
|
|
4215
3560
|
}
|
|
4216
3561
|
/**
|
|
@@ -4250,59 +3595,23 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4250
3595
|
});
|
|
4251
3596
|
return defaultValues;
|
|
4252
3597
|
}
|
|
4253
|
-
|
|
4254
|
-
#
|
|
4255
|
-
const
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
...testPart,
|
|
4261
|
-
sections: testPart.sections.map((section) => {
|
|
4262
|
-
return {
|
|
4263
|
-
...section,
|
|
4264
|
-
items: section.items.map((item) => {
|
|
4265
|
-
if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
|
|
4266
|
-
return item;
|
|
4267
|
-
}
|
|
4268
|
-
const scoreOutcome = itemElement.querySelector("qti-outcome-declaration[identifier='SCORE']");
|
|
4269
|
-
const externalScored = scoreOutcome?.getAttribute("externalScored");
|
|
4270
|
-
const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
|
|
4271
|
-
const containsCorrectResponse = Array.from(responseDeclarations).some((r) => r.querySelector("qti-correct-response"));
|
|
4272
|
-
const containsMapping = Array.from(responseDeclarations).some((r) => {
|
|
4273
|
-
const mapping = r.querySelector("qti-mapping");
|
|
4274
|
-
const areaMapping = r.querySelector("qti-area-mapping");
|
|
4275
|
-
return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
|
|
4276
|
-
});
|
|
4277
|
-
const hasCorrectResponse = containsCorrectResponse || containsMapping;
|
|
4278
|
-
const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
|
|
4279
|
-
return {
|
|
4280
|
-
...item,
|
|
4281
|
-
assessmentItemIdentifier: itemElement.getAttribute("identifier"),
|
|
4282
|
-
label: itemElement.getAttribute("label"),
|
|
4283
|
-
title: itemElement.title,
|
|
4284
|
-
externalScored,
|
|
4285
|
-
adaptive: itemElement.adaptive == "true" || false,
|
|
4286
|
-
timeDependent: itemElement.timeDependent == "true" || false,
|
|
4287
|
-
variables: itemElement.variables,
|
|
4288
|
-
hasCorrectResponse,
|
|
4289
|
-
hasResponseProcessing
|
|
4290
|
-
};
|
|
4291
|
-
})
|
|
4292
|
-
};
|
|
4293
|
-
})
|
|
4294
|
-
};
|
|
4295
|
-
})
|
|
4296
|
-
};
|
|
3598
|
+
/** An item's facts as `computedContext` has carried them; nothing until the item is fetched. */
|
|
3599
|
+
#factsFor(identifier) {
|
|
3600
|
+
const facts = this._itemFacts?.get(identifier);
|
|
3601
|
+
if (!facts)
|
|
3602
|
+
return {};
|
|
3603
|
+
const { identifier: assessmentItemIdentifier, ...rest } = facts;
|
|
3604
|
+
return { ...rest, assessmentItemIdentifier };
|
|
4297
3605
|
}
|
|
4298
3606
|
/* PK: on every change of the candidate we will recomputed the computedContext */
|
|
4299
3607
|
willUpdate(_changedProperties) {
|
|
4300
3608
|
if (!this.computedContext)
|
|
4301
3609
|
return;
|
|
4302
|
-
|
|
3610
|
+
const itemIndexes = this.#itemIndexes();
|
|
4303
3611
|
this.computedContext = {
|
|
4304
3612
|
...this.computedContext,
|
|
4305
3613
|
view: this._sessionContext?.view,
|
|
3614
|
+
plugins: this._sessionContext?.plugins ?? {},
|
|
4306
3615
|
testParts: this.computedContext.testParts.map((testPart) => {
|
|
4307
3616
|
return {
|
|
4308
3617
|
...testPart,
|
|
@@ -4311,11 +3620,12 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4311
3620
|
return {
|
|
4312
3621
|
...section,
|
|
4313
3622
|
active: this._sessionContext?.navSectionId === section.identifier || false,
|
|
4314
|
-
completed: section.items.every((
|
|
3623
|
+
completed: (this.#sectionItems.get(section.identifier) ?? section.items.map((i) => i.identifier)).every((identifier) => this._testContext.items.find((i) => i.identifier === identifier)?.variables.find((v) => v.identifier === "completionStatus")?.value === "completed"),
|
|
4315
3624
|
items: section.items.map((item) => {
|
|
4316
3625
|
const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
|
|
4317
3626
|
const computedItem = {
|
|
4318
3627
|
...item,
|
|
3628
|
+
...this.#factsFor(item.identifier),
|
|
4319
3629
|
...itemContext,
|
|
4320
3630
|
...this.initContext?.find((i) => i.identifier === item.identifier)
|
|
4321
3631
|
};
|
|
@@ -4326,7 +3636,7 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4326
3636
|
const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
|
|
4327
3637
|
const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
|
|
4328
3638
|
const valid = itemContext?.valid ?? true;
|
|
4329
|
-
const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
|
|
3639
|
+
const responseVars = itemContext?.variables?.filter((v) => v.type === "response" && v.identifier !== "numAttempts") || [];
|
|
4330
3640
|
const isDefaultResponse = responseVars.every((v) => {
|
|
4331
3641
|
if (v.value === void 0 || v.value === null) {
|
|
4332
3642
|
return true;
|
|
@@ -4357,7 +3667,7 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4357
3667
|
}
|
|
4358
3668
|
return v.value === defaultValue;
|
|
4359
3669
|
});
|
|
4360
|
-
const index =
|
|
3670
|
+
const index = itemIndexes.get(item.identifier) ?? null;
|
|
4361
3671
|
const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
|
|
4362
3672
|
const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
|
|
4363
3673
|
let optimality = this.#optimality.get(computedItem.identifier);
|
|
@@ -4366,7 +3676,7 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4366
3676
|
if (numAttempts > 0)
|
|
4367
3677
|
this.#optimality.set(computedItem.identifier, optimality);
|
|
4368
3678
|
}
|
|
4369
|
-
const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts, computedItem.adaptive, completionStatus);
|
|
3679
|
+
const done = this.#isItemDone(numAttempts, optimality, computedItem.sessionControl?.maxAttempts, computedItem.adaptive, completionStatus);
|
|
4370
3680
|
return {
|
|
4371
3681
|
...computedItem,
|
|
4372
3682
|
completionStatus,
|
|
@@ -4401,6 +3711,53 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4401
3711
|
bubbles: true
|
|
4402
3712
|
}));
|
|
4403
3713
|
}
|
|
3714
|
+
updated(changedProperties) {
|
|
3715
|
+
super.updated(changedProperties);
|
|
3716
|
+
this.#lockUsedItems();
|
|
3717
|
+
}
|
|
3718
|
+
/** The items this navigation disabled because their attempts are used, so it releases only those. */
|
|
3719
|
+
#lockedItems;
|
|
3720
|
+
/**
|
|
3721
|
+
* Disables every rendered item whose attempts are used, from the computed context, so the
|
|
3722
|
+
* candidate cannot change the answer once the last attempt is ended. Runs after every update:
|
|
3723
|
+
* an item rendered later (another item, a section on screen, a restored state) is locked as it
|
|
3724
|
+
* arrives, and one whose attempts are back to zero (a new state) is released.
|
|
3725
|
+
*
|
|
3726
|
+
* Only `disabled = true` is ever set here, and only on an item that was not disabled already; a
|
|
3727
|
+
* host or view that disables or makes an item read-only itself keeps it so.
|
|
3728
|
+
*/
|
|
3729
|
+
#lockUsedItems() {
|
|
3730
|
+
if (!this.#testElement || !this.computedContext)
|
|
3731
|
+
return;
|
|
3732
|
+
const items = new Map(this.computedContext.testParts.flatMap((part) => part.sections.flatMap((section) => (section.submissionMode || part.submissionMode) === "simultaneous" ? [] : section.items.map((item) => [item.identifier, item]))));
|
|
3733
|
+
for (const itemRef of this.#testElement.querySelectorAll("qti-assessment-item-ref")) {
|
|
3734
|
+
const element = itemRef.assessmentItem;
|
|
3735
|
+
if (!element)
|
|
3736
|
+
continue;
|
|
3737
|
+
const used = this.#attemptsUsed(items.get(itemRef.identifier), element);
|
|
3738
|
+
if (used && !element.disabled) {
|
|
3739
|
+
element.disabled = true;
|
|
3740
|
+
this.#lockedItems.add(element);
|
|
3741
|
+
} else if (!used && this.#lockedItems.has(element)) {
|
|
3742
|
+
this.#lockedItems.delete(element);
|
|
3743
|
+
element.disabled = false;
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
/**
|
|
3748
|
+
* The same rule as `test-end-attempt`'s max-attempts guard: a non-adaptive item with a
|
|
3749
|
+
* `max-attempts` above 0 whose attempts reached it. Adaptive items end themselves, and 0 is
|
|
3750
|
+
* unlimited. With `auto-score-items` every change is scored as an attempt, so the count is not
|
|
3751
|
+
* the candidate's and locks nothing.
|
|
3752
|
+
*/
|
|
3753
|
+
#attemptsUsed(item, element) {
|
|
3754
|
+
if (!item || this.autoScoreItems)
|
|
3755
|
+
return false;
|
|
3756
|
+
if (item.adaptive || element.adaptive === "true")
|
|
3757
|
+
return false;
|
|
3758
|
+
const maxAttempts = item.sessionControl?.maxAttempts ?? 1;
|
|
3759
|
+
return maxAttempts > 0 && (item.numAttempts ?? 0) >= maxAttempts;
|
|
3760
|
+
}
|
|
4404
3761
|
/**
|
|
4405
3762
|
* Decide whether an item should be treated as "the candidate is done with it"
|
|
4406
3763
|
* for the purpose of gating forward navigation and further attempts.
|
|
@@ -4484,63 +3841,54 @@ var TestNavigation = class extends LitElement16 {
|
|
|
4484
3841
|
return Number.isNaN(parsed) ? null : parsed;
|
|
4485
3842
|
}
|
|
4486
3843
|
};
|
|
4487
|
-
|
|
4488
|
-
|
|
3844
|
+
__decorate15([
|
|
3845
|
+
property12({ type: String })
|
|
4489
3846
|
], TestNavigation.prototype, "identifier", void 0);
|
|
4490
|
-
|
|
3847
|
+
__decorate15([
|
|
4491
3848
|
state5()
|
|
4492
3849
|
], TestNavigation.prototype, "initContext", void 0);
|
|
4493
|
-
|
|
3850
|
+
__decorate15([
|
|
4494
3851
|
state5(),
|
|
4495
|
-
|
|
3852
|
+
consume8({ context: configContext, subscribe: true })
|
|
4496
3853
|
], TestNavigation.prototype, "configContext", void 0);
|
|
4497
|
-
|
|
3854
|
+
__decorate15([
|
|
4498
3855
|
state5(),
|
|
4499
|
-
|
|
3856
|
+
consume8({ context: testContext, subscribe: true })
|
|
4500
3857
|
], TestNavigation.prototype, "_testContext", void 0);
|
|
4501
|
-
|
|
3858
|
+
__decorate15([
|
|
4502
3859
|
state5(),
|
|
4503
|
-
|
|
3860
|
+
consume8({ context: sessionContext, subscribe: true })
|
|
4504
3861
|
], TestNavigation.prototype, "_sessionContext", void 0);
|
|
4505
|
-
|
|
3862
|
+
__decorate15([
|
|
3863
|
+
state5(),
|
|
3864
|
+
consume8({ context: itemFactsContext, subscribe: true })
|
|
3865
|
+
], TestNavigation.prototype, "_itemFacts", void 0);
|
|
3866
|
+
__decorate15([
|
|
4506
3867
|
state5(),
|
|
4507
3868
|
provide4({ context: computedContext })
|
|
4508
3869
|
], TestNavigation.prototype, "computedContext", void 0);
|
|
4509
|
-
|
|
4510
|
-
|
|
3870
|
+
__decorate15([
|
|
3871
|
+
property12({ type: Boolean, attribute: "auto-score-items" })
|
|
4511
3872
|
], TestNavigation.prototype, "autoScoreItems", void 0);
|
|
4512
3873
|
|
|
4513
3874
|
// ../qti-test/dist/components/test-next/test-next.js
|
|
4514
|
-
import {
|
|
4515
|
-
import { property as
|
|
4516
|
-
import { consume as
|
|
4517
|
-
var
|
|
3875
|
+
import { LitElement as LitElement14 } from "lit";
|
|
3876
|
+
import { property as property13 } from "lit/decorators.js";
|
|
3877
|
+
import { consume as consume9 } from "@lit/context";
|
|
3878
|
+
var __decorate16 = function(decorators, target, key, desc) {
|
|
4518
3879
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4519
3880
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4520
3881
|
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;
|
|
4521
3882
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4522
3883
|
};
|
|
4523
|
-
var TestNext = class extends
|
|
3884
|
+
var TestNext = class extends LitElement14 {
|
|
4524
3885
|
_handleTestElementChange(_oldValue, newValue) {
|
|
4525
3886
|
if (newValue) {
|
|
4526
3887
|
this.requestUpdate();
|
|
4527
3888
|
}
|
|
4528
3889
|
}
|
|
4529
3890
|
static {
|
|
4530
|
-
this.styles =
|
|
4531
|
-
:host {
|
|
4532
|
-
${btn};
|
|
4533
|
-
}
|
|
4534
|
-
:host(:hover:not([disabled])) {
|
|
4535
|
-
${btnInteractive};
|
|
4536
|
-
}
|
|
4537
|
-
:host(:focus-visible) {
|
|
4538
|
-
${focusRing};
|
|
4539
|
-
}
|
|
4540
|
-
:host([disabled]) {
|
|
4541
|
-
${dis};
|
|
4542
|
-
}
|
|
4543
|
-
`;
|
|
3891
|
+
this.styles = [button, buttonPrimary];
|
|
4544
3892
|
}
|
|
4545
3893
|
#internals;
|
|
4546
3894
|
constructor() {
|
|
@@ -4581,88 +3929,40 @@ var TestNext = class extends LitElement17 {
|
|
|
4581
3929
|
this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 || isLinearIndividual && !activeItem?.done;
|
|
4582
3930
|
}
|
|
4583
3931
|
_requestItem(identifier) {
|
|
4584
|
-
dispatchPublic(this, "
|
|
3932
|
+
dispatchPublic(this, "qc-test-navigate", { type: "item", id: identifier });
|
|
4585
3933
|
}
|
|
4586
3934
|
render() {
|
|
4587
|
-
return
|
|
3935
|
+
return control;
|
|
4588
3936
|
}
|
|
4589
3937
|
};
|
|
4590
|
-
|
|
4591
|
-
|
|
3938
|
+
__decorate16([
|
|
3939
|
+
property13({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
4592
3940
|
], TestNext.prototype, "_internalDisabled", void 0);
|
|
4593
|
-
|
|
4594
|
-
|
|
3941
|
+
__decorate16([
|
|
3942
|
+
consume9({ context: computedContext, subscribe: true })
|
|
4595
3943
|
], TestNext.prototype, "computedContext", void 0);
|
|
4596
|
-
|
|
3944
|
+
__decorate16([
|
|
4597
3945
|
watch("computedContext")
|
|
4598
3946
|
], TestNext.prototype, "_handleTestElementChange", null);
|
|
4599
3947
|
|
|
4600
|
-
// ../qti-test/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js
|
|
4601
|
-
import { html as html17, LitElement as LitElement18 } from "lit";
|
|
4602
|
-
import { consume as consume11 } from "@lit/context";
|
|
4603
|
-
var __decorate18 = function(decorators, target, key, desc) {
|
|
4604
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4605
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4606
|
-
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;
|
|
4607
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4608
|
-
};
|
|
4609
|
-
var TestPagingButtonsStamp = class extends LitElement18 {
|
|
4610
|
-
#internals;
|
|
4611
|
-
createRenderRoot() {
|
|
4612
|
-
return this;
|
|
4613
|
-
}
|
|
4614
|
-
constructor() {
|
|
4615
|
-
super();
|
|
4616
|
-
this.#internals = this.attachInternals();
|
|
4617
|
-
this.#internals.ariaLabel = "pagination";
|
|
4618
|
-
}
|
|
4619
|
-
connectedCallback() {
|
|
4620
|
-
super.connectedCallback();
|
|
4621
|
-
const templateElement = this.querySelector("template");
|
|
4622
|
-
this.myTemplate = prepareTemplate(templateElement);
|
|
4623
|
-
}
|
|
4624
|
-
render() {
|
|
4625
|
-
if (!this.computedContext)
|
|
4626
|
-
return html17``;
|
|
4627
|
-
const items = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items));
|
|
4628
|
-
return html17` ${items.map((item) => this.myTemplate({ item, view: this.computedContext.view }))} `;
|
|
4629
|
-
}
|
|
4630
|
-
};
|
|
4631
|
-
__decorate18([
|
|
4632
|
-
consume11({ context: computedContext, subscribe: true })
|
|
4633
|
-
], TestPagingButtonsStamp.prototype, "computedContext", void 0);
|
|
4634
|
-
|
|
4635
3948
|
// ../qti-test/dist/components/test-prev/test-prev.js
|
|
4636
|
-
import {
|
|
4637
|
-
import { property as
|
|
4638
|
-
import { consume as
|
|
4639
|
-
var
|
|
3949
|
+
import { LitElement as LitElement15 } from "lit";
|
|
3950
|
+
import { property as property14 } from "lit/decorators.js";
|
|
3951
|
+
import { consume as consume10 } from "@lit/context";
|
|
3952
|
+
var __decorate17 = function(decorators, target, key, desc) {
|
|
4640
3953
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4641
3954
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4642
3955
|
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;
|
|
4643
3956
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4644
3957
|
};
|
|
4645
|
-
var TestPrev = class extends
|
|
3958
|
+
var TestPrev = class extends LitElement15 {
|
|
4646
3959
|
_handleTestElementChange(_oldValue, newValue) {
|
|
4647
3960
|
if (newValue) {
|
|
4648
3961
|
this.requestUpdate();
|
|
4649
3962
|
}
|
|
4650
3963
|
}
|
|
4651
3964
|
static {
|
|
4652
|
-
this.styles =
|
|
4653
|
-
:host {
|
|
4654
|
-
${btn};
|
|
4655
|
-
}
|
|
4656
|
-
:host(:hover:not([disabled])) {
|
|
4657
|
-
${btnInteractive};
|
|
4658
|
-
}
|
|
4659
|
-
:host(:focus-visible) {
|
|
4660
|
-
${focusRing};
|
|
4661
|
-
}
|
|
4662
|
-
:host([disabled]) {
|
|
4663
|
-
${dis};
|
|
4664
|
-
}
|
|
4665
|
-
`;
|
|
3965
|
+
this.styles = button;
|
|
4666
3966
|
}
|
|
4667
3967
|
constructor() {
|
|
4668
3968
|
super();
|
|
@@ -4690,520 +3990,39 @@ var TestPrev = class extends LitElement19 {
|
|
|
4690
3990
|
this._internalDisabled = navigationMode === "linear" || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
|
|
4691
3991
|
}
|
|
4692
3992
|
_requestItem(identifier) {
|
|
4693
|
-
dispatchPublic(this, "
|
|
3993
|
+
dispatchPublic(this, "qc-test-navigate", { type: "item", id: identifier });
|
|
4694
3994
|
}
|
|
4695
3995
|
render() {
|
|
4696
|
-
return
|
|
3996
|
+
return control;
|
|
4697
3997
|
}
|
|
4698
3998
|
};
|
|
4699
|
-
|
|
4700
|
-
|
|
3999
|
+
__decorate17([
|
|
4000
|
+
property14({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
4701
4001
|
], TestPrev.prototype, "_internalDisabled", void 0);
|
|
4702
|
-
|
|
4703
|
-
|
|
4002
|
+
__decorate17([
|
|
4003
|
+
consume10({ context: computedContext, subscribe: true })
|
|
4704
4004
|
], TestPrev.prototype, "computedContext", void 0);
|
|
4705
|
-
|
|
4005
|
+
__decorate17([
|
|
4706
4006
|
watch("computedContext")
|
|
4707
4007
|
], TestPrev.prototype, "_handleTestElementChange", null);
|
|
4708
4008
|
|
|
4709
|
-
// ../qti-test/dist/components/test-
|
|
4710
|
-
import {
|
|
4711
|
-
|
|
4712
|
-
import { state as state6 } from "lit/decorators.js";
|
|
4713
|
-
var __decorate20 = function(decorators, target, key, desc) {
|
|
4714
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4715
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4716
|
-
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;
|
|
4717
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4718
|
-
};
|
|
4719
|
-
var TestPrintContext = class extends LitElement20 {
|
|
4720
|
-
render() {
|
|
4721
|
-
return html19` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
|
|
4722
|
-
}
|
|
4723
|
-
};
|
|
4724
|
-
__decorate20([
|
|
4725
|
-
state6(),
|
|
4726
|
-
consume13({ context: computedContext, subscribe: true })
|
|
4727
|
-
], TestPrintContext.prototype, "computedContext", void 0);
|
|
4728
|
-
|
|
4729
|
-
// ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
|
|
4730
|
-
import { html as html20, css as css12, LitElement as LitElement21 } from "lit";
|
|
4731
|
-
import { consume as consume14 } from "@lit/context";
|
|
4732
|
-
var __decorate21 = function(decorators, target, key, desc) {
|
|
4733
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4734
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4735
|
-
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;
|
|
4736
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4737
|
-
};
|
|
4738
|
-
var TestPrintVariables = class extends LitElement21 {
|
|
4739
|
-
static {
|
|
4740
|
-
this.styles = css12`
|
|
4741
|
-
table {
|
|
4742
|
-
width: 100%;
|
|
4743
|
-
border-collapse: collapse;
|
|
4744
|
-
margin: 20px 0;
|
|
4745
|
-
font-size: 14px;
|
|
4746
|
-
text-align: left;
|
|
4747
|
-
}
|
|
4748
|
-
th,
|
|
4749
|
-
td {
|
|
4750
|
-
border: 1px solid #ddd;
|
|
4751
|
-
padding: 8px;
|
|
4752
|
-
}
|
|
4753
|
-
th {
|
|
4754
|
-
background-color: #f4f4f4;
|
|
4755
|
-
font-weight: bold;
|
|
4756
|
-
}
|
|
4757
|
-
h3 {
|
|
4758
|
-
margin-top: 20px;
|
|
4759
|
-
font-size: 16px;
|
|
4760
|
-
}
|
|
4761
|
-
`;
|
|
4762
|
-
}
|
|
4763
|
-
render() {
|
|
4764
|
-
const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
4765
|
-
if (!activeItem || !activeItem.variables)
|
|
4766
|
-
return html20``;
|
|
4767
|
-
const responseVariables = activeItem.variables.filter((v) => v.type === "response");
|
|
4768
|
-
const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
|
|
4769
|
-
const renderTable = (variables, title) => html20`
|
|
4770
|
-
<h3>${title}</h3>
|
|
4771
|
-
<table>
|
|
4772
|
-
<thead>
|
|
4773
|
-
<tr>
|
|
4774
|
-
<th>Identifier</th>
|
|
4775
|
-
<th>Value</th>
|
|
4776
|
-
<th>Cardinality</th>
|
|
4777
|
-
<th>Base Type</th>
|
|
4778
|
-
<th>Correct Response / Mappings</th>
|
|
4779
|
-
</tr>
|
|
4780
|
-
</thead>
|
|
4781
|
-
<tbody>
|
|
4782
|
-
${variables.map((v) => {
|
|
4783
|
-
const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
|
|
4784
|
-
const mapEntries = v.mapping?.mapEntries?.map((m) => `${m.mapKey}=${m.mappedValue}pt`).join(", ") || "";
|
|
4785
|
-
const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m) => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ") || "";
|
|
4786
|
-
return html20`
|
|
4787
|
-
<tr>
|
|
4788
|
-
<td>${v.identifier}</td>
|
|
4789
|
-
<td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
|
|
4790
|
-
<td>${v.cardinality}</td>
|
|
4791
|
-
<td>${v.baseType}</td>
|
|
4792
|
-
<td>${correctResponse || mapEntries || areaMapEntries}</td>
|
|
4793
|
-
</tr>
|
|
4794
|
-
`;
|
|
4795
|
-
})}
|
|
4796
|
-
</tbody>
|
|
4797
|
-
</table>
|
|
4798
|
-
`;
|
|
4799
|
-
return html20`
|
|
4800
|
-
${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
|
|
4801
|
-
`;
|
|
4802
|
-
}
|
|
4803
|
-
};
|
|
4804
|
-
__decorate21([
|
|
4805
|
-
consume14({ context: computedContext, subscribe: true })
|
|
4806
|
-
], TestPrintVariables.prototype, "computedContext", void 0);
|
|
4807
|
-
|
|
4808
|
-
// ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
|
|
4809
|
-
import { html as html21, LitElement as LitElement22, nothing as nothing3 } from "lit";
|
|
4810
|
-
import { consume as consume15 } from "@lit/context";
|
|
4811
|
-
import { property as property16 } from "lit/decorators.js";
|
|
4812
|
-
var __decorate22 = function(decorators, target, key, desc) {
|
|
4813
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4814
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4815
|
-
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;
|
|
4816
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4817
|
-
};
|
|
4818
|
-
var TestScoringButtons = class extends LitElement22 {
|
|
4819
|
-
createRenderRoot() {
|
|
4820
|
-
return this;
|
|
4821
|
-
}
|
|
4822
|
-
connectedCallback() {
|
|
4823
|
-
super.connectedCallback();
|
|
4824
|
-
const templateElement = this.querySelector("template");
|
|
4825
|
-
if (!templateElement) {
|
|
4826
|
-
this.myTemplate = null;
|
|
4827
|
-
return;
|
|
4828
|
-
}
|
|
4829
|
-
this.myTemplate = prepareTemplate(templateElement);
|
|
4830
|
-
}
|
|
4831
|
-
#changeOutcomeScore(value) {
|
|
4832
|
-
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
4833
|
-
const sectionItems = testPart.sections.flatMap((section) => section.items);
|
|
4834
|
-
const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
|
|
4835
|
-
dispatchPublic(this, "cito-test-update-outcome", {
|
|
4836
|
-
assessmentItemRefId: currentItemIdentifier,
|
|
4837
|
-
outcomeVariableId: "SCORE",
|
|
4838
|
-
value
|
|
4839
|
-
});
|
|
4840
|
-
}
|
|
4841
|
-
render() {
|
|
4842
|
-
const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
4843
|
-
if (!activeItem || !activeItem.variables)
|
|
4844
|
-
return html21``;
|
|
4845
|
-
const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
|
|
4846
|
-
const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
|
|
4847
|
-
const score = scoreOutcome?.value;
|
|
4848
|
-
const disabled = !(scoreOutcome?.externalScored === "human");
|
|
4849
|
-
if (!maxScore || !scoreOutcome)
|
|
4850
|
-
return nothing3;
|
|
4851
|
-
const scores = [...Array(Number(maxScore) + 1).keys()];
|
|
4852
|
-
return html21`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing3}`;
|
|
4853
|
-
}
|
|
4854
|
-
constructor() {
|
|
4855
|
-
super();
|
|
4856
|
-
this.view = "";
|
|
4857
|
-
this.disabled = false;
|
|
4858
|
-
this.myTemplate = null;
|
|
4859
|
-
this.addEventListener("click", (e) => {
|
|
4860
|
-
const target = e.target;
|
|
4861
|
-
const value = parseFloat(target.value);
|
|
4862
|
-
if (target.tagName === "INPUT") {
|
|
4863
|
-
this.#changeOutcomeScore(value);
|
|
4864
|
-
}
|
|
4865
|
-
});
|
|
4866
|
-
}
|
|
4867
|
-
};
|
|
4868
|
-
__decorate22([
|
|
4869
|
-
property16({ type: String, attribute: "view" })
|
|
4870
|
-
], TestScoringButtons.prototype, "view", void 0);
|
|
4871
|
-
__decorate22([
|
|
4872
|
-
property16({ type: Boolean })
|
|
4873
|
-
], TestScoringButtons.prototype, "disabled", void 0);
|
|
4874
|
-
__decorate22([
|
|
4875
|
-
consume15({ context: computedContext, subscribe: true })
|
|
4876
|
-
], TestScoringButtons.prototype, "computedContext", void 0);
|
|
4877
|
-
|
|
4878
|
-
// ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
|
|
4879
|
-
import { consume as consume16 } from "@lit/context";
|
|
4880
|
-
import { html as html22, LitElement as LitElement23 } from "lit";
|
|
4881
|
-
import { property as property17 } from "lit/decorators.js";
|
|
4882
|
-
var __decorate23 = function(decorators, target, key, desc) {
|
|
4883
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4884
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4885
|
-
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;
|
|
4886
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4887
|
-
};
|
|
4888
|
-
var TestScoringFeedback = class extends LitElement23 {
|
|
4889
|
-
constructor() {
|
|
4890
|
-
super(...arguments);
|
|
4891
|
-
this.view = null;
|
|
4892
|
-
}
|
|
4893
|
-
render() {
|
|
4894
|
-
const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
4895
|
-
if (!activeItem || !activeItem.variables)
|
|
4896
|
-
return html22``;
|
|
4897
|
-
if (activeItem["category"] === "dep-informational")
|
|
4898
|
-
return html22`<div>${this.dataset.informational}</div>`;
|
|
4899
|
-
const completionStatus = activeItem?.variables.find((v) => v.identifier === "completionStatus")?.value;
|
|
4900
|
-
const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
|
|
4901
|
-
const score = parseFloat(scoreOutcome?.value);
|
|
4902
|
-
const externalScored = activeItem["externalScored"];
|
|
4903
|
-
const feedbackText = () => {
|
|
4904
|
-
if (completionStatus !== "completed") {
|
|
4905
|
-
return this.dataset.textNoResponse;
|
|
4906
|
-
}
|
|
4907
|
-
if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
|
|
4908
|
-
return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
|
|
4909
|
-
}
|
|
4910
|
-
if (externalScored === "externalMachine") {
|
|
4911
|
-
return Number.isNaN(score) || score === void 0 ? this.dataset.scoreUnknown : `We hebben je antwoord ${score === 0 ? "geen punten" : score == 1 ? "\xE9\xE9n punt" : `${score} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`;
|
|
4912
|
-
}
|
|
4913
|
-
if (externalScored === "human") {
|
|
4914
|
-
return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
|
|
4915
|
-
}
|
|
4916
|
-
return this.dataset.inProgress;
|
|
4917
|
-
};
|
|
4918
|
-
return html22`<div>${feedbackText()}</div>`;
|
|
4919
|
-
}
|
|
4920
|
-
};
|
|
4921
|
-
__decorate23([
|
|
4922
|
-
consume16({ context: computedContext, subscribe: true })
|
|
4923
|
-
], TestScoringFeedback.prototype, "computedContext", void 0);
|
|
4924
|
-
__decorate23([
|
|
4925
|
-
property17({ type: String, attribute: "view" })
|
|
4926
|
-
], TestScoringFeedback.prototype, "view", void 0);
|
|
4927
|
-
|
|
4928
|
-
// ../qti-test/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js
|
|
4929
|
-
import { html as html23, LitElement as LitElement24 } from "lit";
|
|
4930
|
-
import { consume as consume17 } from "@lit/context";
|
|
4931
|
-
var __decorate24 = function(decorators, target, key, desc) {
|
|
4932
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4933
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4934
|
-
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;
|
|
4935
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4936
|
-
};
|
|
4937
|
-
var TestSectionButtonsStamp = class extends LitElement24 {
|
|
4938
|
-
#internals;
|
|
4939
|
-
createRenderRoot() {
|
|
4940
|
-
return this;
|
|
4941
|
-
}
|
|
4942
|
-
constructor() {
|
|
4943
|
-
super();
|
|
4944
|
-
this.#internals = this.attachInternals();
|
|
4945
|
-
this.#internals.ariaLabel = "pagination";
|
|
4946
|
-
}
|
|
4947
|
-
connectedCallback() {
|
|
4948
|
-
super.connectedCallback();
|
|
4949
|
-
const templateElement = this.querySelector("template");
|
|
4950
|
-
this.myTemplate = prepareTemplate(templateElement);
|
|
4951
|
-
}
|
|
4952
|
-
render() {
|
|
4953
|
-
if (!this.computedContext)
|
|
4954
|
-
return html23``;
|
|
4955
|
-
const sections = this.computedContext.testParts.flatMap((testPart) => testPart.sections);
|
|
4956
|
-
return html23` ${sections.map((item) => this.myTemplate({ item }))} `;
|
|
4957
|
-
}
|
|
4958
|
-
};
|
|
4959
|
-
__decorate24([
|
|
4960
|
-
consume17({ context: computedContext, subscribe: true })
|
|
4961
|
-
], TestSectionButtonsStamp.prototype, "computedContext", void 0);
|
|
4962
|
-
|
|
4963
|
-
// ../qti-test/dist/components/test-section-link/test-section-link.js
|
|
4964
|
-
import { css as css13, html as html24, LitElement as LitElement25 } from "lit";
|
|
4965
|
-
import { property as property18 } from "lit/decorators.js";
|
|
4966
|
-
var __decorate25 = function(decorators, target, key, desc) {
|
|
4967
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4968
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4969
|
-
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;
|
|
4970
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4971
|
-
};
|
|
4972
|
-
var TestSectionLink = class extends LitElement25 {
|
|
4009
|
+
// ../qti-test/dist/components/test-submit/test-submit.js
|
|
4010
|
+
import { LitElement as LitElement16 } from "lit";
|
|
4011
|
+
var TestSubmit = class extends LitElement16 {
|
|
4973
4012
|
static {
|
|
4974
|
-
this.styles =
|
|
4975
|
-
:host {
|
|
4976
|
-
${btn};
|
|
4977
|
-
}
|
|
4978
|
-
:host(:hover:not([disabled])) {
|
|
4979
|
-
${btnInteractive};
|
|
4980
|
-
}
|
|
4981
|
-
:host(:focus-visible) {
|
|
4982
|
-
${focusRing};
|
|
4983
|
-
}
|
|
4984
|
-
:host([disabled]) {
|
|
4985
|
-
${dis};
|
|
4986
|
-
}
|
|
4987
|
-
`;
|
|
4988
|
-
}
|
|
4989
|
-
#requestItem(identifier) {
|
|
4990
|
-
dispatchPublic(this, "cito-test-navigate", { type: "section", id: identifier });
|
|
4013
|
+
this.styles = button;
|
|
4991
4014
|
}
|
|
4992
4015
|
constructor() {
|
|
4993
4016
|
super();
|
|
4994
|
-
this.
|
|
4995
|
-
this.addEventListener("click", () => this.#requestItem(this.sectionId));
|
|
4017
|
+
this.addEventListener("click", () => dispatchPublic(this, "qc-test-submit", {}));
|
|
4996
4018
|
}
|
|
4997
4019
|
render() {
|
|
4998
|
-
return
|
|
4020
|
+
return control;
|
|
4999
4021
|
}
|
|
5000
4022
|
};
|
|
5001
|
-
__decorate25([
|
|
5002
|
-
property18({ type: String, attribute: "section-id" })
|
|
5003
|
-
], TestSectionLink.prototype, "sectionId", void 0);
|
|
5004
4023
|
|
|
5005
|
-
// ../qti-test/dist/
|
|
5006
|
-
|
|
5007
|
-
import { property as property19, state as state7 } from "lit/decorators.js";
|
|
5008
|
-
import { consume as consume18 } from "@lit/context";
|
|
5009
|
-
var __decorate26 = function(decorators, target, key, desc) {
|
|
5010
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5011
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5012
|
-
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;
|
|
5013
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5014
|
-
};
|
|
5015
|
-
var TestStamp = class extends LitElement26 {
|
|
5016
|
-
constructor() {
|
|
5017
|
-
super(...arguments);
|
|
5018
|
-
this.debug = false;
|
|
5019
|
-
this.stampContext = {
|
|
5020
|
-
view: "candidate",
|
|
5021
|
-
activeItem: {},
|
|
5022
|
-
activeSection: {
|
|
5023
|
-
items: []
|
|
5024
|
-
},
|
|
5025
|
-
activeTestpart: {
|
|
5026
|
-
items: [],
|
|
5027
|
-
sections: []
|
|
5028
|
-
},
|
|
5029
|
-
test: {}
|
|
5030
|
-
};
|
|
5031
|
-
}
|
|
5032
|
-
createRenderRoot() {
|
|
5033
|
-
return this;
|
|
5034
|
-
}
|
|
5035
|
-
connectedCallback() {
|
|
5036
|
-
super.connectedCallback();
|
|
5037
|
-
const templateElement = this.querySelector("template");
|
|
5038
|
-
if (!templateElement) {
|
|
5039
|
-
this.myTemplate = null;
|
|
5040
|
-
return;
|
|
5041
|
-
}
|
|
5042
|
-
this.myTemplate = prepareTemplate(templateElement);
|
|
5043
|
-
}
|
|
5044
|
-
willUpdate(_changedProperties) {
|
|
5045
|
-
if (!this.computedContext) {
|
|
5046
|
-
return;
|
|
5047
|
-
}
|
|
5048
|
-
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
5049
|
-
const activeSection = activeTestPart?.sections.find((section) => section.active);
|
|
5050
|
-
const activeItem = activeSection?.items.find((item) => item.active);
|
|
5051
|
-
const { variables, ...augmentedItem } = activeItem || {};
|
|
5052
|
-
if (!activeTestPart || !activeSection || !activeItem) {
|
|
5053
|
-
return;
|
|
5054
|
-
}
|
|
5055
|
-
const augmentedTestPart = {
|
|
5056
|
-
...activeTestPart,
|
|
5057
|
-
items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables: variables2, ...rest }) => rest)),
|
|
5058
|
-
sections: activeTestPart.sections.map((section) => ({
|
|
5059
|
-
...section,
|
|
5060
|
-
items: section.items.map(({ variables: variables2, ...rest }) => rest)
|
|
5061
|
-
}))
|
|
5062
|
-
};
|
|
5063
|
-
const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables: variables2, ...rest }) => rest) };
|
|
5064
|
-
const { testParts, ...activeTest } = this.computedContext;
|
|
5065
|
-
this.stampContext = {
|
|
5066
|
-
view: this.computedContext.view,
|
|
5067
|
-
activeItem: augmentedItem,
|
|
5068
|
-
activeSection: augmentedSection,
|
|
5069
|
-
activeTestpart: augmentedTestPart,
|
|
5070
|
-
test: activeTest
|
|
5071
|
-
};
|
|
5072
|
-
this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
|
|
5073
|
-
detail: this.stampContext,
|
|
5074
|
-
bubbles: true
|
|
5075
|
-
}));
|
|
5076
|
-
}
|
|
5077
|
-
render() {
|
|
5078
|
-
return html25` ${this.debug ? html25`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing4}
|
|
5079
|
-
${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
|
|
5080
|
-
}
|
|
5081
|
-
};
|
|
5082
|
-
__decorate26([
|
|
5083
|
-
property19({ type: Boolean, reflect: true })
|
|
5084
|
-
], TestStamp.prototype, "debug", void 0);
|
|
5085
|
-
__decorate26([
|
|
5086
|
-
state7(),
|
|
5087
|
-
consume18({ context: computedContext, subscribe: true })
|
|
5088
|
-
], TestStamp.prototype, "computedContext", void 0);
|
|
5089
|
-
__decorate26([
|
|
5090
|
-
state7()
|
|
5091
|
-
], TestStamp.prototype, "stampContext", void 0);
|
|
5092
|
-
|
|
5093
|
-
// ../qti-test/dist/components/test-view-toggle/test-view.js
|
|
5094
|
-
import { html as html26, LitElement as LitElement27 } from "lit";
|
|
5095
|
-
import { property as property20, state as state8 } from "lit/decorators.js";
|
|
5096
|
-
import { consume as consume19 } from "@lit/context";
|
|
5097
|
-
var __decorate27 = function(decorators, target, key, desc) {
|
|
5098
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5099
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5100
|
-
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;
|
|
5101
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5102
|
-
};
|
|
5103
|
-
var _a;
|
|
5104
|
-
var TestView = class extends LitElement27 {
|
|
5105
|
-
constructor() {
|
|
5106
|
-
super(...arguments);
|
|
5107
|
-
this.label = "view";
|
|
5108
|
-
this._handleViewOptionsChange = () => {
|
|
5109
|
-
this.#updateViewOptions();
|
|
5110
|
-
};
|
|
5111
|
-
this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
|
|
5112
|
-
}
|
|
5113
|
-
static {
|
|
5114
|
-
this.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
|
|
5115
|
-
}
|
|
5116
|
-
connectedCallback() {
|
|
5117
|
-
super.connectedCallback();
|
|
5118
|
-
this.#updateViewOptions();
|
|
5119
|
-
}
|
|
5120
|
-
#updateViewOptions() {
|
|
5121
|
-
if (this.viewOptions) {
|
|
5122
|
-
const options = this.viewOptions.split(",").map((opt) => opt.trim());
|
|
5123
|
-
this._viewOptions = options.filter((opt) => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
|
|
5124
|
-
} else {
|
|
5125
|
-
this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
|
|
5126
|
-
}
|
|
5127
|
-
}
|
|
5128
|
-
_switchView(view) {
|
|
5129
|
-
dispatchPublic(this, "cito-test-switch-view", view);
|
|
5130
|
-
}
|
|
5131
|
-
render() {
|
|
5132
|
-
return html26`
|
|
5133
|
-
<label part="label" for="viewSelect">${this.label}</label>
|
|
5134
|
-
<select
|
|
5135
|
-
part="select"
|
|
5136
|
-
id="viewSelect"
|
|
5137
|
-
@change=${(e) => {
|
|
5138
|
-
const el = e.target;
|
|
5139
|
-
this._switchView(el.value);
|
|
5140
|
-
}}
|
|
5141
|
-
>
|
|
5142
|
-
${this._viewOptions.map((v) => html26`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
|
|
5143
|
-
</select>
|
|
5144
|
-
`;
|
|
5145
|
-
}
|
|
5146
|
-
};
|
|
5147
|
-
_a = TestView;
|
|
5148
|
-
__decorate27([
|
|
5149
|
-
consume19({ context: sessionContext, subscribe: true })
|
|
5150
|
-
], TestView.prototype, "sessionContext", void 0);
|
|
5151
|
-
__decorate27([
|
|
5152
|
-
property20({ type: String })
|
|
5153
|
-
], TestView.prototype, "label", void 0);
|
|
5154
|
-
__decorate27([
|
|
5155
|
-
property20({ type: String, attribute: "view-options" })
|
|
5156
|
-
], TestView.prototype, "viewOptions", void 0);
|
|
5157
|
-
__decorate27([
|
|
5158
|
-
watch("viewOptions", { waitUntilFirstUpdate: true })
|
|
5159
|
-
], TestView.prototype, "_handleViewOptionsChange", void 0);
|
|
5160
|
-
__decorate27([
|
|
5161
|
-
state8()
|
|
5162
|
-
], TestView.prototype, "_viewOptions", void 0);
|
|
5163
|
-
|
|
5164
|
-
// ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
|
|
5165
|
-
import { consume as consume20 } from "@lit/context";
|
|
5166
|
-
import { html as html27, LitElement as LitElement28, nothing as nothing5 } from "lit";
|
|
5167
|
-
var __decorate28 = function(decorators, target, key, desc) {
|
|
5168
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5169
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5170
|
-
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;
|
|
5171
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5172
|
-
};
|
|
5173
|
-
var TestViewToggle = class extends LitElement28 {
|
|
5174
|
-
createRenderRoot() {
|
|
5175
|
-
return this;
|
|
5176
|
-
}
|
|
5177
|
-
connectedCallback() {
|
|
5178
|
-
super.connectedCallback();
|
|
5179
|
-
const templateElement = this.querySelector("template");
|
|
5180
|
-
if (!templateElement) {
|
|
5181
|
-
this.myTemplate = null;
|
|
5182
|
-
return;
|
|
5183
|
-
}
|
|
5184
|
-
this.myTemplate = prepareTemplate(templateElement);
|
|
5185
|
-
}
|
|
5186
|
-
_switchView(view) {
|
|
5187
|
-
dispatchPublic(this, "cito-test-switch-view", view);
|
|
5188
|
-
}
|
|
5189
|
-
firstUpdated(_changedProperties) {
|
|
5190
|
-
this.addEventListener("click", () => {
|
|
5191
|
-
if (this.sessionContext?.view === "scorer") {
|
|
5192
|
-
this._switchView("candidate");
|
|
5193
|
-
} else {
|
|
5194
|
-
this._switchView("scorer");
|
|
5195
|
-
}
|
|
5196
|
-
});
|
|
5197
|
-
}
|
|
5198
|
-
render() {
|
|
5199
|
-
return html27`${this.myTemplate ? this.myTemplate({
|
|
5200
|
-
view: this.sessionContext?.view
|
|
5201
|
-
}) : nothing5}`;
|
|
5202
|
-
}
|
|
5203
|
-
};
|
|
5204
|
-
__decorate28([
|
|
5205
|
-
consume20({ context: sessionContext, subscribe: true })
|
|
5206
|
-
], TestViewToggle.prototype, "sessionContext", void 0);
|
|
4024
|
+
// ../qti-test/dist/plugins/elements.js
|
|
4025
|
+
var pluginElements = [{ tag: "test-submit", ctor: TestSubmit }];
|
|
5207
4026
|
|
|
5208
4027
|
// ../qti-test/dist/elements.js
|
|
5209
4028
|
var qtiTestElements = [
|
|
@@ -5212,6 +4031,7 @@ var qtiTestElements = [
|
|
|
5212
4031
|
{ tag: "qti-assessment-test", ctor: QtiAssessmentTest },
|
|
5213
4032
|
{ tag: "qti-branch-rule", ctor: QtiBranchRule },
|
|
5214
4033
|
{ tag: "qti-item-session-control", ctor: QtiItemSessionControl },
|
|
4034
|
+
{ tag: "qti-number-presented", ctor: QtiNumberPresented },
|
|
5215
4035
|
{ tag: "qti-number-selected", ctor: QtiNumberSelected },
|
|
5216
4036
|
{ tag: "qti-outcome-processing", ctor: QtiOutcomeProcessing },
|
|
5217
4037
|
{ tag: "qti-pre-condition", ctor: QtiPreCondition },
|
|
@@ -5219,31 +4039,12 @@ var qtiTestElements = [
|
|
|
5219
4039
|
{ tag: "qti-test-feedback", ctor: QtiTestFeedback },
|
|
5220
4040
|
{ tag: "qti-test-part", ctor: QtiTestPart },
|
|
5221
4041
|
{ tag: "qti-test-variables", ctor: QtiTestVariables },
|
|
5222
|
-
{ tag: "test-check-item", ctor: TestCheckItem },
|
|
5223
4042
|
{ tag: "test-container", ctor: TestContainer },
|
|
5224
4043
|
{ tag: "test-end-attempt", ctor: TestEndAttempt },
|
|
5225
|
-
{ tag: "test-item-link", ctor: TestItemLink },
|
|
5226
|
-
{ tag: "test-item-to-speech", ctor: TestItemToSpeech },
|
|
5227
4044
|
{ tag: "test-navigation", ctor: TestNavigation },
|
|
5228
4045
|
{ tag: "test-next", ctor: TestNext },
|
|
5229
|
-
{ tag: "test-paging-buttons-stamp", ctor: TestPagingButtonsStamp },
|
|
5230
4046
|
{ tag: "test-prev", ctor: TestPrev },
|
|
5231
|
-
|
|
5232
|
-
{ tag: "test-print-item-variables", ctor: TestPrintVariables },
|
|
5233
|
-
{ tag: "test-scoring-buttons", ctor: TestScoringButtons },
|
|
5234
|
-
{ tag: "test-scoring-feedback", ctor: TestScoringFeedback },
|
|
5235
|
-
{ tag: "test-section-buttons-stamp", ctor: TestSectionButtonsStamp },
|
|
5236
|
-
{ tag: "test-section-link", ctor: TestSectionLink },
|
|
5237
|
-
{ tag: "test-stamp", ctor: TestStamp },
|
|
5238
|
-
{ tag: "test-tts-next", ctor: TestTtsNext },
|
|
5239
|
-
{ tag: "test-tts-pause", ctor: TestTtsPause },
|
|
5240
|
-
{ tag: "test-tts-pick", ctor: TestTtsPick },
|
|
5241
|
-
{ tag: "test-tts-play", ctor: TestTtsPlay },
|
|
5242
|
-
{ tag: "test-tts-prev", ctor: TestTtsPrev },
|
|
5243
|
-
{ tag: "test-tts-resume", ctor: TestTtsResume },
|
|
5244
|
-
{ tag: "test-tts-stop", ctor: TestTtsStop },
|
|
5245
|
-
{ tag: "test-view", ctor: TestView },
|
|
5246
|
-
{ tag: "test-view-toggle", ctor: TestViewToggle }
|
|
4047
|
+
...pluginElements
|
|
5247
4048
|
];
|
|
5248
4049
|
|
|
5249
4050
|
export {
|
|
@@ -5252,6 +4053,7 @@ export {
|
|
|
5252
4053
|
QtiAssessmentTest,
|
|
5253
4054
|
QtiBranchRule,
|
|
5254
4055
|
QtiItemSessionControl,
|
|
4056
|
+
QtiNumberPresented,
|
|
5255
4057
|
QtiNumberSelected,
|
|
5256
4058
|
QtiPreCondition,
|
|
5257
4059
|
QtiOutcomeProcessing,
|
|
@@ -5262,32 +4064,13 @@ export {
|
|
|
5262
4064
|
QtiTestVariablesExpression,
|
|
5263
4065
|
QTI_TEST_STATE_VERSION,
|
|
5264
4066
|
QtiTest,
|
|
5265
|
-
TestCheckItem,
|
|
5266
4067
|
TestContainer,
|
|
5267
4068
|
TestEndAttempt,
|
|
5268
|
-
TestItemLink,
|
|
5269
|
-
ttsContext,
|
|
5270
|
-
TestItemToSpeech,
|
|
5271
|
-
TestTtsPlay,
|
|
5272
|
-
TestTtsPause,
|
|
5273
|
-
TestTtsResume,
|
|
5274
|
-
TestTtsStop,
|
|
5275
|
-
TestTtsPrev,
|
|
5276
|
-
TestTtsNext,
|
|
5277
|
-
TestTtsPick,
|
|
5278
4069
|
TestNavigation,
|
|
5279
4070
|
TestNext,
|
|
5280
|
-
TestPagingButtonsStamp,
|
|
5281
4071
|
TestPrev,
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
TestScoringButtons,
|
|
5285
|
-
TestScoringFeedback,
|
|
5286
|
-
TestSectionButtonsStamp,
|
|
5287
|
-
TestSectionLink,
|
|
5288
|
-
TestStamp,
|
|
5289
|
-
TestView,
|
|
5290
|
-
TestViewToggle,
|
|
4072
|
+
TestSubmit,
|
|
4073
|
+
pluginElements,
|
|
5291
4074
|
qtiTestElements
|
|
5292
4075
|
};
|
|
5293
4076
|
/*! Bundled license information:
|
|
@@ -5302,4 +4085,4 @@ export {
|
|
|
5302
4085
|
* Portions Copyright (c) 2013, the Dart project authors.
|
|
5303
4086
|
*)
|
|
5304
4087
|
*/
|
|
5305
|
-
//# sourceMappingURL=chunk-
|
|
4088
|
+
//# sourceMappingURL=chunk-TB2OI3ED.js.map
|