@citolab/qti-components 7.28.1 → 8.0.1
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.
- package/cdn/index.global.js +1 -1
- package/cdn/index.js +6316 -2710
- package/dist/base.d.ts +100 -15
- package/dist/base.js +27 -6
- package/dist/chunk-3AJOQCDU.js +11 -0
- package/dist/chunk-3AJOQCDU.js.map +1 -0
- package/dist/chunk-64XSIBGO.js +241 -0
- package/dist/chunk-64XSIBGO.js.map +1 -0
- package/dist/chunk-7HC5SMCU.js +102 -0
- package/dist/chunk-7HC5SMCU.js.map +1 -0
- package/dist/{chunk-SP6S2WMG.js → chunk-7V4HJFHW.js} +3 -3
- package/dist/{chunk-SP6S2WMG.js.map → chunk-7V4HJFHW.js.map} +1 -1
- package/dist/chunk-CAO4JRLY.js +11 -0
- package/dist/chunk-CAO4JRLY.js.map +1 -0
- package/dist/{chunk-MPC7LIPC.js → chunk-F4BNJWYN.js} +4264 -3647
- package/dist/chunk-F4BNJWYN.js.map +1 -0
- package/dist/{chunk-3XV26R5M.js → chunk-H3J7LFRO.js} +829 -1005
- package/dist/chunk-H3J7LFRO.js.map +1 -0
- package/dist/{chunk-3WBG257S.js → chunk-IJD53WY6.js} +96 -74
- package/dist/chunk-IJD53WY6.js.map +1 -0
- package/dist/chunk-LVBIQDPM.js +1374 -0
- package/dist/chunk-LVBIQDPM.js.map +1 -0
- package/dist/{chunk-REI3AMCZ.js → chunk-NA2N2WSG.js} +1303 -1193
- package/dist/chunk-NA2N2WSG.js.map +1 -0
- package/dist/chunk-QECOPVPO.js +294 -0
- package/dist/chunk-QECOPVPO.js.map +1 -0
- package/dist/{chunk-HFCZFWSH.js → chunk-RXGDQDOV.js} +1993 -1764
- package/dist/chunk-RXGDQDOV.js.map +1 -0
- package/dist/chunk-V5G7X53Y.js +11 -0
- package/dist/chunk-V5G7X53Y.js.map +1 -0
- package/dist/{chunk-WDO2TRFM.js → chunk-WVVMNF74.js} +851 -925
- package/dist/chunk-WVVMNF74.js.map +1 -0
- package/dist/{chunk-FLJAKWXL.js → chunk-X3E5HXG2.js} +2 -2
- package/dist/chunk-XU7HNT4F.js +1608 -0
- package/dist/chunk-XU7HNT4F.js.map +1 -0
- package/dist/{computed-item.context-DfsW_96S.d.ts → computed-item.types.d-BKZdSLLJ.d.ts} +2 -5
- package/dist/{computed.context-DHbxad0N.d.ts → computed.types.d-rKLSPvVG.d.ts} +2 -5
- package/dist/config.context.d-BvU9r-Mg.d.ts +91 -0
- package/dist/corrections.d.ts +432 -0
- package/dist/corrections.js +84 -0
- package/dist/elements.d.ts +8 -14
- package/dist/elements.js +6 -5
- package/dist/index.d.ts +51 -16
- package/dist/index.js +193 -76
- package/dist/interaction.d-D4MstYRz.d.ts +115 -0
- package/dist/interaction.interface.d-CvjHM2bi.d.ts +46 -0
- package/dist/interactions.d.ts +1206 -552
- package/dist/interactions.js +19 -15
- package/dist/item.css +4228 -1656
- package/dist/item.d.ts +13 -55
- package/dist/item.js +6 -11
- package/dist/{variables-CMYcDbyW.d.ts → item.types.d-QU7LljEK.d.ts} +13 -1
- package/dist/loader.d.ts +4 -4
- package/dist/loader.js +2 -3
- package/dist/processing.d.ts +6 -7
- package/dist/processing.js +2 -3
- package/dist/qti-components-jsx.d.ts +5348 -2709
- package/dist/qti-components-jsx.js +1 -0
- package/dist/qti-condition-expression.d-aMvBvpc6.d.ts +8 -0
- package/dist/{qti-condition-expression-Dam-RER6.d.ts → qti-expression.d-BietT_8b.d.ts} +14 -9
- package/dist/{qti-feedback-ChmXhZuf.d.ts → qti-feedback.d-DZbad0RN.d.ts} +1 -1
- package/dist/{qti-transform-test-DoZaWItm.d.ts → qti-transform-test.d-BL7GGFJj.d.ts} +2 -2
- package/dist/response.d-_8y4kjGP.d.ts +106 -0
- package/dist/test.d.ts +199 -39
- package/dist/test.js +34 -11
- package/dist/transformers.d.ts +1 -1
- package/dist/transformers.js +1 -2
- package/package.json +24 -17
- package/custom-elements.json +0 -43251
- package/dist/chunk-3WBG257S.js.map +0 -1
- package/dist/chunk-3XV26R5M.js.map +0 -1
- package/dist/chunk-AQ5RJFM6.js +0 -3673
- package/dist/chunk-AQ5RJFM6.js.map +0 -1
- package/dist/chunk-HFCZFWSH.js.map +0 -1
- package/dist/chunk-MPC7LIPC.js.map +0 -1
- package/dist/chunk-QXBXORM3.js +0 -27
- package/dist/chunk-REI3AMCZ.js.map +0 -1
- package/dist/chunk-RLTYVS2I.js +0 -530
- package/dist/chunk-RLTYVS2I.js.map +0 -1
- package/dist/chunk-WDO2TRFM.js.map +0 -1
- package/dist/config.context-BjZ2bZSY.d.ts +0 -42
- package/dist/interaction-Bgzlw7Iu.d.ts +0 -110
- package/dist/item.context-CkUeDcaO.d.ts +0 -15
- package/dist/test.context-CByZZjkR.d.ts +0 -15
- /package/dist/{chunk-FLJAKWXL.js.map → chunk-X3E5HXG2.js.map} +0 -0
- /package/dist/{chunk-QXBXORM3.js.map → corrections.js.map} +0 -0
- /package/dist/{qti-rule-base-ajOnfGXY.d.ts → qti-rule-base.d-ajOnfGXY.d.ts} +0 -0
- /package/dist/{qti.context-CejJMlfZ.d.ts → qti.context.d-CejJMlfZ.d.ts} +0 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import {
|
|
2
|
+
item_default,
|
|
3
|
+
m
|
|
4
|
+
} from "./chunk-7HC5SMCU.js";
|
|
5
|
+
import {
|
|
6
|
+
watch
|
|
7
|
+
} from "./chunk-64XSIBGO.js";
|
|
8
|
+
import {
|
|
9
|
+
qtiTransformItem
|
|
10
|
+
} from "./chunk-IJD53WY6.js";
|
|
11
|
+
import {
|
|
12
|
+
T,
|
|
13
|
+
c,
|
|
14
|
+
computedItemContext,
|
|
15
|
+
configContext,
|
|
16
|
+
e,
|
|
17
|
+
i,
|
|
18
|
+
i2,
|
|
19
|
+
n2 as n,
|
|
20
|
+
qtiContext,
|
|
21
|
+
r
|
|
22
|
+
} from "./chunk-H3J7LFRO.js";
|
|
23
|
+
|
|
24
|
+
// ../qti-item/dist/components/item-container/item-container.js
|
|
25
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
26
|
+
var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
+
else for (var i3 = decorators.length - 1; i3 >= 0; i3--) if (d = decorators[i3]) r2 = (c2 < 3 ? d(r2) : c2 > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
29
|
+
return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
30
|
+
};
|
|
31
|
+
var ItemContainer = class extends i2 {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
this.customElementRegistry = null;
|
|
35
|
+
this.itemURL = null;
|
|
36
|
+
this.itemDoc = null;
|
|
37
|
+
this.itemXML = null;
|
|
38
|
+
this.qtiContext = {
|
|
39
|
+
QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
|
|
40
|
+
};
|
|
41
|
+
this.#templateContent = null;
|
|
42
|
+
this.#resolvedCustomElementRegistry = null;
|
|
43
|
+
}
|
|
44
|
+
/** Template content if provided */
|
|
45
|
+
#templateContent;
|
|
46
|
+
#resolvedCustomElementRegistry;
|
|
47
|
+
createRenderRoot() {
|
|
48
|
+
const registry = this.customElementRegistry;
|
|
49
|
+
this.#resolvedCustomElementRegistry = registry;
|
|
50
|
+
return this.shadowRoot ?? this.attachShadow({
|
|
51
|
+
...this.constructor.shadowRootOptions,
|
|
52
|
+
...registry ? { customElementRegistry: registry } : {}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async handleItemURLChange() {
|
|
56
|
+
if (!this.itemURL)
|
|
57
|
+
return;
|
|
58
|
+
try {
|
|
59
|
+
const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
|
|
60
|
+
const api = (await qtiTransformItem().load(this.itemURL)).shuffleInteractions(explicitSeed);
|
|
61
|
+
this.itemDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error("Error loading or parsing XML:", error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
handleItemXMLChange() {
|
|
67
|
+
if (!this.itemXML)
|
|
68
|
+
return;
|
|
69
|
+
try {
|
|
70
|
+
this.itemDoc = qtiTransformItem().parse(this.itemXML).htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error("Error parsing XML:", error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async connectedCallback() {
|
|
76
|
+
super.connectedCallback();
|
|
77
|
+
this.#initializeTemplateContent();
|
|
78
|
+
this.#applyStyles();
|
|
79
|
+
if (this.itemURL) {
|
|
80
|
+
this.handleItemURLChange();
|
|
81
|
+
}
|
|
82
|
+
if (this.itemXML) {
|
|
83
|
+
this.handleItemXMLChange();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
#initializeTemplateContent() {
|
|
87
|
+
const template = this.querySelector("template");
|
|
88
|
+
this.#templateContent = template ? template.content : T``;
|
|
89
|
+
}
|
|
90
|
+
#applyStyles() {
|
|
91
|
+
const sheet = new CSSStyleSheet();
|
|
92
|
+
sheet.replaceSync(item_default);
|
|
93
|
+
this.shadowRoot.adoptedStyleSheets = [sheet];
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
return T`
|
|
97
|
+
${this.#templateContent}
|
|
98
|
+
<slot></slot>
|
|
99
|
+
${m(this.itemDoc, T`<span>Loading...</span>`)}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
__decorate([
|
|
104
|
+
n({ attribute: false })
|
|
105
|
+
], ItemContainer.prototype, "customElementRegistry", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
n({ type: String, attribute: "item-url" })
|
|
108
|
+
], ItemContainer.prototype, "itemURL", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
r()
|
|
111
|
+
], ItemContainer.prototype, "itemDoc", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
r()
|
|
114
|
+
], ItemContainer.prototype, "itemXML", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
r(),
|
|
117
|
+
c({ context: qtiContext, subscribe: true })
|
|
118
|
+
], ItemContainer.prototype, "qtiContext", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
watch("itemURL", { waitUntilFirstUpdate: true })
|
|
121
|
+
], ItemContainer.prototype, "handleItemURLChange", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
watch("itemXML", { waitUntilFirstUpdate: true })
|
|
124
|
+
], ItemContainer.prototype, "handleItemXMLChange", null);
|
|
125
|
+
|
|
126
|
+
// ../qti-item/dist/components/item-print-variables/item-print-variables.js
|
|
127
|
+
var __decorate2 = function(decorators, target, key, desc) {
|
|
128
|
+
var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
129
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
130
|
+
else for (var i3 = decorators.length - 1; i3 >= 0; i3--) if (d = decorators[i3]) r2 = (c2 < 3 ? d(r2) : c2 > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
131
|
+
return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
132
|
+
};
|
|
133
|
+
var ItemPrintVariables = class extends i2 {
|
|
134
|
+
static {
|
|
135
|
+
this.styles = i`
|
|
136
|
+
table {
|
|
137
|
+
width: 100%;
|
|
138
|
+
border-collapse: collapse;
|
|
139
|
+
margin: 20px 0;
|
|
140
|
+
font-size: 14px;
|
|
141
|
+
text-align: left;
|
|
142
|
+
}
|
|
143
|
+
th,
|
|
144
|
+
td {
|
|
145
|
+
border: 1px solid #ddd;
|
|
146
|
+
padding: 8px;
|
|
147
|
+
}
|
|
148
|
+
th {
|
|
149
|
+
background-color: #f4f4f4;
|
|
150
|
+
font-weight: bold;
|
|
151
|
+
}
|
|
152
|
+
h3 {
|
|
153
|
+
margin-top: 20px;
|
|
154
|
+
font-size: 16px;
|
|
155
|
+
}
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
const activeItem = this.computedContext;
|
|
160
|
+
if (!activeItem || !activeItem.variables)
|
|
161
|
+
return T``;
|
|
162
|
+
const responseVariables = activeItem.variables.filter((v) => v.type === "response");
|
|
163
|
+
const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
|
|
164
|
+
const renderTable = (variables, title) => T`
|
|
165
|
+
<h3>${title}</h3>
|
|
166
|
+
<table>
|
|
167
|
+
<thead>
|
|
168
|
+
<tr>
|
|
169
|
+
<th>Identifier</th>
|
|
170
|
+
<th>Value</th>
|
|
171
|
+
<th>Cardinality</th>
|
|
172
|
+
<th>Base Type</th>
|
|
173
|
+
<th>Correct Response / Mappings</th>
|
|
174
|
+
</tr>
|
|
175
|
+
</thead>
|
|
176
|
+
<tbody>
|
|
177
|
+
${variables.map((v) => {
|
|
178
|
+
const correctResponse = v.correctResponse ? Array.isArray(v.correctResponse) ? v.correctResponse.join(", ") : v.correctResponse : "";
|
|
179
|
+
const mapEntries = v.mapping?.mapEntries?.map((m2) => `${m2.mapKey}=${m2.mappedValue}pt`).join(", ") || "";
|
|
180
|
+
const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m2) => `${m2.shape}(${m2.coords})=${m2.mappedValue}pt`).join(", ") || "";
|
|
181
|
+
return T`
|
|
182
|
+
<tr>
|
|
183
|
+
<td>${v.identifier}</td>
|
|
184
|
+
<td>${Array.isArray(v.value) ? v.value.join(", ") : v.value}</td>
|
|
185
|
+
<td>${v.cardinality}</td>
|
|
186
|
+
<td>${v.baseType}</td>
|
|
187
|
+
<td>${correctResponse || mapEntries || areaMapEntries}</td>
|
|
188
|
+
</tr>
|
|
189
|
+
`;
|
|
190
|
+
})}
|
|
191
|
+
</tbody>
|
|
192
|
+
</table>
|
|
193
|
+
`;
|
|
194
|
+
return T`
|
|
195
|
+
${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
|
|
196
|
+
`;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
__decorate2([
|
|
200
|
+
c({ context: computedItemContext, subscribe: true })
|
|
201
|
+
], ItemPrintVariables.prototype, "computedContext", void 0);
|
|
202
|
+
|
|
203
|
+
// ../qti-item/dist/components/qti-item/qti-item.js
|
|
204
|
+
var __decorate3 = function(decorators, target, key, desc) {
|
|
205
|
+
var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
206
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
|
|
207
|
+
else for (var i3 = decorators.length - 1; i3 >= 0; i3--) if (d = decorators[i3]) r2 = (c2 < 3 ? d(r2) : c2 > 3 ? d(target, key, r2) : d(target, key)) || r2;
|
|
208
|
+
return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2;
|
|
209
|
+
};
|
|
210
|
+
var QtiItem = class extends i2 {
|
|
211
|
+
// Store event handlers as instance properties
|
|
212
|
+
#onItemContextChanged;
|
|
213
|
+
#onAssessmentItemConnected;
|
|
214
|
+
constructor() {
|
|
215
|
+
super();
|
|
216
|
+
this.configContext = {};
|
|
217
|
+
this.qtiContext = {
|
|
218
|
+
QTI_CONTEXT: {
|
|
219
|
+
testIdentifier: "",
|
|
220
|
+
candidateIdentifier: "",
|
|
221
|
+
environmentIdentifier: "default"
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
this.#onItemContextChanged = this.#handleItemContextChanged.bind(this);
|
|
225
|
+
this.#onAssessmentItemConnected = this.#handleAssessmentItemConnected.bind(this);
|
|
226
|
+
this.addEventListener("qti-item-context-updated", this.#onItemContextChanged);
|
|
227
|
+
this.addEventListener("qti-assessment-item-connected", this.#onAssessmentItemConnected);
|
|
228
|
+
}
|
|
229
|
+
#handleItemContextChanged(e2) {
|
|
230
|
+
this.#updateItemVariablesInTestContext(e2.detail.itemContext.identifier, e2.detail?.itemContext?.variables || []);
|
|
231
|
+
}
|
|
232
|
+
#handleAssessmentItemConnected(e2) {
|
|
233
|
+
const fullVariables = e2.detail._context.variables;
|
|
234
|
+
this.assessmentItem = e2.detail;
|
|
235
|
+
this.computedContext = this.computedContext?.identifier === this.assessmentItem.identifier ? { ...this.computedContext, title: this.assessmentItem.title } : {
|
|
236
|
+
identifier: this.assessmentItem.identifier,
|
|
237
|
+
title: this.assessmentItem.title,
|
|
238
|
+
adaptive: this.assessmentItem.getAttribute("adaptive")?.toLowerCase() === "true" || false,
|
|
239
|
+
variables: fullVariables
|
|
240
|
+
};
|
|
241
|
+
this.#updateItemVariablesInTestContext(this.assessmentItem.identifier, fullVariables || []);
|
|
242
|
+
}
|
|
243
|
+
#updateItemVariablesInTestContext(identifier, variables) {
|
|
244
|
+
const rawscore = variables?.find((vr) => vr.identifier == "SCORE")?.value;
|
|
245
|
+
const score = parseFloat(rawscore?.toString());
|
|
246
|
+
const completionStatus = variables?.find((v) => v.identifier === "completionStatus")?.value;
|
|
247
|
+
const correct = score !== void 0 && !isNaN(score) && score > 0;
|
|
248
|
+
const incorrect = score !== void 0 && !isNaN(score) && score <= 0;
|
|
249
|
+
const completed = completionStatus === "completed";
|
|
250
|
+
this.computedContext = {
|
|
251
|
+
...this.computedContext,
|
|
252
|
+
identifier,
|
|
253
|
+
correct,
|
|
254
|
+
incorrect,
|
|
255
|
+
completed,
|
|
256
|
+
variables
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
render() {
|
|
260
|
+
return T`<slot></slot>`;
|
|
261
|
+
}
|
|
262
|
+
disconnectedCallback() {
|
|
263
|
+
super.disconnectedCallback();
|
|
264
|
+
this.removeEventListener("qti-item-context-changed", this.#onItemContextChanged);
|
|
265
|
+
this.removeEventListener("qti-assessment-item-connected", this.#onAssessmentItemConnected);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
__decorate3([
|
|
269
|
+
r(),
|
|
270
|
+
e({ context: computedItemContext })
|
|
271
|
+
], QtiItem.prototype, "computedContext", void 0);
|
|
272
|
+
__decorate3([
|
|
273
|
+
r(),
|
|
274
|
+
e({ context: configContext })
|
|
275
|
+
], QtiItem.prototype, "configContext", void 0);
|
|
276
|
+
__decorate3([
|
|
277
|
+
r(),
|
|
278
|
+
e({ context: qtiContext })
|
|
279
|
+
], QtiItem.prototype, "qtiContext", void 0);
|
|
280
|
+
|
|
281
|
+
// ../qti-item/dist/elements.js
|
|
282
|
+
var qtiItemElements = [
|
|
283
|
+
{ tag: "item-container", ctor: ItemContainer },
|
|
284
|
+
{ tag: "item-print-variables", ctor: ItemPrintVariables },
|
|
285
|
+
{ tag: "qti-item", ctor: QtiItem }
|
|
286
|
+
];
|
|
287
|
+
|
|
288
|
+
export {
|
|
289
|
+
ItemContainer,
|
|
290
|
+
ItemPrintVariables,
|
|
291
|
+
QtiItem,
|
|
292
|
+
qtiItemElements
|
|
293
|
+
};
|
|
294
|
+
//# sourceMappingURL=chunk-QECOPVPO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../qti-item/src/components/item-container/item-container.ts","../../qti-item/src/components/item-print-variables/item-print-variables.ts","../../qti-item/src/components/qti-item/qti-item.ts","../../qti-item/src/elements.ts"],"sourcesContent":["import { consume } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { until } from 'lit/directives/until.js';\n\nimport { qtiContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\nimport { qtiTransformItem } from '@qti-components/transformers';\n\n// eslint-disable-next-line import/no-relative-packages\nimport itemCss from '../../../../qti-theme/src/item.css?inline';\n\nimport type { QtiContext } from '@qti-components/base';\n\n/**\n * `<item-container>` is a custom element designed for hosting the qti-assessment-item.\n * The `qti-assessment-item` will be placed inside the shadow DOM of this element.\n * The element loads the item from the provided URL and renders it inside the shadow DOM.\n *\n * ### Styling\n * Add a class to the element for styling.\n *\n * ```html\n * <qti-item>\n * <item-container class=\"m-4 bg-white\" item-url=\"./path/to/item.xml\"></item-container>\n * </qti-item>\n * ```\n */\n\nexport class ItemContainer extends LitElement {\n /** Scoped registry used by the item shadow root. Must be set before connection. */\n @property({ attribute: false })\n customElementRegistry: CustomElementRegistry | null = null;\n\n /** URL of the item to load */\n @property({ type: String, attribute: 'item-url' })\n itemURL: string = null;\n\n /** A parsed HTML document */\n @state()\n itemDoc: DocumentFragment = null;\n\n /** The raw XML string */\n @state()\n itemXML: string = null;\n\n @state()\n @consume({ context: qtiContext, subscribe: true })\n protected qtiContext: QtiContext = {\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n };\n\n /** Template content if provided */\n #templateContent: unknown = null;\n #resolvedCustomElementRegistry: CustomElementRegistry | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const registry = this.customElementRegistry;\n\n this.#resolvedCustomElementRegistry = registry;\n\n return (\n this.shadowRoot ??\n this.attachShadow({\n ...(this.constructor as typeof ItemContainer).shadowRootOptions,\n ...(registry ? { customElementRegistry: registry } : {})\n })\n );\n }\n\n @watch('itemURL', { waitUntilFirstUpdate: true })\n protected async handleItemURLChange() {\n if (!this.itemURL) return;\n try {\n const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;\n const api = (await qtiTransformItem().load(this.itemURL)).shuffleInteractions(explicitSeed);\n this.itemDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? undefined);\n } catch (error) {\n console.error('Error loading or parsing XML:', error);\n }\n }\n\n @watch('itemXML', { waitUntilFirstUpdate: true })\n protected handleItemXMLChange() {\n if (!this.itemXML) return;\n try {\n this.itemDoc = qtiTransformItem()\n .parse(this.itemXML)\n .htmlDoc(this.#resolvedCustomElementRegistry ?? undefined);\n } catch (error) {\n console.error('Error parsing XML:', error);\n }\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n this.#initializeTemplateContent();\n this.#applyStyles();\n if (this.itemURL) {\n this.handleItemURLChange();\n }\n if (this.itemXML) {\n this.handleItemXMLChange();\n }\n }\n\n #initializeTemplateContent() {\n const template = this.querySelector('template') as HTMLTemplateElement;\n this.#templateContent = template ? template.content : html``;\n }\n\n #applyStyles() {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(itemCss);\n this.shadowRoot.adoptedStyleSheets = [sheet];\n }\n\n override render() {\n return html`\n ${this.#templateContent}\n <slot></slot>\n ${until(this.itemDoc, html`<span>Loading...</span>`)}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'item-container': ItemContainer;\n }\n}\n","import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\n\nimport { computedItemContext } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\nimport type { ComputedItemContext } from '@qti-components/base';\n\nexport class ItemPrintVariables extends LitElement {\n @consume({ context: computedItemContext, subscribe: true })\n protected computedContext?: ComputedItemContext;\n\n static override styles = css`\n table {\n width: 100%;\n border-collapse: collapse;\n margin: 20px 0;\n font-size: 14px;\n text-align: left;\n }\n th,\n td {\n border: 1px solid #ddd;\n padding: 8px;\n }\n th {\n background-color: #f4f4f4;\n font-weight: bold;\n }\n h3 {\n margin-top: 20px;\n font-size: 16px;\n }\n `;\n\n override render() {\n const activeItem = this.computedContext;\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const responseVariables: ResponseVariable[] = activeItem.variables.filter(v => v.type === 'response');\n const outcomeVariables = activeItem.variables.filter(v => v.type === 'outcome');\n\n const renderTable = (variables: ResponseVariable[], title: string) => html`\n <h3>${title}</h3>\n <table>\n <thead>\n <tr>\n <th>Identifier</th>\n <th>Value</th>\n <th>Cardinality</th>\n <th>Base Type</th>\n <th>Correct Response / Mappings</th>\n </tr>\n </thead>\n <tbody>\n ${variables.map(v => {\n const correctResponse = v.correctResponse\n ? Array.isArray(v.correctResponse)\n ? v.correctResponse.join(', ')\n : v.correctResponse\n : '';\n\n const mapEntries = v.mapping?.mapEntries?.map(m => `${m.mapKey}=${m.mappedValue}pt`).join(', ') || '';\n\n const areaMapEntries =\n v.areaMapping?.areaMapEntries?.map(m => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(', ') || '';\n\n return html`\n <tr>\n <td>${v.identifier}</td>\n <td>${Array.isArray(v.value) ? v.value.join(', ') : v.value}</td>\n <td>${v.cardinality}</td>\n <td>${v.baseType}</td>\n <td>${correctResponse || mapEntries || areaMapEntries}</td>\n </tr>\n `;\n })}\n </tbody>\n </table>\n `;\n\n return html`\n ${renderTable(responseVariables, 'Response Variables')} ${renderTable(outcomeVariables, 'Outcome Variables')}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'item-print-variables': ItemPrintVariables;\n }\n}\n","import { provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { computedItemContext } from '@qti-components/base';\nimport { configContext } from '@qti-components/base';\nimport { qtiContext } from '@qti-components/base';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { QtiContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\nimport type { VariableDeclaration } from '@qti-components/base';\nimport type { ComputedItemContext } from '@qti-components/base';\n\n/**\n * `<qti-item>` is a custom element designed for rendering a single `qti-assessment-item`.\n * It can also host some functionalities to interact with the item like scoring, showing feedback, etc.\n * Placing a mandatory `<item-container>` inside '<qti-item>' will load or parse the item and render it.\n * See `<item-container>` for more details.\n *\n * ```html\n * <qti-item>\n * <item-container class=\"m-4 bg-white\" item-url=\"./path/to/item.xml\"></item-container>\n * </qti-item>\n * ```\n */\n\nexport class QtiItem extends LitElement {\n @state()\n @provide({ context: computedItemContext })\n public computedContext: ComputedItemContext;\n protected assessmentItem?: QtiAssessmentItem;\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n /**\n * Provided so that descendants (e.g. `<item-container>`) can read the QTI runtime\n * context for standalone item delivery, including the optional shuffle `seed`.\n */\n @state()\n @provide({ context: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\n\n // Store event handlers as instance properties\n #onItemContextChanged = this.#handleItemContextChanged.bind(this);\n #onAssessmentItemConnected = this.#handleAssessmentItemConnected.bind(this);\n\n constructor() {\n super();\n this.addEventListener('qti-item-context-updated', this.#onItemContextChanged);\n this.addEventListener('qti-assessment-item-connected', this.#onAssessmentItemConnected);\n }\n\n #handleItemContextChanged(e: CustomEvent<{ itemContext: ItemContext }>) {\n this.#updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail?.itemContext?.variables || []);\n }\n\n #handleAssessmentItemConnected(e: CustomEvent<QtiAssessmentItem>) {\n const fullVariables = (e.detail as any)._context.variables;\n this.assessmentItem = e.detail;\n this.computedContext =\n this.computedContext?.identifier === this.assessmentItem.identifier\n ? { ...this.computedContext, title: this.assessmentItem.title }\n : ({\n identifier: this.assessmentItem.identifier,\n title: this.assessmentItem.title,\n adaptive: this.assessmentItem.getAttribute('adaptive')?.toLowerCase() === 'true' || false,\n variables: fullVariables\n } as ComputedItemContext);\n this.#updateItemVariablesInTestContext(this.assessmentItem.identifier, fullVariables || []);\n }\n\n #updateItemVariablesInTestContext(\n identifier: string,\n variables: readonly VariableDeclaration<string | string[] | null>[]\n ): void {\n const rawscore = variables?.find(vr => vr.identifier == 'SCORE')?.value;\n const score = parseFloat(rawscore?.toString());\n const completionStatus = variables?.find(v => v.identifier === 'completionStatus')?.value;\n\n const correct = score !== undefined && !isNaN(score) && score > 0;\n const incorrect = score !== undefined && !isNaN(score) && score <= 0;\n const completed = completionStatus === 'completed';\n this.computedContext = {\n ...this.computedContext,\n identifier,\n correct,\n incorrect,\n completed,\n variables\n };\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('qti-item-context-changed', this.#onItemContextChanged);\n this.removeEventListener('qti-assessment-item-connected', this.#onAssessmentItemConnected);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-item': QtiItem;\n }\n}\n","import { ItemContainer } from './components/item-container/item-container';\nimport { ItemPrintVariables } from './components/item-print-variables/item-print-variables';\nimport { QtiItem } from './components/qti-item/qti-item';\n\nexport { ItemContainer, ItemPrintVariables, QtiItem };\n\nexport const qtiItemElements = [\n { tag: 'item-container', ctor: ItemContainer },\n { tag: 'item-print-variables', ctor: ItemPrintVariables },\n { tag: 'qti-item', ctor: QtiItem }\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BM,IAAO,gBAAP,cAA6BA,GAAU;EAA7C,cAAA;;AAGE,SAAA,wBAAsD;AAItD,SAAA,UAAkB;AAIlB,SAAA,UAA4B;AAI5B,SAAA,UAAkB;AAIR,SAAA,aAAyB;MACjC,aAAa,EAAE,gBAAgB,IAAI,qBAAqB,IAAI,uBAAuB,UAAS;;AAI9F,SAAA,mBAA4B;AAC5B,SAAA,iCAA+D;EAsEjE;;EAvEE;EACA;EAEmB,mBAAgB;AACjC,UAAM,WAAW,KAAK;AAEtB,SAAK,iCAAiC;AAEtC,WACE,KAAK,cACL,KAAK,aAAa;MAChB,GAAI,KAAK,YAAqC;MAC9C,GAAI,WAAW,EAAE,uBAAuB,SAAQ,IAAK,CAAA;KACtD;EAEL;EAGU,MAAM,sBAAmB;AACjC,QAAI,CAAC,KAAK;AAAS;AACnB,QAAI;AACF,YAAM,eAAe,KAAK,YAAY,aAAa;AACnD,YAAM,OAAO,MAAM,iBAAgB,EAAG,KAAK,KAAK,OAAO,GAAG,oBAAo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