@citolab/qti-components 10.0.0-next.2 → 10.0.0-next.20

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.
Files changed (94) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +4334 -2688
  3. package/dist/base.d.ts +39 -13
  4. package/dist/base.js +14 -1
  5. package/dist/{chunk-RU6332MD.js → chunk-2A52V5TQ.js} +4 -4
  6. package/dist/{chunk-MI7774NV.js → chunk-5BP2A7BI.js} +2 -2
  7. package/dist/{chunk-35WWWFS6.js → chunk-DAESCCLR.js} +2 -2
  8. package/dist/chunk-DJ7PB252.js +7 -0
  9. package/dist/chunk-DJ7PB252.js.map +1 -0
  10. package/dist/{chunk-3ZNECUPV.js → chunk-GJWA6LLT.js} +2 -2
  11. package/dist/{chunk-TDWJ6WZA.js → chunk-GPC53O7P.js} +166 -10
  12. package/dist/chunk-GPC53O7P.js.map +1 -0
  13. package/dist/{chunk-6U3YPHXU.js → chunk-H6DO5UHC.js} +277 -154
  14. package/dist/chunk-H6DO5UHC.js.map +1 -0
  15. package/dist/chunk-J6VX4N7M.js +197 -0
  16. package/dist/chunk-J6VX4N7M.js.map +1 -0
  17. package/dist/{chunk-FD4AB6TM.js → chunk-KQ2LED4X.js} +2 -2
  18. package/dist/{chunk-6K3QWJHH.js → chunk-LPYZVKHX.js} +48 -7
  19. package/dist/chunk-LPYZVKHX.js.map +1 -0
  20. package/dist/{chunk-K3VKQ6QF.js → chunk-ORQFZNJW.js} +614 -1847
  21. package/dist/chunk-ORQFZNJW.js.map +1 -0
  22. package/dist/chunk-PZ5AY32C.js +10 -0
  23. package/dist/chunk-PZ5AY32C.js.map +1 -0
  24. package/dist/{chunk-GBZNFSFY.js → chunk-TSJGL6FI.js} +2 -2
  25. package/dist/{chunk-RSMYGGQK.js → chunk-TZCOXFPB.js} +1590 -610
  26. package/dist/chunk-TZCOXFPB.js.map +1 -0
  27. package/dist/chunk-UCXLDQYA.js +56 -0
  28. package/dist/chunk-UCXLDQYA.js.map +1 -0
  29. package/dist/chunk-WWY2H2YO.js +7 -0
  30. package/dist/chunk-WWY2H2YO.js.map +1 -0
  31. package/dist/{chunk-LFVPS7KB.js → chunk-XWRZP2RM.js} +2 -2
  32. package/dist/{chunk-2KP5UU5A.js → chunk-Y6Q3F2S7.js} +117 -92
  33. package/dist/chunk-Y6Q3F2S7.js.map +1 -0
  34. package/dist/{chunk-TLAVOBEM.js → chunk-ZRORBAHB.js} +122 -3
  35. package/dist/chunk-ZRORBAHB.js.map +1 -0
  36. package/dist/computed.types.d-6Ht-HNRx.d.ts +80 -0
  37. package/dist/{config.context.d-BvU9r-Mg.d.ts → config.context.d-Dm11aAuw.d.ts} +21 -3
  38. package/dist/corrections.d.ts +137 -24
  39. package/dist/corrections.js +12 -12
  40. package/dist/corrections.js.map +1 -1
  41. package/dist/elements.d.ts +66 -73
  42. package/dist/elements.js +9 -6
  43. package/dist/index.d.ts +21 -17
  44. package/dist/index.js +47 -61
  45. package/dist/interactions.d.ts +98 -19
  46. package/dist/interactions.js +8 -3
  47. package/dist/item.css +1948 -1946
  48. package/dist/item.d.ts +8 -6
  49. package/dist/item.js +6 -5
  50. package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
  51. package/dist/loader.d.ts +5 -3
  52. package/dist/loader.js +3 -2
  53. package/dist/processing.d.ts +19 -7
  54. package/dist/processing.js +4 -3
  55. package/dist/public-events.d-3dGip9pd.d.ts +105 -0
  56. package/dist/qti-components-jsx.d.ts +1780 -1727
  57. package/dist/{qti-condition-expression.d-VJH6cWxf.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
  58. package/dist/{qti-expression.d-BPxEp8HU.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
  59. package/dist/{qti-feedback.d-wMYNVkkj.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +8 -1
  60. package/dist/{qti-item.d-DgC1AQbY.d.ts → qti-item.d-CxP6KtCH.d.ts} +3 -2
  61. package/dist/{qti-rule-base.d-Bdzg8eGH.d.ts → qti-rule-base.d-CeKP0Ooi.d.ts} +2 -2
  62. package/dist/qti-test-state-CF9S8X9C.d.ts +68 -0
  63. package/dist/qti-test-state.d-D8Q89RzZ.d.ts +57 -0
  64. package/dist/{qti-test.d-DkpBNcsv.d.ts → qti-test.d-sskv-dEN.d.ts} +87 -485
  65. package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-m0EFv9no.d.ts} +221 -73
  66. package/dist/{qti-transform-test.d-BL7GGFJj.d.ts → qti-transform-test.d-Bb9vnLzP.d.ts} +1 -0
  67. package/dist/{interaction.d-g6XG0T0Z.d.ts → record.d-N1Bq7e1f.d.ts} +67 -4
  68. package/dist/{session.context.d-D5080LVx.d.ts → session.context.d-9gRdGK4T.d.ts} +7 -1
  69. package/dist/test-plugin-api.d.ts +134 -0
  70. package/dist/test-plugin-api.js +19 -0
  71. package/dist/test-plugin-api.js.map +1 -0
  72. package/dist/test.d.ts +26 -57
  73. package/dist/test.js +19 -48
  74. package/dist/transformers.d.ts +1 -1
  75. package/dist/transformers.js +2 -1
  76. package/dist/{item.types.d-B55QkJ92.d.ts → variables.d-DWHlTszN.d.ts} +8 -24
  77. package/package.json +16 -11
  78. package/dist/chunk-2KP5UU5A.js.map +0 -1
  79. package/dist/chunk-6K3QWJHH.js.map +0 -1
  80. package/dist/chunk-6U3YPHXU.js.map +0 -1
  81. package/dist/chunk-K3VKQ6QF.js.map +0 -1
  82. package/dist/chunk-RSMYGGQK.js.map +0 -1
  83. package/dist/chunk-TDWJ6WZA.js.map +0 -1
  84. package/dist/chunk-TLAVOBEM.js.map +0 -1
  85. package/dist/chunk-ZP6QQYSU.js +0 -7
  86. package/dist/chunk-ZP6QQYSU.js.map +0 -1
  87. package/dist/computed.types.d-gJrBeUMG.d.ts +0 -42
  88. /package/dist/{chunk-RU6332MD.js.map → chunk-2A52V5TQ.js.map} +0 -0
  89. /package/dist/{chunk-MI7774NV.js.map → chunk-5BP2A7BI.js.map} +0 -0
  90. /package/dist/{chunk-35WWWFS6.js.map → chunk-DAESCCLR.js.map} +0 -0
  91. /package/dist/{chunk-3ZNECUPV.js.map → chunk-GJWA6LLT.js.map} +0 -0
  92. /package/dist/{chunk-FD4AB6TM.js.map → chunk-KQ2LED4X.js.map} +0 -0
  93. /package/dist/{chunk-GBZNFSFY.js.map → chunk-TSJGL6FI.js.map} +0 -0
  94. /package/dist/{chunk-LFVPS7KB.js.map → chunk-XWRZP2RM.js.map} +0 -0
@@ -1,19 +1,26 @@
1
1
  import {
2
- QtiModalFeedback,
3
- dispatchDeclared,
4
- listenDeclared,
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-6U3YPHXU.js";
13
+ } from "./chunk-UCXLDQYA.js";
7
14
  import {
8
15
  item_css_default
9
- } from "./chunk-ZP6QQYSU.js";
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-TLAVOBEM.js";
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-TDWJ6WZA.js";
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 property21;
646
+ let property15;
640
647
  if (this.left.type === "Getter") {
641
648
  receiver = this.left.receiver.evaluate(scope);
642
- property21 = this.left.name;
649
+ property15 = this.left.name;
643
650
  } else if (this.left.type === "Index") {
644
651
  receiver = this.left.receiver.evaluate(scope);
645
- property21 = this.left.argument.evaluate(scope);
652
+ property15 = this.left.argument.evaluate(scope);
646
653
  } else if (this.left.type === "ID") {
647
654
  receiver = scope;
648
- property21 = this.left.value;
655
+ property15 = this.left.value;
649
656
  }
650
- return receiver === void 0 ? void 0 : receiver[property21] = value;
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, "cito-item-ref-connected", {
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, "cito-test-loaded", 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, "cito-test-loaded", (e) => this.#connectedTest = e.detail);
1548
+ listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
1529
1549
  }
1530
1550
  /**
1531
- * `qti-assessment-test-connected` bubbles *up* from the test element, and this
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,128 @@ 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-test/dist/components/qti-test-feedback/qti-test-feedback.js
1738
+ var __decorate7 = function(decorators, target, key, desc) {
1739
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1740
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1741
+ 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;
1742
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1743
+ };
1607
1744
  var QtiTestFeedback = class extends QtiModalFeedback {
1745
+ constructor() {
1746
+ super(...arguments);
1747
+ this.access = "atEnd";
1748
+ }
1608
1749
  static {
1609
1750
  this.styles = css4`
1610
1751
  :host {
@@ -1612,15 +1753,26 @@ var QtiTestFeedback = class extends QtiModalFeedback {
1612
1753
  }
1613
1754
  `;
1614
1755
  }
1756
+ /**
1757
+ * Whether this feedback applies for a value of its `outcome-identifier`: with `show-hide="show"`
1758
+ * when the value is (or, for a container, holds) its `identifier`; with `hide` when it is not.
1759
+ */
1760
+ matches(value) {
1761
+ const found = Array.isArray(value) ? value.includes(this.identifier) : value != null && value === this.identifier;
1762
+ return this.showHide === "hide" ? !found : found;
1763
+ }
1615
1764
  render() {
1616
1765
  return html7``;
1617
1766
  }
1618
1767
  };
1768
+ __decorate7([
1769
+ property6({ type: String })
1770
+ ], QtiTestFeedback.prototype, "access", void 0);
1619
1771
 
1620
1772
  // ../qti-test/dist/components/qti-test-part/qti-test-part.js
1621
1773
  import { html as html8, LitElement as LitElement8 } from "lit";
1622
- import { property as property6 } from "lit/decorators.js";
1623
- var __decorate6 = function(decorators, target, key, desc) {
1774
+ import { property as property7 } from "lit/decorators.js";
1775
+ var __decorate8 = function(decorators, target, key, desc) {
1624
1776
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1625
1777
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1626
1778
  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 +1808,22 @@ var QtiTestPart = class extends LitElement8 {
1656
1808
  return html8` <slot></slot>`;
1657
1809
  }
1658
1810
  };
1659
- __decorate6([
1660
- property6({ type: String })
1811
+ __decorate8([
1812
+ property7({ type: String })
1661
1813
  ], QtiTestPart.prototype, "identifier", void 0);
1662
- __decorate6([
1663
- property6({ type: String })
1814
+ __decorate8([
1815
+ property7({ type: String })
1664
1816
  ], QtiTestPart.prototype, "class", void 0);
1665
- __decorate6([
1666
- property6({ type: String, attribute: "navigation-mode" })
1817
+ __decorate8([
1818
+ property7({ type: String, attribute: "navigation-mode" })
1667
1819
  ], QtiTestPart.prototype, "navigationMode", void 0);
1668
- __decorate6([
1669
- property6({ type: String, attribute: "submission-mode" })
1820
+ __decorate8([
1821
+ property7({ type: String, attribute: "submission-mode" })
1670
1822
  ], QtiTestPart.prototype, "submissionMode", void 0);
1671
1823
 
1672
1824
  // ../qti-test/dist/components/qti-test-variables/qti-test-variables.js
1673
- import { consume as consume4 } from "@lit/context";
1674
- var __decorate7 = function(decorators, target, key, desc) {
1825
+ import { consume as consume5 } from "@lit/context";
1826
+ var __decorate9 = function(decorators, target, key, desc) {
1675
1827
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1676
1828
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1677
1829
  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 +1833,10 @@ var QtiTestVariables = class extends QtiExpression {
1681
1833
  #connectedTest = null;
1682
1834
  constructor() {
1683
1835
  super();
1684
- listenPublic2(this, "cito-test-loaded", (e) => this.#connectedTest = e.detail);
1836
+ listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
1685
1837
  }
1686
1838
  /**
1687
- * `qti-assessment-test-connected` bubbles *up* from the test element, and this
1839
+ * `qc-test-loaded` bubbles *up* from the test element, and this
1688
1840
  * expression lives inside that test's `qti-outcome-processing` — so the
1689
1841
  * listener above only ever fires for a test handed to us directly (a test
1690
1842
  * harness). Walking up the tree is what resolves the test in a real document.
@@ -1712,8 +1864,8 @@ var QtiTestVariables = class extends QtiExpression {
1712
1864
  return this.getResult();
1713
1865
  }
1714
1866
  };
1715
- __decorate7([
1716
- consume4({ context: testContext, subscribe: true })
1867
+ __decorate9([
1868
+ consume5({ context: testContext, subscribe: true })
1717
1869
  ], QtiTestVariables.prototype, "_testContext", void 0);
1718
1870
  var QtiTestVariablesExpression = class {
1719
1871
  constructor(testContext2, itemVariable, includedItems) {
@@ -1750,7 +1902,7 @@ import { html as html9, LitElement as LitElement10 } from "lit";
1750
1902
  import { state as state2 } from "lit/decorators.js";
1751
1903
 
1752
1904
  // ../qti-test/dist/mixins/test-navigation.mixin.js
1753
- import { property as property7 } from "lit/decorators.js";
1905
+ import { property as property8 } from "lit/decorators.js";
1754
1906
 
1755
1907
  // ../qti-test/dist/internal/item-sequencing.js
1756
1908
  var SECTION = "qti-assessment-section";
@@ -1843,7 +1995,7 @@ function preConditionsPass(itemRef, from) {
1843
1995
  }
1844
1996
 
1845
1997
  // ../qti-test/dist/mixins/test-navigation.mixin.js
1846
- var __decorate8 = function(decorators, target, key, desc) {
1998
+ var __decorate10 = function(decorators, target, key, desc) {
1847
1999
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1848
2000
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1849
2001
  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;
@@ -1882,15 +2034,15 @@ var TestNavigationMixin = (superClass) => {
1882
2034
  navigateTo(type, id) {
1883
2035
  const targetId = id || this._getDefaultNavigationId(type);
1884
2036
  if (targetId) {
1885
- dispatchPublic(this, "cito-test-navigate", { type, id: targetId });
2037
+ dispatchPublic(this, "qc-test-navigate", { type, id: targetId });
1886
2038
  }
1887
2039
  }
1888
2040
  // ===========================================
1889
2041
  // EVENT HANDLER SETUP
1890
2042
  // ===========================================
1891
2043
  _bindEventHandlers() {
1892
- listenPublic2(this, "cito-test-navigate", this._handleNavigationRequest.bind(this));
1893
- listenPublic2(this, "cito-test-loaded", this._handleTestConnected.bind(this));
2044
+ listenPublic2(this, "qc-test-navigate", this._handleNavigationRequest.bind(this));
2045
+ listenPublic2(this, "qc-test-loaded", this._handleTestConnected.bind(this));
1894
2046
  this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
1895
2047
  this.addEventListener("qti-assessment-stimulus-ref-connected", this._handleStimulusRefConnected.bind(this));
1896
2048
  }
@@ -1967,9 +2119,9 @@ var TestNavigationMixin = (superClass) => {
1967
2119
  if (refs[0]?.closest("qti-test-part")?.getAttribute("navigation-mode") === "linear") {
1968
2120
  const first = resolveFirstItem(refs);
1969
2121
  if (first.skipped.length)
1970
- dispatchPublic(this, "cito-test-items-skipped", { ids: first.skipped });
2122
+ dispatchPublic(this, "qc-test-items-skipped", { ids: first.skipped });
1971
2123
  if (first.id === null) {
1972
- dispatchPublic(this, "cito-test-end-reached", {});
2124
+ dispatchPublic(this, "qc-test-end-reached", {});
1973
2125
  return;
1974
2126
  }
1975
2127
  id = first.id;
@@ -2034,8 +2186,8 @@ var TestNavigationMixin = (superClass) => {
2034
2186
  const resolved = this._resolveLinearNext(detail.type, detail.id);
2035
2187
  if (resolved?.id === null) {
2036
2188
  if (resolved.skipped.length)
2037
- dispatchPublic(this, "cito-test-items-skipped", { ids: resolved.skipped });
2038
- dispatchPublic(this, "cito-test-end-reached", {});
2189
+ dispatchPublic(this, "qc-test-items-skipped", { ids: resolved.skipped });
2190
+ dispatchPublic(this, "qc-test-end-reached", {});
2039
2191
  return;
2040
2192
  }
2041
2193
  const target = resolved?.id ?? detail.id;
@@ -2051,7 +2203,7 @@ var TestNavigationMixin = (superClass) => {
2051
2203
  this._activeController = controller;
2052
2204
  await this._executeNavigation(detail.type, target, navigationId, controller);
2053
2205
  if (resolved?.skipped.length && navigationId === this._navigationId && !controller.signal.aborted) {
2054
- dispatchPublic(this, "cito-test-items-skipped", { ids: resolved.skipped });
2206
+ dispatchPublic(this, "qc-test-items-skipped", { ids: resolved.skipped });
2055
2207
  }
2056
2208
  } catch (error) {
2057
2209
  this._handleNavigationError(error, detail.type, target);
@@ -2094,13 +2246,15 @@ var TestNavigationMixin = (superClass) => {
2094
2246
  async _navigateToSection(sectionId, navigationId, controller) {
2095
2247
  const sectionEl = this._findSection(sectionId);
2096
2248
  const navPartId = sectionEl?.closest("qti-test-part")?.identifier;
2249
+ const itemIds = this._getSectionItemIds(sectionId);
2097
2250
  this.sessionContext = {
2098
2251
  ...this.sessionContext,
2099
2252
  navPartId,
2100
2253
  navSectionId: sectionId,
2101
- navItemRefId: null
2254
+ // with navigate="item", the section's first item is the current position, so test-next/test-prev
2255
+ // and item highlights have an item to work from
2256
+ navItemRefId: this.navigate === "item" ? itemIds[0] ?? null : null
2102
2257
  };
2103
- const itemIds = this._getSectionItemIds(sectionId);
2104
2258
  this._resetLoadingState();
2105
2259
  this._loadingState.expectedItems = itemIds.length;
2106
2260
  await this._loadItems(itemIds, navigationId, controller);
@@ -2328,7 +2482,7 @@ var TestNavigationMixin = (superClass) => {
2328
2482
  // EVENT DISPATCHING
2329
2483
  // ===========================================
2330
2484
  _dispatchLoadingStarted(type, id) {
2331
- dispatchPublic(this, "cito-test-navigation-started", { type, id });
2485
+ dispatchPublic(this, "qc-test-navigation-started", { type, id });
2332
2486
  }
2333
2487
  _dispatchLoadingEnded(type, id) {
2334
2488
  this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended", {
@@ -2338,30 +2492,30 @@ var TestNavigationMixin = (superClass) => {
2338
2492
  }));
2339
2493
  }
2340
2494
  _dispatchError(error) {
2341
- dispatchPublic(this, "cito-test-navigation-failed", error);
2495
+ dispatchPublic(this, "qc-test-navigation-failed", error);
2342
2496
  }
2343
- /** The items are in the DOM: tell hosts the new position rendered (`cito-test-navigated`) and which items it holds. */
2497
+ /** The items are in the DOM: tell hosts the new position rendered (`qc-test-navigated`) and which items it holds. */
2344
2498
  _dispatchTestLoaded(results, type, id) {
2345
2499
  requestAnimationFrame(() => {
2346
- dispatchPublic(this, "cito-test-rendered", results.map(({ itemRef }) => ({
2500
+ dispatchPublic(this, "qc-test-rendered", results.map(({ itemRef }) => ({
2347
2501
  identifier: itemRef?.identifier,
2348
2502
  element: itemRef
2349
2503
  })));
2350
- dispatchPublic(this, "cito-test-navigated", { type, id });
2504
+ dispatchPublic(this, "qc-test-navigated", { type, id });
2351
2505
  });
2352
2506
  }
2353
2507
  }
2354
- __decorate8([
2355
- property7({ type: String })
2508
+ __decorate10([
2509
+ property8({ type: String })
2356
2510
  ], TestNavigationClass.prototype, "navigate", void 0);
2357
- __decorate8([
2358
- property7({ type: Number })
2511
+ __decorate10([
2512
+ property8({ type: Number })
2359
2513
  ], TestNavigationClass.prototype, "requestTimeout", void 0);
2360
- __decorate8([
2361
- property7({ attribute: false })
2514
+ __decorate10([
2515
+ property8({ attribute: false })
2362
2516
  ], TestNavigationClass.prototype, "postLoadTransformCallback", void 0);
2363
- __decorate8([
2364
- property7({ attribute: false })
2517
+ __decorate10([
2518
+ property8({ attribute: false })
2365
2519
  ], TestNavigationClass.prototype, "postLoadTestTransformCallback", void 0);
2366
2520
  return TestNavigationClass;
2367
2521
  };
@@ -2372,11 +2526,11 @@ var TestViewMixin = (superClass) => {
2372
2526
  constructor(...args) {
2373
2527
  super(...args);
2374
2528
  this.sessionContext = { ...this.sessionContext, view: "candidate" };
2375
- listenPublic2(this, "cito-test-switch-view", (e) => {
2529
+ listenPublic2(this, "qc-test-switch-view", (e) => {
2376
2530
  this.sessionContext = { ...this.sessionContext, view: e.detail };
2377
2531
  this._updateElementView();
2378
2532
  });
2379
- listenPublic2(this, "cito-test-loaded", () => {
2533
+ listenPublic2(this, "qc-test-loaded", () => {
2380
2534
  this._updateElementView();
2381
2535
  });
2382
2536
  this.addEventListener("qti-assessment-item-connected", (e) => {
@@ -2417,8 +2571,8 @@ var TestViewMixin = (superClass) => {
2417
2571
  // ../qti-test/dist/mixins/test-base.js
2418
2572
  import { provide } from "@lit/context";
2419
2573
  import { LitElement as LitElement9 } from "lit";
2420
- import { property as property8 } from "lit/decorators.js";
2421
- var __decorate9 = function(decorators, target, key, desc) {
2574
+ import { property as property9 } from "lit/decorators.js";
2575
+ var __decorate11 = function(decorators, target, key, desc) {
2422
2576
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2423
2577
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2424
2578
  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 +2598,8 @@ var TestBaseMixin = (superClass) => {
2444
2598
  } else {
2445
2599
  const newVariables = [...assessmentItem.variables];
2446
2600
  for (const variable of itemContext.variables) {
2601
+ if (variable.identifier === "completionStatus" && variable.value === "not_attempted")
2602
+ continue;
2447
2603
  const currentVariable = newVariables.find((v) => v.identifier === variable.identifier);
2448
2604
  if (currentVariable) {
2449
2605
  currentVariable.value = variable.value;
@@ -2452,6 +2608,7 @@ var TestBaseMixin = (superClass) => {
2452
2608
  }
2453
2609
  }
2454
2610
  assessmentItem.variables = newVariables;
2611
+ this.#leaveNotAttempted(identifier, newVariables.find((v) => v.identifier === "completionStatus")?.value);
2455
2612
  if (itemContext.state) {
2456
2613
  assessmentItem.state = itemContext.state;
2457
2614
  }
@@ -2466,12 +2623,12 @@ var TestBaseMixin = (superClass) => {
2466
2623
  * before the item has loaded. To restore a whole session, assign `state` instead.
2467
2624
  *
2468
2625
  * The test context is replaced rather than changed in place, so its consumers update and
2469
- * `qti-state-changed` fires.
2626
+ * `qc-test-state-changed` fires.
2470
2627
  *
2471
2628
  * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.
2472
2629
  * @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.
2473
2630
  */
2474
- updateItemVariables(itemRefID, values, state9) {
2631
+ updateItemVariables(itemRefID, values, state5) {
2475
2632
  this.testContext = {
2476
2633
  ...this.testContext,
2477
2634
  items: this.testContext.items.map((item) => {
@@ -2491,22 +2648,22 @@ var TestBaseMixin = (superClass) => {
2491
2648
  else
2492
2649
  variables.push(updated);
2493
2650
  }
2494
- return { ...item, variables, ...state9 ? { state: { ...state9 } } : {} };
2651
+ return { ...item, variables, ...state5 ? { state: { ...state5 } } : {} };
2495
2652
  })
2496
2653
  };
2497
2654
  const assessmentItem = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(itemRefID)}"]`)?.assessmentItem;
2498
2655
  if (!assessmentItem)
2499
2656
  return;
2500
2657
  assessmentItem.variables = [...this.testContext.items.find((i) => i.identifier === itemRefID)?.variables ?? []];
2501
- if (state9)
2502
- assessmentItem.state = state9;
2658
+ if (state5)
2659
+ assessmentItem.state = state5;
2503
2660
  }
2504
2661
  _initializeEventListeners() {
2505
2662
  this.addEventListener("qti-testdoc-loaded", () => {
2506
2663
  this.testContext = INITIAL_TEST_CONTEXT;
2507
2664
  this.sessionContext = INITIAL_SESSION_CONTEXT;
2508
2665
  });
2509
- listenPublic2(this, "cito-test-loaded", (e) => {
2666
+ listenPublic2(this, "qc-test-loaded", (e) => {
2510
2667
  this._testElement = e.detail;
2511
2668
  const items = Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map((itemRef) => {
2512
2669
  return {
@@ -2536,7 +2693,7 @@ var TestBaseMixin = (superClass) => {
2536
2693
  this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state, e.detail.itemContext.valid);
2537
2694
  });
2538
2695
  }
2539
- _updateItemVariablesInTestContext(identifier, variables, state9, valid) {
2696
+ _updateItemVariablesInTestContext(identifier, variables, state5, valid) {
2540
2697
  this.testContext = {
2541
2698
  ...this.testContext,
2542
2699
  // Spread existing test context properties
@@ -2551,20 +2708,36 @@ var TestBaseMixin = (superClass) => {
2551
2708
  const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
2552
2709
  return matchingVariable ? { ...matchingVariable, ...variable } : variable;
2553
2710
  }),
2554
- ...state9 !== void 0 ? { state: state9 ? { ...state9 } : void 0 } : {},
2711
+ ...state5 !== void 0 ? { state: state5 ? { ...state5 } : void 0 } : {},
2555
2712
  ...valid !== void 0 ? { valid } : {}
2556
2713
  };
2557
2714
  })
2558
2715
  };
2559
2716
  this.dispatchEvent(new CustomEvent("qti-test-context-updated", { detail: this.testContext, bubbles: false, composed: false }));
2560
2717
  }
2718
+ /** Write the presented item's own status over a `not_attempted` the test context still holds for it. */
2719
+ #leaveNotAttempted(identifier, status) {
2720
+ if (typeof status !== "string" || status === "not_attempted")
2721
+ return;
2722
+ const item = this.testContext.items.find((i) => i.identifier === identifier);
2723
+ const current = item?.variables.find((v) => v.identifier === "completionStatus");
2724
+ if (current?.value !== "not_attempted")
2725
+ return;
2726
+ this.testContext = {
2727
+ ...this.testContext,
2728
+ items: this.testContext.items.map((i) => i.identifier !== identifier ? i : {
2729
+ ...i,
2730
+ variables: i.variables.map((v) => v.identifier === "completionStatus" ? { ...v, value: status } : v)
2731
+ })
2732
+ };
2733
+ }
2561
2734
  }
2562
- __decorate9([
2563
- property8({ attribute: false, type: Object }),
2735
+ __decorate11([
2736
+ property9({ attribute: false, type: Object }),
2564
2737
  provide({ context: testContext })
2565
2738
  ], TestBaseClass.prototype, "testContext", void 0);
2566
- __decorate9([
2567
- property8({ attribute: false, type: Object }),
2739
+ __decorate11([
2740
+ property9({ attribute: false, type: Object }),
2568
2741
  provide({ context: sessionContext })
2569
2742
  ], TestBaseClass.prototype, "sessionContext", void 0);
2570
2743
  return TestBaseClass;
@@ -2575,8 +2748,8 @@ var TestBase = class extends TestBaseMixin(LitElement9) {
2575
2748
  // ../qti-test/dist/mixins/test-state.mixin.js
2576
2749
  var copy = (value) => Array.isArray(value) ? [...value] : value ?? null;
2577
2750
  var isQtiTestState = (value) => {
2578
- const state9 = value;
2579
- return state9?.version === QTI_TEST_STATE_VERSION && Array.isArray(state9.test?.items) && Array.isArray(state9.test?.outcomes) && typeof state9.session === "object" && state9.session !== null;
2751
+ const state5 = value;
2752
+ return state5?.version === QTI_TEST_STATE_VERSION && Array.isArray(state5.test?.items) && Array.isArray(state5.test?.outcomes) && typeof state5.session === "object" && state5.session !== null;
2580
2753
  };
2581
2754
  var toState = (test, session) => ({
2582
2755
  version: QTI_TEST_STATE_VERSION,
@@ -2593,6 +2766,7 @@ var toState = (test, session) => ({
2593
2766
  outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
2594
2767
  },
2595
2768
  session: {
2769
+ ...session?.plugins && Object.keys(session.plugins).length > 0 ? { plugins: { ...session.plugins } } : {},
2596
2770
  ...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
2597
2771
  ...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
2598
2772
  ...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
@@ -2615,7 +2789,8 @@ var TestStateMixin = (superClass) => {
2615
2789
  this.#ready = false;
2616
2790
  this.#lastEmitted = null;
2617
2791
  });
2618
- listenPublic2(this, "cito-test-loaded", () => {
2792
+ listenPublic2(this, "qc-test-update-plugin-state", ({ detail }) => this.#updatePluginState(detail));
2793
+ listenPublic2(this, "qc-test-loaded", () => {
2619
2794
  if (this.#pending) {
2620
2795
  this.#apply(this.#pending);
2621
2796
  this.#pending = null;
@@ -2623,6 +2798,22 @@ var TestStateMixin = (superClass) => {
2623
2798
  this.#ready = true;
2624
2799
  });
2625
2800
  }
2801
+ /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */
2802
+ #updatePluginState({ plugin, value }) {
2803
+ if (typeof plugin !== "string" || plugin === "")
2804
+ return;
2805
+ const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};
2806
+ let next = others;
2807
+ if (value !== null && value !== void 0) {
2808
+ try {
2809
+ next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };
2810
+ } catch {
2811
+ console.warn(`[qti-test] Ignoring plugin state for "${plugin}": it is not JSON.`);
2812
+ return;
2813
+ }
2814
+ }
2815
+ this.sessionContext = { ...this.sessionContext, plugins: next };
2816
+ }
2626
2817
  get state() {
2627
2818
  return toState(this.testContext, this.sessionContext);
2628
2819
  }
@@ -2648,22 +2839,26 @@ var TestStateMixin = (superClass) => {
2648
2839
  super.updated(changed);
2649
2840
  if (!this.#ready || !(changed.has("testContext") || changed.has("sessionContext")))
2650
2841
  return;
2651
- const state9 = this.state;
2652
- const serialized = JSON.stringify(state9);
2842
+ const state5 = this.state;
2843
+ const serialized = JSON.stringify(state5);
2653
2844
  if (serialized === this.#lastEmitted)
2654
2845
  return;
2655
2846
  this.#lastEmitted = serialized;
2656
- dispatchPublic(this, "cito-test-state-changed", state9);
2847
+ dispatchPublic(this, "qc-test-state-changed", state5);
2657
2848
  }
2658
- #apply(state9) {
2659
- for (const saved of state9.test.items)
2849
+ #apply(state5) {
2850
+ for (const saved of state5.test.items)
2660
2851
  this.updateItemVariables(saved.identifier, saved.variables, saved.state);
2661
- const savedOutcomes = new Map(state9.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
2852
+ const savedOutcomes = new Map(state5.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
2662
2853
  this.testContext = {
2663
2854
  ...this.testContext,
2664
2855
  testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
2665
2856
  };
2666
- this.sessionContext = { ...this.sessionContext, ...this.#validSession(state9.session) };
2857
+ this.sessionContext = {
2858
+ ...this.sessionContext,
2859
+ ...this.#validSession(state5.session),
2860
+ plugins: state5.session.plugins && typeof state5.session.plugins === "object" ? { ...state5.session.plugins } : {}
2861
+ };
2667
2862
  }
2668
2863
  /** A stored position may point at an item or section a revised test no longer has. */
2669
2864
  #validSession(session) {
@@ -2675,7 +2870,7 @@ var TestStateMixin = (superClass) => {
2675
2870
  };
2676
2871
  }
2677
2872
  #requestNavigation(type, id) {
2678
- dispatchPublic(this, "cito-test-navigate", { type, id });
2873
+ dispatchPublic(this, "qc-test-navigate", { type, id });
2679
2874
  }
2680
2875
  }
2681
2876
  return TestStateClass;
@@ -2693,6 +2888,7 @@ var TestProcessingMixin = (superClass) => {
2693
2888
  };
2694
2889
  e.stopPropagation();
2695
2890
  });
2891
+ listenPublic2(this, "qc-test-submit", () => this.submit());
2696
2892
  this.addEventListener("qti-set-outcome-value", (e) => {
2697
2893
  const { outcomeIdentifier, value } = e.detail;
2698
2894
  this.updateOutcomeVariable(outcomeIdentifier, value);
@@ -2703,9 +2899,35 @@ var TestProcessingMixin = (superClass) => {
2703
2899
  const outcomeProcessor = (this._testElement ?? this).querySelector("qti-outcome-processing");
2704
2900
  if (!outcomeProcessor)
2705
2901
  return false;
2706
- outcomeProcessor?.process();
2902
+ this.testContext = {
2903
+ ...this.testContext,
2904
+ testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => ({
2905
+ ...v,
2906
+ value: v.defaultValue ?? null
2907
+ }))
2908
+ };
2909
+ outcomeProcessor.process();
2910
+ return true;
2911
+ }
2912
+ /**
2913
+ * Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with
2914
+ * `qc-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.
2915
+ */
2916
+ submit() {
2917
+ if (!this.outcomeProcessing())
2918
+ return false;
2919
+ dispatchPublic(this, "qc-test-submitted", {});
2707
2920
  return true;
2708
2921
  }
2922
+ /**
2923
+ * The `qti-test-feedback` elements that apply now, read from the test outcomes: run
2924
+ * `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to
2925
+ * while it runs (`during`); without it, both.
2926
+ */
2927
+ getTestFeedback(access) {
2928
+ const feedback = Array.from((this._testElement ?? this).querySelectorAll("qti-test-feedback") ?? []);
2929
+ return feedback.filter((fb) => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value));
2930
+ }
2709
2931
  /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */
2710
2932
  updateOutcomeVariable(identifier, value) {
2711
2933
  const outcomeVariable = this.getOutcome(identifier);
@@ -2737,7 +2959,7 @@ var TestProcessingMixin = (superClass) => {
2737
2959
  };
2738
2960
 
2739
2961
  // ../qti-test/dist/components/qti-test/qti-test.js
2740
- var __decorate10 = function(decorators, target, key, desc) {
2962
+ var __decorate12 = function(decorators, target, key, desc) {
2741
2963
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2742
2964
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2743
2965
  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 +2993,27 @@ var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixi
2771
2993
  return html9`<slot></slot>`;
2772
2994
  }
2773
2995
  };
2774
- __decorate10([
2996
+ __decorate12([
2775
2997
  state2(),
2776
2998
  provide2({ context: configContext })
2777
2999
  ], QtiTest.prototype, "configContext", void 0);
2778
- __decorate10([
3000
+ __decorate12([
2779
3001
  state2(),
2780
3002
  provide2({ context: qtiContext })
2781
3003
  ], QtiTest.prototype, "qtiContext", void 0);
2782
3004
 
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
3005
  // ../qti-test/dist/components/test-container/test-container.js
2872
3006
  import { consume as consume6 } from "@lit/context";
2873
- import { LitElement as LitElement12, html as html11 } from "lit";
2874
- import { property as property9, state as state3 } from "lit/decorators.js";
3007
+ import { LitElement as LitElement11, html as html10 } from "lit";
3008
+ import { property as property10, state as state3 } from "lit/decorators.js";
2875
3009
  import { until } from "lit/directives/until.js";
2876
- var __decorate12 = function(decorators, target, key, desc) {
3010
+ var __decorate13 = function(decorators, target, key, desc) {
2877
3011
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2878
3012
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2879
3013
  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
3014
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2881
3015
  };
2882
- var TestContainer = class extends LitElement12 {
3016
+ var TestContainer = class extends LitElement11 {
2883
3017
  constructor() {
2884
3018
  super(...arguments);
2885
3019
  this.customElementRegistry = null;
@@ -2928,7 +3062,7 @@ var TestContainer = class extends LitElement12 {
2928
3062
  * Assign a new test document and announce it.
2929
3063
  *
2930
3064
  * The announcement has to happen here rather than on
2931
- * `qti-assessment-test-connected`, because by then the new document's
3065
+ * `qc-test-loaded`, because by then the new document's
2932
3066
  * children have already connected and registered themselves — a host that
2933
3067
  * resets its context on that event throws those registrations away. Lit's
2934
3068
  * re-render is async, so a handler running now still gets in before any child
@@ -2964,7 +3098,7 @@ var TestContainer = class extends LitElement12 {
2964
3098
  }
2965
3099
  #initializeTemplateContent() {
2966
3100
  const template = this.querySelector("template");
2967
- this.#templateContent = template ? template.content : html11``;
3101
+ this.#templateContent = template ? template.content : html10``;
2968
3102
  }
2969
3103
  #applyStyles() {
2970
3104
  const sheet = new CSSStyleSheet();
@@ -2972,96 +3106,96 @@ var TestContainer = class extends LitElement12 {
2972
3106
  this.shadowRoot.adoptedStyleSheets = [sheet];
2973
3107
  }
2974
3108
  render() {
2975
- return html11`
3109
+ return html10`
2976
3110
  ${this.#templateContent}
2977
3111
  <slot></slot>
2978
- ${until(this.testDoc, html11`<span>Loading...</span>`)}
3112
+ ${until(this.testDoc, html10`<span>Loading...</span>`)}
2979
3113
  `;
2980
3114
  }
2981
3115
  };
2982
- __decorate12([
2983
- property9({ attribute: false })
3116
+ __decorate13([
3117
+ property10({ attribute: false })
2984
3118
  ], TestContainer.prototype, "customElementRegistry", void 0);
2985
- __decorate12([
2986
- property9({ type: String, attribute: "test-url" })
3119
+ __decorate13([
3120
+ property10({ type: String, attribute: "test-url" })
2987
3121
  ], TestContainer.prototype, "testURL", void 0);
2988
- __decorate12([
3122
+ __decorate13([
2989
3123
  state3()
2990
3124
  ], TestContainer.prototype, "testDoc", void 0);
2991
- __decorate12([
3125
+ __decorate13([
2992
3126
  state3()
2993
3127
  ], TestContainer.prototype, "testXML", void 0);
2994
- __decorate12([
3128
+ __decorate13([
2995
3129
  consume6({ context: testHostContext, subscribe: true })
2996
3130
  ], TestContainer.prototype, "testHost", void 0);
2997
- __decorate12([
3131
+ __decorate13([
2998
3132
  state3(),
2999
3133
  consume6({ context: qtiContext, subscribe: true })
3000
3134
  ], TestContainer.prototype, "qtiContext", void 0);
3001
- __decorate12([
3135
+ __decorate13([
3002
3136
  watch("testURL", { waitUntilFirstUpdate: true })
3003
3137
  ], TestContainer.prototype, "handleTestURLChange", null);
3004
- __decorate12([
3138
+ __decorate13([
3005
3139
  watch("testXML", { waitUntilFirstUpdate: true })
3006
3140
  ], TestContainer.prototype, "handleTestXMLChange", null);
3007
3141
 
3008
3142
  // ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
3009
- import { css as css7, html as html12, LitElement as LitElement13 } from "lit";
3010
- import { property as property10 } from "lit/decorators.js";
3143
+ import { LitElement as LitElement12 } from "lit";
3144
+ import { property as property11 } from "lit/decorators.js";
3011
3145
  import { consume as consume7 } from "@lit/context";
3012
- var __decorate13 = function(decorators, target, key, desc) {
3146
+ var __decorate14 = function(decorators, target, key, desc) {
3013
3147
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3014
3148
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3015
3149
  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
3150
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3017
3151
  };
3018
- var TestEndAttempt = class extends LitElement13 {
3152
+ var itemRefOf = (element) => {
3153
+ const itemRef = element.closest("qti-assessment-item-ref");
3154
+ if (itemRef)
3155
+ return itemRef.getAttribute("identifier") ?? void 0;
3156
+ const root = element.getRootNode();
3157
+ return root instanceof ShadowRoot ? itemRefOf(root.host) : void 0;
3158
+ };
3159
+ var TestEndAttempt = class extends LitElement12 {
3019
3160
  _handleTestElementChange(_oldValue, newValue) {
3020
3161
  if (newValue) {
3021
3162
  this.requestUpdate();
3022
3163
  }
3023
3164
  }
3024
3165
  static {
3025
- this.styles = css7`
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
- `;
3166
+ this.styles = button;
3039
3167
  }
3040
3168
  constructor() {
3041
3169
  super();
3042
3170
  this._internalDisabled = false;
3171
+ this.requireAnswer = false;
3043
3172
  this.addEventListener("click", (e) => {
3044
3173
  e.preventDefault();
3045
3174
  if (!this._internalDisabled) {
3046
- dispatchPublic(this, "cito-test-end-attempt", {});
3175
+ const itemId = this.#ownItem;
3176
+ dispatchPublic(this, "qc-test-end-attempt", itemId ? { itemId } : {});
3047
3177
  }
3048
3178
  });
3049
3179
  }
3180
+ /** The item named by `item`, or else the item-ref it is stamped into. */
3181
+ get #ownItem() {
3182
+ return this.item || itemRefOf(this);
3183
+ }
3050
3184
  willUpdate(_changedProperties) {
3051
3185
  this.checkDisabled();
3052
3186
  }
3053
3187
  checkDisabled() {
3054
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3055
- if (!testPart)
3188
+ const testParts = this.computedContext?.testParts;
3189
+ const ownItem = this.#ownItem;
3190
+ const testPart = testParts?.find((testPart2) => testPart2.active);
3191
+ if (!testParts || !ownItem && !testPart)
3056
3192
  return;
3057
- const sectionItems = testPart.sections.flatMap((section) => section.items);
3058
- const itemIndex = sectionItems.findIndex((item) => item.active);
3059
- const activeItem = sectionItems[itemIndex];
3193
+ 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
3194
  if (!activeItem) {
3061
3195
  this._internalDisabled = false;
3062
3196
  return;
3063
3197
  }
3064
- const maxAttempts = activeItem.maxAttempts ?? 1;
3198
+ const maxAttempts = activeItem.sessionControl?.maxAttempts ?? 1;
3065
3199
  const numAttempts = activeItem.numAttempts || 0;
3066
3200
  if (!activeItem.adaptive && activeItem.optimal) {
3067
3201
  this._internalDisabled = true;
@@ -3075,923 +3209,77 @@ var TestEndAttempt = class extends LitElement13 {
3075
3209
  this._internalDisabled = true;
3076
3210
  return;
3077
3211
  }
3078
- if (activeItem.allowSkipping === false) {
3212
+ if (this.requireAnswer || activeItem.sessionControl?.allowSkipping === false) {
3079
3213
  this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;
3080
3214
  } else {
3081
3215
  this._internalDisabled = false;
3082
3216
  }
3083
3217
  }
3084
3218
  render() {
3085
- return html12` <slot></slot> `;
3219
+ return control;
3086
3220
  }
3087
3221
  };
3088
- __decorate13([
3222
+ __decorate14([
3089
3223
  consume7({ context: computedContext, subscribe: true }),
3090
- property10({ attribute: false })
3224
+ property11({ attribute: false })
3091
3225
  ], TestEndAttempt.prototype, "computedContext", void 0);
3092
- __decorate13([
3093
- property10({ type: Boolean, reflect: true, attribute: "disabled" })
3226
+ __decorate14([
3227
+ property11({ type: Boolean, reflect: true, attribute: "disabled" })
3094
3228
  ], TestEndAttempt.prototype, "_internalDisabled", void 0);
3095
- __decorate13([
3229
+ __decorate14([
3230
+ property11({ reflect: true })
3231
+ ], TestEndAttempt.prototype, "item", void 0);
3232
+ __decorate14([
3233
+ property11({ type: Boolean, reflect: true, attribute: "require-answer" })
3234
+ ], TestEndAttempt.prototype, "requireAnswer", void 0);
3235
+ __decorate14([
3096
3236
  watch("computedContext")
3097
3237
  ], TestEndAttempt.prototype, "_handleTestElementChange", null);
3098
3238
 
3099
- // ../qti-test/dist/components/test-item-link/test-item-link.js
3100
- import { css as css8, html as html13, LitElement as LitElement14 } from "lit";
3101
- import { property as property11 } from "lit/decorators.js";
3102
- var __decorate14 = function(decorators, target, key, desc) {
3103
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3104
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3105
- 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;
3106
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3107
- };
3108
- var TestItemLink = class extends LitElement14 {
3109
- static {
3110
- this.styles = css8`
3111
- :host {
3112
- ${btn};
3113
- }
3114
- :host(:hover:not([disabled])) {
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);
3140
-
3141
- // ../qti-test/dist/components/test-item-to-speech/test-item-to-speech.js
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";
3239
+ // ../qti-test/dist/components/test-navigation/test-navigation.js
3240
+ import { ContextConsumer, consume as consume8, provide as provide3 } from "@lit/context";
3241
+ import { html as html11, LitElement as LitElement13 } from "lit";
3144
3242
  import { property as property12, state as state4 } from "lit/decorators.js";
3145
- import { ifDefined } from "lit/directives/if-defined.js";
3243
+
3244
+ // ../qti-test/dist/internal/rendered-markup.js
3245
+ function renderedMarkup(element) {
3246
+ return {
3247
+ nodeType: element.nodeType,
3248
+ localName: element.localName,
3249
+ get childNodes() {
3250
+ return Array.from(element.children, renderedMarkup);
3251
+ },
3252
+ getAttribute: (name) => element.getAttribute(name) ?? (name === "title" ? element.getAttribute("data-title") : null)
3253
+ };
3254
+ }
3255
+
3256
+ // ../qti-test/dist/components/test-navigation/test-navigation.js
3146
3257
  var __decorate15 = function(decorators, target, key, desc) {
3147
3258
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3148
3259
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3149
3260
  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
3261
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3151
3262
  };
3152
- var HIGHLIGHT_ELEMENT = "tts-element";
3153
- var HIGHLIGHT_WORD = "tts-word";
3154
- var highlightSheet = null;
3155
- function getHighlightSheet() {
3156
- if (!highlightSheet) {
3157
- highlightSheet = new CSSStyleSheet();
3158
- highlightSheet.replaceSync(`
3159
- ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
3160
- ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
3161
- `);
3162
- }
3163
- return highlightSheet;
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
- `;
3263
+ var newQtiContext = () => ({
3264
+ QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
3265
+ });
3266
+ var TestNavigation = class extends LitElement13 {
3267
+ /**
3268
+ * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
3269
+ * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
3270
+ * shuffle seed here keeps working. Removed in the next major.
3271
+ *
3272
+ * Written before the navigation is inside a test, it waits and is handed over on connect.
3273
+ */
3274
+ get qtiContext() {
3275
+ return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
3228
3276
  }
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());
3988
- }
3989
- set qtiContext(value) {
3990
- if (!this.#warnedQtiContext) {
3991
- this.#warnedQtiContext = true;
3992
- console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.");
3993
- }
3994
- this.#writeQtiContext(value);
3277
+ set qtiContext(value) {
3278
+ if (!this.#warnedQtiContext) {
3279
+ this.#warnedQtiContext = true;
3280
+ console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.");
3281
+ }
3282
+ this.#writeQtiContext(value);
3995
3283
  }
3996
3284
  #pendingQtiContext;
3997
3285
  #warnedQtiContext;
@@ -4038,12 +3326,16 @@ var TestNavigation = class extends LitElement16 {
4038
3326
  this.configContext = {};
4039
3327
  this.autoScoreItems = false;
4040
3328
  this.#optimality = /* @__PURE__ */ new Map();
4041
- listenPublic2(this, "cito-test-loaded", this.#handleTestConnected.bind(this));
3329
+ this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
3330
+ this.#sectionItems = /* @__PURE__ */ new Map();
3331
+ this.#itemOrder = [];
3332
+ this.#lockedItems = /* @__PURE__ */ new WeakSet();
3333
+ listenPublic2(this, "qc-test-loaded", this.#handleTestConnected.bind(this));
4042
3334
  this.addEventListener("qti-assessment-item-connected", this.#handleItemConnected.bind(this));
4043
- listenPublic(this, "cito-item-response-changed", this.#handleInteractionChanged.bind(this));
3335
+ listenPublic(this, "qc-item-response-changed", this.#handleInteractionChanged.bind(this));
4044
3336
  this.addEventListener("qti-item-context-updated", this.#handleItemContextUpdated.bind(this));
4045
- listenPublic2(this, "cito-test-end-attempt", this.#handleTestEndAttempt.bind(this));
4046
- listenPublic2(this, "cito-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
3337
+ listenPublic2(this, "qc-test-end-attempt", this.#handleTestEndAttempt.bind(this));
3338
+ listenPublic2(this, "qc-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
4047
3339
  }
4048
3340
  /**
4049
3341
  * Latch whether an item reached its optimal outcome whenever it has just ended
@@ -4063,7 +3355,7 @@ var TestNavigation = class extends LitElement16 {
4063
3355
  const computedItem = this.computedItemFor(itemContext.identifier);
4064
3356
  const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
4065
3357
  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));
3358
+ this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.sessionControl?.maxAttempts, computedItem?.adaptive, completionStatus));
4067
3359
  }
4068
3360
  /**
4069
3361
  * Extension point for presentation packages reacting to an ended attempt.
@@ -4081,9 +3373,11 @@ var TestNavigation = class extends LitElement16 {
4081
3373
  #assessmentItemFor(identifier) {
4082
3374
  if (!identifier)
4083
3375
  return void 0;
4084
- const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${identifier}"]`);
3376
+ const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"]`);
4085
3377
  return itemRef?.assessmentItem ?? void 0;
4086
3378
  }
3379
+ /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
3380
+ #itemElement;
4087
3381
  /** The currently active assessment item, exposed for optional presentation extensions. */
4088
3382
  get activeAssessmentItem() {
4089
3383
  if (!this.#testElement || !this._sessionContext?.navItemRefId)
@@ -4091,13 +3385,12 @@ var TestNavigation = class extends LitElement16 {
4091
3385
  return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
4092
3386
  }
4093
3387
  /**
4094
- * Handles the 'test-end-attempt' event.
4095
- * @private
4096
- * @listens TestNavigation#test-end-attempt
4097
- * @param {CustomEvent} event - The custom event object.
3388
+ * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or
3389
+ * given an `item`), or else the item on screen.
4098
3390
  */
4099
- #handleTestEndAttempt(_event) {
4100
- const qtiAssessmentItemEl = this.activeAssessmentItem;
3391
+ #handleTestEndAttempt(event) {
3392
+ const itemId = event.detail?.itemId;
3393
+ const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;
4101
3394
  if (!qtiAssessmentItemEl)
4102
3395
  return;
4103
3396
  const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
@@ -4122,7 +3415,7 @@ var TestNavigation = class extends LitElement16 {
4122
3415
  }
4123
3416
  }
4124
3417
  render() {
4125
- return html15`<slot></slot>`;
3418
+ return html11`<slot></slot>`;
4126
3419
  }
4127
3420
  /* PK: on test connected we can build the computed context */
4128
3421
  #handleTestConnected(event) {
@@ -4156,61 +3449,65 @@ var TestNavigation = class extends LitElement16 {
4156
3449
  });
4157
3450
  }
4158
3451
  });
4159
- const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
3452
+ const model = buildTestModel(renderedMarkup(this.#testElement));
3453
+ this.#sectionItems = new Map(model.testParts.flatMap((part) => sectionsInOrder(part.sections).map((section) => [section.identifier, itemRefsInOrder(section.content).map((item) => item.identifier)])));
3454
+ this.#itemOrder = model.testParts.flatMap((part) => itemRefsInOrder(part.sections));
4160
3455
  this.computedContext = {
4161
- identifier: this.#testElement.identifier,
4162
- title: this.#testElement.title,
3456
+ itemElement: this.#itemElement,
3457
+ identifier: model.identifier,
3458
+ title: model.title,
4163
3459
  view: this._sessionContext?.view,
4164
- testParts: testPartElements.map((testPart) => {
4165
- const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
4166
- const testPartSessionControl = testPart.querySelector(":scope > qti-item-session-control");
4167
- const partAllowSkipping = testPartSessionControl ? testPartSessionControl.allowSkipping : true;
4168
- const partMaxAttempts = testPartSessionControl ? testPartSessionControl.maxAttempts : 1;
4169
- const partShowFeedback = testPartSessionControl ? testPartSessionControl.showFeedback : false;
4170
- const partShowSolution = testPartSessionControl ? testPartSessionControl.showSolution : false;
4171
- return {
3460
+ plugins: this._sessionContext?.plugins ?? {},
3461
+ testParts: model.testParts.map((testPart) => ({
3462
+ active: false,
3463
+ identifier: testPart.identifier,
3464
+ navigationMode: testPart.navigationMode,
3465
+ submissionMode: testPart.submissionMode,
3466
+ allowSkipping: testPart.sessionControl.allowSkipping,
3467
+ // Flat, depth first: every section once, each with only its own item-refs, so every item is
3468
+ // listed once. Where a section's item-refs and subsections interleave, this list is not in
3469
+ // document order; `index` is.
3470
+ sections: sectionsInOrder(testPart.sections).map((section) => ({
4172
3471
  active: false,
4173
- identifier: testPart.identifier,
4174
- navigationMode: testPart.navigationMode,
4175
- submissionMode: testPart.submissionMode,
4176
- allowSkipping: partAllowSkipping,
4177
- sections: sectionElements.map((section) => {
4178
- const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
4179
- const sectionSessionControl = section.querySelector(":scope > qti-item-session-control");
4180
- const sectionAllowSkipping = sectionSessionControl ? sectionSessionControl.allowSkipping : partAllowSkipping;
4181
- const sectionMaxAttempts = sectionSessionControl ? sectionSessionControl.maxAttempts : partMaxAttempts;
4182
- const sectionShowFeedback = sectionSessionControl ? sectionSessionControl.showFeedback : partShowFeedback;
4183
- const sectionShowSolution = sectionSessionControl ? sectionSessionControl.showSolution : partShowSolution;
4184
- return {
4185
- active: false,
4186
- identifier: section.identifier,
4187
- title: section.title,
4188
- navigationMode: section.navigationMode,
4189
- submissionMode: section.submissionMode,
4190
- allowSkipping: sectionAllowSkipping,
4191
- items: itemElements.map((item) => {
4192
- const itemSessionControl = item.querySelector(":scope > qti-item-session-control");
4193
- const itemAllowSkipping = itemSessionControl ? itemSessionControl.allowSkipping : sectionAllowSkipping;
4194
- const itemMaxAttempts = itemSessionControl ? itemSessionControl.maxAttempts : sectionMaxAttempts;
4195
- const itemShowFeedback = itemSessionControl ? itemSessionControl.showFeedback : sectionShowFeedback;
4196
- const itemShowSolution = itemSessionControl ? itemSessionControl.showSolution : sectionShowSolution;
4197
- return {
4198
- ...this.initContext?.find((i) => i.identifier === item.identifier),
4199
- active: false,
4200
- identifier: item.identifier,
4201
- categories: item.category ? item.category?.split(" ") : [],
4202
- href: item.href,
4203
- variables: [],
4204
- allowSkipping: itemAllowSkipping,
4205
- maxAttempts: itemMaxAttempts,
4206
- showFeedback: itemShowFeedback,
4207
- showSolution: itemShowSolution
4208
- };
4209
- })
4210
- };
4211
- })
4212
- };
4213
- })
3472
+ identifier: section.identifier,
3473
+ title: section.title,
3474
+ // QTI defines both modes on the test part only; the section attributes go in roadmap T1d.
3475
+ ...this.#sectionModes(section.identifier),
3476
+ allowSkipping: section.sessionControl.allowSkipping,
3477
+ items: ownItemRefs(section).map((item) => ({
3478
+ ...this.initContext?.find((i) => i.identifier === item.identifier),
3479
+ active: false,
3480
+ identifier: item.identifier,
3481
+ categories: item.categories,
3482
+ href: item.href,
3483
+ variables: [],
3484
+ sessionControl: { ...item.sessionControl }
3485
+ }))
3486
+ }))
3487
+ }))
3488
+ };
3489
+ }
3490
+ /**
3491
+ * The item-refs of each section, its subsections' included, by section identifier: a section that
3492
+ * only holds subsections is completed when theirs are.
3493
+ */
3494
+ #sectionItems;
3495
+ /** Every item-ref of the test in document order, which item numbers follow. */
3496
+ #itemOrder;
3497
+ /** Item numbers in document order, skipping info items; null for an info item. */
3498
+ #itemIndexes() {
3499
+ let index = 1;
3500
+ return new Map(this.#itemOrder.map((item) => [
3501
+ item.identifier,
3502
+ item.categories.includes(this.configContext?.infoItemCategory) ? null : index++
3503
+ ]));
3504
+ }
3505
+ /** The non-QTI `navigation-mode` / `submission-mode` a section declares, as before; removed in T1d. */
3506
+ #sectionModes(identifier) {
3507
+ const section = this.#testElement.querySelector(`qti-assessment-section[identifier="${CSS.escape(identifier)}"]`);
3508
+ return {
3509
+ navigationMode: section?.getAttribute("navigation-mode") ?? void 0,
3510
+ submissionMode: section?.getAttribute("submission-mode") ?? void 0
4214
3511
  };
4215
3512
  }
4216
3513
  /**
@@ -4299,10 +3596,11 @@ var TestNavigation = class extends LitElement16 {
4299
3596
  willUpdate(_changedProperties) {
4300
3597
  if (!this.computedContext)
4301
3598
  return;
4302
- let itemIndex = 1;
3599
+ const itemIndexes = this.#itemIndexes();
4303
3600
  this.computedContext = {
4304
3601
  ...this.computedContext,
4305
3602
  view: this._sessionContext?.view,
3603
+ plugins: this._sessionContext?.plugins ?? {},
4306
3604
  testParts: this.computedContext.testParts.map((testPart) => {
4307
3605
  return {
4308
3606
  ...testPart,
@@ -4311,7 +3609,7 @@ var TestNavigation = class extends LitElement16 {
4311
3609
  return {
4312
3610
  ...section,
4313
3611
  active: this._sessionContext?.navSectionId === section.identifier || false,
4314
- completed: section.items.every((item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"),
3612
+ 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
3613
  items: section.items.map((item) => {
4316
3614
  const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
4317
3615
  const computedItem = {
@@ -4326,7 +3624,7 @@ var TestNavigation = class extends LitElement16 {
4326
3624
  const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
4327
3625
  const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
4328
3626
  const valid = itemContext?.valid ?? true;
4329
- const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
3627
+ const responseVars = itemContext?.variables?.filter((v) => v.type === "response" && v.identifier !== "numAttempts") || [];
4330
3628
  const isDefaultResponse = responseVars.every((v) => {
4331
3629
  if (v.value === void 0 || v.value === null) {
4332
3630
  return true;
@@ -4357,7 +3655,7 @@ var TestNavigation = class extends LitElement16 {
4357
3655
  }
4358
3656
  return v.value === defaultValue;
4359
3657
  });
4360
- const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
3658
+ const index = itemIndexes.get(item.identifier) ?? null;
4361
3659
  const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
4362
3660
  const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
4363
3661
  let optimality = this.#optimality.get(computedItem.identifier);
@@ -4366,7 +3664,7 @@ var TestNavigation = class extends LitElement16 {
4366
3664
  if (numAttempts > 0)
4367
3665
  this.#optimality.set(computedItem.identifier, optimality);
4368
3666
  }
4369
- const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts, computedItem.adaptive, completionStatus);
3667
+ const done = this.#isItemDone(numAttempts, optimality, computedItem.sessionControl?.maxAttempts, computedItem.adaptive, completionStatus);
4370
3668
  return {
4371
3669
  ...computedItem,
4372
3670
  completionStatus,
@@ -4401,6 +3699,53 @@ var TestNavigation = class extends LitElement16 {
4401
3699
  bubbles: true
4402
3700
  }));
4403
3701
  }
3702
+ updated(changedProperties) {
3703
+ super.updated(changedProperties);
3704
+ this.#lockUsedItems();
3705
+ }
3706
+ /** The items this navigation disabled because their attempts are used, so it releases only those. */
3707
+ #lockedItems;
3708
+ /**
3709
+ * Disables every rendered item whose attempts are used, from the computed context, so the
3710
+ * candidate cannot change the answer once the last attempt is ended. Runs after every update:
3711
+ * an item rendered later (another item, a section on screen, a restored state) is locked as it
3712
+ * arrives, and one whose attempts are back to zero (a new state) is released.
3713
+ *
3714
+ * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a
3715
+ * host or view that disables or makes an item read-only itself keeps it so.
3716
+ */
3717
+ #lockUsedItems() {
3718
+ if (!this.#testElement || !this.computedContext)
3719
+ return;
3720
+ 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]))));
3721
+ for (const itemRef of this.#testElement.querySelectorAll("qti-assessment-item-ref")) {
3722
+ const element = itemRef.assessmentItem;
3723
+ if (!element)
3724
+ continue;
3725
+ const used = this.#attemptsUsed(items.get(itemRef.identifier), element);
3726
+ if (used && !element.disabled) {
3727
+ element.disabled = true;
3728
+ this.#lockedItems.add(element);
3729
+ } else if (!used && this.#lockedItems.has(element)) {
3730
+ this.#lockedItems.delete(element);
3731
+ element.disabled = false;
3732
+ }
3733
+ }
3734
+ }
3735
+ /**
3736
+ * The same rule as `test-end-attempt`'s max-attempts guard: a non-adaptive item with a
3737
+ * `max-attempts` above 0 whose attempts reached it. Adaptive items end themselves, and 0 is
3738
+ * unlimited. With `auto-score-items` every change is scored as an attempt, so the count is not
3739
+ * the candidate's and locks nothing.
3740
+ */
3741
+ #attemptsUsed(item, element) {
3742
+ if (!item || this.autoScoreItems)
3743
+ return false;
3744
+ if (item.adaptive || element.adaptive === "true")
3745
+ return false;
3746
+ const maxAttempts = item.sessionControl?.maxAttempts ?? 1;
3747
+ return maxAttempts > 0 && (item.numAttempts ?? 0) >= maxAttempts;
3748
+ }
4404
3749
  /**
4405
3750
  * Decide whether an item should be treated as "the candidate is done with it"
4406
3751
  * for the purpose of gating forward navigation and further attempts.
@@ -4484,63 +3829,50 @@ var TestNavigation = class extends LitElement16 {
4484
3829
  return Number.isNaN(parsed) ? null : parsed;
4485
3830
  }
4486
3831
  };
4487
- __decorate16([
4488
- property13({ type: String })
3832
+ __decorate15([
3833
+ property12({ type: String })
4489
3834
  ], TestNavigation.prototype, "identifier", void 0);
4490
- __decorate16([
4491
- state5()
3835
+ __decorate15([
3836
+ state4()
4492
3837
  ], TestNavigation.prototype, "initContext", void 0);
4493
- __decorate16([
4494
- state5(),
4495
- consume9({ context: configContext, subscribe: true })
3838
+ __decorate15([
3839
+ state4(),
3840
+ consume8({ context: configContext, subscribe: true })
4496
3841
  ], TestNavigation.prototype, "configContext", void 0);
4497
- __decorate16([
4498
- state5(),
4499
- consume9({ context: testContext, subscribe: true })
3842
+ __decorate15([
3843
+ state4(),
3844
+ consume8({ context: testContext, subscribe: true })
4500
3845
  ], TestNavigation.prototype, "_testContext", void 0);
4501
- __decorate16([
4502
- state5(),
4503
- consume9({ context: sessionContext, subscribe: true })
3846
+ __decorate15([
3847
+ state4(),
3848
+ consume8({ context: sessionContext, subscribe: true })
4504
3849
  ], TestNavigation.prototype, "_sessionContext", void 0);
4505
- __decorate16([
4506
- state5(),
4507
- provide4({ context: computedContext })
3850
+ __decorate15([
3851
+ state4(),
3852
+ provide3({ context: computedContext })
4508
3853
  ], TestNavigation.prototype, "computedContext", void 0);
4509
- __decorate16([
4510
- property13({ type: Boolean, attribute: "auto-score-items" })
3854
+ __decorate15([
3855
+ property12({ type: Boolean, attribute: "auto-score-items" })
4511
3856
  ], TestNavigation.prototype, "autoScoreItems", void 0);
4512
3857
 
4513
3858
  // ../qti-test/dist/components/test-next/test-next.js
4514
- import { css as css10, html as html16, LitElement as LitElement17 } from "lit";
4515
- import { property as property14 } from "lit/decorators.js";
4516
- import { consume as consume10 } from "@lit/context";
4517
- var __decorate17 = function(decorators, target, key, desc) {
3859
+ import { LitElement as LitElement14 } from "lit";
3860
+ import { property as property13 } from "lit/decorators.js";
3861
+ import { consume as consume9 } from "@lit/context";
3862
+ var __decorate16 = function(decorators, target, key, desc) {
4518
3863
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4519
3864
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4520
3865
  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
3866
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4522
3867
  };
4523
- var TestNext = class extends LitElement17 {
3868
+ var TestNext = class extends LitElement14 {
4524
3869
  _handleTestElementChange(_oldValue, newValue) {
4525
3870
  if (newValue) {
4526
3871
  this.requestUpdate();
4527
3872
  }
4528
3873
  }
4529
3874
  static {
4530
- this.styles = css10`
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
- `;
3875
+ this.styles = [button, buttonPrimary];
4544
3876
  }
4545
3877
  #internals;
4546
3878
  constructor() {
@@ -4581,88 +3913,40 @@ var TestNext = class extends LitElement17 {
4581
3913
  this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 || isLinearIndividual && !activeItem?.done;
4582
3914
  }
4583
3915
  _requestItem(identifier) {
4584
- dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
3916
+ dispatchPublic(this, "qc-test-navigate", { type: "item", id: identifier });
4585
3917
  }
4586
3918
  render() {
4587
- return html16`<slot></slot>`;
3919
+ return control;
4588
3920
  }
4589
3921
  };
4590
- __decorate17([
4591
- property14({ type: Boolean, reflect: true, attribute: "disabled" })
3922
+ __decorate16([
3923
+ property13({ type: Boolean, reflect: true, attribute: "disabled" })
4592
3924
  ], TestNext.prototype, "_internalDisabled", void 0);
4593
- __decorate17([
4594
- consume10({ context: computedContext, subscribe: true })
3925
+ __decorate16([
3926
+ consume9({ context: computedContext, subscribe: true })
4595
3927
  ], TestNext.prototype, "computedContext", void 0);
4596
- __decorate17([
3928
+ __decorate16([
4597
3929
  watch("computedContext")
4598
3930
  ], TestNext.prototype, "_handleTestElementChange", null);
4599
3931
 
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
3932
  // ../qti-test/dist/components/test-prev/test-prev.js
4636
- import { css as css11, html as html18, LitElement as LitElement19 } from "lit";
4637
- import { property as property15 } from "lit/decorators.js";
4638
- import { consume as consume12 } from "@lit/context";
4639
- var __decorate19 = function(decorators, target, key, desc) {
3933
+ import { LitElement as LitElement15 } from "lit";
3934
+ import { property as property14 } from "lit/decorators.js";
3935
+ import { consume as consume10 } from "@lit/context";
3936
+ var __decorate17 = function(decorators, target, key, desc) {
4640
3937
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4641
3938
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4642
3939
  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
3940
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4644
3941
  };
4645
- var TestPrev = class extends LitElement19 {
3942
+ var TestPrev = class extends LitElement15 {
4646
3943
  _handleTestElementChange(_oldValue, newValue) {
4647
3944
  if (newValue) {
4648
3945
  this.requestUpdate();
4649
3946
  }
4650
3947
  }
4651
3948
  static {
4652
- this.styles = css11`
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
- `;
3949
+ this.styles = button;
4666
3950
  }
4667
3951
  constructor() {
4668
3952
  super();
@@ -4690,520 +3974,39 @@ var TestPrev = class extends LitElement19 {
4690
3974
  this._internalDisabled = navigationMode === "linear" || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
4691
3975
  }
4692
3976
  _requestItem(identifier) {
4693
- dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
3977
+ dispatchPublic(this, "qc-test-navigate", { type: "item", id: identifier });
4694
3978
  }
4695
3979
  render() {
4696
- return html18`<slot></slot>`;
3980
+ return control;
4697
3981
  }
4698
3982
  };
4699
- __decorate19([
4700
- property15({ type: Boolean, reflect: true, attribute: "disabled" })
3983
+ __decorate17([
3984
+ property14({ type: Boolean, reflect: true, attribute: "disabled" })
4701
3985
  ], TestPrev.prototype, "_internalDisabled", void 0);
4702
- __decorate19([
4703
- consume12({ context: computedContext, subscribe: true })
3986
+ __decorate17([
3987
+ consume10({ context: computedContext, subscribe: true })
4704
3988
  ], TestPrev.prototype, "computedContext", void 0);
4705
- __decorate19([
3989
+ __decorate17([
4706
3990
  watch("computedContext")
4707
3991
  ], TestPrev.prototype, "_handleTestElementChange", null);
4708
3992
 
4709
- // ../qti-test/dist/components/test-print-context/test-print-context.js
4710
- import { html as html19, LitElement as LitElement20 } from "lit";
4711
- import { consume as consume13 } from "@lit/context";
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 {
3993
+ // ../qti-test/dist/components/test-submit/test-submit.js
3994
+ import { LitElement as LitElement16 } from "lit";
3995
+ var TestSubmit = class extends LitElement16 {
4739
3996
  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}`;
3997
+ this.styles = button;
4853
3998
  }
4854
3999
  constructor() {
4855
4000
  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;
4001
+ this.addEventListener("click", () => dispatchPublic(this, "qc-test-submit", {}));
4892
4002
  }
4893
4003
  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>`;
4004
+ return control;
4919
4005
  }
4920
4006
  };
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
4007
 
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 {
4973
- static {
4974
- this.styles = css13`
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 });
4991
- }
4992
- constructor() {
4993
- super();
4994
- this.sectionId = null;
4995
- this.addEventListener("click", () => this.#requestItem(this.sectionId));
4996
- }
4997
- render() {
4998
- return html24` <slot></slot> `;
4999
- }
5000
- };
5001
- __decorate25([
5002
- property18({ type: String, attribute: "section-id" })
5003
- ], TestSectionLink.prototype, "sectionId", void 0);
5004
-
5005
- // ../qti-test/dist/components/test-stamp/test-stamp.js
5006
- import { html as html25, LitElement as LitElement26, nothing as nothing4 } from "lit";
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);
4008
+ // ../qti-test/dist/plugins/elements.js
4009
+ var pluginElements = [{ tag: "test-submit", ctor: TestSubmit }];
5207
4010
 
5208
4011
  // ../qti-test/dist/elements.js
5209
4012
  var qtiTestElements = [
@@ -5212,6 +4015,7 @@ var qtiTestElements = [
5212
4015
  { tag: "qti-assessment-test", ctor: QtiAssessmentTest },
5213
4016
  { tag: "qti-branch-rule", ctor: QtiBranchRule },
5214
4017
  { tag: "qti-item-session-control", ctor: QtiItemSessionControl },
4018
+ { tag: "qti-number-presented", ctor: QtiNumberPresented },
5215
4019
  { tag: "qti-number-selected", ctor: QtiNumberSelected },
5216
4020
  { tag: "qti-outcome-processing", ctor: QtiOutcomeProcessing },
5217
4021
  { tag: "qti-pre-condition", ctor: QtiPreCondition },
@@ -5219,31 +4023,12 @@ var qtiTestElements = [
5219
4023
  { tag: "qti-test-feedback", ctor: QtiTestFeedback },
5220
4024
  { tag: "qti-test-part", ctor: QtiTestPart },
5221
4025
  { tag: "qti-test-variables", ctor: QtiTestVariables },
5222
- { tag: "test-check-item", ctor: TestCheckItem },
5223
4026
  { tag: "test-container", ctor: TestContainer },
5224
4027
  { tag: "test-end-attempt", ctor: TestEndAttempt },
5225
- { tag: "test-item-link", ctor: TestItemLink },
5226
- { tag: "test-item-to-speech", ctor: TestItemToSpeech },
5227
4028
  { tag: "test-navigation", ctor: TestNavigation },
5228
4029
  { tag: "test-next", ctor: TestNext },
5229
- { tag: "test-paging-buttons-stamp", ctor: TestPagingButtonsStamp },
5230
4030
  { tag: "test-prev", ctor: TestPrev },
5231
- { tag: "test-print-context", ctor: TestPrintContext },
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 }
4031
+ ...pluginElements
5247
4032
  ];
5248
4033
 
5249
4034
  export {
@@ -5252,6 +4037,7 @@ export {
5252
4037
  QtiAssessmentTest,
5253
4038
  QtiBranchRule,
5254
4039
  QtiItemSessionControl,
4040
+ QtiNumberPresented,
5255
4041
  QtiNumberSelected,
5256
4042
  QtiPreCondition,
5257
4043
  QtiOutcomeProcessing,
@@ -5262,32 +4048,13 @@ export {
5262
4048
  QtiTestVariablesExpression,
5263
4049
  QTI_TEST_STATE_VERSION,
5264
4050
  QtiTest,
5265
- TestCheckItem,
5266
4051
  TestContainer,
5267
4052
  TestEndAttempt,
5268
- TestItemLink,
5269
- ttsContext,
5270
- TestItemToSpeech,
5271
- TestTtsPlay,
5272
- TestTtsPause,
5273
- TestTtsResume,
5274
- TestTtsStop,
5275
- TestTtsPrev,
5276
- TestTtsNext,
5277
- TestTtsPick,
5278
4053
  TestNavigation,
5279
4054
  TestNext,
5280
- TestPagingButtonsStamp,
5281
4055
  TestPrev,
5282
- TestPrintContext,
5283
- TestPrintVariables,
5284
- TestScoringButtons,
5285
- TestScoringFeedback,
5286
- TestSectionButtonsStamp,
5287
- TestSectionLink,
5288
- TestStamp,
5289
- TestView,
5290
- TestViewToggle,
4056
+ TestSubmit,
4057
+ pluginElements,
5291
4058
  qtiTestElements
5292
4059
  };
5293
4060
  /*! Bundled license information:
@@ -5302,4 +4069,4 @@ export {
5302
4069
  * Portions Copyright (c) 2013, the Dart project authors.
5303
4070
  *)
5304
4071
  */
5305
- //# sourceMappingURL=chunk-K3VKQ6QF.js.map
4072
+ //# sourceMappingURL=chunk-ORQFZNJW.js.map