@citolab/qti-components 7.28.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +6205 -2973
  3. package/dist/base.d.ts +9 -50
  4. package/dist/base.js +27 -6
  5. package/dist/chunk-5QYII4OZ.js +1374 -0
  6. package/dist/chunk-5QYII4OZ.js.map +1 -0
  7. package/dist/{chunk-MPC7LIPC.js → chunk-5SJS36BI.js} +4264 -3647
  8. package/dist/chunk-5SJS36BI.js.map +1 -0
  9. package/dist/chunk-64XSIBGO.js +241 -0
  10. package/dist/chunk-64XSIBGO.js.map +1 -0
  11. package/dist/{chunk-SP6S2WMG.js → chunk-7V4HJFHW.js} +3 -3
  12. package/dist/{chunk-SP6S2WMG.js.map → chunk-7V4HJFHW.js.map} +1 -1
  13. package/dist/{chunk-3XV26R5M.js → chunk-H3J7LFRO.js} +829 -1005
  14. package/dist/chunk-H3J7LFRO.js.map +1 -0
  15. package/dist/{chunk-3WBG257S.js → chunk-IJD53WY6.js} +96 -74
  16. package/dist/chunk-IJD53WY6.js.map +1 -0
  17. package/dist/chunk-KYEZRYO6.js +1608 -0
  18. package/dist/chunk-KYEZRYO6.js.map +1 -0
  19. package/dist/{chunk-HFCZFWSH.js → chunk-LZJHHZQ2.js} +1954 -1729
  20. package/dist/chunk-LZJHHZQ2.js.map +1 -0
  21. package/dist/chunk-MGF5F3S2.js +11 -0
  22. package/dist/chunk-MGF5F3S2.js.map +1 -0
  23. package/dist/chunk-MJVPNN7W.js +11 -0
  24. package/dist/chunk-MJVPNN7W.js.map +1 -0
  25. package/dist/{chunk-REI3AMCZ.js → chunk-NA2N2WSG.js} +1303 -1193
  26. package/dist/chunk-NA2N2WSG.js.map +1 -0
  27. package/dist/chunk-V5G7X53Y.js +11 -0
  28. package/dist/chunk-V5G7X53Y.js.map +1 -0
  29. package/dist/chunk-W4QZPCNC.js +294 -0
  30. package/dist/chunk-W4QZPCNC.js.map +1 -0
  31. package/dist/chunk-WCQ26LV7.js +102 -0
  32. package/dist/chunk-WCQ26LV7.js.map +1 -0
  33. package/dist/{chunk-WDO2TRFM.js → chunk-WVVMNF74.js} +851 -925
  34. package/dist/chunk-WVVMNF74.js.map +1 -0
  35. package/dist/{chunk-FLJAKWXL.js → chunk-X3E5HXG2.js} +2 -2
  36. package/dist/corrections.d.ts +1 -0
  37. package/dist/corrections.js +84 -0
  38. package/dist/elements.d.ts +1 -399
  39. package/dist/elements.js +6 -5
  40. package/dist/index.d.ts +9 -23
  41. package/dist/index.js +185 -76
  42. package/dist/interactions.d.ts +1 -915
  43. package/dist/interactions.js +19 -15
  44. package/dist/item.css +4118 -1920
  45. package/dist/item.d.ts +1 -134
  46. package/dist/item.js +6 -11
  47. package/dist/loader.d.ts +1 -22
  48. package/dist/loader.js +2 -3
  49. package/dist/processing.d.ts +1 -731
  50. package/dist/processing.js +2 -3
  51. package/dist/qti-components-jsx.d.ts +5220 -2571
  52. package/dist/test.d.ts +1 -539
  53. package/dist/test.js +26 -11
  54. package/dist/transformers.d.ts +1 -18
  55. package/dist/transformers.js +1 -2
  56. package/package.json +19 -15
  57. package/custom-elements.json +0 -43251
  58. package/dist/chunk-3WBG257S.js.map +0 -1
  59. package/dist/chunk-3XV26R5M.js.map +0 -1
  60. package/dist/chunk-AQ5RJFM6.js +0 -3673
  61. package/dist/chunk-AQ5RJFM6.js.map +0 -1
  62. package/dist/chunk-HFCZFWSH.js.map +0 -1
  63. package/dist/chunk-MPC7LIPC.js.map +0 -1
  64. package/dist/chunk-QXBXORM3.js +0 -27
  65. package/dist/chunk-REI3AMCZ.js.map +0 -1
  66. package/dist/chunk-RLTYVS2I.js +0 -530
  67. package/dist/chunk-RLTYVS2I.js.map +0 -1
  68. package/dist/chunk-WDO2TRFM.js.map +0 -1
  69. package/dist/computed-item.context-DfsW_96S.d.ts +0 -22
  70. package/dist/computed.context-DHbxad0N.d.ts +0 -45
  71. package/dist/config.context-BjZ2bZSY.d.ts +0 -42
  72. package/dist/interaction-Bgzlw7Iu.d.ts +0 -110
  73. package/dist/item.context-CkUeDcaO.d.ts +0 -15
  74. package/dist/qti-condition-expression-Dam-RER6.d.ts +0 -26
  75. package/dist/qti-feedback-ChmXhZuf.d.ts +0 -21
  76. package/dist/qti-rule-base-ajOnfGXY.d.ts +0 -16
  77. package/dist/qti-transform-test-DoZaWItm.d.ts +0 -70
  78. package/dist/qti.context-CejJMlfZ.d.ts +0 -50
  79. package/dist/test.context-CByZZjkR.d.ts +0 -15
  80. package/dist/variables-CMYcDbyW.d.ts +0 -70
  81. /package/dist/{chunk-FLJAKWXL.js.map → chunk-X3E5HXG2.js.map} +0 -0
  82. /package/dist/{chunk-QXBXORM3.js.map → corrections.js.map} +0 -0
@@ -1,19 +1,25 @@
1
1
  import {
2
2
  QtiModalFeedback
3
- } from "./chunk-WDO2TRFM.js";
3
+ } from "./chunk-WVVMNF74.js";
4
4
  import {
5
5
  item_default,
6
6
  m
7
- } from "./chunk-AQ5RJFM6.js";
7
+ } from "./chunk-WCQ26LV7.js";
8
+ import {
9
+ watch
10
+ } from "./chunk-64XSIBGO.js";
8
11
  import {
9
12
  qtiTransformItem,
10
13
  qtiTransformTest
11
- } from "./chunk-3WBG257S.js";
14
+ } from "./chunk-IJD53WY6.js";
12
15
  import {
13
16
  A,
17
+ E,
14
18
  INITIAL_SESSION_CONTEXT,
15
19
  INITIAL_TEST_CONTEXT,
20
+ QtiExpression,
16
21
  T,
22
+ Z,
17
23
  c,
18
24
  computedContext,
19
25
  configContext,
@@ -21,22 +27,239 @@ import {
21
27
  i,
22
28
  i2,
23
29
  n,
30
+ n2,
24
31
  qtiContext,
25
32
  r,
26
33
  sessionContext,
27
- t,
28
- testContext,
29
- watch
30
- } from "./chunk-3XV26R5M.js";
31
- import {
32
- __decorateClass,
33
- __privateAdd,
34
- __privateGet,
35
- __privateMethod,
36
- __privateSet
37
- } from "./chunk-QXBXORM3.js";
34
+ testContext
35
+ } from "./chunk-H3J7LFRO.js";
36
+
37
+ // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
38
+ var __decorate = function(decorators, target, key, desc) {
39
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
40
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
41
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
42
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
43
+ };
44
+ var stringToBooleanConverter = {
45
+ fromAttribute(value) {
46
+ return value === "true";
47
+ },
48
+ toAttribute(value) {
49
+ return value ? "true" : "false";
50
+ }
51
+ };
52
+ var QtiAssessmentItemRef = class extends i2 {
53
+ constructor() {
54
+ super(...arguments);
55
+ this.weigths = /* @__PURE__ */ new Map();
56
+ }
57
+ createRenderRoot() {
58
+ return this;
59
+ }
60
+ get assessmentItem() {
61
+ return this.renderRoot?.querySelector("qti-assessment-item");
62
+ }
63
+ async connectedCallback() {
64
+ super.connectedCallback();
65
+ await this.updateComplete;
66
+ this.dispatchEvent(new CustomEvent("qti-assessment-item-ref-connected", {
67
+ bubbles: true,
68
+ composed: true,
69
+ detail: { identifier: this.identifier, href: this.href, category: this.category }
70
+ }));
71
+ }
72
+ render() {
73
+ return this.myTemplate ? this.myTemplate({ xmlDoc: this.xmlDoc }) : this.xmlDoc;
74
+ }
75
+ };
76
+ __decorate([
77
+ n2({ type: String })
78
+ ], QtiAssessmentItemRef.prototype, "category", void 0);
79
+ __decorate([
80
+ n2({ type: String })
81
+ ], QtiAssessmentItemRef.prototype, "identifier", void 0);
82
+ __decorate([
83
+ n2({ type: Boolean, converter: stringToBooleanConverter })
84
+ ], QtiAssessmentItemRef.prototype, "required", void 0);
85
+ __decorate([
86
+ n2({ type: Boolean, converter: stringToBooleanConverter })
87
+ ], QtiAssessmentItemRef.prototype, "fixed", void 0);
88
+ __decorate([
89
+ n2({ type: String })
90
+ ], QtiAssessmentItemRef.prototype, "href", void 0);
91
+ __decorate([
92
+ n2({ type: Object, attribute: false })
93
+ ], QtiAssessmentItemRef.prototype, "xmlDoc", void 0);
94
+
95
+ // ../qti-test/dist/components/qti-assessment-section/qti-assessment-section.js
96
+ var __decorate2 = function(decorators, target, key, desc) {
97
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
98
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
99
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
100
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
101
+ };
102
+ var stringToBooleanConverter2 = {
103
+ fromAttribute(value) {
104
+ return value === "true";
105
+ },
106
+ toAttribute(value) {
107
+ return value ? "true" : "false";
108
+ }
109
+ };
110
+ var QtiAssessmentSection = class extends i2 {
111
+ get title() {
112
+ return this.#title;
113
+ }
114
+ set title(value) {
115
+ this.#title = value;
116
+ this.removeAttribute("title");
117
+ this.setAttribute("data-title", value);
118
+ }
119
+ #title = "";
120
+ async connectedCallback() {
121
+ this.#title = this.getAttribute("title") || "";
122
+ super.connectedCallback();
123
+ await this.updateComplete;
124
+ this.dispatchEvent(new Event("qti-assessment-section-connected", {
125
+ bubbles: true,
126
+ composed: true
127
+ }));
128
+ }
129
+ render() {
130
+ return T`<slot name="qti-rubric-block"></slot><slot></slot>`;
131
+ }
132
+ };
133
+ __decorate2([
134
+ n2({ type: String })
135
+ ], QtiAssessmentSection.prototype, "identifier", void 0);
136
+ __decorate2([
137
+ n2({ type: String })
138
+ ], QtiAssessmentSection.prototype, "required", void 0);
139
+ __decorate2([
140
+ n2({ type: Boolean, converter: stringToBooleanConverter2 })
141
+ ], QtiAssessmentSection.prototype, "fixed", void 0);
142
+ __decorate2([
143
+ n2({ type: Boolean, converter: stringToBooleanConverter2 })
144
+ ], QtiAssessmentSection.prototype, "visible", void 0);
145
+ __decorate2([
146
+ n2({ type: Boolean, converter: stringToBooleanConverter2, attribute: "keep-together" })
147
+ ], QtiAssessmentSection.prototype, "keepTogether", void 0);
148
+ __decorate2([
149
+ c({ context: testContext, subscribe: true })
150
+ ], QtiAssessmentSection.prototype, "_testContext", void 0);
151
+
152
+ // ../qti-test/dist/components/qti-assessment-test/qti-assessment-test.js
153
+ var __decorate3 = function(decorators, target, key, desc) {
154
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
155
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
156
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
157
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
158
+ };
159
+ var QtiAssessmentTest = class extends i2 {
160
+ get title() {
161
+ return this.#title;
162
+ }
163
+ set title(value) {
164
+ this.#title = value;
165
+ this.removeAttribute("title");
166
+ this.setAttribute("data-title", value);
167
+ }
168
+ #title = "";
169
+ async connectedCallback() {
170
+ super.connectedCallback();
171
+ await this.updateComplete;
172
+ this.dispatchEvent(new CustomEvent("qti-assessment-test-connected", {
173
+ detail: this,
174
+ bubbles: true,
175
+ composed: true
176
+ }));
177
+ }
178
+ render() {
179
+ return T` <slot></slot>`;
180
+ }
181
+ };
182
+ __decorate3([
183
+ n2({ type: String })
184
+ ], QtiAssessmentTest.prototype, "identifier", void 0);
185
+ __decorate3([
186
+ n2({ type: String })
187
+ ], QtiAssessmentTest.prototype, "title", null);
188
+ __decorate3([
189
+ c({ context: testContext, subscribe: true })
190
+ ], QtiAssessmentTest.prototype, "_testContext", void 0);
191
+
192
+ // ../qti-test/dist/components/qti-test-feedback/qti-test-feedback.js
193
+ var QtiTestFeedback = class extends QtiModalFeedback {
194
+ static {
195
+ this.styles = i`
196
+ :host {
197
+ color: gray;
198
+ }
199
+ `;
200
+ }
201
+ render() {
202
+ return T``;
203
+ }
204
+ };
205
+
206
+ // ../qti-test/dist/components/qti-test-part/qti-test-part.js
207
+ var __decorate4 = function(decorators, target, key, desc) {
208
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
209
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
210
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
211
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
212
+ };
213
+ var QtiTestPart = class extends i2 {
214
+ constructor() {
215
+ super(...arguments);
216
+ this.identifier = "";
217
+ this.class = "";
218
+ this.navigationMode = "nonlinear";
219
+ this.submissionMode = "individual";
220
+ this.#title = "";
221
+ }
222
+ get title() {
223
+ return this.#title;
224
+ }
225
+ set title(value) {
226
+ this.#title = value;
227
+ this.removeAttribute("title");
228
+ this.setAttribute("data-title", value);
229
+ }
230
+ #title;
231
+ async connectedCallback() {
232
+ super.connectedCallback();
233
+ await this.updateComplete;
234
+ this.dispatchEvent(new Event("qti-test-part-connected", {
235
+ bubbles: true,
236
+ composed: true
237
+ }));
238
+ }
239
+ render() {
240
+ return T` <slot></slot>`;
241
+ }
242
+ };
243
+ __decorate4([
244
+ n2({ type: String })
245
+ ], QtiTestPart.prototype, "identifier", void 0);
246
+ __decorate4([
247
+ n2({ type: String })
248
+ ], QtiTestPart.prototype, "class", void 0);
249
+ __decorate4([
250
+ n2({ type: String, attribute: "navigation-mode" })
251
+ ], QtiTestPart.prototype, "navigationMode", void 0);
252
+ __decorate4([
253
+ n2({ type: String, attribute: "submission-mode" })
254
+ ], QtiTestPart.prototype, "submissionMode", void 0);
38
255
 
39
- // ../qti-test/src/mixins/test-navigation.mixin.ts
256
+ // ../qti-test/dist/mixins/test-navigation.mixin.js
257
+ var __decorate5 = function(decorators, target, key, desc) {
258
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
259
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
260
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
261
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
262
+ };
40
263
  var TestNavigationMixin = (superClass) => {
41
264
  class TestNavigationClass extends superClass {
42
265
  constructor(...args) {
@@ -45,11 +268,9 @@ var TestNavigationMixin = (superClass) => {
45
268
  this.requestTimeout = 3e4;
46
269
  this.postLoadTransformCallback = null;
47
270
  this.postLoadTestTransformCallback = null;
48
- // Navigation state tracking
49
271
  this._activeController = null;
50
272
  this._loadResults = [];
51
273
  this._navigationId = 0;
52
- // Simple loading progress tracking
53
274
  this._loadingState = {
54
275
  expectedItems: 0,
55
276
  connectedItems: 0,
@@ -57,7 +278,6 @@ var TestNavigationMixin = (superClass) => {
57
278
  loadedStimulus: 0,
58
279
  isComplete: false
59
280
  };
60
- // Track loaded/loading stimulus hrefs to prevent duplicates
61
281
  this._loadedStimulusHrefs = /* @__PURE__ */ new Set();
62
282
  this._loadingStimulusHrefs = /* @__PURE__ */ new Set();
63
283
  this._bindEventHandlers();
@@ -73,13 +293,11 @@ var TestNavigationMixin = (superClass) => {
73
293
  navigateTo(type, id) {
74
294
  const targetId = id || this._getDefaultNavigationId(type);
75
295
  if (targetId) {
76
- this.dispatchEvent(
77
- new CustomEvent("qti-request-navigation", {
78
- detail: { type, id: targetId },
79
- bubbles: true,
80
- composed: true
81
- })
82
- );
296
+ this.dispatchEvent(new CustomEvent("qti-request-navigation", {
297
+ detail: { type, id: targetId },
298
+ bubbles: true,
299
+ composed: true
300
+ }));
83
301
  }
84
302
  }
85
303
  // ===========================================
@@ -91,15 +309,15 @@ var TestNavigationMixin = (superClass) => {
91
309
  this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
92
310
  this.addEventListener("qti-assessment-stimulus-ref-connected", this._handleStimulusRefConnected.bind(this));
93
311
  }
94
- _handleTestConnected(e3) {
95
- this._testElement = e3.detail;
312
+ _handleTestConnected(e2) {
313
+ this._testElement = e2.detail;
96
314
  this._initializeNavigation();
97
315
  }
98
316
  /**
99
317
  * Handle item connection events - track connected items and discover stimulus references
100
318
  */
101
- _handleItemConnected(e3) {
102
- const itemRef = e3.detail;
319
+ _handleItemConnected(e2) {
320
+ const itemRef = e2.detail;
103
321
  this._loadingState.connectedItems++;
104
322
  const stimulusRefs = itemRef.querySelectorAll("qti-assessment-stimulus-ref");
105
323
  this._loadingState.expectedStimulus += stimulusRefs.length;
@@ -108,9 +326,9 @@ var TestNavigationMixin = (superClass) => {
108
326
  /**
109
327
  * Handle stimulus reference connection events with duplicate prevention
110
328
  */
111
- async _handleStimulusRefConnected(e3) {
112
- e3.preventDefault();
113
- const { element, item } = e3;
329
+ async _handleStimulusRefConnected(e2) {
330
+ e2.preventDefault();
331
+ const { element, item } = e2;
114
332
  console.info("Stimulus ref connected:", {
115
333
  identifier: element.identifier,
116
334
  href: element.href,
@@ -156,7 +374,8 @@ var TestNavigationMixin = (superClass) => {
156
374
  return this.sessionContext?.navItemRefId ?? this._testElement?.querySelector("qti-assessment-item-ref")?.identifier;
157
375
  }
158
376
  _initializeNavigation() {
159
- if (!this.navigate) return;
377
+ if (!this.navigate)
378
+ return;
160
379
  const id = this._getDefaultNavigationId(this.navigate);
161
380
  if (id) {
162
381
  this.navigateTo(this.navigate, id);
@@ -166,7 +385,8 @@ var TestNavigationMixin = (superClass) => {
166
385
  * Main navigation request handler with proper lifecycle management
167
386
  */
168
387
  async _handleNavigationRequest({ detail }) {
169
- if (!detail?.id) return;
388
+ if (!detail?.id)
389
+ return;
170
390
  this._cancelPreviousNavigation();
171
391
  const navigationId = ++this._navigationId;
172
392
  const controller = new AbortController();
@@ -205,7 +425,8 @@ var TestNavigationMixin = (superClass) => {
205
425
  this._loadingState.expectedItems = 1;
206
426
  await this._loadItems([itemId], navigationId, controller);
207
427
  await this._waitForLoadingComplete(navigationId, controller);
208
- if (this._isStaleNavigation(navigationId, controller)) return;
428
+ if (this._isStaleNavigation(navigationId, controller))
429
+ return;
209
430
  this._dispatchTestLoaded(this._loadResults);
210
431
  }
211
432
  /**
@@ -225,7 +446,8 @@ var TestNavigationMixin = (superClass) => {
225
446
  this._loadingState.expectedItems = itemIds.length;
226
447
  await this._loadItems(itemIds, navigationId, controller);
227
448
  await this._waitForLoadingComplete(navigationId, controller);
228
- if (this._isStaleNavigation(navigationId, controller)) return;
449
+ if (this._isStaleNavigation(navigationId, controller))
450
+ return;
229
451
  this._dispatchTestLoaded(this._loadResults);
230
452
  }
231
453
  // ===========================================
@@ -260,7 +482,8 @@ var TestNavigationMixin = (superClass) => {
260
482
  */
261
483
  async _waitForLoadingComplete(navigationId, controller) {
262
484
  while (!this._loadingState.isComplete) {
263
- if (this._isStaleNavigation(navigationId, controller)) return;
485
+ if (this._isStaleNavigation(navigationId, controller))
486
+ return;
264
487
  await new Promise((resolve) => setTimeout(resolve, 10));
265
488
  }
266
489
  }
@@ -339,24 +562,30 @@ var TestNavigationMixin = (superClass) => {
339
562
  * Load items with simple tracking
340
563
  */
341
564
  async _loadItems(itemIds, navigationId, controller) {
342
- if (!this._testElement || itemIds.length === 0) return;
565
+ if (!this._testElement || itemIds.length === 0)
566
+ return;
343
567
  const itemRefs = itemIds.map((id) => this._findItemRef(id));
344
568
  this._clearLoadedItems();
345
569
  this._clearStimulusRef();
346
570
  const results = await Promise.all(itemRefs.map((ref) => this._loadSingleItem(ref, navigationId, controller)));
347
571
  const validResults = results.filter(Boolean);
348
- if (this._isStaleNavigation(navigationId, controller)) return;
572
+ if (this._isStaleNavigation(navigationId, controller))
573
+ return;
349
574
  validResults.forEach(({ itemRef, doc }) => {
350
- if (itemRef && doc) itemRef.xmlDoc = doc;
575
+ if (itemRef && doc)
576
+ itemRef.xmlDoc = doc;
351
577
  });
352
578
  validResults.forEach(({ itemRef }) => {
353
579
  const itemId = itemRef?.identifier;
354
- if (!itemRef || !itemId) return;
355
- const savedState = this.testContext.items.find((i5) => i5.identifier === itemId)?.state;
356
- if (savedState === void 0) return;
580
+ if (!itemRef || !itemId)
581
+ return;
582
+ const savedState = this.testContext.items.find((i4) => i4.identifier === itemId)?.state;
583
+ if (savedState === void 0)
584
+ return;
357
585
  itemRef.updateComplete.then(() => {
358
586
  const assessmentItem = itemRef.assessmentItem;
359
- if (!assessmentItem) return;
587
+ if (!assessmentItem)
588
+ return;
360
589
  assessmentItem.state = savedState;
361
590
  });
362
591
  });
@@ -372,7 +601,7 @@ var TestNavigationMixin = (superClass) => {
372
601
  if (this._isStaleNavigation(navigationId, controller)) {
373
602
  return null;
374
603
  }
375
- return { itemRef, doc: transformer.htmlDoc() };
604
+ return { itemRef, doc: transformer.htmlDoc(this._customElementRegistry()) };
376
605
  } catch (error) {
377
606
  if (error.name === "AbortError") {
378
607
  console.info(`Item load for ${itemRef.identifier} was aborted`);
@@ -384,15 +613,19 @@ var TestNavigationMixin = (superClass) => {
384
613
  }
385
614
  async _loadStimulus(href) {
386
615
  const transformer = await qtiTransformItem().load(href, this._activeController?.signal);
387
- return transformer.htmlDoc();
616
+ return transformer.htmlDoc(this._customElementRegistry());
617
+ }
618
+ _customElementRegistry() {
619
+ const container = this.querySelector("test-container");
620
+ if (!container)
621
+ return void 0;
622
+ return container.customElementRegistry ?? void 0;
388
623
  }
389
624
  // ===========================================
390
625
  // UTILITIES
391
626
  // ===========================================
392
627
  _findItemRef(itemId) {
393
- const itemRef = this._testElement?.querySelector(
394
- `qti-assessment-item-ref[identifier="${itemId}"]`
395
- );
628
+ const itemRef = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${itemId}"]`);
396
629
  if (!itemRef) {
397
630
  throw new Error(`Item with identifier "${itemId}" not found`);
398
631
  }
@@ -412,11 +645,7 @@ var TestNavigationMixin = (superClass) => {
412
645
  };
413
646
  }
414
647
  _getSectionItemIds(sectionId) {
415
- return Array.from(
416
- this._testElement.querySelectorAll(
417
- `qti-assessment-section[identifier="${sectionId}"] > qti-assessment-item-ref`
418
- )
419
- ).map((ref) => ref.identifier).filter(Boolean);
648
+ return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${sectionId}"] > qti-assessment-item-ref`)).map((ref) => ref.identifier).filter(Boolean);
420
649
  }
421
650
  _clearLoadedItems() {
422
651
  const itemRefs = this._testElement?.querySelectorAll("qti-assessment-item-ref");
@@ -442,78 +671,70 @@ var TestNavigationMixin = (superClass) => {
442
671
  // EVENT DISPATCHING
443
672
  // ===========================================
444
673
  _dispatchLoadingStarted(type, id) {
445
- this.dispatchEvent(
446
- new CustomEvent("qti-navigation-loading-started", {
447
- detail: { type, id },
448
- bubbles: true,
449
- composed: true
450
- })
451
- );
674
+ this.dispatchEvent(new CustomEvent("qti-navigation-loading-started", {
675
+ detail: { type, id },
676
+ bubbles: true,
677
+ composed: true
678
+ }));
452
679
  }
453
680
  _dispatchLoadingEnded(type, id) {
454
- this.dispatchEvent(
455
- new CustomEvent("qti-navigation-loading-ended", {
456
- detail: { type, id },
457
- bubbles: true,
458
- composed: true
459
- })
460
- );
681
+ this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended", {
682
+ detail: { type, id },
683
+ bubbles: true,
684
+ composed: true
685
+ }));
461
686
  }
462
687
  _dispatchError(error) {
463
- this.dispatchEvent(
464
- new CustomEvent("qti-navigation-error", {
465
- detail: error,
466
- bubbles: true,
467
- composed: true
468
- })
469
- );
688
+ this.dispatchEvent(new CustomEvent("qti-navigation-error", {
689
+ detail: error,
690
+ bubbles: true,
691
+ composed: true
692
+ }));
470
693
  }
471
694
  _dispatchTestLoaded(results) {
472
695
  requestAnimationFrame(() => {
473
- this.dispatchEvent(
474
- new CustomEvent("qti-test-loaded", {
475
- detail: results.map(({ itemRef }) => ({
476
- identifier: itemRef?.identifier,
477
- element: itemRef
478
- })),
479
- bubbles: true,
480
- composed: true
481
- })
482
- );
696
+ this.dispatchEvent(new CustomEvent("qti-test-loaded", {
697
+ detail: results.map(({ itemRef }) => ({
698
+ identifier: itemRef?.identifier,
699
+ element: itemRef
700
+ })),
701
+ bubbles: true,
702
+ composed: true
703
+ }));
483
704
  });
484
705
  }
485
706
  }
486
- __decorateClass([
487
- n({ type: String })
488
- ], TestNavigationClass.prototype, "navigate", 2);
489
- __decorateClass([
490
- n({ type: Number })
491
- ], TestNavigationClass.prototype, "requestTimeout", 2);
492
- __decorateClass([
493
- n({ attribute: false })
494
- ], TestNavigationClass.prototype, "postLoadTransformCallback", 2);
495
- __decorateClass([
496
- n({ attribute: false })
497
- ], TestNavigationClass.prototype, "postLoadTestTransformCallback", 2);
707
+ __decorate5([
708
+ n2({ type: String })
709
+ ], TestNavigationClass.prototype, "navigate", void 0);
710
+ __decorate5([
711
+ n2({ type: Number })
712
+ ], TestNavigationClass.prototype, "requestTimeout", void 0);
713
+ __decorate5([
714
+ n2({ attribute: false })
715
+ ], TestNavigationClass.prototype, "postLoadTransformCallback", void 0);
716
+ __decorate5([
717
+ n2({ attribute: false })
718
+ ], TestNavigationClass.prototype, "postLoadTestTransformCallback", void 0);
498
719
  return TestNavigationClass;
499
720
  };
500
721
 
501
- // ../qti-test/src/mixins/test-view.mixin.ts
722
+ // ../qti-test/dist/mixins/test-view.mixin.js
502
723
  var TestViewMixin = (superClass) => {
503
724
  class TestViewClass extends superClass {
504
725
  constructor(...args) {
505
726
  super(...args);
506
727
  this.sessionContext = { ...this.sessionContext, view: "candidate" };
507
- this.addEventListener("on-test-switch-view", (e3) => {
508
- this.sessionContext = { ...this.sessionContext, view: e3.detail };
728
+ this.addEventListener("on-test-switch-view", (e2) => {
729
+ this.sessionContext = { ...this.sessionContext, view: e2.detail };
509
730
  this._updateElementView();
510
731
  });
511
732
  this.addEventListener("qti-assessment-test-connected", () => {
512
733
  this._updateElementView();
513
734
  });
514
- this.addEventListener("qti-assessment-item-connected", (e3) => {
735
+ this.addEventListener("qti-assessment-item-connected", (e2) => {
515
736
  this._updateElementView();
516
- this._setCorrectResponseVisibility(e3.detail);
737
+ this._setCorrectResponseVisibility(e2.detail);
517
738
  });
518
739
  }
519
740
  willUpdate(changedProperties) {
@@ -529,44 +750,41 @@ var TestViewMixin = (superClass) => {
529
750
  viewElements.forEach((element) => {
530
751
  element.classList.toggle("show", element.getAttribute("view") === this.sessionContext.view);
531
752
  });
532
- const assessmentItemRef = this._testElement.querySelector(
533
- `qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`
534
- );
753
+ const assessmentItemRef = this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`);
535
754
  const assessmentItem = assessmentItemRef?.assessmentItem;
536
- if (assessmentItem) {
537
- assessmentItem.showCorrectResponse(this.sessionContext.view === "scorer");
538
- }
755
+ if (assessmentItem)
756
+ this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);
539
757
  }
540
758
  }
541
759
  // Event handler for connected QTI assessment items
542
760
  _setCorrectResponseVisibility(assessmentItem) {
543
- assessmentItem.showCorrectResponse(this.sessionContext.view === "scorer");
761
+ this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);
762
+ }
763
+ /** Extension point for packages that add view-dependent assessment presentation. */
764
+ updateAssessmentItemView(_assessmentItem, _view) {
544
765
  }
545
766
  }
546
767
  return TestViewClass;
547
768
  };
548
769
 
549
- // ../qti-test/src/mixins/test-base.ts
770
+ // ../qti-test/dist/mixins/test-base.js
771
+ var __decorate6 = function(decorators, target, key, desc) {
772
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
773
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
774
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
775
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
776
+ };
550
777
  var TestBaseMixin = (superClass) => {
551
778
  class TestBaseClass extends superClass {
552
779
  constructor(...args) {
553
780
  super(...args);
554
781
  this.testContext = INITIAL_TEST_CONTEXT;
555
782
  this.sessionContext = INITIAL_SESSION_CONTEXT;
556
- /**
557
- * Updates the variables of an assessment item in the test context.
558
- * - Matches the assessment item with the corresponding test context item.
559
- * - If the item is not found, logs a warning.
560
- * - Updates variables in the test context if exactly one variable exists.
561
- * - Otherwise, syncs the assessment item's variables with the test context.
562
- *
563
- * @param assessmentItem - The assessment item to update.
564
- */
565
783
  this._updateItemInTestContext = (assessmentItem) => {
566
784
  const context = assessmentItem._context;
567
785
  const identifier = context.identifier;
568
786
  const fullVariables = context.variables;
569
- const itemContext = this.testContext.items.find((i5) => i5?.identifier === identifier);
787
+ const itemContext = this.testContext.items.find((i4) => i4?.identifier === identifier);
570
788
  if (!itemContext) {
571
789
  console.warn(`Item IDs between assessment.xml and item.xml should match: ${identifier} is not found!`);
572
790
  return;
@@ -576,7 +794,7 @@ var TestBaseMixin = (superClass) => {
576
794
  } else {
577
795
  const newVariables = [...assessmentItem.variables];
578
796
  for (const variable of itemContext.variables) {
579
- const currentVariable = newVariables.find((v2) => v2.identifier === variable.identifier);
797
+ const currentVariable = newVariables.find((v) => v.identifier === variable.identifier);
580
798
  if (currentVariable) {
581
799
  currentVariable.value = variable.value;
582
800
  } else {
@@ -592,23 +810,22 @@ var TestBaseMixin = (superClass) => {
592
810
  const itemContext = this.testContext.items.find((item) => item.identifier === itemRefID);
593
811
  if (itemContext) {
594
812
  itemContext.variables = itemContext.variables.map((variable) => {
595
- const updatedVariable = variables.find((v2) => v2.identifier === variable.identifier);
813
+ const updatedVariable = variables.find((v) => v.identifier === variable.identifier);
596
814
  return updatedVariable ? { ...variable, ...updatedVariable } : variable;
597
815
  });
598
816
  }
599
- const itemRef = this._testElement.querySelector(
600
- `qti-assessment-item-ref[identifier="${itemRefID}"]`
601
- );
817
+ const itemRef = this._testElement.querySelector(`qti-assessment-item-ref[identifier="${itemRefID}"]`);
602
818
  if (itemRef && itemRef.assessmentItem) {
603
819
  itemRef.assessmentItem.variables = variables;
604
820
  }
605
821
  }
606
822
  _initializeEventListeners() {
607
- this.addEventListener("qti-assessment-test-connected", (e3) => {
823
+ this.addEventListener("qti-assessment-test-connected", (e2) => {
608
824
  this.testContext = INITIAL_TEST_CONTEXT;
609
825
  this.sessionContext = INITIAL_SESSION_CONTEXT;
610
- if (this.testContext && this.testContext.items.length > 0) return;
611
- this._testElement = e3.detail;
826
+ if (this.testContext && this.testContext.items.length > 0)
827
+ return;
828
+ this._testElement = e2.detail;
612
829
  const items = Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map((itemRef) => {
613
830
  return {
614
831
  href: itemRef.href,
@@ -625,20 +842,16 @@ var TestBaseMixin = (superClass) => {
625
842
  });
626
843
  this.testContext = { ...this.testContext, items };
627
844
  });
628
- this.addEventListener("qti-assessment-item-connected", (e3) => {
629
- const assessmentItem = e3.detail;
845
+ this.addEventListener("qti-assessment-item-connected", (e2) => {
846
+ const assessmentItem = e2.detail;
630
847
  const assessmentRefId = assessmentItem.closest("qti-assessment-item-ref")?.identifier;
631
848
  if (assessmentRefId) {
632
849
  assessmentItem.assessmentItemRefId = assessmentRefId;
633
850
  }
634
- this._updateItemInTestContext(e3.detail);
851
+ this._updateItemInTestContext(e2.detail);
635
852
  });
636
- this.addEventListener("qti-item-context-updated", (e3) => {
637
- this._updateItemVariablesInTestContext(
638
- e3.detail.itemContext.identifier,
639
- e3.detail.itemContext.variables,
640
- e3.detail.itemContext.state
641
- );
853
+ this.addEventListener("qti-item-context-updated", (e2) => {
854
+ this._updateItemVariablesInTestContext(e2.detail.itemContext.identifier, e2.detail.itemContext.variables, e2.detail.itemContext.state);
642
855
  });
643
856
  }
644
857
  _updateItemVariablesInTestContext(identifier, variables, state) {
@@ -653,55 +866,51 @@ var TestBaseMixin = (superClass) => {
653
866
  ...itemContext,
654
867
  // Keep other properties of the item context
655
868
  variables: variables.map((variable) => {
656
- const matchingVariable = itemContext.variables.find((v2) => v2.identifier === variable.identifier);
869
+ const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
657
870
  return matchingVariable ? { ...matchingVariable, ...variable } : variable;
658
871
  }),
659
872
  ...state !== void 0 ? { state: state ? { ...state } : void 0 } : {}
660
873
  };
661
874
  })
662
875
  };
663
- this.dispatchEvent(
664
- new CustomEvent("qti-test-context-updated", { detail: this.testContext, bubbles: false, composed: false })
665
- );
876
+ this.dispatchEvent(new CustomEvent("qti-test-context-updated", { detail: this.testContext, bubbles: false, composed: false }));
666
877
  }
667
878
  }
668
- __decorateClass([
669
- n({ attribute: false, type: Object }),
879
+ __decorate6([
880
+ n2({ attribute: false, type: Object }),
670
881
  e({ context: testContext })
671
- ], TestBaseClass.prototype, "testContext", 2);
672
- __decorateClass([
673
- n({ attribute: false, type: Object }),
882
+ ], TestBaseClass.prototype, "testContext", void 0);
883
+ __decorate6([
884
+ n2({ attribute: false, type: Object }),
674
885
  e({ context: sessionContext })
675
- ], TestBaseClass.prototype, "sessionContext", 2);
886
+ ], TestBaseClass.prototype, "sessionContext", void 0);
676
887
  return TestBaseClass;
677
888
  };
678
889
  var TestBase = class extends TestBaseMixin(i2) {
679
890
  };
680
891
 
681
- // ../qti-test/src/mixins/test-processing.mixin.ts
892
+ // ../qti-test/dist/mixins/test-processing.mixin.js
682
893
  var TestProcessingMixin = (superClass) => {
683
894
  class TestProcessingElement extends superClass {
684
895
  constructor(...args) {
685
896
  super(...args);
686
- this.addEventListener("qti-register-variable", (e3) => {
897
+ this.addEventListener("qti-register-variable", (e2) => {
687
898
  this.testContext = {
688
899
  ...this.testContext,
689
- testOutcomeVariables: [...this.testContext.testOutcomeVariables || [], e3.detail.variable]
900
+ testOutcomeVariables: [...this.testContext.testOutcomeVariables || [], e2.detail.variable]
690
901
  };
691
- e3.stopPropagation();
902
+ e2.stopPropagation();
903
+ });
904
+ this.addEventListener("qti-set-outcome-value", (e2) => {
905
+ const { outcomeIdentifier, value } = e2.detail;
906
+ this.updateOutcomeVariable(outcomeIdentifier, value);
907
+ e2.stopPropagation();
692
908
  });
693
- this.addEventListener(
694
- "qti-set-outcome-value",
695
- (e3) => {
696
- const { outcomeIdentifier, value } = e3.detail;
697
- this.updateOutcomeVariable(outcomeIdentifier, value);
698
- e3.stopPropagation();
699
- }
700
- );
701
909
  }
702
910
  outcomeProcessing() {
703
911
  const outcomeProcessor = this.querySelector("qti-outcome-processing");
704
- if (!outcomeProcessor) return false;
912
+ if (!outcomeProcessor)
913
+ return false;
705
914
  outcomeProcessor?.process();
706
915
  return true;
707
916
  }
@@ -714,13 +923,13 @@ var TestProcessingMixin = (superClass) => {
714
923
  }
715
924
  this.testContext = {
716
925
  ...this.testContext,
717
- testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v2) => {
718
- if (v2.identifier !== identifier) {
719
- return v2;
926
+ testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => {
927
+ if (v.identifier !== identifier) {
928
+ return v;
720
929
  }
721
930
  return {
722
- ...v2,
723
- value: outcomeVariable.cardinality === "single" ? value : [...v2.value, value]
931
+ ...v,
932
+ value: outcomeVariable.cardinality === "single" ? value : [...v.value, value]
724
933
  };
725
934
  })
726
935
  };
@@ -729,14 +938,19 @@ var TestProcessingMixin = (superClass) => {
729
938
  return this.getVariable(identifier);
730
939
  }
731
940
  getVariable(identifier) {
732
- return this.testContext.testOutcomeVariables?.find((v2) => v2.identifier === identifier) || null;
941
+ return this.testContext.testOutcomeVariables?.find((v) => v.identifier === identifier) || null;
733
942
  }
734
- /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */
735
943
  }
736
944
  return TestProcessingElement;
737
945
  };
738
946
 
739
- // ../qti-test/src/components/qti-test/qti-test.ts
947
+ // ../qti-test/dist/components/qti-test/qti-test.js
948
+ var __decorate7 = function(decorators, target, key, desc) {
949
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
950
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
951
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
952
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
953
+ };
740
954
  var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixin(TestBaseMixin(i2)))) {
741
955
  constructor() {
742
956
  super(...arguments);
@@ -755,248 +969,672 @@ var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixi
755
969
  return T`<slot></slot>`;
756
970
  }
757
971
  };
758
- __decorateClass([
972
+ __decorate7([
759
973
  r(),
760
974
  e({ context: configContext })
761
- ], QtiTest.prototype, "configContext", 2);
762
- QtiTest = __decorateClass([
763
- t("qti-test")
764
- ], QtiTest);
975
+ ], QtiTest.prototype, "configContext", void 0);
765
976
 
766
- // ../qti-test/src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts
767
- var stringToBooleanConverter = {
768
- fromAttribute(value) {
769
- return value === "true";
770
- },
771
- toAttribute(value) {
772
- return value ? "true" : "false";
977
+ // ../qti-test/dist/components/styles.js
978
+ var form = i`
979
+ display: inline-flex;
980
+ align-items: center;
981
+ cursor: pointer;
982
+ padding: 0.5rem 1rem;
983
+ border-radius: 0.25rem;
984
+ user-select: none;
985
+ `;
986
+ var btn = i`
987
+ background-color: lightgray;
988
+ ${form};
989
+ `;
990
+ var dis = i`
991
+ cursor: not-allowed;
992
+ opacity: 0.8;
993
+ `;
994
+ var ind = i`
995
+ ${form};
996
+ border: 1px solid gray;
997
+ `;
998
+
999
+ // ../qti-test/dist/components/test-check-item/test-check-item.js
1000
+ var TestCheckItem = class extends i2 {
1001
+ static {
1002
+ this.styles = i`
1003
+ :host {
1004
+ ${btn};
1005
+ }
1006
+ :host([disabled]) {
1007
+ ${dis};
1008
+ }
1009
+ `;
773
1010
  }
774
- };
775
- var QtiAssessmentItemRef = class extends i2 {
776
1011
  constructor() {
777
- super(...arguments);
778
- // @consume({ context: computedContext, subscribe: true })
779
- // private computedContext: ComputedContext;
780
- this.weigths = /* @__PURE__ */ new Map();
781
- }
782
- // the XMLDocument
783
- createRenderRoot() {
784
- return this;
785
- }
786
- get assessmentItem() {
787
- return this.renderRoot?.querySelector("qti-assessment-item");
788
- }
789
- async connectedCallback() {
790
- super.connectedCallback();
791
- await this.updateComplete;
792
- this.dispatchEvent(
793
- new CustomEvent("qti-assessment-item-ref-connected", {
794
- bubbles: true,
795
- composed: true,
796
- detail: { identifier: this.identifier, href: this.href, category: this.category }
797
- })
798
- );
1012
+ super();
1013
+ this.addEventListener("click", () => {
1014
+ this.dispatchEvent(new CustomEvent("test-end-attempt", { bubbles: true }));
1015
+ const qtiTest = this.closest("qti-test");
1016
+ const testContainer = qtiTest.querySelector("test-container");
1017
+ const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
1018
+ viewElements.forEach((element) => {
1019
+ element.classList.toggle("show", true);
1020
+ });
1021
+ });
799
1022
  }
800
1023
  render() {
801
- return this.myTemplate ? this.myTemplate({ xmlDoc: this.xmlDoc }) : this.xmlDoc;
1024
+ return T` <slot></slot> `;
802
1025
  }
803
1026
  };
804
- __decorateClass([
805
- n({ type: String })
806
- ], QtiAssessmentItemRef.prototype, "category", 2);
807
- __decorateClass([
808
- n({ type: String })
809
- ], QtiAssessmentItemRef.prototype, "identifier", 2);
810
- __decorateClass([
811
- n({ type: Boolean, converter: stringToBooleanConverter })
812
- ], QtiAssessmentItemRef.prototype, "required", 2);
813
- __decorateClass([
814
- n({ type: Boolean, converter: stringToBooleanConverter })
815
- ], QtiAssessmentItemRef.prototype, "fixed", 2);
816
- __decorateClass([
817
- n({ type: String })
818
- ], QtiAssessmentItemRef.prototype, "href", 2);
819
- __decorateClass([
820
- n({ type: Object, attribute: false })
821
- ], QtiAssessmentItemRef.prototype, "xmlDoc", 2);
822
- if (!customElements.get("qti-assessment-item-ref")) {
823
- customElements.define("qti-assessment-item-ref", QtiAssessmentItemRef);
824
- }
825
1027
 
826
- // ../qti-test/src/components/qti-assessment-section/qti-assessment-section.ts
827
- var stringToBooleanConverter2 = {
828
- fromAttribute(value) {
829
- return value === "true";
830
- },
831
- toAttribute(value) {
832
- return value ? "true" : "false";
833
- }
1028
+ // ../qti-test/dist/components/test-container/test-container.js
1029
+ var __decorate8 = function(decorators, target, key, desc) {
1030
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1031
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
1032
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
1033
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
834
1034
  };
835
- var QtiAssessmentSection = class extends i2 {
836
- get title() {
837
- return this.#title;
1035
+ var TestContainer = class extends i2 {
1036
+ constructor() {
1037
+ super(...arguments);
1038
+ this.customElementRegistry = null;
1039
+ this.testURL = null;
1040
+ this.testDoc = null;
1041
+ this.testXML = null;
1042
+ this.qtiContext = {
1043
+ QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
1044
+ };
1045
+ this.#templateContent = null;
1046
+ this.#resolvedCustomElementRegistry = null;
838
1047
  }
839
- set title(value) {
840
- this.#title = value;
841
- this.removeAttribute("title");
842
- this.setAttribute("data-title", value);
1048
+ /** Template content if provided */
1049
+ #templateContent;
1050
+ #resolvedCustomElementRegistry;
1051
+ createRenderRoot() {
1052
+ const registry = this.customElementRegistry;
1053
+ this.#resolvedCustomElementRegistry = registry;
1054
+ return this.shadowRoot ?? this.attachShadow({
1055
+ ...this.constructor.shadowRootOptions,
1056
+ ...registry ? { customElementRegistry: registry } : {}
1057
+ });
1058
+ }
1059
+ /** Callback function to transform the test after loading */
1060
+ // @property({ type: Function }) postLoadTestTransformCallback: PostLoadTestTransformCallback | null = null;
1061
+ async handleTestURLChange() {
1062
+ if (!this.testURL)
1063
+ return;
1064
+ try {
1065
+ const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
1066
+ let api = (await qtiTransformTest().load(this.testURL)).shuffleOrdering(explicitSeed);
1067
+ const qtiTest = this.closest("qti-test");
1068
+ if (qtiTest?.postLoadTestTransformCallback) {
1069
+ const tempDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
1070
+ const testElement = tempDoc.querySelector("qti-assessment-test");
1071
+ if (testElement) {
1072
+ api = await qtiTest.postLoadTestTransformCallback(api, testElement);
1073
+ }
1074
+ }
1075
+ this.testDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
1076
+ } catch (error) {
1077
+ console.error("Error loading or parsing XML:", error);
1078
+ }
1079
+ }
1080
+ handleTestXMLChange() {
1081
+ if (!this.testXML)
1082
+ return;
1083
+ try {
1084
+ const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
1085
+ this.testDoc = qtiTransformTest().parse(this.testXML).shuffleOrdering(explicitSeed).htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
1086
+ } catch (error) {
1087
+ console.error("Error parsing XML:", error);
1088
+ }
843
1089
  }
844
- #title = "";
845
1090
  async connectedCallback() {
846
- this.#title = this.getAttribute("title") || "";
847
1091
  super.connectedCallback();
848
- await this.updateComplete;
849
- this.dispatchEvent(
850
- new Event("qti-assessment-section-connected", {
851
- bubbles: true,
852
- composed: true
853
- })
854
- );
1092
+ this.#initializeTemplateContent();
1093
+ this.#applyStyles();
1094
+ if (this.testURL) {
1095
+ this.handleTestURLChange();
1096
+ }
1097
+ if (this.testXML) {
1098
+ this.handleTestXMLChange();
1099
+ }
1100
+ }
1101
+ #initializeTemplateContent() {
1102
+ const template = this.querySelector("template");
1103
+ this.#templateContent = template ? template.content : T``;
1104
+ }
1105
+ #applyStyles() {
1106
+ const sheet = new CSSStyleSheet();
1107
+ sheet.replaceSync(item_default);
1108
+ this.shadowRoot.adoptedStyleSheets = [sheet];
855
1109
  }
856
1110
  render() {
857
- return T`<slot name="qti-rubric-block"></slot><slot></slot>`;
1111
+ return T`
1112
+ ${this.#templateContent}
1113
+ <slot></slot>
1114
+ ${m(this.testDoc, T`<span>Loading...</span>`)}
1115
+ `;
858
1116
  }
859
1117
  };
860
- __decorateClass([
861
- n({ type: String })
862
- ], QtiAssessmentSection.prototype, "identifier", 2);
863
- __decorateClass([
864
- n({ type: String })
865
- ], QtiAssessmentSection.prototype, "required", 2);
866
- __decorateClass([
867
- n({ type: Boolean, converter: stringToBooleanConverter2 })
868
- ], QtiAssessmentSection.prototype, "fixed", 2);
869
- __decorateClass([
870
- n({ type: Boolean, converter: stringToBooleanConverter2 })
871
- ], QtiAssessmentSection.prototype, "visible", 2);
872
- __decorateClass([
873
- n({ type: Boolean, converter: stringToBooleanConverter2, attribute: "keep-together" })
874
- ], QtiAssessmentSection.prototype, "keepTogether", 2);
875
- __decorateClass([
876
- c({ context: testContext, subscribe: true })
877
- ], QtiAssessmentSection.prototype, "_testContext", 2);
878
- if (!customElements.get("qti-assessment-section")) {
879
- customElements.define("qti-assessment-section", QtiAssessmentSection);
880
- }
1118
+ __decorate8([
1119
+ n2({ attribute: false })
1120
+ ], TestContainer.prototype, "customElementRegistry", void 0);
1121
+ __decorate8([
1122
+ n2({ type: String, attribute: "test-url" })
1123
+ ], TestContainer.prototype, "testURL", void 0);
1124
+ __decorate8([
1125
+ r()
1126
+ ], TestContainer.prototype, "testDoc", void 0);
1127
+ __decorate8([
1128
+ r()
1129
+ ], TestContainer.prototype, "testXML", void 0);
1130
+ __decorate8([
1131
+ r(),
1132
+ c({ context: qtiContext, subscribe: true })
1133
+ ], TestContainer.prototype, "qtiContext", void 0);
1134
+ __decorate8([
1135
+ watch("testURL", { waitUntilFirstUpdate: true })
1136
+ ], TestContainer.prototype, "handleTestURLChange", null);
1137
+ __decorate8([
1138
+ watch("testXML", { waitUntilFirstUpdate: true })
1139
+ ], TestContainer.prototype, "handleTestXMLChange", null);
881
1140
 
882
- // ../qti-test/src/components/qti-assessment-test/qti-assessment-test.ts
883
- var _title;
884
- var QtiAssessmentTest = class extends i2 {
1141
+ // ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
1142
+ var TestEndAttempt = class extends i2 {
1143
+ static {
1144
+ this.styles = i`
1145
+ :host {
1146
+ ${btn};
1147
+ }
1148
+ :host([disabled]) {
1149
+ ${dis};
1150
+ }
1151
+ `;
1152
+ }
885
1153
  constructor() {
886
- super(...arguments);
887
- __privateAdd(this, _title, "");
1154
+ super();
1155
+ this.addEventListener("click", () => this.dispatchEvent(new CustomEvent("test-end-attempt", { bubbles: true })));
888
1156
  }
889
- get title() {
890
- return __privateGet(this, _title);
1157
+ render() {
1158
+ return T` <slot></slot> `;
891
1159
  }
892
- set title(value) {
893
- __privateSet(this, _title, value);
894
- this.removeAttribute("title");
895
- this.setAttribute("data-title", value);
1160
+ };
1161
+
1162
+ // ../qti-test/dist/components/test-item-link/test-item-link.js
1163
+ var __decorate9 = function(decorators, target, key, desc) {
1164
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1165
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
1166
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
1167
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
1168
+ };
1169
+ var TestItemLink = class extends i2 {
1170
+ static {
1171
+ this.styles = i`
1172
+ :host {
1173
+ ${btn};
1174
+ }
1175
+ :host([disabled]) {
1176
+ ${dis};
1177
+ }
1178
+ `;
896
1179
  }
897
- async connectedCallback() {
898
- super.connectedCallback();
899
- await this.updateComplete;
900
- this.dispatchEvent(
901
- new CustomEvent("qti-assessment-test-connected", {
902
- detail: this,
903
- bubbles: true,
904
- composed: true
905
- })
906
- );
1180
+ constructor() {
1181
+ super();
1182
+ this.itemId = null;
1183
+ this.addEventListener("click", () => this._requestItem(this.itemId));
1184
+ }
1185
+ _requestItem(identifier) {
1186
+ this.dispatchEvent(new CustomEvent("qti-request-navigation", {
1187
+ composed: true,
1188
+ bubbles: true,
1189
+ detail: {
1190
+ type: "item",
1191
+ id: identifier
1192
+ }
1193
+ }));
907
1194
  }
908
1195
  render() {
909
- return T` <slot></slot>`;
1196
+ return T` <slot></slot> `;
910
1197
  }
911
1198
  };
912
- _title = new WeakMap();
913
- __decorateClass([
914
- n({ type: String })
915
- ], QtiAssessmentTest.prototype, "identifier", 2);
916
- __decorateClass([
917
- n({ type: String })
918
- ], QtiAssessmentTest.prototype, "title", 1);
919
- __decorateClass([
920
- c({ context: testContext, subscribe: true })
921
- ], QtiAssessmentTest.prototype, "_testContext", 2);
922
- QtiAssessmentTest = __decorateClass([
923
- t("qti-assessment-test")
924
- ], QtiAssessmentTest);
1199
+ __decorate9([
1200
+ n2({ type: String, attribute: "item-id" })
1201
+ ], TestItemLink.prototype, "itemId", void 0);
925
1202
 
926
- // ../qti-test/src/components/qti-test-part/qti-test-part.ts
927
- var _title2;
928
- var QtiTestPart = class extends i2 {
1203
+ // ../qti-test/dist/components/test-item-to-speech/test-item-to-speech.js
1204
+ var __decorate10 = function(decorators, target, key, desc) {
1205
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1206
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
1207
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
1208
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
1209
+ };
1210
+ var HIGHLIGHT_ELEMENT = "tts-element";
1211
+ var HIGHLIGHT_WORD = "tts-word";
1212
+ var highlightSheet = null;
1213
+ function getHighlightSheet() {
1214
+ if (!highlightSheet) {
1215
+ highlightSheet = new CSSStyleSheet();
1216
+ highlightSheet.replaceSync(`
1217
+ ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
1218
+ ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
1219
+ `);
1220
+ }
1221
+ return highlightSheet;
1222
+ }
1223
+ var ttsContext = n(/* @__PURE__ */ Symbol("tts-context"));
1224
+ var TtsButtonBase = class extends i2 {
1225
+ static {
1226
+ this.styles = i`
1227
+ :host {
1228
+ display: inline-block;
1229
+ }
1230
+ button {
1231
+ cursor: pointer;
1232
+ }
1233
+ button:disabled {
1234
+ opacity: 0.4;
1235
+ cursor: default;
1236
+ }
1237
+ `;
1238
+ }
1239
+ #internals = this.attachInternals();
1240
+ updated(changed) {
1241
+ if (changed.has("_tts")) {
1242
+ this.#internals.states.clear();
1243
+ if (this._tts?.state)
1244
+ this.#internals.states.add(this._tts.state);
1245
+ }
1246
+ }
1247
+ };
1248
+ __decorate10([
1249
+ c({ context: ttsContext, subscribe: true })
1250
+ ], TtsButtonBase.prototype, "_tts", void 0);
1251
+ var TestItemToSpeech = class extends i2 {
1252
+ #internals;
1253
+ #itemElements;
1254
+ #boundHandleItemConnected;
1255
+ #eventHost;
1256
+ // Current set of block-level reading elements for the active item
1257
+ #readingElements;
1258
+ #currentElementIndex;
1259
+ // Text nodes of the element currently being spoken (for word-boundary highlight)
1260
+ #textNodes;
1261
+ // Two separate CSS Highlight objects
1262
+ #elementHighlight;
1263
+ // whole-element cursor
1264
+ #wordHighlight;
1265
+ // current word during speech
1266
+ // Tracks previous navItemRefId to detect item switches
1267
+ #prevNavItemRefId;
1268
+ #boundHandleNavigation;
929
1269
  constructor() {
930
- super(...arguments);
931
- this.identifier = "";
932
- this.class = "";
933
- this.navigationMode = "nonlinear";
934
- this.submissionMode = "individual";
935
- __privateAdd(this, _title2, "");
1270
+ super();
1271
+ this.language = "nl-NL";
1272
+ this.#internals = this.attachInternals();
1273
+ this.#itemElements = /* @__PURE__ */ new Map();
1274
+ this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
1275
+ this.#eventHost = null;
1276
+ this.#readingElements = null;
1277
+ this.#currentElementIndex = 0;
1278
+ this.#textNodes = [];
1279
+ this.#elementHighlight = new Highlight();
1280
+ this.#wordHighlight = new Highlight();
1281
+ this.#prevNavItemRefId = void 0;
1282
+ this.#boundHandleNavigation = () => this.#stop();
1283
+ this._ttsContext = {
1284
+ state: "idle",
1285
+ currentElementIndex: 0,
1286
+ elementCount: 0,
1287
+ play: () => this.#playSpeech(),
1288
+ pause: () => this.#pause(),
1289
+ resume: () => this.#resume(),
1290
+ stop: () => this.#stop(),
1291
+ prevElement: () => this.#prevElement(),
1292
+ nextElement: () => this.#nextElement()
1293
+ };
936
1294
  }
937
- get title() {
938
- return __privateGet(this, _title2);
1295
+ willUpdate(changed) {
1296
+ void changed;
939
1297
  }
940
- set title(value) {
941
- __privateSet(this, _title2, value);
942
- this.removeAttribute("title");
943
- this.setAttribute("data-title", value);
1298
+ updated(_changed) {
1299
+ const current = this._sessionContext?.navItemRefId ?? null;
1300
+ if (this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== current) {
1301
+ this.#stop();
1302
+ this.#readingElements = null;
1303
+ this.#currentElementIndex = 0;
1304
+ this.#updateContext();
1305
+ }
1306
+ this.#prevNavItemRefId = current;
944
1307
  }
945
- async connectedCallback() {
1308
+ connectedCallback() {
946
1309
  super.connectedCallback();
947
- await this.updateComplete;
948
- this.dispatchEvent(
949
- new Event("qti-test-part-connected", {
950
- bubbles: true,
951
- composed: true
952
- })
953
- );
1310
+ this.#setSpeechState("idle");
1311
+ this.#eventHost = this.closest("test-navigation") ?? this.closest("qti-test") ?? this.getRootNode();
1312
+ this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
1313
+ this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
1314
+ }
1315
+ disconnectedCallback() {
1316
+ super.disconnectedCallback();
1317
+ speechSynthesis.cancel();
1318
+ this.#clearAllHighlights();
1319
+ this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
1320
+ this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
1321
+ this.#eventHost = null;
1322
+ this.#itemElements.clear();
954
1323
  }
955
1324
  render() {
956
- return T` <slot></slot>`;
1325
+ return T`<slot></slot>`;
1326
+ }
1327
+ #handleItemConnected(event) {
1328
+ const item = event.detail;
1329
+ if (item?.identifier) {
1330
+ this.#itemElements.set(item.identifier, item);
1331
+ }
1332
+ }
1333
+ /** Update speech state on both the context (notifies children) and the host's CSS custom states. */
1334
+ #setSpeechState(state) {
1335
+ this._ttsContext = { ...this._ttsContext, state };
1336
+ this.#internals.states.delete("idle");
1337
+ this.#internals.states.delete("playing");
1338
+ this.#internals.states.delete("paused");
1339
+ this.#internals.states.add(state);
1340
+ }
1341
+ /** Push currentElementIndex and elementCount into context so children can react. */
1342
+ #updateContext() {
1343
+ this._ttsContext = {
1344
+ ...this._ttsContext,
1345
+ currentElementIndex: this.#currentElementIndex,
1346
+ elementCount: this.#readingElements?.length ?? 0
1347
+ };
1348
+ }
1349
+ /** Return cached reading elements, collecting them lazily on first call for the active item. */
1350
+ #getReadingElements() {
1351
+ if (this.#readingElements !== null)
1352
+ return this.#readingElements;
1353
+ const identifier = this._sessionContext?.navItemRefId;
1354
+ if (!identifier)
1355
+ return [];
1356
+ const assessmentItem = this.#itemElements.get(identifier);
1357
+ if (!assessmentItem)
1358
+ return [];
1359
+ const itemBody = assessmentItem.querySelector("qti-item-body");
1360
+ if (!itemBody)
1361
+ return [];
1362
+ const selector = "p, h1, h2, h3, h4, h5, h6, li, blockquote, figcaption";
1363
+ this.#readingElements = Array.from(itemBody.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0);
1364
+ return this.#readingElements;
1365
+ }
1366
+ #playSpeech() {
1367
+ const elements = this.#getReadingElements();
1368
+ if (!elements.length) {
1369
+ console.warn("test-item-to-speech: no readable elements found in qti-item-body");
1370
+ return;
1371
+ }
1372
+ this.#speakElement(this.#currentElementIndex);
1373
+ }
1374
+ /** Speak the element at the given index, then auto-advance when it ends. */
1375
+ #speakElement(index) {
1376
+ const elements = this.#readingElements ?? [];
1377
+ if (index >= elements.length) {
1378
+ this.#clearWordHighlight();
1379
+ this.#currentElementIndex = elements.length - 1;
1380
+ if (elements.length > 0)
1381
+ this.#highlightElement(elements[this.#currentElementIndex]);
1382
+ this.#setSpeechState("idle");
1383
+ this.#updateContext();
1384
+ return;
1385
+ }
1386
+ this.#currentElementIndex = index;
1387
+ this.#updateContext();
1388
+ const element = elements[index];
1389
+ element.scrollIntoView({ behavior: "smooth", block: "nearest" });
1390
+ this.#highlightElement(element);
1391
+ this.#textNodes = this.#collectTextNodes(element);
1392
+ const text = this.#textNodes.map((n3) => n3.textContent ?? "").join("");
1393
+ if (!text.trim()) {
1394
+ this.#speakElement(index + 1);
1395
+ return;
1396
+ }
1397
+ const utterance = new SpeechSynthesisUtterance(text);
1398
+ utterance.lang = this.language;
1399
+ utterance.rate = 1;
1400
+ utterance.onboundary = (event) => {
1401
+ if (event.name !== "word")
1402
+ return;
1403
+ this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
1404
+ };
1405
+ utterance.onend = () => {
1406
+ this.#clearWordHighlight();
1407
+ this.#speakElement(this.#currentElementIndex + 1);
1408
+ };
1409
+ speechSynthesis.speak(utterance);
1410
+ this.#setSpeechState("playing");
1411
+ }
1412
+ #pause() {
1413
+ speechSynthesis.pause();
1414
+ this.#setSpeechState("paused");
1415
+ }
1416
+ #resume() {
1417
+ speechSynthesis.resume();
1418
+ this.#setSpeechState("playing");
1419
+ }
1420
+ #stop() {
1421
+ speechSynthesis.cancel();
1422
+ this.#clearAllHighlights();
1423
+ this.#setSpeechState("idle");
1424
+ }
1425
+ #prevElement() {
1426
+ const elements = this.#getReadingElements();
1427
+ if (!elements.length)
1428
+ return;
1429
+ speechSynthesis.cancel();
1430
+ this.#clearWordHighlight();
1431
+ this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
1432
+ this.#updateContext();
1433
+ const el = elements[this.#currentElementIndex];
1434
+ el.scrollIntoView({ behavior: "smooth", block: "nearest" });
1435
+ this.#highlightElement(el);
1436
+ this.#setSpeechState("idle");
1437
+ }
1438
+ #nextElement() {
1439
+ const elements = this.#getReadingElements();
1440
+ if (!elements.length)
1441
+ return;
1442
+ speechSynthesis.cancel();
1443
+ this.#clearWordHighlight();
1444
+ this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
1445
+ this.#updateContext();
1446
+ const el = elements[this.#currentElementIndex];
1447
+ el.scrollIntoView({ behavior: "smooth", block: "nearest" });
1448
+ this.#highlightElement(el);
1449
+ this.#setSpeechState("idle");
1450
+ }
1451
+ /** Walk text nodes without crossing shadow DOM boundaries. */
1452
+ #collectTextNodes(root) {
1453
+ const nodes = [];
1454
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
1455
+ let node;
1456
+ while (node = walker.nextNode()) {
1457
+ if ((node.textContent ?? "").length > 0) {
1458
+ nodes.push(node);
1459
+ }
1460
+ }
1461
+ return nodes;
1462
+ }
1463
+ /** Highlight the whole element as the navigation cursor (blue). */
1464
+ #highlightElement(element) {
1465
+ if (!("highlights" in CSS))
1466
+ return;
1467
+ this.#ensureHighlightStyles();
1468
+ this.#elementHighlight.clear();
1469
+ const range = new Range();
1470
+ range.selectNodeContents(element);
1471
+ this.#elementHighlight.add(range);
1472
+ CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
1473
+ }
1474
+ /** Highlight the current word within #textNodes (yellow, during speech). */
1475
+ #updateWordHighlight(charIndex, charLength) {
1476
+ if (!("highlights" in CSS))
1477
+ return;
1478
+ this.#ensureHighlightStyles();
1479
+ this.#wordHighlight.clear();
1480
+ const text = this.#textNodes.map((n3) => n3.textContent ?? "").join("");
1481
+ const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));
1482
+ let offset = 0;
1483
+ let startNode = null;
1484
+ let startOffset = 0;
1485
+ let endNode = null;
1486
+ let endOffset = 0;
1487
+ for (const node of this.#textNodes) {
1488
+ const len = node.textContent?.length ?? 0;
1489
+ if (!startNode && offset + len > charIndex) {
1490
+ startNode = node;
1491
+ startOffset = charIndex - offset;
1492
+ }
1493
+ if (startNode && offset + len >= endIndex) {
1494
+ endNode = node;
1495
+ endOffset = endIndex - offset;
1496
+ break;
1497
+ }
1498
+ offset += len;
1499
+ }
1500
+ if (startNode && endNode) {
1501
+ const range = new Range();
1502
+ range.setStart(startNode, startOffset);
1503
+ range.setEnd(endNode, endOffset);
1504
+ this.#wordHighlight.add(range);
1505
+ CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);
1506
+ }
1507
+ }
1508
+ #clearWordHighlight() {
1509
+ if (!("highlights" in CSS))
1510
+ return;
1511
+ this.#wordHighlight.clear();
1512
+ CSS.highlights.delete(HIGHLIGHT_WORD);
1513
+ }
1514
+ #clearAllHighlights() {
1515
+ if (!("highlights" in CSS))
1516
+ return;
1517
+ this.#wordHighlight.clear();
1518
+ CSS.highlights.delete(HIGHLIGHT_WORD);
1519
+ this.#elementHighlight.clear();
1520
+ CSS.highlights.delete(HIGHLIGHT_ELEMENT);
1521
+ }
1522
+ /** Fallback word-length when charLength is 0. */
1523
+ #wordLengthAt(charIndex, text) {
1524
+ const right = text.slice(charIndex).search(/\s/);
1525
+ return right < 0 ? text.length - charIndex : right;
1526
+ }
1527
+ /**
1528
+ * Add ::highlight() rules both to test-container's shadow root (where highlighted
1529
+ * text lives) and to the document (safety net — spec allows document rules to apply
1530
+ * across shadow DOM). Called lazily on first highlight use so test-container is
1531
+ * guaranteed to be in the DOM by the time navigation or speech starts.
1532
+ */
1533
+ #ensureHighlightStyles() {
1534
+ if (!("highlights" in CSS))
1535
+ return;
1536
+ const sheet = getHighlightSheet();
1537
+ if (!document.adoptedStyleSheets.includes(sheet)) {
1538
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
1539
+ }
1540
+ const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.closest("qti-test")?.querySelector("test-container");
1541
+ const root = testContainer?.shadowRoot;
1542
+ if (root && !root.adoptedStyleSheets.includes(sheet)) {
1543
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
1544
+ }
957
1545
  }
958
1546
  };
959
- _title2 = new WeakMap();
960
- __decorateClass([
961
- n({ type: String })
962
- ], QtiTestPart.prototype, "identifier", 2);
963
- __decorateClass([
964
- n({ type: String })
965
- ], QtiTestPart.prototype, "class", 2);
966
- __decorateClass([
967
- n({ type: String, attribute: "navigation-mode" })
968
- ], QtiTestPart.prototype, "navigationMode", 2);
969
- __decorateClass([
970
- n({ type: String, attribute: "submission-mode" })
971
- ], QtiTestPart.prototype, "submissionMode", 2);
972
- QtiTestPart = __decorateClass([
973
- t("qti-test-part")
974
- ], QtiTestPart);
975
- if (!customElements.get("qti-test-part")) {
976
- customElements.define("qti-test-part", QtiTestPart);
977
- }
978
-
979
- // ../qti-test/src/components/qti-test-feedback/qti-test-feedback.ts
980
- var QtiTestFeedback = class extends QtiModalFeedback {
1547
+ __decorate10([
1548
+ n2({ type: String })
1549
+ ], TestItemToSpeech.prototype, "language", void 0);
1550
+ __decorate10([
1551
+ c({ context: sessionContext, subscribe: true })
1552
+ ], TestItemToSpeech.prototype, "_sessionContext", void 0);
1553
+ __decorate10([
1554
+ r(),
1555
+ e({ context: ttsContext })
1556
+ ], TestItemToSpeech.prototype, "_ttsContext", void 0);
1557
+ var TestTtsPlay = class extends TtsButtonBase {
1558
+ #toggle() {
1559
+ if (!this._tts)
1560
+ return;
1561
+ if (this._tts.state === "idle")
1562
+ this._tts.play();
1563
+ else if (this._tts.state === "playing")
1564
+ this._tts.pause();
1565
+ else
1566
+ this._tts.resume();
1567
+ }
981
1568
  render() {
982
- return T``;
1569
+ const playing = this._tts?.state === "playing";
1570
+ return T`
1571
+ <button part="button" @click=${this.#toggle}>
1572
+ ${playing ? T`<slot name="pause">⏸</slot>` : T`<slot name="play">▶</slot>`}
1573
+ </button>
1574
+ `;
1575
+ }
1576
+ };
1577
+ var TestTtsPause = class extends TtsButtonBase {
1578
+ render() {
1579
+ return T`
1580
+ <button part="button" ?disabled=${this._tts?.state !== "playing"} @click=${() => this._tts?.pause()}>
1581
+ <slot>⏸</slot>
1582
+ </button>
1583
+ `;
1584
+ }
1585
+ };
1586
+ var TestTtsResume = class extends TtsButtonBase {
1587
+ render() {
1588
+ return T`
1589
+ <button part="button" ?disabled=${this._tts?.state !== "paused"} @click=${() => this._tts?.resume()}>
1590
+ <slot>▶</slot>
1591
+ </button>
1592
+ `;
1593
+ }
1594
+ };
1595
+ var TestTtsStop = class extends TtsButtonBase {
1596
+ render() {
1597
+ return T`
1598
+ <button part="button" ?disabled=${this._tts?.state === "idle"} @click=${() => this._tts?.stop()}>
1599
+ <slot>■</slot>
1600
+ </button>
1601
+ `;
1602
+ }
1603
+ };
1604
+ var TestTtsPrev = class extends TtsButtonBase {
1605
+ render() {
1606
+ const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
1607
+ const noElements = (this._tts?.elementCount ?? 0) === 0;
1608
+ return T`
1609
+ <button part="button" ?disabled=${noElements || atStart} @click=${() => this._tts?.prevElement()}>
1610
+ <slot>◀◀</slot>
1611
+ </button>
1612
+ `;
1613
+ }
1614
+ };
1615
+ var TestTtsNext = class extends TtsButtonBase {
1616
+ render() {
1617
+ const atEnd = (this._tts?.elementCount ?? 0) > 0 && (this._tts?.currentElementIndex ?? 0) >= (this._tts?.elementCount ?? 0) - 1;
1618
+ const noElements = (this._tts?.elementCount ?? 0) === 0;
1619
+ return T`
1620
+ <button part="button" ?disabled=${noElements || atEnd} @click=${() => this._tts?.nextElement()}>
1621
+ <slot>▶▶</slot>
1622
+ </button>
1623
+ `;
983
1624
  }
984
1625
  };
985
- QtiTestFeedback.styles = i`
986
- :host {
987
- color: gray;
988
- }
989
- `;
990
- QtiTestFeedback = __decorateClass([
991
- t("qti-test-feedback")
992
- ], QtiTestFeedback);
993
1626
 
994
- // ../qti-test/src/components/test-navigation/test-navigation.ts
995
- var _testElement, _TestNavigation_instances, handleTestEndAttempt_fn, handleTestShowCorrectResponse_fn, handleTestShowCandidateCorrection_fn, handleTestUpdateOutcomeVariable_fn, handleInteractionChanged_fn, handleTestConnected_fn, extractDefaultValues_fn, handleItemConnected_fn;
1627
+ // ../qti-test/dist/components/test-navigation/test-navigation.js
1628
+ var __decorate11 = function(decorators, target, key, desc) {
1629
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1630
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
1631
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
1632
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
1633
+ };
996
1634
  var TestNavigation = class extends i2 {
1635
+ #testElement;
997
1636
  constructor() {
998
1637
  super();
999
- __privateAdd(this, _TestNavigation_instances);
1000
1638
  this.identifier = void 0;
1001
1639
  this.initContext = [];
1002
1640
  this.qtiContext = {
@@ -1008,49 +1646,223 @@ var TestNavigation = class extends i2 {
1008
1646
  };
1009
1647
  this.configContext = {};
1010
1648
  this.autoScoreItems = false;
1011
- __privateAdd(this, _testElement);
1012
- this.addEventListener("qti-assessment-test-connected", __privateMethod(this, _TestNavigation_instances, handleTestConnected_fn).bind(this));
1013
- this.addEventListener("qti-assessment-item-connected", __privateMethod(this, _TestNavigation_instances, handleItemConnected_fn).bind(this));
1014
- this.addEventListener("qti-interaction-changed", __privateMethod(this, _TestNavigation_instances, handleInteractionChanged_fn).bind(this));
1015
- this.addEventListener("test-end-attempt", __privateMethod(this, _TestNavigation_instances, handleTestEndAttempt_fn).bind(this));
1016
- this.addEventListener("test-show-correct-response", __privateMethod(this, _TestNavigation_instances, handleTestShowCorrectResponse_fn).bind(this));
1017
- this.addEventListener("test-show-candidate-correction", __privateMethod(this, _TestNavigation_instances, handleTestShowCandidateCorrection_fn).bind(this));
1018
- this.addEventListener("test-update-outcome-variable", __privateMethod(this, _TestNavigation_instances, handleTestUpdateOutcomeVariable_fn).bind(this));
1649
+ this.addEventListener("qti-assessment-test-connected", this.#handleTestConnected.bind(this));
1650
+ this.addEventListener("qti-assessment-item-connected", this.#handleItemConnected.bind(this));
1651
+ this.addEventListener("qti-interaction-changed", this.#handleInteractionChanged.bind(this));
1652
+ this.addEventListener("test-end-attempt", this.#handleTestEndAttempt.bind(this));
1653
+ this.addEventListener("test-update-outcome-variable", this.#handleTestUpdateOutcomeVariable.bind(this));
1654
+ }
1655
+ /** The currently active assessment item, exposed for optional presentation extensions. */
1656
+ get activeAssessmentItem() {
1657
+ if (!this.#testElement || !this._sessionContext?.navItemRefId)
1658
+ return void 0;
1659
+ return this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem;
1660
+ }
1661
+ /**
1662
+ * Handles the 'test-end-attempt' event.
1663
+ * @private
1664
+ * @listens TestNavigation#test-end-attempt
1665
+ * @param {CustomEvent} event - The custom event object.
1666
+ */
1667
+ #handleTestEndAttempt(_event) {
1668
+ const qtiItemEl = this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`);
1669
+ const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
1670
+ const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
1671
+ qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
1672
+ }
1673
+ #handleTestUpdateOutcomeVariable(event) {
1674
+ const qtiItemEl = this.#testElement.querySelector(`qti-assessment-item-ref[identifier="${event.detail.assessmentItemRefId}"]`);
1675
+ const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
1676
+ qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
1677
+ }
1678
+ #handleInteractionChanged(_event) {
1679
+ if (this.autoScoreItems) {
1680
+ const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
1681
+ const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
1682
+ if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
1683
+ const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
1684
+ assessmentItem.processResponse(true, reportValidityAfterScoring);
1685
+ }
1686
+ }
1019
1687
  }
1020
1688
  render() {
1021
1689
  return T`<slot></slot>`;
1022
1690
  }
1023
- /* PK: on every change of the candidate we will recomputed the computedContext */
1024
- willUpdate(_changedProperties) {
1025
- if (!this.computedContext) return;
1026
- let itemIndex = 1;
1691
+ /* PK: on test connected we can build the computed context */
1692
+ #handleTestConnected(event) {
1693
+ this.#testElement = event.detail;
1694
+ if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
1695
+ const currentContext = this.qtiContext.QTI_CONTEXT || {
1696
+ testIdentifier: "",
1697
+ candidateIdentifier: "not set",
1698
+ environmentIdentifier: "default"
1699
+ };
1700
+ this.qtiContext = {
1701
+ QTI_CONTEXT: {
1702
+ ...currentContext,
1703
+ testIdentifier: this.#testElement.identifier,
1704
+ environmentIdentifier: currentContext.environmentIdentifier || "default"
1705
+ }
1706
+ };
1707
+ }
1708
+ const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
1709
+ contextDeclarations.forEach((declaration) => {
1710
+ const defaultValues = this.#extractDefaultValues(declaration);
1711
+ if (Object.keys(defaultValues).length > 0) {
1712
+ this.qtiContext = {
1713
+ QTI_CONTEXT: {
1714
+ ...defaultValues,
1715
+ // Default values first
1716
+ ...this.qtiContext.QTI_CONTEXT
1717
+ // Runtime values override defaults
1718
+ }
1719
+ };
1720
+ }
1721
+ });
1722
+ const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
1027
1723
  this.computedContext = {
1028
- ...this.computedContext,
1724
+ identifier: this.#testElement.identifier,
1725
+ title: this.#testElement.title,
1029
1726
  view: this._sessionContext?.view,
1727
+ testParts: testPartElements.map((testPart) => {
1728
+ const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
1729
+ return {
1730
+ active: false,
1731
+ identifier: testPart.identifier,
1732
+ navigationMode: testPart.navigationMode,
1733
+ submissionMode: testPart.submissionMode,
1734
+ sections: sectionElements.map((section) => {
1735
+ const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
1736
+ return {
1737
+ active: false,
1738
+ identifier: section.identifier,
1739
+ title: section.title,
1740
+ items: itemElements.map((item) => ({
1741
+ ...this.initContext?.find((i4) => i4.identifier === item.identifier),
1742
+ active: false,
1743
+ identifier: item.identifier,
1744
+ categories: item.category ? item.category?.split(" ") : [],
1745
+ href: item.href,
1746
+ variables: []
1747
+ }))
1748
+ };
1749
+ })
1750
+ };
1751
+ })
1752
+ };
1753
+ }
1754
+ /**
1755
+ * Extract default values from a qti-context-declaration element
1756
+ */
1757
+ #extractDefaultValues(declaration) {
1758
+ const defaultValues = {};
1759
+ const defaultValueElement = declaration.querySelector("qti-default-value");
1760
+ if (!defaultValueElement) {
1761
+ return defaultValues;
1762
+ }
1763
+ const valueElements = defaultValueElement.querySelectorAll("qti-value[field-identifier]");
1764
+ valueElements.forEach((valueElement) => {
1765
+ const fieldIdentifier = valueElement.getAttribute("field-identifier");
1766
+ const baseType = valueElement.getAttribute("base-type") || "string";
1767
+ const textContent = valueElement.textContent?.trim() || "";
1768
+ if (fieldIdentifier) {
1769
+ let value = textContent;
1770
+ switch (baseType) {
1771
+ case "integer":
1772
+ value = parseInt(textContent, 10);
1773
+ break;
1774
+ case "float":
1775
+ case "duration":
1776
+ value = parseFloat(textContent);
1777
+ break;
1778
+ case "boolean":
1779
+ value = textContent.toLowerCase() === "true";
1780
+ break;
1781
+ case "string":
1782
+ default:
1783
+ value = textContent;
1784
+ break;
1785
+ }
1786
+ defaultValues[fieldIdentifier] = value;
1787
+ }
1788
+ });
1789
+ return defaultValues;
1790
+ }
1791
+ /* PK: on item connected we can add item only properties in the xml */
1792
+ #handleItemConnected(event) {
1793
+ const itemElement = event.detail;
1794
+ this.computedContext = {
1795
+ ...this.computedContext,
1030
1796
  testParts: this.computedContext.testParts.map((testPart) => {
1031
1797
  return {
1032
1798
  ...testPart,
1033
- active: this._sessionContext?.navPartId === testPart.identifier || false,
1034
1799
  sections: testPart.sections.map((section) => {
1035
1800
  return {
1036
1801
  ...section,
1037
- active: this._sessionContext?.navSectionId === section.identifier || false,
1038
- completed: section.items.every(
1039
- (item) => this._testContext.items.find((i5) => i5.identifier === item.identifier)?.variables.find((v2) => v2.identifier === "completionStatus").value === "completed"
1040
- ),
1041
1802
  items: section.items.map((item) => {
1042
- const itemContext = this._testContext?.items.find((i5) => i5.identifier === item.identifier);
1043
- const computedItem = {
1803
+ if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
1804
+ return item;
1805
+ }
1806
+ const scoreOutcome = itemElement.querySelector("qti-outcome-declaration[identifier='SCORE']");
1807
+ const externalScored = scoreOutcome?.getAttribute("externalScored");
1808
+ const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
1809
+ const containsCorrectResponse = Array.from(responseDeclarations).some((r3) => r3.querySelector("qti-correct-response"));
1810
+ const containsMapping = Array.from(responseDeclarations).some((r3) => {
1811
+ const mapping = r3.querySelector("qti-mapping");
1812
+ const areaMapping = r3.querySelector("qti-area-mapping");
1813
+ return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
1814
+ });
1815
+ const hasCorrectResponse = containsCorrectResponse || containsMapping;
1816
+ const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
1817
+ return {
1044
1818
  ...item,
1045
- ...itemContext,
1046
- ...this.initContext?.find((i5) => i5.identifier === item.identifier)
1819
+ assessmentItemIdentifier: itemElement.getAttribute("identifier"),
1820
+ label: itemElement.getAttribute("label"),
1821
+ title: itemElement.title,
1822
+ externalScored,
1823
+ adaptive: itemElement.adaptive == "true" || false,
1824
+ timeDependent: itemElement.timeDependent == "true" || false,
1825
+ variables: itemElement.variables,
1826
+ hasCorrectResponse,
1827
+ hasResponseProcessing
1047
1828
  };
1048
- const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
1049
- const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
1050
- const completionStatus = computedItem.variables?.find((v2) => v2.identifier === "completionStatus")?.value;
1051
- const response = computedItem.variables?.find((v2) => v2.identifier === "RESPONSE")?.value || "";
1052
- const numAttempts = computedItem.variables?.find((v2) => v2.identifier === "numAttempts")?.value || 0;
1053
- const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
1829
+ })
1830
+ };
1831
+ })
1832
+ };
1833
+ })
1834
+ };
1835
+ }
1836
+ /* PK: on every change of the candidate we will recomputed the computedContext */
1837
+ willUpdate(_changedProperties) {
1838
+ if (!this.computedContext)
1839
+ return;
1840
+ let itemIndex = 1;
1841
+ this.computedContext = {
1842
+ ...this.computedContext,
1843
+ view: this._sessionContext?.view,
1844
+ testParts: this.computedContext.testParts.map((testPart) => {
1845
+ return {
1846
+ ...testPart,
1847
+ active: this._sessionContext?.navPartId === testPart.identifier || false,
1848
+ sections: testPart.sections.map((section) => {
1849
+ return {
1850
+ ...section,
1851
+ active: this._sessionContext?.navSectionId === section.identifier || false,
1852
+ completed: section.items.every((item) => this._testContext.items.find((i4) => i4.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"),
1853
+ items: section.items.map((item) => {
1854
+ const itemContext = this._testContext?.items.find((i4) => i4.identifier === item.identifier);
1855
+ const computedItem = {
1856
+ ...item,
1857
+ ...itemContext,
1858
+ ...this.initContext?.find((i4) => i4.identifier === item.identifier)
1859
+ };
1860
+ const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
1861
+ const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
1862
+ const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
1863
+ const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
1864
+ const numAttempts = computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value || 0;
1865
+ const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
1054
1866
  const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
1055
1867
  const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
1056
1868
  const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
@@ -1074,871 +1886,118 @@ var TestNavigation = class extends i2 {
1074
1886
  };
1075
1887
  })
1076
1888
  };
1077
- this.dispatchEvent(
1078
- new CustomEvent("qti-computed-context-updated", {
1079
- detail: this.computedContext,
1080
- bubbles: true
1081
- })
1082
- );
1083
- }
1084
- };
1085
- _testElement = new WeakMap();
1086
- _TestNavigation_instances = new WeakSet();
1087
- /**
1088
- * Handles the 'test-end-attempt' event.
1089
- * @private
1090
- * @listens TestNavigation#test-end-attempt
1091
- * @param {CustomEvent} event - The custom event object.
1092
- */
1093
- handleTestEndAttempt_fn = function(_event) {
1094
- const qtiItemEl = __privateGet(this, _testElement).querySelector(
1095
- `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
1096
- );
1097
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
1098
- const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
1099
- qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
1100
- };
1101
- /**
1102
- * Handles the 'test-show-correct-response' event.
1103
- * @private
1104
- * @listens TestNavigation#test-show-correct-response
1105
- * @param {CustomEvent} event - The custom event object.
1106
- */
1107
- handleTestShowCorrectResponse_fn = function(event) {
1108
- const qtiItemEl = __privateGet(this, _testElement).querySelector(
1109
- `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
1110
- );
1111
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
1112
- if (!qtiAssessmentItemEl) return;
1113
- qtiAssessmentItemEl.showCorrectResponse(event.detail);
1114
- };
1115
- /**
1116
- * Handles the 'test-show-candidate-correction' event.
1117
- * @private
1118
- * @listens TestNavigation#test-show-candidate-correction
1119
- * @param {CustomEvent} event - The custom event object.
1120
- */
1121
- handleTestShowCandidateCorrection_fn = function(event) {
1122
- const qtiItemEl = __privateGet(this, _testElement).querySelector(
1123
- `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
1124
- );
1125
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
1126
- qtiAssessmentItemEl.showCandidateCorrection(event.detail);
1127
- };
1128
- handleTestUpdateOutcomeVariable_fn = function(event) {
1129
- const qtiItemEl = __privateGet(this, _testElement).querySelector(
1130
- `qti-assessment-item-ref[identifier="${event.detail.assessmentItemRefId}"]`
1131
- );
1132
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
1133
- qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
1134
- };
1135
- handleInteractionChanged_fn = function(_event) {
1136
- if (this.autoScoreItems) {
1137
- const assessmentItem = _event.composedPath()[0].closest(
1138
- "qti-assessment-item"
1139
- );
1140
- const scoreOutcomeIdentifier = assessmentItem.variables.find((v2) => v2.identifier === "SCORE");
1141
- if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
1142
- const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
1143
- assessmentItem.processResponse(true, reportValidityAfterScoring);
1144
- }
1145
- }
1146
- };
1147
- /* PK: on test connected we can build the computed context */
1148
- handleTestConnected_fn = function(event) {
1149
- __privateSet(this, _testElement, event.detail);
1150
- if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
1151
- const currentContext = this.qtiContext.QTI_CONTEXT || {
1152
- testIdentifier: "",
1153
- candidateIdentifier: "not set",
1154
- environmentIdentifier: "default"
1155
- };
1156
- this.qtiContext = {
1157
- QTI_CONTEXT: {
1158
- ...currentContext,
1159
- testIdentifier: __privateGet(this, _testElement).identifier,
1160
- environmentIdentifier: currentContext.environmentIdentifier || "default"
1161
- }
1162
- };
1889
+ this.dispatchEvent(new CustomEvent("qti-computed-context-updated", {
1890
+ detail: this.computedContext,
1891
+ bubbles: true
1892
+ }));
1163
1893
  }
1164
- const contextDeclarations = __privateGet(this, _testElement).querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
1165
- contextDeclarations.forEach((declaration) => {
1166
- const defaultValues = __privateMethod(this, _TestNavigation_instances, extractDefaultValues_fn).call(this, declaration);
1167
- if (Object.keys(defaultValues).length > 0) {
1168
- this.qtiContext = {
1169
- QTI_CONTEXT: {
1170
- ...defaultValues,
1171
- // Default values first
1172
- ...this.qtiContext.QTI_CONTEXT
1173
- // Runtime values override defaults
1174
- }
1175
- };
1176
- }
1177
- });
1178
- const testPartElements = Array.from(__privateGet(this, _testElement)?.querySelectorAll(`qti-test-part`) || []);
1179
- this.computedContext = {
1180
- identifier: __privateGet(this, _testElement).identifier,
1181
- title: __privateGet(this, _testElement).title,
1182
- view: this._sessionContext?.view,
1183
- testParts: testPartElements.map((testPart) => {
1184
- const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
1185
- return {
1186
- active: false,
1187
- identifier: testPart.identifier,
1188
- navigationMode: testPart.navigationMode,
1189
- submissionMode: testPart.submissionMode,
1190
- sections: sectionElements.map((section) => {
1191
- const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
1192
- return {
1193
- active: false,
1194
- identifier: section.identifier,
1195
- title: section.title,
1196
- items: itemElements.map((item) => ({
1197
- ...this.initContext?.find((i5) => i5.identifier === item.identifier),
1198
- active: false,
1199
- identifier: item.identifier,
1200
- categories: item.category ? item.category?.split(" ") : [],
1201
- href: item.href,
1202
- variables: []
1203
- }))
1204
- };
1205
- })
1206
- };
1207
- })
1208
- };
1209
1894
  };
1210
- /**
1211
- * Extract default values from a qti-context-declaration element
1212
- */
1213
- extractDefaultValues_fn = function(declaration) {
1214
- const defaultValues = {};
1215
- const defaultValueElement = declaration.querySelector("qti-default-value");
1216
- if (!defaultValueElement) {
1217
- return defaultValues;
1218
- }
1219
- const valueElements = defaultValueElement.querySelectorAll("qti-value[field-identifier]");
1220
- valueElements.forEach((valueElement) => {
1221
- const fieldIdentifier = valueElement.getAttribute("field-identifier");
1222
- const baseType = valueElement.getAttribute("base-type") || "string";
1223
- const textContent = valueElement.textContent?.trim() || "";
1224
- if (fieldIdentifier) {
1225
- let value = textContent;
1226
- switch (baseType) {
1227
- case "integer":
1228
- value = parseInt(textContent, 10);
1229
- break;
1230
- case "float":
1231
- case "duration":
1232
- value = parseFloat(textContent);
1233
- break;
1234
- case "boolean":
1235
- value = textContent.toLowerCase() === "true";
1236
- break;
1237
- case "string":
1238
- default:
1239
- value = textContent;
1240
- break;
1241
- }
1242
- defaultValues[fieldIdentifier] = value;
1243
- }
1244
- });
1245
- return defaultValues;
1246
- };
1247
- /* PK: on item connected we can add item only properties in the xml */
1248
- handleItemConnected_fn = function(event) {
1249
- const itemElement = event.detail;
1250
- this.computedContext = {
1251
- ...this.computedContext,
1252
- testParts: this.computedContext.testParts.map((testPart) => {
1253
- return {
1254
- ...testPart,
1255
- sections: testPart.sections.map((section) => {
1256
- return {
1257
- ...section,
1258
- items: section.items.map((item) => {
1259
- if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
1260
- return item;
1261
- }
1262
- const scoreOutcome = itemElement.querySelector(
1263
- "qti-outcome-declaration[identifier='SCORE']"
1264
- );
1265
- const externalScored = scoreOutcome?.getAttribute("externalScored");
1266
- const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
1267
- const containsCorrectResponse = Array.from(responseDeclarations).some(
1268
- (r4) => r4.querySelector("qti-correct-response")
1269
- );
1270
- const containsMapping = Array.from(responseDeclarations).some((r4) => {
1271
- const mapping = r4.querySelector("qti-mapping");
1272
- const areaMapping = r4.querySelector("qti-area-mapping");
1273
- return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
1274
- });
1275
- const hasCorrectResponse = containsCorrectResponse || containsMapping;
1276
- const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
1277
- return {
1278
- ...item,
1279
- assessmentItemIdentifier: itemElement.getAttribute("identifier"),
1280
- label: itemElement.getAttribute("label"),
1281
- title: itemElement.title,
1282
- externalScored,
1283
- adaptive: itemElement.adaptive == "true" || false,
1284
- timeDependent: itemElement.timeDependent == "true" || false,
1285
- variables: itemElement.variables,
1286
- hasCorrectResponse,
1287
- hasResponseProcessing
1288
- };
1289
- })
1290
- };
1291
- })
1292
- };
1293
- })
1294
- };
1295
- };
1296
- __decorateClass([
1297
- n({ type: String })
1298
- ], TestNavigation.prototype, "identifier", 2);
1299
- __decorateClass([
1895
+ __decorate11([
1896
+ n2({ type: String })
1897
+ ], TestNavigation.prototype, "identifier", void 0);
1898
+ __decorate11([
1300
1899
  r()
1301
- ], TestNavigation.prototype, "initContext", 2);
1302
- __decorateClass([
1900
+ ], TestNavigation.prototype, "initContext", void 0);
1901
+ __decorate11([
1303
1902
  r(),
1304
1903
  e({ context: qtiContext })
1305
- ], TestNavigation.prototype, "qtiContext", 2);
1306
- __decorateClass([
1904
+ ], TestNavigation.prototype, "qtiContext", void 0);
1905
+ __decorate11([
1307
1906
  r(),
1308
1907
  c({ context: configContext, subscribe: true })
1309
- ], TestNavigation.prototype, "configContext", 2);
1310
- __decorateClass([
1908
+ ], TestNavigation.prototype, "configContext", void 0);
1909
+ __decorate11([
1311
1910
  r(),
1312
1911
  c({ context: testContext, subscribe: true })
1313
- ], TestNavigation.prototype, "_testContext", 2);
1314
- __decorateClass([
1315
- r(),
1316
- c({ context: sessionContext, subscribe: true })
1317
- ], TestNavigation.prototype, "_sessionContext", 2);
1318
- __decorateClass([
1912
+ ], TestNavigation.prototype, "_testContext", void 0);
1913
+ __decorate11([
1319
1914
  r(),
1320
- e({ context: computedContext })
1321
- ], TestNavigation.prototype, "computedContext", 2);
1322
- __decorateClass([
1323
- n({ type: Boolean, attribute: "auto-score-items" })
1324
- ], TestNavigation.prototype, "autoScoreItems", 2);
1325
- TestNavigation = __decorateClass([
1326
- t("test-navigation")
1327
- ], TestNavigation);
1328
-
1329
- // ../qti-test/src/components/styles.ts
1330
- var form = i`
1331
- display: inline-flex;
1332
- align-items: center;
1333
- cursor: pointer;
1334
- padding: 0.5rem 1rem;
1335
- border-radius: 0.25rem;
1336
- user-select: none;
1337
- `;
1338
- var btn = i`
1339
- background-color: lightgray;
1340
- ${form};
1341
- `;
1342
- var dis = i`
1343
- cursor: not-allowed;
1344
- opacity: 0.8;
1345
- `;
1346
- var ind = i`
1347
- ${form};
1348
- border: 1px solid gray;
1349
- `;
1350
-
1351
- // ../qti-test/src/components/test-next/test-next.ts
1352
- var _internals;
1353
- var TestNext = class extends i2 {
1354
- constructor() {
1355
- super();
1356
- this._internalDisabled = true;
1357
- __privateAdd(this, _internals);
1358
- __privateSet(this, _internals, this.attachInternals());
1359
- __privateGet(this, _internals).role = "button";
1360
- __privateGet(this, _internals).ariaLabel = "Next item";
1361
- this.addEventListener("click", (e3) => {
1362
- e3.preventDefault();
1363
- if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);
1364
- });
1365
- }
1366
- _handleTestElementChange(_oldValue, newValue) {
1367
- if (newValue) {
1368
- this._internalDisabled = false;
1369
- }
1370
- }
1371
- connectedCallback() {
1372
- super.connectedCallback();
1373
- this.checkDisabled();
1374
- }
1375
- willUpdate(_changedProperties) {
1376
- if (!this.computedContext) return;
1377
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
1378
- if (!testPart) return;
1379
- this.sectionItems = testPart.sections.flatMap((section) => section.items);
1380
- this.itemIndex = this.sectionItems.findIndex((item) => item.active);
1381
- this.checkDisabled();
1382
- }
1383
- checkDisabled() {
1384
- this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= this.sectionItems?.length - 1;
1385
- }
1386
- _requestItem(identifier) {
1387
- this.dispatchEvent(
1388
- new CustomEvent("qti-request-navigation", {
1389
- composed: true,
1390
- bubbles: true,
1391
- detail: {
1392
- type: "item",
1393
- id: identifier
1394
- }
1395
- })
1396
- );
1397
- }
1398
- render() {
1399
- return T`<slot></slot>`;
1400
- }
1401
- };
1402
- _internals = new WeakMap();
1403
- TestNext.styles = i`
1404
- :host {
1405
- ${btn};
1406
- }
1407
- :host([disabled]) {
1408
- ${dis};
1409
- }
1410
- `;
1411
- __decorateClass([
1412
- n({ type: Boolean, reflect: true, attribute: "disabled" })
1413
- ], TestNext.prototype, "_internalDisabled", 2);
1414
- __decorateClass([
1415
- c({ context: computedContext, subscribe: true })
1416
- ], TestNext.prototype, "computedContext", 2);
1417
- __decorateClass([
1418
- watch("computedContext")
1419
- ], TestNext.prototype, "_handleTestElementChange", 1);
1420
- TestNext = __decorateClass([
1421
- t("test-next")
1422
- ], TestNext);
1423
-
1424
- // ../qti-test/src/components/test-prev/test-prev.ts
1425
- var TestPrev = class extends i2 {
1426
- constructor() {
1427
- super();
1428
- this._internalDisabled = true;
1429
- this.addEventListener("click", (e3) => {
1430
- e3.preventDefault();
1431
- if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);
1432
- });
1433
- }
1434
- _handleTestElementChange(_oldValue, newValue) {
1435
- if (newValue) {
1436
- this._internalDisabled = false;
1437
- }
1438
- }
1439
- willUpdate(_changedProperties) {
1440
- if (!this.computedContext) return;
1441
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
1442
- if (!testPart) return;
1443
- this.sectionItems = testPart.sections.flatMap((section) => section.items);
1444
- this.itemIndex = this.sectionItems.findIndex((item) => item.active);
1445
- this.checkDisabled();
1446
- }
1447
- checkDisabled() {
1448
- this._internalDisabled = !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
1449
- }
1450
- _requestItem(identifier) {
1451
- this.dispatchEvent(
1452
- new CustomEvent("qti-request-navigation", {
1453
- composed: true,
1454
- bubbles: true,
1455
- detail: {
1456
- type: "item",
1457
- id: identifier
1458
- }
1459
- })
1460
- );
1461
- }
1462
- render() {
1463
- return T`<slot></slot>`;
1464
- }
1465
- };
1466
- TestPrev.styles = i`
1467
- :host {
1468
- ${btn};
1469
- }
1470
- :host([disabled]) {
1471
- ${dis};
1472
- }
1473
- `;
1474
- __decorateClass([
1475
- n({ type: Boolean, reflect: true, attribute: "disabled" })
1476
- ], TestPrev.prototype, "_internalDisabled", 2);
1477
- __decorateClass([
1478
- c({ context: computedContext, subscribe: true })
1479
- ], TestPrev.prototype, "computedContext", 2);
1480
- __decorateClass([
1481
- watch("computedContext")
1482
- ], TestPrev.prototype, "_handleTestElementChange", 1);
1483
- TestPrev = __decorateClass([
1484
- t("test-prev")
1485
- ], TestPrev);
1486
-
1487
- // ../qti-test/src/components/test-view-toggle/test-view.ts
1488
- var _TestView_instances, updateViewOptions_fn;
1489
- var TestView = class extends i2 {
1490
- constructor() {
1491
- super(...arguments);
1492
- __privateAdd(this, _TestView_instances);
1493
- this.label = "view";
1494
- this._handleViewOptionsChange = () => {
1495
- __privateMethod(this, _TestView_instances, updateViewOptions_fn).call(this);
1496
- };
1497
- this._viewOptions = TestView.DEFAULT_VIEW_OPTIONS;
1498
- }
1499
- connectedCallback() {
1500
- super.connectedCallback();
1501
- __privateMethod(this, _TestView_instances, updateViewOptions_fn).call(this);
1502
- }
1503
- _switchView(view) {
1504
- this.dispatchEvent(
1505
- new CustomEvent("on-test-switch-view", {
1506
- composed: true,
1507
- bubbles: true,
1508
- detail: view
1509
- })
1510
- );
1511
- }
1512
- render() {
1513
- return T`
1514
- <label part="label" for="viewSelect">${this.label}</label>
1515
- <select
1516
- part="select"
1517
- id="viewSelect"
1518
- @change=${(e3) => {
1519
- const el = e3.target;
1520
- this._switchView(el.value);
1521
- }}
1522
- >
1523
- ${this._viewOptions.map(
1524
- (v2) => T`<option value="${v2}" ?selected=${v2 === this.sessionContext.view}>${v2}</option>`
1525
- )}
1526
- </select>
1527
- `;
1528
- }
1529
- };
1530
- _TestView_instances = new WeakSet();
1531
- updateViewOptions_fn = function() {
1532
- if (this.viewOptions) {
1533
- const options = this.viewOptions.split(",").map((opt) => opt.trim());
1534
- this._viewOptions = options.filter((opt) => TestView.DEFAULT_VIEW_OPTIONS.includes(opt));
1535
- } else {
1536
- this._viewOptions = TestView.DEFAULT_VIEW_OPTIONS;
1537
- }
1538
- };
1539
- TestView.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
1540
- __decorateClass([
1541
- c({ context: sessionContext, subscribe: true })
1542
- ], TestView.prototype, "sessionContext", 2);
1543
- __decorateClass([
1544
- n({ type: String })
1545
- ], TestView.prototype, "label", 2);
1546
- __decorateClass([
1547
- n({ type: String, attribute: "view-options" })
1548
- ], TestView.prototype, "viewOptions", 2);
1549
- __decorateClass([
1550
- watch("viewOptions", { waitUntilFirstUpdate: true })
1551
- ], TestView.prototype, "_handleViewOptionsChange", 2);
1552
- __decorateClass([
1553
- r()
1554
- ], TestView.prototype, "_viewOptions", 2);
1555
- TestView = __decorateClass([
1556
- t("test-view")
1557
- ], TestView);
1558
-
1559
- // ../qti-test/src/components/test-item-link/test-item-link.ts
1560
- var TestItemLink = class extends i2 {
1561
- constructor() {
1562
- super();
1563
- this.itemId = null;
1564
- this.addEventListener("click", () => this._requestItem(this.itemId));
1565
- }
1566
- _requestItem(identifier) {
1567
- this.dispatchEvent(
1568
- new CustomEvent("qti-request-navigation", {
1569
- composed: true,
1570
- bubbles: true,
1571
- detail: {
1572
- type: "item",
1573
- id: identifier
1574
- }
1575
- })
1576
- );
1577
- }
1578
- render() {
1579
- return T` <slot></slot> `;
1580
- }
1581
- };
1582
- TestItemLink.styles = i`
1583
- :host {
1584
- ${btn};
1585
- }
1586
- :host([disabled]) {
1587
- ${dis};
1588
- }
1589
- `;
1590
- __decorateClass([
1591
- n({ type: String, attribute: "item-id" })
1592
- ], TestItemLink.prototype, "itemId", 2);
1593
- TestItemLink = __decorateClass([
1594
- t("test-item-link")
1595
- ], TestItemLink);
1596
-
1597
- // ../qti-test/src/components/test-end-attempt/test-end-attempt.ts
1598
- var TestEndAttempt = class extends i2 {
1599
- constructor() {
1600
- super();
1601
- this.addEventListener("click", () => this.dispatchEvent(new CustomEvent("test-end-attempt", { bubbles: true })));
1602
- }
1603
- render() {
1604
- return T` <slot></slot> `;
1605
- }
1606
- };
1607
- TestEndAttempt.styles = i`
1608
- :host {
1609
- ${btn};
1610
- }
1611
- :host([disabled]) {
1612
- ${dis};
1613
- }
1614
- `;
1615
- TestEndAttempt = __decorateClass([
1616
- t("test-end-attempt")
1617
- ], TestEndAttempt);
1618
-
1619
- // ../qti-test/src/components/test-show-correct-response/test-show-correct-response.ts
1620
- var _previousActiveItem, _TestShowCorrectResponse_instances, toggleState_fn, getDisplayedText_fn;
1621
- var TestShowCorrectResponse = class extends i2 {
1622
- constructor() {
1623
- super(...arguments);
1624
- __privateAdd(this, _TestShowCorrectResponse_instances);
1625
- this.shown = false;
1626
- this.disabled = false;
1627
- this.showCorrectText = "Show correct response";
1628
- this.hideCorrectText = "Hide correct response";
1629
- this.noCorrectResponseText = "No correct response specified";
1630
- __privateAdd(this, _previousActiveItem);
1631
- }
1632
- // Store previous active item reference
1633
- willUpdate(_changedProperties) {
1634
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
1635
- if (__privateGet(this, _previousActiveItem) !== activeItem) {
1636
- this.shown = false;
1637
- __privateSet(this, _previousActiveItem, activeItem);
1638
- }
1639
- if (activeItem) {
1640
- const containsCorrectResponse = !!activeItem?.variables?.some((v2) => v2["correctResponse"]);
1641
- const containsMapping = !!activeItem?.variables?.some((v2) => {
1642
- return v2["mapping"]?.mapEntries?.length > 0 || v2["areaMapping"]?.areaMapEntries?.length > 0;
1643
- });
1644
- this.disabled = !containsCorrectResponse && !containsMapping;
1645
- } else {
1646
- this.disabled = true;
1647
- }
1648
- }
1649
- render() {
1650
- return T` <div @click="${__privateMethod(this, _TestShowCorrectResponse_instances, toggleState_fn)}">${__privateMethod(this, _TestShowCorrectResponse_instances, getDisplayedText_fn).call(this)}</div> `;
1651
- }
1652
- };
1653
- _previousActiveItem = new WeakMap();
1654
- _TestShowCorrectResponse_instances = new WeakSet();
1655
- toggleState_fn = function() {
1656
- if (this.disabled) return;
1657
- this.shown = !this.shown;
1658
- this.dispatchEvent(
1659
- new CustomEvent("test-show-correct-response", {
1660
- detail: this.shown,
1661
- bubbles: true
1662
- })
1663
- );
1664
- };
1665
- getDisplayedText_fn = function() {
1666
- return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;
1667
- };
1668
- TestShowCorrectResponse.styles = i`
1669
- :host {
1670
- ${btn};
1671
- }
1672
- :host([disabled]) {
1673
- ${dis};
1674
- }
1675
- `;
1676
- __decorateClass([
1677
- c({ context: computedContext, subscribe: true })
1678
- ], TestShowCorrectResponse.prototype, "computedContext", 2);
1679
- __decorateClass([
1680
- n({ type: Boolean, reflect: true })
1681
- ], TestShowCorrectResponse.prototype, "shown", 2);
1682
- __decorateClass([
1683
- n({ type: Boolean, reflect: true })
1684
- ], TestShowCorrectResponse.prototype, "disabled", 2);
1685
- __decorateClass([
1686
- n({ type: String })
1687
- ], TestShowCorrectResponse.prototype, "showCorrectText", 2);
1688
- __decorateClass([
1689
- n({ type: String })
1690
- ], TestShowCorrectResponse.prototype, "hideCorrectText", 2);
1691
- __decorateClass([
1692
- n({ type: String })
1693
- ], TestShowCorrectResponse.prototype, "noCorrectResponseText", 2);
1694
- TestShowCorrectResponse = __decorateClass([
1695
- t("test-show-correct-response")
1696
- ], TestShowCorrectResponse);
1697
-
1698
- // ../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/node/lit-html.js
1699
- var t2 = globalThis;
1700
- var i3 = t2.trustedTypes;
1701
- var s = i3 ? i3.createPolicy("lit-html", { createHTML: (t3) => t3 }) : void 0;
1702
- var e2 = "$lit$";
1703
- var h = `lit$${Math.random().toFixed(9).slice(2)}$`;
1704
- var o = "?" + h;
1705
- var n2 = `<${o}>`;
1706
- var r2 = void 0 === t2.document ? { createTreeWalker: () => ({}) } : document;
1707
- var l = () => r2.createComment("");
1708
- var c2 = (t3) => null === t3 || "object" != typeof t3 && "function" != typeof t3;
1709
- var a = Array.isArray;
1710
- var u = (t3) => a(t3) || "function" == typeof t3?.[Symbol.iterator];
1711
- var d = "[ \n\f\r]";
1712
- var f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
1713
- var v = /-->/g;
1714
- var _ = />/g;
1715
- var m2 = RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^
1716
- \f\r"'\`<>=]|("|')|))|$)`, "g");
1717
- var p = /'/g;
1718
- var g = /"/g;
1719
- var $ = /^(?:script|style|textarea|title)$/i;
1720
- var y = (t3) => (i5, ...s2) => ({ _$litType$: t3, strings: i5, values: s2 });
1721
- var x = y(1);
1722
- var T2 = y(2);
1723
- var b = y(3);
1724
- var w = /* @__PURE__ */ Symbol.for("lit-noChange");
1725
- var E = /* @__PURE__ */ Symbol.for("lit-nothing");
1726
- var A2 = /* @__PURE__ */ new WeakMap();
1727
- var C = r2.createTreeWalker(r2, 129);
1728
- function P(t3, i5) {
1729
- if (!a(t3) || !t3.hasOwnProperty("raw")) throw Error("invalid template strings array");
1730
- return void 0 !== s ? s.createHTML(i5) : i5;
1731
- }
1732
- var V = (t3, i5) => {
1733
- const s2 = t3.length - 1, o2 = [];
1734
- let r4, l2 = 2 === i5 ? "<svg>" : 3 === i5 ? "<math>" : "", c3 = f;
1735
- for (let i6 = 0; i6 < s2; i6++) {
1736
- const s3 = t3[i6];
1737
- let a2, u2, d2 = -1, y2 = 0;
1738
- for (; y2 < s3.length && (c3.lastIndex = y2, u2 = c3.exec(s3), null !== u2); ) y2 = c3.lastIndex, c3 === f ? "!--" === u2[1] ? c3 = v : void 0 !== u2[1] ? c3 = _ : void 0 !== u2[2] ? ($.test(u2[2]) && (r4 = RegExp("</" + u2[2], "g")), c3 = m2) : void 0 !== u2[3] && (c3 = m2) : c3 === m2 ? ">" === u2[0] ? (c3 = r4 ?? f, d2 = -1) : void 0 === u2[1] ? d2 = -2 : (d2 = c3.lastIndex - u2[2].length, a2 = u2[1], c3 = void 0 === u2[3] ? m2 : '"' === u2[3] ? g : p) : c3 === g || c3 === p ? c3 = m2 : c3 === v || c3 === _ ? c3 = f : (c3 = m2, r4 = void 0);
1739
- const x2 = c3 === m2 && t3[i6 + 1].startsWith("/>") ? " " : "";
1740
- l2 += c3 === f ? s3 + n2 : d2 >= 0 ? (o2.push(a2), s3.slice(0, d2) + e2 + s3.slice(d2) + h + x2) : s3 + h + (-2 === d2 ? i6 : x2);
1741
- }
1742
- return [P(t3, l2 + (t3[s2] || "<?>") + (2 === i5 ? "</svg>" : 3 === i5 ? "</math>" : "")), o2];
1743
- };
1744
- var N = class _N {
1745
- constructor({ strings: t3, _$litType$: s2 }, n3) {
1746
- let r4;
1747
- this.parts = [];
1748
- let c3 = 0, a2 = 0;
1749
- const u2 = t3.length - 1, d2 = this.parts, [f2, v2] = V(t3, s2);
1750
- if (this.el = _N.createElement(f2, n3), C.currentNode = this.el.content, 2 === s2 || 3 === s2) {
1751
- const t4 = this.el.content.firstChild;
1752
- t4.replaceWith(...t4.childNodes);
1753
- }
1754
- for (; null !== (r4 = C.nextNode()) && d2.length < u2; ) {
1755
- if (1 === r4.nodeType) {
1756
- if (r4.hasAttributes()) for (const t4 of r4.getAttributeNames()) if (t4.endsWith(e2)) {
1757
- const i5 = v2[a2++], s3 = r4.getAttribute(t4).split(h), e3 = /([.?@])?(.*)/.exec(i5);
1758
- d2.push({ type: 1, index: c3, name: e3[2], strings: s3, ctor: "." === e3[1] ? H : "?" === e3[1] ? I : "@" === e3[1] ? L : R }), r4.removeAttribute(t4);
1759
- } else t4.startsWith(h) && (d2.push({ type: 6, index: c3 }), r4.removeAttribute(t4));
1760
- if ($.test(r4.tagName)) {
1761
- const t4 = r4.textContent.split(h), s3 = t4.length - 1;
1762
- if (s3 > 0) {
1763
- r4.textContent = i3 ? i3.emptyScript : "";
1764
- for (let i5 = 0; i5 < s3; i5++) r4.append(t4[i5], l()), C.nextNode(), d2.push({ type: 2, index: ++c3 });
1765
- r4.append(t4[s3], l());
1766
- }
1767
- }
1768
- } else if (8 === r4.nodeType) if (r4.data === o) d2.push({ type: 2, index: c3 });
1769
- else {
1770
- let t4 = -1;
1771
- for (; -1 !== (t4 = r4.data.indexOf(h, t4 + 1)); ) d2.push({ type: 7, index: c3 }), t4 += h.length - 1;
1772
- }
1773
- c3++;
1774
- }
1775
- }
1776
- static createElement(t3, i5) {
1777
- const s2 = r2.createElement("template");
1778
- return s2.innerHTML = t3, s2;
1779
- }
1780
- };
1781
- function S(t3, i5, s2 = t3, e3) {
1782
- if (i5 === w) return i5;
1783
- let h2 = void 0 !== e3 ? s2._$Co?.[e3] : s2._$Cl;
1784
- const o2 = c2(i5) ? void 0 : i5._$litDirective$;
1785
- return h2?.constructor !== o2 && (h2?._$AO?.(false), void 0 === o2 ? h2 = void 0 : (h2 = new o2(t3), h2._$AT(t3, s2, e3)), void 0 !== e3 ? (s2._$Co ??= [])[e3] = h2 : s2._$Cl = h2), void 0 !== h2 && (i5 = S(t3, h2._$AS(t3, i5.values), h2, e3)), i5;
1786
- }
1787
- var M = class {
1788
- constructor(t3, i5) {
1789
- this._$AV = [], this._$AN = void 0, this._$AD = t3, this._$AM = i5;
1790
- }
1791
- get parentNode() {
1792
- return this._$AM.parentNode;
1793
- }
1794
- get _$AU() {
1795
- return this._$AM._$AU;
1796
- }
1797
- u(t3) {
1798
- const { el: { content: i5 }, parts: s2 } = this._$AD, e3 = (t3?.creationScope ?? r2).importNode(i5, true);
1799
- C.currentNode = e3;
1800
- let h2 = C.nextNode(), o2 = 0, n3 = 0, l2 = s2[0];
1801
- for (; void 0 !== l2; ) {
1802
- if (o2 === l2.index) {
1803
- let i6;
1804
- 2 === l2.type ? i6 = new k(h2, h2.nextSibling, this, t3) : 1 === l2.type ? i6 = new l2.ctor(h2, l2.name, l2.strings, this, t3) : 6 === l2.type && (i6 = new z(h2, this, t3)), this._$AV.push(i6), l2 = s2[++n3];
1805
- }
1806
- o2 !== l2?.index && (h2 = C.nextNode(), o2++);
1807
- }
1808
- return C.currentNode = r2, e3;
1809
- }
1810
- p(t3) {
1811
- let i5 = 0;
1812
- for (const s2 of this._$AV) void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t3, s2, i5), i5 += s2.strings.length - 2) : s2._$AI(t3[i5])), i5++;
1813
- }
1915
+ c({ context: sessionContext, subscribe: true })
1916
+ ], TestNavigation.prototype, "_sessionContext", void 0);
1917
+ __decorate11([
1918
+ r(),
1919
+ e({ context: computedContext })
1920
+ ], TestNavigation.prototype, "computedContext", void 0);
1921
+ __decorate11([
1922
+ n2({ type: Boolean, attribute: "auto-score-items" })
1923
+ ], TestNavigation.prototype, "autoScoreItems", void 0);
1924
+
1925
+ // ../qti-test/dist/components/test-next/test-next.js
1926
+ var __decorate12 = function(decorators, target, key, desc) {
1927
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1928
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
1929
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
1930
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
1814
1931
  };
1815
- var k = class _k {
1816
- get _$AU() {
1817
- return this._$AM?._$AU ?? this._$Cv;
1818
- }
1819
- constructor(t3, i5, s2, e3) {
1820
- this.type = 2, this._$AH = E, this._$AN = void 0, this._$AA = t3, this._$AB = i5, this._$AM = s2, this.options = e3, this._$Cv = e3?.isConnected ?? true;
1821
- }
1822
- get parentNode() {
1823
- let t3 = this._$AA.parentNode;
1824
- const i5 = this._$AM;
1825
- return void 0 !== i5 && 11 === t3?.nodeType && (t3 = i5.parentNode), t3;
1826
- }
1827
- get startNode() {
1828
- return this._$AA;
1829
- }
1830
- get endNode() {
1831
- return this._$AB;
1832
- }
1833
- _$AI(t3, i5 = this) {
1834
- t3 = S(this, t3, i5), c2(t3) ? t3 === E || null == t3 || "" === t3 ? (this._$AH !== E && this._$AR(), this._$AH = E) : t3 !== this._$AH && t3 !== w && this._(t3) : void 0 !== t3._$litType$ ? this.$(t3) : void 0 !== t3.nodeType ? this.T(t3) : u(t3) ? this.k(t3) : this._(t3);
1835
- }
1836
- O(t3) {
1837
- return this._$AA.parentNode.insertBefore(t3, this._$AB);
1838
- }
1839
- T(t3) {
1840
- this._$AH !== t3 && (this._$AR(), this._$AH = this.O(t3));
1841
- }
1842
- _(t3) {
1843
- this._$AH !== E && c2(this._$AH) ? this._$AA.nextSibling.data = t3 : this.T(r2.createTextNode(t3)), this._$AH = t3;
1844
- }
1845
- $(t3) {
1846
- const { values: i5, _$litType$: s2 } = t3, e3 = "number" == typeof s2 ? this._$AC(t3) : (void 0 === s2.el && (s2.el = N.createElement(P(s2.h, s2.h[0]), this.options)), s2);
1847
- if (this._$AH?._$AD === e3) this._$AH.p(i5);
1848
- else {
1849
- const t4 = new M(e3, this), s3 = t4.u(this.options);
1850
- t4.p(i5), this.T(s3), this._$AH = t4;
1932
+ var TestNext = class extends i2 {
1933
+ _handleTestElementChange(_oldValue, newValue) {
1934
+ if (newValue) {
1935
+ this._internalDisabled = false;
1851
1936
  }
1852
1937
  }
1853
- _$AC(t3) {
1854
- let i5 = A2.get(t3.strings);
1855
- return void 0 === i5 && A2.set(t3.strings, i5 = new N(t3)), i5;
1856
- }
1857
- k(t3) {
1858
- a(this._$AH) || (this._$AH = [], this._$AR());
1859
- const i5 = this._$AH;
1860
- let s2, e3 = 0;
1861
- for (const h2 of t3) e3 === i5.length ? i5.push(s2 = new _k(this.O(l()), this.O(l()), this, this.options)) : s2 = i5[e3], s2._$AI(h2), e3++;
1862
- e3 < i5.length && (this._$AR(s2 && s2._$AB.nextSibling, e3), i5.length = e3);
1863
- }
1864
- _$AR(t3 = this._$AA.nextSibling, i5) {
1865
- for (this._$AP?.(false, true, i5); t3 !== this._$AB; ) {
1866
- const i6 = t3.nextSibling;
1867
- t3.remove(), t3 = i6;
1938
+ static {
1939
+ this.styles = i`
1940
+ :host {
1941
+ ${btn};
1868
1942
  }
1869
- }
1870
- setConnected(t3) {
1871
- void 0 === this._$AM && (this._$Cv = t3, this._$AP?.(t3));
1872
- }
1873
- };
1874
- var R = class {
1875
- get tagName() {
1876
- return this.element.tagName;
1877
- }
1878
- get _$AU() {
1879
- return this._$AM._$AU;
1880
- }
1881
- constructor(t3, i5, s2, e3, h2) {
1882
- this.type = 1, this._$AH = E, this._$AN = void 0, this.element = t3, this.name = i5, this._$AM = e3, this.options = h2, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = E;
1883
- }
1884
- _$AI(t3, i5 = this, s2, e3) {
1885
- const h2 = this.strings;
1886
- let o2 = false;
1887
- if (void 0 === h2) t3 = S(this, t3, i5, 0), o2 = !c2(t3) || t3 !== this._$AH && t3 !== w, o2 && (this._$AH = t3);
1888
- else {
1889
- const e4 = t3;
1890
- let n3, r4;
1891
- for (t3 = h2[0], n3 = 0; n3 < h2.length - 1; n3++) r4 = S(this, e4[s2 + n3], i5, n3), r4 === w && (r4 = this._$AH[n3]), o2 ||= !c2(r4) || r4 !== this._$AH[n3], r4 === E ? t3 = E : t3 !== E && (t3 += (r4 ?? "") + h2[n3 + 1]), this._$AH[n3] = r4;
1943
+ :host([disabled]) {
1944
+ ${dis};
1892
1945
  }
1893
- o2 && !e3 && this.j(t3);
1894
- }
1895
- j(t3) {
1896
- t3 === E ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t3 ?? "");
1897
- }
1898
- };
1899
- var H = class extends R {
1900
- constructor() {
1901
- super(...arguments), this.type = 3;
1902
- }
1903
- j(t3) {
1904
- this.element[this.name] = t3 === E ? void 0 : t3;
1946
+ `;
1905
1947
  }
1906
- };
1907
- var I = class extends R {
1948
+ #internals;
1908
1949
  constructor() {
1909
- super(...arguments), this.type = 4;
1910
- }
1911
- j(t3) {
1912
- this.element.toggleAttribute(this.name, !!t3 && t3 !== E);
1913
- }
1914
- };
1915
- var L = class extends R {
1916
- constructor(t3, i5, s2, e3, h2) {
1917
- super(t3, i5, s2, e3, h2), this.type = 5;
1950
+ super();
1951
+ this._internalDisabled = true;
1952
+ this.#internals = this.attachInternals();
1953
+ this.#internals.role = "button";
1954
+ this.#internals.ariaLabel = "Next item";
1955
+ this.addEventListener("click", (e2) => {
1956
+ e2.preventDefault();
1957
+ if (!this._internalDisabled)
1958
+ this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);
1959
+ });
1918
1960
  }
1919
- _$AI(t3, i5 = this) {
1920
- if ((t3 = S(this, t3, i5, 0) ?? E) === w) return;
1921
- const s2 = this._$AH, e3 = t3 === E && s2 !== E || t3.capture !== s2.capture || t3.once !== s2.once || t3.passive !== s2.passive, h2 = t3 !== E && (s2 === E || e3);
1922
- e3 && this.element.removeEventListener(this.name, this, s2), h2 && this.element.addEventListener(this.name, this, t3), this._$AH = t3;
1961
+ connectedCallback() {
1962
+ super.connectedCallback();
1963
+ this.checkDisabled();
1923
1964
  }
1924
- handleEvent(t3) {
1925
- "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t3) : this._$AH.handleEvent(t3);
1965
+ willUpdate(_changedProperties) {
1966
+ if (!this.computedContext)
1967
+ return;
1968
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
1969
+ if (!testPart)
1970
+ return;
1971
+ this.sectionItems = testPart.sections.flatMap((section) => section.items);
1972
+ this.itemIndex = this.sectionItems.findIndex((item) => item.active);
1973
+ this.checkDisabled();
1926
1974
  }
1927
- };
1928
- var z = class {
1929
- constructor(t3, i5, s2) {
1930
- this.element = t3, this.type = 6, this._$AN = void 0, this._$AM = i5, this.options = s2;
1975
+ checkDisabled() {
1976
+ this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= this.sectionItems?.length - 1;
1931
1977
  }
1932
- get _$AU() {
1933
- return this._$AM._$AU;
1978
+ _requestItem(identifier) {
1979
+ this.dispatchEvent(new CustomEvent("qti-request-navigation", {
1980
+ composed: true,
1981
+ bubbles: true,
1982
+ detail: {
1983
+ type: "item",
1984
+ id: identifier
1985
+ }
1986
+ }));
1934
1987
  }
1935
- _$AI(t3) {
1936
- S(this, t3);
1988
+ render() {
1989
+ return T`<slot></slot>`;
1937
1990
  }
1938
1991
  };
1939
- var W = { M: e2, P: h, A: o, C: 1, L: V, R: M, D: u, V: S, I: k, H: R, N: I, U: L, B: H, F: z };
1940
- var Z = t2.litHtmlPolyfillSupport;
1941
- Z?.(N, k), (t2.litHtmlVersions ??= []).push("3.3.1");
1992
+ __decorate12([
1993
+ n2({ type: Boolean, reflect: true, attribute: "disabled" })
1994
+ ], TestNext.prototype, "_internalDisabled", void 0);
1995
+ __decorate12([
1996
+ c({ context: computedContext, subscribe: true })
1997
+ ], TestNext.prototype, "computedContext", void 0);
1998
+ __decorate12([
1999
+ watch("computedContext")
2000
+ ], TestNext.prototype, "_handleTestElementChange", null);
1942
2001
 
1943
2002
  // ../../node_modules/.pnpm/@heximal+expressions@0.1.5/node_modules/@heximal/expressions/lib/constants.js
1944
2003
  var KEYWORDS = ["this"];
@@ -2104,11 +2163,11 @@ var Tokenizer = class {
2104
2163
  }
2105
2164
  }
2106
2165
  #getValue(lookahead = 0) {
2107
- const v2 = this.#input.substring(this.#tokenStart, this.#index + lookahead);
2166
+ const v = this.#input.substring(this.#tokenStart, this.#index + lookahead);
2108
2167
  if (lookahead === 0) {
2109
2168
  this.#clearValue();
2110
2169
  }
2111
- return v2;
2170
+ return v;
2112
2171
  }
2113
2172
  #clearValue() {
2114
2173
  this.#tokenStart = this.#index;
@@ -2127,9 +2186,9 @@ var Tokenizer = class {
2127
2186
  }
2128
2187
  this.#advance();
2129
2188
  }
2130
- const t3 = token(Kind.STRING, escapeString(this.#getValue()));
2189
+ const t = token(Kind.STRING, escapeString(this.#getValue()));
2131
2190
  this.#advance();
2132
- return t3;
2191
+ return t;
2133
2192
  }
2134
2193
  #tokenizeIdentOrKeyword() {
2135
2194
  do {
@@ -2189,9 +2248,9 @@ var Tokenizer = class {
2189
2248
  }
2190
2249
  #tokenizeGrouper() {
2191
2250
  const value = String.fromCharCode(this.#next);
2192
- const t3 = token(Kind.GROUPER, value, PRECEDENCE[value]);
2251
+ const t = token(Kind.GROUPER, value, PRECEDENCE[value]);
2193
2252
  this.#advance(true);
2194
- return t3;
2253
+ return t;
2195
2254
  }
2196
2255
  };
2197
2256
 
@@ -2215,10 +2274,10 @@ var Parser = class {
2215
2274
  if (!this._matches(kind, value)) {
2216
2275
  throw new Error(`Expected kind ${kind} (${value}), was ${this.#token?.kind} (${this.#token?.value})`);
2217
2276
  }
2218
- const t3 = this.#tokenizer.nextToken();
2219
- this.#token = t3;
2220
- this.#kind = t3?.kind;
2221
- this.#value = t3?.value;
2277
+ const t = this.#tokenizer.nextToken();
2278
+ this.#token = t;
2279
+ this.#kind = t?.kind;
2280
+ this.#value = t?.value;
2222
2281
  }
2223
2282
  _matches(kind, value) {
2224
2283
  return !(kind && this.#kind !== kind || value && this.#value !== value);
@@ -2424,7 +2483,7 @@ var Parser = class {
2424
2483
  if (this._matches(Kind.ARROW)) {
2425
2484
  this.#advance();
2426
2485
  const body = this.#parseExpression();
2427
- const params = expressions?.map((e3) => e3.value) ?? [];
2486
+ const params = expressions?.map((e2) => e2.value) ?? [];
2428
2487
  return this.#ast.arrowFunction(params, body);
2429
2488
  } else {
2430
2489
  return this.#ast.paren(expressions[0]);
@@ -2450,29 +2509,29 @@ var Parser = class {
2450
2509
  // ../../node_modules/.pnpm/@heximal+expressions@0.1.5/node_modules/@heximal/expressions/lib/eval.js
2451
2510
  var { hasOwn, fromEntries } = Object;
2452
2511
  var _BINARY_OPERATORS = {
2453
- "+": (a2, b2) => a2 + b2,
2454
- "-": (a2, b2) => a2 - b2,
2455
- "*": (a2, b2) => a2 * b2,
2456
- "/": (a2, b2) => a2 / b2,
2457
- "%": (a2, b2) => a2 % b2,
2458
- "==": (a2, b2) => a2 == b2,
2459
- "!=": (a2, b2) => a2 != b2,
2460
- "===": (a2, b2) => a2 === b2,
2461
- "!==": (a2, b2) => a2 !== b2,
2462
- ">": (a2, b2) => a2 > b2,
2463
- ">=": (a2, b2) => a2 >= b2,
2464
- "<": (a2, b2) => a2 < b2,
2465
- "<=": (a2, b2) => a2 <= b2,
2466
- "||": (a2, b2) => a2 || b2,
2467
- "&&": (a2, b2) => a2 && b2,
2468
- "??": (a2, b2) => a2 ?? b2,
2469
- "|": (a2, f2) => f2(a2),
2470
- "|>": (a2, f2) => f2(a2)
2512
+ "+": (a, b) => a + b,
2513
+ "-": (a, b) => a - b,
2514
+ "*": (a, b) => a * b,
2515
+ "/": (a, b) => a / b,
2516
+ "%": (a, b) => a % b,
2517
+ "==": (a, b) => a == b,
2518
+ "!=": (a, b) => a != b,
2519
+ "===": (a, b) => a === b,
2520
+ "!==": (a, b) => a !== b,
2521
+ ">": (a, b) => a > b,
2522
+ ">=": (a, b) => a >= b,
2523
+ "<": (a, b) => a < b,
2524
+ "<=": (a, b) => a <= b,
2525
+ "||": (a, b) => a || b,
2526
+ "&&": (a, b) => a && b,
2527
+ "??": (a, b) => a ?? b,
2528
+ "|": (a, f) => f(a),
2529
+ "|>": (a, f) => f(a)
2471
2530
  };
2472
2531
  var _UNARY_OPERATORS = {
2473
- "+": (a2) => a2,
2474
- "-": (a2) => -a2,
2475
- "!": (a2) => !a2
2532
+ "+": (a) => a,
2533
+ "-": (a) => -a,
2534
+ "!": (a) => !a
2476
2535
  };
2477
2536
  var EvalAstFactory = class {
2478
2537
  empty() {
@@ -2487,10 +2546,10 @@ var EvalAstFactory = class {
2487
2546
  };
2488
2547
  }
2489
2548
  // TODO(justinfagnani): just use a JS literal?
2490
- literal(v2) {
2549
+ literal(v) {
2491
2550
  return {
2492
2551
  type: "Literal",
2493
- value: v2,
2552
+ value: v,
2494
2553
  evaluate(_scope) {
2495
2554
  return this.value;
2496
2555
  },
@@ -2499,10 +2558,10 @@ var EvalAstFactory = class {
2499
2558
  }
2500
2559
  };
2501
2560
  }
2502
- id(v2) {
2561
+ id(v) {
2503
2562
  return {
2504
2563
  type: "ID",
2505
- value: v2,
2564
+ value: v,
2506
2565
  evaluate(scope) {
2507
2566
  if (this.value === "this")
2508
2567
  return scope;
@@ -2515,26 +2574,26 @@ var EvalAstFactory = class {
2515
2574
  };
2516
2575
  }
2517
2576
  unary(op, expr) {
2518
- const f2 = _UNARY_OPERATORS[op];
2577
+ const f = _UNARY_OPERATORS[op];
2519
2578
  return {
2520
2579
  type: "Unary",
2521
2580
  operator: op,
2522
2581
  child: expr,
2523
2582
  evaluate(scope) {
2524
- return f2(this.child.evaluate(scope));
2583
+ return f(this.child.evaluate(scope));
2525
2584
  },
2526
2585
  getIds(idents) {
2527
2586
  return this.child.getIds(idents);
2528
2587
  }
2529
2588
  };
2530
2589
  }
2531
- binary(l2, op, r4) {
2532
- const f2 = _BINARY_OPERATORS[op];
2590
+ binary(l, op, r3) {
2591
+ const f = _BINARY_OPERATORS[op];
2533
2592
  return {
2534
2593
  type: "Binary",
2535
2594
  operator: op,
2536
- left: l2,
2537
- right: r4,
2595
+ left: l,
2596
+ right: r3,
2538
2597
  evaluate(scope) {
2539
2598
  if (this.operator === "=") {
2540
2599
  if (this.left.type !== "ID" && this.left.type !== "Getter" && this.left.type !== "Index") {
@@ -2555,7 +2614,7 @@ var EvalAstFactory = class {
2555
2614
  }
2556
2615
  return receiver === void 0 ? void 0 : receiver[property] = value;
2557
2616
  }
2558
- return f2(this.left.evaluate(scope), this.right.evaluate(scope));
2617
+ return f(this.left.evaluate(scope), this.right.evaluate(scope));
2559
2618
  },
2560
2619
  getIds(idents) {
2561
2620
  this.left.getIds(idents);
@@ -2564,10 +2623,10 @@ var EvalAstFactory = class {
2564
2623
  }
2565
2624
  };
2566
2625
  }
2567
- getter(g2, n3) {
2626
+ getter(g, n3) {
2568
2627
  return {
2569
2628
  type: "Getter",
2570
- receiver: g2,
2629
+ receiver: g,
2571
2630
  name: n3,
2572
2631
  evaluate(scope) {
2573
2632
  return this.receiver.evaluate(scope)?.[this.name];
@@ -2590,26 +2649,26 @@ var EvalAstFactory = class {
2590
2649
  evaluate(scope) {
2591
2650
  const receiver2 = this.receiver.evaluate(scope);
2592
2651
  const _this = this.method ? receiver2 : scope?.["this"] ?? scope;
2593
- const f2 = this.method ? receiver2?.[method] : receiver2;
2652
+ const f = this.method ? receiver2?.[method] : receiver2;
2594
2653
  const args2 = this.arguments ?? [];
2595
- const argValues = args2.map((a2) => a2?.evaluate(scope));
2596
- return f2?.apply?.(_this, argValues);
2654
+ const argValues = args2.map((a) => a?.evaluate(scope));
2655
+ return f?.apply?.(_this, argValues);
2597
2656
  },
2598
2657
  getIds(idents) {
2599
2658
  this.receiver.getIds(idents);
2600
- this.arguments?.forEach((a2) => a2?.getIds(idents));
2659
+ this.arguments?.forEach((a) => a?.getIds(idents));
2601
2660
  return idents;
2602
2661
  }
2603
2662
  };
2604
2663
  }
2605
- paren(e3) {
2606
- return e3;
2664
+ paren(e2) {
2665
+ return e2;
2607
2666
  }
2608
- index(e3, a2) {
2667
+ index(e2, a) {
2609
2668
  return {
2610
2669
  type: "Index",
2611
- receiver: e3,
2612
- argument: a2,
2670
+ receiver: e2,
2671
+ argument: a,
2613
2672
  evaluate(scope) {
2614
2673
  return this.receiver.evaluate(scope)?.[this.argument.evaluate(scope)];
2615
2674
  },
@@ -2619,15 +2678,15 @@ var EvalAstFactory = class {
2619
2678
  }
2620
2679
  };
2621
2680
  }
2622
- ternary(c3, t3, f2) {
2681
+ ternary(c2, t, f) {
2623
2682
  return {
2624
2683
  type: "Ternary",
2625
- condition: c3,
2626
- trueExpr: t3,
2627
- falseExpr: f2,
2684
+ condition: c2,
2685
+ trueExpr: t,
2686
+ falseExpr: f,
2628
2687
  evaluate(scope) {
2629
- const c4 = this.condition.evaluate(scope);
2630
- if (c4) {
2688
+ const c3 = this.condition.evaluate(scope);
2689
+ if (c3) {
2631
2690
  return this.trueExpr.evaluate(scope);
2632
2691
  } else {
2633
2692
  return this.falseExpr.evaluate(scope);
@@ -2671,15 +2730,15 @@ var EvalAstFactory = class {
2671
2730
  };
2672
2731
  }
2673
2732
  // TODO(justinfagnani): if the list is deeply literal
2674
- list(l2) {
2733
+ list(l) {
2675
2734
  return {
2676
2735
  type: "List",
2677
- items: l2,
2736
+ items: l,
2678
2737
  evaluate(scope) {
2679
- return this.items?.map((a2) => a2?.evaluate(scope));
2738
+ return this.items?.map((a) => a?.evaluate(scope));
2680
2739
  },
2681
2740
  getIds(idents) {
2682
- this.items?.forEach((i5) => i5?.getIds(idents));
2741
+ this.items?.forEach((i4) => i4?.getIds(idents));
2683
2742
  return idents;
2684
2743
  }
2685
2744
  };
@@ -2693,7 +2752,7 @@ var EvalAstFactory = class {
2693
2752
  const params2 = this.params;
2694
2753
  const body2 = this.body;
2695
2754
  return function(...args) {
2696
- const paramsObj = fromEntries(params2.map((p2, i5) => [p2, args[i5]]));
2755
+ const paramsObj = fromEntries(params2.map((p, i4) => [p, args[i4]]));
2697
2756
  const newScope = new Proxy(scope ?? {}, {
2698
2757
  set(target, prop, value) {
2699
2758
  if (hasOwn(paramsObj, prop)) {
@@ -2718,41 +2777,41 @@ var EvalAstFactory = class {
2718
2777
  }
2719
2778
  };
2720
2779
 
2721
- // ../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/node/private-ssr-support.js
2722
- var r3 = null;
2723
- var i4 = { boundAttributeSuffix: W.M, marker: W.P, markerMatch: W.A, HTML_RESULT: W.C, getTemplateHtml: W.L, overrideDirectiveResolve: (e3, t3) => class extends e3 {
2724
- _$AS(e4, r4) {
2725
- return t3(this, r4);
2726
- }
2727
- }, patchDirectiveResolve: (e3, t3) => {
2728
- if (e3.prototype._$AS.name !== t3.name) {
2729
- r3 ??= e3.prototype._$AS.name;
2730
- for (let i5 = e3.prototype; i5 !== Object.prototype; i5 = Object.getPrototypeOf(i5)) if (i5.hasOwnProperty(r3)) return void (i5[r3] = t3);
2780
+ // ../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/node/private-ssr-support.js
2781
+ var r2 = null;
2782
+ var i3 = { boundAttributeSuffix: Z.M, marker: Z.P, markerMatch: Z.A, HTML_RESULT: Z.C, getTemplateHtml: Z.L, overrideDirectiveResolve: (e2, t) => class extends e2 {
2783
+ _$AS(e3, r3) {
2784
+ return t(this, r3);
2785
+ }
2786
+ }, patchDirectiveResolve: (e2, t) => {
2787
+ if (e2.prototype._$AS.name !== t.name) {
2788
+ r2 ??= e2.prototype._$AS.name;
2789
+ for (let i4 = e2.prototype; i4 !== Object.prototype; i4 = Object.getPrototypeOf(i4)) if (i4.hasOwnProperty(r2)) return void (i4[r2] = t);
2731
2790
  throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527");
2732
2791
  }
2733
- }, setDirectiveClass(e3, t3) {
2734
- e3._$litDirective$ = t3;
2735
- }, getAttributePartCommittedValue: (e3, r4, i5) => {
2736
- let o2 = w;
2737
- return e3.j = (e4) => o2 = e4, e3._$AI(r4, e3, i5), o2;
2738
- }, connectedDisconnectable: (e3) => ({ ...e3, _$AU: true }), resolveDirective: W.V, AttributePart: W.H, PropertyPart: W.B, BooleanAttributePart: W.N, EventPart: W.U, ElementPart: W.F, TemplateInstance: W.R, isIterable: W.D, ChildPart: W.I };
2792
+ }, setDirectiveClass(e2, t) {
2793
+ e2._$litDirective$ = t;
2794
+ }, getAttributePartCommittedValue: (e2, r3, i4) => {
2795
+ let o = E;
2796
+ return e2.j = (e3) => o = e3, e2._$AI(r3, e2, i4), o;
2797
+ }, connectedDisconnectable: (e2) => ({ ...e2, _$AU: true }), resolveDirective: Z.V, AttributePart: Z.H, PropertyPart: Z.B, BooleanAttributePart: Z.N, EventPart: Z.U, ElementPart: Z.F, TemplateInstance: Z.R, isIterable: Z.D, ChildPart: Z.I };
2739
2798
 
2740
2799
  // ../../node_modules/.pnpm/@heximal+templates@0.1.5/node_modules/@heximal/templates/index.js
2741
- var { AttributePart, PropertyPart, BooleanAttributePart, EventPart } = i4;
2800
+ var { AttributePart, PropertyPart, BooleanAttributePart, EventPart } = i3;
2742
2801
  var astFactory = new EvalAstFactory();
2743
2802
  var expressionCache = /* @__PURE__ */ new Map();
2744
- var toCamelCase = (s2) => s2.replace(/-(-|\w)/g, (_2, p1) => p1.toUpperCase());
2745
- var getSingleValue = (s2, model) => {
2746
- let ast = expressionCache.get(s2);
2803
+ var toCamelCase = (s) => s.replace(/-(-|\w)/g, (_, p1) => p1.toUpperCase());
2804
+ var getSingleValue = (s, model) => {
2805
+ let ast = expressionCache.get(s);
2747
2806
  if (ast === void 0) {
2748
- if (expressionCache.has(s2)) {
2807
+ if (expressionCache.has(s)) {
2749
2808
  return void 0;
2750
2809
  }
2751
- s2 = s2.trim();
2752
- if (s2.startsWith("{{") && s2.endsWith("}}")) {
2753
- const expression = s2.substring(2, s2.length - 2).trim();
2810
+ s = s.trim();
2811
+ if (s.startsWith("{{") && s.endsWith("}}")) {
2812
+ const expression = s.substring(2, s.length - 2).trim();
2754
2813
  ast = new Parser(expression, astFactory).parse();
2755
- expressionCache.set(s2, ast);
2814
+ expressionCache.set(s, ast);
2756
2815
  }
2757
2816
  }
2758
2817
  return ast?.evaluate(model);
@@ -2765,14 +2824,14 @@ var ifHandler = (template, model, handlers, renderers) => {
2765
2824
  return void 0;
2766
2825
  };
2767
2826
  var bindingRegex = /(?<!\\){{(.*?)(?:(?<!\\)}})/g;
2768
- var hasEscapedBindingMarkers = (s2) => /(?:\\{{)|(?:\\}})/g.test(s2);
2769
- var unescapeBindingMarkers = (s2) => s2.replaceAll(/\\{{/g, "{{").replace(/\\}}/g, "}}");
2827
+ var hasEscapedBindingMarkers = (s) => /(?:\\{{)|(?:\\}})/g.test(s);
2828
+ var unescapeBindingMarkers = (s) => s.replaceAll(/\\{{/g, "{{").replace(/\\}}/g, "}}");
2770
2829
  var repeatHandler = (template, model, handlers, renderers) => {
2771
2830
  const repeatAttribute = template.getAttribute("repeat");
2772
2831
  if (repeatAttribute !== null) {
2773
2832
  const items = getSingleValue(repeatAttribute, model);
2774
2833
  if (!items[Symbol.iterator]) {
2775
- return E;
2834
+ return A;
2776
2835
  }
2777
2836
  const litTemplate = getLitTemplate(template);
2778
2837
  let index = -1;
@@ -2975,10 +3034,10 @@ var makeLitTemplate = (template) => {
2975
3034
  }
2976
3035
  const strings = [unescapeBindingMarkers(splitValue[0])];
2977
3036
  const exprs = [];
2978
- for (let i5 = 1; i5 < splitValue.length; i5 += 2) {
2979
- const exprText = splitValue[i5];
3037
+ for (let i4 = 1; i4 < splitValue.length; i4 += 2) {
3038
+ const exprText = splitValue[i4];
2980
3039
  exprs.push(parse(exprText, astFactory));
2981
- strings.push(unescapeBindingMarkers(splitValue[i5 + 1]));
3040
+ strings.push(unescapeBindingMarkers(splitValue[i4 + 1]));
2982
3041
  }
2983
3042
  litTemplate.parts.push({
2984
3043
  type: 1,
@@ -3001,15 +3060,15 @@ var makeLitTemplate = (template) => {
3001
3060
  } else if (hasEscapedBindingMarkers(text)) {
3002
3061
  textNode.textContent = unescapeBindingMarkers(text);
3003
3062
  }
3004
- for (let i5 = 1; i5 < strings.length; i5 += 2) {
3005
- const exprText = strings[i5];
3063
+ for (let i4 = 1; i4 < strings.length; i4 += 2) {
3064
+ const exprText = strings[i4];
3006
3065
  const expr = parse(exprText, astFactory);
3007
3066
  litTemplate.parts.push({
3008
3067
  type: 2,
3009
3068
  index: ++nodeIndex,
3010
3069
  update: (model, _handlers) => expr.evaluate(model)
3011
3070
  });
3012
- const newTextNode = new Text(strings[i5 + 1].replace("\\{{", "{{"));
3071
+ const newTextNode = new Text(strings[i4 + 1].replace("\\{{", "{{"));
3013
3072
  textNode.parentNode.insertBefore(newTextNode, textNode.nextSibling);
3014
3073
  textNode.parentNode.insertBefore(document.createComment(""), textNode.nextSibling);
3015
3074
  textNode = newTextNode;
@@ -3017,268 +3076,368 @@ var makeLitTemplate = (template) => {
3017
3076
  }
3018
3077
  }
3019
3078
  }
3020
- for (const e3 of elementsToRemove) {
3021
- e3.remove();
3079
+ for (const e2 of elementsToRemove) {
3080
+ e2.remove();
3022
3081
  }
3023
3082
  return litTemplate;
3024
3083
  };
3025
3084
 
3026
- // ../qti-test/src/components/test-paging-buttons-stamp/test-paging-buttons-stamp.ts
3027
- var _internals2;
3085
+ // ../qti-test/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js
3086
+ var __decorate13 = function(decorators, target, key, desc) {
3087
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3088
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3089
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3090
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3091
+ };
3028
3092
  var TestPagingButtonsStamp = class extends i2 {
3029
- constructor() {
3030
- super();
3031
- __privateAdd(this, _internals2);
3032
- __privateSet(this, _internals2, this.attachInternals());
3033
- __privateGet(this, _internals2).ariaLabel = "pagination";
3034
- }
3093
+ #internals;
3035
3094
  createRenderRoot() {
3036
3095
  return this;
3037
3096
  }
3097
+ constructor() {
3098
+ super();
3099
+ this.#internals = this.attachInternals();
3100
+ this.#internals.ariaLabel = "pagination";
3101
+ }
3038
3102
  connectedCallback() {
3039
3103
  super.connectedCallback();
3040
3104
  const templateElement = this.querySelector("template");
3041
3105
  this.myTemplate = prepareTemplate(templateElement);
3042
3106
  }
3043
3107
  render() {
3044
- if (!this.computedContext) return T``;
3045
- const items = this.computedContext.testParts.flatMap(
3046
- (testPart) => testPart.sections.flatMap((section) => section.items)
3047
- );
3108
+ if (!this.computedContext)
3109
+ return T``;
3110
+ const items = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items));
3048
3111
  return T` ${items.map((item) => this.myTemplate({ item, view: this.computedContext.view }))} `;
3049
3112
  }
3050
3113
  };
3051
- _internals2 = new WeakMap();
3052
- __decorateClass([
3114
+ __decorate13([
3053
3115
  c({ context: computedContext, subscribe: true })
3054
- ], TestPagingButtonsStamp.prototype, "computedContext", 2);
3055
- TestPagingButtonsStamp = __decorateClass([
3056
- t("test-paging-buttons-stamp")
3057
- ], TestPagingButtonsStamp);
3116
+ ], TestPagingButtonsStamp.prototype, "computedContext", void 0);
3058
3117
 
3059
- // ../qti-test/src/components/test-container/test-container.ts
3060
- var _templateContent, _TestContainer_instances, initializeTemplateContent_fn, applyStyles_fn;
3061
- var TestContainer = class extends i2 {
3118
+ // ../qti-test/dist/components/test-prev/test-prev.js
3119
+ var __decorate14 = function(decorators, target, key, desc) {
3120
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3121
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3122
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3123
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3124
+ };
3125
+ var TestPrev = class extends i2 {
3126
+ _handleTestElementChange(_oldValue, newValue) {
3127
+ if (newValue) {
3128
+ this._internalDisabled = false;
3129
+ }
3130
+ }
3131
+ static {
3132
+ this.styles = i`
3133
+ :host {
3134
+ ${btn};
3135
+ }
3136
+ :host([disabled]) {
3137
+ ${dis};
3138
+ }
3139
+ `;
3140
+ }
3062
3141
  constructor() {
3063
- super(...arguments);
3064
- __privateAdd(this, _TestContainer_instances);
3065
- this.testURL = null;
3066
- this.testDoc = null;
3067
- this.testXML = null;
3068
- this.qtiContext = {
3069
- QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
3070
- };
3071
- /** Template content if provided */
3072
- __privateAdd(this, _templateContent, null);
3142
+ super();
3143
+ this._internalDisabled = true;
3144
+ this.addEventListener("click", (e2) => {
3145
+ e2.preventDefault();
3146
+ if (!this._internalDisabled)
3147
+ this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);
3148
+ });
3073
3149
  }
3074
- async handleTestURLChange() {
3075
- if (!this.testURL) return;
3076
- try {
3077
- const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
3078
- let api = (await qtiTransformTest().load(this.testURL)).shuffleOrdering(explicitSeed);
3079
- const qtiTest = this.closest("qti-test");
3080
- if (qtiTest?.postLoadTestTransformCallback) {
3081
- const tempDoc = api.htmlDoc();
3082
- const testElement = tempDoc.querySelector("qti-assessment-test");
3083
- if (testElement) {
3084
- api = await qtiTest.postLoadTestTransformCallback(api, testElement);
3085
- }
3150
+ willUpdate(_changedProperties) {
3151
+ if (!this.computedContext)
3152
+ return;
3153
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3154
+ if (!testPart)
3155
+ return;
3156
+ this.sectionItems = testPart.sections.flatMap((section) => section.items);
3157
+ this.itemIndex = this.sectionItems.findIndex((item) => item.active);
3158
+ this.checkDisabled();
3159
+ }
3160
+ checkDisabled() {
3161
+ this._internalDisabled = !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
3162
+ }
3163
+ _requestItem(identifier) {
3164
+ this.dispatchEvent(new CustomEvent("qti-request-navigation", {
3165
+ composed: true,
3166
+ bubbles: true,
3167
+ detail: {
3168
+ type: "item",
3169
+ id: identifier
3086
3170
  }
3087
- this.testDoc = api.htmlDoc();
3088
- } catch (error) {
3089
- console.error("Error loading or parsing XML:", error);
3090
- }
3171
+ }));
3091
3172
  }
3092
- handleTestXMLChange() {
3093
- if (!this.testXML) return;
3094
- try {
3095
- this.testDoc = qtiTransformTest().parse(this.testXML).htmlDoc();
3096
- } catch (error) {
3097
- console.error("Error parsing XML:", error);
3098
- }
3173
+ render() {
3174
+ return T`<slot></slot>`;
3099
3175
  }
3100
- async connectedCallback() {
3101
- super.connectedCallback();
3102
- __privateMethod(this, _TestContainer_instances, initializeTemplateContent_fn).call(this);
3103
- __privateMethod(this, _TestContainer_instances, applyStyles_fn).call(this);
3104
- if (this.testURL) {
3105
- this.handleTestURLChange();
3176
+ };
3177
+ __decorate14([
3178
+ n2({ type: Boolean, reflect: true, attribute: "disabled" })
3179
+ ], TestPrev.prototype, "_internalDisabled", void 0);
3180
+ __decorate14([
3181
+ c({ context: computedContext, subscribe: true })
3182
+ ], TestPrev.prototype, "computedContext", void 0);
3183
+ __decorate14([
3184
+ watch("computedContext")
3185
+ ], TestPrev.prototype, "_handleTestElementChange", null);
3186
+
3187
+ // ../qti-test/dist/components/test-print-context/test-print-context.js
3188
+ var __decorate15 = function(decorators, target, key, desc) {
3189
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3190
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3191
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3192
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3193
+ };
3194
+ var TestPrintContext = class extends i2 {
3195
+ render() {
3196
+ return T` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
3197
+ }
3198
+ };
3199
+ __decorate15([
3200
+ r(),
3201
+ c({ context: computedContext, subscribe: true })
3202
+ ], TestPrintContext.prototype, "computedContext", void 0);
3203
+
3204
+ // ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
3205
+ var __decorate16 = function(decorators, target, key, desc) {
3206
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3207
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3208
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3209
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3210
+ };
3211
+ var TestPrintVariables = class extends i2 {
3212
+ static {
3213
+ this.styles = i`
3214
+ table {
3215
+ width: 100%;
3216
+ border-collapse: collapse;
3217
+ margin: 20px 0;
3218
+ font-size: 14px;
3219
+ text-align: left;
3106
3220
  }
3107
- if (this.testXML) {
3108
- this.handleTestXMLChange();
3221
+ th,
3222
+ td {
3223
+ border: 1px solid #ddd;
3224
+ padding: 8px;
3225
+ }
3226
+ th {
3227
+ background-color: #f4f4f4;
3228
+ font-weight: bold;
3229
+ }
3230
+ h3 {
3231
+ margin-top: 20px;
3232
+ font-size: 16px;
3109
3233
  }
3234
+ `;
3110
3235
  }
3111
3236
  render() {
3237
+ const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
3238
+ if (!activeItem || !activeItem.variables)
3239
+ return T``;
3240
+ const responseVariables = activeItem.variables.filter((v) => v.type === "response");
3241
+ const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
3242
+ const renderTable = (variables, title) => T`
3243
+ <h3>${title}</h3>
3244
+ <table>
3245
+ <thead>
3246
+ <tr>
3247
+ <th>Identifier</th>
3248
+ <th>Value</th>
3249
+ <th>Cardinality</th>
3250
+ <th>Base Type</th>
3251
+ <th>Correct Response / Mappings</th>
3252
+ </tr>
3253
+ </thead>
3254
+ <tbody>
3255
+ ${variables.map((v) => {
3256
+ const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
3257
+ const mapEntries = v.mapping?.mapEntries?.map((m2) => `${m2.mapKey}=${m2.mappedValue}pt`).join(", ") || "";
3258
+ const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m2) => `${m2.shape}(${m2.coords})=${m2.mappedValue}pt`).join(", ") || "";
3259
+ return T`
3260
+ <tr>
3261
+ <td>${v.identifier}</td>
3262
+ <td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
3263
+ <td>${v.cardinality}</td>
3264
+ <td>${v.baseType}</td>
3265
+ <td>${correctResponse || mapEntries || areaMapEntries}</td>
3266
+ </tr>
3267
+ `;
3268
+ })}
3269
+ </tbody>
3270
+ </table>
3271
+ `;
3112
3272
  return T`
3113
- ${__privateGet(this, _templateContent)}
3114
- <slot></slot>
3115
- ${m(this.testDoc, T`<span>Loading...</span>`)}
3273
+ ${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
3116
3274
  `;
3117
3275
  }
3118
3276
  };
3119
- _templateContent = new WeakMap();
3120
- _TestContainer_instances = new WeakSet();
3121
- initializeTemplateContent_fn = function() {
3122
- const template = this.querySelector("template");
3123
- __privateSet(this, _templateContent, template ? template.content : T``);
3277
+ __decorate16([
3278
+ c({ context: computedContext, subscribe: true })
3279
+ ], TestPrintVariables.prototype, "computedContext", void 0);
3280
+
3281
+ // ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
3282
+ var __decorate17 = function(decorators, target, key, desc) {
3283
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3284
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3285
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3286
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3124
3287
  };
3125
- applyStyles_fn = function() {
3126
- const sheet = new CSSStyleSheet();
3127
- sheet.replaceSync(item_default);
3128
- this.shadowRoot.adoptedStyleSheets = [sheet];
3288
+ var TestScoringButtons = class extends i2 {
3289
+ createRenderRoot() {
3290
+ return this;
3291
+ }
3292
+ connectedCallback() {
3293
+ super.connectedCallback();
3294
+ const templateElement = this.querySelector("template");
3295
+ if (!templateElement) {
3296
+ this.myTemplate = null;
3297
+ return;
3298
+ }
3299
+ this.myTemplate = prepareTemplate(templateElement);
3300
+ }
3301
+ #changeOutcomeScore(value) {
3302
+ const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3303
+ const sectionItems = testPart.sections.flatMap((section) => section.items);
3304
+ const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
3305
+ this.dispatchEvent(new CustomEvent("test-update-outcome-variable", {
3306
+ detail: {
3307
+ assessmentItemRefId: currentItemIdentifier,
3308
+ outcomeVariableId: "SCORE",
3309
+ value
3310
+ },
3311
+ bubbles: true
3312
+ }));
3313
+ }
3314
+ render() {
3315
+ const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
3316
+ if (!activeItem || !activeItem.variables)
3317
+ return T``;
3318
+ const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
3319
+ const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
3320
+ const score = scoreOutcome?.value;
3321
+ const disabled = !(scoreOutcome?.externalScored === "human");
3322
+ if (!maxScore || !scoreOutcome)
3323
+ return A;
3324
+ const scores = [...Array(Number(maxScore) + 1).keys()];
3325
+ return T`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : A}`;
3326
+ }
3327
+ constructor() {
3328
+ super();
3329
+ this.view = "";
3330
+ this.disabled = false;
3331
+ this.myTemplate = null;
3332
+ this.addEventListener("click", (e2) => {
3333
+ const target = e2.target;
3334
+ const value = parseFloat(target.value);
3335
+ if (target.tagName === "INPUT") {
3336
+ this.#changeOutcomeScore(value);
3337
+ }
3338
+ });
3339
+ }
3129
3340
  };
3130
- __decorateClass([
3131
- n({ type: String, attribute: "test-url" })
3132
- ], TestContainer.prototype, "testURL", 2);
3133
- __decorateClass([
3134
- r()
3135
- ], TestContainer.prototype, "testDoc", 2);
3136
- __decorateClass([
3137
- r()
3138
- ], TestContainer.prototype, "testXML", 2);
3139
- __decorateClass([
3140
- r(),
3141
- c({ context: qtiContext, subscribe: true })
3142
- ], TestContainer.prototype, "qtiContext", 2);
3143
- __decorateClass([
3144
- watch("testURL", { waitUntilFirstUpdate: true })
3145
- ], TestContainer.prototype, "handleTestURLChange", 1);
3146
- __decorateClass([
3147
- watch("testXML", { waitUntilFirstUpdate: true })
3148
- ], TestContainer.prototype, "handleTestXMLChange", 1);
3149
- TestContainer = __decorateClass([
3150
- t("test-container")
3151
- ], TestContainer);
3341
+ __decorate17([
3342
+ n2({ type: String, attribute: "view" })
3343
+ ], TestScoringButtons.prototype, "view", void 0);
3344
+ __decorate17([
3345
+ n2({ type: Boolean })
3346
+ ], TestScoringButtons.prototype, "disabled", void 0);
3347
+ __decorate17([
3348
+ c({ context: computedContext, subscribe: true })
3349
+ ], TestScoringButtons.prototype, "computedContext", void 0);
3152
3350
 
3153
- // ../qti-test/src/components/test-print-item-variables/test-print-item-variables.ts
3154
- var TestPrintVariables = class extends i2 {
3351
+ // ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
3352
+ var __decorate18 = function(decorators, target, key, desc) {
3353
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3354
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3355
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3356
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3357
+ };
3358
+ var TestScoringFeedback = class extends i2 {
3359
+ constructor() {
3360
+ super(...arguments);
3361
+ this.view = null;
3362
+ }
3155
3363
  render() {
3156
3364
  const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
3157
- if (!activeItem || !activeItem.variables) return T``;
3158
- const responseVariables = activeItem.variables.filter((v2) => v2.type === "response");
3159
- const outcomeVariables = activeItem.variables.filter((v2) => v2.type === "outcome");
3160
- const renderTable = (variables, title) => T`
3161
- <h3>${title}</h3>
3162
- <table>
3163
- <thead>
3164
- <tr>
3165
- <th>Identifier</th>
3166
- <th>Value</th>
3167
- <th>Cardinality</th>
3168
- <th>Base Type</th>
3169
- <th>Correct Response / Mappings</th>
3170
- </tr>
3171
- </thead>
3172
- <tbody>
3173
- ${variables.map((v2) => {
3174
- const correctResponse = v2.correctResponse ? Array.isArray(v2.correctResponse) ? v2.correctResponse.join(", ") : v2.correctResponse : "";
3175
- const mapEntries = v2.mapping?.mapEntries?.map((m3) => `${m3.mapKey}=${m3.mappedValue}pt`).join(", ") || "";
3176
- const areaMapEntries = v2.areaMapping?.areaMapEntries?.map((m3) => `${m3.shape}(${m3.coords})=${m3.mappedValue}pt`).join(", ") || "";
3177
- return T`
3178
- <tr>
3179
- <td>${v2.identifier}</td>
3180
- <td>${Array.isArray(v2.value) ? v2.value.join(", ") : v2.value}</td>
3181
- <td>${v2.cardinality}</td>
3182
- <td>${v2.baseType}</td>
3183
- <td>${correctResponse || mapEntries || areaMapEntries}</td>
3184
- </tr>
3185
- `;
3186
- })}
3187
- </tbody>
3188
- </table>
3189
- `;
3190
- return T`
3191
- ${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
3192
- `;
3365
+ if (!activeItem || !activeItem.variables)
3366
+ return T``;
3367
+ if (activeItem["category"] === "dep-informational")
3368
+ return T`<div>${this.dataset.informational}</div>`;
3369
+ const completionStatus = activeItem?.variables.find((v) => v.identifier === "completionStatus")?.value;
3370
+ const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
3371
+ const score = parseFloat(scoreOutcome?.value);
3372
+ const externalScored = activeItem["externalScored"];
3373
+ const feedbackText = () => {
3374
+ if (completionStatus !== "completed") {
3375
+ return this.dataset.textNoResponse;
3376
+ }
3377
+ if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
3378
+ return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
3379
+ }
3380
+ if (externalScored === "externalMachine") {
3381
+ 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.`;
3382
+ }
3383
+ if (externalScored === "human") {
3384
+ return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
3385
+ }
3386
+ return this.dataset.inProgress;
3387
+ };
3388
+ return T`<div>${feedbackText()}</div>`;
3193
3389
  }
3194
3390
  };
3195
- TestPrintVariables.styles = i`
3196
- table {
3197
- width: 100%;
3198
- border-collapse: collapse;
3199
- margin: 20px 0;
3200
- font-size: 14px;
3201
- text-align: left;
3202
- }
3203
- th,
3204
- td {
3205
- border: 1px solid #ddd;
3206
- padding: 8px;
3207
- }
3208
- th {
3209
- background-color: #f4f4f4;
3210
- font-weight: bold;
3211
- }
3212
- h3 {
3213
- margin-top: 20px;
3214
- font-size: 16px;
3215
- }
3216
- `;
3217
- __decorateClass([
3391
+ __decorate18([
3218
3392
  c({ context: computedContext, subscribe: true })
3219
- ], TestPrintVariables.prototype, "computedContext", 2);
3220
- TestPrintVariables = __decorateClass([
3221
- t("test-print-item-variables")
3222
- ], TestPrintVariables);
3393
+ ], TestScoringFeedback.prototype, "computedContext", void 0);
3394
+ __decorate18([
3395
+ n2({ type: String, attribute: "view" })
3396
+ ], TestScoringFeedback.prototype, "view", void 0);
3223
3397
 
3224
- // ../qti-test/src/components/test-section-buttons-stamp/test-section-buttons-stamp.ts
3225
- var _internals3;
3398
+ // ../qti-test/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js
3399
+ var __decorate19 = function(decorators, target, key, desc) {
3400
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3401
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3402
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3403
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3404
+ };
3226
3405
  var TestSectionButtonsStamp = class extends i2 {
3227
- constructor() {
3228
- super();
3229
- __privateAdd(this, _internals3);
3230
- __privateSet(this, _internals3, this.attachInternals());
3231
- __privateGet(this, _internals3).ariaLabel = "pagination";
3232
- }
3406
+ #internals;
3233
3407
  createRenderRoot() {
3234
3408
  return this;
3235
3409
  }
3410
+ constructor() {
3411
+ super();
3412
+ this.#internals = this.attachInternals();
3413
+ this.#internals.ariaLabel = "pagination";
3414
+ }
3236
3415
  connectedCallback() {
3237
3416
  super.connectedCallback();
3238
3417
  const templateElement = this.querySelector("template");
3239
3418
  this.myTemplate = prepareTemplate(templateElement);
3240
3419
  }
3241
3420
  render() {
3242
- if (!this.computedContext) return T``;
3421
+ if (!this.computedContext)
3422
+ return T``;
3243
3423
  const sections = this.computedContext.testParts.flatMap((testPart) => testPart.sections);
3244
3424
  return T` ${sections.map((item) => this.myTemplate({ item }))} `;
3245
3425
  }
3246
3426
  };
3247
- _internals3 = new WeakMap();
3248
- __decorateClass([
3427
+ __decorate19([
3249
3428
  c({ context: computedContext, subscribe: true })
3250
- ], TestSectionButtonsStamp.prototype, "computedContext", 2);
3251
- TestSectionButtonsStamp = __decorateClass([
3252
- t("test-section-buttons-stamp")
3253
- ], TestSectionButtonsStamp);
3429
+ ], TestSectionButtonsStamp.prototype, "computedContext", void 0);
3254
3430
 
3255
- // ../qti-test/src/components/test-section-link/test-section-link.ts
3256
- var _TestSectionLink_instances, requestItem_fn;
3257
- var TestSectionLink = class extends i2 {
3258
- constructor() {
3259
- super();
3260
- __privateAdd(this, _TestSectionLink_instances);
3261
- this.sectionId = null;
3262
- this.addEventListener("click", () => __privateMethod(this, _TestSectionLink_instances, requestItem_fn).call(this, this.sectionId));
3263
- }
3264
- render() {
3265
- return T` <slot></slot> `;
3266
- }
3431
+ // ../qti-test/dist/components/test-section-link/test-section-link.js
3432
+ var __decorate20 = function(decorators, target, key, desc) {
3433
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3434
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3435
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3436
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3267
3437
  };
3268
- _TestSectionLink_instances = new WeakSet();
3269
- requestItem_fn = function(identifier) {
3270
- this.dispatchEvent(
3271
- new CustomEvent("qti-request-navigation", {
3272
- composed: true,
3273
- bubbles: true,
3274
- detail: {
3275
- type: "section",
3276
- id: identifier
3277
- }
3278
- })
3279
- );
3280
- };
3281
- TestSectionLink.styles = i`
3438
+ var TestSectionLink = class extends i2 {
3439
+ static {
3440
+ this.styles = i`
3282
3441
  :host {
3283
3442
  ${btn};
3284
3443
  }
@@ -3286,28 +3445,37 @@ TestSectionLink.styles = i`
3286
3445
  ${dis};
3287
3446
  }
3288
3447
  `;
3289
- __decorateClass([
3290
- n({ type: String, attribute: "section-id" })
3291
- ], TestSectionLink.prototype, "sectionId", 2);
3292
- TestSectionLink = __decorateClass([
3293
- t("test-section-link")
3294
- ], TestSectionLink);
3295
-
3296
- // ../qti-test/src/components/test-print-context/test-print-context.ts
3297
- var TestPrintContext = class extends i2 {
3448
+ }
3449
+ #requestItem(identifier) {
3450
+ this.dispatchEvent(new CustomEvent("qti-request-navigation", {
3451
+ composed: true,
3452
+ bubbles: true,
3453
+ detail: {
3454
+ type: "section",
3455
+ id: identifier
3456
+ }
3457
+ }));
3458
+ }
3459
+ constructor() {
3460
+ super();
3461
+ this.sectionId = null;
3462
+ this.addEventListener("click", () => this.#requestItem(this.sectionId));
3463
+ }
3298
3464
  render() {
3299
- return T` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
3465
+ return T` <slot></slot> `;
3300
3466
  }
3301
3467
  };
3302
- __decorateClass([
3303
- r(),
3304
- c({ context: computedContext, subscribe: true })
3305
- ], TestPrintContext.prototype, "computedContext", 2);
3306
- TestPrintContext = __decorateClass([
3307
- t("test-print-context")
3308
- ], TestPrintContext);
3468
+ __decorate20([
3469
+ n2({ type: String, attribute: "section-id" })
3470
+ ], TestSectionLink.prototype, "sectionId", void 0);
3309
3471
 
3310
- // ../qti-test/src/components/test-stamp/test-stamp.ts
3472
+ // ../qti-test/dist/components/test-stamp/test-stamp.js
3473
+ var __decorate21 = function(decorators, target, key, desc) {
3474
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3475
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3476
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3477
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3478
+ };
3311
3479
  var TestStamp = class extends i2 {
3312
3480
  constructor() {
3313
3481
  super(...arguments);
@@ -3365,103 +3533,106 @@ var TestStamp = class extends i2 {
3365
3533
  activeTestpart: augmentedTestPart,
3366
3534
  test: activeTest
3367
3535
  };
3368
- this.dispatchEvent(
3369
- new CustomEvent("qti-stamp-context-updated", {
3370
- detail: this.stampContext,
3371
- bubbles: true
3372
- })
3373
- );
3536
+ this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
3537
+ detail: this.stampContext,
3538
+ bubbles: true
3539
+ }));
3374
3540
  }
3375
3541
  render() {
3376
3542
  return T` ${this.debug ? T`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : A}
3377
3543
  ${this.myTemplate ? this.myTemplate(this.stampContext) : A}`;
3378
3544
  }
3379
3545
  };
3380
- __decorateClass([
3381
- n({ type: Boolean, reflect: true })
3382
- ], TestStamp.prototype, "debug", 2);
3383
- __decorateClass([
3546
+ __decorate21([
3547
+ n2({ type: Boolean, reflect: true })
3548
+ ], TestStamp.prototype, "debug", void 0);
3549
+ __decorate21([
3384
3550
  r(),
3385
3551
  c({ context: computedContext, subscribe: true })
3386
- ], TestStamp.prototype, "computedContext", 2);
3387
- __decorateClass([
3552
+ ], TestStamp.prototype, "computedContext", void 0);
3553
+ __decorate21([
3388
3554
  r()
3389
- ], TestStamp.prototype, "stampContext", 2);
3390
- TestStamp = __decorateClass([
3391
- t("test-stamp")
3392
- ], TestStamp);
3555
+ ], TestStamp.prototype, "stampContext", void 0);
3393
3556
 
3394
- // ../qti-test/src/components/test-scoring-buttons/test-scoring-buttons.ts
3395
- var _TestScoringButtons_instances, changeOutcomeScore_fn;
3396
- var TestScoringButtons = class extends i2 {
3557
+ // ../qti-test/dist/components/test-view-toggle/test-view.js
3558
+ var __decorate22 = function(decorators, target, key, desc) {
3559
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3560
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3561
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3562
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3563
+ };
3564
+ var _a;
3565
+ var TestView = class extends i2 {
3397
3566
  constructor() {
3398
- super();
3399
- __privateAdd(this, _TestScoringButtons_instances);
3400
- this.view = "";
3401
- this.disabled = false;
3402
- this.myTemplate = null;
3403
- this.addEventListener("click", (e3) => {
3404
- const target = e3.target;
3405
- const value = parseFloat(target.value);
3406
- if (target.tagName === "INPUT") {
3407
- __privateMethod(this, _TestScoringButtons_instances, changeOutcomeScore_fn).call(this, value);
3408
- }
3409
- });
3567
+ super(...arguments);
3568
+ this.label = "view";
3569
+ this._handleViewOptionsChange = () => {
3570
+ this.#updateViewOptions();
3571
+ };
3572
+ this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
3410
3573
  }
3411
- createRenderRoot() {
3412
- return this;
3574
+ static {
3575
+ this.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
3413
3576
  }
3414
3577
  connectedCallback() {
3415
3578
  super.connectedCallback();
3416
- const templateElement = this.querySelector("template");
3417
- if (!templateElement) {
3418
- this.myTemplate = null;
3419
- return;
3579
+ this.#updateViewOptions();
3580
+ }
3581
+ #updateViewOptions() {
3582
+ if (this.viewOptions) {
3583
+ const options = this.viewOptions.split(",").map((opt) => opt.trim());
3584
+ this._viewOptions = options.filter((opt) => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
3585
+ } else {
3586
+ this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
3420
3587
  }
3421
- this.myTemplate = prepareTemplate(templateElement);
3588
+ }
3589
+ _switchView(view) {
3590
+ this.dispatchEvent(new CustomEvent("on-test-switch-view", {
3591
+ composed: true,
3592
+ bubbles: true,
3593
+ detail: view
3594
+ }));
3422
3595
  }
3423
3596
  render() {
3424
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
3425
- if (!activeItem || !activeItem.variables) return T``;
3426
- const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
3427
- const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
3428
- const score = scoreOutcome?.value;
3429
- const disabled = !(scoreOutcome?.externalScored === "human");
3430
- if (!maxScore || !scoreOutcome) return A;
3431
- const scores = [...Array(Number(maxScore) + 1).keys()];
3432
- return T`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : A}`;
3597
+ return T`
3598
+ <label part="label" for="viewSelect">${this.label}</label>
3599
+ <select
3600
+ part="select"
3601
+ id="viewSelect"
3602
+ @change=${(e2) => {
3603
+ const el = e2.target;
3604
+ this._switchView(el.value);
3605
+ }}
3606
+ >
3607
+ ${this._viewOptions.map((v) => T`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
3608
+ </select>
3609
+ `;
3433
3610
  }
3434
3611
  };
3435
- _TestScoringButtons_instances = new WeakSet();
3436
- changeOutcomeScore_fn = function(value) {
3437
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3438
- const sectionItems = testPart.sections.flatMap((section) => section.items);
3439
- const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
3440
- this.dispatchEvent(
3441
- new CustomEvent("test-update-outcome-variable", {
3442
- detail: {
3443
- assessmentItemRefId: currentItemIdentifier,
3444
- outcomeVariableId: "SCORE",
3445
- value
3446
- },
3447
- bubbles: true
3448
- })
3449
- );
3450
- };
3451
- __decorateClass([
3452
- n({ type: String, attribute: "view" })
3453
- ], TestScoringButtons.prototype, "view", 2);
3454
- __decorateClass([
3455
- n({ type: Boolean })
3456
- ], TestScoringButtons.prototype, "disabled", 2);
3457
- __decorateClass([
3458
- c({ context: computedContext, subscribe: true })
3459
- ], TestScoringButtons.prototype, "computedContext", 2);
3460
- TestScoringButtons = __decorateClass([
3461
- t("test-scoring-buttons")
3462
- ], TestScoringButtons);
3612
+ _a = TestView;
3613
+ __decorate22([
3614
+ c({ context: sessionContext, subscribe: true })
3615
+ ], TestView.prototype, "sessionContext", void 0);
3616
+ __decorate22([
3617
+ n2({ type: String })
3618
+ ], TestView.prototype, "label", void 0);
3619
+ __decorate22([
3620
+ n2({ type: String, attribute: "view-options" })
3621
+ ], TestView.prototype, "viewOptions", void 0);
3622
+ __decorate22([
3623
+ watch("viewOptions", { waitUntilFirstUpdate: true })
3624
+ ], TestView.prototype, "_handleViewOptionsChange", void 0);
3625
+ __decorate22([
3626
+ r()
3627
+ ], TestView.prototype, "_viewOptions", void 0);
3463
3628
 
3464
- // ../qti-test/src/components/test-view-toggle/test-view-toggle.ts
3629
+ // ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
3630
+ var __decorate23 = function(decorators, target, key, desc) {
3631
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3632
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3633
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3634
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3635
+ };
3465
3636
  var TestViewToggle = class extends i2 {
3466
3637
  createRenderRoot() {
3467
3638
  return this;
@@ -3476,13 +3647,11 @@ var TestViewToggle = class extends i2 {
3476
3647
  this.myTemplate = prepareTemplate(templateElement);
3477
3648
  }
3478
3649
  _switchView(view) {
3479
- this.dispatchEvent(
3480
- new CustomEvent("on-test-switch-view", {
3481
- composed: true,
3482
- bubbles: true,
3483
- detail: view
3484
- })
3485
- );
3650
+ this.dispatchEvent(new CustomEvent("on-test-switch-view", {
3651
+ composed: true,
3652
+ bubbles: true,
3653
+ detail: view
3654
+ }));
3486
3655
  }
3487
3656
  firstUpdated(_changedProperties) {
3488
3657
  this.addEventListener("click", () => {
@@ -3499,126 +3668,182 @@ var TestViewToggle = class extends i2 {
3499
3668
  }) : A}`;
3500
3669
  }
3501
3670
  };
3502
- __decorateClass([
3671
+ __decorate23([
3503
3672
  c({ context: sessionContext, subscribe: true })
3504
- ], TestViewToggle.prototype, "sessionContext", 2);
3505
- TestViewToggle = __decorateClass([
3506
- t("test-view-toggle")
3507
- ], TestViewToggle);
3673
+ ], TestViewToggle.prototype, "sessionContext", void 0);
3508
3674
 
3509
- // ../qti-test/src/components/test-scoring-feedback/test-scoring-feedback.ts
3510
- var TestScoringFeedback = class extends i2 {
3511
- constructor() {
3512
- super(...arguments);
3513
- this.view = null;
3675
+ // ../qti-test/dist/components/qti-outcome-processing/qti-outcome-processing.js
3676
+ var QtiOutcomeProcessing = class extends i2 {
3677
+ static {
3678
+ this.styles = [
3679
+ i`
3680
+ :host {
3681
+ display: none;
3682
+ }
3683
+ `
3684
+ ];
3514
3685
  }
3515
3686
  render() {
3516
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
3517
- if (!activeItem || !activeItem.variables) return T``;
3518
- if (activeItem["category"] === "dep-informational") return T`<div>${this.dataset.informational}</div>`;
3519
- const completionStatus = activeItem?.variables.find((v2) => v2.identifier === "completionStatus")?.value;
3520
- const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
3521
- const score = parseFloat(scoreOutcome?.value);
3522
- const externalScored = activeItem["externalScored"];
3523
- const feedbackText = () => {
3524
- if (completionStatus !== "completed") {
3525
- return this.dataset.textNoResponse;
3526
- }
3527
- if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
3528
- return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
3529
- }
3530
- if (externalScored === "externalMachine") {
3531
- 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.`;
3532
- }
3533
- if (externalScored === "human") {
3534
- return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
3535
- }
3536
- return this.dataset.inProgress;
3537
- };
3538
- return T`<div>${feedbackText()}</div>`;
3687
+ return T`<slot></slot>`;
3688
+ }
3689
+ process() {
3690
+ const logic = new QtiOutcomeProcessingProcessor();
3691
+ const rules = [...this.children];
3692
+ logic.process(rules);
3693
+ }
3694
+ };
3695
+ var QtiOutcomeProcessingProcessor = class {
3696
+ process(rules) {
3697
+ for (const rule of rules) {
3698
+ rule.process();
3699
+ }
3539
3700
  }
3540
3701
  };
3541
- __decorateClass([
3542
- c({ context: computedContext, subscribe: true })
3543
- ], TestScoringFeedback.prototype, "computedContext", 2);
3544
- __decorateClass([
3545
- n({ type: String, attribute: "view" })
3546
- ], TestScoringFeedback.prototype, "view", 2);
3547
- TestScoringFeedback = __decorateClass([
3548
- t("test-scoring-feedback")
3549
- ], TestScoringFeedback);
3550
3702
 
3551
- // ../qti-test/src/components/test-check-item/test-check-item.ts
3552
- var TestCheckItem = class extends i2 {
3703
+ // ../qti-test/dist/components/qti-test-variables/qti-test-variables.js
3704
+ var __decorate24 = function(decorators, target, key, desc) {
3705
+ var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3706
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc);
3707
+ else for (var i4 = decorators.length - 1; i4 >= 0; i4--) if (d = decorators[i4]) r3 = (c2 < 3 ? d(r3) : c2 > 3 ? d(target, key, r3) : d(target, key)) || r3;
3708
+ return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
3709
+ };
3710
+ var QtiTestVariables = class extends QtiExpression {
3711
+ #testElement;
3553
3712
  constructor() {
3554
3713
  super();
3555
- this.addEventListener("click", () => {
3556
- this.dispatchEvent(new CustomEvent("test-end-attempt", { bubbles: true }));
3557
- this.dispatchEvent(
3558
- new CustomEvent("test-show-correct-response", {
3559
- detail: true,
3560
- bubbles: true
3561
- })
3562
- );
3563
- const qtiTest = this.closest("qti-test");
3564
- const testContainer = qtiTest.querySelector("test-container");
3565
- const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
3566
- viewElements.forEach((element) => {
3567
- element.classList.toggle("show", true);
3568
- });
3714
+ this.addEventListener("qti-assessment-test-connected", (e2) => this.#testElement = e2.detail);
3715
+ }
3716
+ getResult() {
3717
+ const includedCategories = this.getAttribute("include-category")?.split(" ") ?? [];
3718
+ const excludedCategories = this.getAttribute("exclude-category")?.split(" ") ?? [];
3719
+ const weightIdentifier = this.getAttribute("weight-identifier") ?? "";
3720
+ const itemVariable = this.getAttribute("variable-identifier");
3721
+ const itemRefEls = Array.from(this.#testElement.querySelectorAll(`qti-asssessment-test qti-assessment-item-ref`));
3722
+ const includedItems = itemRefEls.filter((itemRef) => {
3723
+ let include = true;
3724
+ if (includedCategories.length > 0) {
3725
+ include = includedCategories.includes(itemRef.category);
3726
+ }
3727
+ if (excludedCategories.length > 0) {
3728
+ include = !excludedCategories.includes(itemRef.category);
3729
+ }
3730
+ return include;
3731
+ }).map((itemRef) => {
3732
+ let weight = 1;
3733
+ if (weightIdentifier) {
3734
+ const weightVariable = itemRef.weigths.get(weightIdentifier);
3735
+ if (weightVariable !== null && weightVariable !== void 0) {
3736
+ weight = weightVariable;
3737
+ }
3738
+ }
3739
+ return { item: itemRef.identifier, weight };
3569
3740
  });
3741
+ const logic = new QtiTestVariablesExpression(this._testContext, itemVariable, includedItems);
3742
+ const value = logic.calculate();
3743
+ return value;
3570
3744
  }
3571
- render() {
3572
- return T` <slot></slot> `;
3745
+ calculate() {
3746
+ return this.getResult();
3573
3747
  }
3574
3748
  };
3575
- TestCheckItem.styles = i`
3576
- :host {
3577
- ${btn};
3578
- }
3579
- :host([disabled]) {
3580
- ${dis};
3581
- }
3582
- `;
3583
- TestCheckItem = __decorateClass([
3584
- t("test-check-item")
3585
- ], TestCheckItem);
3749
+ __decorate24([
3750
+ c({ context: testContext, subscribe: true })
3751
+ ], QtiTestVariables.prototype, "_testContext", void 0);
3752
+ var QtiTestVariablesExpression = class {
3753
+ constructor(testContext2, itemVariable, includedItems) {
3754
+ this.testContext = testContext2;
3755
+ this.itemVariable = itemVariable;
3756
+ this.includedItems = includedItems;
3757
+ }
3758
+ calculate() {
3759
+ const { items } = this.testContext;
3760
+ let total = 0;
3761
+ const uniqueItems = [...new Set(this.includedItems.map((item) => item.item))];
3762
+ items.forEach((item) => {
3763
+ if (uniqueItems.includes(item.identifier)) {
3764
+ const variable = item.variables.find((vr) => vr.identifier === this.itemVariable);
3765
+ const weight = this.includedItems.find((i4) => i4.item === item.identifier)?.weight ?? 1;
3766
+ if (variable) {
3767
+ total += Number(variable.value) * weight;
3768
+ }
3769
+ }
3770
+ });
3771
+ return total;
3772
+ }
3773
+ };
3774
+
3775
+ // ../qti-test/dist/elements.js
3776
+ var qtiTestElements = [
3777
+ { tag: "qti-assessment-item-ref", ctor: QtiAssessmentItemRef },
3778
+ { tag: "qti-assessment-section", ctor: QtiAssessmentSection },
3779
+ { tag: "qti-assessment-test", ctor: QtiAssessmentTest },
3780
+ { tag: "qti-outcome-processing", ctor: QtiOutcomeProcessing },
3781
+ { tag: "qti-test", ctor: QtiTest },
3782
+ { tag: "qti-test-feedback", ctor: QtiTestFeedback },
3783
+ { tag: "qti-test-part", ctor: QtiTestPart },
3784
+ { tag: "qti-test-variables", ctor: QtiTestVariables },
3785
+ { tag: "test-check-item", ctor: TestCheckItem },
3786
+ { tag: "test-container", ctor: TestContainer },
3787
+ { tag: "test-end-attempt", ctor: TestEndAttempt },
3788
+ { tag: "test-item-link", ctor: TestItemLink },
3789
+ { tag: "test-item-to-speech", ctor: TestItemToSpeech },
3790
+ { tag: "test-navigation", ctor: TestNavigation },
3791
+ { tag: "test-next", ctor: TestNext },
3792
+ { tag: "test-paging-buttons-stamp", ctor: TestPagingButtonsStamp },
3793
+ { tag: "test-prev", ctor: TestPrev },
3794
+ { tag: "test-print-context", ctor: TestPrintContext },
3795
+ { tag: "test-print-item-variables", ctor: TestPrintVariables },
3796
+ { tag: "test-scoring-buttons", ctor: TestScoringButtons },
3797
+ { tag: "test-scoring-feedback", ctor: TestScoringFeedback },
3798
+ { tag: "test-section-buttons-stamp", ctor: TestSectionButtonsStamp },
3799
+ { tag: "test-section-link", ctor: TestSectionLink },
3800
+ { tag: "test-stamp", ctor: TestStamp },
3801
+ { tag: "test-tts-next", ctor: TestTtsNext },
3802
+ { tag: "test-tts-pause", ctor: TestTtsPause },
3803
+ { tag: "test-tts-play", ctor: TestTtsPlay },
3804
+ { tag: "test-tts-prev", ctor: TestTtsPrev },
3805
+ { tag: "test-tts-resume", ctor: TestTtsResume },
3806
+ { tag: "test-tts-stop", ctor: TestTtsStop },
3807
+ { tag: "test-view", ctor: TestView },
3808
+ { tag: "test-view-toggle", ctor: TestViewToggle }
3809
+ ];
3586
3810
 
3587
3811
  export {
3588
- QtiTest,
3589
3812
  QtiAssessmentItemRef,
3590
3813
  QtiAssessmentSection,
3591
3814
  QtiAssessmentTest,
3592
- QtiTestPart,
3593
3815
  QtiTestFeedback,
3816
+ QtiTestPart,
3817
+ QtiTest,
3818
+ TestCheckItem,
3819
+ TestContainer,
3820
+ TestEndAttempt,
3821
+ TestItemLink,
3822
+ ttsContext,
3823
+ TestItemToSpeech,
3824
+ TestTtsPlay,
3825
+ TestTtsPause,
3826
+ TestTtsResume,
3827
+ TestTtsStop,
3828
+ TestTtsPrev,
3829
+ TestTtsNext,
3594
3830
  TestNavigation,
3595
3831
  TestNext,
3596
- TestPrev,
3597
- TestView,
3598
- TestItemLink,
3599
- TestEndAttempt,
3600
- TestShowCorrectResponse,
3601
3832
  TestPagingButtonsStamp,
3602
- TestContainer,
3833
+ TestPrev,
3834
+ TestPrintContext,
3603
3835
  TestPrintVariables,
3836
+ TestScoringButtons,
3837
+ TestScoringFeedback,
3604
3838
  TestSectionButtonsStamp,
3605
3839
  TestSectionLink,
3606
- TestPrintContext,
3607
3840
  TestStamp,
3608
- TestScoringButtons,
3841
+ TestView,
3609
3842
  TestViewToggle,
3610
- TestScoringFeedback,
3611
- TestCheckItem
3843
+ qtiTestElements
3612
3844
  };
3613
3845
  /*! Bundled license information:
3614
3846
 
3615
- lit-html/node/lit-html.js:
3616
- (**
3617
- * @license
3618
- * Copyright 2017 Google LLC
3619
- * SPDX-License-Identifier: BSD-3-Clause
3620
- *)
3621
-
3622
3847
  @heximal/expressions/lib/constants.js:
3623
3848
  @heximal/expressions/lib/tokenizer.js:
3624
3849
  @heximal/expressions/lib/parser.js:
@@ -3636,4 +3861,4 @@ lit-html/node/private-ssr-support.js:
3636
3861
  * SPDX-License-Identifier: BSD-3-Clause
3637
3862
  *)
3638
3863
  */
3639
- //# sourceMappingURL=chunk-HFCZFWSH.js.map
3864
+ //# sourceMappingURL=chunk-LZJHHZQ2.js.map