@citolab/qti-components 7.15.0 → 7.15.2

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 (46) hide show
  1. package/LICENSE.md +674 -0
  2. package/dist/base.js +2 -49
  3. package/dist/base.js.map +1 -1
  4. package/dist/elements.js +2 -41
  5. package/dist/elements.js.map +1 -1
  6. package/dist/index.js +9 -327
  7. package/dist/index.js.map +1 -1
  8. package/dist/interactions.js +2 -71
  9. package/dist/interactions.js.map +1 -1
  10. package/dist/item.js +2 -22
  11. package/dist/item.js.map +1 -1
  12. package/dist/loader.js +2 -10
  13. package/dist/loader.js.map +1 -1
  14. package/dist/processing.js +2 -102
  15. package/dist/processing.js.map +1 -1
  16. package/dist/test.js +2 -60
  17. package/dist/test.js.map +1 -1
  18. package/dist/transformers.js +2 -11
  19. package/dist/transformers.js.map +1 -1
  20. package/package.json +23 -22
  21. package/dist/chunk-2DOYPVF5.js +0 -481
  22. package/dist/chunk-2DOYPVF5.js.map +0 -1
  23. package/dist/chunk-2ZEJ3RR5.js +0 -89
  24. package/dist/chunk-2ZEJ3RR5.js.map +0 -1
  25. package/dist/chunk-352OTVTY.js +0 -3330
  26. package/dist/chunk-352OTVTY.js.map +0 -1
  27. package/dist/chunk-C2HQFI2C.js +0 -5927
  28. package/dist/chunk-C2HQFI2C.js.map +0 -1
  29. package/dist/chunk-DWIRLYDS.js +0 -20
  30. package/dist/chunk-DWIRLYDS.js.map +0 -1
  31. package/dist/chunk-EUXUH3YW.js +0 -15
  32. package/dist/chunk-EUXUH3YW.js.map +0 -1
  33. package/dist/chunk-F44CI35W.js +0 -145
  34. package/dist/chunk-F44CI35W.js.map +0 -1
  35. package/dist/chunk-INKI27D5.js +0 -493
  36. package/dist/chunk-INKI27D5.js.map +0 -1
  37. package/dist/chunk-JEUY3MYB.js +0 -2010
  38. package/dist/chunk-JEUY3MYB.js.map +0 -1
  39. package/dist/chunk-O4XIWHTF.js +0 -1139
  40. package/dist/chunk-O4XIWHTF.js.map +0 -1
  41. package/dist/chunk-RI47B4ZT.js +0 -1753
  42. package/dist/chunk-RI47B4ZT.js.map +0 -1
  43. package/dist/chunk-VEV4DGPH.js +0 -31
  44. package/dist/chunk-VEV4DGPH.js.map +0 -1
  45. package/dist/chunk-W4SQRNWO.js +0 -3844
  46. package/dist/chunk-W4SQRNWO.js.map +0 -1
package/dist/test.js CHANGED
@@ -1,61 +1,3 @@
1
- import {
2
- QtiAssessmentItemRef,
3
- QtiAssessmentSection,
4
- QtiAssessmentTest,
5
- QtiTest,
6
- QtiTestFeedback,
7
- QtiTestPart,
8
- TestCheckItem,
9
- TestContainer,
10
- TestEndAttempt,
11
- TestItemLink,
12
- TestNavigation,
13
- TestNext,
14
- TestPagingButtonsStamp,
15
- TestPrev,
16
- TestPrintContext,
17
- TestPrintVariables,
18
- TestScoringButtons,
19
- TestScoringFeedback,
20
- TestSectionButtonsStamp,
21
- TestSectionLink,
22
- TestShowCorrectResponse,
23
- TestStamp,
24
- TestView,
25
- TestViewToggle
26
- } from "./chunk-352OTVTY.js";
27
- import "./chunk-O4XIWHTF.js";
28
- import "./chunk-DWIRLYDS.js";
29
- import "./chunk-W4SQRNWO.js";
30
- import "./chunk-F44CI35W.js";
31
- import "./chunk-2ZEJ3RR5.js";
32
- import "./chunk-INKI27D5.js";
33
- import "./chunk-JEUY3MYB.js";
34
- import "./chunk-EUXUH3YW.js";
35
- export {
36
- QtiAssessmentItemRef,
37
- QtiAssessmentSection,
38
- QtiAssessmentTest,
39
- QtiTest,
40
- QtiTestFeedback,
41
- QtiTestPart,
42
- TestCheckItem,
43
- TestContainer,
44
- TestEndAttempt,
45
- TestItemLink,
46
- TestNavigation,
47
- TestNext,
48
- TestPagingButtonsStamp,
49
- TestPrev,
50
- TestPrintContext,
51
- TestPrintVariables,
52
- TestScoringButtons,
53
- TestScoringFeedback,
54
- TestSectionButtonsStamp,
55
- TestSectionLink,
56
- TestShowCorrectResponse,
57
- TestStamp,
58
- TestView,
59
- TestViewToggle
60
- };
1
+ // src/test.ts
2
+ export * from "@qti-components/test";
61
3
  //# sourceMappingURL=test.js.map
package/dist/test.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/test.ts"],"sourcesContent":["export * from '@qti-components/test';\n"],"mappings":";AAAA,cAAc;","names":[]}
@@ -1,12 +1,3 @@
1
- import {
2
- qtiTransformItem,
3
- qtiTransformManifest,
4
- qtiTransformTest
5
- } from "./chunk-INKI27D5.js";
6
- import "./chunk-EUXUH3YW.js";
7
- export {
8
- qtiTransformItem,
9
- qtiTransformManifest,
10
- qtiTransformTest
11
- };
1
+ // src/transformers.ts
2
+ export * from "@qti-components/transformers";
12
3
  //# sourceMappingURL=transformers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/transformers.ts"],"sourcesContent":["export * from '@qti-components/transformers';\n"],"mappings":";AAAA,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,19 +1,8 @@
1
1
  {
2
2
  "name": "@citolab/qti-components",
3
- "version": "7.15.0",
3
+ "version": "7.15.2",
4
4
  "description": "QTI component utilities",
5
5
  "main": "dist/index.js",
6
- "scripts": {
7
- "build": "run-p tsup css cem",
8
- "clean": "rm -rf dist cdn",
9
- "attw": "attw --pack --profile esm-only --format table",
10
- "publint": "publint",
11
- "publish": "npm publish --access public",
12
- "-": "---build---",
13
- "tsup": "tsup",
14
- "css": "postcss ../qti-theme/src/item.css -d dist -m",
15
- "cem": "cd ../../ && CEM_OUTDIR=packages/qti-components/ cem analyze --config custom-elements-manifest.config.mjs"
16
- },
17
6
  "keywords": [
18
7
  "qti",
19
8
  "components"
@@ -85,18 +74,30 @@
85
74
  "custom-elements.json"
86
75
  ],
87
76
  "dependencies": {
88
- "@qti-components/test": "workspace:*",
89
- "@qti-components/item": "workspace:*",
90
- "@qti-components/elements": "workspace:*",
91
- "@qti-components/transformers": "workspace:*",
92
- "@qti-components/interactions": "workspace:*",
93
- "@qti-components/processing": "workspace:*",
94
- "@qti-components/loader": "workspace:*",
95
- "@qti-components/base": "workspace:*",
96
- "@qti-components/theme": "workspace:*",
97
77
  "lit": "^3.3.1",
98
78
  "@lit/context": "^1.1.6",
99
79
  "@heximal/templates": "^0.1.5"
100
80
  },
101
- "customElements": "dist/custom-elements.json"
81
+ "peerDependencies": {
82
+ "@qti-components/test": "1.0.0",
83
+ "@qti-components/elements": "1.0.0",
84
+ "@qti-components/transformers": "1.0.0",
85
+ "@qti-components/item": "1.0.0",
86
+ "@qti-components/interactions": "1.0.0",
87
+ "@qti-components/processing": "1.0.0",
88
+ "@qti-components/loader": "1.0.0",
89
+ "@qti-components/base": "1.0.0",
90
+ "@qti-components/theme": "1.0.0"
91
+ },
92
+ "customElements": "dist/custom-elements.json",
93
+ "scripts": {
94
+ "build": "run-p tsup css cem",
95
+ "clean": "rm -rf dist cdn",
96
+ "attw": "attw --pack --profile esm-only --format table",
97
+ "publint": "publint",
98
+ "-": "---build---",
99
+ "tsup": "tsup",
100
+ "css": "postcss ../qti-theme/src/item.css -d dist -m",
101
+ "cem": "cd ../../ && CEM_OUTDIR=packages/qti-components/ cem analyze --config custom-elements-manifest.config.mjs"
102
+ }
102
103
  }
@@ -1,481 +0,0 @@
1
- import {
2
- item_default,
3
- m
4
- } from "./chunk-W4SQRNWO.js";
5
- import {
6
- watch
7
- } from "./chunk-2ZEJ3RR5.js";
8
- import {
9
- qtiTransformItem
10
- } from "./chunk-INKI27D5.js";
11
- import {
12
- c,
13
- computedItemContext,
14
- configContext,
15
- e,
16
- i,
17
- i2,
18
- n,
19
- r,
20
- t,
21
- x
22
- } from "./chunk-JEUY3MYB.js";
23
- import {
24
- __decorateClass
25
- } from "./chunk-EUXUH3YW.js";
26
-
27
- // ../qti-item/src/components/item-container/item-container.ts
28
- var ItemContainer = class extends i2 {
29
- constructor() {
30
- super(...arguments);
31
- this.itemURL = null;
32
- this.itemDoc = null;
33
- this.itemXML = null;
34
- /** Template content if provided */
35
- this.templateContent = null;
36
- }
37
- async handleItemURLChange() {
38
- if (!this.itemURL) return;
39
- try {
40
- const api = await qtiTransformItem().load(this.itemURL);
41
- this.itemDoc = api.htmlDoc();
42
- } catch (error) {
43
- console.error("Error loading or parsing XML:", error);
44
- }
45
- }
46
- handleItemXMLChange() {
47
- if (!this.itemXML) return;
48
- try {
49
- this.itemDoc = qtiTransformItem().parse(this.itemXML).htmlDoc();
50
- } catch (error) {
51
- console.error("Error parsing XML:", error);
52
- }
53
- }
54
- async connectedCallback() {
55
- super.connectedCallback();
56
- this.initializeTemplateContent();
57
- this.applyStyles();
58
- if (this.itemURL) {
59
- this.handleItemURLChange();
60
- }
61
- if (this.itemXML) {
62
- this.handleItemXMLChange();
63
- }
64
- }
65
- initializeTemplateContent() {
66
- const template = this.querySelector("template");
67
- this.templateContent = template ? template.content : x``;
68
- }
69
- applyStyles() {
70
- const sheet = new CSSStyleSheet();
71
- sheet.replaceSync(item_default);
72
- this.shadowRoot.adoptedStyleSheets = [sheet];
73
- }
74
- render() {
75
- return x`
76
- ${this.templateContent}
77
- <slot></slot>
78
- ${m(this.itemDoc, x`<span>Loading...</span>`)}
79
- `;
80
- }
81
- };
82
- __decorateClass([
83
- n({ type: String, attribute: "item-url" })
84
- ], ItemContainer.prototype, "itemURL", 2);
85
- __decorateClass([
86
- r()
87
- ], ItemContainer.prototype, "itemDoc", 2);
88
- __decorateClass([
89
- r()
90
- ], ItemContainer.prototype, "itemXML", 2);
91
- __decorateClass([
92
- watch("itemURL", { waitUntilFirstUpdate: true })
93
- ], ItemContainer.prototype, "handleItemURLChange", 1);
94
- __decorateClass([
95
- watch("itemXML", { waitUntilFirstUpdate: true })
96
- ], ItemContainer.prototype, "handleItemXMLChange", 1);
97
- ItemContainer = __decorateClass([
98
- t("item-container")
99
- ], ItemContainer);
100
-
101
- // ../qti-item/src/components/item-correct-response-mode/item-correct-response-mode.ts
102
- var ItemCorrectResponseMode = class extends i2 {
103
- constructor() {
104
- super(...arguments);
105
- this.label = "Correct response mode";
106
- this._options = {
107
- internal: "Internal",
108
- full: "Full (copy)"
109
- };
110
- }
111
- _switchMode(view) {
112
- this.dispatchEvent(
113
- new CustomEvent("item-switch-correct-response-mode", {
114
- detail: view,
115
- bubbles: true
116
- })
117
- );
118
- }
119
- render() {
120
- return x`
121
- <label part="label" for="modeSelect">${this.label}</label>
122
- <select
123
- part="select"
124
- id="modeSelect"
125
- @change=${(e2) => {
126
- const el = e2.target;
127
- this._switchMode(el.value);
128
- }}
129
- >
130
- ${Object.keys(this._options).map(
131
- (value) => x`<option value="${value}" ?selected=${value === this.itemContext?.correctResponseMode}>
132
- ${this._options[value]}
133
- </option>`
134
- )}
135
- </select>
136
- `;
137
- }
138
- };
139
- __decorateClass([
140
- c({ context: configContext, subscribe: true })
141
- ], ItemCorrectResponseMode.prototype, "itemContext", 2);
142
- __decorateClass([
143
- n({ type: String })
144
- ], ItemCorrectResponseMode.prototype, "label", 2);
145
- __decorateClass([
146
- r()
147
- ], ItemCorrectResponseMode.prototype, "_options", 2);
148
- ItemCorrectResponseMode = __decorateClass([
149
- t("item-correct-response-mode")
150
- ], ItemCorrectResponseMode);
151
-
152
- // ../qti-item/src/components/styles.ts
153
- var form = i`
154
- display: inline-flex;
155
- align-items: center;
156
- cursor: pointer;
157
- padding: 0.5rem 1rem;
158
- border-radius: 0.25rem;
159
- user-select: none;
160
- `;
161
- var btn = i`
162
- background-color: lightgray;
163
- ${form};
164
- `;
165
- var dis = i`
166
- cursor: not-allowed;
167
- opacity: 0.8;
168
- `;
169
- var ind = i`
170
- ${form};
171
- border: 1px solid gray;
172
- `;
173
-
174
- // ../qti-item/src/components/item-show-candidate-correction/item-show-candidate-correction.ts
175
- var ItemShowCandidateCorrection = class extends i2 {
176
- // Store previous active item reference
177
- constructor() {
178
- super();
179
- this.shown = false;
180
- this.disabled = false;
181
- this.showCandidateCorrectionText = "Show candidate correction";
182
- this.hideCandidateCorrectionText = "Hide candidate correction";
183
- this.noCorrectResponseText = "No correct response specified";
184
- this._hasCorrectResponse = false;
185
- // correct response is removed on certain point
186
- this._previousActiveItem = "";
187
- }
188
- updated() {
189
- if (!this._hasCorrectResponse || this._previousActiveItem !== this.computedContext?.identifier) {
190
- this._previousActiveItem = this.computedContext?.identifier;
191
- const containsCorrectResponse = !!this.computedContext?.variables.some((v) => v["correctResponse"]);
192
- const containsMapping = !!this.computedContext?.variables.some((v) => {
193
- return v["mapping"]?.mapEntries?.length > 0 || v["areaMapping"]?.areaMapEntries?.length > 0;
194
- });
195
- this._hasCorrectResponse = containsCorrectResponse || containsMapping;
196
- }
197
- this.disabled = !this._hasCorrectResponse;
198
- }
199
- _toggleState() {
200
- if (this.disabled) return;
201
- this.dispatchEvent(
202
- new CustomEvent("item-show-candidate-correction", {
203
- detail: !this.shown,
204
- bubbles: true
205
- })
206
- );
207
- }
208
- _getDisplayedText() {
209
- return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCandidateCorrectionText : this.showCandidateCorrectionText;
210
- }
211
- render() {
212
- return x` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `;
213
- }
214
- };
215
- ItemShowCandidateCorrection.styles = i`
216
- :host {
217
- ${btn};
218
- }
219
- :host([disabled]) {
220
- ${dis};
221
- }
222
- `;
223
- __decorateClass([
224
- c({ context: computedItemContext, subscribe: true })
225
- ], ItemShowCandidateCorrection.prototype, "computedContext", 2);
226
- __decorateClass([
227
- n({ type: Boolean, reflect: true })
228
- ], ItemShowCandidateCorrection.prototype, "shown", 2);
229
- __decorateClass([
230
- n({ type: Boolean, reflect: true })
231
- ], ItemShowCandidateCorrection.prototype, "disabled", 2);
232
- __decorateClass([
233
- n({ type: String })
234
- ], ItemShowCandidateCorrection.prototype, "showCandidateCorrectionText", 2);
235
- __decorateClass([
236
- n({ type: String })
237
- ], ItemShowCandidateCorrection.prototype, "hideCandidateCorrectionText", 2);
238
- __decorateClass([
239
- n({ type: String })
240
- ], ItemShowCandidateCorrection.prototype, "noCorrectResponseText", 2);
241
- ItemShowCandidateCorrection = __decorateClass([
242
- t("item-show-candidate-correction")
243
- ], ItemShowCandidateCorrection);
244
-
245
- // ../qti-item/src/components/item-show-correct-response/item-show-correct-response.ts
246
- var ItemShowCorrectResponse = class extends i2 {
247
- constructor() {
248
- super(...arguments);
249
- this.shown = false;
250
- this.disabled = false;
251
- this.showCorrectText = "Show correct response";
252
- this.hideCorrectText = "Hide correct response";
253
- this.noCorrectResponseText = "No correct response specified";
254
- this._hasCorrectResponse = false;
255
- // correct response is removed on certain point
256
- this._previousActiveItem = "";
257
- }
258
- // Store previous active item reference
259
- updated() {
260
- if (!this._hasCorrectResponse || this._previousActiveItem !== this.computedContext?.identifier) {
261
- this._previousActiveItem = this.computedContext?.identifier;
262
- const containsCorrectResponse = !!this.computedContext?.variables.some((v) => v["correctResponse"]);
263
- const containsMapping = !!this.computedContext?.variables.some((v) => {
264
- return v["mapping"]?.mapEntries?.length > 0 || v["areaMapping"]?.areaMapEntries?.length > 0;
265
- });
266
- this._hasCorrectResponse = containsCorrectResponse || containsMapping;
267
- }
268
- this.disabled = !this._hasCorrectResponse;
269
- }
270
- _toggleState() {
271
- if (this.disabled) return;
272
- this.dispatchEvent(
273
- new CustomEvent("item-show-correct-response", {
274
- detail: !this.shown,
275
- bubbles: true
276
- })
277
- );
278
- }
279
- _getDisplayedText() {
280
- return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;
281
- }
282
- render() {
283
- return x` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `;
284
- }
285
- };
286
- ItemShowCorrectResponse.styles = i`
287
- :host {
288
- ${btn};
289
- }
290
- :host([disabled]) {
291
- ${dis};
292
- }
293
- `;
294
- __decorateClass([
295
- c({ context: computedItemContext, subscribe: true })
296
- ], ItemShowCorrectResponse.prototype, "computedContext", 2);
297
- __decorateClass([
298
- n({ type: Boolean, reflect: true })
299
- ], ItemShowCorrectResponse.prototype, "shown", 2);
300
- __decorateClass([
301
- n({ type: Boolean, reflect: true })
302
- ], ItemShowCorrectResponse.prototype, "disabled", 2);
303
- __decorateClass([
304
- n({ type: String })
305
- ], ItemShowCorrectResponse.prototype, "showCorrectText", 2);
306
- __decorateClass([
307
- n({ type: String })
308
- ], ItemShowCorrectResponse.prototype, "hideCorrectText", 2);
309
- __decorateClass([
310
- n({ type: String })
311
- ], ItemShowCorrectResponse.prototype, "noCorrectResponseText", 2);
312
- ItemShowCorrectResponse = __decorateClass([
313
- t("item-show-correct-response")
314
- ], ItemShowCorrectResponse);
315
-
316
- // ../qti-item/src/components/item-print-variables/item-print-variables.ts
317
- var ItemPrintVariables = class extends i2 {
318
- render() {
319
- const activeItem = this.computedContext;
320
- if (!activeItem || !activeItem.variables) return x``;
321
- const responseVariables = activeItem.variables.filter((v) => v.type === "response");
322
- const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
323
- const renderTable = (variables, title) => x`
324
- <h3>${title}</h3>
325
- <table>
326
- <thead>
327
- <tr>
328
- <th>Identifier</th>
329
- <th>Value</th>
330
- <th>Cardinality</th>
331
- <th>Base Type</th>
332
- <th>Correct Response / Mappings</th>
333
- </tr>
334
- </thead>
335
- <tbody>
336
- ${variables.map((v) => {
337
- const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
338
- const mapEntries = v.mapping?.mapEntries?.map((m2) => `${m2.mapKey}=${m2.mappedValue}pt`).join(", ") || "";
339
- const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m2) => `${m2.shape}(${m2.coords})=${m2.mappedValue}pt`).join(", ") || "";
340
- return x`
341
- <tr>
342
- <td>${v.identifier}</td>
343
- <td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
344
- <td>${v.cardinality}</td>
345
- <td>${v.baseType}</td>
346
- <td>${correctResponse || mapEntries || areaMapEntries}</td>
347
- </tr>
348
- `;
349
- })}
350
- </tbody>
351
- </table>
352
- `;
353
- return x`
354
- ${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
355
- `;
356
- }
357
- };
358
- ItemPrintVariables.styles = i`
359
- table {
360
- width: 100%;
361
- border-collapse: collapse;
362
- margin: 20px 0;
363
- font-size: 14px;
364
- text-align: left;
365
- }
366
- th,
367
- td {
368
- border: 1px solid #ddd;
369
- padding: 8px;
370
- }
371
- th {
372
- background-color: #f4f4f4;
373
- font-weight: bold;
374
- }
375
- h3 {
376
- margin-top: 20px;
377
- font-size: 16px;
378
- }
379
- `;
380
- __decorateClass([
381
- c({ context: computedItemContext, subscribe: true })
382
- ], ItemPrintVariables.prototype, "computedContext", 2);
383
- ItemPrintVariables = __decorateClass([
384
- t("item-print-variables")
385
- ], ItemPrintVariables);
386
-
387
- // ../qti-item/src/components/qti-item/qti-item.ts
388
- var QtiItem = class extends i2 {
389
- constructor() {
390
- super();
391
- this.configContext = {};
392
- // Store event handlers as instance properties
393
- this._onItemContextChanged = this._handleItemContextChanged.bind(this);
394
- this._onAssessmentItemConnected = this._handleAssessmentItemConnected.bind(this);
395
- this._onHandleShowCorrectResponse = this._handleShowCorrectResponse.bind(this);
396
- this._onHandleShowCandidateCorrection = this._handleShowCandidateCorrection.bind(this);
397
- this._onHandleSwitchCorrectResponseMode = this._handleSwitchCorrectResponseMode.bind(this);
398
- this.addEventListener("qti-item-context-updated", this._onItemContextChanged);
399
- this.addEventListener("qti-assessment-item-connected", this._onAssessmentItemConnected);
400
- this.addEventListener("item-show-correct-response", this._onHandleShowCorrectResponse);
401
- this.addEventListener("item-show-candidate-correction", this._onHandleShowCandidateCorrection);
402
- this.addEventListener("item-switch-correct-response-mode", this._onHandleSwitchCorrectResponseMode);
403
- }
404
- _handleItemContextChanged(e2) {
405
- this._updateItemVariablesInTestContext(e2.detail.itemContext.identifier, e2.detail?.itemContext?.variables || []);
406
- }
407
- _handleAssessmentItemConnected(e2) {
408
- const fullVariables = e2.detail._context.variables;
409
- this._qtiAssessmentItem = e2.detail;
410
- this.computedContext = this.computedContext?.identifier === this._qtiAssessmentItem.identifier ? { ...this.computedContext, title: this._qtiAssessmentItem.title } : {
411
- identifier: this._qtiAssessmentItem.identifier,
412
- title: this._qtiAssessmentItem.title,
413
- adaptive: this._qtiAssessmentItem.getAttribute("adaptive")?.toLowerCase() === "true" || false,
414
- variables: fullVariables,
415
- correctResponseMode: "internal"
416
- };
417
- this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier, fullVariables || []);
418
- }
419
- _handleShowCorrectResponse(e2) {
420
- if (this._qtiAssessmentItem) {
421
- this._qtiAssessmentItem.showCorrectResponse(e2.detail);
422
- }
423
- }
424
- _handleShowCandidateCorrection(e2) {
425
- if (this._qtiAssessmentItem) {
426
- this._qtiAssessmentItem.showCandidateCorrection(e2.detail);
427
- }
428
- }
429
- _handleSwitchCorrectResponseMode(e2) {
430
- this._handleShowCorrectResponse(new CustomEvent("item-show-correct-response", { detail: false, bubbles: true }));
431
- this.configContext = {
432
- ...this.configContext,
433
- correctResponseMode: e2.detail
434
- };
435
- }
436
- _updateItemVariablesInTestContext(identifier, variables) {
437
- const rawscore = variables?.find((vr) => vr.identifier == "SCORE")?.value;
438
- const score = parseFloat(rawscore?.toString());
439
- const completionStatus = variables?.find((v) => v.identifier === "completionStatus")?.value;
440
- const correct = score !== void 0 && !isNaN(score) && score > 0;
441
- const incorrect = score !== void 0 && !isNaN(score) && score <= 0;
442
- const completed = completionStatus === "completed";
443
- this.computedContext = {
444
- ...this.computedContext,
445
- identifier,
446
- correct,
447
- incorrect,
448
- completed,
449
- variables
450
- };
451
- }
452
- render() {
453
- return x`<slot></slot>`;
454
- }
455
- disconnectedCallback() {
456
- super.disconnectedCallback();
457
- this.removeEventListener("qti-item-context-changed", this._onItemContextChanged);
458
- this.removeEventListener("qti-assessment-item-connected", this._onAssessmentItemConnected);
459
- }
460
- };
461
- __decorateClass([
462
- r(),
463
- e({ context: computedItemContext })
464
- ], QtiItem.prototype, "computedContext", 2);
465
- __decorateClass([
466
- r(),
467
- e({ context: configContext })
468
- ], QtiItem.prototype, "configContext", 2);
469
- QtiItem = __decorateClass([
470
- t("qti-item")
471
- ], QtiItem);
472
-
473
- export {
474
- ItemContainer,
475
- ItemCorrectResponseMode,
476
- ItemShowCandidateCorrection,
477
- ItemShowCorrectResponse,
478
- ItemPrintVariables,
479
- QtiItem
480
- };
481
- //# sourceMappingURL=chunk-2DOYPVF5.js.map