@citolab/qti-components 10.0.0-next.1 → 10.0.0-next.10

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 (64) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +1970 -364
  3. package/dist/base.d.ts +10 -10
  4. package/dist/base.js +7 -1
  5. package/dist/{chunk-RU6332MD.js → chunk-3TUGZHKB.js} +3 -3
  6. package/dist/{chunk-RSMYGGQK.js → chunk-AHULN3UB.js} +390 -243
  7. package/dist/chunk-AHULN3UB.js.map +1 -0
  8. package/dist/{chunk-35WWWFS6.js → chunk-CQ3WU35R.js} +2 -2
  9. package/dist/{chunk-6K3QWJHH.js → chunk-LCGPLQLE.js} +40 -4
  10. package/dist/chunk-LCGPLQLE.js.map +1 -0
  11. package/dist/{chunk-MI7774NV.js → chunk-M7X6TWSX.js} +2 -2
  12. package/dist/{chunk-FD4AB6TM.js → chunk-Q3C7XFVS.js} +2 -2
  13. package/dist/chunk-QVZLJY75.js +7 -0
  14. package/dist/chunk-QVZLJY75.js.map +1 -0
  15. package/dist/{chunk-CKJ7M7JQ.js → chunk-RRMCWCSA.js} +2287 -2061
  16. package/dist/chunk-RRMCWCSA.js.map +1 -0
  17. package/dist/{chunk-GBZNFSFY.js → chunk-RWMY7KRT.js} +2 -2
  18. package/dist/{chunk-TDWJ6WZA.js → chunk-T7YSBBAA.js} +37 -1
  19. package/dist/chunk-T7YSBBAA.js.map +1 -0
  20. package/dist/{chunk-YYIS6FDP.js → chunk-WPILS3CW.js} +2 -2
  21. package/dist/{chunk-6U3YPHXU.js → chunk-YOCOLMGB.js} +40 -5
  22. package/dist/{chunk-6U3YPHXU.js.map → chunk-YOCOLMGB.js.map} +1 -1
  23. package/dist/{chunk-FWR6HZQS.js → chunk-YYZCTIZY.js} +6 -6
  24. package/dist/{computed.types.d-gJrBeUMG.d.ts → computed.types.d-IXACuBr7.d.ts} +10 -1
  25. package/dist/corrections.d.ts +9 -9
  26. package/dist/corrections.js +8 -8
  27. package/dist/elements.d.ts +2 -2
  28. package/dist/elements.js +3 -3
  29. package/dist/index.d.ts +11 -11
  30. package/dist/index.js +37 -19
  31. package/dist/interactions.d.ts +4 -4
  32. package/dist/interactions.js +7 -3
  33. package/dist/item.css +2 -1
  34. package/dist/item.d.ts +4 -4
  35. package/dist/item.js +4 -4
  36. package/dist/{item.types.d-B55QkJ92.d.ts → item.types.d-DuVR0ZVK.d.ts} +7 -1
  37. package/dist/loader.d.ts +2 -2
  38. package/dist/processing.d.ts +10 -3
  39. package/dist/processing.js +3 -3
  40. package/dist/qti-components-jsx.d.ts +928 -757
  41. package/dist/{qti-condition-expression.d-VJH6cWxf.d.ts → qti-condition-expression.d-B-T1NNl0.d.ts} +1 -1
  42. package/dist/{qti-expression.d-BPxEp8HU.d.ts → qti-expression.d-B-Cfbqlb.d.ts} +1 -1
  43. package/dist/{qti-feedback.d-wMYNVkkj.d.ts → qti-feedback.d-DbzPSJuK.d.ts} +1 -1
  44. package/dist/{qti-item.d-DgC1AQbY.d.ts → qti-item.d-B1gffYCL.d.ts} +1 -1
  45. package/dist/{qti-test.d-DkpBNcsv.d.ts → qti-test.d-D-RYWphm.d.ts} +182 -99
  46. package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-utFyp1DH.d.ts} +28 -18
  47. package/dist/{interaction.d-g6XG0T0Z.d.ts → record.d-wB9uYs-j.d.ts} +34 -2
  48. package/dist/{session.context.d-D5080LVx.d.ts → session.context.d-DW09Lrie.d.ts} +7 -1
  49. package/dist/test.d.ts +117 -9
  50. package/dist/test.js +19 -11
  51. package/package.json +9 -9
  52. package/dist/chunk-6K3QWJHH.js.map +0 -1
  53. package/dist/chunk-CKJ7M7JQ.js.map +0 -1
  54. package/dist/chunk-RSMYGGQK.js.map +0 -1
  55. package/dist/chunk-TDWJ6WZA.js.map +0 -1
  56. package/dist/chunk-ZP6QQYSU.js +0 -7
  57. package/dist/chunk-ZP6QQYSU.js.map +0 -1
  58. /package/dist/{chunk-RU6332MD.js.map → chunk-3TUGZHKB.js.map} +0 -0
  59. /package/dist/{chunk-35WWWFS6.js.map → chunk-CQ3WU35R.js.map} +0 -0
  60. /package/dist/{chunk-MI7774NV.js.map → chunk-M7X6TWSX.js.map} +0 -0
  61. /package/dist/{chunk-FD4AB6TM.js.map → chunk-Q3C7XFVS.js.map} +0 -0
  62. /package/dist/{chunk-GBZNFSFY.js.map → chunk-RWMY7KRT.js.map} +0 -0
  63. /package/dist/{chunk-YYIS6FDP.js.map → chunk-WPILS3CW.js.map} +0 -0
  64. /package/dist/{chunk-FWR6HZQS.js.map → chunk-YYZCTIZY.js.map} +0 -0
@@ -3,10 +3,10 @@ import {
3
3
  dispatchDeclared,
4
4
  listenDeclared,
5
5
  listenPublic
6
- } from "./chunk-6U3YPHXU.js";
6
+ } from "./chunk-YOCOLMGB.js";
7
7
  import {
8
8
  item_css_default
9
- } from "./chunk-ZP6QQYSU.js";
9
+ } from "./chunk-QVZLJY75.js";
10
10
  import {
11
11
  watch
12
12
  } from "./chunk-4DB4SC5K.js";
@@ -21,10 +21,11 @@ import {
21
21
  QtiExpression,
22
22
  computedContext,
23
23
  configContext,
24
+ isRecordValue,
24
25
  qtiContext,
25
26
  sessionContext,
26
27
  testContext
27
- } from "./chunk-TDWJ6WZA.js";
28
+ } from "./chunk-T7YSBBAA.js";
28
29
 
29
30
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
30
31
  import { LitElement, nothing as nothing2 } from "lit";
@@ -636,18 +637,18 @@ var EvalAstFactory = class {
636
637
  }
637
638
  const value = this.right.evaluate(scope);
638
639
  let receiver = void 0;
639
- let property21;
640
+ let property24;
640
641
  if (this.left.type === "Getter") {
641
642
  receiver = this.left.receiver.evaluate(scope);
642
- property21 = this.left.name;
643
+ property24 = this.left.name;
643
644
  } else if (this.left.type === "Index") {
644
645
  receiver = this.left.receiver.evaluate(scope);
645
- property21 = this.left.argument.evaluate(scope);
646
+ property24 = this.left.argument.evaluate(scope);
646
647
  } else if (this.left.type === "ID") {
647
648
  receiver = scope;
648
- property21 = this.left.value;
649
+ property24 = this.left.value;
649
650
  }
650
- return receiver === void 0 ? void 0 : receiver[property21] = value;
651
+ return receiver === void 0 ? void 0 : receiver[property24] = value;
651
652
  }
652
653
  return f(this.left.evaluate(scope), this.right.evaluate(scope));
653
654
  },
@@ -1107,8 +1108,11 @@ var testHostContext = createContext(/* @__PURE__ */ Symbol("testHost"));
1107
1108
  var PUBLIC_EVENTS = {
1108
1109
  "cito-test-navigate": { kind: "request", scope: "test", deprecated: "qti-request-navigation" },
1109
1110
  "cito-test-end-attempt": { kind: "request", scope: "test", deprecated: "test-end-attempt" },
1111
+ "cito-test-submit": { kind: "request", scope: "test" },
1110
1112
  "cito-test-update-outcome": { kind: "request", scope: "test", deprecated: "test-update-outcome-variable" },
1113
+ "cito-test-update-plugin-state": { kind: "request", scope: "test" },
1111
1114
  "cito-test-switch-view": { kind: "request", scope: "test", deprecated: "on-test-switch-view" },
1115
+ "cito-test-submitted": { kind: "notification", scope: "test" },
1112
1116
  "cito-test-navigated": { kind: "notification", scope: "test" },
1113
1117
  "cito-test-navigation-started": {
1114
1118
  kind: "notification",
@@ -1495,6 +1499,9 @@ __decorate5([
1495
1499
  property5({ type: Boolean, converter: stringToBooleanConverter3, attribute: "validate-responses" })
1496
1500
  ], QtiItemSessionControl.prototype, "validateResponses", void 0);
1497
1501
 
1502
+ // ../qti-test/dist/components/qti-number-presented/qti-number-presented.js
1503
+ import { consume as consume4 } from "@lit/context";
1504
+
1498
1505
  // ../qti-test/dist/internal/item-ref-selection.js
1499
1506
  var categoryList = (value) => value?.split(/\s+/).filter(Boolean) ?? [];
1500
1507
  var selectionFrom = (element) => ({
@@ -1520,6 +1527,43 @@ var selectItemRefs = (testElement, { sectionIdentifier, includeCategories, exclu
1520
1527
  });
1521
1528
  };
1522
1529
 
1530
+ // ../qti-test/dist/components/qti-number-presented/qti-number-presented.js
1531
+ var __decorate6 = function(decorators, target, key, desc) {
1532
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1533
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1534
+ 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;
1535
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1536
+ };
1537
+ var QtiNumberPresented = class extends QtiExpression {
1538
+ #connectedTest = null;
1539
+ constructor() {
1540
+ super();
1541
+ listenPublic2(this, "cito-test-loaded", (e) => this.#connectedTest = e.detail);
1542
+ }
1543
+ /** The test this expression is in: handed over by a test harness, or found up the tree in a real document. */
1544
+ get #testElement() {
1545
+ return this.#connectedTest ?? this.closest("qti-assessment-test");
1546
+ }
1547
+ getResult() {
1548
+ const testElement = this.#testElement;
1549
+ if (!testElement) {
1550
+ console.warn("qti-number-presented: no enclosing qti-assessment-test, nothing to count");
1551
+ return 0;
1552
+ }
1553
+ const presented = new Set((this._testContext?.items ?? []).filter((item) => {
1554
+ const status = item.variables?.find((v) => v.identifier === "completionStatus")?.value;
1555
+ return status != null && status !== "not_attempted";
1556
+ }).map((item) => item.identifier));
1557
+ return selectItemRefs(testElement, selectionFrom(this)).filter((itemRef) => presented.has(itemRef.identifier)).length;
1558
+ }
1559
+ calculate() {
1560
+ return this.getResult();
1561
+ }
1562
+ };
1563
+ __decorate6([
1564
+ consume4({ context: testContext, subscribe: true })
1565
+ ], QtiNumberPresented.prototype, "_testContext", void 0);
1566
+
1523
1567
  // ../qti-test/dist/components/qti-number-selected/qti-number-selected.js
1524
1568
  var QtiNumberSelected = class extends QtiExpression {
1525
1569
  #connectedTest = null;
@@ -1604,7 +1648,18 @@ var QtiOutcomeProcessingProcessor = class {
1604
1648
 
1605
1649
  // ../qti-test/dist/components/qti-test-feedback/qti-test-feedback.js
1606
1650
  import { css as css4, html as html7 } from "lit";
1651
+ import { property as property6 } from "lit/decorators.js";
1652
+ var __decorate7 = function(decorators, target, key, desc) {
1653
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1654
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1655
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1656
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1657
+ };
1607
1658
  var QtiTestFeedback = class extends QtiModalFeedback {
1659
+ constructor() {
1660
+ super(...arguments);
1661
+ this.access = "atEnd";
1662
+ }
1608
1663
  static {
1609
1664
  this.styles = css4`
1610
1665
  :host {
@@ -1612,15 +1667,26 @@ var QtiTestFeedback = class extends QtiModalFeedback {
1612
1667
  }
1613
1668
  `;
1614
1669
  }
1670
+ /**
1671
+ * Whether this feedback applies for a value of its `outcome-identifier`: with `show-hide="show"`
1672
+ * when the value is (or, for a container, holds) its `identifier`; with `hide` when it is not.
1673
+ */
1674
+ matches(value) {
1675
+ const found = Array.isArray(value) ? value.includes(this.identifier) : value != null && value === this.identifier;
1676
+ return this.showHide === "hide" ? !found : found;
1677
+ }
1615
1678
  render() {
1616
1679
  return html7``;
1617
1680
  }
1618
1681
  };
1682
+ __decorate7([
1683
+ property6({ type: String })
1684
+ ], QtiTestFeedback.prototype, "access", void 0);
1619
1685
 
1620
1686
  // ../qti-test/dist/components/qti-test-part/qti-test-part.js
1621
1687
  import { html as html8, LitElement as LitElement8 } from "lit";
1622
- import { property as property6 } from "lit/decorators.js";
1623
- var __decorate6 = function(decorators, target, key, desc) {
1688
+ import { property as property7 } from "lit/decorators.js";
1689
+ var __decorate8 = function(decorators, target, key, desc) {
1624
1690
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1625
1691
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1626
1692
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -1656,22 +1722,22 @@ var QtiTestPart = class extends LitElement8 {
1656
1722
  return html8` <slot></slot>`;
1657
1723
  }
1658
1724
  };
1659
- __decorate6([
1660
- property6({ type: String })
1725
+ __decorate8([
1726
+ property7({ type: String })
1661
1727
  ], QtiTestPart.prototype, "identifier", void 0);
1662
- __decorate6([
1663
- property6({ type: String })
1728
+ __decorate8([
1729
+ property7({ type: String })
1664
1730
  ], QtiTestPart.prototype, "class", void 0);
1665
- __decorate6([
1666
- property6({ type: String, attribute: "navigation-mode" })
1731
+ __decorate8([
1732
+ property7({ type: String, attribute: "navigation-mode" })
1667
1733
  ], QtiTestPart.prototype, "navigationMode", void 0);
1668
- __decorate6([
1669
- property6({ type: String, attribute: "submission-mode" })
1734
+ __decorate8([
1735
+ property7({ type: String, attribute: "submission-mode" })
1670
1736
  ], QtiTestPart.prototype, "submissionMode", void 0);
1671
1737
 
1672
1738
  // ../qti-test/dist/components/qti-test-variables/qti-test-variables.js
1673
- import { consume as consume4 } from "@lit/context";
1674
- var __decorate7 = function(decorators, target, key, desc) {
1739
+ import { consume as consume5 } from "@lit/context";
1740
+ var __decorate9 = function(decorators, target, key, desc) {
1675
1741
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1676
1742
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1677
1743
  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;
@@ -1712,8 +1778,8 @@ var QtiTestVariables = class extends QtiExpression {
1712
1778
  return this.getResult();
1713
1779
  }
1714
1780
  };
1715
- __decorate7([
1716
- consume4({ context: testContext, subscribe: true })
1781
+ __decorate9([
1782
+ consume5({ context: testContext, subscribe: true })
1717
1783
  ], QtiTestVariables.prototype, "_testContext", void 0);
1718
1784
  var QtiTestVariablesExpression = class {
1719
1785
  constructor(testContext2, itemVariable, includedItems) {
@@ -1750,7 +1816,7 @@ import { html as html9, LitElement as LitElement10 } from "lit";
1750
1816
  import { state as state2 } from "lit/decorators.js";
1751
1817
 
1752
1818
  // ../qti-test/dist/mixins/test-navigation.mixin.js
1753
- import { property as property7 } from "lit/decorators.js";
1819
+ import { property as property8 } from "lit/decorators.js";
1754
1820
 
1755
1821
  // ../qti-test/dist/internal/item-sequencing.js
1756
1822
  var SECTION = "qti-assessment-section";
@@ -1843,7 +1909,7 @@ function preConditionsPass(itemRef, from) {
1843
1909
  }
1844
1910
 
1845
1911
  // ../qti-test/dist/mixins/test-navigation.mixin.js
1846
- var __decorate8 = function(decorators, target, key, desc) {
1912
+ var __decorate10 = function(decorators, target, key, desc) {
1847
1913
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1848
1914
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1849
1915
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2351,17 +2417,17 @@ var TestNavigationMixin = (superClass) => {
2351
2417
  });
2352
2418
  }
2353
2419
  }
2354
- __decorate8([
2355
- property7({ type: String })
2420
+ __decorate10([
2421
+ property8({ type: String })
2356
2422
  ], TestNavigationClass.prototype, "navigate", void 0);
2357
- __decorate8([
2358
- property7({ type: Number })
2423
+ __decorate10([
2424
+ property8({ type: Number })
2359
2425
  ], TestNavigationClass.prototype, "requestTimeout", void 0);
2360
- __decorate8([
2361
- property7({ attribute: false })
2426
+ __decorate10([
2427
+ property8({ attribute: false })
2362
2428
  ], TestNavigationClass.prototype, "postLoadTransformCallback", void 0);
2363
- __decorate8([
2364
- property7({ attribute: false })
2429
+ __decorate10([
2430
+ property8({ attribute: false })
2365
2431
  ], TestNavigationClass.prototype, "postLoadTestTransformCallback", void 0);
2366
2432
  return TestNavigationClass;
2367
2433
  };
@@ -2417,8 +2483,8 @@ var TestViewMixin = (superClass) => {
2417
2483
  // ../qti-test/dist/mixins/test-base.js
2418
2484
  import { provide } from "@lit/context";
2419
2485
  import { LitElement as LitElement9 } from "lit";
2420
- import { property as property8 } from "lit/decorators.js";
2421
- var __decorate9 = function(decorators, target, key, desc) {
2486
+ import { property as property9 } from "lit/decorators.js";
2487
+ var __decorate11 = function(decorators, target, key, desc) {
2422
2488
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2423
2489
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2424
2490
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2444,6 +2510,8 @@ var TestBaseMixin = (superClass) => {
2444
2510
  } else {
2445
2511
  const newVariables = [...assessmentItem.variables];
2446
2512
  for (const variable of itemContext.variables) {
2513
+ if (variable.identifier === "completionStatus" && variable.value === "not_attempted")
2514
+ continue;
2447
2515
  const currentVariable = newVariables.find((v) => v.identifier === variable.identifier);
2448
2516
  if (currentVariable) {
2449
2517
  currentVariable.value = variable.value;
@@ -2452,6 +2520,7 @@ var TestBaseMixin = (superClass) => {
2452
2520
  }
2453
2521
  }
2454
2522
  assessmentItem.variables = newVariables;
2523
+ this.#leaveNotAttempted(identifier, newVariables.find((v) => v.identifier === "completionStatus")?.value);
2455
2524
  if (itemContext.state) {
2456
2525
  assessmentItem.state = itemContext.state;
2457
2526
  }
@@ -2558,13 +2627,29 @@ var TestBaseMixin = (superClass) => {
2558
2627
  };
2559
2628
  this.dispatchEvent(new CustomEvent("qti-test-context-updated", { detail: this.testContext, bubbles: false, composed: false }));
2560
2629
  }
2630
+ /** Write the presented item's own status over a `not_attempted` the test context still holds for it. */
2631
+ #leaveNotAttempted(identifier, status) {
2632
+ if (typeof status !== "string" || status === "not_attempted")
2633
+ return;
2634
+ const item = this.testContext.items.find((i) => i.identifier === identifier);
2635
+ const current = item?.variables.find((v) => v.identifier === "completionStatus");
2636
+ if (current?.value !== "not_attempted")
2637
+ return;
2638
+ this.testContext = {
2639
+ ...this.testContext,
2640
+ items: this.testContext.items.map((i) => i.identifier !== identifier ? i : {
2641
+ ...i,
2642
+ variables: i.variables.map((v) => v.identifier === "completionStatus" ? { ...v, value: status } : v)
2643
+ })
2644
+ };
2645
+ }
2561
2646
  }
2562
- __decorate9([
2563
- property8({ attribute: false, type: Object }),
2647
+ __decorate11([
2648
+ property9({ attribute: false, type: Object }),
2564
2649
  provide({ context: testContext })
2565
2650
  ], TestBaseClass.prototype, "testContext", void 0);
2566
- __decorate9([
2567
- property8({ attribute: false, type: Object }),
2651
+ __decorate11([
2652
+ property9({ attribute: false, type: Object }),
2568
2653
  provide({ context: sessionContext })
2569
2654
  ], TestBaseClass.prototype, "sessionContext", void 0);
2570
2655
  return TestBaseClass;
@@ -2593,6 +2678,7 @@ var toState = (test, session) => ({
2593
2678
  outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
2594
2679
  },
2595
2680
  session: {
2681
+ ...session?.plugins && Object.keys(session.plugins).length > 0 ? { plugins: { ...session.plugins } } : {},
2596
2682
  ...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
2597
2683
  ...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
2598
2684
  ...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
@@ -2615,6 +2701,7 @@ var TestStateMixin = (superClass) => {
2615
2701
  this.#ready = false;
2616
2702
  this.#lastEmitted = null;
2617
2703
  });
2704
+ listenPublic2(this, "cito-test-update-plugin-state", ({ detail }) => this.#updatePluginState(detail));
2618
2705
  listenPublic2(this, "cito-test-loaded", () => {
2619
2706
  if (this.#pending) {
2620
2707
  this.#apply(this.#pending);
@@ -2623,6 +2710,22 @@ var TestStateMixin = (superClass) => {
2623
2710
  this.#ready = true;
2624
2711
  });
2625
2712
  }
2713
+ /** One plugin's entry, as JSON: the test stores it without reading it. `null` removes it. */
2714
+ #updatePluginState({ plugin, value }) {
2715
+ if (typeof plugin !== "string" || plugin === "")
2716
+ return;
2717
+ const { [plugin]: _removed, ...others } = this.sessionContext.plugins ?? {};
2718
+ let next = others;
2719
+ if (value !== null && value !== void 0) {
2720
+ try {
2721
+ next = { ...others, [plugin]: JSON.parse(JSON.stringify(value)) };
2722
+ } catch {
2723
+ console.warn(`[qti-test] Ignoring plugin state for "${plugin}": it is not JSON.`);
2724
+ return;
2725
+ }
2726
+ }
2727
+ this.sessionContext = { ...this.sessionContext, plugins: next };
2728
+ }
2626
2729
  get state() {
2627
2730
  return toState(this.testContext, this.sessionContext);
2628
2731
  }
@@ -2663,7 +2766,11 @@ var TestStateMixin = (superClass) => {
2663
2766
  ...this.testContext,
2664
2767
  testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
2665
2768
  };
2666
- this.sessionContext = { ...this.sessionContext, ...this.#validSession(state9.session) };
2769
+ this.sessionContext = {
2770
+ ...this.sessionContext,
2771
+ ...this.#validSession(state9.session),
2772
+ plugins: state9.session.plugins && typeof state9.session.plugins === "object" ? { ...state9.session.plugins } : {}
2773
+ };
2667
2774
  }
2668
2775
  /** A stored position may point at an item or section a revised test no longer has. */
2669
2776
  #validSession(session) {
@@ -2693,6 +2800,7 @@ var TestProcessingMixin = (superClass) => {
2693
2800
  };
2694
2801
  e.stopPropagation();
2695
2802
  });
2803
+ listenPublic2(this, "cito-test-submit", () => this.submit());
2696
2804
  this.addEventListener("qti-set-outcome-value", (e) => {
2697
2805
  const { outcomeIdentifier, value } = e.detail;
2698
2806
  this.updateOutcomeVariable(outcomeIdentifier, value);
@@ -2703,9 +2811,35 @@ var TestProcessingMixin = (superClass) => {
2703
2811
  const outcomeProcessor = (this._testElement ?? this).querySelector("qti-outcome-processing");
2704
2812
  if (!outcomeProcessor)
2705
2813
  return false;
2706
- outcomeProcessor?.process();
2814
+ this.testContext = {
2815
+ ...this.testContext,
2816
+ testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => ({
2817
+ ...v,
2818
+ value: v.defaultValue ?? null
2819
+ }))
2820
+ };
2821
+ outcomeProcessor.process();
2822
+ return true;
2823
+ }
2824
+ /**
2825
+ * Ends the test for scoring: runs `outcomeProcessing()`, then tells the host with
2826
+ * `cito-test-submitted`. Returns false, and sends nothing, when the test has no outcome processing.
2827
+ */
2828
+ submit() {
2829
+ if (!this.outcomeProcessing())
2830
+ return false;
2831
+ dispatchPublic(this, "cito-test-submitted", {});
2707
2832
  return true;
2708
2833
  }
2834
+ /**
2835
+ * The `qti-test-feedback` elements that apply now, read from the test outcomes: run
2836
+ * `outcomeProcessing()` first. `access` narrows them to the end of the test (`atEnd`) or to
2837
+ * while it runs (`during`); without it, both.
2838
+ */
2839
+ getTestFeedback(access) {
2840
+ const feedback = Array.from((this._testElement ?? this).querySelectorAll("qti-test-feedback") ?? []);
2841
+ return feedback.filter((fb) => (!access || fb.access === access) && fb.matches(this.getOutcome(fb.outcomeIdentifier)?.value));
2842
+ }
2709
2843
  /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */
2710
2844
  updateOutcomeVariable(identifier, value) {
2711
2845
  const outcomeVariable = this.getOutcome(identifier);
@@ -2737,7 +2871,7 @@ var TestProcessingMixin = (superClass) => {
2737
2871
  };
2738
2872
 
2739
2873
  // ../qti-test/dist/components/qti-test/qti-test.js
2740
- var __decorate10 = function(decorators, target, key, desc) {
2874
+ var __decorate12 = function(decorators, target, key, desc) {
2741
2875
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2742
2876
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2743
2877
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2771,115 +2905,27 @@ var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixi
2771
2905
  return html9`<slot></slot>`;
2772
2906
  }
2773
2907
  };
2774
- __decorate10([
2908
+ __decorate12([
2775
2909
  state2(),
2776
2910
  provide2({ context: configContext })
2777
2911
  ], QtiTest.prototype, "configContext", void 0);
2778
- __decorate10([
2912
+ __decorate12([
2779
2913
  state2(),
2780
2914
  provide2({ context: qtiContext })
2781
2915
  ], QtiTest.prototype, "qtiContext", void 0);
2782
2916
 
2783
- // ../qti-test/dist/components/test-check-item/test-check-item.js
2784
- import { consume as consume5 } from "@lit/context";
2785
- import { css as css6, html as html10, LitElement as LitElement11 } from "lit";
2786
-
2787
- // ../qti-test/dist/components/styles.js
2788
- import { css as css5 } from "lit";
2789
- var form = css5`
2790
- display: inline-flex;
2791
- align-items: center;
2792
- justify-content: center;
2793
- gap: 0.375em;
2794
- box-sizing: border-box;
2795
- min-block-size: var(--test-button-size, 2.25rem);
2796
- padding: 0 0.875rem;
2797
- font: inherit;
2798
- line-height: 1.25;
2799
- cursor: pointer;
2800
- user-select: none;
2801
- border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
2802
- `;
2803
- var btn = css5`
2804
- ${form};
2805
- background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
2806
- color: var(--test-button-color, var(--qti-component-color, inherit));
2807
- border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
2808
- var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
2809
- `;
2810
- var btnInteractive = css5`
2811
- background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
2812
- `;
2813
- var focusRing = css5`
2814
- outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
2815
- outline-offset: 2px;
2816
- `;
2817
- var dis = css5`
2818
- cursor: not-allowed;
2819
- opacity: 0.45;
2820
- `;
2821
- var ind = css5`
2822
- ${form};
2823
- border: 1px solid gray;
2824
- `;
2825
-
2826
- // ../qti-test/dist/components/test-check-item/test-check-item.js
2827
- var __decorate11 = function(decorators, target, key, desc) {
2828
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2829
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2830
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2831
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2832
- };
2833
- var TestCheckItem = class extends LitElement11 {
2834
- static {
2835
- this.styles = css6`
2836
- :host {
2837
- ${btn};
2838
- }
2839
- :host(:hover:not([disabled])) {
2840
- ${btnInteractive};
2841
- }
2842
- :host(:focus-visible) {
2843
- ${focusRing};
2844
- }
2845
- :host([disabled]) {
2846
- ${dis};
2847
- }
2848
- `;
2849
- }
2850
- constructor() {
2851
- super();
2852
- this.addEventListener("click", () => {
2853
- dispatchPublic(this, "cito-test-end-attempt", {});
2854
- const testContainer = this.testHost?.querySelector("test-container");
2855
- if (!testContainer)
2856
- return;
2857
- const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
2858
- viewElements.forEach((element) => {
2859
- element.classList.toggle("show", true);
2860
- });
2861
- });
2862
- }
2863
- render() {
2864
- return html10` <slot></slot> `;
2865
- }
2866
- };
2867
- __decorate11([
2868
- consume5({ context: testHostContext, subscribe: true })
2869
- ], TestCheckItem.prototype, "testHost", void 0);
2870
-
2871
2917
  // ../qti-test/dist/components/test-container/test-container.js
2872
2918
  import { consume as consume6 } from "@lit/context";
2873
- import { LitElement as LitElement12, html as html11 } from "lit";
2874
- import { property as property9, state as state3 } from "lit/decorators.js";
2919
+ import { LitElement as LitElement11, html as html10 } from "lit";
2920
+ import { property as property10, state as state3 } from "lit/decorators.js";
2875
2921
  import { until } from "lit/directives/until.js";
2876
- var __decorate12 = function(decorators, target, key, desc) {
2922
+ var __decorate13 = function(decorators, target, key, desc) {
2877
2923
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2878
2924
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2879
2925
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2880
2926
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2881
2927
  };
2882
- var TestContainer = class extends LitElement12 {
2928
+ var TestContainer = class extends LitElement11 {
2883
2929
  constructor() {
2884
2930
  super(...arguments);
2885
2931
  this.customElementRegistry = null;
@@ -2964,7 +3010,7 @@ var TestContainer = class extends LitElement12 {
2964
3010
  }
2965
3011
  #initializeTemplateContent() {
2966
3012
  const template = this.querySelector("template");
2967
- this.#templateContent = template ? template.content : html11``;
3013
+ this.#templateContent = template ? template.content : html10``;
2968
3014
  }
2969
3015
  #applyStyles() {
2970
3016
  const sheet = new CSSStyleSheet();
@@ -2972,57 +3018,98 @@ var TestContainer = class extends LitElement12 {
2972
3018
  this.shadowRoot.adoptedStyleSheets = [sheet];
2973
3019
  }
2974
3020
  render() {
2975
- return html11`
3021
+ return html10`
2976
3022
  ${this.#templateContent}
2977
3023
  <slot></slot>
2978
- ${until(this.testDoc, html11`<span>Loading...</span>`)}
3024
+ ${until(this.testDoc, html10`<span>Loading...</span>`)}
2979
3025
  `;
2980
3026
  }
2981
3027
  };
2982
- __decorate12([
2983
- property9({ attribute: false })
3028
+ __decorate13([
3029
+ property10({ attribute: false })
2984
3030
  ], TestContainer.prototype, "customElementRegistry", void 0);
2985
- __decorate12([
2986
- property9({ type: String, attribute: "test-url" })
3031
+ __decorate13([
3032
+ property10({ type: String, attribute: "test-url" })
2987
3033
  ], TestContainer.prototype, "testURL", void 0);
2988
- __decorate12([
3034
+ __decorate13([
2989
3035
  state3()
2990
3036
  ], TestContainer.prototype, "testDoc", void 0);
2991
- __decorate12([
3037
+ __decorate13([
2992
3038
  state3()
2993
3039
  ], TestContainer.prototype, "testXML", void 0);
2994
- __decorate12([
3040
+ __decorate13([
2995
3041
  consume6({ context: testHostContext, subscribe: true })
2996
3042
  ], TestContainer.prototype, "testHost", void 0);
2997
- __decorate12([
3043
+ __decorate13([
2998
3044
  state3(),
2999
3045
  consume6({ context: qtiContext, subscribe: true })
3000
3046
  ], TestContainer.prototype, "qtiContext", void 0);
3001
- __decorate12([
3047
+ __decorate13([
3002
3048
  watch("testURL", { waitUntilFirstUpdate: true })
3003
3049
  ], TestContainer.prototype, "handleTestURLChange", null);
3004
- __decorate12([
3050
+ __decorate13([
3005
3051
  watch("testXML", { waitUntilFirstUpdate: true })
3006
3052
  ], TestContainer.prototype, "handleTestXMLChange", null);
3007
3053
 
3008
3054
  // ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
3009
- import { css as css7, html as html12, LitElement as LitElement13 } from "lit";
3010
- import { property as property10 } from "lit/decorators.js";
3055
+ import { css as css6, html as html11, LitElement as LitElement12 } from "lit";
3056
+ import { property as property11 } from "lit/decorators.js";
3011
3057
  import { consume as consume7 } from "@lit/context";
3012
- var __decorate13 = function(decorators, target, key, desc) {
3058
+
3059
+ // ../qti-test/dist/components/styles.js
3060
+ import { css as css5 } from "lit";
3061
+ var form = css5`
3062
+ display: inline-flex;
3063
+ align-items: center;
3064
+ justify-content: center;
3065
+ gap: 0.375em;
3066
+ box-sizing: border-box;
3067
+ min-block-size: var(--test-button-size, 2.25rem);
3068
+ padding: 0 0.875rem;
3069
+ font: inherit;
3070
+ line-height: 1.25;
3071
+ cursor: pointer;
3072
+ user-select: none;
3073
+ border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
3074
+ `;
3075
+ var btn = css5`
3076
+ ${form};
3077
+ background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
3078
+ color: var(--test-button-color, var(--qti-component-color, inherit));
3079
+ border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
3080
+ var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
3081
+ `;
3082
+ var btnInteractive = css5`
3083
+ background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
3084
+ `;
3085
+ var focusRing = css5`
3086
+ outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
3087
+ outline-offset: 2px;
3088
+ `;
3089
+ var dis = css5`
3090
+ cursor: not-allowed;
3091
+ opacity: 0.45;
3092
+ `;
3093
+ var ind = css5`
3094
+ ${form};
3095
+ border: 1px solid gray;
3096
+ `;
3097
+
3098
+ // ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
3099
+ var __decorate14 = function(decorators, target, key, desc) {
3013
3100
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3014
3101
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3015
3102
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3016
3103
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3017
3104
  };
3018
- var TestEndAttempt = class extends LitElement13 {
3105
+ var TestEndAttempt = class extends LitElement12 {
3019
3106
  _handleTestElementChange(_oldValue, newValue) {
3020
3107
  if (newValue) {
3021
3108
  this.requestUpdate();
3022
3109
  }
3023
3110
  }
3024
3111
  static {
3025
- this.styles = css7`
3112
+ this.styles = css6`
3026
3113
  :host {
3027
3114
  ${btn};
3028
3115
  }
@@ -3067,6 +3154,10 @@ var TestEndAttempt = class extends LitElement13 {
3067
3154
  this._internalDisabled = true;
3068
3155
  return;
3069
3156
  }
3157
+ if (activeItem.adaptive && activeItem.completionStatus === "completed") {
3158
+ this._internalDisabled = true;
3159
+ return;
3160
+ }
3070
3161
  if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {
3071
3162
  this._internalDisabled = true;
3072
3163
  return;
@@ -3078,32 +3169,32 @@ var TestEndAttempt = class extends LitElement13 {
3078
3169
  }
3079
3170
  }
3080
3171
  render() {
3081
- return html12` <slot></slot> `;
3172
+ return html11` <slot></slot> `;
3082
3173
  }
3083
3174
  };
3084
- __decorate13([
3175
+ __decorate14([
3085
3176
  consume7({ context: computedContext, subscribe: true }),
3086
- property10({ attribute: false })
3177
+ property11({ attribute: false })
3087
3178
  ], TestEndAttempt.prototype, "computedContext", void 0);
3088
- __decorate13([
3089
- property10({ type: Boolean, reflect: true, attribute: "disabled" })
3179
+ __decorate14([
3180
+ property11({ type: Boolean, reflect: true, attribute: "disabled" })
3090
3181
  ], TestEndAttempt.prototype, "_internalDisabled", void 0);
3091
- __decorate13([
3182
+ __decorate14([
3092
3183
  watch("computedContext")
3093
3184
  ], TestEndAttempt.prototype, "_handleTestElementChange", null);
3094
3185
 
3095
3186
  // ../qti-test/dist/components/test-item-link/test-item-link.js
3096
- import { css as css8, html as html13, LitElement as LitElement14 } from "lit";
3097
- import { property as property11 } from "lit/decorators.js";
3098
- var __decorate14 = function(decorators, target, key, desc) {
3187
+ import { css as css7, html as html12, LitElement as LitElement13 } from "lit";
3188
+ import { property as property12 } from "lit/decorators.js";
3189
+ var __decorate15 = function(decorators, target, key, desc) {
3099
3190
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3100
3191
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3101
3192
  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;
3102
3193
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3103
3194
  };
3104
- var TestItemLink = class extends LitElement14 {
3195
+ var TestItemLink = class extends LitElement13 {
3105
3196
  static {
3106
- this.styles = css8`
3197
+ this.styles = css7`
3107
3198
  :host {
3108
3199
  ${btn};
3109
3200
  }
@@ -3127,2071 +3218,2218 @@ var TestItemLink = class extends LitElement14 {
3127
3218
  dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
3128
3219
  }
3129
3220
  render() {
3130
- return html13` <slot></slot> `;
3221
+ return html12` <slot></slot> `;
3131
3222
  }
3132
3223
  };
3133
- __decorate14([
3134
- property11({ type: String, attribute: "item-id" })
3224
+ __decorate15([
3225
+ property12({ type: String, attribute: "item-id" })
3135
3226
  ], TestItemLink.prototype, "itemId", void 0);
3136
3227
 
3137
- // ../qti-test/dist/components/test-item-to-speech/test-item-to-speech.js
3138
- import { html as html14, LitElement as LitElement15, css as css9 } from "lit";
3139
- import { consume as consume8, provide as provide3, createContext as createContext2 } from "@lit/context";
3140
- import { property as property12, state as state4 } from "lit/decorators.js";
3141
- import { ifDefined } from "lit/directives/if-defined.js";
3142
- var __decorate15 = function(decorators, target, key, desc) {
3228
+ // ../qti-test/dist/components/test-navigation/test-navigation.js
3229
+ import { ContextConsumer, consume as consume8, provide as provide3 } from "@lit/context";
3230
+ import { html as html13, LitElement as LitElement14 } from "lit";
3231
+ import { property as property13, state as state4 } from "lit/decorators.js";
3232
+ var __decorate16 = function(decorators, target, key, desc) {
3143
3233
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3144
3234
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3145
3235
  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;
3146
3236
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3147
3237
  };
3148
- var HIGHLIGHT_ELEMENT = "tts-element";
3149
- var HIGHLIGHT_WORD = "tts-word";
3150
- var highlightSheet = null;
3151
- function getHighlightSheet() {
3152
- if (!highlightSheet) {
3153
- highlightSheet = new CSSStyleSheet();
3154
- highlightSheet.replaceSync(`
3155
- ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
3156
- ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
3157
- `);
3238
+ var newQtiContext = () => ({
3239
+ QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
3240
+ });
3241
+ var TestNavigation = class extends LitElement14 {
3242
+ /**
3243
+ * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
3244
+ * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
3245
+ * shuffle seed here keeps working. Removed in the next major.
3246
+ *
3247
+ * Written before the navigation is inside a test, it waits and is handed over on connect.
3248
+ */
3249
+ get qtiContext() {
3250
+ return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
3158
3251
  }
3159
- return highlightSheet;
3160
- }
3161
- var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
3162
- var ICONS = {
3163
- play: "M8 5v14l11-7z",
3164
- pause: "M6 5h4v14H6zM14 5h4v14h-4z",
3165
- stop: "M6 6h12v12H6z",
3166
- prev: "M6 5h2v14H6zM20 5v14L9 12z",
3167
- next: "M16 5h2v14h-2zM4 5v14l11-7z",
3168
- pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
3169
- };
3170
- var iconContent = (icon, label) => {
3171
- const svg = html14`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
3172
- <path d="${ICONS[icon]}"></path>
3173
- </svg>`;
3174
- return html14`${svg}<span class="label">${label}</span>`;
3175
- };
3176
- var TtsButtonBase = class extends LitElement15 {
3177
- static {
3178
- this.styles = css9`
3179
- :host {
3180
- display: inline-flex;
3181
- }
3182
- button {
3183
- ${btn};
3184
- min-inline-size: var(--test-button-size, 2.25rem);
3185
- padding-inline: 0.5rem;
3186
- /* Containing block for the visually hidden .label. Without it the label is placed against
3187
- the nearest positioned ancestor, which can sit outside a scroll container and make the
3188
- page as tall as the scrolled content. */
3189
- position: relative;
3190
- }
3191
- button:hover:not(:disabled) {
3192
- ${btnInteractive};
3193
- }
3194
- button:focus-visible {
3195
- ${focusRing};
3196
- }
3197
- button:disabled {
3198
- ${dis};
3199
- }
3200
- button[aria-pressed='true'],
3201
- button[aria-pressed='true']:hover {
3202
- background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
3203
- color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
3204
- }
3205
- svg,
3206
- ::slotted(svg) {
3207
- flex: none;
3208
- inline-size: var(--test-tts-icon-size, 1.125rem);
3209
- block-size: var(--test-tts-icon-size, 1.125rem);
3210
- }
3211
- svg {
3212
- fill: currentColor;
3213
- }
3214
- /* The default content is icon-only; this keeps the button's accessible name. */
3215
- .label {
3216
- position: absolute;
3217
- inline-size: 1px;
3218
- block-size: 1px;
3219
- overflow: hidden;
3220
- clip-path: inset(50%);
3221
- white-space: nowrap;
3252
+ set qtiContext(value) {
3253
+ if (!this.#warnedQtiContext) {
3254
+ this.#warnedQtiContext = true;
3255
+ console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.");
3222
3256
  }
3223
- `;
3257
+ this.#writeQtiContext(value);
3224
3258
  }
3225
- #internals = this.attachInternals();
3226
- #mirroredState;
3227
- #mirroredPicking = false;
3228
- updated(_changed) {
3229
- const state9 = this._tts?.state;
3230
- const picking = this._tts?.picking ?? false;
3231
- if (state9 === this.#mirroredState && picking === this.#mirroredPicking)
3232
- return;
3233
- this.#mirroredState = state9;
3234
- this.#mirroredPicking = picking;
3235
- this.#internals.states.clear();
3236
- if (state9)
3237
- this.#internals.states.add(state9);
3238
- if (picking)
3239
- this.#internals.states.add("picking");
3259
+ #pendingQtiContext;
3260
+ #warnedQtiContext;
3261
+ /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */
3262
+ #writeQtiContext(value) {
3263
+ const owner = this.#owner();
3264
+ if (owner)
3265
+ owner.qtiContext = value;
3266
+ else
3267
+ this.#pendingQtiContext = value;
3240
3268
  }
3241
- };
3242
- __decorate15([
3243
- property12({ type: String })
3244
- ], TtsButtonBase.prototype, "label", void 0);
3245
- __decorate15([
3246
- consume8({ context: ttsContext, subscribe: true })
3247
- ], TtsButtonBase.prototype, "_tts", void 0);
3248
- var TestItemToSpeech = class extends LitElement15 {
3249
- static {
3250
- this.styles = css9`
3251
- :host {
3252
- display: inline-flex;
3253
- flex-wrap: wrap;
3254
- align-items: center;
3255
- gap: var(--test-tts-gap, 0.25rem);
3256
- }
3257
- `;
3269
+ /**
3270
+ * The `qti-test` this navigation is in, found through context so it works across shadow roots.
3271
+ * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.
3272
+ */
3273
+ #testHost;
3274
+ #owner() {
3275
+ return this.#testHost.value ?? null;
3258
3276
  }
3259
- #internals;
3260
- // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
3261
- // placeholder itself is looked up on every use — a host may swap the element.
3262
- #stimulusMode;
3263
- // Stimulus mode: resets the player when the stimulus content next to it is replaced.
3264
- #stimulusObserver;
3265
- // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
3266
- // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
3267
- #contentMode;
3268
- // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
3269
- #itemRef;
3270
- // Where the item-connected (and, in cursor mode, navigation) events are listened for.
3271
- #eventHost;
3272
- #boundHandleItemConnected;
3273
- #boundHandleNavigation;
3274
- // Cursor mode: the previous navigation position, to detect moving to another item or section.
3275
- #prevNavItemRefId;
3276
- #prevNavSectionId;
3277
- // Current set of block-level reading elements for the item
3278
- #readingElements;
3279
- #currentElementIndex;
3280
- // Text nodes of the element currently being spoken (for word-boundary highlight)
3281
- #textNodes;
3282
- // The utterance this player is speaking; lets the error handler tell "our speech was
3283
- // cancelled by another player" apart from a cancel we issued ourselves.
3284
- #currentUtterance;
3285
- // Pick mode: all elements highlighted, a click on one starts reading from there.
3286
- #picking;
3287
- #pickRoot;
3288
- #boundHandlePickClick;
3289
- // Set when the last element has been read: the cursor stays on it (so prev still works),
3290
- // but the next play starts the item over instead of repeating that last element.
3291
- #finished;
3292
- // Two separate CSS Highlight objects
3293
- #elementHighlight;
3294
- // whole-element cursor
3295
- #wordHighlight;
3296
- // current word during speech
3277
+ #testElement;
3278
+ /**
3279
+ * Whether each item's last *ended attempt* reached the optimal outcome, keyed
3280
+ * by item-ref id. Written from #handleItemContextUpdated when processResponse
3281
+ * ends an attempt — never on a plain selection. Mirrors how inline feedback
3282
+ * only re-evaluates when an attempt is processed, so a freshly-picked answer
3283
+ * doesn't flip `done` until the candidate ends the attempt.
3284
+ */
3285
+ #optimality;
3297
3286
  constructor() {
3298
3287
  super();
3299
- this.language = "nl-NL";
3300
- this.#internals = this.attachInternals();
3301
- this.#stimulusMode = false;
3302
- this.#stimulusObserver = null;
3303
- this.#contentMode = false;
3304
- this.#itemRef = null;
3305
- this.#eventHost = null;
3306
- this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
3307
- this.#boundHandleNavigation = () => this.#stop();
3308
- this.#prevNavItemRefId = void 0;
3309
- this.#prevNavSectionId = void 0;
3310
- this.#readingElements = null;
3311
- this.#currentElementIndex = 0;
3312
- this.#textNodes = [];
3313
- this.#currentUtterance = null;
3314
- this.#picking = false;
3315
- this.#pickRoot = null;
3316
- this.#boundHandlePickClick = this.#handlePickClick.bind(this);
3317
- this.#finished = false;
3318
- this.#elementHighlight = new Highlight();
3319
- this.#wordHighlight = new Highlight();
3320
- this._ttsContext = {
3321
- state: "idle",
3322
- currentElementIndex: 0,
3323
- elementCount: 0,
3324
- play: () => this.#playSpeech(),
3325
- pause: () => this.#pause(),
3326
- resume: () => this.#resume(),
3327
- stop: () => {
3328
- this.#stopPicking();
3329
- this.#stop();
3330
- },
3331
- prevElement: () => this.#prevElement(),
3332
- nextElement: () => this.#nextElement(),
3333
- togglePick: () => this.#togglePick(),
3334
- picking: false
3335
- };
3336
- }
3337
- // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
3338
- // render already under way instead of scheduling a second one (Lit's change-in-update).
3339
- willUpdate(changed) {
3340
- super.willUpdate(changed);
3341
- if (this.#stimulusMode || this.#contentMode || this.#itemRef)
3342
- return;
3343
- const item = this._sessionContext?.navItemRefId ?? null;
3344
- const section = this._sessionContext?.navSectionId ?? null;
3345
- const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
3346
- const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
3347
- if (itemChanged || sectionChanged)
3348
- this.#resetReadingPosition();
3349
- this.#prevNavItemRefId = item;
3350
- this.#prevNavSectionId = section;
3351
- }
3352
- /** Stop speech and forget the collected reading elements, so the next play starts afresh. */
3353
- #resetReadingPosition() {
3354
- this.#stopPicking();
3355
- this.#stop();
3356
- this.#readingElements = null;
3357
- this.#currentElementIndex = 0;
3358
- this.#finished = false;
3359
- this.#updateContext();
3360
- }
3361
- connectedCallback() {
3362
- super.connectedCallback();
3363
- this.#setSpeechState("idle");
3364
- this.#stimulusMode = this.#stimulusPlaceholder() !== null;
3365
- if (this.#stimulusMode) {
3366
- this.#stimulusObserver = new MutationObserver((records) => {
3367
- if (records.some((record) => !this.contains(record.target)))
3368
- this.#handleStimulusReplaced();
3369
- });
3370
- this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
3371
- return;
3372
- }
3373
- this.#contentMode = this.#contentElement() !== null;
3374
- if (this.#contentMode)
3375
- return;
3376
- this.#itemRef = this.closest("qti-assessment-item-ref");
3377
- this.#eventHost = this.#itemRef ?? this.closest("test-navigation") ?? this.testHost ?? this.getRootNode();
3378
- this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
3379
- if (!this.#itemRef) {
3380
- this.#eventHost.addEventListener("cito-test-navigate", this.#boundHandleNavigation);
3381
- this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
3382
- }
3383
- }
3384
- disconnectedCallback() {
3385
- super.disconnectedCallback();
3386
- if (this.#currentUtterance) {
3387
- this.#currentUtterance = null;
3388
- speechSynthesis.cancel();
3389
- }
3390
- this.#stopPicking();
3391
- this.#clearAllHighlights();
3392
- this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
3393
- this.#eventHost?.removeEventListener("cito-test-navigate", this.#boundHandleNavigation);
3394
- this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
3395
- this.#eventHost = null;
3396
- this.#itemRef = null;
3397
- this.#stimulusObserver?.disconnect();
3398
- this.#stimulusObserver = null;
3399
- this.#stimulusMode = false;
3400
- this.#contentMode = false;
3401
- }
3402
- render() {
3403
- return html14`<slot></slot>`;
3288
+ this.identifier = void 0;
3289
+ this.initContext = [];
3290
+ this.#warnedQtiContext = false;
3291
+ this.#testHost = new ContextConsumer(this, {
3292
+ context: testHostContext,
3293
+ subscribe: true,
3294
+ callback: (host) => {
3295
+ if (host && this.#pendingQtiContext) {
3296
+ host.qtiContext = this.#pendingQtiContext;
3297
+ this.#pendingQtiContext = void 0;
3298
+ }
3299
+ }
3300
+ });
3301
+ this.configContext = {};
3302
+ this.autoScoreItems = false;
3303
+ this.#optimality = /* @__PURE__ */ new Map();
3304
+ this.#itemElement = (identifier) => this.#assessmentItemFor(identifier) ?? null;
3305
+ listenPublic2(this, "cito-test-loaded", this.#handleTestConnected.bind(this));
3306
+ this.addEventListener("qti-assessment-item-connected", this.#handleItemConnected.bind(this));
3307
+ listenPublic(this, "cito-item-response-changed", this.#handleInteractionChanged.bind(this));
3308
+ this.addEventListener("qti-item-context-updated", this.#handleItemContextUpdated.bind(this));
3309
+ listenPublic2(this, "cito-test-end-attempt", this.#handleTestEndAttempt.bind(this));
3310
+ listenPublic2(this, "cito-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
3404
3311
  }
3405
3312
  /**
3406
- * An item (re)rendered. If it is ours — e.g. after navigating to the item already shown — the
3407
- * elements collected earlier are detached now. That does not move the navigation cursor, so
3408
- * the check in updated() does not catch it.
3313
+ * Latch whether an item reached its optimal outcome whenever it has just ended
3314
+ * an attempt. processResponse — fired by test-end-attempt, autoscore, or an
3315
+ * in-item end-attempt interaction — flags its context update with
3316
+ * `responseProcessed`; a plain selection updates the context without it, so
3317
+ * `done` can't flip until the candidate actually ends the attempt.
3409
3318
  */
3410
- #handleItemConnected(event) {
3411
- if (this.#readingElements === null)
3319
+ #handleItemContextUpdated(event) {
3320
+ if (!event.detail?.responseProcessed)
3412
3321
  return;
3413
- const identifier = event.detail?.identifier;
3414
- if (this.#itemRef || identifier === this._sessionContext?.navItemRefId)
3415
- this.#resetReadingPosition();
3322
+ const itemContext = event.detail.itemContext;
3323
+ if (!itemContext?.identifier)
3324
+ return;
3325
+ const optimality = this.#assessOptimality(itemContext);
3326
+ this.#optimality.set(itemContext.identifier, optimality);
3327
+ const computedItem = this.computedItemFor(itemContext.identifier);
3328
+ const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
3329
+ const completionStatus = itemContext.variables?.find((v) => v.identifier === "completionStatus")?.value;
3330
+ this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.maxAttempts, computedItem?.adaptive, completionStatus));
3416
3331
  }
3417
3332
  /**
3418
- * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
3419
- * collected, so the next play reads the new content from the top. Unlike
3420
- * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
3421
- * while an item player on the same page is speaking.
3333
+ * Extension point for presentation packages reacting to an ended attempt.
3334
+ * `done` is settled here — from the freshly latched optimality and the
3335
+ * session-control cascade — because the computed context only catches up on
3336
+ * the next update, after this event has finished bubbling.
3422
3337
  */
3423
- #handleStimulusReplaced() {
3424
- if (this.#currentUtterance) {
3425
- this.#currentUtterance = null;
3426
- speechSynthesis.cancel();
3427
- }
3428
- this.#stopPicking();
3429
- this.#clearAllHighlights();
3430
- this.#setSpeechState("idle");
3431
- this.#readingElements = null;
3432
- this.#currentElementIndex = 0;
3433
- this.#finished = false;
3434
- this.#updateContext();
3338
+ afterAttemptEnded(_assessmentItem, _computedItem, _done) {
3435
3339
  }
3436
- /**
3437
- * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
3438
- * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
3439
- * loading replaces the placeholder's content.
3440
- */
3441
- #stimulusPlaceholder() {
3442
- return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
3340
+ /** The computed-context entry for an item, from the session-control cascade. */
3341
+ computedItemFor(identifier) {
3342
+ return this.computedContext?.testParts?.flatMap((part) => part.sections).flatMap((section) => section.items).find((i) => i.identifier === identifier);
3443
3343
  }
3444
- /**
3445
- * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
3446
- * The marker goes on one container; the player finds the readable elements inside it.
3447
- */
3448
- #contentElement() {
3449
- return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
3344
+ /** The assessment item for an item-ref id, if it has been rendered. */
3345
+ #assessmentItemFor(identifier) {
3346
+ if (!identifier)
3347
+ return void 0;
3348
+ const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"]`);
3349
+ return itemRef?.assessmentItem ?? void 0;
3350
+ }
3351
+ /** `computedContext.itemElement`: one function for the life of this element, carried along by every update. */
3352
+ #itemElement;
3353
+ /** The currently active assessment item, exposed for optional presentation extensions. */
3354
+ get activeAssessmentItem() {
3355
+ if (!this.#testElement || !this._sessionContext?.navItemRefId)
3356
+ return void 0;
3357
+ return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
3450
3358
  }
3451
3359
  /**
3452
- * The element whose text is read: the stimulus body next to the player (stimulus mode), the
3453
- * marked content next to it (content mode), or the item body of the item to read.
3360
+ * Handles the 'test-end-attempt' event.
3361
+ * @private
3362
+ * @listens TestNavigation#test-end-attempt
3363
+ * @param {CustomEvent} event - The custom event object.
3454
3364
  */
3455
- #resolveReadingRoot() {
3456
- if (this.#stimulusMode)
3457
- return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
3458
- if (this.#contentMode)
3459
- return this.#contentElement();
3460
- return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
3365
+ #handleTestEndAttempt(_event) {
3366
+ const qtiAssessmentItemEl = this.activeAssessmentItem;
3367
+ if (!qtiAssessmentItemEl)
3368
+ return;
3369
+ const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
3370
+ qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
3461
3371
  }
3462
- /** The item to read: our item-ref's (item-ref mode), or the navigated one (cursor mode). */
3463
- #resolveItem() {
3464
- if (this.#itemRef)
3465
- return this.#itemRef.assessmentItem;
3466
- const identifier = this._sessionContext?.navItemRefId;
3467
- return identifier ? this.#findItemInDom(identifier) : null;
3372
+ #handleTestUpdateOutcomeVariable(event) {
3373
+ const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);
3374
+ if (!qtiAssessmentItemEl)
3375
+ return;
3376
+ qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
3468
3377
  }
3469
- /**
3470
- * Cursor mode: find the rendered item for an item-ref identifier. Our own `<qti-test>` first —
3471
- * a page can hold several tests showing the same item — then every root from here up to the
3472
- * document; each scope directly and in the `test-container` shadow roots inside it.
3473
- */
3474
- #findItemInDom(identifier) {
3475
- const selector = `qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"] qti-assessment-item`;
3476
- const search = (scope) => {
3477
- const direct = scope.querySelector(selector);
3478
- if (direct)
3479
- return direct;
3480
- for (const container of Array.from(scope.querySelectorAll("test-container"))) {
3481
- const inShadow = container.shadowRoot?.querySelector(selector);
3482
- if (inShadow)
3483
- return inShadow;
3378
+ #handleInteractionChanged(_event) {
3379
+ if (this.autoScoreItems) {
3380
+ const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
3381
+ if (!assessmentItem)
3382
+ return;
3383
+ const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
3384
+ if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
3385
+ const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
3386
+ assessmentItem.processResponse(true, reportValidityAfterScoring);
3484
3387
  }
3485
- return null;
3486
- };
3487
- const test = this.closest("qti-test");
3488
- const inTest = test && search(test);
3489
- if (inTest)
3490
- return inTest;
3491
- let root = this.getRootNode();
3492
- for (; ; ) {
3493
- const found = search(root);
3494
- if (found)
3495
- return found;
3496
- const host = root.host;
3497
- if (!host)
3498
- return null;
3499
- root = host.getRootNode();
3500
3388
  }
3501
3389
  }
3502
- /** Update speech state on both the context (notifies children) and the host's CSS custom states. */
3503
- #setSpeechState(state9) {
3504
- this._ttsContext = { ...this._ttsContext, state: state9 };
3505
- this.#internals.states.delete("idle");
3506
- this.#internals.states.delete("playing");
3507
- this.#internals.states.delete("paused");
3508
- this.#internals.states.add(state9);
3390
+ render() {
3391
+ return html13`<slot></slot>`;
3509
3392
  }
3510
- /** Push currentElementIndex and elementCount into context so children can react. */
3511
- #updateContext() {
3512
- this._ttsContext = {
3513
- ...this._ttsContext,
3514
- currentElementIndex: this.#currentElementIndex,
3515
- elementCount: this.#getReadingElements().length
3393
+ /* PK: on test connected we can build the computed context */
3394
+ #handleTestConnected(event) {
3395
+ this.#testElement = event.detail;
3396
+ this.#optimality.clear();
3397
+ if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
3398
+ const currentContext = this.qtiContext.QTI_CONTEXT || {
3399
+ testIdentifier: "",
3400
+ candidateIdentifier: "not set",
3401
+ environmentIdentifier: "default"
3402
+ };
3403
+ this.#writeQtiContext({
3404
+ QTI_CONTEXT: {
3405
+ ...currentContext,
3406
+ testIdentifier: this.#testElement.identifier,
3407
+ environmentIdentifier: currentContext.environmentIdentifier || "default"
3408
+ }
3409
+ });
3410
+ }
3411
+ const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
3412
+ contextDeclarations.forEach((declaration) => {
3413
+ const defaultValues = this.#extractDefaultValues(declaration);
3414
+ if (Object.keys(defaultValues).length > 0) {
3415
+ this.#writeQtiContext({
3416
+ QTI_CONTEXT: {
3417
+ ...defaultValues,
3418
+ // Default values first
3419
+ ...this.qtiContext.QTI_CONTEXT
3420
+ // Runtime values override defaults
3421
+ }
3422
+ });
3423
+ }
3424
+ });
3425
+ const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
3426
+ this.computedContext = {
3427
+ itemElement: this.#itemElement,
3428
+ identifier: this.#testElement.identifier,
3429
+ title: this.#testElement.title,
3430
+ view: this._sessionContext?.view,
3431
+ plugins: this._sessionContext?.plugins ?? {},
3432
+ testParts: testPartElements.map((testPart) => {
3433
+ const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
3434
+ const testPartSessionControl = testPart.querySelector(":scope > qti-item-session-control");
3435
+ const partAllowSkipping = testPartSessionControl ? testPartSessionControl.allowSkipping : true;
3436
+ const partMaxAttempts = testPartSessionControl ? testPartSessionControl.maxAttempts : 1;
3437
+ const partShowFeedback = testPartSessionControl ? testPartSessionControl.showFeedback : false;
3438
+ const partShowSolution = testPartSessionControl ? testPartSessionControl.showSolution : false;
3439
+ return {
3440
+ active: false,
3441
+ identifier: testPart.identifier,
3442
+ navigationMode: testPart.navigationMode,
3443
+ submissionMode: testPart.submissionMode,
3444
+ allowSkipping: partAllowSkipping,
3445
+ sections: sectionElements.map((section) => {
3446
+ const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
3447
+ const sectionSessionControl = section.querySelector(":scope > qti-item-session-control");
3448
+ const sectionAllowSkipping = sectionSessionControl ? sectionSessionControl.allowSkipping : partAllowSkipping;
3449
+ const sectionMaxAttempts = sectionSessionControl ? sectionSessionControl.maxAttempts : partMaxAttempts;
3450
+ const sectionShowFeedback = sectionSessionControl ? sectionSessionControl.showFeedback : partShowFeedback;
3451
+ const sectionShowSolution = sectionSessionControl ? sectionSessionControl.showSolution : partShowSolution;
3452
+ return {
3453
+ active: false,
3454
+ identifier: section.identifier,
3455
+ title: section.title,
3456
+ navigationMode: section.navigationMode,
3457
+ submissionMode: section.submissionMode,
3458
+ allowSkipping: sectionAllowSkipping,
3459
+ items: itemElements.map((item) => {
3460
+ const itemSessionControl = item.querySelector(":scope > qti-item-session-control");
3461
+ const itemAllowSkipping = itemSessionControl ? itemSessionControl.allowSkipping : sectionAllowSkipping;
3462
+ const itemMaxAttempts = itemSessionControl ? itemSessionControl.maxAttempts : sectionMaxAttempts;
3463
+ const itemShowFeedback = itemSessionControl ? itemSessionControl.showFeedback : sectionShowFeedback;
3464
+ const itemShowSolution = itemSessionControl ? itemSessionControl.showSolution : sectionShowSolution;
3465
+ return {
3466
+ ...this.initContext?.find((i) => i.identifier === item.identifier),
3467
+ active: false,
3468
+ identifier: item.identifier,
3469
+ categories: item.category ? item.category?.split(" ") : [],
3470
+ href: item.href,
3471
+ variables: [],
3472
+ allowSkipping: itemAllowSkipping,
3473
+ maxAttempts: itemMaxAttempts,
3474
+ showFeedback: itemShowFeedback,
3475
+ showSolution: itemShowSolution
3476
+ };
3477
+ })
3478
+ };
3479
+ })
3480
+ };
3481
+ })
3516
3482
  };
3517
3483
  }
3518
3484
  /**
3519
- * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
3520
- * first call), filtered live for visibility on every call. Feedback and other
3521
- * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
3522
- * CSS custom state reveals it) is excluded while hidden and picked up again once shown,
3523
- * without needing to re-collect the candidate set.
3485
+ * Extract default values from a qti-context-declaration element
3524
3486
  */
3525
- #getReadingElements() {
3526
- if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
3527
- this.#readingElements = null;
3528
- this.#currentElementIndex = 0;
3529
- this.#finished = false;
3530
- }
3531
- if (this.#readingElements === null) {
3532
- const root = this.#resolveReadingRoot();
3533
- if (!root)
3534
- return [];
3535
- const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
3536
- this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
3487
+ #extractDefaultValues(declaration) {
3488
+ const defaultValues = {};
3489
+ const defaultValueElement = declaration.querySelector("qti-default-value");
3490
+ if (!defaultValueElement) {
3491
+ return defaultValues;
3537
3492
  }
3538
- return this.#readingElements.filter((el) => this.#isVisible(el));
3493
+ const valueElements = defaultValueElement.querySelectorAll("qti-value[field-identifier]");
3494
+ valueElements.forEach((valueElement) => {
3495
+ const fieldIdentifier = valueElement.getAttribute("field-identifier");
3496
+ const baseType = valueElement.getAttribute("base-type") || "string";
3497
+ const textContent = valueElement.textContent?.trim() || "";
3498
+ if (fieldIdentifier) {
3499
+ let value = textContent;
3500
+ switch (baseType) {
3501
+ case "integer":
3502
+ value = parseInt(textContent, 10);
3503
+ break;
3504
+ case "float":
3505
+ case "duration":
3506
+ value = parseFloat(textContent);
3507
+ break;
3508
+ case "boolean":
3509
+ value = textContent.toLowerCase() === "true";
3510
+ break;
3511
+ case "string":
3512
+ default:
3513
+ value = textContent;
3514
+ break;
3515
+ }
3516
+ defaultValues[fieldIdentifier] = value;
3517
+ }
3518
+ });
3519
+ return defaultValues;
3539
3520
  }
3540
- /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
3541
- #isVisible(element) {
3542
- if (typeof element.checkVisibility === "function") {
3543
- return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
3544
- }
3545
- return element.getClientRects().length > 0;
3521
+ /* PK: on item connected we can add item only properties in the xml */
3522
+ #handleItemConnected(event) {
3523
+ const itemElement = event.detail;
3524
+ this.computedContext = {
3525
+ ...this.computedContext,
3526
+ testParts: this.computedContext.testParts.map((testPart) => {
3527
+ return {
3528
+ ...testPart,
3529
+ sections: testPart.sections.map((section) => {
3530
+ return {
3531
+ ...section,
3532
+ items: section.items.map((item) => {
3533
+ if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
3534
+ return item;
3535
+ }
3536
+ const scoreOutcome = itemElement.querySelector("qti-outcome-declaration[identifier='SCORE']");
3537
+ const externalScored = scoreOutcome?.getAttribute("externalScored");
3538
+ const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
3539
+ const containsCorrectResponse = Array.from(responseDeclarations).some((r) => r.querySelector("qti-correct-response"));
3540
+ const containsMapping = Array.from(responseDeclarations).some((r) => {
3541
+ const mapping = r.querySelector("qti-mapping");
3542
+ const areaMapping = r.querySelector("qti-area-mapping");
3543
+ return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
3544
+ });
3545
+ const hasCorrectResponse = containsCorrectResponse || containsMapping;
3546
+ const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
3547
+ return {
3548
+ ...item,
3549
+ assessmentItemIdentifier: itemElement.getAttribute("identifier"),
3550
+ label: itemElement.getAttribute("label"),
3551
+ title: itemElement.title,
3552
+ externalScored,
3553
+ adaptive: itemElement.adaptive == "true" || false,
3554
+ timeDependent: itemElement.timeDependent == "true" || false,
3555
+ variables: itemElement.variables,
3556
+ hasCorrectResponse,
3557
+ hasResponseProcessing
3558
+ };
3559
+ })
3560
+ };
3561
+ })
3562
+ };
3563
+ })
3564
+ };
3565
+ }
3566
+ /* PK: on every change of the candidate we will recomputed the computedContext */
3567
+ willUpdate(_changedProperties) {
3568
+ if (!this.computedContext)
3569
+ return;
3570
+ let itemIndex = 1;
3571
+ this.computedContext = {
3572
+ ...this.computedContext,
3573
+ view: this._sessionContext?.view,
3574
+ plugins: this._sessionContext?.plugins ?? {},
3575
+ testParts: this.computedContext.testParts.map((testPart) => {
3576
+ return {
3577
+ ...testPart,
3578
+ active: this._sessionContext?.navPartId === testPart.identifier || false,
3579
+ sections: testPart.sections.map((section) => {
3580
+ return {
3581
+ ...section,
3582
+ active: this._sessionContext?.navSectionId === section.identifier || false,
3583
+ completed: section.items.every((item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"),
3584
+ items: section.items.map((item) => {
3585
+ const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
3586
+ const computedItem = {
3587
+ ...item,
3588
+ ...itemContext,
3589
+ ...this.initContext?.find((i) => i.identifier === item.identifier)
3590
+ };
3591
+ const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
3592
+ const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
3593
+ const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
3594
+ const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
3595
+ const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
3596
+ const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
3597
+ const valid = itemContext?.valid ?? true;
3598
+ const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
3599
+ const isDefaultResponse = responseVars.every((v) => {
3600
+ if (v.value === void 0 || v.value === null) {
3601
+ return true;
3602
+ }
3603
+ let fallbackValue;
3604
+ switch (v.baseType) {
3605
+ case "integer":
3606
+ case "float":
3607
+ case "duration":
3608
+ fallbackValue = "0";
3609
+ break;
3610
+ case "boolean":
3611
+ fallbackValue = "false";
3612
+ break;
3613
+ case "string":
3614
+ case "directedPair":
3615
+ case "identifier":
3616
+ case "pair":
3617
+ case "record":
3618
+ default:
3619
+ fallbackValue = "";
3620
+ break;
3621
+ }
3622
+ const defaultValue = v.defaultValue ?? fallbackValue;
3623
+ if (Array.isArray(v.value)) {
3624
+ const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
3625
+ return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
3626
+ }
3627
+ return v.value === defaultValue;
3628
+ });
3629
+ const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
3630
+ const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
3631
+ const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
3632
+ let optimality = this.#optimality.get(computedItem.identifier);
3633
+ if (optimality === void 0) {
3634
+ optimality = itemContext ? this.#assessOptimality(itemContext) : "unscored";
3635
+ if (numAttempts > 0)
3636
+ this.#optimality.set(computedItem.identifier, optimality);
3637
+ }
3638
+ const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts, computedItem.adaptive, completionStatus);
3639
+ return {
3640
+ ...computedItem,
3641
+ completionStatus,
3642
+ numAttempts,
3643
+ score,
3644
+ response,
3645
+ index,
3646
+ active,
3647
+ valid,
3648
+ isDefaultResponse,
3649
+ maxScore,
3650
+ done,
3651
+ // Reflects the last *ended* attempt only. Read the latch directly
3652
+ // (not the `optimality` local) — the latch is written solely on
3653
+ // responseProcessed / restore-seed (line above, guarded by
3654
+ // numAttempts > 0), so a freshly-picked mid-attempt selection
3655
+ // computed live is never stored and never counts as optimal.
3656
+ optimal: this.#optimality.get(computedItem.identifier) === "optimal"
3657
+ // type,
3658
+ // correct,
3659
+ // incorrect,
3660
+ // completed
3661
+ };
3662
+ })
3663
+ };
3664
+ })
3665
+ };
3666
+ })
3667
+ };
3668
+ this.dispatchEvent(new CustomEvent("qti-computed-context-updated", {
3669
+ detail: this.computedContext,
3670
+ bubbles: true
3671
+ }));
3546
3672
  }
3547
3673
  /**
3548
- * Resolve the speech language for a reading element.
3549
- * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
3550
- * Empty `lang=""` is treated as absent.
3674
+ * Decide whether an item should be treated as "the candidate is done with it"
3675
+ * for the purpose of gating forward navigation and further attempts.
3676
+ *
3677
+ * - The candidate must have actually ended an attempt (numAttempts > 0).
3678
+ * - Once attempted, the item is done if they reached the optimal outcome
3679
+ * ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
3680
+ * done while a better attempt is still possible ('suboptimal') and attempts
3681
+ * remain — see #assessOptimality for how "optimal" is determined.
3682
+ *
3683
+ * `optimality` reflects the last *ended attempt* (see #optimality), not the
3684
+ * live selection — so a freshly-picked optimal answer doesn't count as done
3685
+ * until test-end-attempt evaluates it.
3686
+ *
3687
+ * Adaptive items decide this themselves: max-attempts does not apply to them
3688
+ * (QTI 3, itemSessionControl), and a wrong attempt may be the step that leads
3689
+ * on to the next part of the item. They are done once their response
3690
+ * processing sets completionStatus to 'completed'.
3551
3691
  */
3552
- #resolveLang(element) {
3553
- let node = element;
3554
- while (node) {
3555
- const lang = node.getAttribute("lang") || node.getAttribute("xml:lang");
3556
- if (lang?.trim())
3557
- return lang.trim();
3558
- node = node.parentElement ?? node.getRootNode().host ?? null;
3559
- }
3560
- const documentLang = document.documentElement.getAttribute("lang");
3561
- if (documentLang?.trim())
3562
- return documentLang.trim();
3563
- return this.language;
3564
- }
3565
- #playSpeech() {
3566
- const elements = this.#getReadingElements();
3567
- if (!elements.length) {
3568
- console.warn("test-item-to-speech: no readable elements found");
3569
- return;
3570
- }
3571
- this.#stopPicking();
3572
- speechSynthesis.cancel();
3573
- if (this.#finished) {
3574
- this.#finished = false;
3575
- this.#currentElementIndex = 0;
3576
- }
3577
- if (this.#contentMode && this.#currentElementIndex === 0)
3578
- this.#readingElements = null;
3579
- this.#speakElement(this.#currentElementIndex);
3692
+ #isItemDone(numAttempts, optimality, maxAttempts, adaptive, completionStatus) {
3693
+ if (numAttempts === 0)
3694
+ return false;
3695
+ if (adaptive)
3696
+ return completionStatus === "completed";
3697
+ if (optimality !== "suboptimal")
3698
+ return true;
3699
+ const max = maxAttempts ?? 1;
3700
+ return max > 0 && numAttempts >= max;
3580
3701
  }
3581
- /** Speak the element at the given index, then auto-advance when it ends. */
3582
- #speakElement(index) {
3583
- const elements = this.#getReadingElements();
3584
- if (index >= elements.length) {
3585
- this.#clearWordHighlight();
3586
- this.#currentElementIndex = elements.length - 1;
3587
- if (elements.length > 0)
3588
- this.#highlightElement(elements[this.#currentElementIndex]);
3589
- this.#finished = true;
3590
- this.#setSpeechState("idle");
3591
- this.#updateContext();
3592
- return;
3593
- }
3594
- this.#currentElementIndex = index;
3595
- this.#finished = false;
3596
- this.#updateContext();
3597
- const element = elements[index];
3598
- element.scrollIntoView({ behavior: "smooth", block: "nearest" });
3599
- this.#highlightElement(element);
3600
- this.#textNodes = this.#collectTextNodes(element);
3601
- const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
3602
- if (!text.trim()) {
3603
- this.#speakElement(index + 1);
3604
- return;
3702
+ /**
3703
+ * Decide whether an item's submission is as good as it can get — i.e. the
3704
+ * candidate reached the *optimal* outcome, so there's no reason to make them
3705
+ * try again. 'optimal' means best achievable, 'suboptimal' means a better
3706
+ * attempt is still possible, 'unscored' means there's nothing to judge against.
3707
+ * ("optimal" is the spec's own word — a qti-correct-response is defined as
3708
+ * "the (or an) optimal value".)
3709
+ *
3710
+ * Two signals, in order of authority:
3711
+ * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).
3712
+ * This correctly handles partial-credit / qti-mapping items, where an exact
3713
+ * response match would under- or over-judge.
3714
+ * 2. The declared qti-correct-response, for items that aren't scored (no
3715
+ * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping
3716
+ * variables like numAttempts can be typed 'response' but never declare a
3717
+ * correctResponse, so we filter on a declared correctResponse.
3718
+ *
3719
+ * Items with neither a comparable score nor a correctResponse (essays, info
3720
+ * items, etc.) are 'unscored' — there's no optimal value to require, so one
3721
+ * attempt is enough.
3722
+ */
3723
+ #assessOptimality(item) {
3724
+ const variables = item.variables ?? [];
3725
+ const score = this.#numericVariable(variables, "SCORE");
3726
+ const maxScore = this.#numericVariable(variables, "MAXSCORE");
3727
+ if (score !== null && maxScore !== null) {
3728
+ return score >= maxScore ? "optimal" : "suboptimal";
3605
3729
  }
3606
- const utterance = new SpeechSynthesisUtterance(text);
3607
- utterance.lang = this.#resolveLang(element);
3608
- utterance.rate = 1;
3609
- utterance.onboundary = (event) => {
3610
- if (event.name !== "word")
3611
- return;
3612
- this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
3613
- };
3614
- utterance.onend = () => {
3615
- if (this.#currentUtterance !== utterance)
3616
- return;
3617
- this.#currentUtterance = null;
3618
- this.#clearWordHighlight();
3619
- this.#speakElement(this.#currentElementIndex + 1);
3620
- };
3621
- utterance.onerror = () => {
3622
- if (this.#currentUtterance !== utterance)
3623
- return;
3624
- this.#currentUtterance = null;
3625
- this.#clearAllHighlights();
3626
- this.#setSpeechState("idle");
3627
- };
3628
- this.#currentUtterance = utterance;
3629
- speechSynthesis.speak(utterance);
3630
- this.#setSpeechState("playing");
3730
+ const responseVars = variables.filter((v) => v.type === "response" && v.correctResponse !== void 0 && v.correctResponse !== null);
3731
+ if (responseVars.length === 0)
3732
+ return "unscored";
3733
+ const allMatch = responseVars.every((v) => {
3734
+ const expected = v.correctResponse;
3735
+ const actual = v.value;
3736
+ if (actual === void 0 || actual === null)
3737
+ return false;
3738
+ if (Array.isArray(expected) && Array.isArray(actual)) {
3739
+ return expected.length === actual.length && expected.every((e) => actual.includes(e));
3740
+ }
3741
+ if (Array.isArray(expected) || Array.isArray(actual))
3742
+ return false;
3743
+ return expected === actual;
3744
+ });
3745
+ return allMatch ? "optimal" : "suboptimal";
3631
3746
  }
3632
- #pause() {
3633
- speechSynthesis.pause();
3634
- this.#setSpeechState("paused");
3747
+ /** Read a single numeric outcome value, or null when absent / non-numeric. */
3748
+ #numericVariable(variables, identifier) {
3749
+ const raw = variables?.find((v) => v.identifier === identifier)?.value;
3750
+ if (raw === void 0 || raw === null || Array.isArray(raw))
3751
+ return null;
3752
+ const parsed = parseFloat(raw.toString());
3753
+ return Number.isNaN(parsed) ? null : parsed;
3635
3754
  }
3636
- #resume() {
3637
- speechSynthesis.resume();
3638
- this.#setSpeechState("playing");
3755
+ };
3756
+ __decorate16([
3757
+ property13({ type: String })
3758
+ ], TestNavigation.prototype, "identifier", void 0);
3759
+ __decorate16([
3760
+ state4()
3761
+ ], TestNavigation.prototype, "initContext", void 0);
3762
+ __decorate16([
3763
+ state4(),
3764
+ consume8({ context: configContext, subscribe: true })
3765
+ ], TestNavigation.prototype, "configContext", void 0);
3766
+ __decorate16([
3767
+ state4(),
3768
+ consume8({ context: testContext, subscribe: true })
3769
+ ], TestNavigation.prototype, "_testContext", void 0);
3770
+ __decorate16([
3771
+ state4(),
3772
+ consume8({ context: sessionContext, subscribe: true })
3773
+ ], TestNavigation.prototype, "_sessionContext", void 0);
3774
+ __decorate16([
3775
+ state4(),
3776
+ provide3({ context: computedContext })
3777
+ ], TestNavigation.prototype, "computedContext", void 0);
3778
+ __decorate16([
3779
+ property13({ type: Boolean, attribute: "auto-score-items" })
3780
+ ], TestNavigation.prototype, "autoScoreItems", void 0);
3781
+
3782
+ // ../qti-test/dist/components/test-next/test-next.js
3783
+ import { css as css8, html as html14, LitElement as LitElement15 } from "lit";
3784
+ import { property as property14 } from "lit/decorators.js";
3785
+ import { consume as consume9 } from "@lit/context";
3786
+ var __decorate17 = function(decorators, target, key, desc) {
3787
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3788
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3789
+ 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;
3790
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3791
+ };
3792
+ var TestNext = class extends LitElement15 {
3793
+ _handleTestElementChange(_oldValue, newValue) {
3794
+ if (newValue) {
3795
+ this.requestUpdate();
3796
+ }
3639
3797
  }
3640
- #stop() {
3641
- this.#currentUtterance = null;
3642
- speechSynthesis.cancel();
3643
- this.#clearAllHighlights();
3644
- this.#setSpeechState("idle");
3798
+ static {
3799
+ this.styles = css8`
3800
+ :host {
3801
+ ${btn};
3802
+ }
3803
+ :host(:hover:not([disabled])) {
3804
+ ${btnInteractive};
3805
+ }
3806
+ :host(:focus-visible) {
3807
+ ${focusRing};
3808
+ }
3809
+ :host([disabled]) {
3810
+ ${dis};
3811
+ }
3812
+ `;
3645
3813
  }
3646
- // ─── Pick mode ────────────────────────────────────────────────────────────
3647
- #togglePick() {
3648
- if (this.#picking)
3649
- this.#stopPicking();
3650
- else
3651
- this.#startPicking();
3814
+ #internals;
3815
+ constructor() {
3816
+ super();
3817
+ this._internalDisabled = true;
3818
+ this.#internals = this.attachInternals();
3819
+ this.#internals.role = "button";
3820
+ this.#internals.ariaLabel = "Next item";
3821
+ this.addEventListener("click", (e) => {
3822
+ e.preventDefault();
3823
+ if (!this._internalDisabled)
3824
+ this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);
3825
+ });
3652
3826
  }
3653
- /** Highlight every reading element and wait for a click on one of them. */
3654
- #startPicking() {
3655
- if (this.#contentMode)
3656
- this.#readingElements = null;
3657
- const elements = this.#getReadingElements();
3658
- if (!elements.length) {
3659
- console.warn("test-item-to-speech: no readable elements found");
3660
- return;
3661
- }
3662
- this.#stop();
3663
- this.#picking = true;
3664
- this.#internals.states.add("picking");
3665
- this.#highlightElements(elements);
3666
- this.#pickRoot = elements[0].getRootNode();
3667
- this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
3668
- this._ttsContext = { ...this._ttsContext, picking: true };
3827
+ connectedCallback() {
3828
+ super.connectedCallback();
3829
+ this.checkDisabled();
3669
3830
  }
3670
- #stopPicking() {
3671
- if (!this.#picking)
3831
+ willUpdate(_changedProperties) {
3832
+ if (!this.computedContext)
3672
3833
  return;
3673
- this.#picking = false;
3674
- this.#internals.states.delete("picking");
3675
- this.#pickRoot?.removeEventListener("click", this.#boundHandlePickClick, true);
3676
- this.#pickRoot = null;
3677
- this.#clearAllHighlights();
3678
- this._ttsContext = { ...this._ttsContext, picking: false };
3679
- }
3680
- #handlePickClick(event) {
3681
- const elements = this.#getReadingElements();
3682
- const path = event.composedPath();
3683
- let index = elements.findIndex((el) => path.includes(el));
3684
- if (index < 0) {
3685
- const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
3686
- if (container)
3687
- index = elements.findIndex((el) => container.contains(el));
3688
- }
3689
- if (index < 0)
3834
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3835
+ if (!testPart)
3690
3836
  return;
3691
- event.preventDefault();
3692
- event.stopPropagation();
3693
- this.#stopPicking();
3694
- speechSynthesis.cancel();
3695
- this.#speakElement(index);
3837
+ this.sectionItems = testPart.sections.flatMap((section) => section.items);
3838
+ this.itemIndex = this.sectionItems.findIndex((item) => item.active);
3839
+ this.checkDisabled();
3696
3840
  }
3697
- #prevElement() {
3698
- const elements = this.#getReadingElements();
3699
- if (!elements.length)
3841
+ checkDisabled() {
3842
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3843
+ if (!testPart)
3700
3844
  return;
3701
- this.#currentUtterance = null;
3702
- speechSynthesis.cancel();
3703
- this.#clearWordHighlight();
3704
- this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
3705
- this.#finished = false;
3706
- this.#updateContext();
3707
- const el = elements[this.#currentElementIndex];
3708
- el.scrollIntoView({ behavior: "smooth", block: "nearest" });
3709
- this.#highlightElement(el);
3710
- this.#setSpeechState("idle");
3845
+ const activeSection = testPart.sections.find((s) => s.active);
3846
+ const navigationMode = activeSection?.navigationMode || testPart.navigationMode;
3847
+ const submissionMode = activeSection?.submissionMode || testPart.submissionMode;
3848
+ const activeItem = this.sectionItems[this.itemIndex];
3849
+ const isLinearIndividual = navigationMode === "linear" && submissionMode === "individual";
3850
+ this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 || isLinearIndividual && !activeItem?.done;
3711
3851
  }
3712
- #nextElement() {
3713
- const elements = this.#getReadingElements();
3714
- if (!elements.length)
3715
- return;
3716
- this.#currentUtterance = null;
3717
- speechSynthesis.cancel();
3718
- this.#clearWordHighlight();
3719
- this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
3720
- this.#finished = false;
3721
- this.#updateContext();
3722
- const el = elements[this.#currentElementIndex];
3723
- el.scrollIntoView({ behavior: "smooth", block: "nearest" });
3724
- this.#highlightElement(el);
3725
- this.#setSpeechState("idle");
3726
- }
3727
- /** Walk text nodes without crossing shadow DOM boundaries. */
3728
- #collectTextNodes(root) {
3729
- const nodes = [];
3730
- const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
3731
- let node;
3732
- while (node = walker.nextNode()) {
3733
- if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
3734
- nodes.push(node);
3735
- }
3736
- }
3737
- return nodes;
3852
+ _requestItem(identifier) {
3853
+ dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
3738
3854
  }
3739
- /** Highlight the whole element as the navigation cursor (blue). */
3740
- #highlightElement(element) {
3741
- this.#highlightElements([element]);
3855
+ render() {
3856
+ return html14`<slot></slot>`;
3742
3857
  }
3743
- /** Put the blue cursor highlight on several elements at once (pick mode). */
3744
- #highlightElements(elements) {
3745
- if (!("highlights" in CSS))
3746
- return;
3747
- this.#ensureHighlightStyles();
3748
- this.#elementHighlight.clear();
3749
- for (const element of elements) {
3750
- const range = new Range();
3751
- range.selectNodeContents(element);
3752
- this.#elementHighlight.add(range);
3858
+ };
3859
+ __decorate17([
3860
+ property14({ type: Boolean, reflect: true, attribute: "disabled" })
3861
+ ], TestNext.prototype, "_internalDisabled", void 0);
3862
+ __decorate17([
3863
+ consume9({ context: computedContext, subscribe: true })
3864
+ ], TestNext.prototype, "computedContext", void 0);
3865
+ __decorate17([
3866
+ watch("computedContext")
3867
+ ], TestNext.prototype, "_handleTestElementChange", null);
3868
+
3869
+ // ../qti-test/dist/components/test-prev/test-prev.js
3870
+ import { css as css9, html as html15, LitElement as LitElement16 } from "lit";
3871
+ import { property as property15 } from "lit/decorators.js";
3872
+ import { consume as consume10 } from "@lit/context";
3873
+ var __decorate18 = function(decorators, target, key, desc) {
3874
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3875
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3876
+ 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;
3877
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3878
+ };
3879
+ var TestPrev = class extends LitElement16 {
3880
+ _handleTestElementChange(_oldValue, newValue) {
3881
+ if (newValue) {
3882
+ this.requestUpdate();
3753
3883
  }
3754
- CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
3755
3884
  }
3756
- /** Highlight the current word within #textNodes (yellow, during speech). */
3757
- #updateWordHighlight(charIndex, charLength) {
3758
- if (!("highlights" in CSS))
3759
- return;
3760
- this.#ensureHighlightStyles();
3761
- this.#wordHighlight.clear();
3762
- const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
3763
- const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));
3764
- let offset = 0;
3765
- let startNode = null;
3766
- let startOffset = 0;
3767
- let endNode = null;
3768
- let endOffset = 0;
3769
- for (const node of this.#textNodes) {
3770
- const len = node.textContent?.length ?? 0;
3771
- if (!startNode && offset + len > charIndex) {
3772
- startNode = node;
3773
- startOffset = charIndex - offset;
3774
- }
3775
- if (startNode && offset + len >= endIndex) {
3776
- endNode = node;
3777
- endOffset = endIndex - offset;
3778
- break;
3779
- }
3780
- offset += len;
3885
+ static {
3886
+ this.styles = css9`
3887
+ :host {
3888
+ ${btn};
3781
3889
  }
3782
- if (startNode && endNode) {
3783
- const range = new Range();
3784
- range.setStart(startNode, startOffset);
3785
- range.setEnd(endNode, endOffset);
3786
- this.#wordHighlight.add(range);
3787
- CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);
3890
+ :host(:hover:not([disabled])) {
3891
+ ${btnInteractive};
3892
+ }
3893
+ :host(:focus-visible) {
3894
+ ${focusRing};
3788
3895
  }
3896
+ :host([disabled]) {
3897
+ ${dis};
3898
+ }
3899
+ `;
3789
3900
  }
3790
- #clearWordHighlight() {
3791
- if (!("highlights" in CSS))
3792
- return;
3793
- this.#wordHighlight.clear();
3794
- if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight)
3795
- CSS.highlights.delete(HIGHLIGHT_WORD);
3901
+ constructor() {
3902
+ super();
3903
+ this._internalDisabled = true;
3904
+ this.addEventListener("click", (e) => {
3905
+ e.preventDefault();
3906
+ if (!this._internalDisabled)
3907
+ this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);
3908
+ });
3796
3909
  }
3797
- #clearAllHighlights() {
3798
- if (!("highlights" in CSS))
3910
+ willUpdate(_changedProperties) {
3911
+ if (!this.computedContext)
3799
3912
  return;
3800
- this.#clearWordHighlight();
3801
- this.#elementHighlight.clear();
3802
- if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
3803
- CSS.highlights.delete(HIGHLIGHT_ELEMENT);
3804
- }
3805
- /** Fallback word-length when charLength is 0. */
3806
- #wordLengthAt(charIndex, text) {
3807
- const right = text.slice(charIndex).search(/\s/);
3808
- return right < 0 ? text.length - charIndex : right;
3809
- }
3810
- /**
3811
- * Add ::highlight() rules both to test-container's shadow root (where highlighted
3812
- * text lives) and to the document (safety net — spec allows document rules to apply
3813
- * across shadow DOM). Called lazily on first highlight use so test-container is
3814
- * guaranteed to be in the DOM by the time navigation or speech starts.
3815
- */
3816
- #ensureHighlightStyles() {
3817
- if (!("highlights" in CSS))
3913
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3914
+ if (!testPart)
3818
3915
  return;
3819
- const sheet = getHighlightSheet();
3820
- if (!document.adoptedStyleSheets.includes(sheet)) {
3821
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
3822
- }
3823
- const roots = /* @__PURE__ */ new Set();
3824
- const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.testHost?.querySelector("test-container");
3825
- if (testContainer?.shadowRoot)
3826
- roots.add(testContainer.shadowRoot);
3827
- const ownRoot = this.getRootNode();
3828
- if (ownRoot instanceof ShadowRoot)
3829
- roots.add(ownRoot);
3830
- const itemRoot = this.#readingElements?.[0]?.getRootNode();
3831
- if (itemRoot instanceof ShadowRoot)
3832
- roots.add(itemRoot);
3833
- for (const root of roots) {
3834
- if (!root.adoptedStyleSheets.includes(sheet)) {
3835
- root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
3836
- }
3837
- }
3916
+ this.sectionItems = testPart.sections.flatMap((section) => section.items);
3917
+ this.itemIndex = this.sectionItems.findIndex((item) => item.active);
3918
+ this.checkDisabled();
3838
3919
  }
3839
- };
3840
- __decorate15([
3841
- property12({ type: String })
3842
- ], TestItemToSpeech.prototype, "language", void 0);
3843
- __decorate15([
3844
- consume8({ context: sessionContext, subscribe: true })
3845
- ], TestItemToSpeech.prototype, "_sessionContext", void 0);
3846
- __decorate15([
3847
- consume8({ context: testHostContext, subscribe: true })
3848
- ], TestItemToSpeech.prototype, "testHost", void 0);
3849
- __decorate15([
3850
- state4(),
3851
- provide3({ context: ttsContext })
3852
- ], TestItemToSpeech.prototype, "_ttsContext", void 0);
3853
- var TestTtsPlay = class extends TtsButtonBase {
3854
- #toggle() {
3855
- if (!this._tts)
3856
- return;
3857
- if (this._tts.state === "idle")
3858
- this._tts.play();
3859
- else if (this._tts.state === "playing")
3860
- this._tts.pause();
3861
- else
3862
- this._tts.resume();
3920
+ checkDisabled() {
3921
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3922
+ const activeSection = testPart?.sections.find((s) => s.active);
3923
+ const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || "nonlinear";
3924
+ this._internalDisabled = navigationMode === "linear" || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
3863
3925
  }
3864
- render() {
3865
- const playing = this._tts?.state === "playing";
3866
- return html14`
3867
- <button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
3868
- ${playing ? html14`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html14`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
3869
- </button>
3870
- `;
3926
+ _requestItem(identifier) {
3927
+ dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
3871
3928
  }
3872
- };
3873
- __decorate15([
3874
- property12({ type: String, attribute: "pause-label" })
3875
- ], TestTtsPlay.prototype, "pauseLabel", void 0);
3876
- var TestTtsPause = class extends TtsButtonBase {
3877
3929
  render() {
3878
- return html14`
3879
- <button
3880
- part="button"
3881
- aria-label=${ifDefined(this.label)}
3882
- ?disabled=${this._tts?.state !== "playing"}
3883
- @click=${() => this._tts?.pause()}
3884
- >
3885
- <slot>${iconContent("pause", this.label ?? "Pause")}</slot>
3886
- </button>
3887
- `;
3930
+ return html15`<slot></slot>`;
3888
3931
  }
3889
3932
  };
3890
- var TestTtsResume = class extends TtsButtonBase {
3933
+ __decorate18([
3934
+ property15({ type: Boolean, reflect: true, attribute: "disabled" })
3935
+ ], TestPrev.prototype, "_internalDisabled", void 0);
3936
+ __decorate18([
3937
+ consume10({ context: computedContext, subscribe: true })
3938
+ ], TestPrev.prototype, "computedContext", void 0);
3939
+ __decorate18([
3940
+ watch("computedContext")
3941
+ ], TestPrev.prototype, "_handleTestElementChange", null);
3942
+
3943
+ // ../qti-test/dist/components/test-section-link/test-section-link.js
3944
+ import { css as css10, html as html16, LitElement as LitElement17 } from "lit";
3945
+ import { property as property16 } from "lit/decorators.js";
3946
+ var __decorate19 = function(decorators, target, key, desc) {
3947
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3948
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3949
+ 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;
3950
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3951
+ };
3952
+ var TestSectionLink = class extends LitElement17 {
3953
+ static {
3954
+ this.styles = css10`
3955
+ :host {
3956
+ ${btn};
3957
+ }
3958
+ :host(:hover:not([disabled])) {
3959
+ ${btnInteractive};
3960
+ }
3961
+ :host(:focus-visible) {
3962
+ ${focusRing};
3963
+ }
3964
+ :host([disabled]) {
3965
+ ${dis};
3966
+ }
3967
+ `;
3968
+ }
3969
+ #requestItem(identifier) {
3970
+ dispatchPublic(this, "cito-test-navigate", { type: "section", id: identifier });
3971
+ }
3972
+ constructor() {
3973
+ super();
3974
+ this.sectionId = null;
3975
+ this.addEventListener("click", () => this.#requestItem(this.sectionId));
3976
+ }
3891
3977
  render() {
3892
- return html14`
3893
- <button
3894
- part="button"
3895
- aria-label=${ifDefined(this.label)}
3896
- ?disabled=${this._tts?.state !== "paused"}
3897
- @click=${() => this._tts?.resume()}
3898
- >
3899
- <slot>${iconContent("play", this.label ?? "Resume")}</slot>
3900
- </button>
3901
- `;
3902
- }
3903
- };
3904
- var TestTtsStop = class extends TtsButtonBase {
3905
- render() {
3906
- const idle = this._tts?.state === "idle" && !this._tts?.picking;
3907
- return html14`
3908
- <button part="button" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>
3909
- <slot>${iconContent("stop", this.label ?? "Stop")}</slot>
3910
- </button>
3911
- `;
3912
- }
3913
- };
3914
- var TestTtsPrev = class extends TtsButtonBase {
3915
- render() {
3916
- const collected = (this._tts?.elementCount ?? 0) > 0;
3917
- const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
3918
- return html14`
3919
- <button
3920
- part="button"
3921
- aria-label=${ifDefined(this.label)}
3922
- ?disabled=${collected && atStart}
3923
- @click=${() => this._tts?.prevElement()}
3924
- >
3925
- <slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
3926
- </button>
3927
- `;
3928
- }
3929
- };
3930
- var TestTtsNext = class extends TtsButtonBase {
3931
- render() {
3932
- const count = this._tts?.elementCount ?? 0;
3933
- const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
3934
- return html14`
3935
- <button
3936
- part="button"
3937
- aria-label=${ifDefined(this.label)}
3938
- ?disabled=${atEnd}
3939
- @click=${() => this._tts?.nextElement()}
3940
- >
3941
- <slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
3942
- </button>
3943
- `;
3944
- }
3945
- };
3946
- var TestTtsPick = class extends TtsButtonBase {
3947
- render() {
3948
- return html14`
3949
- <button
3950
- part="button"
3951
- aria-label=${ifDefined(this.label)}
3952
- aria-pressed=${this._tts?.picking ? "true" : "false"}
3953
- @click=${() => this._tts?.togglePick()}
3954
- >
3955
- <slot>${iconContent("pick", this.label ?? "Read from here")}</slot>
3956
- </button>
3957
- `;
3978
+ return html16` <slot></slot> `;
3958
3979
  }
3959
3980
  };
3981
+ __decorate19([
3982
+ property16({ type: String, attribute: "section-id" })
3983
+ ], TestSectionLink.prototype, "sectionId", void 0);
3960
3984
 
3961
- // ../qti-test/dist/components/test-navigation/test-navigation.js
3962
- import { ContextConsumer, consume as consume9, provide as provide4 } from "@lit/context";
3963
- import { html as html15, LitElement as LitElement16 } from "lit";
3964
- import { property as property13, state as state5 } from "lit/decorators.js";
3965
- var __decorate16 = function(decorators, target, key, desc) {
3985
+ // ../qti-test/dist/plugin-state.js
3986
+ var pluginState = (context, plugin) => context?.plugins?.[plugin];
3987
+
3988
+ // ../qti-test/dist/components/test-bookmark/test-bookmark.js
3989
+ import { css as css11, html as html17, LitElement as LitElement18 } from "lit";
3990
+ import { consume as consume11 } from "@lit/context";
3991
+ import { property as property17 } from "lit/decorators.js";
3992
+ var __decorate20 = function(decorators, target, key, desc) {
3966
3993
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3967
3994
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3968
3995
  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;
3969
3996
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3970
3997
  };
3971
- var newQtiContext = () => ({
3972
- QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
3973
- });
3974
- var TestNavigation = class extends LitElement16 {
3975
- /**
3976
- * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
3977
- * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
3978
- * shuffle seed here keeps working. Removed in the next major.
3979
- *
3980
- * Written before the navigation is inside a test, it waits and is handed over on connect.
3981
- */
3982
- get qtiContext() {
3983
- return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
3984
- }
3985
- set qtiContext(value) {
3986
- if (!this.#warnedQtiContext) {
3987
- this.#warnedQtiContext = true;
3988
- console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.");
3998
+ var bookmarkedItems = (context) => pluginState(context, "bookmarks") ?? [];
3999
+ var itemRefOf = (element) => {
4000
+ const itemRef = element.closest("qti-assessment-item-ref");
4001
+ if (itemRef)
4002
+ return itemRef.getAttribute("identifier") ?? void 0;
4003
+ const root = element.getRootNode();
4004
+ return root instanceof ShadowRoot ? itemRefOf(root.host) : void 0;
4005
+ };
4006
+ var TestBookmark = class extends LitElement18 {
4007
+ static {
4008
+ this.styles = css11`
4009
+ :host {
4010
+ ${btn};
3989
4011
  }
3990
- this.#writeQtiContext(value);
3991
- }
3992
- #pendingQtiContext;
3993
- #warnedQtiContext;
3994
- /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */
3995
- #writeQtiContext(value) {
3996
- const owner = this.#owner();
3997
- if (owner)
3998
- owner.qtiContext = value;
3999
- else
4000
- this.#pendingQtiContext = value;
4001
- }
4002
- /**
4003
- * The `qti-test` this navigation is in, found through context so it works across shadow roots.
4004
- * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.
4005
- */
4006
- #testHost;
4007
- #owner() {
4008
- return this.#testHost.value ?? null;
4012
+ :host(:hover:not([disabled])) {
4013
+ ${btnInteractive};
4014
+ }
4015
+ :host {
4016
+ display: inline-flex;
4017
+ align-items: center;
4018
+ gap: 0.4em;
4019
+ }
4020
+ svg {
4021
+ width: 1.1em;
4022
+ height: 1.1em;
4023
+ flex: none;
4024
+ fill: none;
4025
+ stroke: currentColor;
4026
+ stroke-width: 2;
4027
+ stroke-linejoin: round;
4028
+ }
4029
+ :host([bookmarked]) {
4030
+ color: var(--qti-bookmark-color, #b45309);
4031
+ }
4032
+ :host([bookmarked]) svg {
4033
+ fill: currentColor;
4034
+ }
4035
+ :host(:focus-visible) {
4036
+ ${focusRing};
4037
+ }
4038
+ :host([disabled]) {
4039
+ ${dis};
4040
+ }
4041
+ `;
4009
4042
  }
4010
- #testElement;
4011
- /**
4012
- * Whether each item's last *ended attempt* reached the optimal outcome, keyed
4013
- * by item-ref id. Written from #handleItemContextUpdated when processResponse
4014
- * ends an attempt — never on a plain selection. Mirrors how inline feedback
4015
- * only re-evaluates when an attempt is processed, so a freshly-picked answer
4016
- * doesn't flip `done` until the candidate ends the attempt.
4017
- */
4018
- #optimality;
4019
4043
  constructor() {
4020
4044
  super();
4021
- this.identifier = void 0;
4022
- this.initContext = [];
4023
- this.#warnedQtiContext = false;
4024
- this.#testHost = new ContextConsumer(this, {
4025
- context: testHostContext,
4026
- subscribe: true,
4027
- callback: (host) => {
4028
- if (host && this.#pendingQtiContext) {
4029
- host.qtiContext = this.#pendingQtiContext;
4030
- this.#pendingQtiContext = void 0;
4031
- }
4032
- }
4045
+ this.bookmarked = false;
4046
+ this.disabled = false;
4047
+ this.addEventListener("click", () => this.#toggle());
4048
+ this.addEventListener("keydown", (event) => {
4049
+ if (event.key !== "Enter" && event.key !== " ")
4050
+ return;
4051
+ event.preventDefault();
4052
+ this.#toggle();
4033
4053
  });
4034
- this.configContext = {};
4035
- this.autoScoreItems = false;
4036
- this.#optimality = /* @__PURE__ */ new Map();
4037
- listenPublic2(this, "cito-test-loaded", this.#handleTestConnected.bind(this));
4038
- this.addEventListener("qti-assessment-item-connected", this.#handleItemConnected.bind(this));
4039
- listenPublic(this, "cito-item-response-changed", this.#handleInteractionChanged.bind(this));
4040
- this.addEventListener("qti-item-context-updated", this.#handleItemContextUpdated.bind(this));
4041
- listenPublic2(this, "cito-test-end-attempt", this.#handleTestEndAttempt.bind(this));
4042
- listenPublic2(this, "cito-test-update-outcome", this.#handleTestUpdateOutcomeVariable.bind(this));
4043
- }
4044
- /**
4045
- * Latch whether an item reached its optimal outcome whenever it has just ended
4046
- * an attempt. processResponse — fired by test-end-attempt, autoscore, or an
4047
- * in-item end-attempt interaction — flags its context update with
4048
- * `responseProcessed`; a plain selection updates the context without it, so
4049
- * `done` can't flip until the candidate actually ends the attempt.
4050
- */
4051
- #handleItemContextUpdated(event) {
4052
- if (!event.detail?.responseProcessed)
4053
- return;
4054
- const itemContext = event.detail.itemContext;
4055
- if (!itemContext?.identifier)
4056
- return;
4057
- const optimality = this.#assessOptimality(itemContext);
4058
- this.#optimality.set(itemContext.identifier, optimality);
4059
- const computedItem = this.computedItemFor(itemContext.identifier);
4060
- const numAttempts = Number(itemContext.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
4061
- this.afterAttemptEnded(event.composedPath()[0]?.closest("qti-assessment-item"), computedItem, this.#isItemDone(numAttempts, optimality, computedItem?.maxAttempts));
4062
4054
  }
4063
- /**
4064
- * Extension point for presentation packages reacting to an ended attempt.
4065
- * `done` is settled here — from the freshly latched optimality and the
4066
- * session-control cascade — because the computed context only catches up on
4067
- * the next update, after this event has finished bubbling.
4068
- */
4069
- afterAttemptEnded(_assessmentItem, _computedItem, _done) {
4055
+ connectedCallback() {
4056
+ super.connectedCallback();
4057
+ if (!this.hasAttribute("role"))
4058
+ this.setAttribute("role", "button");
4059
+ if (!this.hasAttribute("tabindex"))
4060
+ this.setAttribute("tabindex", "0");
4070
4061
  }
4071
- /** The computed-context entry for an item, from the session-control cascade. */
4072
- computedItemFor(identifier) {
4073
- return this.computedContext?.testParts?.flatMap((part) => part.sections).flatMap((section) => section.items).find((i) => i.identifier === identifier);
4062
+ /** The item this button marks: its own, or else the one on screen. */
4063
+ get #activeItem() {
4064
+ return this.item || (itemRefOf(this) ?? this.computedContext?.testParts?.flatMap((part) => part.sections.flatMap((section) => section.items)).find((item) => item.active)?.identifier);
4074
4065
  }
4075
- /** The assessment item for an item-ref id, if it has been rendered. */
4076
- #assessmentItemFor(identifier) {
4077
- if (!identifier)
4078
- return void 0;
4079
- const itemRef = this.#testElement?.querySelector(`qti-assessment-item-ref[identifier="${identifier}"]`);
4080
- return itemRef?.assessmentItem ?? void 0;
4066
+ willUpdate() {
4067
+ const active = this.#activeItem;
4068
+ this.disabled = !active;
4069
+ this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);
4081
4070
  }
4082
- /** The currently active assessment item, exposed for optional presentation extensions. */
4083
- get activeAssessmentItem() {
4084
- if (!this.#testElement || !this._sessionContext?.navItemRefId)
4085
- return void 0;
4086
- return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
4071
+ updated() {
4072
+ this.setAttribute("aria-pressed", String(this.bookmarked));
4073
+ this.setAttribute("aria-disabled", String(this.disabled));
4087
4074
  }
4088
- /**
4089
- * Handles the 'test-end-attempt' event.
4090
- * @private
4091
- * @listens TestNavigation#test-end-attempt
4092
- * @param {CustomEvent} event - The custom event object.
4093
- */
4094
- #handleTestEndAttempt(_event) {
4095
- const qtiAssessmentItemEl = this.activeAssessmentItem;
4096
- if (!qtiAssessmentItemEl)
4075
+ #toggle() {
4076
+ const active = this.#activeItem;
4077
+ if (!active)
4097
4078
  return;
4098
- const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
4099
- qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
4079
+ const marked = bookmarkedItems(this.computedContext);
4080
+ const next = marked.includes(active) ? marked.filter((id) => id !== active) : [...marked, active];
4081
+ dispatchPublic(this, "cito-test-update-plugin-state", {
4082
+ plugin: "bookmarks",
4083
+ value: next.length > 0 ? next : null
4084
+ });
4100
4085
  }
4101
- #handleTestUpdateOutcomeVariable(event) {
4102
- const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);
4103
- if (!qtiAssessmentItemEl)
4104
- return;
4105
- qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
4086
+ render() {
4087
+ return html17`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot>`;
4106
4088
  }
4107
- #handleInteractionChanged(_event) {
4108
- if (this.autoScoreItems) {
4109
- const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
4110
- if (!assessmentItem)
4111
- return;
4112
- const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
4113
- if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
4114
- const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
4115
- assessmentItem.processResponse(true, reportValidityAfterScoring);
4116
- }
4089
+ };
4090
+ __decorate20([
4091
+ consume11({ context: computedContext, subscribe: true }),
4092
+ property17({ attribute: false })
4093
+ ], TestBookmark.prototype, "computedContext", void 0);
4094
+ __decorate20([
4095
+ property17({ reflect: true })
4096
+ ], TestBookmark.prototype, "item", void 0);
4097
+ __decorate20([
4098
+ property17({ type: Boolean, reflect: true })
4099
+ ], TestBookmark.prototype, "bookmarked", void 0);
4100
+ __decorate20([
4101
+ property17({ type: Boolean, reflect: true })
4102
+ ], TestBookmark.prototype, "disabled", void 0);
4103
+
4104
+ // ../qti-test/dist/components/test-check-item/test-check-item.js
4105
+ import { css as css12, html as html18, LitElement as LitElement19 } from "lit";
4106
+ import { property as property18 } from "lit/decorators.js";
4107
+ var __decorate21 = function(decorators, target, key, desc) {
4108
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4109
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4110
+ 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;
4111
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4112
+ };
4113
+ var TestCheckItem = class extends LitElement19 {
4114
+ static {
4115
+ this.styles = css12`
4116
+ :host {
4117
+ ${btn};
4118
+ }
4119
+ :host(:hover:not([disabled])) {
4120
+ ${btnInteractive};
4121
+ }
4122
+ :host(:focus-visible) {
4123
+ ${focusRing};
4124
+ }
4125
+ :host([disabled]) {
4126
+ ${dis};
4117
4127
  }
4128
+ `;
4129
+ }
4130
+ constructor() {
4131
+ super();
4132
+ this.view = "scorer";
4133
+ this.addEventListener("click", () => {
4134
+ dispatchPublic(this, "cito-test-end-attempt", {});
4135
+ dispatchPublic(this, "cito-test-switch-view", this.view);
4136
+ });
4118
4137
  }
4119
4138
  render() {
4120
- return html15`<slot></slot>`;
4139
+ return html18` <slot></slot> `;
4121
4140
  }
4122
- /* PK: on test connected we can build the computed context */
4123
- #handleTestConnected(event) {
4124
- this.#testElement = event.detail;
4125
- this.#optimality.clear();
4126
- if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
4127
- const currentContext = this.qtiContext.QTI_CONTEXT || {
4128
- testIdentifier: "",
4129
- candidateIdentifier: "not set",
4130
- environmentIdentifier: "default"
4131
- };
4132
- this.#writeQtiContext({
4133
- QTI_CONTEXT: {
4134
- ...currentContext,
4135
- testIdentifier: this.#testElement.identifier,
4136
- environmentIdentifier: currentContext.environmentIdentifier || "default"
4137
- }
4138
- });
4141
+ };
4142
+ __decorate21([
4143
+ property18({ type: String })
4144
+ ], TestCheckItem.prototype, "view", void 0);
4145
+
4146
+ // ../qti-test/dist/components/test-print-context/test-print-context.js
4147
+ import { html as html19, LitElement as LitElement20 } from "lit";
4148
+ import { consume as consume12 } from "@lit/context";
4149
+ import { state as state5 } from "lit/decorators.js";
4150
+ var __decorate22 = function(decorators, target, key, desc) {
4151
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4152
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4153
+ 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;
4154
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4155
+ };
4156
+ var TestPrintContext = class extends LitElement20 {
4157
+ render() {
4158
+ return html19` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
4159
+ }
4160
+ };
4161
+ __decorate22([
4162
+ state5(),
4163
+ consume12({ context: computedContext, subscribe: true })
4164
+ ], TestPrintContext.prototype, "computedContext", void 0);
4165
+
4166
+ // ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
4167
+ import { html as html20, css as css13, LitElement as LitElement21 } from "lit";
4168
+ import { consume as consume13 } from "@lit/context";
4169
+ var __decorate23 = function(decorators, target, key, desc) {
4170
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4171
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4172
+ 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;
4173
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4174
+ };
4175
+ var formatVariableValue = (value) => {
4176
+ if (value === null || value === void 0)
4177
+ return "";
4178
+ if (Array.isArray(value))
4179
+ return value.map(formatVariableValue).join(", ");
4180
+ if (isRecordValue(value)) {
4181
+ return Object.entries(value).map(([field, fieldValue]) => `${field}: ${formatVariableValue(fieldValue)}`).join(", ");
4182
+ }
4183
+ return String(value);
4184
+ };
4185
+ var TestPrintVariables = class extends LitElement21 {
4186
+ static {
4187
+ this.styles = css13`
4188
+ table {
4189
+ width: 100%;
4190
+ border-collapse: collapse;
4191
+ margin: 20px 0;
4192
+ font-size: 14px;
4193
+ text-align: left;
4139
4194
  }
4140
- const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
4141
- contextDeclarations.forEach((declaration) => {
4142
- const defaultValues = this.#extractDefaultValues(declaration);
4143
- if (Object.keys(defaultValues).length > 0) {
4144
- this.#writeQtiContext({
4145
- QTI_CONTEXT: {
4146
- ...defaultValues,
4147
- // Default values first
4148
- ...this.qtiContext.QTI_CONTEXT
4149
- // Runtime values override defaults
4150
- }
4151
- });
4152
- }
4153
- });
4154
- const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
4155
- this.computedContext = {
4156
- identifier: this.#testElement.identifier,
4157
- title: this.#testElement.title,
4158
- view: this._sessionContext?.view,
4159
- testParts: testPartElements.map((testPart) => {
4160
- const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
4161
- const testPartSessionControl = testPart.querySelector(":scope > qti-item-session-control");
4162
- const partAllowSkipping = testPartSessionControl ? testPartSessionControl.allowSkipping : true;
4163
- const partMaxAttempts = testPartSessionControl ? testPartSessionControl.maxAttempts : 1;
4164
- const partShowFeedback = testPartSessionControl ? testPartSessionControl.showFeedback : false;
4165
- const partShowSolution = testPartSessionControl ? testPartSessionControl.showSolution : false;
4166
- return {
4167
- active: false,
4168
- identifier: testPart.identifier,
4169
- navigationMode: testPart.navigationMode,
4170
- submissionMode: testPart.submissionMode,
4171
- allowSkipping: partAllowSkipping,
4172
- sections: sectionElements.map((section) => {
4173
- const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
4174
- const sectionSessionControl = section.querySelector(":scope > qti-item-session-control");
4175
- const sectionAllowSkipping = sectionSessionControl ? sectionSessionControl.allowSkipping : partAllowSkipping;
4176
- const sectionMaxAttempts = sectionSessionControl ? sectionSessionControl.maxAttempts : partMaxAttempts;
4177
- const sectionShowFeedback = sectionSessionControl ? sectionSessionControl.showFeedback : partShowFeedback;
4178
- const sectionShowSolution = sectionSessionControl ? sectionSessionControl.showSolution : partShowSolution;
4179
- return {
4180
- active: false,
4181
- identifier: section.identifier,
4182
- title: section.title,
4183
- navigationMode: section.navigationMode,
4184
- submissionMode: section.submissionMode,
4185
- allowSkipping: sectionAllowSkipping,
4186
- items: itemElements.map((item) => {
4187
- const itemSessionControl = item.querySelector(":scope > qti-item-session-control");
4188
- const itemAllowSkipping = itemSessionControl ? itemSessionControl.allowSkipping : sectionAllowSkipping;
4189
- const itemMaxAttempts = itemSessionControl ? itemSessionControl.maxAttempts : sectionMaxAttempts;
4190
- const itemShowFeedback = itemSessionControl ? itemSessionControl.showFeedback : sectionShowFeedback;
4191
- const itemShowSolution = itemSessionControl ? itemSessionControl.showSolution : sectionShowSolution;
4192
- return {
4193
- ...this.initContext?.find((i) => i.identifier === item.identifier),
4194
- active: false,
4195
- identifier: item.identifier,
4196
- categories: item.category ? item.category?.split(" ") : [],
4197
- href: item.href,
4198
- variables: [],
4199
- allowSkipping: itemAllowSkipping,
4200
- maxAttempts: itemMaxAttempts,
4201
- showFeedback: itemShowFeedback,
4202
- showSolution: itemShowSolution
4203
- };
4204
- })
4205
- };
4206
- })
4207
- };
4208
- })
4209
- };
4195
+ th,
4196
+ td {
4197
+ border: 1px solid #ddd;
4198
+ padding: 8px;
4199
+ }
4200
+ th {
4201
+ background-color: #f4f4f4;
4202
+ font-weight: bold;
4203
+ }
4204
+ h3 {
4205
+ margin-top: 20px;
4206
+ font-size: 16px;
4207
+ }
4208
+ `;
4210
4209
  }
4211
- /**
4212
- * Extract default values from a qti-context-declaration element
4213
- */
4214
- #extractDefaultValues(declaration) {
4215
- const defaultValues = {};
4216
- const defaultValueElement = declaration.querySelector("qti-default-value");
4217
- if (!defaultValueElement) {
4218
- return defaultValues;
4210
+ render() {
4211
+ const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4212
+ if (!activeItem || !activeItem.variables)
4213
+ return html20``;
4214
+ const responseVariables = activeItem.variables.filter((v) => v.type === "response");
4215
+ const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
4216
+ const renderTable = (variables, title) => html20`
4217
+ <h3>${title}</h3>
4218
+ <table>
4219
+ <thead>
4220
+ <tr>
4221
+ <th>Identifier</th>
4222
+ <th>Value</th>
4223
+ <th>Cardinality</th>
4224
+ <th>Base Type</th>
4225
+ <th>Correct Response / Mappings</th>
4226
+ </tr>
4227
+ </thead>
4228
+ <tbody>
4229
+ ${variables.map((v) => {
4230
+ const correctResponse = formatVariableValue(v.correctResponse);
4231
+ const mapEntries = v.mapping?.mapEntries?.map((m) => `${m.mapKey}=${m.mappedValue}pt`).join(", ") || "";
4232
+ const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m) => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ") || "";
4233
+ return html20`
4234
+ <tr>
4235
+ <td>${v.identifier}</td>
4236
+ <td>${formatVariableValue(v.value)}</td>
4237
+ <td>${v.cardinality}</td>
4238
+ <td>${v.baseType}</td>
4239
+ <td>${correctResponse || mapEntries || areaMapEntries}</td>
4240
+ </tr>
4241
+ `;
4242
+ })}
4243
+ </tbody>
4244
+ </table>
4245
+ `;
4246
+ return html20`
4247
+ ${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
4248
+ `;
4249
+ }
4250
+ };
4251
+ __decorate23([
4252
+ consume13({ context: computedContext, subscribe: true })
4253
+ ], TestPrintVariables.prototype, "computedContext", void 0);
4254
+
4255
+ // ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
4256
+ import { html as html21, LitElement as LitElement22, nothing as nothing3 } from "lit";
4257
+ import { consume as consume14 } from "@lit/context";
4258
+ import { property as property19 } from "lit/decorators.js";
4259
+ var __decorate24 = function(decorators, target, key, desc) {
4260
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4261
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4262
+ 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;
4263
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4264
+ };
4265
+ var TestScoringButtons = class extends LitElement22 {
4266
+ createRenderRoot() {
4267
+ return this;
4268
+ }
4269
+ connectedCallback() {
4270
+ super.connectedCallback();
4271
+ const templateElement = this.querySelector("template");
4272
+ if (!templateElement) {
4273
+ this.myTemplate = null;
4274
+ return;
4219
4275
  }
4220
- const valueElements = defaultValueElement.querySelectorAll("qti-value[field-identifier]");
4221
- valueElements.forEach((valueElement) => {
4222
- const fieldIdentifier = valueElement.getAttribute("field-identifier");
4223
- const baseType = valueElement.getAttribute("base-type") || "string";
4224
- const textContent = valueElement.textContent?.trim() || "";
4225
- if (fieldIdentifier) {
4226
- let value = textContent;
4227
- switch (baseType) {
4228
- case "integer":
4229
- value = parseInt(textContent, 10);
4230
- break;
4231
- case "float":
4232
- case "duration":
4233
- value = parseFloat(textContent);
4234
- break;
4235
- case "boolean":
4236
- value = textContent.toLowerCase() === "true";
4237
- break;
4238
- case "string":
4239
- default:
4240
- value = textContent;
4241
- break;
4242
- }
4243
- defaultValues[fieldIdentifier] = value;
4276
+ this.myTemplate = prepareTemplate(templateElement);
4277
+ }
4278
+ #changeOutcomeScore(value) {
4279
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4280
+ const sectionItems = testPart.sections.flatMap((section) => section.items);
4281
+ const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
4282
+ dispatchPublic(this, "cito-test-update-outcome", {
4283
+ assessmentItemRefId: currentItemIdentifier,
4284
+ outcomeVariableId: "SCORE",
4285
+ value
4286
+ });
4287
+ }
4288
+ render() {
4289
+ const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4290
+ if (!activeItem || !activeItem.variables)
4291
+ return html21``;
4292
+ const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
4293
+ const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
4294
+ const score = scoreOutcome?.value;
4295
+ const disabled = !(scoreOutcome?.externalScored === "human");
4296
+ if (!maxScore || !scoreOutcome)
4297
+ return nothing3;
4298
+ const scores = [...Array(Number(maxScore) + 1).keys()];
4299
+ return html21`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing3}`;
4300
+ }
4301
+ constructor() {
4302
+ super();
4303
+ this.view = "";
4304
+ this.disabled = false;
4305
+ this.myTemplate = null;
4306
+ this.addEventListener("click", (e) => {
4307
+ const target = e.target;
4308
+ const value = parseFloat(target.value);
4309
+ if (target.tagName === "INPUT") {
4310
+ this.#changeOutcomeScore(value);
4244
4311
  }
4245
4312
  });
4246
- return defaultValues;
4247
4313
  }
4248
- /* PK: on item connected we can add item only properties in the xml */
4249
- #handleItemConnected(event) {
4250
- const itemElement = event.detail;
4251
- this.computedContext = {
4252
- ...this.computedContext,
4253
- testParts: this.computedContext.testParts.map((testPart) => {
4254
- return {
4255
- ...testPart,
4256
- sections: testPart.sections.map((section) => {
4257
- return {
4258
- ...section,
4259
- items: section.items.map((item) => {
4260
- if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
4261
- return item;
4262
- }
4263
- const scoreOutcome = itemElement.querySelector("qti-outcome-declaration[identifier='SCORE']");
4264
- const externalScored = scoreOutcome?.getAttribute("externalScored");
4265
- const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
4266
- const containsCorrectResponse = Array.from(responseDeclarations).some((r) => r.querySelector("qti-correct-response"));
4267
- const containsMapping = Array.from(responseDeclarations).some((r) => {
4268
- const mapping = r.querySelector("qti-mapping");
4269
- const areaMapping = r.querySelector("qti-area-mapping");
4270
- return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
4271
- });
4272
- const hasCorrectResponse = containsCorrectResponse || containsMapping;
4273
- const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
4274
- return {
4275
- ...item,
4276
- assessmentItemIdentifier: itemElement.getAttribute("identifier"),
4277
- label: itemElement.getAttribute("label"),
4278
- title: itemElement.title,
4279
- externalScored,
4280
- adaptive: itemElement.adaptive == "true" || false,
4281
- timeDependent: itemElement.timeDependent == "true" || false,
4282
- variables: itemElement.variables,
4283
- hasCorrectResponse,
4284
- hasResponseProcessing
4285
- };
4286
- })
4287
- };
4288
- })
4289
- };
4290
- })
4314
+ };
4315
+ __decorate24([
4316
+ property19({ type: String, attribute: "view" })
4317
+ ], TestScoringButtons.prototype, "view", void 0);
4318
+ __decorate24([
4319
+ property19({ type: Boolean })
4320
+ ], TestScoringButtons.prototype, "disabled", void 0);
4321
+ __decorate24([
4322
+ consume14({ context: computedContext, subscribe: true })
4323
+ ], TestScoringButtons.prototype, "computedContext", void 0);
4324
+
4325
+ // ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
4326
+ import { consume as consume15 } from "@lit/context";
4327
+ import { html as html22, LitElement as LitElement23 } from "lit";
4328
+ import { property as property20 } from "lit/decorators.js";
4329
+ var __decorate25 = function(decorators, target, key, desc) {
4330
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4331
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4332
+ 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;
4333
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4334
+ };
4335
+ var TestScoringFeedback = class extends LitElement23 {
4336
+ constructor() {
4337
+ super(...arguments);
4338
+ this.view = null;
4339
+ }
4340
+ render() {
4341
+ const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4342
+ if (!activeItem || !activeItem.variables)
4343
+ return html22``;
4344
+ if (activeItem["category"] === "dep-informational")
4345
+ return html22`<div>${this.dataset.informational}</div>`;
4346
+ const completionStatus = activeItem?.variables.find((v) => v.identifier === "completionStatus")?.value;
4347
+ const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
4348
+ const score = parseFloat(scoreOutcome?.value);
4349
+ const externalScored = activeItem["externalScored"];
4350
+ const feedbackText = () => {
4351
+ if (completionStatus !== "completed") {
4352
+ return this.dataset.textNoResponse;
4353
+ }
4354
+ if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
4355
+ return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
4356
+ }
4357
+ if (externalScored === "externalMachine") {
4358
+ 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.`;
4359
+ }
4360
+ if (externalScored === "human") {
4361
+ return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
4362
+ }
4363
+ return this.dataset.inProgress;
4291
4364
  };
4365
+ return html22`<div>${feedbackText()}</div>`;
4292
4366
  }
4293
- /* PK: on every change of the candidate we will recomputed the computedContext */
4294
- willUpdate(_changedProperties) {
4295
- if (!this.computedContext)
4296
- return;
4297
- let itemIndex = 1;
4298
- this.computedContext = {
4299
- ...this.computedContext,
4300
- view: this._sessionContext?.view,
4301
- testParts: this.computedContext.testParts.map((testPart) => {
4302
- return {
4303
- ...testPart,
4304
- active: this._sessionContext?.navPartId === testPart.identifier || false,
4305
- sections: testPart.sections.map((section) => {
4306
- return {
4307
- ...section,
4308
- active: this._sessionContext?.navSectionId === section.identifier || false,
4309
- completed: section.items.every((item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"),
4310
- items: section.items.map((item) => {
4311
- const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
4312
- const computedItem = {
4313
- ...item,
4314
- ...itemContext,
4315
- ...this.initContext?.find((i) => i.identifier === item.identifier)
4316
- };
4317
- const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
4318
- const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
4319
- const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
4320
- const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
4321
- const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
4322
- const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
4323
- const valid = itemContext?.valid ?? true;
4324
- const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
4325
- const isDefaultResponse = responseVars.every((v) => {
4326
- if (v.value === void 0 || v.value === null) {
4327
- return true;
4328
- }
4329
- let fallbackValue;
4330
- switch (v.baseType) {
4331
- case "integer":
4332
- case "float":
4333
- case "duration":
4334
- fallbackValue = "0";
4335
- break;
4336
- case "boolean":
4337
- fallbackValue = "false";
4338
- break;
4339
- case "string":
4340
- case "directedPair":
4341
- case "identifier":
4342
- case "pair":
4343
- case "record":
4344
- default:
4345
- fallbackValue = "";
4346
- break;
4347
- }
4348
- const defaultValue = v.defaultValue ?? fallbackValue;
4349
- if (Array.isArray(v.value)) {
4350
- const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
4351
- return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);
4352
- }
4353
- return v.value === defaultValue;
4354
- });
4355
- const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
4356
- const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
4357
- const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
4358
- let optimality = this.#optimality.get(computedItem.identifier);
4359
- if (optimality === void 0) {
4360
- optimality = itemContext ? this.#assessOptimality(itemContext) : "unscored";
4361
- if (numAttempts > 0)
4362
- this.#optimality.set(computedItem.identifier, optimality);
4363
- }
4364
- const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts);
4365
- return {
4366
- ...computedItem,
4367
- completionStatus,
4368
- numAttempts,
4369
- score,
4370
- response,
4371
- index,
4372
- active,
4373
- valid,
4374
- isDefaultResponse,
4375
- maxScore,
4376
- done,
4377
- // Reflects the last *ended* attempt only. Read the latch directly
4378
- // (not the `optimality` local) — the latch is written solely on
4379
- // responseProcessed / restore-seed (line above, guarded by
4380
- // numAttempts > 0), so a freshly-picked mid-attempt selection
4381
- // computed live is never stored and never counts as optimal.
4382
- optimal: this.#optimality.get(computedItem.identifier) === "optimal"
4383
- // type,
4384
- // correct,
4385
- // incorrect,
4386
- // completed
4387
- };
4388
- })
4389
- };
4390
- })
4391
- };
4392
- })
4367
+ };
4368
+ __decorate25([
4369
+ consume15({ context: computedContext, subscribe: true })
4370
+ ], TestScoringFeedback.prototype, "computedContext", void 0);
4371
+ __decorate25([
4372
+ property20({ type: String, attribute: "view" })
4373
+ ], TestScoringFeedback.prototype, "view", void 0);
4374
+
4375
+ // ../qti-test/dist/components/test-stamp/test-stamp.js
4376
+ import { html as html23, LitElement as LitElement24, nothing as nothing4 } from "lit";
4377
+ import { property as property21, state as state6 } from "lit/decorators.js";
4378
+ import { consume as consume16 } from "@lit/context";
4379
+ var __decorate26 = function(decorators, target, key, desc) {
4380
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4381
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4382
+ 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;
4383
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4384
+ };
4385
+ var TestStamp = class extends LitElement24 {
4386
+ constructor() {
4387
+ super(...arguments);
4388
+ this.debug = false;
4389
+ this.stampContext = {
4390
+ view: "candidate",
4391
+ activeItem: {},
4392
+ activeSection: {
4393
+ items: []
4394
+ },
4395
+ activeTestpart: {
4396
+ items: [],
4397
+ sections: []
4398
+ },
4399
+ test: {}
4393
4400
  };
4394
- this.dispatchEvent(new CustomEvent("qti-computed-context-updated", {
4395
- detail: this.computedContext,
4401
+ }
4402
+ createRenderRoot() {
4403
+ return this;
4404
+ }
4405
+ connectedCallback() {
4406
+ super.connectedCallback();
4407
+ const templateElement = this.querySelector("template");
4408
+ if (!templateElement) {
4409
+ this.myTemplate = null;
4410
+ return;
4411
+ }
4412
+ this.myTemplate = prepareTemplate(templateElement);
4413
+ }
4414
+ willUpdate(_changedProperties) {
4415
+ if (!this.computedContext) {
4416
+ return;
4417
+ }
4418
+ const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
4419
+ const activeSection = activeTestPart?.sections.find((section) => section.active);
4420
+ const activeItem = activeSection?.items.find((item) => item.active);
4421
+ const { variables, ...augmentedItem } = activeItem || {};
4422
+ if (!activeTestPart) {
4423
+ return;
4424
+ }
4425
+ const augmentedTestPart = {
4426
+ ...activeTestPart,
4427
+ items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables: variables2, ...rest }) => rest)),
4428
+ sections: activeTestPart.sections.map((section) => ({
4429
+ ...section,
4430
+ items: section.items.map(({ variables: variables2, ...rest }) => rest)
4431
+ }))
4432
+ };
4433
+ const augmentedSection = {
4434
+ ...activeSection,
4435
+ items: (activeSection?.items ?? []).map(({ variables: variables2, ...rest }) => rest)
4436
+ };
4437
+ const { testParts, ...activeTest } = this.computedContext;
4438
+ this.stampContext = {
4439
+ view: this.computedContext.view,
4440
+ activeItem: augmentedItem,
4441
+ activeSection: augmentedSection,
4442
+ activeTestpart: augmentedTestPart,
4443
+ test: activeTest
4444
+ };
4445
+ this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
4446
+ detail: this.stampContext,
4396
4447
  bubbles: true
4397
4448
  }));
4398
4449
  }
4399
- /**
4400
- * Decide whether an item should be treated as "the candidate is done with it"
4401
- * for the purpose of gating forward navigation and further attempts.
4402
- *
4403
- * - The candidate must have actually ended an attempt (numAttempts > 0).
4404
- * - Once attempted, the item is done if they reached the optimal outcome
4405
- * ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*
4406
- * done while a better attempt is still possible ('suboptimal') and attempts
4407
- * remain — see #assessOptimality for how "optimal" is determined.
4408
- *
4409
- * `optimality` reflects the last *ended attempt* (see #optimality), not the
4410
- * live selection — so a freshly-picked optimal answer doesn't count as done
4411
- * until test-end-attempt evaluates it.
4412
- */
4413
- #isItemDone(numAttempts, optimality, maxAttempts) {
4414
- if (numAttempts === 0)
4415
- return false;
4416
- if (optimality !== "suboptimal")
4417
- return true;
4418
- const max = maxAttempts ?? 1;
4419
- return max > 0 && numAttempts >= max;
4450
+ render() {
4451
+ return html23` ${this.debug ? html23`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing4}
4452
+ ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
4420
4453
  }
4421
- /**
4422
- * Decide whether an item's submission is as good as it can get — i.e. the
4423
- * candidate reached the *optimal* outcome, so there's no reason to make them
4424
- * try again. 'optimal' means best achievable, 'suboptimal' means a better
4425
- * attempt is still possible, 'unscored' means there's nothing to judge against.
4426
- * ("optimal" is the spec's own word — a qti-correct-response is defined as
4427
- * "the (or an) optimal value".)
4428
- *
4429
- * Two signals, in order of authority:
4430
- * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).
4431
- * This correctly handles partial-credit / qti-mapping items, where an exact
4432
- * response match would under- or over-judge.
4433
- * 2. The declared qti-correct-response, for items that aren't scored (no
4434
- * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping
4435
- * variables like numAttempts can be typed 'response' but never declare a
4436
- * correctResponse, so we filter on a declared correctResponse.
4437
- *
4438
- * Items with neither a comparable score nor a correctResponse (essays, info
4439
- * items, etc.) are 'unscored' — there's no optimal value to require, so one
4440
- * attempt is enough.
4441
- */
4442
- #assessOptimality(item) {
4443
- const variables = item.variables ?? [];
4444
- const score = this.#numericVariable(variables, "SCORE");
4445
- const maxScore = this.#numericVariable(variables, "MAXSCORE");
4446
- if (score !== null && maxScore !== null) {
4447
- return score >= maxScore ? "optimal" : "suboptimal";
4454
+ };
4455
+ __decorate26([
4456
+ property21({ type: Boolean, reflect: true })
4457
+ ], TestStamp.prototype, "debug", void 0);
4458
+ __decorate26([
4459
+ state6(),
4460
+ consume16({ context: computedContext, subscribe: true })
4461
+ ], TestStamp.prototype, "computedContext", void 0);
4462
+ __decorate26([
4463
+ state6()
4464
+ ], TestStamp.prototype, "stampContext", void 0);
4465
+
4466
+ // ../qti-test/dist/components/test-submit/test-submit.js
4467
+ import { css as css14, html as html24, LitElement as LitElement25 } from "lit";
4468
+ var TestSubmit = class extends LitElement25 {
4469
+ static {
4470
+ this.styles = css14`
4471
+ :host {
4472
+ ${btn};
4448
4473
  }
4449
- const responseVars = variables.filter((v) => v.type === "response" && v.correctResponse !== void 0 && v.correctResponse !== null);
4450
- if (responseVars.length === 0)
4451
- return "unscored";
4452
- const allMatch = responseVars.every((v) => {
4453
- const expected = v.correctResponse;
4454
- const actual = v.value;
4455
- if (actual === void 0 || actual === null)
4456
- return false;
4457
- if (Array.isArray(expected) && Array.isArray(actual)) {
4458
- return expected.length === actual.length && expected.every((e) => actual.includes(e));
4474
+ :host(:hover:not([disabled])) {
4475
+ ${btnInteractive};
4476
+ }
4477
+ :host(:focus-visible) {
4478
+ ${focusRing};
4479
+ }
4480
+ :host([disabled]) {
4481
+ ${dis};
4482
+ }
4483
+ `;
4484
+ }
4485
+ constructor() {
4486
+ super();
4487
+ this.addEventListener("click", () => dispatchPublic(this, "cito-test-submit", {}));
4488
+ }
4489
+ render() {
4490
+ return html24` <slot></slot> `;
4491
+ }
4492
+ };
4493
+
4494
+ // ../qti-test/dist/components/test-view-toggle/test-view.js
4495
+ import { html as html25, LitElement as LitElement26 } from "lit";
4496
+ import { property as property22, state as state7 } from "lit/decorators.js";
4497
+ import { consume as consume17 } from "@lit/context";
4498
+ var __decorate27 = function(decorators, target, key, desc) {
4499
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4500
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4501
+ 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;
4502
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4503
+ };
4504
+ var _a;
4505
+ var TestView = class extends LitElement26 {
4506
+ constructor() {
4507
+ super(...arguments);
4508
+ this.label = "view";
4509
+ this._handleViewOptionsChange = () => {
4510
+ this.#updateViewOptions();
4511
+ };
4512
+ this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
4513
+ }
4514
+ static {
4515
+ this.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
4516
+ }
4517
+ connectedCallback() {
4518
+ super.connectedCallback();
4519
+ this.#updateViewOptions();
4520
+ }
4521
+ #updateViewOptions() {
4522
+ if (this.viewOptions) {
4523
+ const options = this.viewOptions.split(",").map((opt) => opt.trim());
4524
+ this._viewOptions = options.filter((opt) => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
4525
+ } else {
4526
+ this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
4527
+ }
4528
+ }
4529
+ _switchView(view) {
4530
+ dispatchPublic(this, "cito-test-switch-view", view);
4531
+ }
4532
+ render() {
4533
+ return html25`
4534
+ <label part="label" for="viewSelect">${this.label}</label>
4535
+ <select
4536
+ part="select"
4537
+ id="viewSelect"
4538
+ @change=${(e) => {
4539
+ const el = e.target;
4540
+ this._switchView(el.value);
4541
+ }}
4542
+ >
4543
+ ${this._viewOptions.map((v) => html25`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
4544
+ </select>
4545
+ `;
4546
+ }
4547
+ };
4548
+ _a = TestView;
4549
+ __decorate27([
4550
+ consume17({ context: sessionContext, subscribe: true })
4551
+ ], TestView.prototype, "sessionContext", void 0);
4552
+ __decorate27([
4553
+ property22({ type: String })
4554
+ ], TestView.prototype, "label", void 0);
4555
+ __decorate27([
4556
+ property22({ type: String, attribute: "view-options" })
4557
+ ], TestView.prototype, "viewOptions", void 0);
4558
+ __decorate27([
4559
+ watch("viewOptions", { waitUntilFirstUpdate: true })
4560
+ ], TestView.prototype, "_handleViewOptionsChange", void 0);
4561
+ __decorate27([
4562
+ state7()
4563
+ ], TestView.prototype, "_viewOptions", void 0);
4564
+
4565
+ // ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
4566
+ import { consume as consume18 } from "@lit/context";
4567
+ import { html as html26, LitElement as LitElement27, nothing as nothing5 } from "lit";
4568
+ var __decorate28 = function(decorators, target, key, desc) {
4569
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4570
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4571
+ 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;
4572
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4573
+ };
4574
+ var TestViewToggle = class extends LitElement27 {
4575
+ createRenderRoot() {
4576
+ return this;
4577
+ }
4578
+ connectedCallback() {
4579
+ super.connectedCallback();
4580
+ const templateElement = this.querySelector("template");
4581
+ if (!templateElement) {
4582
+ this.myTemplate = null;
4583
+ return;
4584
+ }
4585
+ this.myTemplate = prepareTemplate(templateElement);
4586
+ }
4587
+ _switchView(view) {
4588
+ dispatchPublic(this, "cito-test-switch-view", view);
4589
+ }
4590
+ firstUpdated(_changedProperties) {
4591
+ this.addEventListener("click", () => {
4592
+ if (this.sessionContext?.view === "scorer") {
4593
+ this._switchView("candidate");
4594
+ } else {
4595
+ this._switchView("scorer");
4459
4596
  }
4460
- if (Array.isArray(expected) || Array.isArray(actual))
4461
- return false;
4462
- return expected === actual;
4463
4597
  });
4464
- return allMatch ? "optimal" : "suboptimal";
4465
4598
  }
4466
- /** Read a single numeric outcome value, or null when absent / non-numeric. */
4467
- #numericVariable(variables, identifier) {
4468
- const raw = variables?.find((v) => v.identifier === identifier)?.value;
4469
- if (raw === void 0 || raw === null || Array.isArray(raw))
4470
- return null;
4471
- const parsed = parseFloat(raw.toString());
4472
- return Number.isNaN(parsed) ? null : parsed;
4599
+ render() {
4600
+ return html26`${this.myTemplate ? this.myTemplate({
4601
+ view: this.sessionContext?.view
4602
+ }) : nothing5}`;
4473
4603
  }
4474
4604
  };
4475
- __decorate16([
4476
- property13({ type: String })
4477
- ], TestNavigation.prototype, "identifier", void 0);
4478
- __decorate16([
4479
- state5()
4480
- ], TestNavigation.prototype, "initContext", void 0);
4481
- __decorate16([
4482
- state5(),
4483
- consume9({ context: configContext, subscribe: true })
4484
- ], TestNavigation.prototype, "configContext", void 0);
4485
- __decorate16([
4486
- state5(),
4487
- consume9({ context: testContext, subscribe: true })
4488
- ], TestNavigation.prototype, "_testContext", void 0);
4489
- __decorate16([
4490
- state5(),
4491
- consume9({ context: sessionContext, subscribe: true })
4492
- ], TestNavigation.prototype, "_sessionContext", void 0);
4493
- __decorate16([
4494
- state5(),
4495
- provide4({ context: computedContext })
4496
- ], TestNavigation.prototype, "computedContext", void 0);
4497
- __decorate16([
4498
- property13({ type: Boolean, attribute: "auto-score-items" })
4499
- ], TestNavigation.prototype, "autoScoreItems", void 0);
4605
+ __decorate28([
4606
+ consume18({ context: sessionContext, subscribe: true })
4607
+ ], TestViewToggle.prototype, "sessionContext", void 0);
4500
4608
 
4501
- // ../qti-test/dist/components/test-next/test-next.js
4502
- import { css as css10, html as html16, LitElement as LitElement17 } from "lit";
4503
- import { property as property14 } from "lit/decorators.js";
4504
- import { consume as consume10 } from "@lit/context";
4505
- var __decorate17 = function(decorators, target, key, desc) {
4609
+ // ../qti-test/dist/tts/test-item-to-speech.js
4610
+ import { html as html27, LitElement as LitElement28, css as css15 } from "lit";
4611
+ import { consume as consume19, provide as provide4, createContext as createContext2 } from "@lit/context";
4612
+ import { property as property23, state as state8 } from "lit/decorators.js";
4613
+ import { ifDefined } from "lit/directives/if-defined.js";
4614
+ var __decorate29 = function(decorators, target, key, desc) {
4506
4615
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4507
4616
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4508
4617
  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;
4509
4618
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4510
4619
  };
4511
- var TestNext = class extends LitElement17 {
4512
- _handleTestElementChange(_oldValue, newValue) {
4513
- if (newValue) {
4514
- this.requestUpdate();
4515
- }
4620
+ var HIGHLIGHT_ELEMENT = "tts-element";
4621
+ var HIGHLIGHT_WORD = "tts-word";
4622
+ var highlightSheet = null;
4623
+ function getHighlightSheet() {
4624
+ if (!highlightSheet) {
4625
+ highlightSheet = new CSSStyleSheet();
4626
+ highlightSheet.replaceSync(`
4627
+ ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
4628
+ ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
4629
+ `);
4516
4630
  }
4631
+ return highlightSheet;
4632
+ }
4633
+ var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
4634
+ var ICONS = {
4635
+ play: "M8 5v14l11-7z",
4636
+ pause: "M6 5h4v14H6zM14 5h4v14h-4z",
4637
+ stop: "M6 6h12v12H6z",
4638
+ prev: "M6 5h2v14H6zM20 5v14L9 12z",
4639
+ next: "M16 5h2v14h-2zM4 5v14l11-7z",
4640
+ pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
4641
+ };
4642
+ var iconContent = (icon, label) => {
4643
+ const svg = html27`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
4644
+ <path d="${ICONS[icon]}"></path>
4645
+ </svg>`;
4646
+ return html27`${svg}<span class="label">${label}</span>`;
4647
+ };
4648
+ var TtsButtonBase = class extends LitElement28 {
4517
4649
  static {
4518
- this.styles = css10`
4650
+ this.styles = css15`
4519
4651
  :host {
4652
+ display: inline-flex;
4653
+ }
4654
+ button {
4520
4655
  ${btn};
4656
+ min-inline-size: var(--test-button-size, 2.25rem);
4657
+ padding-inline: 0.5rem;
4658
+ /* Containing block for the visually hidden .label. Without it the label is placed against
4659
+ the nearest positioned ancestor, which can sit outside a scroll container and make the
4660
+ page as tall as the scrolled content. */
4661
+ position: relative;
4521
4662
  }
4522
- :host(:hover:not([disabled])) {
4663
+ button:hover:not(:disabled) {
4523
4664
  ${btnInteractive};
4524
4665
  }
4525
- :host(:focus-visible) {
4666
+ button:focus-visible {
4526
4667
  ${focusRing};
4527
4668
  }
4528
- :host([disabled]) {
4669
+ button:disabled {
4529
4670
  ${dis};
4530
4671
  }
4672
+ button[aria-pressed='true'],
4673
+ button[aria-pressed='true']:hover {
4674
+ background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
4675
+ color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
4676
+ }
4677
+ svg,
4678
+ ::slotted(svg) {
4679
+ flex: none;
4680
+ inline-size: var(--test-tts-icon-size, 1.125rem);
4681
+ block-size: var(--test-tts-icon-size, 1.125rem);
4682
+ }
4683
+ svg {
4684
+ fill: currentColor;
4685
+ }
4686
+ /* The default content is icon-only; this keeps the button's accessible name. */
4687
+ .label {
4688
+ position: absolute;
4689
+ inline-size: 1px;
4690
+ block-size: 1px;
4691
+ overflow: hidden;
4692
+ clip-path: inset(50%);
4693
+ white-space: nowrap;
4694
+ }
4531
4695
  `;
4532
4696
  }
4533
- #internals;
4534
- constructor() {
4535
- super();
4536
- this._internalDisabled = true;
4537
- this.#internals = this.attachInternals();
4538
- this.#internals.role = "button";
4539
- this.#internals.ariaLabel = "Next item";
4540
- this.addEventListener("click", (e) => {
4541
- e.preventDefault();
4542
- if (!this._internalDisabled)
4543
- this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);
4544
- });
4545
- }
4546
- connectedCallback() {
4547
- super.connectedCallback();
4548
- this.checkDisabled();
4549
- }
4550
- willUpdate(_changedProperties) {
4551
- if (!this.computedContext)
4552
- return;
4553
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4554
- if (!testPart)
4555
- return;
4556
- this.sectionItems = testPart.sections.flatMap((section) => section.items);
4557
- this.itemIndex = this.sectionItems.findIndex((item) => item.active);
4558
- this.checkDisabled();
4559
- }
4560
- checkDisabled() {
4561
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4562
- if (!testPart)
4697
+ #internals = this.attachInternals();
4698
+ #mirroredState;
4699
+ #mirroredPicking = false;
4700
+ updated(_changed) {
4701
+ const state9 = this._tts?.state;
4702
+ const picking = this._tts?.picking ?? false;
4703
+ if (state9 === this.#mirroredState && picking === this.#mirroredPicking)
4563
4704
  return;
4564
- const activeSection = testPart.sections.find((s) => s.active);
4565
- const navigationMode = activeSection?.navigationMode || testPart.navigationMode;
4566
- const submissionMode = activeSection?.submissionMode || testPart.submissionMode;
4567
- const activeItem = this.sectionItems[this.itemIndex];
4568
- const isLinearIndividual = navigationMode === "linear" && submissionMode === "individual";
4569
- this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 || isLinearIndividual && !activeItem?.done;
4570
- }
4571
- _requestItem(identifier) {
4572
- dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
4573
- }
4574
- render() {
4575
- return html16`<slot></slot>`;
4705
+ this.#mirroredState = state9;
4706
+ this.#mirroredPicking = picking;
4707
+ this.#internals.states.clear();
4708
+ if (state9)
4709
+ this.#internals.states.add(state9);
4710
+ if (picking)
4711
+ this.#internals.states.add("picking");
4576
4712
  }
4577
4713
  };
4578
- __decorate17([
4579
- property14({ type: Boolean, reflect: true, attribute: "disabled" })
4580
- ], TestNext.prototype, "_internalDisabled", void 0);
4581
- __decorate17([
4582
- consume10({ context: computedContext, subscribe: true })
4583
- ], TestNext.prototype, "computedContext", void 0);
4584
- __decorate17([
4585
- watch("computedContext")
4586
- ], TestNext.prototype, "_handleTestElementChange", null);
4587
-
4588
- // ../qti-test/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js
4589
- import { html as html17, LitElement as LitElement18 } from "lit";
4590
- import { consume as consume11 } from "@lit/context";
4591
- var __decorate18 = function(decorators, target, key, desc) {
4592
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4593
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4594
- 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;
4595
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4596
- };
4597
- var TestPagingButtonsStamp = class extends LitElement18 {
4714
+ __decorate29([
4715
+ property23({ type: String })
4716
+ ], TtsButtonBase.prototype, "label", void 0);
4717
+ __decorate29([
4718
+ consume19({ context: ttsContext, subscribe: true })
4719
+ ], TtsButtonBase.prototype, "_tts", void 0);
4720
+ var TestItemToSpeech = class extends LitElement28 {
4721
+ static {
4722
+ this.styles = css15`
4723
+ :host {
4724
+ display: inline-flex;
4725
+ flex-wrap: wrap;
4726
+ align-items: center;
4727
+ gap: var(--test-tts-gap, 0.25rem);
4728
+ }
4729
+ `;
4730
+ }
4598
4731
  #internals;
4599
- createRenderRoot() {
4600
- return this;
4732
+ // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
4733
+ // placeholder itself is looked up on every use — a host may swap the element.
4734
+ #stimulusMode;
4735
+ // Stimulus mode: resets the player when the stimulus content next to it is replaced.
4736
+ #stimulusObserver;
4737
+ // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
4738
+ // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
4739
+ #contentMode;
4740
+ // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
4741
+ #itemRef;
4742
+ // Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's
4743
+ // navigation request is heard.
4744
+ #eventHost;
4745
+ #boundHandleItemConnected;
4746
+ #boundHandleNavigation;
4747
+ // Cursor mode: the previous navigation position, to detect moving to another item or section.
4748
+ #prevNavItemRefId;
4749
+ #prevNavSectionId;
4750
+ // Current set of block-level reading elements for the item, and the root they were collected from
4751
+ #readingElements;
4752
+ #readingRoot;
4753
+ #currentElementIndex;
4754
+ // Text nodes of the element currently being spoken (for word-boundary highlight)
4755
+ #textNodes;
4756
+ // The utterance this player is speaking; lets the error handler tell "our speech was
4757
+ // cancelled by another player" apart from a cancel we issued ourselves.
4758
+ #currentUtterance;
4759
+ // Pick mode: all elements highlighted, a click on one starts reading from there.
4760
+ #picking;
4761
+ #pickRoot;
4762
+ #boundHandlePickClick;
4763
+ // Set when the last element has been read: the cursor stays on it (so prev still works),
4764
+ // but the next play starts the item over instead of repeating that last element.
4765
+ #finished;
4766
+ // Two separate CSS Highlight objects
4767
+ #elementHighlight;
4768
+ // whole-element cursor
4769
+ #wordHighlight;
4770
+ // current word during speech
4771
+ constructor() {
4772
+ super();
4773
+ this.language = "nl-NL";
4774
+ this.#internals = this.attachInternals();
4775
+ this.#stimulusMode = false;
4776
+ this.#stimulusObserver = null;
4777
+ this.#contentMode = false;
4778
+ this.#itemRef = null;
4779
+ this.#eventHost = null;
4780
+ this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
4781
+ this.#boundHandleNavigation = () => this.#stop();
4782
+ this.#prevNavItemRefId = void 0;
4783
+ this.#prevNavSectionId = void 0;
4784
+ this.#readingElements = null;
4785
+ this.#readingRoot = null;
4786
+ this.#currentElementIndex = 0;
4787
+ this.#textNodes = [];
4788
+ this.#currentUtterance = null;
4789
+ this.#picking = false;
4790
+ this.#pickRoot = null;
4791
+ this.#boundHandlePickClick = this.#handlePickClick.bind(this);
4792
+ this.#finished = false;
4793
+ this.#elementHighlight = new Highlight();
4794
+ this.#wordHighlight = new Highlight();
4795
+ this._ttsContext = {
4796
+ state: "idle",
4797
+ currentElementIndex: 0,
4798
+ elementCount: 0,
4799
+ play: () => this.#playSpeech(),
4800
+ pause: () => this.#pause(),
4801
+ resume: () => this.#resume(),
4802
+ stop: () => {
4803
+ this.#stopPicking();
4804
+ this.#stop();
4805
+ },
4806
+ prevElement: () => this.#prevElement(),
4807
+ nextElement: () => this.#nextElement(),
4808
+ togglePick: () => this.#togglePick(),
4809
+ picking: false
4810
+ };
4601
4811
  }
4602
- constructor() {
4603
- super();
4604
- this.#internals = this.attachInternals();
4605
- this.#internals.ariaLabel = "pagination";
4812
+ // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
4813
+ // render already under way instead of scheduling a second one (Lit's change-in-update).
4814
+ willUpdate(changed) {
4815
+ super.willUpdate(changed);
4816
+ if (this.#stimulusMode || this.#contentMode || this.#itemRef)
4817
+ return;
4818
+ const { item, section } = this.#activePosition();
4819
+ const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
4820
+ const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
4821
+ const rerendered = this.#readingElements !== null && this.#readingRoot !== null && this.#readingRoot !== this.#resolveReadingRoot();
4822
+ if (itemChanged || sectionChanged || rerendered)
4823
+ this.#resetReadingPosition();
4824
+ this.#prevNavItemRefId = item;
4825
+ this.#prevNavSectionId = section;
4826
+ }
4827
+ /** Stop speech and forget the collected reading elements, so the next play starts afresh. */
4828
+ #resetReadingPosition() {
4829
+ this.#stopPicking();
4830
+ this.#stop();
4831
+ this.#readingElements = null;
4832
+ this.#currentElementIndex = 0;
4833
+ this.#finished = false;
4834
+ this.#updateContext();
4606
4835
  }
4607
4836
  connectedCallback() {
4608
4837
  super.connectedCallback();
4609
- const templateElement = this.querySelector("template");
4610
- this.myTemplate = prepareTemplate(templateElement);
4611
- }
4612
- render() {
4613
- if (!this.computedContext)
4614
- return html17``;
4615
- const items = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items));
4616
- return html17` ${items.map((item) => this.myTemplate({ item, view: this.computedContext.view }))} `;
4617
- }
4618
- };
4619
- __decorate18([
4620
- consume11({ context: computedContext, subscribe: true })
4621
- ], TestPagingButtonsStamp.prototype, "computedContext", void 0);
4622
-
4623
- // ../qti-test/dist/components/test-prev/test-prev.js
4624
- import { css as css11, html as html18, LitElement as LitElement19 } from "lit";
4625
- import { property as property15 } from "lit/decorators.js";
4626
- import { consume as consume12 } from "@lit/context";
4627
- var __decorate19 = function(decorators, target, key, desc) {
4628
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4629
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4630
- 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;
4631
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4632
- };
4633
- var TestPrev = class extends LitElement19 {
4634
- _handleTestElementChange(_oldValue, newValue) {
4635
- if (newValue) {
4636
- this.requestUpdate();
4637
- }
4638
- }
4639
- static {
4640
- this.styles = css11`
4641
- :host {
4642
- ${btn};
4643
- }
4644
- :host(:hover:not([disabled])) {
4645
- ${btnInteractive};
4646
- }
4647
- :host(:focus-visible) {
4648
- ${focusRing};
4649
- }
4650
- :host([disabled]) {
4651
- ${dis};
4652
- }
4653
- `;
4654
- }
4655
- constructor() {
4656
- super();
4657
- this._internalDisabled = true;
4658
- this.addEventListener("click", (e) => {
4659
- e.preventDefault();
4660
- if (!this._internalDisabled)
4661
- this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);
4662
- });
4663
- }
4664
- willUpdate(_changedProperties) {
4665
- if (!this.computedContext)
4838
+ this.#setSpeechState("idle");
4839
+ this.#stimulusMode = this.#stimulusPlaceholder() !== null;
4840
+ if (this.#stimulusMode) {
4841
+ this.#stimulusObserver = new MutationObserver((records) => {
4842
+ if (records.some((record) => !this.contains(record.target)))
4843
+ this.#handleStimulusReplaced();
4844
+ });
4845
+ this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
4666
4846
  return;
4667
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4668
- if (!testPart)
4847
+ }
4848
+ this.#contentMode = this.#contentElement() !== null;
4849
+ if (this.#contentMode)
4669
4850
  return;
4670
- this.sectionItems = testPart.sections.flatMap((section) => section.items);
4671
- this.itemIndex = this.sectionItems.findIndex((item) => item.active);
4672
- this.checkDisabled();
4673
- }
4674
- checkDisabled() {
4675
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4676
- const activeSection = testPart?.sections.find((s) => s.active);
4677
- const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || "nonlinear";
4678
- this._internalDisabled = navigationMode === "linear" || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
4851
+ this.#itemRef = this.closest("qti-assessment-item-ref");
4852
+ if (this.#itemRef) {
4853
+ this.#eventHost = this.#itemRef;
4854
+ this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
4855
+ } else {
4856
+ this.#eventHost = this.closest("test-navigation") ?? this.getRootNode();
4857
+ this.#eventHost.addEventListener("cito-test-navigate", this.#boundHandleNavigation);
4858
+ this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
4859
+ }
4679
4860
  }
4680
- _requestItem(identifier) {
4681
- dispatchPublic(this, "cito-test-navigate", { type: "item", id: identifier });
4861
+ disconnectedCallback() {
4862
+ super.disconnectedCallback();
4863
+ if (this.#currentUtterance) {
4864
+ this.#currentUtterance = null;
4865
+ speechSynthesis.cancel();
4866
+ }
4867
+ this.#stopPicking();
4868
+ this.#clearAllHighlights();
4869
+ this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
4870
+ this.#eventHost?.removeEventListener("cito-test-navigate", this.#boundHandleNavigation);
4871
+ this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
4872
+ this.#eventHost = null;
4873
+ this.#itemRef = null;
4874
+ this.#stimulusObserver?.disconnect();
4875
+ this.#stimulusObserver = null;
4876
+ this.#stimulusMode = false;
4877
+ this.#contentMode = false;
4682
4878
  }
4683
4879
  render() {
4684
- return html18`<slot></slot>`;
4880
+ return html27`<slot></slot>`;
4685
4881
  }
4686
- };
4687
- __decorate19([
4688
- property15({ type: Boolean, reflect: true, attribute: "disabled" })
4689
- ], TestPrev.prototype, "_internalDisabled", void 0);
4690
- __decorate19([
4691
- consume12({ context: computedContext, subscribe: true })
4692
- ], TestPrev.prototype, "computedContext", void 0);
4693
- __decorate19([
4694
- watch("computedContext")
4695
- ], TestPrev.prototype, "_handleTestElementChange", null);
4696
-
4697
- // ../qti-test/dist/components/test-print-context/test-print-context.js
4698
- import { html as html19, LitElement as LitElement20 } from "lit";
4699
- import { consume as consume13 } from "@lit/context";
4700
- import { state as state6 } from "lit/decorators.js";
4701
- var __decorate20 = function(decorators, target, key, desc) {
4702
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4703
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4704
- 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;
4705
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4706
- };
4707
- var TestPrintContext = class extends LitElement20 {
4708
- render() {
4709
- return html19` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
4882
+ /** Item-ref mode: our item rendered again, so the elements collected earlier are detached. */
4883
+ #handleItemConnected() {
4884
+ if (this.#readingElements !== null)
4885
+ this.#resetReadingPosition();
4710
4886
  }
4711
- };
4712
- __decorate20([
4713
- state6(),
4714
- consume13({ context: computedContext, subscribe: true })
4715
- ], TestPrintContext.prototype, "computedContext", void 0);
4716
-
4717
- // ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
4718
- import { html as html20, css as css12, LitElement as LitElement21 } from "lit";
4719
- import { consume as consume14 } from "@lit/context";
4720
- var __decorate21 = function(decorators, target, key, desc) {
4721
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4722
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4723
- 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;
4724
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4725
- };
4726
- var TestPrintVariables = class extends LitElement21 {
4727
- static {
4728
- this.styles = css12`
4729
- table {
4730
- width: 100%;
4731
- border-collapse: collapse;
4732
- margin: 20px 0;
4733
- font-size: 14px;
4734
- text-align: left;
4735
- }
4736
- th,
4737
- td {
4738
- border: 1px solid #ddd;
4739
- padding: 8px;
4740
- }
4741
- th {
4742
- background-color: #f4f4f4;
4743
- font-weight: bold;
4744
- }
4745
- h3 {
4746
- margin-top: 20px;
4747
- font-size: 16px;
4887
+ /** Cursor mode: the active item and section, from the computed context. */
4888
+ #activePosition() {
4889
+ for (const part of this._computedContext?.testParts ?? []) {
4890
+ for (const section of part.sections) {
4891
+ if (!section.active)
4892
+ continue;
4893
+ return { item: section.items.find((item) => item.active)?.identifier ?? null, section: section.identifier };
4894
+ }
4748
4895
  }
4749
- `;
4750
- }
4751
- render() {
4752
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4753
- if (!activeItem || !activeItem.variables)
4754
- return html20``;
4755
- const responseVariables = activeItem.variables.filter((v) => v.type === "response");
4756
- const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
4757
- const renderTable = (variables, title) => html20`
4758
- <h3>${title}</h3>
4759
- <table>
4760
- <thead>
4761
- <tr>
4762
- <th>Identifier</th>
4763
- <th>Value</th>
4764
- <th>Cardinality</th>
4765
- <th>Base Type</th>
4766
- <th>Correct Response / Mappings</th>
4767
- </tr>
4768
- </thead>
4769
- <tbody>
4770
- ${variables.map((v) => {
4771
- const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
4772
- const mapEntries = v.mapping?.mapEntries?.map((m) => `${m.mapKey}=${m.mappedValue}pt`).join(", ") || "";
4773
- const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m) => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ") || "";
4774
- return html20`
4775
- <tr>
4776
- <td>${v.identifier}</td>
4777
- <td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
4778
- <td>${v.cardinality}</td>
4779
- <td>${v.baseType}</td>
4780
- <td>${correctResponse || mapEntries || areaMapEntries}</td>
4781
- </tr>
4782
- `;
4783
- })}
4784
- </tbody>
4785
- </table>
4786
- `;
4787
- return html20`
4788
- ${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
4789
- `;
4896
+ return { item: null, section: null };
4790
4897
  }
4791
- };
4792
- __decorate21([
4793
- consume14({ context: computedContext, subscribe: true })
4794
- ], TestPrintVariables.prototype, "computedContext", void 0);
4795
-
4796
- // ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
4797
- import { html as html21, LitElement as LitElement22, nothing as nothing3 } from "lit";
4798
- import { consume as consume15 } from "@lit/context";
4799
- import { property as property16 } from "lit/decorators.js";
4800
- var __decorate22 = function(decorators, target, key, desc) {
4801
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4802
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4803
- 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;
4804
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4805
- };
4806
- var TestScoringButtons = class extends LitElement22 {
4807
- createRenderRoot() {
4808
- return this;
4898
+ /**
4899
+ * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
4900
+ * collected, so the next play reads the new content from the top. Unlike
4901
+ * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
4902
+ * while an item player on the same page is speaking.
4903
+ */
4904
+ #handleStimulusReplaced() {
4905
+ if (this.#currentUtterance) {
4906
+ this.#currentUtterance = null;
4907
+ speechSynthesis.cancel();
4908
+ }
4909
+ this.#stopPicking();
4910
+ this.#clearAllHighlights();
4911
+ this.#setSpeechState("idle");
4912
+ this.#readingElements = null;
4913
+ this.#currentElementIndex = 0;
4914
+ this.#finished = false;
4915
+ this.#updateContext();
4809
4916
  }
4810
- connectedCallback() {
4811
- super.connectedCallback();
4812
- const templateElement = this.querySelector("template");
4813
- if (!templateElement) {
4814
- this.myTemplate = null;
4815
- return;
4816
- }
4817
- this.myTemplate = prepareTemplate(templateElement);
4917
+ /**
4918
+ * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
4919
+ * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
4920
+ * loading replaces the placeholder's content.
4921
+ */
4922
+ #stimulusPlaceholder() {
4923
+ return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
4818
4924
  }
4819
- #changeOutcomeScore(value) {
4820
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4821
- const sectionItems = testPart.sections.flatMap((section) => section.items);
4822
- const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
4823
- dispatchPublic(this, "cito-test-update-outcome", {
4824
- assessmentItemRefId: currentItemIdentifier,
4825
- outcomeVariableId: "SCORE",
4826
- value
4827
- });
4925
+ /**
4926
+ * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
4927
+ * The marker goes on one container; the player finds the readable elements inside it.
4928
+ */
4929
+ #contentElement() {
4930
+ return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
4828
4931
  }
4829
- render() {
4830
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4831
- if (!activeItem || !activeItem.variables)
4832
- return html21``;
4833
- const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
4834
- const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
4835
- const score = scoreOutcome?.value;
4836
- const disabled = !(scoreOutcome?.externalScored === "human");
4837
- if (!maxScore || !scoreOutcome)
4838
- return nothing3;
4839
- const scores = [...Array(Number(maxScore) + 1).keys()];
4840
- return html21`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing3}`;
4932
+ /**
4933
+ * The element whose text is read: the stimulus body next to the player (stimulus mode), the
4934
+ * marked content next to it (content mode), or the item body of the item to read.
4935
+ */
4936
+ #resolveReadingRoot() {
4937
+ if (this.#stimulusMode)
4938
+ return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
4939
+ if (this.#contentMode)
4940
+ return this.#contentElement();
4941
+ return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
4841
4942
  }
4842
- constructor() {
4843
- super();
4844
- this.view = "";
4845
- this.disabled = false;
4846
- this.myTemplate = null;
4847
- this.addEventListener("click", (e) => {
4848
- const target = e.target;
4849
- const value = parseFloat(target.value);
4850
- if (target.tagName === "INPUT") {
4851
- this.#changeOutcomeScore(value);
4852
- }
4853
- });
4943
+ /**
4944
+ * The item to read: our item-ref's (item-ref mode), or the active one (cursor mode). The test
4945
+ * looks the active one up in its own items (`computedContext.itemElement`), so a page with
4946
+ * several tests showing the same item still reads the right one.
4947
+ */
4948
+ #resolveItem() {
4949
+ if (this.#itemRef)
4950
+ return this.#itemRef.assessmentItem;
4951
+ const { item } = this.#activePosition();
4952
+ return item ? this._computedContext?.itemElement?.(item) ?? null : null;
4854
4953
  }
4855
- };
4856
- __decorate22([
4857
- property16({ type: String, attribute: "view" })
4858
- ], TestScoringButtons.prototype, "view", void 0);
4859
- __decorate22([
4860
- property16({ type: Boolean })
4861
- ], TestScoringButtons.prototype, "disabled", void 0);
4862
- __decorate22([
4863
- consume15({ context: computedContext, subscribe: true })
4864
- ], TestScoringButtons.prototype, "computedContext", void 0);
4865
-
4866
- // ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
4867
- import { consume as consume16 } from "@lit/context";
4868
- import { html as html22, LitElement as LitElement23 } from "lit";
4869
- import { property as property17 } from "lit/decorators.js";
4870
- var __decorate23 = function(decorators, target, key, desc) {
4871
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4872
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4873
- 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;
4874
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4875
- };
4876
- var TestScoringFeedback = class extends LitElement23 {
4877
- constructor() {
4878
- super(...arguments);
4879
- this.view = null;
4954
+ /** Update speech state on both the context (notifies children) and the host's CSS custom states. */
4955
+ #setSpeechState(state9) {
4956
+ this._ttsContext = { ...this._ttsContext, state: state9 };
4957
+ this.#internals.states.delete("idle");
4958
+ this.#internals.states.delete("playing");
4959
+ this.#internals.states.delete("paused");
4960
+ this.#internals.states.add(state9);
4880
4961
  }
4881
- render() {
4882
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4883
- if (!activeItem || !activeItem.variables)
4884
- return html22``;
4885
- if (activeItem["category"] === "dep-informational")
4886
- return html22`<div>${this.dataset.informational}</div>`;
4887
- const completionStatus = activeItem?.variables.find((v) => v.identifier === "completionStatus")?.value;
4888
- const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
4889
- const score = parseFloat(scoreOutcome?.value);
4890
- const externalScored = activeItem["externalScored"];
4891
- const feedbackText = () => {
4892
- if (completionStatus !== "completed") {
4893
- return this.dataset.textNoResponse;
4894
- }
4895
- if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
4896
- return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
4897
- }
4898
- if (externalScored === "externalMachine") {
4899
- 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.`;
4900
- }
4901
- if (externalScored === "human") {
4902
- return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
4903
- }
4904
- return this.dataset.inProgress;
4962
+ /** Push currentElementIndex and elementCount into context so children can react. */
4963
+ #updateContext() {
4964
+ this._ttsContext = {
4965
+ ...this._ttsContext,
4966
+ currentElementIndex: this.#currentElementIndex,
4967
+ elementCount: this.#getReadingElements().length
4905
4968
  };
4906
- return html22`<div>${feedbackText()}</div>`;
4907
- }
4908
- };
4909
- __decorate23([
4910
- consume16({ context: computedContext, subscribe: true })
4911
- ], TestScoringFeedback.prototype, "computedContext", void 0);
4912
- __decorate23([
4913
- property17({ type: String, attribute: "view" })
4914
- ], TestScoringFeedback.prototype, "view", void 0);
4915
-
4916
- // ../qti-test/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js
4917
- import { html as html23, LitElement as LitElement24 } from "lit";
4918
- import { consume as consume17 } from "@lit/context";
4919
- var __decorate24 = function(decorators, target, key, desc) {
4920
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4921
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4922
- 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;
4923
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4924
- };
4925
- var TestSectionButtonsStamp = class extends LitElement24 {
4926
- #internals;
4927
- createRenderRoot() {
4928
- return this;
4929
4969
  }
4930
- constructor() {
4931
- super();
4932
- this.#internals = this.attachInternals();
4933
- this.#internals.ariaLabel = "pagination";
4970
+ /**
4971
+ * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
4972
+ * first call), filtered live for visibility on every call. Feedback and other
4973
+ * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
4974
+ * CSS custom state reveals it) is excluded while hidden and picked up again once shown,
4975
+ * without needing to re-collect the candidate set.
4976
+ */
4977
+ #getReadingElements() {
4978
+ if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
4979
+ this.#readingElements = null;
4980
+ this.#currentElementIndex = 0;
4981
+ this.#finished = false;
4982
+ }
4983
+ if (this.#readingElements === null) {
4984
+ const root = this.#resolveReadingRoot();
4985
+ if (!root)
4986
+ return [];
4987
+ this.#readingRoot = root;
4988
+ const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
4989
+ this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
4990
+ }
4991
+ return this.#readingElements.filter((el) => this.#isVisible(el));
4934
4992
  }
4935
- connectedCallback() {
4936
- super.connectedCallback();
4937
- const templateElement = this.querySelector("template");
4938
- this.myTemplate = prepareTemplate(templateElement);
4993
+ /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
4994
+ #isVisible(element) {
4995
+ if (typeof element.checkVisibility === "function") {
4996
+ return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
4997
+ }
4998
+ return element.getClientRects().length > 0;
4939
4999
  }
4940
- render() {
4941
- if (!this.computedContext)
4942
- return html23``;
4943
- const sections = this.computedContext.testParts.flatMap((testPart) => testPart.sections);
4944
- return html23` ${sections.map((item) => this.myTemplate({ item }))} `;
5000
+ /**
5001
+ * Resolve the speech language for a reading element.
5002
+ * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
5003
+ * Empty `lang=""` is treated as absent.
5004
+ */
5005
+ #resolveLang(element) {
5006
+ let node = element;
5007
+ while (node) {
5008
+ const lang = node.getAttribute("lang") || node.getAttribute("xml:lang");
5009
+ if (lang?.trim())
5010
+ return lang.trim();
5011
+ node = node.parentElement ?? node.getRootNode().host ?? null;
5012
+ }
5013
+ const documentLang = document.documentElement.getAttribute("lang");
5014
+ if (documentLang?.trim())
5015
+ return documentLang.trim();
5016
+ return this.language;
4945
5017
  }
4946
- };
4947
- __decorate24([
4948
- consume17({ context: computedContext, subscribe: true })
4949
- ], TestSectionButtonsStamp.prototype, "computedContext", void 0);
4950
-
4951
- // ../qti-test/dist/components/test-section-link/test-section-link.js
4952
- import { css as css13, html as html24, LitElement as LitElement25 } from "lit";
4953
- import { property as property18 } from "lit/decorators.js";
4954
- var __decorate25 = function(decorators, target, key, desc) {
4955
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4956
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4957
- 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;
4958
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4959
- };
4960
- var TestSectionLink = class extends LitElement25 {
4961
- static {
4962
- this.styles = css13`
4963
- :host {
4964
- ${btn};
5018
+ #playSpeech() {
5019
+ const elements = this.#getReadingElements();
5020
+ if (!elements.length) {
5021
+ console.warn("test-item-to-speech: no readable elements found");
5022
+ return;
4965
5023
  }
4966
- :host(:hover:not([disabled])) {
4967
- ${btnInteractive};
5024
+ this.#stopPicking();
5025
+ speechSynthesis.cancel();
5026
+ if (this.#finished) {
5027
+ this.#finished = false;
5028
+ this.#currentElementIndex = 0;
4968
5029
  }
4969
- :host(:focus-visible) {
4970
- ${focusRing};
5030
+ if (this.#contentMode && this.#currentElementIndex === 0)
5031
+ this.#readingElements = null;
5032
+ this.#speakElement(this.#currentElementIndex);
5033
+ }
5034
+ /** Speak the element at the given index, then auto-advance when it ends. */
5035
+ #speakElement(index) {
5036
+ const elements = this.#getReadingElements();
5037
+ if (index >= elements.length) {
5038
+ this.#clearWordHighlight();
5039
+ this.#currentElementIndex = elements.length - 1;
5040
+ if (elements.length > 0)
5041
+ this.#highlightElement(elements[this.#currentElementIndex]);
5042
+ this.#finished = true;
5043
+ this.#setSpeechState("idle");
5044
+ this.#updateContext();
5045
+ return;
4971
5046
  }
4972
- :host([disabled]) {
4973
- ${dis};
5047
+ this.#currentElementIndex = index;
5048
+ this.#finished = false;
5049
+ this.#updateContext();
5050
+ const element = elements[index];
5051
+ element.scrollIntoView({ behavior: "smooth", block: "nearest" });
5052
+ this.#highlightElement(element);
5053
+ this.#textNodes = this.#collectTextNodes(element);
5054
+ const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
5055
+ if (!text.trim()) {
5056
+ this.#speakElement(index + 1);
5057
+ return;
4974
5058
  }
4975
- `;
4976
- }
4977
- #requestItem(identifier) {
4978
- dispatchPublic(this, "cito-test-navigate", { type: "section", id: identifier });
5059
+ const utterance = new SpeechSynthesisUtterance(text);
5060
+ utterance.lang = this.#resolveLang(element);
5061
+ utterance.rate = 1;
5062
+ utterance.onboundary = (event) => {
5063
+ if (event.name !== "word")
5064
+ return;
5065
+ this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
5066
+ };
5067
+ utterance.onend = () => {
5068
+ if (this.#currentUtterance !== utterance)
5069
+ return;
5070
+ this.#currentUtterance = null;
5071
+ this.#clearWordHighlight();
5072
+ this.#speakElement(this.#currentElementIndex + 1);
5073
+ };
5074
+ utterance.onerror = () => {
5075
+ if (this.#currentUtterance !== utterance)
5076
+ return;
5077
+ this.#currentUtterance = null;
5078
+ this.#clearAllHighlights();
5079
+ this.#setSpeechState("idle");
5080
+ };
5081
+ this.#currentUtterance = utterance;
5082
+ speechSynthesis.speak(utterance);
5083
+ this.#setSpeechState("playing");
4979
5084
  }
4980
- constructor() {
4981
- super();
4982
- this.sectionId = null;
4983
- this.addEventListener("click", () => this.#requestItem(this.sectionId));
5085
+ #pause() {
5086
+ speechSynthesis.pause();
5087
+ this.#setSpeechState("paused");
4984
5088
  }
4985
- render() {
4986
- return html24` <slot></slot> `;
5089
+ #resume() {
5090
+ speechSynthesis.resume();
5091
+ this.#setSpeechState("playing");
4987
5092
  }
4988
- };
4989
- __decorate25([
4990
- property18({ type: String, attribute: "section-id" })
4991
- ], TestSectionLink.prototype, "sectionId", void 0);
4992
-
4993
- // ../qti-test/dist/components/test-stamp/test-stamp.js
4994
- import { html as html25, LitElement as LitElement26, nothing as nothing4 } from "lit";
4995
- import { property as property19, state as state7 } from "lit/decorators.js";
4996
- import { consume as consume18 } from "@lit/context";
4997
- var __decorate26 = function(decorators, target, key, desc) {
4998
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4999
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5000
- 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;
5001
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5002
- };
5003
- var TestStamp = class extends LitElement26 {
5004
- constructor() {
5005
- super(...arguments);
5006
- this.debug = false;
5007
- this.stampContext = {
5008
- view: "candidate",
5009
- activeItem: {},
5010
- activeSection: {
5011
- items: []
5012
- },
5013
- activeTestpart: {
5014
- items: [],
5015
- sections: []
5016
- },
5017
- test: {}
5018
- };
5093
+ #stop() {
5094
+ this.#currentUtterance = null;
5095
+ speechSynthesis.cancel();
5096
+ this.#clearAllHighlights();
5097
+ this.#setSpeechState("idle");
5019
5098
  }
5020
- createRenderRoot() {
5021
- return this;
5099
+ // ─── Pick mode ────────────────────────────────────────────────────────────
5100
+ #togglePick() {
5101
+ if (this.#picking)
5102
+ this.#stopPicking();
5103
+ else
5104
+ this.#startPicking();
5022
5105
  }
5023
- connectedCallback() {
5024
- super.connectedCallback();
5025
- const templateElement = this.querySelector("template");
5026
- if (!templateElement) {
5027
- this.myTemplate = null;
5106
+ /** Highlight every reading element and wait for a click on one of them. */
5107
+ #startPicking() {
5108
+ if (this.#contentMode)
5109
+ this.#readingElements = null;
5110
+ const elements = this.#getReadingElements();
5111
+ if (!elements.length) {
5112
+ console.warn("test-item-to-speech: no readable elements found");
5028
5113
  return;
5029
5114
  }
5030
- this.myTemplate = prepareTemplate(templateElement);
5115
+ this.#stop();
5116
+ this.#picking = true;
5117
+ this.#internals.states.add("picking");
5118
+ this.#highlightElements(elements);
5119
+ this.#pickRoot = elements[0].getRootNode();
5120
+ this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
5121
+ this._ttsContext = { ...this._ttsContext, picking: true };
5031
5122
  }
5032
- willUpdate(_changedProperties) {
5033
- if (!this.computedContext) {
5123
+ #stopPicking() {
5124
+ if (!this.#picking)
5034
5125
  return;
5126
+ this.#picking = false;
5127
+ this.#internals.states.delete("picking");
5128
+ this.#pickRoot?.removeEventListener("click", this.#boundHandlePickClick, true);
5129
+ this.#pickRoot = null;
5130
+ this.#clearAllHighlights();
5131
+ this._ttsContext = { ...this._ttsContext, picking: false };
5132
+ }
5133
+ #handlePickClick(event) {
5134
+ const elements = this.#getReadingElements();
5135
+ const path = event.composedPath();
5136
+ let index = elements.findIndex((el) => path.includes(el));
5137
+ if (index < 0) {
5138
+ const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
5139
+ if (container)
5140
+ index = elements.findIndex((el) => container.contains(el));
5035
5141
  }
5036
- const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
5037
- const activeSection = activeTestPart?.sections.find((section) => section.active);
5038
- const activeItem = activeSection?.items.find((item) => item.active);
5039
- const { variables, ...augmentedItem } = activeItem || {};
5040
- if (!activeTestPart || !activeSection || !activeItem) {
5142
+ if (index < 0)
5041
5143
  return;
5144
+ event.preventDefault();
5145
+ event.stopPropagation();
5146
+ this.#stopPicking();
5147
+ speechSynthesis.cancel();
5148
+ this.#speakElement(index);
5149
+ }
5150
+ #prevElement() {
5151
+ const elements = this.#getReadingElements();
5152
+ if (!elements.length)
5153
+ return;
5154
+ this.#currentUtterance = null;
5155
+ speechSynthesis.cancel();
5156
+ this.#clearWordHighlight();
5157
+ this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
5158
+ this.#finished = false;
5159
+ this.#updateContext();
5160
+ const el = elements[this.#currentElementIndex];
5161
+ el.scrollIntoView({ behavior: "smooth", block: "nearest" });
5162
+ this.#highlightElement(el);
5163
+ this.#setSpeechState("idle");
5164
+ }
5165
+ #nextElement() {
5166
+ const elements = this.#getReadingElements();
5167
+ if (!elements.length)
5168
+ return;
5169
+ this.#currentUtterance = null;
5170
+ speechSynthesis.cancel();
5171
+ this.#clearWordHighlight();
5172
+ this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
5173
+ this.#finished = false;
5174
+ this.#updateContext();
5175
+ const el = elements[this.#currentElementIndex];
5176
+ el.scrollIntoView({ behavior: "smooth", block: "nearest" });
5177
+ this.#highlightElement(el);
5178
+ this.#setSpeechState("idle");
5179
+ }
5180
+ /** Walk text nodes without crossing shadow DOM boundaries. */
5181
+ #collectTextNodes(root) {
5182
+ const nodes = [];
5183
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
5184
+ let node;
5185
+ while (node = walker.nextNode()) {
5186
+ if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
5187
+ nodes.push(node);
5188
+ }
5042
5189
  }
5043
- const augmentedTestPart = {
5044
- ...activeTestPart,
5045
- items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables: variables2, ...rest }) => rest)),
5046
- sections: activeTestPart.sections.map((section) => ({
5047
- ...section,
5048
- items: section.items.map(({ variables: variables2, ...rest }) => rest)
5049
- }))
5050
- };
5051
- const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables: variables2, ...rest }) => rest) };
5052
- const { testParts, ...activeTest } = this.computedContext;
5053
- this.stampContext = {
5054
- view: this.computedContext.view,
5055
- activeItem: augmentedItem,
5056
- activeSection: augmentedSection,
5057
- activeTestpart: augmentedTestPart,
5058
- test: activeTest
5059
- };
5060
- this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
5061
- detail: this.stampContext,
5062
- bubbles: true
5063
- }));
5190
+ return nodes;
5064
5191
  }
5065
- render() {
5066
- return html25` ${this.debug ? html25`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing4}
5067
- ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
5192
+ /** Highlight the whole element as the navigation cursor (blue). */
5193
+ #highlightElement(element) {
5194
+ this.#highlightElements([element]);
5068
5195
  }
5069
- };
5070
- __decorate26([
5071
- property19({ type: Boolean, reflect: true })
5072
- ], TestStamp.prototype, "debug", void 0);
5073
- __decorate26([
5074
- state7(),
5075
- consume18({ context: computedContext, subscribe: true })
5076
- ], TestStamp.prototype, "computedContext", void 0);
5077
- __decorate26([
5078
- state7()
5079
- ], TestStamp.prototype, "stampContext", void 0);
5080
-
5081
- // ../qti-test/dist/components/test-view-toggle/test-view.js
5082
- import { html as html26, LitElement as LitElement27 } from "lit";
5083
- import { property as property20, state as state8 } from "lit/decorators.js";
5084
- import { consume as consume19 } from "@lit/context";
5085
- var __decorate27 = function(decorators, target, key, desc) {
5086
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5087
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5088
- 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;
5089
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5090
- };
5091
- var _a;
5092
- var TestView = class extends LitElement27 {
5093
- constructor() {
5094
- super(...arguments);
5095
- this.label = "view";
5096
- this._handleViewOptionsChange = () => {
5097
- this.#updateViewOptions();
5098
- };
5099
- this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
5196
+ /** Put the blue cursor highlight on several elements at once (pick mode). */
5197
+ #highlightElements(elements) {
5198
+ if (!("highlights" in CSS))
5199
+ return;
5200
+ this.#ensureHighlightStyles();
5201
+ this.#elementHighlight.clear();
5202
+ for (const element of elements) {
5203
+ const range = new Range();
5204
+ range.selectNodeContents(element);
5205
+ this.#elementHighlight.add(range);
5206
+ }
5207
+ CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
5208
+ }
5209
+ /** Highlight the current word within #textNodes (yellow, during speech). */
5210
+ #updateWordHighlight(charIndex, charLength) {
5211
+ if (!("highlights" in CSS))
5212
+ return;
5213
+ this.#ensureHighlightStyles();
5214
+ this.#wordHighlight.clear();
5215
+ const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
5216
+ const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));
5217
+ let offset = 0;
5218
+ let startNode = null;
5219
+ let startOffset = 0;
5220
+ let endNode = null;
5221
+ let endOffset = 0;
5222
+ for (const node of this.#textNodes) {
5223
+ const len = node.textContent?.length ?? 0;
5224
+ if (!startNode && offset + len > charIndex) {
5225
+ startNode = node;
5226
+ startOffset = charIndex - offset;
5227
+ }
5228
+ if (startNode && offset + len >= endIndex) {
5229
+ endNode = node;
5230
+ endOffset = endIndex - offset;
5231
+ break;
5232
+ }
5233
+ offset += len;
5234
+ }
5235
+ if (startNode && endNode) {
5236
+ const range = new Range();
5237
+ range.setStart(startNode, startOffset);
5238
+ range.setEnd(endNode, endOffset);
5239
+ this.#wordHighlight.add(range);
5240
+ CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);
5241
+ }
5100
5242
  }
5101
- static {
5102
- this.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
5243
+ #clearWordHighlight() {
5244
+ if (!("highlights" in CSS))
5245
+ return;
5246
+ this.#wordHighlight.clear();
5247
+ if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight)
5248
+ CSS.highlights.delete(HIGHLIGHT_WORD);
5103
5249
  }
5104
- connectedCallback() {
5105
- super.connectedCallback();
5106
- this.#updateViewOptions();
5250
+ #clearAllHighlights() {
5251
+ if (!("highlights" in CSS))
5252
+ return;
5253
+ this.#clearWordHighlight();
5254
+ this.#elementHighlight.clear();
5255
+ if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
5256
+ CSS.highlights.delete(HIGHLIGHT_ELEMENT);
5107
5257
  }
5108
- #updateViewOptions() {
5109
- if (this.viewOptions) {
5110
- const options = this.viewOptions.split(",").map((opt) => opt.trim());
5111
- this._viewOptions = options.filter((opt) => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
5112
- } else {
5113
- this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
5258
+ /** Fallback word-length when charLength is 0. */
5259
+ #wordLengthAt(charIndex, text) {
5260
+ const right = text.slice(charIndex).search(/\s/);
5261
+ return right < 0 ? text.length - charIndex : right;
5262
+ }
5263
+ /**
5264
+ * Add ::highlight() rules both to the shadow root the highlighted text lives in and to the
5265
+ * document (safety net — spec allows document rules to apply across shadow DOM). Called lazily
5266
+ * on first highlight use, once the reading elements have been collected.
5267
+ */
5268
+ #ensureHighlightStyles() {
5269
+ if (!("highlights" in CSS))
5270
+ return;
5271
+ const sheet = getHighlightSheet();
5272
+ if (!document.adoptedStyleSheets.includes(sheet)) {
5273
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
5274
+ }
5275
+ const roots = /* @__PURE__ */ new Set();
5276
+ const ownRoot = this.getRootNode();
5277
+ if (ownRoot instanceof ShadowRoot)
5278
+ roots.add(ownRoot);
5279
+ const itemRoot = this.#readingElements?.[0]?.getRootNode();
5280
+ if (itemRoot instanceof ShadowRoot)
5281
+ roots.add(itemRoot);
5282
+ for (const root of roots) {
5283
+ if (!root.adoptedStyleSheets.includes(sheet)) {
5284
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
5285
+ }
5114
5286
  }
5115
5287
  }
5116
- _switchView(view) {
5117
- dispatchPublic(this, "cito-test-switch-view", view);
5288
+ };
5289
+ __decorate29([
5290
+ property23({ type: String })
5291
+ ], TestItemToSpeech.prototype, "language", void 0);
5292
+ __decorate29([
5293
+ consume19({ context: computedContext, subscribe: true })
5294
+ ], TestItemToSpeech.prototype, "_computedContext", void 0);
5295
+ __decorate29([
5296
+ state8(),
5297
+ provide4({ context: ttsContext })
5298
+ ], TestItemToSpeech.prototype, "_ttsContext", void 0);
5299
+ var TestTtsPlay = class extends TtsButtonBase {
5300
+ #toggle() {
5301
+ if (!this._tts)
5302
+ return;
5303
+ if (this._tts.state === "idle")
5304
+ this._tts.play();
5305
+ else if (this._tts.state === "playing")
5306
+ this._tts.pause();
5307
+ else
5308
+ this._tts.resume();
5118
5309
  }
5119
5310
  render() {
5120
- return html26`
5121
- <label part="label" for="viewSelect">${this.label}</label>
5122
- <select
5123
- part="select"
5124
- id="viewSelect"
5125
- @change=${(e) => {
5126
- const el = e.target;
5127
- this._switchView(el.value);
5128
- }}
5129
- >
5130
- ${this._viewOptions.map((v) => html26`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
5131
- </select>
5311
+ const playing = this._tts?.state === "playing";
5312
+ return html27`
5313
+ <button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
5314
+ ${playing ? html27`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html27`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
5315
+ </button>
5132
5316
  `;
5133
5317
  }
5134
5318
  };
5135
- _a = TestView;
5136
- __decorate27([
5137
- consume19({ context: sessionContext, subscribe: true })
5138
- ], TestView.prototype, "sessionContext", void 0);
5139
- __decorate27([
5140
- property20({ type: String })
5141
- ], TestView.prototype, "label", void 0);
5142
- __decorate27([
5143
- property20({ type: String, attribute: "view-options" })
5144
- ], TestView.prototype, "viewOptions", void 0);
5145
- __decorate27([
5146
- watch("viewOptions", { waitUntilFirstUpdate: true })
5147
- ], TestView.prototype, "_handleViewOptionsChange", void 0);
5148
- __decorate27([
5149
- state8()
5150
- ], TestView.prototype, "_viewOptions", void 0);
5151
-
5152
- // ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
5153
- import { consume as consume20 } from "@lit/context";
5154
- import { html as html27, LitElement as LitElement28, nothing as nothing5 } from "lit";
5155
- var __decorate28 = function(decorators, target, key, desc) {
5156
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5157
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5158
- 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;
5159
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5319
+ __decorate29([
5320
+ property23({ type: String, attribute: "pause-label" })
5321
+ ], TestTtsPlay.prototype, "pauseLabel", void 0);
5322
+ var TestTtsPause = class extends TtsButtonBase {
5323
+ render() {
5324
+ return html27`
5325
+ <button
5326
+ part="button"
5327
+ aria-label=${ifDefined(this.label)}
5328
+ ?disabled=${this._tts?.state !== "playing"}
5329
+ @click=${() => this._tts?.pause()}
5330
+ >
5331
+ <slot>${iconContent("pause", this.label ?? "Pause")}</slot>
5332
+ </button>
5333
+ `;
5334
+ }
5160
5335
  };
5161
- var TestViewToggle = class extends LitElement28 {
5162
- createRenderRoot() {
5163
- return this;
5336
+ var TestTtsResume = class extends TtsButtonBase {
5337
+ render() {
5338
+ return html27`
5339
+ <button
5340
+ part="button"
5341
+ aria-label=${ifDefined(this.label)}
5342
+ ?disabled=${this._tts?.state !== "paused"}
5343
+ @click=${() => this._tts?.resume()}
5344
+ >
5345
+ <slot>${iconContent("play", this.label ?? "Resume")}</slot>
5346
+ </button>
5347
+ `;
5164
5348
  }
5165
- connectedCallback() {
5166
- super.connectedCallback();
5167
- const templateElement = this.querySelector("template");
5168
- if (!templateElement) {
5169
- this.myTemplate = null;
5170
- return;
5171
- }
5172
- this.myTemplate = prepareTemplate(templateElement);
5349
+ };
5350
+ var TestTtsStop = class extends TtsButtonBase {
5351
+ render() {
5352
+ const idle = this._tts?.state === "idle" && !this._tts?.picking;
5353
+ return html27`
5354
+ <button part="button" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>
5355
+ <slot>${iconContent("stop", this.label ?? "Stop")}</slot>
5356
+ </button>
5357
+ `;
5173
5358
  }
5174
- _switchView(view) {
5175
- dispatchPublic(this, "cito-test-switch-view", view);
5359
+ };
5360
+ var TestTtsPrev = class extends TtsButtonBase {
5361
+ render() {
5362
+ const collected = (this._tts?.elementCount ?? 0) > 0;
5363
+ const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
5364
+ return html27`
5365
+ <button
5366
+ part="button"
5367
+ aria-label=${ifDefined(this.label)}
5368
+ ?disabled=${collected && atStart}
5369
+ @click=${() => this._tts?.prevElement()}
5370
+ >
5371
+ <slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
5372
+ </button>
5373
+ `;
5176
5374
  }
5177
- firstUpdated(_changedProperties) {
5178
- this.addEventListener("click", () => {
5179
- if (this.sessionContext?.view === "scorer") {
5180
- this._switchView("candidate");
5181
- } else {
5182
- this._switchView("scorer");
5183
- }
5184
- });
5375
+ };
5376
+ var TestTtsNext = class extends TtsButtonBase {
5377
+ render() {
5378
+ const count = this._tts?.elementCount ?? 0;
5379
+ const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
5380
+ return html27`
5381
+ <button
5382
+ part="button"
5383
+ aria-label=${ifDefined(this.label)}
5384
+ ?disabled=${atEnd}
5385
+ @click=${() => this._tts?.nextElement()}
5386
+ >
5387
+ <slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
5388
+ </button>
5389
+ `;
5185
5390
  }
5391
+ };
5392
+ var TestTtsPick = class extends TtsButtonBase {
5186
5393
  render() {
5187
- return html27`${this.myTemplate ? this.myTemplate({
5188
- view: this.sessionContext?.view
5189
- }) : nothing5}`;
5394
+ return html27`
5395
+ <button
5396
+ part="button"
5397
+ aria-label=${ifDefined(this.label)}
5398
+ aria-pressed=${this._tts?.picking ? "true" : "false"}
5399
+ @click=${() => this._tts?.togglePick()}
5400
+ >
5401
+ <slot>${iconContent("pick", this.label ?? "Read from here")}</slot>
5402
+ </button>
5403
+ `;
5190
5404
  }
5191
5405
  };
5192
- __decorate28([
5193
- consume20({ context: sessionContext, subscribe: true })
5194
- ], TestViewToggle.prototype, "sessionContext", void 0);
5406
+
5407
+ // ../qti-test/dist/tts/elements.js
5408
+ var ttsElements = [
5409
+ { tag: "test-item-to-speech", ctor: TestItemToSpeech },
5410
+ { tag: "test-tts-next", ctor: TestTtsNext },
5411
+ { tag: "test-tts-pause", ctor: TestTtsPause },
5412
+ { tag: "test-tts-pick", ctor: TestTtsPick },
5413
+ { tag: "test-tts-play", ctor: TestTtsPlay },
5414
+ { tag: "test-tts-prev", ctor: TestTtsPrev },
5415
+ { tag: "test-tts-resume", ctor: TestTtsResume },
5416
+ { tag: "test-tts-stop", ctor: TestTtsStop }
5417
+ ];
5418
+
5419
+ // ../qti-test/dist/plugins/elements.js
5420
+ var pluginElements = [
5421
+ { tag: "test-check-item", ctor: TestCheckItem },
5422
+ { tag: "test-bookmark", ctor: TestBookmark },
5423
+ { tag: "test-print-context", ctor: TestPrintContext },
5424
+ { tag: "test-print-item-variables", ctor: TestPrintVariables },
5425
+ { tag: "test-scoring-buttons", ctor: TestScoringButtons },
5426
+ { tag: "test-scoring-feedback", ctor: TestScoringFeedback },
5427
+ { tag: "test-stamp", ctor: TestStamp },
5428
+ { tag: "test-submit", ctor: TestSubmit },
5429
+ { tag: "test-view", ctor: TestView },
5430
+ { tag: "test-view-toggle", ctor: TestViewToggle },
5431
+ ...ttsElements
5432
+ ];
5195
5433
 
5196
5434
  // ../qti-test/dist/elements.js
5197
5435
  var qtiTestElements = [
@@ -5200,6 +5438,7 @@ var qtiTestElements = [
5200
5438
  { tag: "qti-assessment-test", ctor: QtiAssessmentTest },
5201
5439
  { tag: "qti-branch-rule", ctor: QtiBranchRule },
5202
5440
  { tag: "qti-item-session-control", ctor: QtiItemSessionControl },
5441
+ { tag: "qti-number-presented", ctor: QtiNumberPresented },
5203
5442
  { tag: "qti-number-selected", ctor: QtiNumberSelected },
5204
5443
  { tag: "qti-outcome-processing", ctor: QtiOutcomeProcessing },
5205
5444
  { tag: "qti-pre-condition", ctor: QtiPreCondition },
@@ -5207,31 +5446,14 @@ var qtiTestElements = [
5207
5446
  { tag: "qti-test-feedback", ctor: QtiTestFeedback },
5208
5447
  { tag: "qti-test-part", ctor: QtiTestPart },
5209
5448
  { tag: "qti-test-variables", ctor: QtiTestVariables },
5210
- { tag: "test-check-item", ctor: TestCheckItem },
5211
5449
  { tag: "test-container", ctor: TestContainer },
5212
5450
  { tag: "test-end-attempt", ctor: TestEndAttempt },
5213
5451
  { tag: "test-item-link", ctor: TestItemLink },
5214
- { tag: "test-item-to-speech", ctor: TestItemToSpeech },
5215
5452
  { tag: "test-navigation", ctor: TestNavigation },
5216
5453
  { tag: "test-next", ctor: TestNext },
5217
- { tag: "test-paging-buttons-stamp", ctor: TestPagingButtonsStamp },
5218
5454
  { tag: "test-prev", ctor: TestPrev },
5219
- { tag: "test-print-context", ctor: TestPrintContext },
5220
- { tag: "test-print-item-variables", ctor: TestPrintVariables },
5221
- { tag: "test-scoring-buttons", ctor: TestScoringButtons },
5222
- { tag: "test-scoring-feedback", ctor: TestScoringFeedback },
5223
- { tag: "test-section-buttons-stamp", ctor: TestSectionButtonsStamp },
5224
5455
  { tag: "test-section-link", ctor: TestSectionLink },
5225
- { tag: "test-stamp", ctor: TestStamp },
5226
- { tag: "test-tts-next", ctor: TestTtsNext },
5227
- { tag: "test-tts-pause", ctor: TestTtsPause },
5228
- { tag: "test-tts-pick", ctor: TestTtsPick },
5229
- { tag: "test-tts-play", ctor: TestTtsPlay },
5230
- { tag: "test-tts-prev", ctor: TestTtsPrev },
5231
- { tag: "test-tts-resume", ctor: TestTtsResume },
5232
- { tag: "test-tts-stop", ctor: TestTtsStop },
5233
- { tag: "test-view", ctor: TestView },
5234
- { tag: "test-view-toggle", ctor: TestViewToggle }
5456
+ ...pluginElements
5235
5457
  ];
5236
5458
 
5237
5459
  export {
@@ -5240,6 +5462,7 @@ export {
5240
5462
  QtiAssessmentTest,
5241
5463
  QtiBranchRule,
5242
5464
  QtiItemSessionControl,
5465
+ QtiNumberPresented,
5243
5466
  QtiNumberSelected,
5244
5467
  QtiPreCondition,
5245
5468
  QtiOutcomeProcessing,
@@ -5250,32 +5473,35 @@ export {
5250
5473
  QtiTestVariablesExpression,
5251
5474
  QTI_TEST_STATE_VERSION,
5252
5475
  QtiTest,
5253
- TestCheckItem,
5254
5476
  TestContainer,
5255
5477
  TestEndAttempt,
5256
5478
  TestItemLink,
5257
- ttsContext,
5258
- TestItemToSpeech,
5259
- TestTtsPlay,
5260
- TestTtsPause,
5261
- TestTtsResume,
5262
- TestTtsStop,
5263
- TestTtsPrev,
5264
- TestTtsNext,
5265
- TestTtsPick,
5266
5479
  TestNavigation,
5267
5480
  TestNext,
5268
- TestPagingButtonsStamp,
5269
5481
  TestPrev,
5482
+ TestSectionLink,
5483
+ pluginState,
5484
+ bookmarkedItems,
5485
+ TestBookmark,
5486
+ TestCheckItem,
5270
5487
  TestPrintContext,
5271
5488
  TestPrintVariables,
5272
5489
  TestScoringButtons,
5273
5490
  TestScoringFeedback,
5274
- TestSectionButtonsStamp,
5275
- TestSectionLink,
5276
5491
  TestStamp,
5492
+ TestSubmit,
5277
5493
  TestView,
5278
5494
  TestViewToggle,
5495
+ TestItemToSpeech,
5496
+ TestTtsPlay,
5497
+ TestTtsPause,
5498
+ TestTtsResume,
5499
+ TestTtsStop,
5500
+ TestTtsPrev,
5501
+ TestTtsNext,
5502
+ TestTtsPick,
5503
+ ttsElements,
5504
+ pluginElements,
5279
5505
  qtiTestElements
5280
5506
  };
5281
5507
  /*! Bundled license information:
@@ -5290,4 +5516,4 @@ export {
5290
5516
  * Portions Copyright (c) 2013, the Dart project authors.
5291
5517
  *)
5292
5518
  */
5293
- //# sourceMappingURL=chunk-CKJ7M7JQ.js.map
5519
+ //# sourceMappingURL=chunk-RRMCWCSA.js.map