@citolab/qti-components 7.14.3 → 7.15.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.
- package/cdn/index.global.js +1 -1
- package/cdn/index.js +4044 -4030
- package/custom-elements.json +10478 -26460
- package/dist/base.d.ts +8 -0
- package/dist/base.js +50 -0
- package/dist/{chunks/chunk-DGBI4IU5.js → chunk-2DOYPVF5.js} +252 -136
- package/dist/chunk-2DOYPVF5.js.map +1 -0
- package/dist/chunk-2ZEJ3RR5.js +89 -0
- package/dist/chunk-2ZEJ3RR5.js.map +1 -0
- package/dist/{chunks/chunk-E4GR4K26.js → chunk-352OTVTY.js} +1481 -442
- package/dist/chunk-352OTVTY.js.map +1 -0
- package/dist/{chunks/chunk-C4ELTNV7.js → chunk-C2HQFI2C.js} +857 -3819
- package/dist/chunk-C2HQFI2C.js.map +1 -0
- package/dist/chunk-DWIRLYDS.js +20 -0
- package/dist/chunk-DWIRLYDS.js.map +1 -0
- package/dist/{chunks/chunk-H2JE6IVU.js → chunk-EUXUH3YW.js} +1 -1
- package/dist/chunk-F44CI35W.js +145 -0
- package/dist/chunk-F44CI35W.js.map +1 -0
- package/dist/{chunks/chunk-XBPO6E25.js → chunk-INKI27D5.js} +6 -5
- package/dist/chunk-INKI27D5.js.map +1 -0
- package/dist/chunk-JEUY3MYB.js +2010 -0
- package/dist/chunk-JEUY3MYB.js.map +1 -0
- package/dist/chunk-O4XIWHTF.js +1139 -0
- package/dist/chunk-O4XIWHTF.js.map +1 -0
- package/dist/chunk-RI47B4ZT.js +1753 -0
- package/dist/chunk-RI47B4ZT.js.map +1 -0
- package/dist/{qti-loader/index.js → chunk-VEV4DGPH.js} +6 -6
- package/dist/chunk-VEV4DGPH.js.map +1 -0
- package/dist/{chunks/chunk-TN75CWLX.js → chunk-W4SQRNWO.js} +97 -2
- package/dist/chunk-W4SQRNWO.js.map +1 -0
- package/dist/elements.d.ts +1 -0
- package/dist/elements.js +42 -0
- package/dist/index.d.ts +8 -24
- package/dist/index.js +117 -285
- package/dist/index.js.map +1 -1
- package/dist/interactions.d.ts +1 -0
- package/dist/interactions.js +72 -0
- package/dist/item.d.ts +1 -0
- package/dist/item.js +23 -0
- package/dist/loader.d.ts +1 -0
- package/dist/loader.js +11 -0
- package/dist/processing.d.ts +1 -0
- package/dist/processing.js +103 -0
- package/dist/qti-components-jsx.d.ts +1475 -2388
- package/dist/test.d.ts +1 -0
- package/dist/{qti-test/index.js → test.js} +11 -19
- package/dist/transformers.d.ts +1 -0
- package/dist/{qti-transformers/index.js → transformers.js} +3 -3
- package/dist/vscode.html-custom-data.json +469 -631
- package/package.json +70 -166
- package/LICENSE.md +0 -674
- package/dist/chunks/chunk-4OGJBG35.js +0 -8
- package/dist/chunks/chunk-4OGJBG35.js.map +0 -1
- package/dist/chunks/chunk-AGV5GOTF.js +0 -234
- package/dist/chunks/chunk-AGV5GOTF.js.map +0 -1
- package/dist/chunks/chunk-BHJSX3Q6.js +0 -8
- package/dist/chunks/chunk-BHJSX3Q6.js.map +0 -1
- package/dist/chunks/chunk-C4ELTNV7.js.map +0 -1
- package/dist/chunks/chunk-C5RLRG3L.js +0 -10
- package/dist/chunks/chunk-C5RLRG3L.js.map +0 -1
- package/dist/chunks/chunk-CJADUWEC.js +0 -10
- package/dist/chunks/chunk-CJADUWEC.js.map +0 -1
- package/dist/chunks/chunk-DGBI4IU5.js.map +0 -1
- package/dist/chunks/chunk-DVQQ7I6Y.js +0 -8
- package/dist/chunks/chunk-DVQQ7I6Y.js.map +0 -1
- package/dist/chunks/chunk-E4GR4K26.js.map +0 -1
- package/dist/chunks/chunk-ELDMXTUQ.js +0 -31
- package/dist/chunks/chunk-ELDMXTUQ.js.map +0 -1
- package/dist/chunks/chunk-GAAFN7QF.js +0 -146
- package/dist/chunks/chunk-GAAFN7QF.js.map +0 -1
- package/dist/chunks/chunk-H6KHXSIO.js +0 -8
- package/dist/chunks/chunk-H6KHXSIO.js.map +0 -1
- package/dist/chunks/chunk-JQ6HWGRY.js +0 -22
- package/dist/chunks/chunk-JQ6HWGRY.js.map +0 -1
- package/dist/chunks/chunk-NJNQOQUU.js +0 -8
- package/dist/chunks/chunk-NJNQOQUU.js.map +0 -1
- package/dist/chunks/chunk-P4QBOVQ2.js +0 -206
- package/dist/chunks/chunk-P4QBOVQ2.js.map +0 -1
- package/dist/chunks/chunk-SV4K25ZI.js +0 -19
- package/dist/chunks/chunk-SV4K25ZI.js.map +0 -1
- package/dist/chunks/chunk-TN75CWLX.js.map +0 -1
- package/dist/chunks/chunk-XBPO6E25.js.map +0 -1
- package/dist/exports/computed-item.context.d.ts +0 -23
- package/dist/exports/computed-item.context.js +0 -8
- package/dist/exports/computed.context.d.ts +0 -34
- package/dist/exports/computed.context.js +0 -8
- package/dist/exports/config.context.d.ts +0 -14
- package/dist/exports/config.context.js +0 -8
- package/dist/exports/expression-result.d.ts +0 -19
- package/dist/exports/expression-result.js +0 -1
- package/dist/exports/interaction.d.ts +0 -46
- package/dist/exports/interaction.interface.d.ts +0 -13
- package/dist/exports/interaction.interface.js +0 -1
- package/dist/exports/interaction.js +0 -12
- package/dist/exports/item.context.d.ts +0 -11
- package/dist/exports/item.context.js +0 -8
- package/dist/exports/qti-assessment-item.context.d.ts +0 -9
- package/dist/exports/qti-assessment-item.context.js +0 -8
- package/dist/exports/qti-condition-expression.d.ts +0 -14
- package/dist/exports/qti-condition-expression.js +0 -11
- package/dist/exports/qti-condition-expression.js.map +0 -1
- package/dist/exports/qti-expression.d.ts +0 -23
- package/dist/exports/qti-expression.js +0 -10
- package/dist/exports/qti-expression.js.map +0 -1
- package/dist/exports/qti-test.d.ts +0 -12
- package/dist/exports/qti-test.js +0 -1
- package/dist/exports/qti-test.js.map +0 -1
- package/dist/exports/qti.context.d.ts +0 -14
- package/dist/exports/qti.context.js +0 -8
- package/dist/exports/qti.context.js.map +0 -1
- package/dist/exports/session.context.d.ts +0 -15
- package/dist/exports/session.context.js +0 -10
- package/dist/exports/session.context.js.map +0 -1
- package/dist/exports/test.context.d.ts +0 -16
- package/dist/exports/test.context.js +0 -10
- package/dist/exports/test.context.js.map +0 -1
- package/dist/exports/variables.d.ts +0 -2
- package/dist/exports/variables.js +0 -1
- package/dist/exports/variables.js.map +0 -1
- package/dist/qti-assessment-item-l-mN3teH.d.ts +0 -105
- package/dist/qti-components/index.d.ts +0 -1524
- package/dist/qti-components/index.js +0 -216
- package/dist/qti-components/index.js.map +0 -1
- package/dist/qti-item/index.d.ts +0 -114
- package/dist/qti-item/index.js +0 -19
- package/dist/qti-item/index.js.map +0 -1
- package/dist/qti-loader/index.d.ts +0 -21
- package/dist/qti-loader/index.js.map +0 -1
- package/dist/qti-modal-feedback-Cp3CHVKw.d.ts +0 -30
- package/dist/qti-test/index.d.ts +0 -480
- package/dist/qti-test/index.js.map +0 -1
- package/dist/qti-test-mmY8zNIj.d.ts +0 -120
- package/dist/qti-transform-test-Bz9A3hmD.d.ts +0 -63
- package/dist/qti-transformers/index.d.ts +0 -18
- package/dist/qti-transformers/index.js.map +0 -1
- package/dist/variables-BCkyLoXK.d.ts +0 -55
- package/readme.md +0 -59
- /package/dist/{chunks/chunk-H2JE6IVU.js.map → base.js.map} +0 -0
- /package/dist/{exports/computed-item.context.js.map → chunk-EUXUH3YW.js.map} +0 -0
- /package/dist/{exports/computed.context.js.map → elements.js.map} +0 -0
- /package/dist/{exports/config.context.js.map → interactions.js.map} +0 -0
- /package/dist/{exports/expression-result.js.map → item.js.map} +0 -0
- /package/dist/{exports/interaction.interface.js.map → loader.js.map} +0 -0
- /package/dist/{exports/interaction.js.map → processing.js.map} +0 -0
- /package/dist/{exports/item.context.js.map → test.js.map} +0 -0
- /package/dist/{exports/qti-assessment-item.context.js.map → transformers.js.map} +0 -0
|
@@ -0,0 +1,1139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
o
|
|
3
|
+
} from "./chunk-DWIRLYDS.js";
|
|
4
|
+
import {
|
|
5
|
+
watch
|
|
6
|
+
} from "./chunk-2ZEJ3RR5.js";
|
|
7
|
+
import {
|
|
8
|
+
qtiTransformItem
|
|
9
|
+
} from "./chunk-INKI27D5.js";
|
|
10
|
+
import {
|
|
11
|
+
QtiFeedback,
|
|
12
|
+
QtiVariableDeclaration,
|
|
13
|
+
c,
|
|
14
|
+
e,
|
|
15
|
+
i,
|
|
16
|
+
i2,
|
|
17
|
+
itemContext,
|
|
18
|
+
itemContextVariables,
|
|
19
|
+
n,
|
|
20
|
+
r,
|
|
21
|
+
t,
|
|
22
|
+
x
|
|
23
|
+
} from "./chunk-JEUY3MYB.js";
|
|
24
|
+
import {
|
|
25
|
+
__decorateClass
|
|
26
|
+
} from "./chunk-EUXUH3YW.js";
|
|
27
|
+
|
|
28
|
+
// ../qti-elements/src/components/qti-assessment-item/qti-assessment-item.ts
|
|
29
|
+
var QtiAssessmentItem = class extends i2 {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this._templateProcessing = null;
|
|
33
|
+
this.identifier = "";
|
|
34
|
+
this.adaptive = "false";
|
|
35
|
+
this.timeDependent = null;
|
|
36
|
+
this._handleDisabledChange = (_, disabled) => {
|
|
37
|
+
this._interactionElements.forEach((ch) => ch.disabled = disabled);
|
|
38
|
+
};
|
|
39
|
+
this._handleReadonlyChange = (_, readonly) => this._interactionElements.forEach((ch) => ch.readonly = readonly);
|
|
40
|
+
this._context = {
|
|
41
|
+
variables: itemContextVariables
|
|
42
|
+
};
|
|
43
|
+
this._initialContext = { ...this._context, variables: this._context.variables };
|
|
44
|
+
this._feedbackElements = [];
|
|
45
|
+
this._interactionElements = [];
|
|
46
|
+
this._handleRegisterVariable = (e2) => {
|
|
47
|
+
e2.stopImmediatePropagation();
|
|
48
|
+
this._context = { ...this._context, variables: [...this._context.variables, e2.detail.variable] };
|
|
49
|
+
this._initialContext = this._context;
|
|
50
|
+
e2.stopPropagation();
|
|
51
|
+
};
|
|
52
|
+
this._handleRegisterFeedback = (e2) => {
|
|
53
|
+
e2.stopImmediatePropagation();
|
|
54
|
+
const feedbackElement = e2.detail;
|
|
55
|
+
this._feedbackElements.push(feedbackElement);
|
|
56
|
+
const numAttempts = Number(this._context.variables.find((v) => v.identifier === "numAttempts")?.value) || 0;
|
|
57
|
+
if (numAttempts > 0) {
|
|
58
|
+
feedbackElement.checkShowFeedback(feedbackElement.outcomeIdentifier);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
this._handleRegisterInteraction = (e2) => {
|
|
62
|
+
e2.stopImmediatePropagation();
|
|
63
|
+
this._interactionElements.push(e2.detail.interactionElement);
|
|
64
|
+
};
|
|
65
|
+
this._handleEndAttempt = (e2) => {
|
|
66
|
+
e2.stopImmediatePropagation();
|
|
67
|
+
const { responseIdentifier, countAttempt } = e2.detail;
|
|
68
|
+
this.validate();
|
|
69
|
+
this.updateResponseVariable(responseIdentifier, "true");
|
|
70
|
+
this.processResponse(countAttempt);
|
|
71
|
+
};
|
|
72
|
+
this._handleSetOutcomeValue = (e2) => {
|
|
73
|
+
e2.stopImmediatePropagation();
|
|
74
|
+
const { outcomeIdentifier, value } = e2.detail;
|
|
75
|
+
this.updateOutcomeVariable(outcomeIdentifier, value);
|
|
76
|
+
e2.stopPropagation();
|
|
77
|
+
};
|
|
78
|
+
this._handleUpdateResponseVariable = (e2) => {
|
|
79
|
+
e2.stopImmediatePropagation();
|
|
80
|
+
const { responseIdentifier, response } = e2.detail;
|
|
81
|
+
this.updateResponseVariable(responseIdentifier, response);
|
|
82
|
+
this.dispatchEvent(
|
|
83
|
+
new CustomEvent("qti-item-context-updated", {
|
|
84
|
+
bubbles: true,
|
|
85
|
+
composed: true,
|
|
86
|
+
detail: { itemContext: this._context }
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
get title() {
|
|
92
|
+
return this._itemTitle;
|
|
93
|
+
}
|
|
94
|
+
set title(value) {
|
|
95
|
+
this._itemTitle = value;
|
|
96
|
+
this.removeAttribute("title");
|
|
97
|
+
this.setAttribute("data-title", value);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sets the identifier for the assessment item reference if this item is in a test.
|
|
101
|
+
*
|
|
102
|
+
* @param identifier - The identifier for the assessment item reference.
|
|
103
|
+
*/
|
|
104
|
+
set assessmentItemRefId(identifier) {
|
|
105
|
+
this._context = { ...this._context, identifier };
|
|
106
|
+
}
|
|
107
|
+
get assessmentItemRefId() {
|
|
108
|
+
return this._context.identifier;
|
|
109
|
+
}
|
|
110
|
+
get variables() {
|
|
111
|
+
return this._context.variables.map((v) => ({
|
|
112
|
+
identifier: v.identifier,
|
|
113
|
+
value: v.value,
|
|
114
|
+
type: v.type,
|
|
115
|
+
// add externalscored, a fixed prop to the test, so the testcontext can read and decide how to score this item
|
|
116
|
+
...v.type === "outcome" && v.identifier === "SCORE" ? { externalScored: v.externalScored } : {}
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
set variables(value) {
|
|
120
|
+
if (!Array.isArray(value) || value.some((v) => !("identifier" in v))) {
|
|
121
|
+
console.warn("variables property should be an array of VariableDeclaration");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this._context = {
|
|
125
|
+
...this._context,
|
|
126
|
+
variables: this._context.variables.map((variable) => {
|
|
127
|
+
const matchingValue = value.find((v) => v.identifier === variable.identifier);
|
|
128
|
+
if (matchingValue) {
|
|
129
|
+
return {
|
|
130
|
+
...variable,
|
|
131
|
+
...matchingValue,
|
|
132
|
+
interpolationTable: variable.interpolationTable
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return variable;
|
|
136
|
+
})
|
|
137
|
+
};
|
|
138
|
+
this._context.variables.forEach((variable) => {
|
|
139
|
+
if (variable.type === "response") {
|
|
140
|
+
const interactionElement = this._interactionElements.find(
|
|
141
|
+
(el) => el.responseIdentifier === variable.identifier
|
|
142
|
+
);
|
|
143
|
+
if (interactionElement) {
|
|
144
|
+
interactionElement.response = variable.value;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
this.variables.forEach((variable) => {
|
|
149
|
+
if (variable.type === "outcome") {
|
|
150
|
+
this._feedbackElements.forEach((fe) => fe.checkShowFeedback(variable.identifier));
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/** @deprecated use variables property instead */
|
|
155
|
+
set responses(myResponses) {
|
|
156
|
+
if (myResponses) {
|
|
157
|
+
for (const response of myResponses) {
|
|
158
|
+
const responseVariable = this.getResponse(response.responseIdentifier);
|
|
159
|
+
if (responseVariable) {
|
|
160
|
+
this.updateResponseVariable(response.responseIdentifier, response.response);
|
|
161
|
+
}
|
|
162
|
+
const interaction = this._interactionElements.find(
|
|
163
|
+
(i3) => i3.getAttribute("response-identifier") === response.responseIdentifier
|
|
164
|
+
);
|
|
165
|
+
if (interaction) {
|
|
166
|
+
interaction.response = response.response;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
render() {
|
|
172
|
+
return x`<slot></slot>`;
|
|
173
|
+
}
|
|
174
|
+
connectedCallback() {
|
|
175
|
+
this._attachEventListeners();
|
|
176
|
+
super.connectedCallback();
|
|
177
|
+
this.updateComplete.then(() => {
|
|
178
|
+
this.dispatchEvent(
|
|
179
|
+
new CustomEvent("qti-assessment-item-connected", {
|
|
180
|
+
bubbles: true,
|
|
181
|
+
composed: true,
|
|
182
|
+
detail: this
|
|
183
|
+
})
|
|
184
|
+
);
|
|
185
|
+
this._processTemplates();
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
disconnectedCallback() {
|
|
189
|
+
this._removeEventListeners();
|
|
190
|
+
super.disconnectedCallback();
|
|
191
|
+
}
|
|
192
|
+
_attachEventListeners() {
|
|
193
|
+
this.addEventListener("qti-register-variable", this._handleRegisterVariable);
|
|
194
|
+
this.addEventListener("qti-register-feedback", this._handleRegisterFeedback);
|
|
195
|
+
this.addEventListener("qti-register-interaction", this._handleRegisterInteraction);
|
|
196
|
+
this.addEventListener("end-attempt", this._handleEndAttempt);
|
|
197
|
+
this.addEventListener("qti-set-outcome-value", this._handleSetOutcomeValue);
|
|
198
|
+
this.addEventListener("qti-interaction-response", this._handleUpdateResponseVariable);
|
|
199
|
+
}
|
|
200
|
+
_removeEventListeners() {
|
|
201
|
+
this.removeEventListener("qti-register-variable", this._handleRegisterVariable);
|
|
202
|
+
this.removeEventListener("qti-register-feedback", this._handleRegisterFeedback);
|
|
203
|
+
this.removeEventListener("qti-register-interaction", this._handleRegisterInteraction);
|
|
204
|
+
this.removeEventListener("end-attempt", this._handleEndAttempt);
|
|
205
|
+
this.removeEventListener("qti-set-outcome-value", this._handleSetOutcomeValue);
|
|
206
|
+
this.removeEventListener("qti-interaction-response", this._handleUpdateResponseVariable);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Toggles the display of correct responses for all interactions.
|
|
210
|
+
* @param show - A boolean indicating whether to show or hide correct responses.
|
|
211
|
+
*/
|
|
212
|
+
showCorrectResponse(show) {
|
|
213
|
+
for (const interaction of this._interactionElements) {
|
|
214
|
+
interaction.toggleCorrectResponse(show);
|
|
215
|
+
}
|
|
216
|
+
document.querySelectorAll("item-show-correct-response").forEach((el) => {
|
|
217
|
+
el.shown = show;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Toggles the display of the candidate correction for all interactions.
|
|
222
|
+
* @param show - A boolean indicating whether to show or hide candidate correction.
|
|
223
|
+
*/
|
|
224
|
+
showCandidateCorrection(show) {
|
|
225
|
+
for (const interaction of this._interactionElements) {
|
|
226
|
+
interaction.toggleCandidateCorrection(show);
|
|
227
|
+
}
|
|
228
|
+
document.querySelectorAll("item-show-candidate-correction").forEach((el) => {
|
|
229
|
+
el.shown = show;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
_processTemplates() {
|
|
233
|
+
this._templateProcessing = this.querySelector("qti-template-processing");
|
|
234
|
+
if (this._templateProcessing) {
|
|
235
|
+
this._templateProcessing.process();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
processResponse(countNumAttempts = true, reportValidityAfterScoring = true) {
|
|
239
|
+
this.validate(reportValidityAfterScoring);
|
|
240
|
+
if (countNumAttempts) {
|
|
241
|
+
this.updateOutcomeVariable(
|
|
242
|
+
"numAttempts",
|
|
243
|
+
(+this._context.variables.find((v) => v.identifier === "numAttempts")?.value + 1).toString()
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
const responseProcessor = this.querySelector("qti-response-processing");
|
|
247
|
+
if (!responseProcessor) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
if (!responseProcessor.process) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
responseProcessor.process();
|
|
254
|
+
if (this.adaptive === "false") {
|
|
255
|
+
this.updateOutcomeVariable("completionStatus", this._getCompletionStatus());
|
|
256
|
+
}
|
|
257
|
+
this.dispatchEvent(
|
|
258
|
+
new CustomEvent("qti-item-context-updated", {
|
|
259
|
+
bubbles: true,
|
|
260
|
+
composed: true,
|
|
261
|
+
detail: { itemContext: this._context }
|
|
262
|
+
})
|
|
263
|
+
);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
resetResponses() {
|
|
267
|
+
this._context = this._initialContext;
|
|
268
|
+
}
|
|
269
|
+
getResponse(identifier) {
|
|
270
|
+
return this.getVariable(identifier);
|
|
271
|
+
}
|
|
272
|
+
getOutcome(identifier) {
|
|
273
|
+
return this.getVariable(identifier);
|
|
274
|
+
}
|
|
275
|
+
getVariable(identifier) {
|
|
276
|
+
return this._context.variables.find((v) => v.identifier === identifier) || null;
|
|
277
|
+
}
|
|
278
|
+
// saving privates here: ------------------------------------------------------------------------------
|
|
279
|
+
/**
|
|
280
|
+
* Updates the response variable with the specified identifier to the given value.
|
|
281
|
+
*
|
|
282
|
+
* @protected
|
|
283
|
+
*
|
|
284
|
+
* This method is intended for internal use within the class and subclasses.
|
|
285
|
+
* It should not be called externally by third parties.
|
|
286
|
+
*
|
|
287
|
+
* @param identifier - The identifier of the response variable to update.
|
|
288
|
+
* @param value - The new value for the response variable.
|
|
289
|
+
*/
|
|
290
|
+
updateResponseVariable(identifier, value) {
|
|
291
|
+
this._context = {
|
|
292
|
+
...this._context,
|
|
293
|
+
variables: this._context.variables.map((v) => v.identifier !== identifier ? v : { ...v, value })
|
|
294
|
+
};
|
|
295
|
+
this.showCandidateCorrection(false);
|
|
296
|
+
this.dispatchEvent(
|
|
297
|
+
new CustomEvent("qti-interaction-changed", {
|
|
298
|
+
bubbles: true,
|
|
299
|
+
composed: true,
|
|
300
|
+
detail: {
|
|
301
|
+
item: this.identifier,
|
|
302
|
+
responseIdentifier: identifier,
|
|
303
|
+
response: Array.isArray(value) ? [...value] : value
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
);
|
|
307
|
+
if (this.adaptive === "false") {
|
|
308
|
+
this.updateOutcomeVariable("completionStatus", this._getCompletionStatus());
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
setOutcomeVariable(identifier, value) {
|
|
312
|
+
this.updateOutcomeVariable(identifier, value);
|
|
313
|
+
this.dispatchEvent(
|
|
314
|
+
new CustomEvent("qti-item-context-updated", {
|
|
315
|
+
bubbles: true,
|
|
316
|
+
composed: true,
|
|
317
|
+
detail: { itemContext: this._context }
|
|
318
|
+
})
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Updates the outcome variable with the specified identifier to the given value.
|
|
323
|
+
*
|
|
324
|
+
* @protected
|
|
325
|
+
*
|
|
326
|
+
* This method is intended for internal use within the class and subclasses.
|
|
327
|
+
* It should not be called externally by third parties.
|
|
328
|
+
*
|
|
329
|
+
* @param identifier - The identifier of the response variable to update.
|
|
330
|
+
* @param value - The new value for the response variable.
|
|
331
|
+
*/
|
|
332
|
+
updateOutcomeVariable(identifier, value) {
|
|
333
|
+
const outcomeVariable = this.getOutcome(identifier);
|
|
334
|
+
if (!outcomeVariable) {
|
|
335
|
+
console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
this._context = {
|
|
339
|
+
...this._context,
|
|
340
|
+
variables: this._context.variables.map((v) => {
|
|
341
|
+
if (v.identifier !== identifier) {
|
|
342
|
+
return v;
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
...v,
|
|
346
|
+
value: outcomeVariable.cardinality === "single" ? value : Array.isArray(value) ? value : [value]
|
|
347
|
+
};
|
|
348
|
+
})
|
|
349
|
+
};
|
|
350
|
+
this._feedbackElements.forEach((fe) => fe.checkShowFeedback(identifier));
|
|
351
|
+
this.dispatchEvent(
|
|
352
|
+
new CustomEvent("qti-outcome-changed", {
|
|
353
|
+
bubbles: true,
|
|
354
|
+
composed: true,
|
|
355
|
+
detail: {
|
|
356
|
+
item: this.identifier,
|
|
357
|
+
outcomeIdentifier: identifier,
|
|
358
|
+
value: this._context.variables.find((v) => v.identifier === identifier)?.value
|
|
359
|
+
}
|
|
360
|
+
})
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
validate(reportValidity = true) {
|
|
364
|
+
const isValid = this._interactionElements.every((interactionElement) => interactionElement.validate());
|
|
365
|
+
if (reportValidity) {
|
|
366
|
+
this.reportValidity();
|
|
367
|
+
}
|
|
368
|
+
return isValid;
|
|
369
|
+
}
|
|
370
|
+
reportValidity() {
|
|
371
|
+
for (const interactionElement of this._interactionElements) {
|
|
372
|
+
interactionElement.reportValidity();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
_getCompletionStatus() {
|
|
376
|
+
const valid = this.validate(false);
|
|
377
|
+
if (valid === true) return "completed";
|
|
378
|
+
if (valid === false) return "incomplete";
|
|
379
|
+
return "not_attempted";
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
__decorateClass([
|
|
383
|
+
n({ type: String })
|
|
384
|
+
], QtiAssessmentItem.prototype, "identifier", 2);
|
|
385
|
+
__decorateClass([
|
|
386
|
+
n({ type: String })
|
|
387
|
+
], QtiAssessmentItem.prototype, "adaptive", 2);
|
|
388
|
+
__decorateClass([
|
|
389
|
+
n({ type: String })
|
|
390
|
+
], QtiAssessmentItem.prototype, "timeDependent", 2);
|
|
391
|
+
__decorateClass([
|
|
392
|
+
n({ type: String })
|
|
393
|
+
], QtiAssessmentItem.prototype, "title", 1);
|
|
394
|
+
__decorateClass([
|
|
395
|
+
n({ type: Boolean })
|
|
396
|
+
], QtiAssessmentItem.prototype, "disabled", 2);
|
|
397
|
+
__decorateClass([
|
|
398
|
+
watch("disabled", { waitUntilFirstUpdate: true })
|
|
399
|
+
], QtiAssessmentItem.prototype, "_handleDisabledChange", 2);
|
|
400
|
+
__decorateClass([
|
|
401
|
+
n({ type: Boolean })
|
|
402
|
+
], QtiAssessmentItem.prototype, "readonly", 2);
|
|
403
|
+
__decorateClass([
|
|
404
|
+
watch("readonly", { waitUntilFirstUpdate: true })
|
|
405
|
+
], QtiAssessmentItem.prototype, "_handleReadonlyChange", 2);
|
|
406
|
+
__decorateClass([
|
|
407
|
+
e({ context: itemContext })
|
|
408
|
+
], QtiAssessmentItem.prototype, "_context", 2);
|
|
409
|
+
QtiAssessmentItem = __decorateClass([
|
|
410
|
+
t("qti-assessment-item")
|
|
411
|
+
], QtiAssessmentItem);
|
|
412
|
+
|
|
413
|
+
// ../qti-elements/src/components/qti-assessment-stimulus-ref/qti-assessment-stimulus-ref.ts
|
|
414
|
+
var QtiAssessmentStimulusRefConnectedEvent = class _QtiAssessmentStimulusRefConnectedEvent extends Event {
|
|
415
|
+
constructor(element, item) {
|
|
416
|
+
super(_QtiAssessmentStimulusRefConnectedEvent.eventName, { bubbles: true, composed: true, cancelable: true });
|
|
417
|
+
this.element = element;
|
|
418
|
+
this.item = item;
|
|
419
|
+
}
|
|
420
|
+
static {
|
|
421
|
+
this.eventName = "qti-assessment-stimulus-ref-connected";
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
var QtiAssessmentStimulusRef = class extends i2 {
|
|
425
|
+
constructor() {
|
|
426
|
+
super(...arguments);
|
|
427
|
+
this.identifier = "";
|
|
428
|
+
this.href = "";
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Lifecycle method called when the element is connected to the DOM.
|
|
432
|
+
* First checks if there's a data-stimulus-idref element. If found, loads the stimulus directly.
|
|
433
|
+
* If not found, delegates to the delivery platform via an event.
|
|
434
|
+
*/
|
|
435
|
+
async connectedCallback() {
|
|
436
|
+
super.connectedCallback();
|
|
437
|
+
await this.updateComplete;
|
|
438
|
+
const item = this.closest("qti-assessment-item");
|
|
439
|
+
const event = new QtiAssessmentStimulusRefConnectedEvent(this, item);
|
|
440
|
+
this.dispatchEvent(event);
|
|
441
|
+
const stimulusRef = item?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);
|
|
442
|
+
if (!event.defaultPrevented && stimulusRef) {
|
|
443
|
+
await this.updateStimulusRef(stimulusRef);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Loads and appends the stimulus to the specified element.
|
|
448
|
+
* @param stimulusRef - The element to which the stimulus will be appended.
|
|
449
|
+
*/
|
|
450
|
+
async updateStimulusRef(stimulusRef) {
|
|
451
|
+
const stimulus = await qtiTransformItem().load(this.href).then((api) => api.htmlDoc());
|
|
452
|
+
if (stimulus) {
|
|
453
|
+
const elements = stimulus.querySelectorAll("qti-stimulus-body, qti-stylesheet");
|
|
454
|
+
stimulusRef.innerHTML = "";
|
|
455
|
+
stimulusRef.append(...elements);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
__decorateClass([
|
|
460
|
+
n({ type: String })
|
|
461
|
+
], QtiAssessmentStimulusRef.prototype, "identifier", 2);
|
|
462
|
+
__decorateClass([
|
|
463
|
+
n({ type: String })
|
|
464
|
+
], QtiAssessmentStimulusRef.prototype, "href", 2);
|
|
465
|
+
QtiAssessmentStimulusRef = __decorateClass([
|
|
466
|
+
t("qti-assessment-stimulus-ref")
|
|
467
|
+
], QtiAssessmentStimulusRef);
|
|
468
|
+
|
|
469
|
+
// ../qti-elements/src/components/qti-companion-materials-info/qti-companion-materials-info.ts
|
|
470
|
+
var QtiCompanionMaterialsInfo = class extends i2 {
|
|
471
|
+
// static override styles = css`
|
|
472
|
+
// slot {
|
|
473
|
+
// display: hidden;
|
|
474
|
+
// }
|
|
475
|
+
// `;
|
|
476
|
+
// override render() {
|
|
477
|
+
// return html` <slot></slot> `;
|
|
478
|
+
// }
|
|
479
|
+
};
|
|
480
|
+
QtiCompanionMaterialsInfo = __decorateClass([
|
|
481
|
+
t("qti-companion-materials-info")
|
|
482
|
+
], QtiCompanionMaterialsInfo);
|
|
483
|
+
|
|
484
|
+
// ../qti-elements/src/components/qti-custom-operator/qti-custom-operator.ts
|
|
485
|
+
var QtiCustomOperator = class extends i2 {
|
|
486
|
+
render() {
|
|
487
|
+
return x`<slot @slotchange=${this.handleSlotChange}></slot>`;
|
|
488
|
+
}
|
|
489
|
+
handleSlotChange() {
|
|
490
|
+
const commentNode = Array.from(this.firstElementChild?.childNodes ?? []).find(
|
|
491
|
+
(node) => node.nodeType === Node.COMMENT_NODE
|
|
492
|
+
);
|
|
493
|
+
try {
|
|
494
|
+
this.operatorFunction = new Function("context", "fn", "item", commentNode?.textContent ?? "");
|
|
495
|
+
} catch (e2) {
|
|
496
|
+
console.error("custom-operator contains invalid javascript code", e2);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
calculate() {
|
|
500
|
+
const fn = {
|
|
501
|
+
variable: (responseIdentifier) => this._context?.variables.find((v) => v.identifier === responseIdentifier)?.value ?? "",
|
|
502
|
+
correct: (responseIdentifier) => this._context?.variables.find((v) => v.identifier === responseIdentifier)?.correctResponse ?? ""
|
|
503
|
+
};
|
|
504
|
+
const item = {
|
|
505
|
+
getVariable: (variableIdentifier) => this._context?.variables.find((v) => v.identifier === variableIdentifier),
|
|
506
|
+
updateOutcomeVariable: (outcomeIdentifier, value) => {
|
|
507
|
+
this.dispatchEvent(
|
|
508
|
+
new CustomEvent("qti-set-outcome-value", {
|
|
509
|
+
bubbles: true,
|
|
510
|
+
composed: true,
|
|
511
|
+
detail: {
|
|
512
|
+
outcomeIdentifier,
|
|
513
|
+
value
|
|
514
|
+
}
|
|
515
|
+
})
|
|
516
|
+
);
|
|
517
|
+
},
|
|
518
|
+
updateResponseVariable: (responseIdentifier, response) => {
|
|
519
|
+
this.dispatchEvent(
|
|
520
|
+
new CustomEvent("qti-interaction-response", {
|
|
521
|
+
bubbles: true,
|
|
522
|
+
composed: true,
|
|
523
|
+
detail: {
|
|
524
|
+
responseIdentifier,
|
|
525
|
+
response
|
|
526
|
+
}
|
|
527
|
+
})
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
return this.operatorFunction(this._context, fn, item);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
__decorateClass([
|
|
535
|
+
c({ context: itemContext, subscribe: true }),
|
|
536
|
+
r()
|
|
537
|
+
], QtiCustomOperator.prototype, "_context", 2);
|
|
538
|
+
QtiCustomOperator = __decorateClass([
|
|
539
|
+
t("qti-custom-operator")
|
|
540
|
+
], QtiCustomOperator);
|
|
541
|
+
|
|
542
|
+
// ../qti-elements/src/components/qti-feedback-block/qti-feedback-block.ts
|
|
543
|
+
var QtiFeedbackBlock = class extends QtiFeedback {
|
|
544
|
+
render() {
|
|
545
|
+
return x` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `;
|
|
546
|
+
}
|
|
547
|
+
connectedCallback() {
|
|
548
|
+
super.connectedCallback();
|
|
549
|
+
this.checkShowFeedback(this.outcomeIdentifier);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
QtiFeedbackBlock.styles = i`
|
|
553
|
+
:host {
|
|
554
|
+
display: block;
|
|
555
|
+
}
|
|
556
|
+
.on {
|
|
557
|
+
display: block;
|
|
558
|
+
}
|
|
559
|
+
.off {
|
|
560
|
+
display: none;
|
|
561
|
+
}
|
|
562
|
+
`;
|
|
563
|
+
QtiFeedbackBlock = __decorateClass([
|
|
564
|
+
t("qti-feedback-block")
|
|
565
|
+
], QtiFeedbackBlock);
|
|
566
|
+
|
|
567
|
+
// ../qti-elements/src/components/qti-feedback-inline/qti-feedback-inline.ts
|
|
568
|
+
var QtiFeedbackInline = class extends QtiFeedback {
|
|
569
|
+
constructor() {
|
|
570
|
+
super(...arguments);
|
|
571
|
+
this.render = () => x` <slot part="feedback" class="${o(this.showStatus)}"></slot> `;
|
|
572
|
+
}
|
|
573
|
+
connectedCallback() {
|
|
574
|
+
super.connectedCallback();
|
|
575
|
+
this.checkShowFeedback(this.outcomeIdentifier);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
QtiFeedbackInline.styles = i`
|
|
579
|
+
.on {
|
|
580
|
+
display: inline-block;
|
|
581
|
+
}
|
|
582
|
+
.off {
|
|
583
|
+
display: none;
|
|
584
|
+
}
|
|
585
|
+
`;
|
|
586
|
+
QtiFeedbackInline = __decorateClass([
|
|
587
|
+
t("qti-feedback-inline")
|
|
588
|
+
], QtiFeedbackInline);
|
|
589
|
+
|
|
590
|
+
// ../qti-elements/src/components/qti-modal-feedback/qti-modal-feedback.ts
|
|
591
|
+
var QtiModalFeedback = class extends QtiFeedback {
|
|
592
|
+
render() {
|
|
593
|
+
return x`
|
|
594
|
+
<dialog class="qti-dialog" part="feedback" ?open="${this.showStatus === "on"}">
|
|
595
|
+
<slot></slot>
|
|
596
|
+
<div style="margin-top: var(--qti-gap-size); text-align: center;">
|
|
597
|
+
<button class="button close-button" @click="${this.closeFeedback}">Close</button>
|
|
598
|
+
</div>
|
|
599
|
+
</dialog>
|
|
600
|
+
`;
|
|
601
|
+
}
|
|
602
|
+
openFeedback() {
|
|
603
|
+
const dialog = this.shadowRoot?.querySelector("dialog");
|
|
604
|
+
if (dialog && !dialog.open) {
|
|
605
|
+
dialog.showModal();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
closeFeedback() {
|
|
609
|
+
const dialog = this.shadowRoot?.querySelector("dialog");
|
|
610
|
+
if (dialog && dialog.open) {
|
|
611
|
+
dialog.close();
|
|
612
|
+
this.showStatus = "off";
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
connectedCallback() {
|
|
616
|
+
super.connectedCallback();
|
|
617
|
+
if (this.showStatus === "on") {
|
|
618
|
+
this.openFeedback();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
updated(changedProperties) {
|
|
622
|
+
if (changedProperties.has("showStatus")) {
|
|
623
|
+
if (this.showStatus === "on") {
|
|
624
|
+
this.openFeedback();
|
|
625
|
+
} else {
|
|
626
|
+
this.closeFeedback();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
QtiModalFeedback.styles = i`
|
|
632
|
+
.qti-dialog {
|
|
633
|
+
background: var(--qti-bg);
|
|
634
|
+
border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
|
|
635
|
+
border-radius: var(--qti-border-radius);
|
|
636
|
+
padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
|
|
637
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
638
|
+
position: fixed;
|
|
639
|
+
top: 50%;
|
|
640
|
+
left: 50%;
|
|
641
|
+
transform: translate(-50%, -50%);
|
|
642
|
+
z-index: 1000;
|
|
643
|
+
width: auto;
|
|
644
|
+
max-width: 90%;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.button {
|
|
648
|
+
border-radius: var(--qti-border-radius);
|
|
649
|
+
padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
|
|
650
|
+
background-color: var(--qti-bg-active);
|
|
651
|
+
border: var(--qti-border-active);
|
|
652
|
+
cursor: pointer;
|
|
653
|
+
position: relative;
|
|
654
|
+
display: inline-block;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
.button:hover {
|
|
658
|
+
background-color: var(--qti-hover-bg);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.button:disabled {
|
|
662
|
+
background-color: var(--qti-disabled-bg);
|
|
663
|
+
color: var(--qti-disabled-color);
|
|
664
|
+
cursor: not-allowed;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
.button:focus {
|
|
668
|
+
outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
|
|
669
|
+
}
|
|
670
|
+
`;
|
|
671
|
+
QtiModalFeedback = __decorateClass([
|
|
672
|
+
t("qti-modal-feedback")
|
|
673
|
+
], QtiModalFeedback);
|
|
674
|
+
|
|
675
|
+
// ../qti-elements/src/components/qti-item-body/qti-item-body.styles.ts
|
|
676
|
+
var qti_item_body_styles_default = i`
|
|
677
|
+
:host {
|
|
678
|
+
display: block;
|
|
679
|
+
}
|
|
680
|
+
`;
|
|
681
|
+
|
|
682
|
+
// ../qti-elements/src/components/qti-item-body/qti-item-body.ts
|
|
683
|
+
var QtiItemBody = class extends i2 {
|
|
684
|
+
render() {
|
|
685
|
+
return x`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`;
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
QtiItemBody.styles = qti_item_body_styles_default;
|
|
689
|
+
QtiItemBody = __decorateClass([
|
|
690
|
+
t("qti-item-body")
|
|
691
|
+
], QtiItemBody);
|
|
692
|
+
|
|
693
|
+
// ../qti-elements/src/components/qti-prompt/qti-prompt.ts
|
|
694
|
+
var QtiPrompt = class extends i2 {
|
|
695
|
+
render() {
|
|
696
|
+
return x`<slot></slot>`;
|
|
697
|
+
}
|
|
698
|
+
connectedCallback() {
|
|
699
|
+
const inInteraction = this.parentElement.tagName.endsWith("INTERACTION");
|
|
700
|
+
if (inInteraction) {
|
|
701
|
+
this.setAttribute("slot", "prompt");
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
QtiPrompt = __decorateClass([
|
|
706
|
+
t("qti-prompt")
|
|
707
|
+
], QtiPrompt);
|
|
708
|
+
|
|
709
|
+
// ../qti-elements/src/components/qti-content-body/qti-content-body.ts
|
|
710
|
+
var QtiContentBody = class extends i2 {
|
|
711
|
+
render() {
|
|
712
|
+
return x`<slot></slot>`;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
QtiContentBody = __decorateClass([
|
|
716
|
+
t("qti-content-body")
|
|
717
|
+
], QtiContentBody);
|
|
718
|
+
|
|
719
|
+
// ../qti-elements/src/components/qti-rubric-block/qti-rubric-block.ts
|
|
720
|
+
var QtiRubricBlock = class extends i2 {
|
|
721
|
+
handleclassNamesChange() {
|
|
722
|
+
const classNames = this.classNames.split(" ");
|
|
723
|
+
classNames.forEach((className) => {
|
|
724
|
+
switch (className) {
|
|
725
|
+
case "qti-rubric-discretionary-placement":
|
|
726
|
+
{
|
|
727
|
+
const event = new CustomEvent("qti-rubric:discretionary-placement", {
|
|
728
|
+
detail: { className, element: this },
|
|
729
|
+
bubbles: true,
|
|
730
|
+
composed: true,
|
|
731
|
+
cancelable: true
|
|
732
|
+
});
|
|
733
|
+
const notCancelled = this.dispatchEvent(event);
|
|
734
|
+
if (!notCancelled) return;
|
|
735
|
+
this.setAttribute("slot", "qti-rubric-block");
|
|
736
|
+
}
|
|
737
|
+
break;
|
|
738
|
+
case "qti-rubric-inline":
|
|
739
|
+
this.setAttribute("slot", "");
|
|
740
|
+
break;
|
|
741
|
+
default:
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
render() {
|
|
747
|
+
return x`<slot></slot>`;
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
QtiRubricBlock.styles = i`
|
|
751
|
+
:host {
|
|
752
|
+
display: block;
|
|
753
|
+
}
|
|
754
|
+
`;
|
|
755
|
+
__decorateClass([
|
|
756
|
+
n({ type: String })
|
|
757
|
+
], QtiRubricBlock.prototype, "id", 2);
|
|
758
|
+
__decorateClass([
|
|
759
|
+
n({ type: String })
|
|
760
|
+
], QtiRubricBlock.prototype, "use", 2);
|
|
761
|
+
__decorateClass([
|
|
762
|
+
n({ type: String })
|
|
763
|
+
], QtiRubricBlock.prototype, "view", 2);
|
|
764
|
+
__decorateClass([
|
|
765
|
+
n({ type: String, attribute: "class" })
|
|
766
|
+
], QtiRubricBlock.prototype, "classNames", 2);
|
|
767
|
+
__decorateClass([
|
|
768
|
+
watch("classNames", { waitUntilFirstUpdate: true })
|
|
769
|
+
], QtiRubricBlock.prototype, "handleclassNamesChange", 1);
|
|
770
|
+
QtiRubricBlock = __decorateClass([
|
|
771
|
+
t("qti-rubric-block")
|
|
772
|
+
], QtiRubricBlock);
|
|
773
|
+
|
|
774
|
+
// ../qti-elements/src/components/qti-stylesheet/qti-stylesheet.ts
|
|
775
|
+
var QtiStylesheet = class extends i2 {
|
|
776
|
+
constructor() {
|
|
777
|
+
super(...arguments);
|
|
778
|
+
this.styleElement = null;
|
|
779
|
+
}
|
|
780
|
+
firstUpdated(_changedProperties) {
|
|
781
|
+
super.firstUpdated(_changedProperties);
|
|
782
|
+
const link = this.getAttribute("href");
|
|
783
|
+
if (link !== null) {
|
|
784
|
+
fetch(link).then((response) => response.text()).then((cssContent) => {
|
|
785
|
+
const minifiedCss = this.minifyCss(cssContent);
|
|
786
|
+
this.styleElement = document.createElement("style");
|
|
787
|
+
this.styleElement.media = "screen";
|
|
788
|
+
this.styleElement.textContent = `@scope {${minifiedCss}}`;
|
|
789
|
+
if (this.parentElement) {
|
|
790
|
+
this.parentElement.appendChild(this.styleElement);
|
|
791
|
+
} else {
|
|
792
|
+
console.warn("No parent element to append the scoped stylesheet to.");
|
|
793
|
+
}
|
|
794
|
+
}).catch((error) => {
|
|
795
|
+
console.error("Failed to load stylesheet:", error);
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
if (this.textContent !== null && this.textContent.trim() !== "") {
|
|
799
|
+
const minifiedCss = this.minifyCss(this.textContent);
|
|
800
|
+
this.styleElement = document.createElement("style");
|
|
801
|
+
this.styleElement.media = "screen";
|
|
802
|
+
this.styleElement.textContent = `@scope {${minifiedCss}}`;
|
|
803
|
+
if (this.parentElement) {
|
|
804
|
+
this.parentElement.appendChild(this.styleElement);
|
|
805
|
+
} else {
|
|
806
|
+
console.warn("No parent element to append the scoped stylesheet to.");
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
minifyCss(cssContent) {
|
|
811
|
+
return cssContent.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;])\s*/g, "$1").trim();
|
|
812
|
+
}
|
|
813
|
+
disconnectedCallback() {
|
|
814
|
+
if (this.styleElement) {
|
|
815
|
+
try {
|
|
816
|
+
this.styleElement.remove();
|
|
817
|
+
} catch (error) {
|
|
818
|
+
console.error("Could not remove stylesheet:", error);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
super.disconnectedCallback();
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
QtiStylesheet = __decorateClass([
|
|
825
|
+
t("qti-stylesheet")
|
|
826
|
+
], QtiStylesheet);
|
|
827
|
+
|
|
828
|
+
// ../qti-elements/src/components/qti-response-declaration/qti-response-declaration.ts
|
|
829
|
+
var QtiResponseDeclaration = class extends QtiVariableDeclaration {
|
|
830
|
+
render() {
|
|
831
|
+
const value = this.itemContext?.variables.find((v) => v.identifier === this.identifier)?.value;
|
|
832
|
+
return x`${JSON.stringify(value, null, 2)}`;
|
|
833
|
+
}
|
|
834
|
+
connectedCallback() {
|
|
835
|
+
super.connectedCallback();
|
|
836
|
+
const defaultValue = this.defaultValues(this.cardinality);
|
|
837
|
+
const responseVariable = {
|
|
838
|
+
baseType: this.baseType,
|
|
839
|
+
identifier: this.identifier,
|
|
840
|
+
correctResponse: this.correctResponse,
|
|
841
|
+
cardinality: this.cardinality || "single",
|
|
842
|
+
mapping: this.mapping,
|
|
843
|
+
defaultValue,
|
|
844
|
+
areaMapping: this.areaMapping,
|
|
845
|
+
value: null,
|
|
846
|
+
type: "response",
|
|
847
|
+
candidateResponse: null
|
|
848
|
+
};
|
|
849
|
+
responseVariable.value = defaultValue;
|
|
850
|
+
this.dispatchEvent(
|
|
851
|
+
new CustomEvent("qti-register-variable", {
|
|
852
|
+
bubbles: true,
|
|
853
|
+
composed: true,
|
|
854
|
+
detail: { variable: responseVariable }
|
|
855
|
+
})
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
get correctResponse() {
|
|
859
|
+
let result;
|
|
860
|
+
const correctResponse = this.querySelector("qti-correct-response");
|
|
861
|
+
if (correctResponse) {
|
|
862
|
+
const values = correctResponse.querySelectorAll("qti-value");
|
|
863
|
+
if (this.cardinality === "single" && values.length > 0) {
|
|
864
|
+
result = values[0].textContent.trim();
|
|
865
|
+
values[0].remove();
|
|
866
|
+
} else if (this.cardinality !== "single") {
|
|
867
|
+
result = [];
|
|
868
|
+
for (let i3 = 0; i3 < values.length; i3++) {
|
|
869
|
+
result.push(values[i3].textContent.trim());
|
|
870
|
+
values[i3].remove();
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return result;
|
|
875
|
+
}
|
|
876
|
+
get mapping() {
|
|
877
|
+
const mappingElement = this.querySelector("qti-mapping");
|
|
878
|
+
const lowerBound = parseFloat(mappingElement?.getAttribute("lower-bound"));
|
|
879
|
+
const uppperBound = parseFloat(mappingElement?.getAttribute("upper-bound"));
|
|
880
|
+
const mappingValue = {
|
|
881
|
+
defaultValue: Number(mappingElement?.getAttribute("default-value")) || 0,
|
|
882
|
+
lowerBound: isNaN(lowerBound) ? null : lowerBound,
|
|
883
|
+
upperBound: isNaN(uppperBound) ? null : uppperBound,
|
|
884
|
+
mapEntries: Array.from(mappingElement?.querySelectorAll("qti-map-entry") || []).map((el) => ({
|
|
885
|
+
mapKey: el.getAttribute("map-key") || "",
|
|
886
|
+
mappedValue: Number(el.getAttribute("mapped-value")) || 0,
|
|
887
|
+
caseSensitive: el.hasAttribute("case-sensitive") ? el.getAttribute("case-sensitive") !== "false" : false
|
|
888
|
+
}))
|
|
889
|
+
};
|
|
890
|
+
return mappingValue;
|
|
891
|
+
}
|
|
892
|
+
get areaMapping() {
|
|
893
|
+
const areaMappingElement = this.querySelector("qti-area-mapping");
|
|
894
|
+
const defaultValue = Number(areaMappingElement?.getAttribute("default-value")) || 0;
|
|
895
|
+
const lowerBound = parseFloat(areaMappingElement?.getAttribute("lower-bound"));
|
|
896
|
+
const uppperBound = parseFloat(areaMappingElement?.getAttribute("upper-bound"));
|
|
897
|
+
const areaMapEntries = Array.from(areaMappingElement?.querySelectorAll("qti-area-map-entry") || []).map(
|
|
898
|
+
(el) => ({
|
|
899
|
+
shape: el.getAttribute("shape") || "default",
|
|
900
|
+
coords: el.getAttribute("coords") || "",
|
|
901
|
+
mappedValue: Number(el.getAttribute("mapped-value")) || 0,
|
|
902
|
+
defaultValue: Number(el.getAttribute("default-value")) || 0
|
|
903
|
+
})
|
|
904
|
+
);
|
|
905
|
+
return {
|
|
906
|
+
defaultValue,
|
|
907
|
+
lowerBound: isNaN(lowerBound) ? null : lowerBound,
|
|
908
|
+
upperBound: isNaN(uppperBound) ? null : uppperBound,
|
|
909
|
+
areaMapEntries
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
QtiResponseDeclaration.styles = [
|
|
914
|
+
i`
|
|
915
|
+
:host {
|
|
916
|
+
display: none;
|
|
917
|
+
}
|
|
918
|
+
`
|
|
919
|
+
];
|
|
920
|
+
__decorateClass([
|
|
921
|
+
n({ type: String, attribute: "base-type" })
|
|
922
|
+
], QtiResponseDeclaration.prototype, "baseType", 2);
|
|
923
|
+
__decorateClass([
|
|
924
|
+
n({ type: String })
|
|
925
|
+
], QtiResponseDeclaration.prototype, "identifier", 2);
|
|
926
|
+
__decorateClass([
|
|
927
|
+
n({ type: String })
|
|
928
|
+
], QtiResponseDeclaration.prototype, "cardinality", 2);
|
|
929
|
+
__decorateClass([
|
|
930
|
+
c({ context: itemContext, subscribe: true }),
|
|
931
|
+
r()
|
|
932
|
+
], QtiResponseDeclaration.prototype, "itemContext", 2);
|
|
933
|
+
QtiResponseDeclaration = __decorateClass([
|
|
934
|
+
t("qti-response-declaration")
|
|
935
|
+
], QtiResponseDeclaration);
|
|
936
|
+
|
|
937
|
+
// ../qti-elements/src/components/qti-outcome-declaration/qti-outcome-declaration.ts
|
|
938
|
+
var QtiOutcomeDeclaration = class extends QtiVariableDeclaration {
|
|
939
|
+
constructor() {
|
|
940
|
+
super(...arguments);
|
|
941
|
+
this.externalScored = null;
|
|
942
|
+
}
|
|
943
|
+
render() {
|
|
944
|
+
const value = this.itemContext?.variables.find((v) => v.identifier === this.identifier)?.value;
|
|
945
|
+
return x`${JSON.stringify(value, null, 2)}`;
|
|
946
|
+
}
|
|
947
|
+
get interpolationTable() {
|
|
948
|
+
const table = this.querySelector("qti-interpolation-table");
|
|
949
|
+
if (table) {
|
|
950
|
+
const entries = /* @__PURE__ */ new Map();
|
|
951
|
+
for (const entry of table.querySelectorAll("qti-interpolation-table-entry")) {
|
|
952
|
+
if (!entry.getAttribute("source-value") && entry.getAttribute("target-value")) {
|
|
953
|
+
console.error("source-value or target-value is missing in qti-interpolation-table-entry");
|
|
954
|
+
}
|
|
955
|
+
const sourceValue = parseFloat(entry.getAttribute("source-value"));
|
|
956
|
+
const targetValue = parseFloat(entry.getAttribute("target-value"));
|
|
957
|
+
if (isNaN(sourceValue) || isNaN(targetValue)) {
|
|
958
|
+
console.error("source-value or target-value is not a number in qti-interpolation-table-entry");
|
|
959
|
+
}
|
|
960
|
+
entries.set(sourceValue, targetValue);
|
|
961
|
+
}
|
|
962
|
+
return entries;
|
|
963
|
+
}
|
|
964
|
+
return null;
|
|
965
|
+
}
|
|
966
|
+
connectedCallback() {
|
|
967
|
+
super.connectedCallback();
|
|
968
|
+
const defaultValue = this.defaultValues(this.cardinality);
|
|
969
|
+
const outcomeVariable = {
|
|
970
|
+
identifier: this.identifier,
|
|
971
|
+
cardinality: this.cardinality,
|
|
972
|
+
baseType: this.baseType,
|
|
973
|
+
defaultValue,
|
|
974
|
+
type: "outcome",
|
|
975
|
+
value: null,
|
|
976
|
+
interpolationTable: this.interpolationTable,
|
|
977
|
+
externalScored: this.externalScored
|
|
978
|
+
};
|
|
979
|
+
outcomeVariable.value = defaultValue;
|
|
980
|
+
if ((outcomeVariable.value === null || outcomeVariable.value == void 0) && (outcomeVariable.baseType === "integer" || outcomeVariable.baseType === "float")) {
|
|
981
|
+
outcomeVariable.value = "0";
|
|
982
|
+
}
|
|
983
|
+
this.dispatchEvent(
|
|
984
|
+
new CustomEvent("qti-register-variable", {
|
|
985
|
+
bubbles: true,
|
|
986
|
+
composed: true,
|
|
987
|
+
detail: { variable: outcomeVariable }
|
|
988
|
+
})
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
QtiOutcomeDeclaration.styles = [
|
|
993
|
+
i`
|
|
994
|
+
:host {
|
|
995
|
+
display: none;
|
|
996
|
+
}
|
|
997
|
+
`
|
|
998
|
+
];
|
|
999
|
+
__decorateClass([
|
|
1000
|
+
n({ type: String, attribute: "base-type" })
|
|
1001
|
+
], QtiOutcomeDeclaration.prototype, "baseType", 2);
|
|
1002
|
+
__decorateClass([
|
|
1003
|
+
n({ type: String, attribute: "external-scored" })
|
|
1004
|
+
], QtiOutcomeDeclaration.prototype, "externalScored", 2);
|
|
1005
|
+
__decorateClass([
|
|
1006
|
+
n({ type: String })
|
|
1007
|
+
], QtiOutcomeDeclaration.prototype, "identifier", 2);
|
|
1008
|
+
__decorateClass([
|
|
1009
|
+
n({ type: String })
|
|
1010
|
+
], QtiOutcomeDeclaration.prototype, "cardinality", 2);
|
|
1011
|
+
__decorateClass([
|
|
1012
|
+
c({ context: itemContext, subscribe: true }),
|
|
1013
|
+
r()
|
|
1014
|
+
], QtiOutcomeDeclaration.prototype, "itemContext", 2);
|
|
1015
|
+
QtiOutcomeDeclaration = __decorateClass([
|
|
1016
|
+
t("qti-outcome-declaration")
|
|
1017
|
+
], QtiOutcomeDeclaration);
|
|
1018
|
+
|
|
1019
|
+
// ../qti-elements/src/internal/template-strings.ts
|
|
1020
|
+
var matchCorrect = `<qti-response-processing>
|
|
1021
|
+
<qti-response-condition>
|
|
1022
|
+
<qti-response-if>
|
|
1023
|
+
<qti-match>
|
|
1024
|
+
<qti-variable identifier="RESPONSE"></qti-variable>
|
|
1025
|
+
<qti-correct identifier="RESPONSE"></qti-correct>
|
|
1026
|
+
</qti-match>
|
|
1027
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
1028
|
+
<qti-base-value base-type="float">1</qti-base-value>
|
|
1029
|
+
</qti-set-outcome-value>
|
|
1030
|
+
</qti-response-if>
|
|
1031
|
+
<qti-response-else>
|
|
1032
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
1033
|
+
<qti-base-value base-type="float">0</qti-base-value>
|
|
1034
|
+
</qti-set-outcome-value>
|
|
1035
|
+
</qti-response-else>
|
|
1036
|
+
</qti-response-condition>
|
|
1037
|
+
</qti-response-processing>`;
|
|
1038
|
+
var mapResponse = `<qti-response-processing>
|
|
1039
|
+
<qti-response-condition>
|
|
1040
|
+
<qti-response-if>
|
|
1041
|
+
<qti-is-null>
|
|
1042
|
+
<qti-variable identifier="RESPONSE"></qti-variable>
|
|
1043
|
+
</qti-is-null>
|
|
1044
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
1045
|
+
<qti-base-value base-type="float">0.0</qti-base-value>
|
|
1046
|
+
</qti-set-outcome-value>
|
|
1047
|
+
</qti-response-if>
|
|
1048
|
+
<qti-response-else>
|
|
1049
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
1050
|
+
<qti-map-response identifier="RESPONSE"> </qti-map-response>
|
|
1051
|
+
</qti-set-outcome-value>
|
|
1052
|
+
</qti-response-else>
|
|
1053
|
+
</qti-response-condition>
|
|
1054
|
+
</qti-response-processing>`;
|
|
1055
|
+
var mapResponsePoint = `<qti-response-processing>
|
|
1056
|
+
<qti-response-condition>
|
|
1057
|
+
<qti-response-if>
|
|
1058
|
+
<qti-is-null>
|
|
1059
|
+
<qti-variable identifier="RESPONSE"></qti-variable>
|
|
1060
|
+
</qti-is-null>
|
|
1061
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
1062
|
+
<qti-base-value base-type="float">0</qti-base-value>
|
|
1063
|
+
</qti-set-outcome-value>
|
|
1064
|
+
</qti-response-if>
|
|
1065
|
+
<qti-response-else>
|
|
1066
|
+
<qti-set-outcome-value identifier="SCORE">
|
|
1067
|
+
<qti-map-response-point identifier="RESPONSE"></qti-map-response-point>
|
|
1068
|
+
</qti-set-outcome-value>
|
|
1069
|
+
</qti-response-else>
|
|
1070
|
+
</qti-response-condition>
|
|
1071
|
+
</qti-response-processing>`;
|
|
1072
|
+
|
|
1073
|
+
// ../qti-elements/src/components/qti-response-processing/qti-response-processing.ts
|
|
1074
|
+
var QtiResponseProcessing = class extends i2 {
|
|
1075
|
+
render() {
|
|
1076
|
+
return x`<slot></slot>`;
|
|
1077
|
+
}
|
|
1078
|
+
process() {
|
|
1079
|
+
const assessmentItem = this.closest("qti-assessment-item");
|
|
1080
|
+
if (!assessmentItem) return;
|
|
1081
|
+
const rules = [...this.children];
|
|
1082
|
+
for (const rule of rules) {
|
|
1083
|
+
rule.process();
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
firstUpdated(_changedProperties) {
|
|
1087
|
+
if (this.getAttribute("template")) {
|
|
1088
|
+
const splittedTemplateName = this.getAttribute("template").split("/");
|
|
1089
|
+
const templateName = splittedTemplateName[splittedTemplateName.length - 1].replace(".xml", "");
|
|
1090
|
+
this.innerHTML = "";
|
|
1091
|
+
switch (templateName) {
|
|
1092
|
+
case "map_response": {
|
|
1093
|
+
this.appendChild(this.fragmentFromString(mapResponse).firstElementChild.firstElementChild);
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
case "map_response_point": {
|
|
1097
|
+
this.appendChild(this.fragmentFromString(mapResponsePoint).firstElementChild.firstElementChild);
|
|
1098
|
+
break;
|
|
1099
|
+
}
|
|
1100
|
+
case "match_correct":
|
|
1101
|
+
this.appendChild(this.fragmentFromString(matchCorrect).firstElementChild.firstElementChild);
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
fragmentFromString(strHTML) {
|
|
1107
|
+
return document.createRange().createContextualFragment(strHTML);
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
QtiResponseProcessing.styles = [
|
|
1111
|
+
i`
|
|
1112
|
+
:host {
|
|
1113
|
+
display: none;
|
|
1114
|
+
}
|
|
1115
|
+
`
|
|
1116
|
+
];
|
|
1117
|
+
QtiResponseProcessing = __decorateClass([
|
|
1118
|
+
t("qti-response-processing")
|
|
1119
|
+
], QtiResponseProcessing);
|
|
1120
|
+
|
|
1121
|
+
export {
|
|
1122
|
+
QtiAssessmentItem,
|
|
1123
|
+
QtiAssessmentStimulusRefConnectedEvent,
|
|
1124
|
+
QtiAssessmentStimulusRef,
|
|
1125
|
+
QtiCompanionMaterialsInfo,
|
|
1126
|
+
QtiCustomOperator,
|
|
1127
|
+
QtiFeedbackBlock,
|
|
1128
|
+
QtiFeedbackInline,
|
|
1129
|
+
QtiModalFeedback,
|
|
1130
|
+
QtiItemBody,
|
|
1131
|
+
QtiPrompt,
|
|
1132
|
+
QtiContentBody,
|
|
1133
|
+
QtiRubricBlock,
|
|
1134
|
+
QtiStylesheet,
|
|
1135
|
+
QtiResponseDeclaration,
|
|
1136
|
+
QtiOutcomeDeclaration,
|
|
1137
|
+
QtiResponseProcessing
|
|
1138
|
+
};
|
|
1139
|
+
//# sourceMappingURL=chunk-O4XIWHTF.js.map
|