@citolab/qti-components 10.0.0-next.3 → 10.0.0-next.31

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 +4335 -2689
  3. package/dist/base.d.ts +39 -13
  4. package/dist/base.js +14 -1
  5. package/dist/{chunk-OQDBARD5.js → chunk-3HG5GIKR.js} +2 -2
  6. package/dist/{chunk-RU6332MD.js → chunk-566LB3G2.js} +4 -4
  7. package/dist/{chunk-MI7774NV.js → chunk-5BP2A7BI.js} +2 -2
  8. package/dist/{chunk-D3BYGEQU.js → chunk-5LNSB6J6.js} +117 -92
  9. package/dist/chunk-5LNSB6J6.js.map +1 -0
  10. package/dist/chunk-7ISPUOJG.js +209 -0
  11. package/dist/chunk-7ISPUOJG.js.map +1 -0
  12. package/dist/{chunk-GBZNFSFY.js → chunk-ADTCTKXS.js} +2 -2
  13. package/dist/{chunk-FD4AB6TM.js → chunk-BBP7QV32.js} +2 -2
  14. package/dist/{chunk-LFVPS7KB.js → chunk-CFTWXYBO.js} +2 -2
  15. package/dist/{chunk-35WWWFS6.js → chunk-DAESCCLR.js} +2 -2
  16. package/dist/chunk-DJ7PB252.js +7 -0
  17. package/dist/chunk-DJ7PB252.js.map +1 -0
  18. package/dist/{chunk-6U3YPHXU.js → chunk-GAPMCYR5.js} +277 -154
  19. package/dist/chunk-GAPMCYR5.js.map +1 -0
  20. package/dist/{chunk-TDWJ6WZA.js → chunk-GPC53O7P.js} +166 -10
  21. package/dist/chunk-GPC53O7P.js.map +1 -0
  22. package/dist/{chunk-6K3QWJHH.js → chunk-LPYZVKHX.js} +48 -7
  23. package/dist/chunk-LPYZVKHX.js.map +1 -0
  24. package/dist/{chunk-TLAVOBEM.js → chunk-O2XRZPKA.js} +356 -62
  25. package/dist/chunk-O2XRZPKA.js.map +1 -0
  26. package/dist/chunk-PZ5AY32C.js +10 -0
  27. package/dist/chunk-PZ5AY32C.js.map +1 -0
  28. package/dist/{chunk-SIE3E4FG.js → chunk-R352K4KZ.js} +966 -2078
  29. package/dist/chunk-R352K4KZ.js.map +1 -0
  30. package/dist/{chunk-RSMYGGQK.js → chunk-TZCOXFPB.js} +1590 -610
  31. package/dist/chunk-TZCOXFPB.js.map +1 -0
  32. package/dist/chunk-UCXLDQYA.js +56 -0
  33. package/dist/chunk-UCXLDQYA.js.map +1 -0
  34. package/dist/chunk-WWY2H2YO.js +7 -0
  35. package/dist/chunk-WWY2H2YO.js.map +1 -0
  36. package/dist/computed.types.d-D06SAPP2.d.ts +131 -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 +50 -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 +1725 -1777
  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-B7LgeKnN.d.ts +81 -0
  63. package/dist/qti-test-state.d-CjvdranT.d.ts +61 -0
  64. package/dist/{qti-test.d-86TlaMlI.d.ts → qti-test.d-DGXU-4tv.d.ts} +91 -487
  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-CtNaWJr8.d.ts} +9 -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 +143 -0
  70. package/dist/test-plugin-api.js +21 -0
  71. package/dist/test-plugin-api.js.map +1 -0
  72. package/dist/test.d.ts +72 -57
  73. package/dist/test.js +22 -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-6K3QWJHH.js.map +0 -1
  79. package/dist/chunk-6U3YPHXU.js.map +0 -1
  80. package/dist/chunk-D3BYGEQU.js.map +0 -1
  81. package/dist/chunk-RSMYGGQK.js.map +0 -1
  82. package/dist/chunk-SIE3E4FG.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-OQDBARD5.js.map → chunk-3HG5GIKR.js.map} +0 -0
  89. /package/dist/{chunk-RU6332MD.js.map → chunk-566LB3G2.js.map} +0 -0
  90. /package/dist/{chunk-MI7774NV.js.map → chunk-5BP2A7BI.js.map} +0 -0
  91. /package/dist/{chunk-GBZNFSFY.js.map → chunk-ADTCTKXS.js.map} +0 -0
  92. /package/dist/{chunk-FD4AB6TM.js.map → chunk-BBP7QV32.js.map} +0 -0
  93. /package/dist/{chunk-LFVPS7KB.js.map → chunk-CFTWXYBO.js.map} +0 -0
  94. /package/dist/{chunk-35WWWFS6.js.map → chunk-DAESCCLR.js.map} +0 -0
@@ -1,19 +1,27 @@
1
1
  import {
2
- QtiModalFeedback,
3
- dispatchDeclared,
4
- listenDeclared,
2
+ button,
3
+ buttonPrimary,
4
+ control,
5
+ dispatchPublic,
6
+ itemsInOrder,
7
+ listenPublic as listenPublic2
8
+ } from "./chunk-7ISPUOJG.js";
9
+ import {
10
+ QtiModalFeedback
11
+ } from "./chunk-GAPMCYR5.js";
12
+ import {
5
13
  listenPublic
6
- } from "./chunk-6U3YPHXU.js";
14
+ } from "./chunk-UCXLDQYA.js";
7
15
  import {
8
16
  item_css_default
9
- } from "./chunk-ZP6QQYSU.js";
17
+ } from "./chunk-WWY2H2YO.js";
10
18
  import {
11
19
  watch
12
20
  } from "./chunk-4DB4SC5K.js";
13
21
  import {
14
22
  qtiTransformItem,
15
23
  qtiTransformTest
16
- } from "./chunk-TLAVOBEM.js";
24
+ } from "./chunk-O2XRZPKA.js";
17
25
  import {
18
26
  INITIAL_SESSION_CONTEXT,
19
27
  INITIAL_TEST_CONTEXT,
@@ -24,7 +32,7 @@ import {
24
32
  qtiContext,
25
33
  sessionContext,
26
34
  testContext
27
- } from "./chunk-TDWJ6WZA.js";
35
+ } from "./chunk-GPC53O7P.js";
28
36
 
29
37
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
30
38
  import { LitElement, nothing as nothing2 } from "lit";
@@ -636,18 +644,18 @@ var EvalAstFactory = class {
636
644
  }
637
645
  const value = this.right.evaluate(scope);
638
646
  let receiver = void 0;
639
- let property22;
647
+ let property15;
640
648
  if (this.left.type === "Getter") {
641
649
  receiver = this.left.receiver.evaluate(scope);
642
- property22 = this.left.name;
650
+ property15 = this.left.name;
643
651
  } else if (this.left.type === "Index") {
644
652
  receiver = this.left.receiver.evaluate(scope);
645
- property22 = this.left.argument.evaluate(scope);
653
+ property15 = this.left.argument.evaluate(scope);
646
654
  } else if (this.left.type === "ID") {
647
655
  receiver = scope;
648
- property22 = this.left.value;
656
+ property15 = this.left.value;
649
657
  }
650
- return receiver === void 0 ? void 0 : receiver[property22] = value;
658
+ return receiver === void 0 ? void 0 : receiver[property15] = value;
651
659
  }
652
660
  return f(this.left.evaluate(scope), this.right.evaluate(scope));
653
661
  },
@@ -1103,33 +1111,6 @@ var makeLitTemplate = (template) => {
1103
1111
  import { createContext } from "@lit/context";
1104
1112
  var testHostContext = createContext(/* @__PURE__ */ Symbol("testHost"));
1105
1113
 
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
1114
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
1134
1115
  var __decorate = function(decorators, target, key, desc) {
1135
1116
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1191,7 +1172,7 @@ var QtiAssessmentItemRef = class extends LitElement {
1191
1172
  this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;
1192
1173
  this.requestUpdate();
1193
1174
  await this.updateComplete;
1194
- dispatchPublic(this, "cito-item-ref-connected", {
1175
+ dispatchPublic(this, "qc-item-ref-connected", {
1195
1176
  identifier: this.identifier,
1196
1177
  href: this.href,
1197
1178
  category: this.category
@@ -1323,12 +1304,6 @@ __decorate2([
1323
1304
  __decorate2([
1324
1305
  property2({ type: Boolean, converter: stringToBooleanConverter2, attribute: "keep-together" })
1325
1306
  ], QtiAssessmentSection.prototype, "keepTogether", void 0);
1326
- __decorate2([
1327
- property2({ type: String, attribute: "navigation-mode" })
1328
- ], QtiAssessmentSection.prototype, "navigationMode", void 0);
1329
- __decorate2([
1330
- property2({ type: String, attribute: "submission-mode" })
1331
- ], QtiAssessmentSection.prototype, "submissionMode", void 0);
1332
1307
  __decorate2([
1333
1308
  consume2({ context: testContext, subscribe: true })
1334
1309
  ], QtiAssessmentSection.prototype, "_testContext", void 0);
@@ -1356,7 +1331,7 @@ var QtiAssessmentTest = class extends LitElement3 {
1356
1331
  async connectedCallback() {
1357
1332
  super.connectedCallback();
1358
1333
  await this.updateComplete;
1359
- dispatchPublic(this, "cito-test-loaded", this);
1334
+ dispatchPublic(this, "qc-test-loaded", this);
1360
1335
  }
1361
1336
  render() {
1362
1337
  return html2` <slot></slot>`;
@@ -1534,7 +1509,7 @@ var QtiNumberPresented = class extends QtiExpression {
1534
1509
  #connectedTest = null;
1535
1510
  constructor() {
1536
1511
  super();
1537
- listenPublic2(this, "cito-test-loaded", (e) => this.#connectedTest = e.detail);
1512
+ listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
1538
1513
  }
1539
1514
  /** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */
1540
1515
  get #testElement() {
@@ -1565,10 +1540,10 @@ var QtiNumberSelected = class extends QtiExpression {
1565
1540
  #connectedTest = null;
1566
1541
  constructor() {
1567
1542
  super();
1568
- listenPublic2(this, "cito-test-loaded", (e) => this.#connectedTest = e.detail);
1543
+ listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
1569
1544
  }
1570
1545
  /**
1571
- * `qti-assessment-test-connected` bubbles *up* from the test element, and this
1546
+ * `qc-test-loaded` bubbles *up* from the test element, and this
1572
1547
  * expression lives inside that test's `qti-outcome-processing` — so the
1573
1548
  * listener above only ever fires for a test handed to us directly (a test
1574
1549
  * harness). Walking up the tree is what resolves the test in a real document.
@@ -1645,6 +1620,271 @@ var QtiOutcomeProcessingProcessor = class {
1645
1620
  // ../qti-test/dist/components/qti-test-feedback/qti-test-feedback.js
1646
1621
  import { css as css4, html as html7 } from "lit";
1647
1622
  import { property as property6 } from "lit/decorators.js";
1623
+
1624
+ // ../qti-delivery/dist/model/xml-node.js
1625
+ var ELEMENT_NODE = 1;
1626
+ function childElements(parent, ...localNames) {
1627
+ const nodes = parent.childNodes;
1628
+ const children = [];
1629
+ for (let index = 0; index < nodes.length; index++) {
1630
+ const node = nodes[index];
1631
+ if (node.nodeType === ELEMENT_NODE && localNames.includes(node.localName ?? "")) {
1632
+ children.push(node);
1633
+ }
1634
+ }
1635
+ return children;
1636
+ }
1637
+ var childElement = (parent, localName) => childElements(parent, localName)[0] ?? null;
1638
+ function booleanAttribute(element, name) {
1639
+ const value = element.getAttribute(name)?.trim();
1640
+ if (value === "true" || value === "1")
1641
+ return true;
1642
+ if (value === "false" || value === "0")
1643
+ return false;
1644
+ return void 0;
1645
+ }
1646
+ function integerAttribute(element, name) {
1647
+ const value = element.getAttribute(name)?.trim();
1648
+ return value && /^[+-]?\d+$/.test(value) ? Number(value) : void 0;
1649
+ }
1650
+
1651
+ // ../qti-delivery/dist/model/test-model.js
1652
+ var DEFAULT_SESSION_CONTROL = Object.freeze({
1653
+ maxAttempts: 1,
1654
+ showFeedback: false,
1655
+ allowReview: true,
1656
+ showSolution: false,
1657
+ allowComment: false,
1658
+ allowSkipping: true,
1659
+ validateResponses: false
1660
+ });
1661
+ function buildTestModel(test) {
1662
+ if (test.localName !== "qti-assessment-test") {
1663
+ throw new TypeError(`Expected a qti-assessment-test element, not ${String(test.localName)}.`);
1664
+ }
1665
+ return {
1666
+ identifier: test.getAttribute("identifier") ?? "",
1667
+ title: test.getAttribute("title") ?? "",
1668
+ testParts: childElements(test, "qti-test-part").map(buildTestPart)
1669
+ };
1670
+ }
1671
+ function buildTestPart(part) {
1672
+ const sessionControl = resolveSessionControl(DEFAULT_SESSION_CONTROL, part);
1673
+ return {
1674
+ identifier: part.getAttribute("identifier") ?? "",
1675
+ navigationMode: part.getAttribute("navigation-mode") === "linear" ? "linear" : "nonlinear",
1676
+ submissionMode: part.getAttribute("submission-mode") === "simultaneous" ? "simultaneous" : "individual",
1677
+ sessionControl,
1678
+ sections: childElements(part, "qti-assessment-section").map((section) => buildSection(section, sessionControl))
1679
+ };
1680
+ }
1681
+ function buildSection(section, inherited) {
1682
+ const sessionControl = resolveSessionControl(inherited, section);
1683
+ return {
1684
+ kind: "section",
1685
+ identifier: section.getAttribute("identifier") ?? "",
1686
+ title: section.getAttribute("title") ?? "",
1687
+ visible: booleanAttribute(section, "visible") ?? true,
1688
+ sessionControl,
1689
+ content: childElements(section, "qti-assessment-section", "qti-assessment-item-ref").map((child) => child.localName === "qti-assessment-section" ? buildSection(child, sessionControl) : buildItemRef(child, sessionControl))
1690
+ };
1691
+ }
1692
+ function buildItemRef(itemRef, inherited) {
1693
+ const category = itemRef.getAttribute("category")?.trim();
1694
+ return {
1695
+ kind: "itemRef",
1696
+ identifier: itemRef.getAttribute("identifier") ?? "",
1697
+ href: itemRef.getAttribute("href") ?? "",
1698
+ categories: category ? category.split(/\s+/) : [],
1699
+ sessionControl: resolveSessionControl(inherited, itemRef),
1700
+ declaredSessionControl: declaredSessionControl(itemRef)
1701
+ };
1702
+ }
1703
+ function resolveSessionControl(inherited, owner) {
1704
+ return { ...inherited, ...declaredSessionControl(owner) };
1705
+ }
1706
+ function declaredSessionControl(owner) {
1707
+ const element = childElement(owner, "qti-item-session-control");
1708
+ if (!element)
1709
+ return {};
1710
+ const declared = {
1711
+ maxAttempts: integerAttribute(element, "max-attempts"),
1712
+ showFeedback: booleanAttribute(element, "show-feedback"),
1713
+ allowReview: booleanAttribute(element, "allow-review"),
1714
+ showSolution: booleanAttribute(element, "show-solution"),
1715
+ allowComment: booleanAttribute(element, "allow-comment"),
1716
+ allowSkipping: booleanAttribute(element, "allow-skipping"),
1717
+ validateResponses: booleanAttribute(element, "validate-responses")
1718
+ };
1719
+ return Object.fromEntries(Object.entries(declared).filter(([, value]) => value !== void 0));
1720
+ }
1721
+ var ownItemRefs = (section) => section.content.filter((child) => child.kind === "itemRef");
1722
+ function sectionsInOrder(sections) {
1723
+ return sections.flatMap((section) => [
1724
+ section,
1725
+ ...sectionsInOrder(section.content.filter((child) => child.kind === "section"))
1726
+ ]);
1727
+ }
1728
+ function itemRefsInOrder(sections) {
1729
+ return sections.flatMap((child) => child.kind === "itemRef" ? [child] : itemRefsInOrder(child.content));
1730
+ }
1731
+
1732
+ // ../qti-delivery/dist/model/item-facts.js
1733
+ function readItemFacts(item) {
1734
+ if (item.localName !== "qti-assessment-item") {
1735
+ throw new TypeError(`Expected a qti-assessment-item element, not ${String(item.localName)}.`);
1736
+ }
1737
+ const responseDeclarations = childElements(item, "qti-response-declaration");
1738
+ const score = childElements(item, "qti-outcome-declaration").find((declaration) => declaration.getAttribute("identifier") === "SCORE");
1739
+ return {
1740
+ identifier: item.getAttribute("identifier") ?? "",
1741
+ adaptive: booleanAttribute(item, "adaptive") ?? false,
1742
+ timeDependent: booleanAttribute(item, "time-dependent") ?? false,
1743
+ hasCorrectResponse: responseDeclarations.some(hasSomethingToCompareWith),
1744
+ hasResponseProcessing: childElement(item, "qti-response-processing") !== null,
1745
+ externalScored: externalScored(score),
1746
+ label: item.getAttribute("label"),
1747
+ title: item.getAttribute("title") ?? ""
1748
+ };
1749
+ }
1750
+ function hasSomethingToCompareWith(declaration) {
1751
+ if (childElement(declaration, "qti-correct-response"))
1752
+ return true;
1753
+ const mapping = childElement(declaration, "qti-mapping");
1754
+ if (mapping && childElement(mapping, "qti-map-entry"))
1755
+ return true;
1756
+ const areaMapping = childElement(declaration, "qti-area-mapping");
1757
+ return areaMapping !== null && childElement(areaMapping, "qti-area-map-entry") !== null;
1758
+ }
1759
+ function externalScored(declaration) {
1760
+ const value = declaration?.getAttribute("external-scored")?.trim();
1761
+ return value === "human" || value === "externalMachine" ? value : null;
1762
+ }
1763
+
1764
+ // ../qti-delivery/dist/lifecycle/item-lifecycle.js
1765
+ var ITEM_LIFECYCLE = {
1766
+ initial: {
1767
+ beginAttempt: [{ to: "interacting", when: ["attemptsLeft"] }],
1768
+ endItemSession: "closed"
1769
+ },
1770
+ interacting: {
1771
+ // The guards are read after response processing, with the ended attempt counted.
1772
+ endAttempt: [
1773
+ { to: "closed", when: ["individualSubmission"], unless: ["attemptsLeft"] },
1774
+ { to: "modalFeedback", when: ["individualSubmission", "attemptsLeft", "modalFeedback"] },
1775
+ { to: "interacting", when: ["individualSubmission", "attemptsLeft"] }
1776
+ ],
1777
+ endCandidateSession: "suspended",
1778
+ endItemSession: "closed"
1779
+ },
1780
+ modalFeedback: {
1781
+ beginAttempt: [{ to: "interacting", when: ["attemptsLeft"] }],
1782
+ endCandidateSession: "suspended",
1783
+ endItemSession: "closed"
1784
+ },
1785
+ suspended: {
1786
+ beginCandidateSession: [{ to: "interacting", when: ["mayResume"] }],
1787
+ endItemSession: "closed"
1788
+ },
1789
+ closed: {
1790
+ beginReview: [{ to: "review", when: ["allowReview"] }],
1791
+ beginSolution: [{ to: "solution", when: ["showSolution"] }]
1792
+ },
1793
+ review: {
1794
+ endReview: "closed"
1795
+ },
1796
+ solution: {
1797
+ endSolution: "closed"
1798
+ }
1799
+ };
1800
+ function transition(state6, event, guards) {
1801
+ const target = ITEM_LIFECYCLE[state6][event];
1802
+ if (target === void 0)
1803
+ return null;
1804
+ if (typeof target === "string")
1805
+ return target;
1806
+ const branch = target.find(({ when = [], unless = [] }) => when.every((guard) => guards[guard]) && !unless.some((guard) => guards[guard]));
1807
+ return branch?.to ?? null;
1808
+ }
1809
+ function hasAttemptsLeft({ sessionControl: { maxAttempts }, adaptive, numAttempts, completionStatus }) {
1810
+ if (adaptive)
1811
+ return completionStatus !== "completed";
1812
+ return maxAttempts === 0 || numAttempts < maxAttempts;
1813
+ }
1814
+ function itemLifecycleGuards(input) {
1815
+ return {
1816
+ attemptsLeft: hasAttemptsLeft(input),
1817
+ // In a simultaneous part every response is processed when the part is submitted (§4.1).
1818
+ individualSubmission: input.submissionMode === "individual",
1819
+ modalFeedback: input.modalFeedback,
1820
+ // A linear part restricts the candidate to each item in turn: once left, never again (§4.1).
1821
+ mayResume: input.navigationMode === "nonlinear" || !input.left,
1822
+ allowReview: input.sessionControl.allowReview,
1823
+ showSolution: input.sessionControl.showSolution
1824
+ };
1825
+ }
1826
+ function seedItemLifecycle(input) {
1827
+ if (!hasAttemptsLeft(input) || input.passed)
1828
+ return "closed";
1829
+ if (input.presented)
1830
+ return "interacting";
1831
+ return input.numAttempts === 0 ? "initial" : "suspended";
1832
+ }
1833
+
1834
+ // ../qti-delivery/dist/lifecycle/item-rules.js
1835
+ function itemRules(input) {
1836
+ const { state: state6, sessionControl, adaptive } = input;
1837
+ const guards = itemLifecycleGuards(input);
1838
+ const individual = guards.individualSubmission;
1839
+ const maySkip = !individual || sessionControl.allowSkipping || !input.skipped;
1840
+ const maySubmit = maySkip && (!individual || !sessionControl.validateResponses || input.valid);
1841
+ return {
1842
+ attemptsLeft: guards.attemptsLeft,
1843
+ attemptsUsed: !guards.attemptsLeft,
1844
+ interactive: state6 === "interacting",
1845
+ done: state6 === "closed" || state6 === "review" || state6 === "solution",
1846
+ mayEndAttempt: maySubmit && transition(state6, "endAttempt", guards) !== null,
1847
+ maySubmit,
1848
+ maySkip,
1849
+ mayShowFeedback: guards.attemptsLeft || sessionControl.showFeedback || state6 === "review" && adaptive && sessionControl.allowReview,
1850
+ mayBeginReview: transition(state6, "beginReview", guards) !== null,
1851
+ mayBeginSolution: transition(state6, "beginSolution", guards) !== null
1852
+ };
1853
+ }
1854
+
1855
+ // ../qti-delivery/dist/lifecycle/item-session.js
1856
+ var guardsFor = (facts) => (
1857
+ // Modal feedback does not stop a session yet: nothing reports it, so `modalFeedback` is never entered.
1858
+ itemLifecycleGuards({ ...facts, left: facts.passed, modalFeedback: false })
1859
+ );
1860
+ var OVER = ["closed", "review", "solution"];
1861
+ function followItemSession(previous, facts) {
1862
+ const { numAttempts } = facts;
1863
+ if (!previous || previous.numAttempts !== numAttempts)
1864
+ return { state: seedItemLifecycle(facts), numAttempts };
1865
+ const guards = guardsFor(facts);
1866
+ let state6 = previous.state;
1867
+ if (facts.passed) {
1868
+ if (!OVER.includes(state6))
1869
+ state6 = transition(state6, "endItemSession", guards) ?? state6;
1870
+ } else if (facts.presented) {
1871
+ if (state6 === "initial")
1872
+ state6 = transition(state6, "beginAttempt", guards) ?? state6;
1873
+ else if (state6 === "suspended")
1874
+ state6 = transition(state6, "beginCandidateSession", guards) ?? state6;
1875
+ } else if (state6 === "interacting" || state6 === "modalFeedback") {
1876
+ state6 = transition(state6, "endCandidateSession", guards) ?? state6;
1877
+ }
1878
+ return { state: state6, numAttempts };
1879
+ }
1880
+ function endItemAttempt(previous, facts) {
1881
+ const { numAttempts } = facts;
1882
+ if (previous?.state !== "interacting")
1883
+ return { state: seedItemLifecycle({ ...facts, presented: true }), numAttempts };
1884
+ return { state: transition("interacting", "endAttempt", guardsFor(facts)) ?? "interacting", numAttempts };
1885
+ }
1886
+
1887
+ // ../qti-test/dist/components/qti-test-feedback/qti-test-feedback.js
1648
1888
  var __decorate7 = function(decorators, target, key, desc) {
1649
1889
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1650
1890
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1743,10 +1983,10 @@ var QtiTestVariables = class extends QtiExpression {
1743
1983
  #connectedTest = null;
1744
1984
  constructor() {
1745
1985
  super();
1746
- listenPublic2(this, "cito-test-loaded", (e) => this.#connectedTest = e.detail);
1986
+ listenPublic2(this, "qc-test-loaded", (e) => this.#connectedTest = e.detail);
1747
1987
  }
1748
1988
  /**
1749
- * `qti-assessment-test-connected` bubbles *up* from the test element, and this
1989
+ * `qc-test-loaded` bubbles *up* from the test element, and this
1750
1990
  * expression lives inside that test's `qti-outcome-processing` — so the
1751
1991
  * listener above only ever fires for a test handed to us directly (a test
1752
1992
  * harness). Walking up the tree is what resolves the test in a real document.
@@ -1789,10 +2029,10 @@ var QtiTestVariablesExpression = class {
1789
2029
  const uniqueItems = [...new Set(this.includedItems.map((item) => item.item))];
1790
2030
  items.forEach((item) => {
1791
2031
  if (uniqueItems.includes(item.identifier)) {
1792
- const variable = item.variables.find((vr) => vr.identifier === this.itemVariable);
2032
+ const variable2 = item.variables.find((vr) => vr.identifier === this.itemVariable);
1793
2033
  const weight = this.includedItems.find((i) => i.item === item.identifier)?.weight ?? 1;
1794
- if (variable) {
1795
- const value = Number(variable.value);
2034
+ if (variable2) {
2035
+ const value = Number(variable2.value);
1796
2036
  if (!Number.isNaN(value)) {
1797
2037
  total += value * weight;
1798
2038
  }
@@ -1806,13 +2046,53 @@ var QtiTestVariablesExpression = class {
1806
2046
  // ../qti-test/dist/types/qti-test-state.js
1807
2047
  var QTI_TEST_STATE_VERSION = 1;
1808
2048
 
2049
+ // ../qti-test/dist/state-from-contexts.js
2050
+ var VARIABLE_TYPES = ["response", "outcome", "template", "context"];
2051
+ var valueOf = (value) => {
2052
+ if (value === null || value === void 0)
2053
+ return null;
2054
+ if (Array.isArray(value))
2055
+ return value.map(String);
2056
+ return String(value);
2057
+ };
2058
+ var variable = ({ identifier, type, value }) => ({
2059
+ identifier,
2060
+ ...VARIABLE_TYPES.includes(type) ? { type } : {},
2061
+ value: valueOf(value)
2062
+ });
2063
+ var stateFromContexts = (testContext2, sessionContext2) => ({
2064
+ version: QTI_TEST_STATE_VERSION,
2065
+ test: {
2066
+ items: (testContext2?.items ?? []).filter((item) => item?.identifier).map((item) => ({
2067
+ identifier: item.identifier,
2068
+ variables: (item.variables ?? []).map(variable),
2069
+ ...item.state ? { state: { ...item.state } } : {}
2070
+ })),
2071
+ outcomes: (testContext2?.testOutcomeVariables ?? []).map((v) => ({
2072
+ identifier: v.identifier,
2073
+ value: valueOf(v.value)
2074
+ }))
2075
+ },
2076
+ session: {
2077
+ ...sessionContext2?.plugins && Object.keys(sessionContext2.plugins).length > 0 ? { plugins: { ...sessionContext2.plugins } } : {},
2078
+ ...sessionContext2?.navPartId !== void 0 ? { navPartId: sessionContext2.navPartId } : {},
2079
+ ...sessionContext2?.navSectionId !== void 0 ? { navSectionId: sessionContext2.navSectionId } : {},
2080
+ ...sessionContext2?.navItemRefId !== void 0 ? { navItemRefId: sessionContext2.navItemRefId } : {}
2081
+ }
2082
+ });
2083
+
1809
2084
  // ../qti-test/dist/components/qti-test/qti-test.js
1810
- import { ContextProvider, provide as provide2 } from "@lit/context";
2085
+ import { ContextProvider, provide as provide3 } from "@lit/context";
1811
2086
  import { html as html9, LitElement as LitElement10 } from "lit";
1812
- import { state as state2 } from "lit/decorators.js";
2087
+ import { state as state3 } from "lit/decorators.js";
1813
2088
 
1814
2089
  // ../qti-test/dist/mixins/test-navigation.mixin.js
1815
- import { property as property8 } from "lit/decorators.js";
2090
+ import { provide } from "@lit/context";
2091
+ import { property as property8, state as state2 } from "lit/decorators.js";
2092
+
2093
+ // ../qti-test/dist/internal/item-facts.context.js
2094
+ import { createContext as createContext2 } from "@lit/context";
2095
+ var itemFactsContext = createContext2(/* @__PURE__ */ Symbol("itemFacts"));
1816
2096
 
1817
2097
  // ../qti-test/dist/internal/item-sequencing.js
1818
2098
  var SECTION = "qti-assessment-section";
@@ -1919,6 +2199,7 @@ var TestNavigationMixin = (superClass) => {
1919
2199
  this.requestTimeout = 3e4;
1920
2200
  this.postLoadTransformCallback = null;
1921
2201
  this.postLoadTestTransformCallback = null;
2202
+ this.itemFacts = /* @__PURE__ */ new Map();
1922
2203
  this._activeController = null;
1923
2204
  this._loadResults = [];
1924
2205
  this._navigationId = 0;
@@ -1944,20 +2225,21 @@ var TestNavigationMixin = (superClass) => {
1944
2225
  navigateTo(type, id) {
1945
2226
  const targetId = id || this._getDefaultNavigationId(type);
1946
2227
  if (targetId) {
1947
- dispatchPublic(this, "cito-test-navigate", { type, id: targetId });
2228
+ dispatchPublic(this, "qc-test-navigate", { type, id: targetId });
1948
2229
  }
1949
2230
  }
1950
2231
  // ===========================================
1951
2232
  // EVENT HANDLER SETUP
1952
2233
  // ===========================================
1953
2234
  _bindEventHandlers() {
1954
- listenPublic2(this, "cito-test-navigate", this._handleNavigationRequest.bind(this));
1955
- listenPublic2(this, "cito-test-loaded", this._handleTestConnected.bind(this));
2235
+ listenPublic2(this, "qc-test-navigate", this._handleNavigationRequest.bind(this));
2236
+ listenPublic2(this, "qc-test-loaded", this._handleTestConnected.bind(this));
1956
2237
  this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
1957
2238
  this.addEventListener("qti-assessment-stimulus-ref-connected", this._handleStimulusRefConnected.bind(this));
1958
2239
  }
1959
2240
  _handleTestConnected(e) {
1960
2241
  this._testElement = e.detail;
2242
+ this.itemFacts = /* @__PURE__ */ new Map();
1961
2243
  this._initializeNavigation();
1962
2244
  }
1963
2245
  /**
@@ -2029,9 +2311,9 @@ var TestNavigationMixin = (superClass) => {
2029
2311
  if (refs[0]?.closest("qti-test-part")?.getAttribute("navigation-mode") === "linear") {
2030
2312
  const first = resolveFirstItem(refs);
2031
2313
  if (first.skipped.length)
2032
- dispatchPublic(this, "cito-test-items-skipped", { ids: first.skipped });
2314
+ dispatchPublic(this, "qc-test-items-skipped", { ids: first.skipped });
2033
2315
  if (first.id === null) {
2034
- dispatchPublic(this, "cito-test-end-reached", {});
2316
+ dispatchPublic(this, "qc-test-end-reached", {});
2035
2317
  return;
2036
2318
  }
2037
2319
  id = first.id;
@@ -2050,10 +2332,7 @@ var TestNavigationMixin = (superClass) => {
2050
2332
  const currentItemRef = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${currentItemId}"]`);
2051
2333
  if (!currentItemRef)
2052
2334
  return false;
2053
- const section = currentItemRef.closest("qti-assessment-section");
2054
- const testPart = currentItemRef.closest("qti-test-part");
2055
- const navigationMode = section?.navigationMode || section?.getAttribute("navigation-mode") || testPart?.navigationMode || testPart?.getAttribute("navigation-mode") || "nonlinear";
2056
- if (navigationMode !== "linear")
2335
+ if (currentItemRef.closest("qti-test-part")?.getAttribute("navigation-mode") !== "linear")
2057
2336
  return false;
2058
2337
  const allItemRefs = Array.from(this._testElement?.querySelectorAll("qti-assessment-item-ref") || []);
2059
2338
  const currentIndex = allItemRefs.findIndex((ref) => ref.identifier === currentItemId);
@@ -2096,8 +2375,8 @@ var TestNavigationMixin = (superClass) => {
2096
2375
  const resolved = this._resolveLinearNext(detail.type, detail.id);
2097
2376
  if (resolved?.id === null) {
2098
2377
  if (resolved.skipped.length)
2099
- dispatchPublic(this, "cito-test-items-skipped", { ids: resolved.skipped });
2100
- dispatchPublic(this, "cito-test-end-reached", {});
2378
+ dispatchPublic(this, "qc-test-items-skipped", { ids: resolved.skipped });
2379
+ dispatchPublic(this, "qc-test-end-reached", {});
2101
2380
  return;
2102
2381
  }
2103
2382
  const target = resolved?.id ?? detail.id;
@@ -2113,7 +2392,7 @@ var TestNavigationMixin = (superClass) => {
2113
2392
  this._activeController = controller;
2114
2393
  await this._executeNavigation(detail.type, target, navigationId, controller);
2115
2394
  if (resolved?.skipped.length && navigationId === this._navigationId && !controller.signal.aborted) {
2116
- dispatchPublic(this, "cito-test-items-skipped", { ids: resolved.skipped });
2395
+ dispatchPublic(this, "qc-test-items-skipped", { ids: resolved.skipped });
2117
2396
  }
2118
2397
  } catch (error) {
2119
2398
  this._handleNavigationError(error, detail.type, target);
@@ -2156,13 +2435,15 @@ var TestNavigationMixin = (superClass) => {
2156
2435
  async _navigateToSection(sectionId, navigationId, controller) {
2157
2436
  const sectionEl = this._findSection(sectionId);
2158
2437
  const navPartId = sectionEl?.closest("qti-test-part")?.identifier;
2438
+ const itemIds = this._getSectionItemIds(sectionId);
2159
2439
  this.sessionContext = {
2160
2440
  ...this.sessionContext,
2161
2441
  navPartId,
2162
2442
  navSectionId: sectionId,
2163
- navItemRefId: null
2443
+ // with navigate="item", the section's first item is the current position, so test-next/test-prev
2444
+ // and item highlights have an item to work from
2445
+ navItemRefId: this.navigate === "item" ? itemIds[0] ?? null : null
2164
2446
  };
2165
- const itemIds = this._getSectionItemIds(sectionId);
2166
2447
  this._resetLoadingState();
2167
2448
  this._loadingState.expectedItems = itemIds.length;
2168
2449
  await this._loadItems(itemIds, navigationId, controller);
@@ -2290,10 +2571,14 @@ var TestNavigationMixin = (superClass) => {
2290
2571
  const validResults = results.filter(Boolean);
2291
2572
  if (this._isStaleNavigation(navigationId, controller))
2292
2573
  return;
2293
- validResults.forEach(({ itemRef, doc }) => {
2574
+ const itemFacts = new Map(this.itemFacts);
2575
+ validResults.forEach(({ itemRef, doc, facts }) => {
2294
2576
  if (itemRef && doc)
2295
2577
  itemRef.xmlDoc = doc;
2578
+ if (itemRef && facts)
2579
+ itemFacts.set(itemRef.identifier, facts);
2296
2580
  });
2581
+ this.itemFacts = itemFacts;
2297
2582
  validResults.forEach(({ itemRef }) => {
2298
2583
  const itemId = itemRef?.identifier;
2299
2584
  if (!itemRef || !itemId)
@@ -2320,7 +2605,9 @@ var TestNavigationMixin = (superClass) => {
2320
2605
  if (this._isStaleNavigation(navigationId, controller)) {
2321
2606
  return null;
2322
2607
  }
2323
- return { itemRef, doc: transformer.htmlDoc(this._customElementRegistry()) };
2608
+ const item = transformer.xmlDoc().documentElement;
2609
+ const facts = item?.localName === "qti-assessment-item" ? readItemFacts(item) : null;
2610
+ return { itemRef, doc: transformer.htmlDoc(this._customElementRegistry()), facts };
2324
2611
  } catch (error) {
2325
2612
  if (error.name === "AbortError") {
2326
2613
  console.info(`Item load for ${itemRef.identifier} was aborted`);
@@ -2390,7 +2677,7 @@ var TestNavigationMixin = (superClass) => {
2390
2677
  // EVENT DISPATCHING
2391
2678
  // ===========================================
2392
2679
  _dispatchLoadingStarted(type, id) {
2393
- dispatchPublic(this, "cito-test-navigation-started", { type, id });
2680
+ dispatchPublic(this, "qc-test-navigation-started", { type, id });
2394
2681
  }
2395
2682
  _dispatchLoadingEnded(type, id) {
2396
2683
  this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended", {
@@ -2400,16 +2687,16 @@ var TestNavigationMixin = (superClass) => {
2400
2687
  }));
2401
2688
  }
2402
2689
  _dispatchError(error) {
2403
- dispatchPublic(this, "cito-test-navigation-failed", error);
2690
+ dispatchPublic(this, "qc-test-navigation-failed", error);
2404
2691
  }
2405
- /** The items are in the DOM: tell hosts the new position rendered (`cito-test-navigated`) and which items it holds. */
2692
+ /** The items are in the DOM: tell hosts the new position rendered (`qc-test-navigated`) and which items it holds. */
2406
2693
  _dispatchTestLoaded(results, type, id) {
2407
2694
  requestAnimationFrame(() => {
2408
- dispatchPublic(this, "cito-test-rendered", results.map(({ itemRef }) => ({
2695
+ dispatchPublic(this, "qc-test-rendered", results.map(({ itemRef }) => ({
2409
2696
  identifier: itemRef?.identifier,
2410
2697
  element: itemRef
2411
2698
  })));
2412
- dispatchPublic(this, "cito-test-navigated", { type, id });
2699
+ dispatchPublic(this, "qc-test-navigated", { type, id });
2413
2700
  });
2414
2701
  }
2415
2702
  }
@@ -2425,6 +2712,10 @@ var TestNavigationMixin = (superClass) => {
2425
2712
  __decorate10([
2426
2713
  property8({ attribute: false })
2427
2714
  ], TestNavigationClass.prototype, "postLoadTestTransformCallback", void 0);
2715
+ __decorate10([
2716
+ state2(),
2717
+ provide({ context: itemFactsContext })
2718
+ ], TestNavigationClass.prototype, "itemFacts", void 0);
2428
2719
  return TestNavigationClass;
2429
2720
  };
2430
2721
 
@@ -2434,11 +2725,11 @@ var TestViewMixin = (superClass) => {
2434
2725
  constructor(...args) {
2435
2726
  super(...args);
2436
2727
  this.sessionContext = { ...this.sessionContext, view: "candidate" };
2437
- listenPublic2(this, "cito-test-switch-view", (e) => {
2728
+ listenPublic2(this, "qc-test-switch-view", (e) => {
2438
2729
  this.sessionContext = { ...this.sessionContext, view: e.detail };
2439
2730
  this._updateElementView();
2440
2731
  });
2441
- listenPublic2(this, "cito-test-loaded", () => {
2732
+ listenPublic2(this, "qc-test-loaded", () => {
2442
2733
  this._updateElementView();
2443
2734
  });
2444
2735
  this.addEventListener("qti-assessment-item-connected", (e) => {
@@ -2477,7 +2768,7 @@ var TestViewMixin = (superClass) => {
2477
2768
  };
2478
2769
 
2479
2770
  // ../qti-test/dist/mixins/test-base.js
2480
- import { provide } from "@lit/context";
2771
+ import { provide as provide2 } from "@lit/context";
2481
2772
  import { LitElement as LitElement9 } from "lit";
2482
2773
  import { property as property9 } from "lit/decorators.js";
2483
2774
  var __decorate11 = function(decorators, target, key, desc) {
@@ -2505,14 +2796,14 @@ var TestBaseMixin = (superClass) => {
2505
2796
  this._updateItemVariablesInTestContext(identifier, fullVariables, void 0, context.valid);
2506
2797
  } else {
2507
2798
  const newVariables = [...assessmentItem.variables];
2508
- for (const variable of itemContext.variables) {
2509
- if (variable.identifier === "completionStatus" && variable.value === "not_attempted")
2799
+ for (const variable2 of itemContext.variables) {
2800
+ if (variable2.identifier === "completionStatus" && variable2.value === "not_attempted")
2510
2801
  continue;
2511
- const currentVariable = newVariables.find((v) => v.identifier === variable.identifier);
2802
+ const currentVariable = newVariables.find((v) => v.identifier === variable2.identifier);
2512
2803
  if (currentVariable) {
2513
- currentVariable.value = variable.value;
2804
+ currentVariable.value = variable2.value;
2514
2805
  } else {
2515
- newVariables.push(variable);
2806
+ newVariables.push(variable2);
2516
2807
  }
2517
2808
  }
2518
2809
  assessmentItem.variables = newVariables;
@@ -2531,12 +2822,13 @@ var TestBaseMixin = (superClass) => {
2531
2822
  * before the item has loaded. To restore a whole session, assign `state` instead.
2532
2823
  *
2533
2824
  * The test context is replaced rather than changed in place, so its consumers update and
2534
- * `qti-state-changed` fires.
2825
+ * `qc-test-state-changed` fires.
2535
2826
  *
2536
- * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.
2827
+ * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier; a
2828
+ * `with-replacement` clone's instance id (`item-3#2`).
2537
2829
  * @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.
2538
2830
  */
2539
- updateItemVariables(itemRefID, values, state9) {
2831
+ updateItemVariables(itemRefID, values, state6) {
2540
2832
  this.testContext = {
2541
2833
  ...this.testContext,
2542
2834
  items: this.testContext.items.map((item) => {
@@ -2556,22 +2848,22 @@ var TestBaseMixin = (superClass) => {
2556
2848
  else
2557
2849
  variables.push(updated);
2558
2850
  }
2559
- return { ...item, variables, ...state9 ? { state: { ...state9 } } : {} };
2851
+ return { ...item, variables, ...state6 ? { state: { ...state6 } } : {} };
2560
2852
  })
2561
2853
  };
2562
2854
  const assessmentItem = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(itemRefID)}"]`)?.assessmentItem;
2563
2855
  if (!assessmentItem)
2564
2856
  return;
2565
2857
  assessmentItem.variables = [...this.testContext.items.find((i) => i.identifier === itemRefID)?.variables ?? []];
2566
- if (state9)
2567
- assessmentItem.state = state9;
2858
+ if (state6)
2859
+ assessmentItem.state = state6;
2568
2860
  }
2569
2861
  _initializeEventListeners() {
2570
2862
  this.addEventListener("qti-testdoc-loaded", () => {
2571
2863
  this.testContext = INITIAL_TEST_CONTEXT;
2572
2864
  this.sessionContext = INITIAL_SESSION_CONTEXT;
2573
2865
  });
2574
- listenPublic2(this, "cito-test-loaded", (e) => {
2866
+ listenPublic2(this, "qc-test-loaded", (e) => {
2575
2867
  this._testElement = e.detail;
2576
2868
  const items = Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map((itemRef) => {
2577
2869
  return {
@@ -2601,7 +2893,7 @@ var TestBaseMixin = (superClass) => {
2601
2893
  this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state, e.detail.itemContext.valid);
2602
2894
  });
2603
2895
  }
2604
- _updateItemVariablesInTestContext(identifier, variables, state9, valid) {
2896
+ _updateItemVariablesInTestContext(identifier, variables, state6, valid) {
2605
2897
  this.testContext = {
2606
2898
  ...this.testContext,
2607
2899
  // Spread existing test context properties
@@ -2612,11 +2904,11 @@ var TestBaseMixin = (superClass) => {
2612
2904
  return {
2613
2905
  ...itemContext,
2614
2906
  // Keep other properties of the item context
2615
- variables: variables.map((variable) => {
2616
- const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
2617
- return matchingVariable ? { ...matchingVariable, ...variable } : variable;
2907
+ variables: variables.map((variable2) => {
2908
+ const matchingVariable = itemContext.variables.find((v) => v.identifier === variable2.identifier);
2909
+ return matchingVariable ? { ...matchingVariable, ...variable2 } : variable2;
2618
2910
  }),
2619
- ...state9 !== void 0 ? { state: state9 ? { ...state9 } : void 0 } : {},
2911
+ ...state6 !== void 0 ? { state: state6 ? { ...state6 } : void 0 } : {},
2620
2912
  ...valid !== void 0 ? { valid } : {}
2621
2913
  };
2622
2914
  })
@@ -2642,11 +2934,11 @@ var TestBaseMixin = (superClass) => {
2642
2934
  }
2643
2935
  __decorate11([
2644
2936
  property9({ attribute: false, type: Object }),
2645
- provide({ context: testContext })
2937
+ provide2({ context: testContext })
2646
2938
  ], TestBaseClass.prototype, "testContext", void 0);
2647
2939
  __decorate11([
2648
2940
  property9({ attribute: false, type: Object }),
2649
- provide({ context: sessionContext })
2941
+ provide2({ context: sessionContext })
2650
2942
  ], TestBaseClass.prototype, "sessionContext", void 0);
2651
2943
  return TestBaseClass;
2652
2944
  };
@@ -2656,33 +2948,15 @@ var TestBase = class extends TestBaseMixin(LitElement9) {
2656
2948
  // ../qti-test/dist/mixins/test-state.mixin.js
2657
2949
  var copy = (value) => Array.isArray(value) ? [...value] : value ?? null;
2658
2950
  var isQtiTestState = (value) => {
2659
- const state9 = value;
2660
- return state9?.version === QTI_TEST_STATE_VERSION && Array.isArray(state9.test?.items) && Array.isArray(state9.test?.outcomes) && typeof state9.session === "object" && state9.session !== null;
2951
+ const state6 = value;
2952
+ return state6?.version === QTI_TEST_STATE_VERSION && Array.isArray(state6.test?.items) && Array.isArray(state6.test?.outcomes) && typeof state6.session === "object" && state6.session !== null;
2661
2953
  };
2662
- var toState = (test, session) => ({
2663
- version: QTI_TEST_STATE_VERSION,
2664
- test: {
2665
- items: (test?.items ?? []).filter((item) => item.identifier).map((item) => ({
2666
- identifier: item.identifier,
2667
- variables: (item.variables ?? []).map((v) => ({
2668
- identifier: v.identifier,
2669
- ...v.type ? { type: v.type } : {},
2670
- value: copy(v.value)
2671
- })),
2672
- ...item.state ? { state: { ...item.state } } : {}
2673
- })),
2674
- outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
2675
- },
2676
- session: {
2677
- ...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
2678
- ...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
2679
- ...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
2680
- }
2681
- });
2682
2954
  var TestStateMixin = (superClass) => {
2683
2955
  class TestStateClass extends superClass {
2684
2956
  /** A state assigned before the test connected, applied when it does. */
2685
2957
  #pending = null;
2958
+ /** A refused state assigned before the test connected, reported when it does. */
2959
+ #refused = null;
2686
2960
  /**
2687
2961
  * False while a test document is loading. Loading resets both contexts and rebuilds them, so
2688
2962
  * the intermediate states are empty — emitting one would invite a host to save it over the
@@ -2696,20 +2970,46 @@ var TestStateMixin = (superClass) => {
2696
2970
  this.#ready = false;
2697
2971
  this.#lastEmitted = null;
2698
2972
  });
2699
- listenPublic2(this, "cito-test-loaded", () => {
2973
+ listenPublic2(this, "qc-test-update-plugin-state", ({ detail }) => this.#updatePluginState(detail));
2974
+ listenPublic2(this, "qc-test-loaded", () => {
2700
2975
  if (this.#pending) {
2701
2976
  this.#apply(this.#pending);
2702
2977
  this.#pending = null;
2703
2978
  }
2704
2979
  this.#ready = true;
2980
+ if (this.#refused) {
2981
+ dispatchPublic(this, "qc-test-state-refused", this.#refused);
2982
+ this.#refused = null;
2983
+ }
2705
2984
  });
2706
2985
  }
2986
+ /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */
2987
+ #updatePluginState({ plugin, value }) {
2988
+ if (typeof plugin !== "string" || plugin === "")
2989
+ return;
2990
+ const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};
2991
+ let next = others;
2992
+ if (value !== null && value !== void 0) {
2993
+ try {
2994
+ next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };
2995
+ } catch {
2996
+ console.warn(`[qti-test] Ignoring plugin state for "${plugin}": it is not JSON.`);
2997
+ return;
2998
+ }
2999
+ }
3000
+ this.sessionContext = { ...this.sessionContext, plugins: next };
3001
+ }
2707
3002
  get state() {
2708
- return toState(this.testContext, this.sessionContext);
3003
+ return stateFromContexts(this.testContext, this.sessionContext);
2709
3004
  }
2710
3005
  set state(value) {
2711
3006
  if (!isQtiTestState(value)) {
2712
- console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);
3007
+ const message = `Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`;
3008
+ console.warn(`[qti-test] ${message}`);
3009
+ if (this.#ready)
3010
+ dispatchPublic(this, "qc-test-state-refused", { message, state: value });
3011
+ else
3012
+ this.#refused = { message, state: value };
2713
3013
  return;
2714
3014
  }
2715
3015
  if (!this.#ready) {
@@ -2729,22 +3029,39 @@ var TestStateMixin = (superClass) => {
2729
3029
  super.updated(changed);
2730
3030
  if (!this.#ready || !(changed.has("testContext") || changed.has("sessionContext")))
2731
3031
  return;
2732
- const state9 = this.state;
2733
- const serialized = JSON.stringify(state9);
3032
+ const state6 = this.state;
3033
+ const serialized = JSON.stringify(state6);
2734
3034
  if (serialized === this.#lastEmitted)
2735
3035
  return;
2736
3036
  this.#lastEmitted = serialized;
2737
- dispatchPublic(this, "cito-test-state-changed", state9);
3037
+ dispatchPublic(this, "qc-test-state-changed", state6);
2738
3038
  }
2739
- #apply(state9) {
2740
- for (const saved of state9.test.items)
3039
+ #apply(state6) {
3040
+ for (const saved of state6.test.items)
2741
3041
  this.updateItemVariables(saved.identifier, saved.variables, saved.state);
2742
- const savedOutcomes = new Map(state9.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
3042
+ this.#warnLeftOut(state6);
3043
+ const savedOutcomes = new Map(state6.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
2743
3044
  this.testContext = {
2744
3045
  ...this.testContext,
2745
3046
  testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
2746
3047
  };
2747
- this.sessionContext = { ...this.sessionContext, ...this.#validSession(state9.session) };
3048
+ this.sessionContext = {
3049
+ ...this.sessionContext,
3050
+ ...this.#validSession(state6.session),
3051
+ plugins: state6.session.plugins && typeof state6.session.plugins === "object" ? { ...state6.session.plugins } : {}
3052
+ };
3053
+ }
3054
+ /**
3055
+ * Answers for items this test does not present are not restored, and the next state leaves them
3056
+ * out: a selection (`qti-selection`) that leaves an item out, or a revised test. Said, not silent
3057
+ * (roadmap 1 T4, `plans/host-api.md` → Decided).
3058
+ */
3059
+ #warnLeftOut(state6) {
3060
+ const presented = new Set(this.testContext.items.map((item) => item.identifier));
3061
+ const leftOut = state6.test.items.map((item) => item.identifier).filter((identifier) => !presented.has(identifier));
3062
+ if (leftOut.length === 0)
3063
+ return;
3064
+ console.warn(`[qti-test] The state has answers for items this test does not present (not selected, or no longer in it); they are not restored: ${leftOut.join(", ")}.`);
2748
3065
  }
2749
3066
  /** A stored position may point at an item or section a revised test no longer has. */
2750
3067
  #validSession(session) {
@@ -2756,7 +3073,7 @@ var TestStateMixin = (superClass) => {
2756
3073
  };
2757
3074
  }
2758
3075
  #requestNavigation(type, id) {
2759
- dispatchPublic(this, "cito-test-navigate", { type, id });
3076
+ dispatchPublic(this, "qc-test-navigate", { type, id });
2760
3077
  }
2761
3078
  }
2762
3079
  return TestStateClass;
@@ -2774,6 +3091,7 @@ var TestProcessingMixin = (superClass) => {
2774
3091
  };
2775
3092
  e.stopPropagation();
2776
3093
  });
3094
+ listenPublic2(this, "qc-test-submit", () => this.submit());
2777
3095
  this.addEventListener("qti-set-outcome-value", (e) => {
2778
3096
  const { outcomeIdentifier, value } = e.detail;
2779
3097
  this.updateOutcomeVariable(outcomeIdentifier, value);
@@ -2784,7 +3102,24 @@ var TestProcessingMixin = (superClass) => {
2784
3102
  const outcomeProcessor = (this._testElement ?? this).querySelector("qti-outcome-processing");
2785
3103
  if (!outcomeProcessor)
2786
3104
  return false;
2787
- outcomeProcessor?.process();
3105
+ this.testContext = {
3106
+ ...this.testContext,
3107
+ testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => ({
3108
+ ...v,
3109
+ value: v.defaultValue ?? null
3110
+ }))
3111
+ };
3112
+ outcomeProcessor.process();
3113
+ return true;
3114
+ }
3115
+ /**
3116
+ * Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with
3117
+ * `qc-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.
3118
+ */
3119
+ submit() {
3120
+ if (!this.outcomeProcessing())
3121
+ return false;
3122
+ dispatchPublic(this, "qc-test-submitted", {});
2788
3123
  return true;
2789
3124
  }
2790
3125
  /**
@@ -2862,114 +3197,26 @@ var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixi
2862
3197
  }
2863
3198
  };
2864
3199
  __decorate12([
2865
- state2(),
2866
- provide2({ context: configContext })
3200
+ state3(),
3201
+ provide3({ context: configContext })
2867
3202
  ], QtiTest.prototype, "configContext", void 0);
2868
3203
  __decorate12([
2869
- state2(),
2870
- provide2({ context: qtiContext })
3204
+ state3(),
3205
+ provide3({ context: qtiContext })
2871
3206
  ], QtiTest.prototype, "qtiContext", void 0);
2872
3207
 
2873
- // ../qti-test/dist/components/test-check-item/test-check-item.js
2874
- import { consume as consume6 } from "@lit/context";
2875
- import { css as css6, html as html10, LitElement as LitElement11 } from "lit";
2876
-
2877
- // ../qti-test/dist/components/styles.js
2878
- import { css as css5 } from "lit";
2879
- var form = css5`
2880
- display: inline-flex;
2881
- align-items: center;
2882
- justify-content: center;
2883
- gap: 0.375em;
2884
- box-sizing: border-box;
2885
- min-block-size: var(--test-button-size, 2.25rem);
2886
- padding: 0 0.875rem;
2887
- font: inherit;
2888
- line-height: 1.25;
2889
- cursor: pointer;
2890
- user-select: none;
2891
- border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
2892
- `;
2893
- var btn = css5`
2894
- ${form};
2895
- background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
2896
- color: var(--test-button-color, var(--qti-component-color, inherit));
2897
- border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
2898
- var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
2899
- `;
2900
- var btnInteractive = css5`
2901
- background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
2902
- `;
2903
- var focusRing = css5`
2904
- outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
2905
- outline-offset: 2px;
2906
- `;
2907
- var dis = css5`
2908
- cursor: not-allowed;
2909
- opacity: 0.45;
2910
- `;
2911
- var ind = css5`
2912
- ${form};
2913
- border: 1px solid gray;
2914
- `;
2915
-
2916
- // ../qti-test/dist/components/test-check-item/test-check-item.js
2917
- var __decorate13 = function(decorators, target, key, desc) {
2918
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2919
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2920
- 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;
2921
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2922
- };
2923
- var TestCheckItem = class extends LitElement11 {
2924
- static {
2925
- this.styles = css6`
2926
- :host {
2927
- ${btn};
2928
- }
2929
- :host(:hover:not([disabled])) {
2930
- ${btnInteractive};
2931
- }
2932
- :host(:focus-visible) {
2933
- ${focusRing};
2934
- }
2935
- :host([disabled]) {
2936
- ${dis};
2937
- }
2938
- `;
2939
- }
2940
- constructor() {
2941
- super();
2942
- this.addEventListener("click", () => {
2943
- dispatchPublic(this, "cito-test-end-attempt", {});
2944
- const testContainer = this.testHost?.querySelector("test-container");
2945
- if (!testContainer)
2946
- return;
2947
- const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
2948
- viewElements.forEach((element) => {
2949
- element.classList.toggle("show", true);
2950
- });
2951
- });
2952
- }
2953
- render() {
2954
- return html10` <slot></slot> `;
2955
- }
2956
- };
2957
- __decorate13([
2958
- consume6({ context: testHostContext, subscribe: true })
2959
- ], TestCheckItem.prototype, "testHost", void 0);
2960
-
2961
3208
  // ../qti-test/dist/components/test-container/test-container.js
2962
- import { consume as consume7 } from "@lit/context";
2963
- import { LitElement as LitElement12, html as html11 } from "lit";
2964
- import { property as property10, state as state3 } from "lit/decorators.js";
3209
+ import { consume as consume6 } from "@lit/context";
3210
+ import { LitElement as LitElement11, html as html10 } from "lit";
3211
+ import { property as property10, state as state4 } from "lit/decorators.js";
2965
3212
  import { until } from "lit/directives/until.js";
2966
- var __decorate14 = function(decorators, target, key, desc) {
3213
+ var __decorate13 = function(decorators, target, key, desc) {
2967
3214
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2968
3215
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2969
3216
  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;
2970
3217
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2971
3218
  };
2972
- var TestContainer = class extends LitElement12 {
3219
+ var TestContainer = class extends LitElement11 {
2973
3220
  constructor() {
2974
3221
  super(...arguments);
2975
3222
  this.customElementRegistry = null;
@@ -3000,7 +3247,7 @@ var TestContainer = class extends LitElement12 {
3000
3247
  return;
3001
3248
  try {
3002
3249
  const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
3003
- let api = (await qtiTransformTest().load(this.testURL)).shuffleOrdering(explicitSeed);
3250
+ let api = (await qtiTransformTest().load(this.testURL)).applySelection(explicitSeed).shuffleOrdering(explicitSeed);
3004
3251
  const qtiTest = this.testHost;
3005
3252
  if (qtiTest?.postLoadTestTransformCallback) {
3006
3253
  const tempDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
@@ -3018,7 +3265,7 @@ var TestContainer = class extends LitElement12 {
3018
3265
  * Assign a new test document and announce it.
3019
3266
  *
3020
3267
  * The announcement has to happen here rather than on
3021
- * `qti-assessment-test-connected`, because by then the new document's
3268
+ * `qc-test-loaded`, because by then the new document's
3022
3269
  * children have already connected and registered themselves — a host that
3023
3270
  * resets its context on that event throws those registrations away. Lit's
3024
3271
  * re-render is async, so a handler running now still gets in before any child
@@ -3036,7 +3283,7 @@ var TestContainer = class extends LitElement12 {
3036
3283
  return;
3037
3284
  try {
3038
3285
  const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
3039
- this.#setTestDoc(qtiTransformTest().parse(this.testXML).shuffleOrdering(explicitSeed).htmlDoc(this.#resolvedCustomElementRegistry ?? void 0));
3286
+ this.#setTestDoc(qtiTransformTest().parse(this.testXML).applySelection(explicitSeed).shuffleOrdering(explicitSeed).htmlDoc(this.#resolvedCustomElementRegistry ?? void 0));
3040
3287
  } catch (error) {
3041
3288
  console.error("Error parsing XML:", error);
3042
3289
  }
@@ -3054,7 +3301,7 @@ var TestContainer = class extends LitElement12 {
3054
3301
  }
3055
3302
  #initializeTemplateContent() {
3056
3303
  const template = this.querySelector("template");
3057
- this.#templateContent = template ? template.content : html11``;
3304
+ this.#templateContent = template ? template.content : html10``;
3058
3305
  }
3059
3306
  #applyStyles() {
3060
3307
  const sheet = new CSSStyleSheet();
@@ -3062,96 +3309,96 @@ var TestContainer = class extends LitElement12 {
3062
3309
  this.shadowRoot.adoptedStyleSheets = [sheet];
3063
3310
  }
3064
3311
  render() {
3065
- return html11`
3312
+ return html10`
3066
3313
  ${this.#templateContent}
3067
3314
  <slot></slot>
3068
- ${until(this.testDoc, html11`<span>Loading...</span>`)}
3315
+ ${until(this.testDoc, html10`<span>Loading...</span>`)}
3069
3316
  `;
3070
3317
  }
3071
3318
  };
3072
- __decorate14([
3319
+ __decorate13([
3073
3320
  property10({ attribute: false })
3074
3321
  ], TestContainer.prototype, "customElementRegistry", void 0);
3075
- __decorate14([
3322
+ __decorate13([
3076
3323
  property10({ type: String, attribute: "test-url" })
3077
3324
  ], TestContainer.prototype, "testURL", void 0);
3078
- __decorate14([
3079
- state3()
3325
+ __decorate13([
3326
+ state4()
3080
3327
  ], TestContainer.prototype, "testDoc", void 0);
3081
- __decorate14([
3082
- state3()
3328
+ __decorate13([
3329
+ state4()
3083
3330
  ], TestContainer.prototype, "testXML", void 0);
3084
- __decorate14([
3085
- consume7({ context: testHostContext, subscribe: true })
3331
+ __decorate13([
3332
+ consume6({ context: testHostContext, subscribe: true })
3086
3333
  ], TestContainer.prototype, "testHost", void 0);
3087
- __decorate14([
3088
- state3(),
3089
- consume7({ context: qtiContext, subscribe: true })
3334
+ __decorate13([
3335
+ state4(),
3336
+ consume6({ context: qtiContext, subscribe: true })
3090
3337
  ], TestContainer.prototype, "qtiContext", void 0);
3091
- __decorate14([
3338
+ __decorate13([
3092
3339
  watch("testURL", { waitUntilFirstUpdate: true })
3093
3340
  ], TestContainer.prototype, "handleTestURLChange", null);
3094
- __decorate14([
3341
+ __decorate13([
3095
3342
  watch("testXML", { waitUntilFirstUpdate: true })
3096
3343
  ], TestContainer.prototype, "handleTestXMLChange", null);
3097
3344
 
3098
3345
  // ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
3099
- import { css as css7, html as html12, LitElement as LitElement13 } from "lit";
3346
+ import { LitElement as LitElement12 } from "lit";
3100
3347
  import { property as property11 } from "lit/decorators.js";
3101
- import { consume as consume8 } from "@lit/context";
3102
- var __decorate15 = function(decorators, target, key, desc) {
3348
+ import { consume as consume7 } from "@lit/context";
3349
+ var __decorate14 = function(decorators, target, key, desc) {
3103
3350
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3104
3351
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3105
3352
  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
3353
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3107
3354
  };
3108
- var TestEndAttempt = class extends LitElement13 {
3355
+ var itemRefOf = (element) => {
3356
+ const itemRef = element.closest("qti-assessment-item-ref");
3357
+ if (itemRef)
3358
+ return itemRef.getAttribute("identifier") ?? void 0;
3359
+ const root = element.getRootNode();
3360
+ return root instanceof ShadowRoot ? itemRefOf(root.host) : void 0;
3361
+ };
3362
+ var TestEndAttempt = class extends LitElement12 {
3109
3363
  _handleTestElementChange(_oldValue, newValue) {
3110
3364
  if (newValue) {
3111
3365
  this.requestUpdate();
3112
3366
  }
3113
3367
  }
3114
3368
  static {
3115
- this.styles = css7`
3116
- :host {
3117
- ${btn};
3118
- }
3119
- :host(:hover:not([disabled])) {
3120
- ${btnInteractive};
3121
- }
3122
- :host(:focus-visible) {
3123
- ${focusRing};
3124
- }
3125
- :host([disabled]) {
3126
- ${dis};
3127
- }
3128
- `;
3369
+ this.styles = button;
3129
3370
  }
3130
3371
  constructor() {
3131
3372
  super();
3132
3373
  this._internalDisabled = false;
3374
+ this.requireAnswer = false;
3133
3375
  this.addEventListener("click", (e) => {
3134
3376
  e.preventDefault();
3135
3377
  if (!this._internalDisabled) {
3136
- dispatchPublic(this, "cito-test-end-attempt", {});
3378
+ const itemId = this.#ownItem;
3379
+ dispatchPublic(this, "qc-test-end-attempt", itemId ? { itemId } : {});
3137
3380
  }
3138
3381
  });
3139
3382
  }
3383
+ /** The item named by `item`, or else the item-ref it is stamped into. */
3384
+ get #ownItem() {
3385
+ return this.item || itemRefOf(this);
3386
+ }
3140
3387
  willUpdate(_changedProperties) {
3141
3388
  this.checkDisabled();
3142
3389
  }
3143
3390
  checkDisabled() {
3144
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3145
- if (!testPart)
3391
+ const testParts = this.computedContext?.testParts;
3392
+ const ownItem = this.#ownItem;
3393
+ const testPart = testParts?.find((testPart2) => testPart2.active);
3394
+ if (!testParts || !ownItem && !testPart)
3146
3395
  return;
3147
- const sectionItems = testPart.sections.flatMap((section) => section.items);
3148
- const itemIndex = sectionItems.findIndex((item) => item.active);
3149
- const activeItem = sectionItems[itemIndex];
3396
+ 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);
3150
3397
  if (!activeItem) {
3151
3398
  this._internalDisabled = false;
3152
3399
  return;
3153
3400
  }
3154
- const maxAttempts = activeItem.maxAttempts ?? 1;
3401
+ const maxAttempts = activeItem.sessionControl?.maxAttempts ?? 1;
3155
3402
  const numAttempts = activeItem.numAttempts || 0;
3156
3403
  if (!activeItem.adaptive && activeItem.optimal) {
3157
3404
  this._internalDisabled = true;
@@ -3165,898 +3412,271 @@ var TestEndAttempt = class extends LitElement13 {
3165
3412
  this._internalDisabled = true;
3166
3413
  return;
3167
3414
  }
3168
- if (activeItem.allowSkipping === false) {
3415
+ if (this.requireAnswer || activeItem.sessionControl?.allowSkipping === false) {
3169
3416
  this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;
3170
3417
  } else {
3171
3418
  this._internalDisabled = false;
3172
3419
  }
3173
3420
  }
3174
3421
  render() {
3175
- return html12` <slot></slot> `;
3422
+ return control;
3176
3423
  }
3177
3424
  };
3178
- __decorate15([
3179
- consume8({ context: computedContext, subscribe: true }),
3425
+ __decorate14([
3426
+ consume7({ context: computedContext, subscribe: true }),
3180
3427
  property11({ attribute: false })
3181
3428
  ], TestEndAttempt.prototype, "computedContext", void 0);
3182
- __decorate15([
3429
+ __decorate14([
3183
3430
  property11({ type: Boolean, reflect: true, attribute: "disabled" })
3184
3431
  ], TestEndAttempt.prototype, "_internalDisabled", void 0);
3185
- __decorate15([
3432
+ __decorate14([
3433
+ property11({ reflect: true })
3434
+ ], TestEndAttempt.prototype, "item", void 0);
3435
+ __decorate14([
3436
+ property11({ type: Boolean, reflect: true, attribute: "require-answer" })
3437
+ ], TestEndAttempt.prototype, "requireAnswer", void 0);
3438
+ __decorate14([
3186
3439
  watch("computedContext")
3187
3440
  ], TestEndAttempt.prototype, "_handleTestElementChange", null);
3188
3441
 
3189
- // ../qti-test/dist/components/test-item-link/test-item-link.js
3190
- import { css as css8, html as html13, LitElement as LitElement14 } from "lit";
3191
- import { property as property12 } from "lit/decorators.js";
3192
- var __decorate16 = function(decorators, target, key, desc) {
3193
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3194
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3195
- 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;
3196
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3197
- };
3198
- var TestItemLink = class extends LitElement14 {
3199
- static {
3200
- this.styles = css8`
3201
- :host {
3202
- ${btn};
3203
- }
3204
- :host(:hover:not([disabled])) {
3205
- ${btnInteractive};
3442
+ // ../qti-test/dist/components/test-navigation/test-navigation.js
3443
+ import { ContextConsumer, consume as consume8, provide as provide4 } from "@lit/context";
3444
+ import { html as html11, LitElement as LitElement13 } from "lit";
3445
+ import { property as property12, state as state5 } from "lit/decorators.js";
3446
+
3447
+ // ../qti-test/dist/internal/derive-computed-context.js
3448
+ function deriveComputedContext(inputs) {
3449
+ const { model, sessionContext: sessionContext2, itemElement } = inputs;
3450
+ const itemIndexes = indexesInDocumentOrder(model.testParts.flatMap((part) => itemRefsInOrder(part.sections)), inputs.infoItemCategory);
3451
+ return {
3452
+ itemElement,
3453
+ identifier: model.identifier,
3454
+ title: model.title,
3455
+ view: sessionContext2?.view,
3456
+ plugins: sessionContext2?.plugins ?? {},
3457
+ testParts: model.testParts.map((testPart) => ({
3458
+ active: sessionContext2?.navPartId === testPart.identifier,
3459
+ identifier: testPart.identifier,
3460
+ navigationMode: testPart.navigationMode,
3461
+ submissionMode: testPart.submissionMode,
3462
+ allowSkipping: testPart.sessionControl.allowSkipping,
3463
+ itemOrder: itemRefsInOrder(testPart.sections).map((item) => item.identifier),
3464
+ // Flat, depth first: every section once, each with only its own item-refs, so every item is
3465
+ // listed once. Where a section's item-refs and subsections interleave, this list is not in
3466
+ // document order; `index` is.
3467
+ sections: sectionsInOrder(testPart.sections).map((section) => ({
3468
+ active: sessionContext2?.navSectionId === section.identifier,
3469
+ identifier: section.identifier,
3470
+ title: section.title,
3471
+ allowSkipping: section.sessionControl.allowSkipping,
3472
+ // A section that only holds subsections is completed when theirs are.
3473
+ completed: itemRefsInOrder(section.content).every((item) => variableValue(itemContextFor(inputs, item.identifier), "completionStatus") === "completed"),
3474
+ items: ownItemRefs(section).map((item) => deriveItem(inputs, testPart, item, itemIndexes.get(item.identifier) ?? null))
3475
+ }))
3476
+ }))
3477
+ };
3478
+ }
3479
+ function deriveItem(inputs, testPart, item, index) {
3480
+ const itemContext = itemContextFor(inputs, item.identifier);
3481
+ const computedItem = {
3482
+ active: false,
3483
+ identifier: item.identifier,
3484
+ categories: [...item.categories],
3485
+ href: item.href,
3486
+ variables: [],
3487
+ sessionControl: { ...item.sessionControl },
3488
+ ...factsFor(inputs.itemFacts, item.identifier),
3489
+ ...itemContext,
3490
+ ...inputs.itemData?.find((data) => data.identifier === item.identifier)
3491
+ };
3492
+ const rawScore = variableValue(computedItem, "SCORE");
3493
+ const score = rawScore === void 0 || rawScore === null ? null : parseFloat(rawScore.toString());
3494
+ const rawMaxScore = variableValue(computedItem, "MAXSCORE");
3495
+ const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore.toString());
3496
+ const completionStatus = variableValue(computedItem, "completionStatus");
3497
+ const response = variableValue(computedItem, "RESPONSE") || "";
3498
+ const numAttempts = Number(variableValue(computedItem, "numAttempts")) || 0;
3499
+ const latched = inputs.optimality.get(item.identifier);
3500
+ const optimality = latched ?? (itemContext ? assessOptimality(itemContext) : "unscored");
3501
+ return {
3502
+ ...computedItem,
3503
+ completionStatus,
3504
+ numAttempts,
3505
+ score,
3506
+ response,
3507
+ index,
3508
+ active: inputs.sessionContext?.navItemRefId === item.identifier,
3509
+ // Published by the item. One that is not on screen has nothing to be invalid.
3510
+ valid: itemContext?.valid ?? true,
3511
+ isDefaultResponse: isDefaultResponse(itemContext),
3512
+ maxScore,
3513
+ done: isItemDone(numAttempts, optimality, computedItem.sessionControl?.maxAttempts, computedItem.adaptive, completionStatus),
3514
+ // Reflects the last *ended* attempt only: the latch, not the fallback above.
3515
+ optimal: latched === "optimal",
3516
+ ...lifecycleOf(inputs, testPart, item, itemContext, { numAttempts, completionStatus })
3517
+ };
3518
+ }
3519
+ function lifecycleOf(inputs, testPart, item, itemContext, { numAttempts, completionStatus }) {
3520
+ const session = {
3521
+ sessionControl: item.sessionControl,
3522
+ adaptive: inputs.itemFacts?.get(item.identifier)?.adaptive ?? false,
3523
+ navigationMode: testPart.navigationMode,
3524
+ submissionMode: testPart.submissionMode,
3525
+ numAttempts,
3526
+ completionStatus: completionStatus ?? null
3527
+ };
3528
+ const lifecycle = inputs.lifecycle?.get(item.identifier) ?? seedItemLifecycle({
3529
+ ...session,
3530
+ presented: inputs.sessionContext?.navItemRefId === item.identifier,
3531
+ passed: false
3532
+ });
3533
+ const rules = itemRules({
3534
+ ...session,
3535
+ state: lifecycle,
3536
+ // Only resuming reads it, and no answer asks about resuming.
3537
+ left: false,
3538
+ modalFeedback: false,
3539
+ skipped: isSkipped(itemContext),
3540
+ valid: itemContext?.valid ?? true
3541
+ });
3542
+ return { lifecycle, rules };
3543
+ }
3544
+ function itemContextFor(inputs, identifier) {
3545
+ return inputs.testContext?.items?.find((item) => item.identifier === identifier);
3546
+ }
3547
+ function variableValue(item, identifier) {
3548
+ return item?.variables?.find((variable2) => variable2.identifier === identifier)?.value;
3549
+ }
3550
+ function factsFor(itemFacts, identifier) {
3551
+ const facts = itemFacts?.get(identifier);
3552
+ if (!facts)
3553
+ return {};
3554
+ const { identifier: assessmentItemIdentifier, ...rest } = facts;
3555
+ return { ...rest, assessmentItemIdentifier };
3556
+ }
3557
+ function indexesInDocumentOrder(items, infoItemCategory) {
3558
+ let index = 1;
3559
+ return new Map(items.map((item) => [item.identifier, item.categories.includes(infoItemCategory) ? null : index++]));
3560
+ }
3561
+ function isSkipped(itemContext) {
3562
+ if (!itemContext)
3563
+ return true;
3564
+ const responses = itemContext.variables?.filter((v) => v.type === "response" && v.identifier !== "numAttempts" && v.identifier !== "duration");
3565
+ return Boolean(responses?.length) && isDefaultResponse(itemContext);
3566
+ }
3567
+ function isDefaultResponse(itemContext) {
3568
+ const responseVariables = itemContext?.variables?.filter((v) => v.type === "response" && v.identifier !== "numAttempts") || [];
3569
+ return responseVariables.every((v) => {
3570
+ if (v.value === void 0 || v.value === null)
3571
+ return true;
3572
+ let fallbackValue;
3573
+ switch (v.baseType) {
3574
+ case "integer":
3575
+ case "float":
3576
+ case "duration":
3577
+ fallbackValue = "0";
3578
+ break;
3579
+ case "boolean":
3580
+ fallbackValue = "false";
3581
+ break;
3582
+ default:
3583
+ fallbackValue = "";
3584
+ break;
3206
3585
  }
3207
- :host(:focus-visible) {
3208
- ${focusRing};
3586
+ const defaultValue = v.defaultValue ?? fallbackValue;
3587
+ if (Array.isArray(v.value)) {
3588
+ const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
3589
+ return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
3209
3590
  }
3210
- :host([disabled]) {
3211
- ${dis};
3591
+ return v.value === defaultValue;
3592
+ });
3593
+ }
3594
+ function isItemDone(numAttempts, optimality, maxAttempts, adaptive, completionStatus) {
3595
+ if (numAttempts === 0)
3596
+ return false;
3597
+ if (adaptive)
3598
+ return completionStatus === "completed";
3599
+ if (optimality !== "suboptimal")
3600
+ return true;
3601
+ const max = maxAttempts ?? 1;
3602
+ return max > 0 && numAttempts >= max;
3603
+ }
3604
+ function assessOptimality(item) {
3605
+ const variables = item.variables ?? [];
3606
+ const score = numericVariable(variables, "SCORE");
3607
+ const maxScore = numericVariable(variables, "MAXSCORE");
3608
+ if (score !== null && maxScore !== null) {
3609
+ return score >= maxScore ? "optimal" : "suboptimal";
3610
+ }
3611
+ const responseVars = variables.filter((v) => v.type === "response" && v.correctResponse !== void 0 && v.correctResponse !== null);
3612
+ if (responseVars.length === 0)
3613
+ return "unscored";
3614
+ const allMatch = responseVars.every((v) => {
3615
+ const expected = v.correctResponse;
3616
+ const actual = v.value;
3617
+ if (actual === void 0 || actual === null)
3618
+ return false;
3619
+ if (Array.isArray(expected) && Array.isArray(actual)) {
3620
+ return expected.length === actual.length && expected.every((e) => actual.includes(e));
3212
3621
  }
3213
- `;
3214
- }
3215
- constructor() {
3216
- super();
3217
- this.itemId = null;
3218
- this.addEventListener("click", () => this._requestItem(this.itemId));
3219
- }
3220
- _requestItem(identifier) {
3221
- dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
3222
- }
3223
- render() {
3224
- return html13` <slot></slot> `;
3622
+ if (Array.isArray(expected) || Array.isArray(actual))
3623
+ return false;
3624
+ return expected === actual;
3625
+ });
3626
+ return allMatch ? "optimal" : "suboptimal";
3627
+ }
3628
+ function numericVariable(variables, identifier) {
3629
+ const raw = variables?.find((v) => v.identifier === identifier)?.value;
3630
+ if (raw === void 0 || raw === null || Array.isArray(raw))
3631
+ return null;
3632
+ const parsed = parseFloat(raw.toString());
3633
+ return Number.isNaN(parsed) ? null : parsed;
3634
+ }
3635
+
3636
+ // ../qti-test/dist/internal/item-session-facts.js
3637
+ function itemSessionFacts(model, itemFacts, items, { current, presented }) {
3638
+ const facts = /* @__PURE__ */ new Map();
3639
+ for (const testPart of model.testParts) {
3640
+ const order = itemRefsInOrder(testPart.sections);
3641
+ const currentIndex = order.findIndex((item) => item.identifier === current);
3642
+ order.forEach((item, index) => {
3643
+ const context = items?.find((candidate) => candidate.identifier === item.identifier);
3644
+ facts.set(item.identifier, {
3645
+ ...attemptsOf(context),
3646
+ sessionControl: item.sessionControl,
3647
+ adaptive: itemFacts?.get(item.identifier)?.adaptive ?? false,
3648
+ navigationMode: testPart.navigationMode,
3649
+ submissionMode: testPart.submissionMode,
3650
+ presented: presented.has(item.identifier),
3651
+ passed: testPart.navigationMode === "linear" && currentIndex >= 0 && index < currentIndex
3652
+ });
3653
+ });
3225
3654
  }
3226
- };
3227
- __decorate16([
3228
- property12({ type: String, attribute: "item-id" })
3229
- ], TestItemLink.prototype, "itemId", void 0);
3655
+ return facts;
3656
+ }
3657
+ function attemptsOf(context) {
3658
+ const value = (identifier) => context?.variables?.find((v) => v.identifier === identifier)?.value;
3659
+ const completionStatus = value("completionStatus");
3660
+ return {
3661
+ numAttempts: Number(value("numAttempts")) || 0,
3662
+ completionStatus: typeof completionStatus === "string" ? completionStatus : null
3663
+ };
3664
+ }
3230
3665
 
3231
- // ../qti-test/dist/components/test-item-to-speech/test-item-to-speech.js
3232
- import { html as html14, LitElement as LitElement15, css as css9 } from "lit";
3233
- import { consume as consume9, provide as provide3, createContext as createContext2 } from "@lit/context";
3234
- import { property as property13, state as state4 } from "lit/decorators.js";
3235
- import { ifDefined } from "lit/directives/if-defined.js";
3236
- var __decorate17 = function(decorators, target, key, desc) {
3237
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3238
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3239
- 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;
3240
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3241
- };
3242
- var HIGHLIGHT_ELEMENT = "tts-element";
3243
- var HIGHLIGHT_WORD = "tts-word";
3244
- var highlightSheet = null;
3245
- function getHighlightSheet() {
3246
- if (!highlightSheet) {
3247
- highlightSheet = new CSSStyleSheet();
3248
- highlightSheet.replaceSync(`
3249
- ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
3250
- ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
3251
- `);
3252
- }
3253
- return highlightSheet;
3254
- }
3255
- var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
3256
- var ICONS = {
3257
- play: "M8 5v14l11-7z",
3258
- pause: "M6 5h4v14H6zM14 5h4v14h-4z",
3259
- stop: "M6 6h12v12H6z",
3260
- prev: "M6 5h2v14H6zM20 5v14L9 12z",
3261
- next: "M16 5h2v14h-2zM4 5v14l11-7z",
3262
- pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
3263
- };
3264
- var iconContent = (icon, label) => {
3265
- const svg = html14`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
3266
- <path d="${ICONS[icon]}"></path>
3267
- </svg>`;
3268
- return html14`${svg}<span class="label">${label}</span>`;
3269
- };
3270
- var TtsButtonBase = class extends LitElement15 {
3271
- static {
3272
- this.styles = css9`
3273
- :host {
3274
- display: inline-flex;
3275
- }
3276
- button {
3277
- ${btn};
3278
- min-inline-size: var(--test-button-size, 2.25rem);
3279
- padding-inline: 0.5rem;
3280
- /* Containing block for the visually hidden .label. Without it the label is placed against
3281
- the nearest positioned ancestor, which can sit outside a scroll container and make the
3282
- page as tall as the scrolled content. */
3283
- position: relative;
3284
- }
3285
- button:hover:not(:disabled) {
3286
- ${btnInteractive};
3287
- }
3288
- button:focus-visible {
3289
- ${focusRing};
3290
- }
3291
- button:disabled {
3292
- ${dis};
3293
- }
3294
- button[aria-pressed='true'],
3295
- button[aria-pressed='true']:hover {
3296
- background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
3297
- color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
3298
- }
3299
- svg,
3300
- ::slotted(svg) {
3301
- flex: none;
3302
- inline-size: var(--test-tts-icon-size, 1.125rem);
3303
- block-size: var(--test-tts-icon-size, 1.125rem);
3304
- }
3305
- svg {
3306
- fill: currentColor;
3307
- }
3308
- /* The default content is icon-only; this keeps the button's accessible name. */
3309
- .label {
3310
- position: absolute;
3311
- inline-size: 1px;
3312
- block-size: 1px;
3313
- overflow: hidden;
3314
- clip-path: inset(50%);
3315
- white-space: nowrap;
3316
- }
3317
- `;
3318
- }
3319
- #internals = this.attachInternals();
3320
- #mirroredState;
3321
- #mirroredPicking = false;
3322
- updated(_changed) {
3323
- const state9 = this._tts?.state;
3324
- const picking = this._tts?.picking ?? false;
3325
- if (state9 === this.#mirroredState && picking === this.#mirroredPicking)
3326
- return;
3327
- this.#mirroredState = state9;
3328
- this.#mirroredPicking = picking;
3329
- this.#internals.states.clear();
3330
- if (state9)
3331
- this.#internals.states.add(state9);
3332
- if (picking)
3333
- this.#internals.states.add("picking");
3334
- }
3335
- };
3336
- __decorate17([
3337
- property13({ type: String })
3338
- ], TtsButtonBase.prototype, "label", void 0);
3339
- __decorate17([
3340
- consume9({ context: ttsContext, subscribe: true })
3341
- ], TtsButtonBase.prototype, "_tts", void 0);
3342
- var TestItemToSpeech = class extends LitElement15 {
3343
- static {
3344
- this.styles = css9`
3345
- :host {
3346
- display: inline-flex;
3347
- flex-wrap: wrap;
3348
- align-items: center;
3349
- gap: var(--test-tts-gap, 0.25rem);
3350
- }
3351
- `;
3352
- }
3353
- #internals;
3354
- // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
3355
- // placeholder itself is looked up on every use — a host may swap the element.
3356
- #stimulusMode;
3357
- // Stimulus mode: resets the player when the stimulus content next to it is replaced.
3358
- #stimulusObserver;
3359
- // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
3360
- // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
3361
- #contentMode;
3362
- // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
3363
- #itemRef;
3364
- // Where the item-connected (and, in cursor mode, navigation) events are listened for.
3365
- #eventHost;
3366
- #boundHandleItemConnected;
3367
- #boundHandleNavigation;
3368
- // Cursor mode: the previous navigation position, to detect moving to another item or section.
3369
- #prevNavItemRefId;
3370
- #prevNavSectionId;
3371
- // Current set of block-level reading elements for the item
3372
- #readingElements;
3373
- #currentElementIndex;
3374
- // Text nodes of the element currently being spoken (for word-boundary highlight)
3375
- #textNodes;
3376
- // The utterance this player is speaking; lets the error handler tell "our speech was
3377
- // cancelled by another player" apart from a cancel we issued ourselves.
3378
- #currentUtterance;
3379
- // Pick mode: all elements highlighted, a click on one starts reading from there.
3380
- #picking;
3381
- #pickRoot;
3382
- #boundHandlePickClick;
3383
- // Set when the last element has been read: the cursor stays on it (so prev still works),
3384
- // but the next play starts the item over instead of repeating that last element.
3385
- #finished;
3386
- // Two separate CSS Highlight objects
3387
- #elementHighlight;
3388
- // whole-element cursor
3389
- #wordHighlight;
3390
- // current word during speech
3391
- constructor() {
3392
- super();
3393
- this.language = "nl-NL";
3394
- this.#internals = this.attachInternals();
3395
- this.#stimulusMode = false;
3396
- this.#stimulusObserver = null;
3397
- this.#contentMode = false;
3398
- this.#itemRef = null;
3399
- this.#eventHost = null;
3400
- this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
3401
- this.#boundHandleNavigation = () => this.#stop();
3402
- this.#prevNavItemRefId = void 0;
3403
- this.#prevNavSectionId = void 0;
3404
- this.#readingElements = null;
3405
- this.#currentElementIndex = 0;
3406
- this.#textNodes = [];
3407
- this.#currentUtterance = null;
3408
- this.#picking = false;
3409
- this.#pickRoot = null;
3410
- this.#boundHandlePickClick = this.#handlePickClick.bind(this);
3411
- this.#finished = false;
3412
- this.#elementHighlight = new Highlight();
3413
- this.#wordHighlight = new Highlight();
3414
- this._ttsContext = {
3415
- state: "idle",
3416
- currentElementIndex: 0,
3417
- elementCount: 0,
3418
- play: () => this.#playSpeech(),
3419
- pause: () => this.#pause(),
3420
- resume: () => this.#resume(),
3421
- stop: () => {
3422
- this.#stopPicking();
3423
- this.#stop();
3424
- },
3425
- prevElement: () => this.#prevElement(),
3426
- nextElement: () => this.#nextElement(),
3427
- togglePick: () => this.#togglePick(),
3428
- picking: false
3429
- };
3430
- }
3431
- // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
3432
- // render already under way instead of scheduling a second one (Lit's change-in-update).
3433
- willUpdate(changed) {
3434
- super.willUpdate(changed);
3435
- if (this.#stimulusMode || this.#contentMode || this.#itemRef)
3436
- return;
3437
- const item = this._sessionContext?.navItemRefId ?? null;
3438
- const section = this._sessionContext?.navSectionId ?? null;
3439
- const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
3440
- const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
3441
- if (itemChanged || sectionChanged)
3442
- this.#resetReadingPosition();
3443
- this.#prevNavItemRefId = item;
3444
- this.#prevNavSectionId = section;
3445
- }
3446
- /** Stop speech and forget the collected reading elements, so the next play starts afresh. */
3447
- #resetReadingPosition() {
3448
- this.#stopPicking();
3449
- this.#stop();
3450
- this.#readingElements = null;
3451
- this.#currentElementIndex = 0;
3452
- this.#finished = false;
3453
- this.#updateContext();
3454
- }
3455
- connectedCallback() {
3456
- super.connectedCallback();
3457
- this.#setSpeechState("idle");
3458
- this.#stimulusMode = this.#stimulusPlaceholder() !== null;
3459
- if (this.#stimulusMode) {
3460
- this.#stimulusObserver = new MutationObserver((records) => {
3461
- if (records.some((record) => !this.contains(record.target)))
3462
- this.#handleStimulusReplaced();
3463
- });
3464
- this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
3465
- return;
3466
- }
3467
- this.#contentMode = this.#contentElement() !== null;
3468
- if (this.#contentMode)
3469
- return;
3470
- this.#itemRef = this.closest("qti-assessment-item-ref");
3471
- this.#eventHost = this.#itemRef ?? this.closest("test-navigation") ?? this.testHost ?? this.getRootNode();
3472
- this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
3473
- if (!this.#itemRef) {
3474
- this.#eventHost.addEventListener("cito-test-navigate", this.#boundHandleNavigation);
3475
- this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
3476
- }
3477
- }
3478
- disconnectedCallback() {
3479
- super.disconnectedCallback();
3480
- if (this.#currentUtterance) {
3481
- this.#currentUtterance = null;
3482
- speechSynthesis.cancel();
3483
- }
3484
- this.#stopPicking();
3485
- this.#clearAllHighlights();
3486
- this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
3487
- this.#eventHost?.removeEventListener("cito-test-navigate", this.#boundHandleNavigation);
3488
- this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
3489
- this.#eventHost = null;
3490
- this.#itemRef = null;
3491
- this.#stimulusObserver?.disconnect();
3492
- this.#stimulusObserver = null;
3493
- this.#stimulusMode = false;
3494
- this.#contentMode = false;
3495
- }
3496
- render() {
3497
- return html14`<slot></slot>`;
3498
- }
3499
- /**
3500
- * An item (re)rendered. If it is ours — e.g. after navigating to the item already shown — the
3501
- * elements collected earlier are detached now. That does not move the navigation cursor, so
3502
- * the check in updated() does not catch it.
3503
- */
3504
- #handleItemConnected(event) {
3505
- if (this.#readingElements === null)
3506
- return;
3507
- const identifier = event.detail?.identifier;
3508
- if (this.#itemRef || identifier === this._sessionContext?.navItemRefId)
3509
- this.#resetReadingPosition();
3510
- }
3511
- /**
3512
- * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
3513
- * collected, so the next play reads the new content from the top. Unlike
3514
- * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
3515
- * while an item player on the same page is speaking.
3516
- */
3517
- #handleStimulusReplaced() {
3518
- if (this.#currentUtterance) {
3519
- this.#currentUtterance = null;
3520
- speechSynthesis.cancel();
3521
- }
3522
- this.#stopPicking();
3523
- this.#clearAllHighlights();
3524
- this.#setSpeechState("idle");
3525
- this.#readingElements = null;
3526
- this.#currentElementIndex = 0;
3527
- this.#finished = false;
3528
- this.#updateContext();
3529
- }
3530
- /**
3531
- * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
3532
- * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
3533
- * loading replaces the placeholder's content.
3534
- */
3535
- #stimulusPlaceholder() {
3536
- return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
3537
- }
3538
- /**
3539
- * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
3540
- * The marker goes on one container; the player finds the readable elements inside it.
3541
- */
3542
- #contentElement() {
3543
- return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
3544
- }
3545
- /**
3546
- * The element whose text is read: the stimulus body next to the player (stimulus mode), the
3547
- * marked content next to it (content mode), or the item body of the item to read.
3548
- */
3549
- #resolveReadingRoot() {
3550
- if (this.#stimulusMode)
3551
- return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
3552
- if (this.#contentMode)
3553
- return this.#contentElement();
3554
- return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
3555
- }
3556
- /** The item to read: our item-ref's (item-ref mode), or the navigated one (cursor mode). */
3557
- #resolveItem() {
3558
- if (this.#itemRef)
3559
- return this.#itemRef.assessmentItem;
3560
- const identifier = this._sessionContext?.navItemRefId;
3561
- return identifier ? this.#findItemInDom(identifier) : null;
3562
- }
3563
- /**
3564
- * Cursor mode: find the rendered item for an item-ref identifier. Our own `<qti-test>` first —
3565
- * a page can hold several tests showing the same item — then every root from here up to the
3566
- * document; each scope directly and in the `test-container` shadow roots inside it.
3567
- */
3568
- #findItemInDom(identifier) {
3569
- const selector = `qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"] qti-assessment-item`;
3570
- const search = (scope) => {
3571
- const direct = scope.querySelector(selector);
3572
- if (direct)
3573
- return direct;
3574
- for (const container of Array.from(scope.querySelectorAll("test-container"))) {
3575
- const inShadow = container.shadowRoot?.querySelector(selector);
3576
- if (inShadow)
3577
- return inShadow;
3578
- }
3579
- return null;
3580
- };
3581
- const test = this.closest("qti-test");
3582
- const inTest = test && search(test);
3583
- if (inTest)
3584
- return inTest;
3585
- let root = this.getRootNode();
3586
- for (; ; ) {
3587
- const found = search(root);
3588
- if (found)
3589
- return found;
3590
- const host = root.host;
3591
- if (!host)
3592
- return null;
3593
- root = host.getRootNode();
3594
- }
3595
- }
3596
- /** Update speech state on both the context (notifies children) and the host's CSS custom states. */
3597
- #setSpeechState(state9) {
3598
- this._ttsContext = { ...this._ttsContext, state: state9 };
3599
- this.#internals.states.delete("idle");
3600
- this.#internals.states.delete("playing");
3601
- this.#internals.states.delete("paused");
3602
- this.#internals.states.add(state9);
3603
- }
3604
- /** Push currentElementIndex and elementCount into context so children can react. */
3605
- #updateContext() {
3606
- this._ttsContext = {
3607
- ...this._ttsContext,
3608
- currentElementIndex: this.#currentElementIndex,
3609
- elementCount: this.#getReadingElements().length
3610
- };
3611
- }
3612
- /**
3613
- * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
3614
- * first call), filtered live for visibility on every call. Feedback and other
3615
- * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
3616
- * CSS custom state reveals it) is excluded while hidden and picked up again once shown,
3617
- * without needing to re-collect the candidate set.
3618
- */
3619
- #getReadingElements() {
3620
- if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
3621
- this.#readingElements = null;
3622
- this.#currentElementIndex = 0;
3623
- this.#finished = false;
3624
- }
3625
- if (this.#readingElements === null) {
3626
- const root = this.#resolveReadingRoot();
3627
- if (!root)
3628
- return [];
3629
- const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
3630
- this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
3631
- }
3632
- return this.#readingElements.filter((el) => this.#isVisible(el));
3633
- }
3634
- /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
3635
- #isVisible(element) {
3636
- if (typeof element.checkVisibility === "function") {
3637
- return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
3638
- }
3639
- return element.getClientRects().length > 0;
3640
- }
3641
- /**
3642
- * Resolve the speech language for a reading element.
3643
- * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
3644
- * Empty `lang=""` is treated as absent.
3645
- */
3646
- #resolveLang(element) {
3647
- let node = element;
3648
- while (node) {
3649
- const lang = node.getAttribute("lang") || node.getAttribute("xml:lang");
3650
- if (lang?.trim())
3651
- return lang.trim();
3652
- node = node.parentElement ?? node.getRootNode().host ?? null;
3653
- }
3654
- const documentLang = document.documentElement.getAttribute("lang");
3655
- if (documentLang?.trim())
3656
- return documentLang.trim();
3657
- return this.language;
3658
- }
3659
- #playSpeech() {
3660
- const elements = this.#getReadingElements();
3661
- if (!elements.length) {
3662
- console.warn("test-item-to-speech: no readable elements found");
3663
- return;
3664
- }
3665
- this.#stopPicking();
3666
- speechSynthesis.cancel();
3667
- if (this.#finished) {
3668
- this.#finished = false;
3669
- this.#currentElementIndex = 0;
3670
- }
3671
- if (this.#contentMode && this.#currentElementIndex === 0)
3672
- this.#readingElements = null;
3673
- this.#speakElement(this.#currentElementIndex);
3674
- }
3675
- /** Speak the element at the given index, then auto-advance when it ends. */
3676
- #speakElement(index) {
3677
- const elements = this.#getReadingElements();
3678
- if (index >= elements.length) {
3679
- this.#clearWordHighlight();
3680
- this.#currentElementIndex = elements.length - 1;
3681
- if (elements.length > 0)
3682
- this.#highlightElement(elements[this.#currentElementIndex]);
3683
- this.#finished = true;
3684
- this.#setSpeechState("idle");
3685
- this.#updateContext();
3686
- return;
3687
- }
3688
- this.#currentElementIndex = index;
3689
- this.#finished = false;
3690
- this.#updateContext();
3691
- const element = elements[index];
3692
- element.scrollIntoView({ behavior: "smooth", block: "nearest" });
3693
- this.#highlightElement(element);
3694
- this.#textNodes = this.#collectTextNodes(element);
3695
- const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
3696
- if (!text.trim()) {
3697
- this.#speakElement(index + 1);
3698
- return;
3699
- }
3700
- const utterance = new SpeechSynthesisUtterance(text);
3701
- utterance.lang = this.#resolveLang(element);
3702
- utterance.rate = 1;
3703
- utterance.onboundary = (event) => {
3704
- if (event.name !== "word")
3705
- return;
3706
- this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
3707
- };
3708
- utterance.onend = () => {
3709
- if (this.#currentUtterance !== utterance)
3710
- return;
3711
- this.#currentUtterance = null;
3712
- this.#clearWordHighlight();
3713
- this.#speakElement(this.#currentElementIndex + 1);
3714
- };
3715
- utterance.onerror = () => {
3716
- if (this.#currentUtterance !== utterance)
3717
- return;
3718
- this.#currentUtterance = null;
3719
- this.#clearAllHighlights();
3720
- this.#setSpeechState("idle");
3721
- };
3722
- this.#currentUtterance = utterance;
3723
- speechSynthesis.speak(utterance);
3724
- this.#setSpeechState("playing");
3725
- }
3726
- #pause() {
3727
- speechSynthesis.pause();
3728
- this.#setSpeechState("paused");
3729
- }
3730
- #resume() {
3731
- speechSynthesis.resume();
3732
- this.#setSpeechState("playing");
3733
- }
3734
- #stop() {
3735
- this.#currentUtterance = null;
3736
- speechSynthesis.cancel();
3737
- this.#clearAllHighlights();
3738
- this.#setSpeechState("idle");
3739
- }
3740
- // ─── Pick mode ────────────────────────────────────────────────────────────
3741
- #togglePick() {
3742
- if (this.#picking)
3743
- this.#stopPicking();
3744
- else
3745
- this.#startPicking();
3746
- }
3747
- /** Highlight every reading element and wait for a click on one of them. */
3748
- #startPicking() {
3749
- if (this.#contentMode)
3750
- this.#readingElements = null;
3751
- const elements = this.#getReadingElements();
3752
- if (!elements.length) {
3753
- console.warn("test-item-to-speech: no readable elements found");
3754
- return;
3755
- }
3756
- this.#stop();
3757
- this.#picking = true;
3758
- this.#internals.states.add("picking");
3759
- this.#highlightElements(elements);
3760
- this.#pickRoot = elements[0].getRootNode();
3761
- this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
3762
- this._ttsContext = { ...this._ttsContext, picking: true };
3763
- }
3764
- #stopPicking() {
3765
- if (!this.#picking)
3766
- return;
3767
- this.#picking = false;
3768
- this.#internals.states.delete("picking");
3769
- this.#pickRoot?.removeEventListener("click", this.#boundHandlePickClick, true);
3770
- this.#pickRoot = null;
3771
- this.#clearAllHighlights();
3772
- this._ttsContext = { ...this._ttsContext, picking: false };
3773
- }
3774
- #handlePickClick(event) {
3775
- const elements = this.#getReadingElements();
3776
- const path = event.composedPath();
3777
- let index = elements.findIndex((el) => path.includes(el));
3778
- if (index < 0) {
3779
- const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
3780
- if (container)
3781
- index = elements.findIndex((el) => container.contains(el));
3782
- }
3783
- if (index < 0)
3784
- return;
3785
- event.preventDefault();
3786
- event.stopPropagation();
3787
- this.#stopPicking();
3788
- speechSynthesis.cancel();
3789
- this.#speakElement(index);
3790
- }
3791
- #prevElement() {
3792
- const elements = this.#getReadingElements();
3793
- if (!elements.length)
3794
- return;
3795
- this.#currentUtterance = null;
3796
- speechSynthesis.cancel();
3797
- this.#clearWordHighlight();
3798
- this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
3799
- this.#finished = false;
3800
- this.#updateContext();
3801
- const el = elements[this.#currentElementIndex];
3802
- el.scrollIntoView({ behavior: "smooth", block: "nearest" });
3803
- this.#highlightElement(el);
3804
- this.#setSpeechState("idle");
3805
- }
3806
- #nextElement() {
3807
- const elements = this.#getReadingElements();
3808
- if (!elements.length)
3809
- return;
3810
- this.#currentUtterance = null;
3811
- speechSynthesis.cancel();
3812
- this.#clearWordHighlight();
3813
- this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
3814
- this.#finished = false;
3815
- this.#updateContext();
3816
- const el = elements[this.#currentElementIndex];
3817
- el.scrollIntoView({ behavior: "smooth", block: "nearest" });
3818
- this.#highlightElement(el);
3819
- this.#setSpeechState("idle");
3820
- }
3821
- /** Walk text nodes without crossing shadow DOM boundaries. */
3822
- #collectTextNodes(root) {
3823
- const nodes = [];
3824
- const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
3825
- let node;
3826
- while (node = walker.nextNode()) {
3827
- if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
3828
- nodes.push(node);
3829
- }
3830
- }
3831
- return nodes;
3832
- }
3833
- /** Highlight the whole element as the navigation cursor (blue). */
3834
- #highlightElement(element) {
3835
- this.#highlightElements([element]);
3836
- }
3837
- /** Put the blue cursor highlight on several elements at once (pick mode). */
3838
- #highlightElements(elements) {
3839
- if (!("highlights" in CSS))
3840
- return;
3841
- this.#ensureHighlightStyles();
3842
- this.#elementHighlight.clear();
3843
- for (const element of elements) {
3844
- const range = new Range();
3845
- range.selectNodeContents(element);
3846
- this.#elementHighlight.add(range);
3847
- }
3848
- CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
3849
- }
3850
- /** Highlight the current word within #textNodes (yellow, during speech). */
3851
- #updateWordHighlight(charIndex, charLength) {
3852
- if (!("highlights" in CSS))
3853
- return;
3854
- this.#ensureHighlightStyles();
3855
- this.#wordHighlight.clear();
3856
- const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
3857
- const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));
3858
- let offset = 0;
3859
- let startNode = null;
3860
- let startOffset = 0;
3861
- let endNode = null;
3862
- let endOffset = 0;
3863
- for (const node of this.#textNodes) {
3864
- const len = node.textContent?.length ?? 0;
3865
- if (!startNode && offset + len > charIndex) {
3866
- startNode = node;
3867
- startOffset = charIndex - offset;
3868
- }
3869
- if (startNode && offset + len >= endIndex) {
3870
- endNode = node;
3871
- endOffset = endIndex - offset;
3872
- break;
3873
- }
3874
- offset += len;
3875
- }
3876
- if (startNode && endNode) {
3877
- const range = new Range();
3878
- range.setStart(startNode, startOffset);
3879
- range.setEnd(endNode, endOffset);
3880
- this.#wordHighlight.add(range);
3881
- CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);
3882
- }
3883
- }
3884
- #clearWordHighlight() {
3885
- if (!("highlights" in CSS))
3886
- return;
3887
- this.#wordHighlight.clear();
3888
- if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight)
3889
- CSS.highlights.delete(HIGHLIGHT_WORD);
3890
- }
3891
- #clearAllHighlights() {
3892
- if (!("highlights" in CSS))
3893
- return;
3894
- this.#clearWordHighlight();
3895
- this.#elementHighlight.clear();
3896
- if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
3897
- CSS.highlights.delete(HIGHLIGHT_ELEMENT);
3898
- }
3899
- /** Fallback word-length when charLength is 0. */
3900
- #wordLengthAt(charIndex, text) {
3901
- const right = text.slice(charIndex).search(/\s/);
3902
- return right < 0 ? text.length - charIndex : right;
3903
- }
3904
- /**
3905
- * Add ::highlight() rules both to test-container's shadow root (where highlighted
3906
- * text lives) and to the document (safety net — spec allows document rules to apply
3907
- * across shadow DOM). Called lazily on first highlight use so test-container is
3908
- * guaranteed to be in the DOM by the time navigation or speech starts.
3909
- */
3910
- #ensureHighlightStyles() {
3911
- if (!("highlights" in CSS))
3912
- return;
3913
- const sheet = getHighlightSheet();
3914
- if (!document.adoptedStyleSheets.includes(sheet)) {
3915
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
3916
- }
3917
- const roots = /* @__PURE__ */ new Set();
3918
- const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.testHost?.querySelector("test-container");
3919
- if (testContainer?.shadowRoot)
3920
- roots.add(testContainer.shadowRoot);
3921
- const ownRoot = this.getRootNode();
3922
- if (ownRoot instanceof ShadowRoot)
3923
- roots.add(ownRoot);
3924
- const itemRoot = this.#readingElements?.[0]?.getRootNode();
3925
- if (itemRoot instanceof ShadowRoot)
3926
- roots.add(itemRoot);
3927
- for (const root of roots) {
3928
- if (!root.adoptedStyleSheets.includes(sheet)) {
3929
- root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
3930
- }
3931
- }
3932
- }
3933
- };
3934
- __decorate17([
3935
- property13({ type: String })
3936
- ], TestItemToSpeech.prototype, "language", void 0);
3937
- __decorate17([
3938
- consume9({ context: sessionContext, subscribe: true })
3939
- ], TestItemToSpeech.prototype, "_sessionContext", void 0);
3940
- __decorate17([
3941
- consume9({ context: testHostContext, subscribe: true })
3942
- ], TestItemToSpeech.prototype, "testHost", void 0);
3943
- __decorate17([
3944
- state4(),
3945
- provide3({ context: ttsContext })
3946
- ], TestItemToSpeech.prototype, "_ttsContext", void 0);
3947
- var TestTtsPlay = class extends TtsButtonBase {
3948
- #toggle() {
3949
- if (!this._tts)
3950
- return;
3951
- if (this._tts.state === "idle")
3952
- this._tts.play();
3953
- else if (this._tts.state === "playing")
3954
- this._tts.pause();
3955
- else
3956
- this._tts.resume();
3957
- }
3958
- render() {
3959
- const playing = this._tts?.state === "playing";
3960
- return html14`
3961
- <button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
3962
- ${playing ? html14`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html14`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
3963
- </button>
3964
- `;
3965
- }
3966
- };
3967
- __decorate17([
3968
- property13({ type: String, attribute: "pause-label" })
3969
- ], TestTtsPlay.prototype, "pauseLabel", void 0);
3970
- var TestTtsPause = class extends TtsButtonBase {
3971
- render() {
3972
- return html14`
3973
- <button
3974
- part="button"
3975
- aria-label=${ifDefined(this.label)}
3976
- ?disabled=${this._tts?.state !== "playing"}
3977
- @click=${() => this._tts?.pause()}
3978
- >
3979
- <slot>${iconContent("pause", this.label ?? "Pause")}</slot>
3980
- </button>
3981
- `;
3982
- }
3983
- };
3984
- var TestTtsResume = class extends TtsButtonBase {
3985
- render() {
3986
- return html14`
3987
- <button
3988
- part="button"
3989
- aria-label=${ifDefined(this.label)}
3990
- ?disabled=${this._tts?.state !== "paused"}
3991
- @click=${() => this._tts?.resume()}
3992
- >
3993
- <slot>${iconContent("play", this.label ?? "Resume")}</slot>
3994
- </button>
3995
- `;
3996
- }
3997
- };
3998
- var TestTtsStop = class extends TtsButtonBase {
3999
- render() {
4000
- const idle = this._tts?.state === "idle" && !this._tts?.picking;
4001
- return html14`
4002
- <button part="button" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>
4003
- <slot>${iconContent("stop", this.label ?? "Stop")}</slot>
4004
- </button>
4005
- `;
4006
- }
4007
- };
4008
- var TestTtsPrev = class extends TtsButtonBase {
4009
- render() {
4010
- const collected = (this._tts?.elementCount ?? 0) > 0;
4011
- const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
4012
- return html14`
4013
- <button
4014
- part="button"
4015
- aria-label=${ifDefined(this.label)}
4016
- ?disabled=${collected && atStart}
4017
- @click=${() => this._tts?.prevElement()}
4018
- >
4019
- <slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
4020
- </button>
4021
- `;
4022
- }
4023
- };
4024
- var TestTtsNext = class extends TtsButtonBase {
4025
- render() {
4026
- const count = this._tts?.elementCount ?? 0;
4027
- const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
4028
- return html14`
4029
- <button
4030
- part="button"
4031
- aria-label=${ifDefined(this.label)}
4032
- ?disabled=${atEnd}
4033
- @click=${() => this._tts?.nextElement()}
4034
- >
4035
- <slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
4036
- </button>
4037
- `;
4038
- }
4039
- };
4040
- var TestTtsPick = class extends TtsButtonBase {
4041
- render() {
4042
- return html14`
4043
- <button
4044
- part="button"
4045
- aria-label=${ifDefined(this.label)}
4046
- aria-pressed=${this._tts?.picking ? "true" : "false"}
4047
- @click=${() => this._tts?.togglePick()}
4048
- >
4049
- <slot>${iconContent("pick", this.label ?? "Read from here")}</slot>
4050
- </button>
4051
- `;
4052
- }
4053
- };
4054
-
4055
- // ../qti-test/dist/components/test-navigation/test-navigation.js
4056
- import { ContextConsumer, consume as consume10, provide as provide4 } from "@lit/context";
4057
- import { html as html15, LitElement as LitElement16 } from "lit";
4058
- import { property as property14, state as state5 } from "lit/decorators.js";
4059
- var __decorate18 = function(decorators, target, key, desc) {
3666
+ // ../qti-test/dist/internal/rendered-markup.js
3667
+ function renderedMarkup(element) {
3668
+ return {
3669
+ nodeType: element.nodeType,
3670
+ localName: element.localName,
3671
+ get childNodes() {
3672
+ return Array.from(element.children, renderedMarkup);
3673
+ },
3674
+ getAttribute: (name) => element.getAttribute(name) ?? (name === "title" ? element.getAttribute("data-title") : null)
3675
+ };
3676
+ }
3677
+
3678
+ // ../qti-test/dist/components/test-navigation/test-navigation.js
3679
+ var __decorate15 = function(decorators, target, key, desc) {
4060
3680
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4061
3681
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4062
3682
  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;
@@ -4065,7 +3685,7 @@ var __decorate18 = function(decorators, target, key, desc) {
4065
3685
  var newQtiContext = () => ({
4066
3686
  QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
4067
3687
  });
4068
- var TestNavigation = class extends LitElement16 {
3688
+ var TestNavigation = class extends LitElement13 {
4069
3689
  /**
4070
3690
  * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
4071
3691
  * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
@@ -4110,6 +3730,15 @@ var TestNavigation = class extends LitElement16 {
4110
3730
  * doesn't flip `done` until the candidate ends the attempt.
4111
3731
  */
4112
3732
  #optimality;
3733
+ /**
3734
+ * Each item session's lifecycle state, by item-ref identifier, changed only through the lifecycle
3735
+ * table (`followItemSession` as the candidate moves, `endItemAttempt` when an attempt ends). It
3736
+ * lives here until `DeliveryState` holds it (roadmap 1, T3d); a session whose attempts change
3737
+ * outside an ended attempt (a restored or assigned state) is seeded again.
3738
+ */
3739
+ #sessions;
3740
+ /** Set while `auto-score-items` scores a change: that run is not the candidate ending an attempt. */
3741
+ #autoScoring;
4113
3742
  constructor() {
4114
3743
  super();
4115
3744
  this.identifier = void 0;
@@ -4128,12 +3757,15 @@ var TestNavigation = class extends LitElement16 {
4128
3757
  this.configContext = {};
4129
3758
  this.autoScoreItems = false;
4130
3759
  this.#optimality = /* @__PURE__ */ new Map();
4131
- listenPublic2(this, "cito-test-loaded", this.#handleTestConnected.bind(this));
4132
- this.addEventListener("qti-assessment-item-connected", this.#handleItemConnected.bind(this));
4133
- listenPublic(this, "cito-item-response-changed", this.#handleInteractionChanged.bind(this));
3760
+ this.#sessions = /* @__PURE__ */ new Map();
3761
+ this.#autoScoring = false;
3762
+ this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
3763
+ this.#lockedItems = /* @__PURE__ */ new WeakSet();
3764
+ listenPublic2(this, "qc-test-loaded", this.#handleTestConnected.bind(this));
3765
+ listenPublic(this, "qc-item-response-changed", this.#handleInteractionChanged.bind(this));
4134
3766
  this.addEventListener("qti-item-context-updated", this.#handleItemContextUpdated.bind(this));
4135
- listenPublic2(this, "cito-test-end-attempt", this.#handleTestEndAttempt.bind(this));
4136
- listenPublic2(this, "cito-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
3767
+ listenPublic2(this, "qc-test-end-attempt", this.#handleTestEndAttempt.bind(this));
3768
+ listenPublic2(this, "qc-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
4137
3769
  }
4138
3770
  /**
4139
3771
  * Latch whether an item reached its optimal outcome whenever it has just ended
@@ -4148,12 +3780,38 @@ var TestNavigation = class extends LitElement16 {
4148
3780
  const itemContext = event.detail.itemContext;
4149
3781
  if (!itemContext?.identifier)
4150
3782
  return;
4151
- const optimality = this.#assessOptimality(itemContext);
3783
+ const optimality = assessOptimality(itemContext);
4152
3784
  this.#optimality.set(itemContext.identifier, optimality);
3785
+ this.#endAttempt(itemContext);
4153
3786
  const computedItem = this.computedItemFor(itemContext.identifier);
4154
3787
  const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
4155
3788
  const completionStatus = itemContext.variables?.find((v) => v.identifier === "completionStatus")?.value;
4156
- this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.maxAttempts, computedItem?.adaptive, completionStatus));
3789
+ this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, isItemDone(numAttempts, optimality, computedItem?.sessionControl?.maxAttempts, computedItem?.adaptive, completionStatus));
3790
+ }
3791
+ /** Moves the item's session on for its ended attempt; an auto-scored change only updates its count. */
3792
+ #endAttempt(itemContext) {
3793
+ const facts = this.#sessionFacts().get(itemContext.identifier);
3794
+ if (!facts)
3795
+ return;
3796
+ const ended = { ...facts, ...attemptsOf(itemContext) };
3797
+ const previous = this.#sessions.get(itemContext.identifier);
3798
+ this.#sessions.set(itemContext.identifier, this.#autoScoring ? { state: previous?.state ?? followItemSession(void 0, ended).state, numAttempts: ended.numAttempts } : endItemAttempt(previous, ended));
3799
+ }
3800
+ /** The facts of every item session now: the model, the item facts, the contexts and the items on screen. */
3801
+ #sessionFacts() {
3802
+ if (!this.#model)
3803
+ return /* @__PURE__ */ new Map();
3804
+ const presented = new Set([...this.#testElement?.querySelectorAll("qti-assessment-item-ref") ?? []].filter((itemRef) => itemRef.assessmentItem).map((itemRef) => itemRef.identifier));
3805
+ return itemSessionFacts(this.#model, this._itemFacts, this._testContext?.items, {
3806
+ current: this._sessionContext?.navItemRefId,
3807
+ presented
3808
+ });
3809
+ }
3810
+ /** Moves every item session on for where the candidate is now. */
3811
+ #followSessions() {
3812
+ for (const [identifier, facts] of this.#sessionFacts()) {
3813
+ this.#sessions.set(identifier, followItemSession(this.#sessions.get(identifier), facts));
3814
+ }
4157
3815
  }
4158
3816
  /**
4159
3817
  * Extension point for presentation packages reacting to an ended attempt.
@@ -4171,9 +3829,11 @@ var TestNavigation = class extends LitElement16 {
4171
3829
  #assessmentItemFor(identifier) {
4172
3830
  if (!identifier)
4173
3831
  return void 0;
4174
- const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${identifier}"]`);
3832
+ const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"]`);
4175
3833
  return itemRef?.assessmentItem ?? void 0;
4176
3834
  }
3835
+ /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
3836
+ #itemElement;
4177
3837
  /** The currently active assessment item, exposed for optional presentation extensions. */
4178
3838
  get activeAssessmentItem() {
4179
3839
  if (!this.#testElement || !this._sessionContext?.navItemRefId)
@@ -4181,13 +3841,12 @@ var TestNavigation = class extends LitElement16 {
4181
3841
  return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
4182
3842
  }
4183
3843
  /**
4184
- * Handles the 'test-end-attempt' event.
4185
- * @private
4186
- * @listens TestNavigation#test-end-attempt
4187
- * @param {CustomEvent} event - The custom event object.
3844
+ * Ends an attempt: the item named by `detail.itemId` (a `test-end-attempt` stamped into an item, or
3845
+ * given an `item`), or else the item on screen.
4188
3846
  */
4189
- #handleTestEndAttempt(_event) {
4190
- const qtiAssessmentItemEl = this.activeAssessmentItem;
3847
+ #handleTestEndAttempt(event) {
3848
+ const itemId = event.detail?.itemId;
3849
+ const qtiAssessmentItemEl = itemId ? this.#assessmentItemFor(itemId) : this.activeAssessmentItem;
4191
3850
  if (!qtiAssessmentItemEl)
4192
3851
  return;
4193
3852
  const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
@@ -4207,17 +3866,23 @@ var TestNavigation = class extends LitElement16 {
4207
3866
  const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
4208
3867
  if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
4209
3868
  const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
4210
- assessmentItem.processResponse(true, reportValidityAfterScoring);
3869
+ this.#autoScoring = true;
3870
+ try {
3871
+ assessmentItem.processResponse(true, reportValidityAfterScoring);
3872
+ } finally {
3873
+ this.#autoScoring = false;
3874
+ }
4211
3875
  }
4212
3876
  }
4213
3877
  }
4214
3878
  render() {
4215
- return html15`<slot></slot>`;
3879
+ return html11`<slot></slot>`;
4216
3880
  }
4217
3881
  /* PK: on test connected we can build the computed context */
4218
3882
  #handleTestConnected(event) {
4219
3883
  this.#testElement = event.detail;
4220
3884
  this.#optimality.clear();
3885
+ this.#sessions.clear();
4221
3886
  if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
4222
3887
  const currentContext = this.qtiContext.QTI_CONTEXT || {
4223
3888
  testIdentifier: "",
@@ -4246,62 +3911,40 @@ var TestNavigation = class extends LitElement16 {
4246
3911
  });
4247
3912
  }
4248
3913
  });
4249
- const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
4250
- this.computedContext = {
4251
- identifier: this.#testElement.identifier,
4252
- title: this.#testElement.title,
4253
- view: this._sessionContext?.view,
4254
- testParts: testPartElements.map((testPart) => {
4255
- const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
4256
- const testPartSessionControl = testPart.querySelector(":scope > qti-item-session-control");
4257
- const partAllowSkipping = testPartSessionControl ? testPartSessionControl.allowSkipping : true;
4258
- const partMaxAttempts = testPartSessionControl ? testPartSessionControl.maxAttempts : 1;
4259
- const partShowFeedback = testPartSessionControl ? testPartSessionControl.showFeedback : false;
4260
- const partShowSolution = testPartSessionControl ? testPartSessionControl.showSolution : false;
4261
- return {
4262
- active: false,
4263
- identifier: testPart.identifier,
4264
- navigationMode: testPart.navigationMode,
4265
- submissionMode: testPart.submissionMode,
4266
- allowSkipping: partAllowSkipping,
4267
- sections: sectionElements.map((section) => {
4268
- const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
4269
- const sectionSessionControl = section.querySelector(":scope > qti-item-session-control");
4270
- const sectionAllowSkipping = sectionSessionControl ? sectionSessionControl.allowSkipping : partAllowSkipping;
4271
- const sectionMaxAttempts = sectionSessionControl ? sectionSessionControl.maxAttempts : partMaxAttempts;
4272
- const sectionShowFeedback = sectionSessionControl ? sectionSessionControl.showFeedback : partShowFeedback;
4273
- const sectionShowSolution = sectionSessionControl ? sectionSessionControl.showSolution : partShowSolution;
4274
- return {
4275
- active: false,
4276
- identifier: section.identifier,
4277
- title: section.title,
4278
- navigationMode: section.navigationMode,
4279
- submissionMode: section.submissionMode,
4280
- allowSkipping: sectionAllowSkipping,
4281
- items: itemElements.map((item) => {
4282
- const itemSessionControl = item.querySelector(":scope > qti-item-session-control");
4283
- const itemAllowSkipping = itemSessionControl ? itemSessionControl.allowSkipping : sectionAllowSkipping;
4284
- const itemMaxAttempts = itemSessionControl ? itemSessionControl.maxAttempts : sectionMaxAttempts;
4285
- const itemShowFeedback = itemSessionControl ? itemSessionControl.showFeedback : sectionShowFeedback;
4286
- const itemShowSolution = itemSessionControl ? itemSessionControl.showSolution : sectionShowSolution;
4287
- return {
4288
- ...this.initContext?.find((i) => i.identifier === item.identifier),
4289
- active: false,
4290
- identifier: item.identifier,
4291
- categories: item.category ? item.category?.split(" ") : [],
4292
- href: item.href,
4293
- variables: [],
4294
- allowSkipping: itemAllowSkipping,
4295
- maxAttempts: itemMaxAttempts,
4296
- showFeedback: itemShowFeedback,
4297
- showSolution: itemShowSolution
4298
- };
4299
- })
4300
- };
4301
- })
4302
- };
4303
- })
4304
- };
3914
+ this.#model = buildTestModel(renderedMarkup(this.#testElement));
3915
+ this.computedContext = this.#derive();
3916
+ }
3917
+ /** The test's structure and resolved session control, read from its markup when it is connected. */
3918
+ #model;
3919
+ /** `computedContext`, derived anew from its inputs (`deriveComputedContext`), never from the previous one. */
3920
+ #derive() {
3921
+ this.#seedOptimality();
3922
+ this.#followSessions();
3923
+ return deriveComputedContext({
3924
+ model: this.#model,
3925
+ itemFacts: this._itemFacts,
3926
+ testContext: this._testContext,
3927
+ sessionContext: this._sessionContext,
3928
+ infoItemCategory: this.configContext?.infoItemCategory,
3929
+ itemData: this.initContext,
3930
+ optimality: this.#optimality,
3931
+ lifecycle: new Map([...this.#sessions].map(([identifier, session]) => [identifier, session.state])),
3932
+ itemElement: this.#itemElement
3933
+ });
3934
+ }
3935
+ /**
3936
+ * On a restored session no attempt is ended this run, so the latch is seeded once from the
3937
+ * persisted context, which still holds the submitted response. A later change of the answer
3938
+ * leaves the seeded value alone.
3939
+ */
3940
+ #seedOptimality() {
3941
+ for (const itemContext of this._testContext?.items ?? []) {
3942
+ if (!itemContext.identifier || this.#optimality.has(itemContext.identifier))
3943
+ continue;
3944
+ const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
3945
+ if (numAttempts > 0)
3946
+ this.#optimality.set(itemContext.identifier, assessOptimality(itemContext));
3947
+ }
4305
3948
  }
4306
3949
  /**
4307
3950
  * Extract default values from a qti-context-declaration element
@@ -4340,297 +3983,112 @@ var TestNavigation = class extends LitElement16 {
4340
3983
  });
4341
3984
  return defaultValues;
4342
3985
  }
4343
- /* PK: on item connected we can add item only properties in the xml */
4344
- #handleItemConnected(event) {
4345
- const itemElement = event.detail;
4346
- this.computedContext = {
4347
- ...this.computedContext,
4348
- testParts: this.computedContext.testParts.map((testPart) => {
4349
- return {
4350
- ...testPart,
4351
- sections: testPart.sections.map((section) => {
4352
- return {
4353
- ...section,
4354
- items: section.items.map((item) => {
4355
- if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
4356
- return item;
4357
- }
4358
- const scoreOutcome = itemElement.querySelector("qti-outcome-declaration[identifier='SCORE']");
4359
- const externalScored = scoreOutcome?.getAttribute("externalScored");
4360
- const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
4361
- const containsCorrectResponse = Array.from(responseDeclarations).some((r) => r.querySelector("qti-correct-response"));
4362
- const containsMapping = Array.from(responseDeclarations).some((r) => {
4363
- const mapping = r.querySelector("qti-mapping");
4364
- const areaMapping = r.querySelector("qti-area-mapping");
4365
- return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
4366
- });
4367
- const hasCorrectResponse = containsCorrectResponse || containsMapping;
4368
- const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
4369
- return {
4370
- ...item,
4371
- assessmentItemIdentifier: itemElement.getAttribute("identifier"),
4372
- label: itemElement.getAttribute("label"),
4373
- title: itemElement.title,
4374
- externalScored,
4375
- adaptive: itemElement.adaptive == "true" || false,
4376
- timeDependent: itemElement.timeDependent == "true" || false,
4377
- variables: itemElement.variables,
4378
- hasCorrectResponse,
4379
- hasResponseProcessing
4380
- };
4381
- })
4382
- };
4383
- })
4384
- };
4385
- })
4386
- };
4387
- }
4388
- /* PK: on every change of the candidate we will recomputed the computedContext */
3986
+ /* On every change of the candidate's state, the context is derived again. */
4389
3987
  willUpdate(_changedProperties) {
4390
- if (!this.computedContext)
3988
+ if (!this.#model)
4391
3989
  return;
4392
- let itemIndex = 1;
4393
- this.computedContext = {
4394
- ...this.computedContext,
4395
- view: this._sessionContext?.view,
4396
- testParts: this.computedContext.testParts.map((testPart) => {
4397
- return {
4398
- ...testPart,
4399
- active: this._sessionContext?.navPartId === testPart.identifier || false,
4400
- sections: testPart.sections.map((section) => {
4401
- return {
4402
- ...section,
4403
- active: this._sessionContext?.navSectionId === section.identifier || false,
4404
- completed: section.items.every((item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"),
4405
- items: section.items.map((item) => {
4406
- const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
4407
- const computedItem = {
4408
- ...item,
4409
- ...itemContext,
4410
- ...this.initContext?.find((i) => i.identifier === item.identifier)
4411
- };
4412
- const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
4413
- const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
4414
- const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
4415
- const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
4416
- const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
4417
- const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
4418
- const valid = itemContext?.valid ?? true;
4419
- const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
4420
- const isDefaultResponse = responseVars.every((v) => {
4421
- if (v.value === void 0 || v.value === null) {
4422
- return true;
4423
- }
4424
- let fallbackValue;
4425
- switch (v.baseType) {
4426
- case "integer":
4427
- case "float":
4428
- case "duration":
4429
- fallbackValue = "0";
4430
- break;
4431
- case "boolean":
4432
- fallbackValue = "false";
4433
- break;
4434
- case "string":
4435
- case "directedPair":
4436
- case "identifier":
4437
- case "pair":
4438
- case "record":
4439
- default:
4440
- fallbackValue = "";
4441
- break;
4442
- }
4443
- const defaultValue = v.defaultValue ?? fallbackValue;
4444
- if (Array.isArray(v.value)) {
4445
- const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
4446
- return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
4447
- }
4448
- return v.value === defaultValue;
4449
- });
4450
- const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
4451
- const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
4452
- const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
4453
- let optimality = this.#optimality.get(computedItem.identifier);
4454
- if (optimality === void 0) {
4455
- optimality = itemContext ? this.#assessOptimality(itemContext) : "unscored";
4456
- if (numAttempts > 0)
4457
- this.#optimality.set(computedItem.identifier, optimality);
4458
- }
4459
- const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts, computedItem.adaptive, completionStatus);
4460
- return {
4461
- ...computedItem,
4462
- completionStatus,
4463
- numAttempts,
4464
- score,
4465
- response,
4466
- index,
4467
- active,
4468
- valid,
4469
- isDefaultResponse,
4470
- maxScore,
4471
- done,
4472
- // Reflects the last *ended* attempt only. Read the latch directly
4473
- // (not the `optimality` local) — the latch is written solely on
4474
- // responseProcessed / restore-seed (line above, guarded by
4475
- // numAttempts > 0), so a freshly-picked mid-attempt selection
4476
- // computed live is never stored and never counts as optimal.
4477
- optimal: this.#optimality.get(computedItem.identifier) === "optimal"
4478
- // type,
4479
- // correct,
4480
- // incorrect,
4481
- // completed
4482
- };
4483
- })
4484
- };
4485
- })
4486
- };
4487
- })
4488
- };
3990
+ this.computedContext = this.#derive();
4489
3991
  this.dispatchEvent(new CustomEvent("qti-computed-context-updated", {
4490
3992
  detail: this.computedContext,
4491
3993
  bubbles: true
4492
3994
  }));
4493
3995
  }
4494
- /**
4495
- * Decide whether an item should be treated as "the candidate is done with it"
4496
- * for the purpose of gating forward navigation and further attempts.
4497
- *
4498
- * - The candidate must have actually ended an attempt (numAttempts > 0).
4499
- * - Once attempted, the item is done if they reached the optimal outcome
4500
- * ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
4501
- * done while a better attempt is still possible ('suboptimal') and attempts
4502
- * remain — see #assessOptimality for how "optimal" is determined.
4503
- *
4504
- * `optimality` reflects the last *ended attempt* (see #optimality), not the
4505
- * live selection — so a freshly-picked optimal answer doesn't count as done
4506
- * until test-end-attempt evaluates it.
4507
- *
4508
- * Adaptive items decide this themselves: max-attempts does not apply to them
4509
- * (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads
4510
- * on to the next part of the item. They are done once their response
4511
- * processing sets completionStatus to 'completed'.
4512
- */
4513
- #isItemDone(numAttempts, optimality, maxAttempts, adaptive, completionStatus) {
4514
- if (numAttempts === 0)
4515
- return false;
4516
- if (adaptive)
4517
- return completionStatus === "completed";
4518
- if (optimality !== "suboptimal")
4519
- return true;
4520
- const max = maxAttempts ?? 1;
4521
- return max > 0 && numAttempts >= max;
3996
+ updated(changedProperties) {
3997
+ super.updated(changedProperties);
3998
+ this.#lockUsedItems();
4522
3999
  }
4000
+ /** The items this navigation disabled because their attempts are used, so it releases only those. */
4001
+ #lockedItems;
4523
4002
  /**
4524
- * Decide whether an item's submission is as good as it can get — i.e. the
4525
- * candidate reached the *optimal* outcome, so there's no reason to make them
4526
- * try again. 'optimal' means best achievable, 'suboptimal' means a better
4527
- * attempt is still possible, 'unscored' means there's nothing to judge against.
4528
- * ("optimal" is the spec's own word — a qti-correct-response is defined as
4529
- * "the (or an) optimal value".)
4530
- *
4531
- * Two signals, in order of authority:
4532
- * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).
4533
- * This correctly handles partial-credit / qti-mapping items, where an exact
4534
- * response match would under- or over-judge.
4535
- * 2. The declared qti-correct-response, for items that aren't scored (no
4536
- * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping
4537
- * variables like numAttempts can be typed 'response' but never declare a
4538
- * correctResponse, so we filter on a declared correctResponse.
4003
+ * Disables every rendered item whose attempts are used, from the computed context, so the
4004
+ * candidate cannot change the answer once the last attempt is ended. Runs after every update:
4005
+ * an item rendered later (another item, a section on screen, a restored state) is locked as it
4006
+ * arrives, and one whose attempts are back to zero (a new state) is released.
4539
4007
  *
4540
- * Items with neither a comparable score nor a correctResponse (essays, info
4541
- * items, etc.) are 'unscored' — there's no optimal value to require, so one
4542
- * attempt is enough.
4008
+ * Only `disabled = true` is ever set here, and only on an item that was not disabled already; a
4009
+ * host or view that disables or makes an item read-only itself keeps it so.
4543
4010
  */
4544
- #assessOptimality(item) {
4545
- const variables = item.variables ?? [];
4546
- const score = this.#numericVariable(variables, "SCORE");
4547
- const maxScore = this.#numericVariable(variables, "MAXSCORE");
4548
- if (score !== null && maxScore !== null) {
4549
- return score >= maxScore ? "optimal" : "suboptimal";
4550
- }
4551
- const responseVars = variables.filter((v) => v.type === "response" && v.correctResponse !== void 0 && v.correctResponse !== null);
4552
- if (responseVars.length === 0)
4553
- return "unscored";
4554
- const allMatch = responseVars.every((v) => {
4555
- const expected = v.correctResponse;
4556
- const actual = v.value;
4557
- if (actual === void 0 || actual === null)
4558
- return false;
4559
- if (Array.isArray(expected) && Array.isArray(actual)) {
4560
- return expected.length === actual.length && expected.every((e) => actual.includes(e));
4011
+ #lockUsedItems() {
4012
+ if (!this.#testElement || !this.computedContext)
4013
+ return;
4014
+ const items = new Map(this.computedContext.testParts.flatMap((part) => part.submissionMode === "simultaneous" ? [] : part.sections.flatMap((section) => section.items.map((item) => [item.identifier, item]))));
4015
+ for (const itemRef of this.#testElement.querySelectorAll("qti-assessment-item-ref")) {
4016
+ const element = itemRef.assessmentItem;
4017
+ if (!element)
4018
+ continue;
4019
+ const used = this.#attemptsUsed(items.get(itemRef.identifier), element);
4020
+ if (used && !element.disabled) {
4021
+ element.disabled = true;
4022
+ this.#lockedItems.add(element);
4023
+ } else if (!used && this.#lockedItems.has(element)) {
4024
+ this.#lockedItems.delete(element);
4025
+ element.disabled = false;
4561
4026
  }
4562
- if (Array.isArray(expected) || Array.isArray(actual))
4563
- return false;
4564
- return expected === actual;
4565
- });
4566
- return allMatch ? "optimal" : "suboptimal";
4027
+ }
4567
4028
  }
4568
- /** Read a single numeric outcome value, or null when absent / non-numeric. */
4569
- #numericVariable(variables, identifier) {
4570
- const raw = variables?.find((v) => v.identifier === identifier)?.value;
4571
- if (raw === void 0 || raw === null || Array.isArray(raw))
4572
- return null;
4573
- const parsed = parseFloat(raw.toString());
4574
- return Number.isNaN(parsed) ? null : parsed;
4029
+ /**
4030
+ * The same rule as `test-end-attempt`'s max-attempts guard: a non-adaptive item with a
4031
+ * `max-attempts` above 0 whose attempts reached it. Adaptive items end themselves, and 0 is
4032
+ * unlimited. With `auto-score-items` every change is scored as an attempt, so the count is not
4033
+ * the candidate's and locks nothing.
4034
+ */
4035
+ #attemptsUsed(item, element) {
4036
+ if (!item || this.autoScoreItems)
4037
+ return false;
4038
+ if (item.adaptive || element.adaptive === "true")
4039
+ return false;
4040
+ const maxAttempts = item.sessionControl?.maxAttempts ?? 1;
4041
+ return maxAttempts > 0 && (item.numAttempts ?? 0) >= maxAttempts;
4575
4042
  }
4576
4043
  };
4577
- __decorate18([
4578
- property14({ type: String })
4044
+ __decorate15([
4045
+ property12({ type: String })
4579
4046
  ], TestNavigation.prototype, "identifier", void 0);
4580
- __decorate18([
4047
+ __decorate15([
4581
4048
  state5()
4582
4049
  ], TestNavigation.prototype, "initContext", void 0);
4583
- __decorate18([
4050
+ __decorate15([
4584
4051
  state5(),
4585
- consume10({ context: configContext, subscribe: true })
4052
+ consume8({ context: configContext, subscribe: true })
4586
4053
  ], TestNavigation.prototype, "configContext", void 0);
4587
- __decorate18([
4054
+ __decorate15([
4588
4055
  state5(),
4589
- consume10({ context: testContext, subscribe: true })
4056
+ consume8({ context: testContext, subscribe: true })
4590
4057
  ], TestNavigation.prototype, "_testContext", void 0);
4591
- __decorate18([
4058
+ __decorate15([
4592
4059
  state5(),
4593
- consume10({ context: sessionContext, subscribe: true })
4060
+ consume8({ context: sessionContext, subscribe: true })
4594
4061
  ], TestNavigation.prototype, "_sessionContext", void 0);
4595
- __decorate18([
4062
+ __decorate15([
4063
+ state5(),
4064
+ consume8({ context: itemFactsContext, subscribe: true })
4065
+ ], TestNavigation.prototype, "_itemFacts", void 0);
4066
+ __decorate15([
4596
4067
  state5(),
4597
4068
  provide4({ context: computedContext })
4598
4069
  ], TestNavigation.prototype, "computedContext", void 0);
4599
- __decorate18([
4600
- property14({ type: Boolean, attribute: "auto-score-items" })
4070
+ __decorate15([
4071
+ property12({ type: Boolean, attribute: "auto-score-items" })
4601
4072
  ], TestNavigation.prototype, "autoScoreItems", void 0);
4602
4073
 
4603
4074
  // ../qti-test/dist/components/test-next/test-next.js
4604
- import { css as css10, html as html16, LitElement as LitElement17 } from "lit";
4605
- import { property as property15 } from "lit/decorators.js";
4606
- import { consume as consume11 } from "@lit/context";
4607
- var __decorate19 = function(decorators, target, key, desc) {
4075
+ import { LitElement as LitElement14 } from "lit";
4076
+ import { property as property13 } from "lit/decorators.js";
4077
+ import { consume as consume9 } from "@lit/context";
4078
+ var __decorate16 = function(decorators, target, key, desc) {
4608
4079
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4609
4080
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4610
4081
  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;
4611
4082
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4612
4083
  };
4613
- var TestNext = class extends LitElement17 {
4084
+ var TestNext = class extends LitElement14 {
4614
4085
  _handleTestElementChange(_oldValue, newValue) {
4615
4086
  if (newValue) {
4616
4087
  this.requestUpdate();
4617
4088
  }
4618
4089
  }
4619
4090
  static {
4620
- this.styles = css10`
4621
- :host {
4622
- ${btn};
4623
- }
4624
- :host(:hover:not([disabled])) {
4625
- ${btnInteractive};
4626
- }
4627
- :host(:focus-visible) {
4628
- ${focusRing};
4629
- }
4630
- :host([disabled]) {
4631
- ${dis};
4632
- }
4633
- `;
4091
+ this.styles = [button, buttonPrimary];
4634
4092
  }
4635
4093
  #internals;
4636
4094
  constructor() {
@@ -4655,7 +4113,7 @@ var TestNext = class extends LitElement17 {
4655
4113
  const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4656
4114
  if (!testPart)
4657
4115
  return;
4658
- this.sectionItems = testPart.sections.flatMap((section) => section.items);
4116
+ this.sectionItems = itemsInOrder(testPart);
4659
4117
  this.itemIndex = this.sectionItems.findIndex((item) => item.active);
4660
4118
  this.checkDisabled();
4661
4119
  }
@@ -4663,96 +4121,45 @@ var TestNext = class extends LitElement17 {
4663
4121
  const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4664
4122
  if (!testPart)
4665
4123
  return;
4666
- const activeSection = testPart.sections.find((s) => s.active);
4667
- const navigationMode = activeSection?.navigationMode || testPart.navigationMode;
4668
- const submissionMode = activeSection?.submissionMode || testPart.submissionMode;
4669
4124
  const activeItem = this.sectionItems[this.itemIndex];
4670
- const isLinearIndividual = navigationMode === "linear" && submissionMode === "individual";
4125
+ const isLinearIndividual = testPart.navigationMode === "linear" && testPart.submissionMode === "individual";
4671
4126
  this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 || isLinearIndividual && !activeItem?.done;
4672
4127
  }
4673
4128
  _requestItem(identifier) {
4674
- dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
4129
+ dispatchPublic(this, "qc-test-navigate", { type: "item", id: identifier });
4675
4130
  }
4676
4131
  render() {
4677
- return html16`<slot></slot>`;
4132
+ return control;
4678
4133
  }
4679
4134
  };
4680
- __decorate19([
4681
- property15({ type: Boolean, reflect: true, attribute: "disabled" })
4135
+ __decorate16([
4136
+ property13({ type: Boolean, reflect: true, attribute: "disabled" })
4682
4137
  ], TestNext.prototype, "_internalDisabled", void 0);
4683
- __decorate19([
4684
- consume11({ context: computedContext, subscribe: true })
4138
+ __decorate16([
4139
+ consume9({ context: computedContext, subscribe: true })
4685
4140
  ], TestNext.prototype, "computedContext", void 0);
4686
- __decorate19([
4141
+ __decorate16([
4687
4142
  watch("computedContext")
4688
4143
  ], TestNext.prototype, "_handleTestElementChange", null);
4689
4144
 
4690
- // ../qti-test/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js
4691
- import { html as html17, LitElement as LitElement18 } from "lit";
4692
- import { consume as consume12 } from "@lit/context";
4693
- var __decorate20 = function(decorators, target, key, desc) {
4694
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4695
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4696
- 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;
4697
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4698
- };
4699
- var TestPagingButtonsStamp = class extends LitElement18 {
4700
- #internals;
4701
- createRenderRoot() {
4702
- return this;
4703
- }
4704
- constructor() {
4705
- super();
4706
- this.#internals = this.attachInternals();
4707
- this.#internals.ariaLabel = "pagination";
4708
- }
4709
- connectedCallback() {
4710
- super.connectedCallback();
4711
- const templateElement = this.querySelector("template");
4712
- this.myTemplate = prepareTemplate(templateElement);
4713
- }
4714
- render() {
4715
- if (!this.computedContext)
4716
- return html17``;
4717
- const items = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items));
4718
- return html17` ${items.map((item) => this.myTemplate({ item, view: this.computedContext.view }))} `;
4719
- }
4720
- };
4721
- __decorate20([
4722
- consume12({ context: computedContext, subscribe: true })
4723
- ], TestPagingButtonsStamp.prototype, "computedContext", void 0);
4724
-
4725
4145
  // ../qti-test/dist/components/test-prev/test-prev.js
4726
- import { css as css11, html as html18, LitElement as LitElement19 } from "lit";
4727
- import { property as property16 } from "lit/decorators.js";
4728
- import { consume as consume13 } from "@lit/context";
4729
- var __decorate21 = function(decorators, target, key, desc) {
4146
+ import { LitElement as LitElement15 } from "lit";
4147
+ import { property as property14 } from "lit/decorators.js";
4148
+ import { consume as consume10 } from "@lit/context";
4149
+ var __decorate17 = function(decorators, target, key, desc) {
4730
4150
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4731
4151
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4732
4152
  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;
4733
4153
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4734
4154
  };
4735
- var TestPrev = class extends LitElement19 {
4155
+ var TestPrev = class extends LitElement15 {
4736
4156
  _handleTestElementChange(_oldValue, newValue) {
4737
4157
  if (newValue) {
4738
4158
  this.requestUpdate();
4739
4159
  }
4740
4160
  }
4741
4161
  static {
4742
- this.styles = css11`
4743
- :host {
4744
- ${btn};
4745
- }
4746
- :host(:hover:not([disabled])) {
4747
- ${btnInteractive};
4748
- }
4749
- :host(:focus-visible) {
4750
- ${focusRing};
4751
- }
4752
- :host([disabled]) {
4753
- ${dis};
4754
- }
4755
- `;
4162
+ this.styles = button;
4756
4163
  }
4757
4164
  constructor() {
4758
4165
  super();
@@ -4769,531 +4176,49 @@ var TestPrev = class extends LitElement19 {
4769
4176
  const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4770
4177
  if (!testPart)
4771
4178
  return;
4772
- this.sectionItems = testPart.sections.flatMap((section) => section.items);
4179
+ this.sectionItems = itemsInOrder(testPart);
4773
4180
  this.itemIndex = this.sectionItems.findIndex((item) => item.active);
4774
4181
  this.checkDisabled();
4775
4182
  }
4776
4183
  checkDisabled() {
4777
4184
  const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4778
- const activeSection = testPart?.sections.find((s) => s.active);
4779
- const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || "nonlinear";
4185
+ const navigationMode = testPart?.navigationMode ?? "nonlinear";
4780
4186
  this._internalDisabled = navigationMode === "linear" || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
4781
4187
  }
4782
4188
  _requestItem(identifier) {
4783
- dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
4189
+ dispatchPublic(this, "qc-test-navigate", { type: "item", id: identifier });
4784
4190
  }
4785
4191
  render() {
4786
- return html18`<slot></slot>`;
4192
+ return control;
4787
4193
  }
4788
4194
  };
4789
- __decorate21([
4790
- property16({ type: Boolean, reflect: true, attribute: "disabled" })
4195
+ __decorate17([
4196
+ property14({ type: Boolean, reflect: true, attribute: "disabled" })
4791
4197
  ], TestPrev.prototype, "_internalDisabled", void 0);
4792
- __decorate21([
4793
- consume13({ context: computedContext, subscribe: true })
4198
+ __decorate17([
4199
+ consume10({ context: computedContext, subscribe: true })
4794
4200
  ], TestPrev.prototype, "computedContext", void 0);
4795
- __decorate21([
4201
+ __decorate17([
4796
4202
  watch("computedContext")
4797
4203
  ], TestPrev.prototype, "_handleTestElementChange", null);
4798
4204
 
4799
- // ../qti-test/dist/components/test-print-context/test-print-context.js
4800
- import { html as html19, LitElement as LitElement20 } from "lit";
4801
- import { consume as consume14 } from "@lit/context";
4802
- import { state as state6 } from "lit/decorators.js";
4803
- var __decorate22 = function(decorators, target, key, desc) {
4804
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4805
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4806
- 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;
4807
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4808
- };
4809
- var TestPrintContext = class extends LitElement20 {
4810
- render() {
4811
- return html19` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
4812
- }
4813
- };
4814
- __decorate22([
4815
- state6(),
4816
- consume14({ context: computedContext, subscribe: true })
4817
- ], TestPrintContext.prototype, "computedContext", void 0);
4818
-
4819
- // ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
4820
- import { html as html20, css as css12, LitElement as LitElement21 } from "lit";
4821
- import { consume as consume15 } from "@lit/context";
4822
- var __decorate23 = function(decorators, target, key, desc) {
4823
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4824
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4825
- 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;
4826
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4827
- };
4828
- var TestPrintVariables = class extends LitElement21 {
4205
+ // ../qti-test/dist/components/test-submit/test-submit.js
4206
+ import { LitElement as LitElement16 } from "lit";
4207
+ var TestSubmit = class extends LitElement16 {
4829
4208
  static {
4830
- this.styles = css12`
4831
- table {
4832
- width: 100%;
4833
- border-collapse: collapse;
4834
- margin: 20px 0;
4835
- font-size: 14px;
4836
- text-align: left;
4837
- }
4838
- th,
4839
- td {
4840
- border: 1px solid #ddd;
4841
- padding: 8px;
4842
- }
4843
- th {
4844
- background-color: #f4f4f4;
4845
- font-weight: bold;
4846
- }
4847
- h3 {
4848
- margin-top: 20px;
4849
- font-size: 16px;
4850
- }
4851
- `;
4852
- }
4853
- render() {
4854
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4855
- if (!activeItem || !activeItem.variables)
4856
- return html20``;
4857
- const responseVariables = activeItem.variables.filter((v) => v.type === "response");
4858
- const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
4859
- const renderTable = (variables, title) => html20`
4860
- <h3>${title}</h3>
4861
- <table>
4862
- <thead>
4863
- <tr>
4864
- <th>Identifier</th>
4865
- <th>Value</th>
4866
- <th>Cardinality</th>
4867
- <th>Base Type</th>
4868
- <th>Correct Response / Mappings</th>
4869
- </tr>
4870
- </thead>
4871
- <tbody>
4872
- ${variables.map((v) => {
4873
- const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
4874
- const mapEntries = v.mapping?.mapEntries?.map((m) => `${m.mapKey}=${m.mappedValue}pt`).join(", ") || "";
4875
- const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m) => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ") || "";
4876
- return html20`
4877
- <tr>
4878
- <td>${v.identifier}</td>
4879
- <td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
4880
- <td>${v.cardinality}</td>
4881
- <td>${v.baseType}</td>
4882
- <td>${correctResponse || mapEntries || areaMapEntries}</td>
4883
- </tr>
4884
- `;
4885
- })}
4886
- </tbody>
4887
- </table>
4888
- `;
4889
- return html20`
4890
- ${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
4891
- `;
4892
- }
4893
- };
4894
- __decorate23([
4895
- consume15({ context: computedContext, subscribe: true })
4896
- ], TestPrintVariables.prototype, "computedContext", void 0);
4897
-
4898
- // ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
4899
- import { html as html21, LitElement as LitElement22, nothing as nothing3 } from "lit";
4900
- import { consume as consume16 } from "@lit/context";
4901
- import { property as property17 } from "lit/decorators.js";
4902
- var __decorate24 = function(decorators, target, key, desc) {
4903
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4904
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4905
- 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;
4906
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4907
- };
4908
- var TestScoringButtons = class extends LitElement22 {
4909
- createRenderRoot() {
4910
- return this;
4911
- }
4912
- connectedCallback() {
4913
- super.connectedCallback();
4914
- const templateElement = this.querySelector("template");
4915
- if (!templateElement) {
4916
- this.myTemplate = null;
4917
- return;
4918
- }
4919
- this.myTemplate = prepareTemplate(templateElement);
4920
- }
4921
- #changeOutcomeScore(value) {
4922
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4923
- const sectionItems = testPart.sections.flatMap((section) => section.items);
4924
- const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
4925
- dispatchPublic(this, "cito-test-update-outcome", {
4926
- assessmentItemRefId: currentItemIdentifier,
4927
- outcomeVariableId: "SCORE",
4928
- value
4929
- });
4930
- }
4931
- render() {
4932
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4933
- if (!activeItem || !activeItem.variables)
4934
- return html21``;
4935
- const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
4936
- const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
4937
- const score = scoreOutcome?.value;
4938
- const disabled = !(scoreOutcome?.externalScored === "human");
4939
- if (!maxScore || !scoreOutcome)
4940
- return nothing3;
4941
- const scores = [...Array(Number(maxScore) + 1).keys()];
4942
- return html21`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing3}`;
4209
+ this.styles = button;
4943
4210
  }
4944
4211
  constructor() {
4945
4212
  super();
4946
- this.view = "";
4947
- this.disabled = false;
4948
- this.myTemplate = null;
4949
- this.addEventListener("click", (e) => {
4950
- const target = e.target;
4951
- const value = parseFloat(target.value);
4952
- if (target.tagName === "INPUT") {
4953
- this.#changeOutcomeScore(value);
4954
- }
4955
- });
4956
- }
4957
- };
4958
- __decorate24([
4959
- property17({ type: String, attribute: "view" })
4960
- ], TestScoringButtons.prototype, "view", void 0);
4961
- __decorate24([
4962
- property17({ type: Boolean })
4963
- ], TestScoringButtons.prototype, "disabled", void 0);
4964
- __decorate24([
4965
- consume16({ context: computedContext, subscribe: true })
4966
- ], TestScoringButtons.prototype, "computedContext", void 0);
4967
-
4968
- // ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
4969
- import { consume as consume17 } from "@lit/context";
4970
- import { html as html22, LitElement as LitElement23 } from "lit";
4971
- import { property as property18 } from "lit/decorators.js";
4972
- var __decorate25 = function(decorators, target, key, desc) {
4973
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4974
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4975
- 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;
4976
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4977
- };
4978
- var TestScoringFeedback = class extends LitElement23 {
4979
- constructor() {
4980
- super(...arguments);
4981
- this.view = null;
4213
+ this.addEventListener("click", () => dispatchPublic(this, "qc-test-submit", {}));
4982
4214
  }
4983
4215
  render() {
4984
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4985
- if (!activeItem || !activeItem.variables)
4986
- return html22``;
4987
- if (activeItem["category"] === "dep-informational")
4988
- return html22`<div>${this.dataset.informational}</div>`;
4989
- const completionStatus = activeItem?.variables.find((v) => v.identifier === "completionStatus")?.value;
4990
- const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
4991
- const score = parseFloat(scoreOutcome?.value);
4992
- const externalScored = activeItem["externalScored"];
4993
- const feedbackText = () => {
4994
- if (completionStatus !== "completed") {
4995
- return this.dataset.textNoResponse;
4996
- }
4997
- if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
4998
- return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
4999
- }
5000
- if (externalScored === "externalMachine") {
5001
- 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.`;
5002
- }
5003
- if (externalScored === "human") {
5004
- return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
5005
- }
5006
- return this.dataset.inProgress;
5007
- };
5008
- return html22`<div>${feedbackText()}</div>`;
4216
+ return control;
5009
4217
  }
5010
4218
  };
5011
- __decorate25([
5012
- consume17({ context: computedContext, subscribe: true })
5013
- ], TestScoringFeedback.prototype, "computedContext", void 0);
5014
- __decorate25([
5015
- property18({ type: String, attribute: "view" })
5016
- ], TestScoringFeedback.prototype, "view", void 0);
5017
4219
 
5018
- // ../qti-test/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js
5019
- import { html as html23, LitElement as LitElement24 } from "lit";
5020
- import { consume as consume18 } from "@lit/context";
5021
- var __decorate26 = function(decorators, target, key, desc) {
5022
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5023
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5024
- 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;
5025
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5026
- };
5027
- var TestSectionButtonsStamp = class extends LitElement24 {
5028
- #internals;
5029
- createRenderRoot() {
5030
- return this;
5031
- }
5032
- constructor() {
5033
- super();
5034
- this.#internals = this.attachInternals();
5035
- this.#internals.ariaLabel = "pagination";
5036
- }
5037
- connectedCallback() {
5038
- super.connectedCallback();
5039
- const templateElement = this.querySelector("template");
5040
- this.myTemplate = prepareTemplate(templateElement);
5041
- }
5042
- render() {
5043
- if (!this.computedContext)
5044
- return html23``;
5045
- const sections = this.computedContext.testParts.flatMap((testPart) => testPart.sections);
5046
- return html23` ${sections.map((item) => this.myTemplate({ item }))} `;
5047
- }
5048
- };
5049
- __decorate26([
5050
- consume18({ context: computedContext, subscribe: true })
5051
- ], TestSectionButtonsStamp.prototype, "computedContext", void 0);
5052
-
5053
- // ../qti-test/dist/components/test-section-link/test-section-link.js
5054
- import { css as css13, html as html24, LitElement as LitElement25 } from "lit";
5055
- import { property as property19 } from "lit/decorators.js";
5056
- var __decorate27 = function(decorators, target, key, desc) {
5057
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5058
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5059
- 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;
5060
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5061
- };
5062
- var TestSectionLink = class extends LitElement25 {
5063
- static {
5064
- this.styles = css13`
5065
- :host {
5066
- ${btn};
5067
- }
5068
- :host(:hover:not([disabled])) {
5069
- ${btnInteractive};
5070
- }
5071
- :host(:focus-visible) {
5072
- ${focusRing};
5073
- }
5074
- :host([disabled]) {
5075
- ${dis};
5076
- }
5077
- `;
5078
- }
5079
- #requestItem(identifier) {
5080
- dispatchPublic(this, "cito-test-navigate", { type: "section", id: identifier });
5081
- }
5082
- constructor() {
5083
- super();
5084
- this.sectionId = null;
5085
- this.addEventListener("click", () => this.#requestItem(this.sectionId));
5086
- }
5087
- render() {
5088
- return html24` <slot></slot> `;
5089
- }
5090
- };
5091
- __decorate27([
5092
- property19({ type: String, attribute: "section-id" })
5093
- ], TestSectionLink.prototype, "sectionId", void 0);
5094
-
5095
- // ../qti-test/dist/components/test-stamp/test-stamp.js
5096
- import { html as html25, LitElement as LitElement26, nothing as nothing4 } from "lit";
5097
- import { property as property20, state as state7 } from "lit/decorators.js";
5098
- import { consume as consume19 } from "@lit/context";
5099
- var __decorate28 = function(decorators, target, key, desc) {
5100
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5101
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5102
- 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;
5103
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5104
- };
5105
- var TestStamp = class extends LitElement26 {
5106
- constructor() {
5107
- super(...arguments);
5108
- this.debug = false;
5109
- this.stampContext = {
5110
- view: "candidate",
5111
- activeItem: {},
5112
- activeSection: {
5113
- items: []
5114
- },
5115
- activeTestpart: {
5116
- items: [],
5117
- sections: []
5118
- },
5119
- test: {}
5120
- };
5121
- }
5122
- createRenderRoot() {
5123
- return this;
5124
- }
5125
- connectedCallback() {
5126
- super.connectedCallback();
5127
- const templateElement = this.querySelector("template");
5128
- if (!templateElement) {
5129
- this.myTemplate = null;
5130
- return;
5131
- }
5132
- this.myTemplate = prepareTemplate(templateElement);
5133
- }
5134
- willUpdate(_changedProperties) {
5135
- if (!this.computedContext) {
5136
- return;
5137
- }
5138
- const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
5139
- const activeSection = activeTestPart?.sections.find((section) => section.active);
5140
- const activeItem = activeSection?.items.find((item) => item.active);
5141
- const { variables, ...augmentedItem } = activeItem || {};
5142
- if (!activeTestPart || !activeSection || !activeItem) {
5143
- return;
5144
- }
5145
- const augmentedTestPart = {
5146
- ...activeTestPart,
5147
- items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables: variables2, ...rest }) => rest)),
5148
- sections: activeTestPart.sections.map((section) => ({
5149
- ...section,
5150
- items: section.items.map(({ variables: variables2, ...rest }) => rest)
5151
- }))
5152
- };
5153
- const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables: variables2, ...rest }) => rest) };
5154
- const { testParts, ...activeTest } = this.computedContext;
5155
- this.stampContext = {
5156
- view: this.computedContext.view,
5157
- activeItem: augmentedItem,
5158
- activeSection: augmentedSection,
5159
- activeTestpart: augmentedTestPart,
5160
- test: activeTest
5161
- };
5162
- this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
5163
- detail: this.stampContext,
5164
- bubbles: true
5165
- }));
5166
- }
5167
- render() {
5168
- return html25` ${this.debug ? html25`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing4}
5169
- ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
5170
- }
5171
- };
5172
- __decorate28([
5173
- property20({ type: Boolean, reflect: true })
5174
- ], TestStamp.prototype, "debug", void 0);
5175
- __decorate28([
5176
- state7(),
5177
- consume19({ context: computedContext, subscribe: true })
5178
- ], TestStamp.prototype, "computedContext", void 0);
5179
- __decorate28([
5180
- state7()
5181
- ], TestStamp.prototype, "stampContext", void 0);
5182
-
5183
- // ../qti-test/dist/components/test-view-toggle/test-view.js
5184
- import { html as html26, LitElement as LitElement27 } from "lit";
5185
- import { property as property21, state as state8 } from "lit/decorators.js";
5186
- import { consume as consume20 } from "@lit/context";
5187
- var __decorate29 = function(decorators, target, key, desc) {
5188
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5189
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5190
- 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;
5191
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5192
- };
5193
- var _a;
5194
- var TestView = class extends LitElement27 {
5195
- constructor() {
5196
- super(...arguments);
5197
- this.label = "view";
5198
- this._handleViewOptionsChange = () => {
5199
- this.#updateViewOptions();
5200
- };
5201
- this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
5202
- }
5203
- static {
5204
- this.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
5205
- }
5206
- connectedCallback() {
5207
- super.connectedCallback();
5208
- this.#updateViewOptions();
5209
- }
5210
- #updateViewOptions() {
5211
- if (this.viewOptions) {
5212
- const options = this.viewOptions.split(",").map((opt) => opt.trim());
5213
- this._viewOptions = options.filter((opt) => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
5214
- } else {
5215
- this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
5216
- }
5217
- }
5218
- _switchView(view) {
5219
- dispatchPublic(this, "cito-test-switch-view", view);
5220
- }
5221
- render() {
5222
- return html26`
5223
- <label part="label" for="viewSelect">${this.label}</label>
5224
- <select
5225
- part="select"
5226
- id="viewSelect"
5227
- @change=${(e) => {
5228
- const el = e.target;
5229
- this._switchView(el.value);
5230
- }}
5231
- >
5232
- ${this._viewOptions.map((v) => html26`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
5233
- </select>
5234
- `;
5235
- }
5236
- };
5237
- _a = TestView;
5238
- __decorate29([
5239
- consume20({ context: sessionContext, subscribe: true })
5240
- ], TestView.prototype, "sessionContext", void 0);
5241
- __decorate29([
5242
- property21({ type: String })
5243
- ], TestView.prototype, "label", void 0);
5244
- __decorate29([
5245
- property21({ type: String, attribute: "view-options" })
5246
- ], TestView.prototype, "viewOptions", void 0);
5247
- __decorate29([
5248
- watch("viewOptions", { waitUntilFirstUpdate: true })
5249
- ], TestView.prototype, "_handleViewOptionsChange", void 0);
5250
- __decorate29([
5251
- state8()
5252
- ], TestView.prototype, "_viewOptions", void 0);
5253
-
5254
- // ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
5255
- import { consume as consume21 } from "@lit/context";
5256
- import { html as html27, LitElement as LitElement28, nothing as nothing5 } from "lit";
5257
- var __decorate30 = function(decorators, target, key, desc) {
5258
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5259
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5260
- 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;
5261
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5262
- };
5263
- var TestViewToggle = class extends LitElement28 {
5264
- createRenderRoot() {
5265
- return this;
5266
- }
5267
- connectedCallback() {
5268
- super.connectedCallback();
5269
- const templateElement = this.querySelector("template");
5270
- if (!templateElement) {
5271
- this.myTemplate = null;
5272
- return;
5273
- }
5274
- this.myTemplate = prepareTemplate(templateElement);
5275
- }
5276
- _switchView(view) {
5277
- dispatchPublic(this, "cito-test-switch-view", view);
5278
- }
5279
- firstUpdated(_changedProperties) {
5280
- this.addEventListener("click", () => {
5281
- if (this.sessionContext?.view === "scorer") {
5282
- this._switchView("candidate");
5283
- } else {
5284
- this._switchView("scorer");
5285
- }
5286
- });
5287
- }
5288
- render() {
5289
- return html27`${this.myTemplate ? this.myTemplate({
5290
- view: this.sessionContext?.view
5291
- }) : nothing5}`;
5292
- }
5293
- };
5294
- __decorate30([
5295
- consume21({ context: sessionContext, subscribe: true })
5296
- ], TestViewToggle.prototype, "sessionContext", void 0);
4220
+ // ../qti-test/dist/plugins/elements.js
4221
+ var pluginElements = [{ tag: "test-submit", ctor: TestSubmit }];
5297
4222
 
5298
4223
  // ../qti-test/dist/elements.js
5299
4224
  var qtiTestElements = [
@@ -5310,31 +4235,12 @@ var qtiTestElements = [
5310
4235
  { tag: "qti-test-feedback", ctor: QtiTestFeedback },
5311
4236
  { tag: "qti-test-part", ctor: QtiTestPart },
5312
4237
  { tag: "qti-test-variables", ctor: QtiTestVariables },
5313
- { tag: "test-check-item", ctor: TestCheckItem },
5314
4238
  { tag: "test-container", ctor: TestContainer },
5315
4239
  { tag: "test-end-attempt", ctor: TestEndAttempt },
5316
- { tag: "test-item-link", ctor: TestItemLink },
5317
- { tag: "test-item-to-speech", ctor: TestItemToSpeech },
5318
4240
  { tag: "test-navigation", ctor: TestNavigation },
5319
4241
  { tag: "test-next", ctor: TestNext },
5320
- { tag: "test-paging-buttons-stamp", ctor: TestPagingButtonsStamp },
5321
4242
  { tag: "test-prev", ctor: TestPrev },
5322
- { tag: "test-print-context", ctor: TestPrintContext },
5323
- { tag: "test-print-item-variables", ctor: TestPrintVariables },
5324
- { tag: "test-scoring-buttons", ctor: TestScoringButtons },
5325
- { tag: "test-scoring-feedback", ctor: TestScoringFeedback },
5326
- { tag: "test-section-buttons-stamp", ctor: TestSectionButtonsStamp },
5327
- { tag: "test-section-link", ctor: TestSectionLink },
5328
- { tag: "test-stamp", ctor: TestStamp },
5329
- { tag: "test-tts-next", ctor: TestTtsNext },
5330
- { tag: "test-tts-pause", ctor: TestTtsPause },
5331
- { tag: "test-tts-pick", ctor: TestTtsPick },
5332
- { tag: "test-tts-play", ctor: TestTtsPlay },
5333
- { tag: "test-tts-prev", ctor: TestTtsPrev },
5334
- { tag: "test-tts-resume", ctor: TestTtsResume },
5335
- { tag: "test-tts-stop", ctor: TestTtsStop },
5336
- { tag: "test-view", ctor: TestView },
5337
- { tag: "test-view-toggle", ctor: TestViewToggle }
4243
+ ...pluginElements
5338
4244
  ];
5339
4245
 
5340
4246
  export {
@@ -5353,33 +4259,15 @@ export {
5353
4259
  QtiTestVariables,
5354
4260
  QtiTestVariablesExpression,
5355
4261
  QTI_TEST_STATE_VERSION,
4262
+ stateFromContexts,
5356
4263
  QtiTest,
5357
- TestCheckItem,
5358
4264
  TestContainer,
5359
4265
  TestEndAttempt,
5360
- TestItemLink,
5361
- ttsContext,
5362
- TestItemToSpeech,
5363
- TestTtsPlay,
5364
- TestTtsPause,
5365
- TestTtsResume,
5366
- TestTtsStop,
5367
- TestTtsPrev,
5368
- TestTtsNext,
5369
- TestTtsPick,
5370
4266
  TestNavigation,
5371
4267
  TestNext,
5372
- TestPagingButtonsStamp,
5373
4268
  TestPrev,
5374
- TestPrintContext,
5375
- TestPrintVariables,
5376
- TestScoringButtons,
5377
- TestScoringFeedback,
5378
- TestSectionButtonsStamp,
5379
- TestSectionLink,
5380
- TestStamp,
5381
- TestView,
5382
- TestViewToggle,
4269
+ TestSubmit,
4270
+ pluginElements,
5383
4271
  qtiTestElements
5384
4272
  };
5385
4273
  /*! Bundled license information:
@@ -5394,4 +4282,4 @@ export {
5394
4282
  * Portions Copyright (c) 2013, the Dart project authors.
5395
4283
  *)
5396
4284
  */
5397
- //# sourceMappingURL=chunk-SIE3E4FG.js.map
4285
+ //# sourceMappingURL=chunk-R352K4KZ.js.map