@citolab/qti-components 10.0.0-next.2 → 10.0.0-next.21
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 +4334 -2688
- package/dist/base.d.ts +39 -13
- package/dist/base.js +14 -1
- package/dist/{chunk-RU6332MD.js → chunk-2A52V5TQ.js} +4 -4
- package/dist/{chunk-2KP5UU5A.js → chunk-55WWIRLN.js} +117 -92
- package/dist/chunk-55WWIRLN.js.map +1 -0
- package/dist/{chunk-MI7774NV.js → chunk-5BP2A7BI.js} +2 -2
- package/dist/{chunk-35WWWFS6.js → chunk-DAESCCLR.js} +2 -2
- package/dist/chunk-DJ7PB252.js +7 -0
- package/dist/chunk-DJ7PB252.js.map +1 -0
- package/dist/{chunk-TDWJ6WZA.js → chunk-GPC53O7P.js} +166 -10
- package/dist/chunk-GPC53O7P.js.map +1 -0
- package/dist/{chunk-6U3YPHXU.js → chunk-H6DO5UHC.js} +277 -154
- package/dist/chunk-H6DO5UHC.js.map +1 -0
- package/dist/chunk-J6VX4N7M.js +197 -0
- package/dist/chunk-J6VX4N7M.js.map +1 -0
- package/dist/{chunk-3ZNECUPV.js → chunk-JIDSFFFD.js} +2 -2
- package/dist/{chunk-FD4AB6TM.js → chunk-KQ2LED4X.js} +2 -2
- package/dist/{chunk-6K3QWJHH.js → chunk-LPYZVKHX.js} +48 -7
- package/dist/chunk-LPYZVKHX.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/{chunk-K3VKQ6QF.js → chunk-TB2OI3ED.js} +677 -1894
- package/dist/chunk-TB2OI3ED.js.map +1 -0
- package/dist/{chunk-GBZNFSFY.js → chunk-TSJGL6FI.js} +2 -2
- package/dist/{chunk-RSMYGGQK.js → chunk-TZCOXFPB.js} +1590 -610
- package/dist/chunk-TZCOXFPB.js.map +1 -0
- package/dist/chunk-UCXLDQYA.js +56 -0
- package/dist/chunk-UCXLDQYA.js.map +1 -0
- package/dist/chunk-WWY2H2YO.js +7 -0
- package/dist/chunk-WWY2H2YO.js.map +1 -0
- package/dist/{chunk-LFVPS7KB.js → chunk-XWRZP2RM.js} +2 -2
- package/dist/{chunk-TLAVOBEM.js → chunk-ZRORBAHB.js} +122 -3
- package/dist/chunk-ZRORBAHB.js.map +1 -0
- package/dist/computed.types.d-6Ht-HNRx.d.ts +80 -0
- package/dist/{config.context.d-BvU9r-Mg.d.ts → config.context.d-Dm11aAuw.d.ts} +21 -3
- package/dist/corrections.d.ts +137 -24
- package/dist/corrections.js +12 -12
- package/dist/corrections.js.map +1 -1
- package/dist/elements.d.ts +66 -73
- package/dist/elements.js +9 -6
- package/dist/index.d.ts +21 -17
- package/dist/index.js +47 -61
- package/dist/interactions.d.ts +98 -19
- package/dist/interactions.js +8 -3
- package/dist/item.css +1948 -1946
- package/dist/item.d.ts +8 -6
- package/dist/item.js +6 -5
- package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
- package/dist/loader.d.ts +5 -3
- package/dist/loader.js +3 -2
- package/dist/processing.d.ts +19 -7
- package/dist/processing.js +4 -3
- package/dist/public-events.d-3dGip9pd.d.ts +105 -0
- package/dist/qti-components-jsx.d.ts +1780 -1727
- package/dist/{qti-condition-expression.d-VJH6cWxf.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
- package/dist/{qti-expression.d-BPxEp8HU.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
- package/dist/{qti-feedback.d-wMYNVkkj.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +8 -1
- package/dist/{qti-item.d-DgC1AQbY.d.ts → qti-item.d-CxP6KtCH.d.ts} +3 -2
- package/dist/{qti-rule-base.d-Bdzg8eGH.d.ts → qti-rule-base.d-CeKP0Ooi.d.ts} +2 -2
- package/dist/qti-test-state-CF9S8X9C.d.ts +68 -0
- package/dist/qti-test-state.d-D8Q89RzZ.d.ts +57 -0
- package/dist/{qti-test.d-DkpBNcsv.d.ts → qti-test.d-DBT-YpRu.d.ts} +124 -485
- package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-m0EFv9no.d.ts} +221 -73
- package/dist/{qti-transform-test.d-BL7GGFJj.d.ts → qti-transform-test.d-Bb9vnLzP.d.ts} +1 -0
- package/dist/{interaction.d-g6XG0T0Z.d.ts → record.d-N1Bq7e1f.d.ts} +67 -4
- package/dist/{session.context.d-D5080LVx.d.ts → session.context.d-9gRdGK4T.d.ts} +7 -1
- package/dist/test-plugin-api.d.ts +134 -0
- package/dist/test-plugin-api.js +19 -0
- package/dist/test-plugin-api.js.map +1 -0
- package/dist/test.d.ts +26 -57
- package/dist/test.js +19 -48
- package/dist/transformers.d.ts +1 -1
- package/dist/transformers.js +2 -1
- package/dist/{item.types.d-B55QkJ92.d.ts → variables.d-DWHlTszN.d.ts} +8 -24
- package/package.json +16 -11
- package/dist/chunk-2KP5UU5A.js.map +0 -1
- package/dist/chunk-6K3QWJHH.js.map +0 -1
- package/dist/chunk-6U3YPHXU.js.map +0 -1
- package/dist/chunk-K3VKQ6QF.js.map +0 -1
- package/dist/chunk-RSMYGGQK.js.map +0 -1
- package/dist/chunk-TDWJ6WZA.js.map +0 -1
- package/dist/chunk-TLAVOBEM.js.map +0 -1
- package/dist/chunk-ZP6QQYSU.js +0 -7
- package/dist/chunk-ZP6QQYSU.js.map +0 -1
- package/dist/computed.types.d-gJrBeUMG.d.ts +0 -42
- /package/dist/{chunk-RU6332MD.js.map → chunk-2A52V5TQ.js.map} +0 -0
- /package/dist/{chunk-MI7774NV.js.map → chunk-5BP2A7BI.js.map} +0 -0
- /package/dist/{chunk-35WWWFS6.js.map → chunk-DAESCCLR.js.map} +0 -0
- /package/dist/{chunk-3ZNECUPV.js.map → chunk-JIDSFFFD.js.map} +0 -0
- /package/dist/{chunk-FD4AB6TM.js.map → chunk-KQ2LED4X.js.map} +0 -0
- /package/dist/{chunk-GBZNFSFY.js.map → chunk-TSJGL6FI.js.map} +0 -0
- /package/dist/{chunk-LFVPS7KB.js.map → chunk-XWRZP2RM.js.map} +0 -0
|
@@ -1,65 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dispatchPublic
|
|
3
|
+
} from "./chunk-UCXLDQYA.js";
|
|
1
4
|
import {
|
|
2
5
|
watch
|
|
3
6
|
} from "./chunk-4DB4SC5K.js";
|
|
4
7
|
import {
|
|
5
8
|
qtiTransformItem
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZRORBAHB.js";
|
|
7
10
|
import {
|
|
8
11
|
QtiExitResponseSignal,
|
|
9
12
|
QtiFeedback,
|
|
10
13
|
QtiVariableDeclaration,
|
|
11
14
|
getCustomOperator,
|
|
12
15
|
itemContext,
|
|
13
|
-
itemContextVariables
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// ../qti-elements/dist/public-events.js
|
|
17
|
-
var PUBLIC_ITEM_EVENTS = {
|
|
18
|
-
// The old name `qti-assessment-item-connected` stays as internal plumbing: it is sent separately.
|
|
19
|
-
"cito-item-rendered": { kind: "notification", scope: "item" },
|
|
20
|
-
"cito-item-response-changed": { kind: "notification", scope: "item", deprecated: "qti-interaction-changed" },
|
|
21
|
-
"cito-item-outcome-changed": { kind: "notification", scope: "item", deprecated: "qti-outcome-changed" },
|
|
22
|
-
"cito-item-rubric-placement": {
|
|
23
|
-
kind: "notification",
|
|
24
|
-
scope: "item",
|
|
25
|
-
deprecated: "qti-rubric:discretionary-placement"
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function dispatchDeclared(target, declarations, name, detail, cancelable = false) {
|
|
29
|
-
const init = { detail: detail ?? {}, bubbles: true, composed: true, cancelable };
|
|
30
|
-
const notCancelled = target.dispatchEvent(new CustomEvent(name, init));
|
|
31
|
-
const { deprecated } = declarations[name];
|
|
32
|
-
if (!deprecated)
|
|
33
|
-
return notCancelled;
|
|
34
|
-
return target.dispatchEvent(new CustomEvent(deprecated, init)) && notCancelled;
|
|
35
|
-
}
|
|
36
|
-
var warned = /* @__PURE__ */ new Set();
|
|
37
|
-
function listenDeclared(target, declarations, name, handler) {
|
|
38
|
-
let justHandled;
|
|
39
|
-
target.addEventListener(name, (e) => {
|
|
40
|
-
justHandled = e.detail;
|
|
41
|
-
queueMicrotask(() => justHandled = void 0);
|
|
42
|
-
handler(e);
|
|
43
|
-
});
|
|
44
|
-
const { deprecated } = declarations[name];
|
|
45
|
-
if (deprecated) {
|
|
46
|
-
target.addEventListener(deprecated, (e) => {
|
|
47
|
-
if (justHandled !== void 0 && e.detail === justHandled)
|
|
48
|
-
return;
|
|
49
|
-
if (!warned.has(deprecated)) {
|
|
50
|
-
warned.add(deprecated);
|
|
51
|
-
console.warn(`[qti-components] The event "${deprecated}" is deprecated; dispatch "${name}" instead.`);
|
|
52
|
-
}
|
|
53
|
-
handler(e);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function dispatchPublic(target, name, detail, cancelable = false) {
|
|
58
|
-
return dispatchDeclared(target, PUBLIC_ITEM_EVENTS, name, detail, cancelable);
|
|
59
|
-
}
|
|
60
|
-
function listenPublic(target, name, handler) {
|
|
61
|
-
listenDeclared(target, PUBLIC_ITEM_EVENTS, name, handler);
|
|
62
|
-
}
|
|
16
|
+
itemContextVariables,
|
|
17
|
+
readRecordFieldValues
|
|
18
|
+
} from "./chunk-GPC53O7P.js";
|
|
63
19
|
|
|
64
20
|
// ../qti-elements/dist/components/qti-assessment-item/qti-assessment-item.js
|
|
65
21
|
import { provide } from "@lit/context";
|
|
@@ -103,13 +59,26 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
103
59
|
const { responseIdentifier, countAttempt } = e.detail;
|
|
104
60
|
this.validate();
|
|
105
61
|
this.updateResponseVariable(responseIdentifier, "true");
|
|
106
|
-
this
|
|
62
|
+
this.#processResponse(countAttempt, true, responseIdentifier);
|
|
107
63
|
};
|
|
108
|
-
this.#
|
|
64
|
+
this.#handleSetOutcomes = (e) => {
|
|
109
65
|
e.stopImmediatePropagation();
|
|
110
|
-
const {
|
|
111
|
-
|
|
112
|
-
|
|
66
|
+
const { outcomes = [], responseProcessed = false } = e.detail ?? {};
|
|
67
|
+
const completion = [];
|
|
68
|
+
if (responseProcessed && this.adaptive === "false") {
|
|
69
|
+
const sent = outcomes.find((o) => o.identifier === "completionStatus")?.value;
|
|
70
|
+
if ((sent ?? this.getVariable("completionStatus")?.value) === "unknown") {
|
|
71
|
+
completion.push({ identifier: "completionStatus", value: "completed" });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
this.#applyOutcomes([...outcomes, ...completion], this.#checkValidity(false));
|
|
75
|
+
if (responseProcessed) {
|
|
76
|
+
this.dispatchEvent(new CustomEvent("qti-item-context-updated", {
|
|
77
|
+
bubbles: true,
|
|
78
|
+
composed: true,
|
|
79
|
+
detail: { itemContext: this._context, responseProcessed: true }
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
113
82
|
};
|
|
114
83
|
this.#handleSetTemplateValue = (e) => {
|
|
115
84
|
e.stopImmediatePropagation();
|
|
@@ -223,6 +192,8 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
223
192
|
this.#runTemplateProcessing();
|
|
224
193
|
}
|
|
225
194
|
void this.updateComplete.then(() => this.#revalidate());
|
|
195
|
+
if (this.isConnected)
|
|
196
|
+
this.#beginFirstAttempt();
|
|
226
197
|
}
|
|
227
198
|
get state() {
|
|
228
199
|
return this._context.state;
|
|
@@ -264,7 +235,8 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
264
235
|
super.connectedCallback();
|
|
265
236
|
this.updateComplete.then(() => {
|
|
266
237
|
this.validate(false);
|
|
267
|
-
|
|
238
|
+
this.#beginFirstAttempt();
|
|
239
|
+
dispatchPublic(this, "qc-item-rendered", this);
|
|
268
240
|
this.dispatchEvent(new CustomEvent("qti-assessment-item-connected", {
|
|
269
241
|
bubbles: true,
|
|
270
242
|
composed: true,
|
|
@@ -281,7 +253,7 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
281
253
|
this.addEventListener("qti-register-variable", this.#handleRegisterVariable);
|
|
282
254
|
this.addEventListener("qti-register-interaction", this.#handleRegisterInteraction);
|
|
283
255
|
this.addEventListener("end-attempt", this.#handleEndAttempt);
|
|
284
|
-
this.addEventListener("
|
|
256
|
+
this.addEventListener("qc-item-set-outcomes", this.#handleSetOutcomes);
|
|
285
257
|
this.addEventListener("qti-set-template-value", this.#handleSetTemplateValue);
|
|
286
258
|
this.addEventListener("qti-set-correct-response", this.#handleSetCorrectResponse);
|
|
287
259
|
this.addEventListener("qti-interaction-response", this.#handleUpdateResponseVariable);
|
|
@@ -290,7 +262,7 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
290
262
|
this.removeEventListener("qti-register-variable", this.#handleRegisterVariable);
|
|
291
263
|
this.removeEventListener("qti-register-interaction", this.#handleRegisterInteraction);
|
|
292
264
|
this.removeEventListener("end-attempt", this.#handleEndAttempt);
|
|
293
|
-
this.removeEventListener("
|
|
265
|
+
this.removeEventListener("qc-item-set-outcomes", this.#handleSetOutcomes);
|
|
294
266
|
this.removeEventListener("qti-set-template-value", this.#handleSetTemplateValue);
|
|
295
267
|
this.removeEventListener("qti-set-correct-response", this.#handleSetCorrectResponse);
|
|
296
268
|
this.removeEventListener("qti-interaction-response", this.#handleUpdateResponseVariable);
|
|
@@ -298,7 +270,16 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
298
270
|
#handleRegisterVariable;
|
|
299
271
|
#handleRegisterInteraction;
|
|
300
272
|
#handleEndAttempt;
|
|
301
|
-
|
|
273
|
+
/**
|
|
274
|
+
* Applies the outcomes of a processing run, ours or a backend's, in one update, with the
|
|
275
|
+
* interactions' validity.
|
|
276
|
+
*
|
|
277
|
+
* completionStatus is response processing's to set (QTI info model §2.2.2). When an attempt of a
|
|
278
|
+
* non-adaptive item ends and processing left it `unknown`, the item marks it `completed`: the
|
|
279
|
+
* attempt is done. TAO does the same, and the 1EdTech results-reporting reference results expect
|
|
280
|
+
* it. An adaptive item is completed only by its own processing.
|
|
281
|
+
*/
|
|
282
|
+
#handleSetOutcomes;
|
|
302
283
|
#handleSetTemplateValue;
|
|
303
284
|
#handleSetCorrectResponse;
|
|
304
285
|
#handleUpdateResponseVariable;
|
|
@@ -318,31 +299,69 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
318
299
|
this.#templateProcessing.process();
|
|
319
300
|
this.#initialContext = { ...this._context, variables: this._context.variables };
|
|
320
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Scores the attempt. The item does not score itself: its response processing does, like a
|
|
304
|
+
* backend, and sends the outcomes back in `qc-item-set-outcomes`, which the item applies in one
|
|
305
|
+
* update. The item keeps the attempt count (QTI info model §2.2.2: the delivery engine maintains
|
|
306
|
+
* numAttempts) and hands the new count to the run, whose rules may read it. Without response
|
|
307
|
+
* processing the item only counts the attempt. A run that throws still counts the attempt and applies
|
|
308
|
+
* no outcomes.
|
|
309
|
+
*
|
|
310
|
+
* @returns whether the item has response processing.
|
|
311
|
+
*/
|
|
321
312
|
processResponse(countNumAttempts = true, reportValidityAfterScoring = true) {
|
|
322
|
-
this
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
313
|
+
return this.#processResponse(countNumAttempts, reportValidityAfterScoring);
|
|
314
|
+
}
|
|
315
|
+
#processResponse(countNumAttempts, reportValidity, endedBy) {
|
|
316
|
+
this.#checkValidity(reportValidity);
|
|
317
|
+
this.#resetOtherEndAttempts(endedBy);
|
|
318
|
+
const numAttempts = +this.getVariable("numAttempts")?.value + (countNumAttempts ? 1 : 0);
|
|
319
|
+
const processor = this.querySelector("qti-response-processing");
|
|
320
|
+
if (typeof processor?.processResponse === "function") {
|
|
321
|
+
try {
|
|
322
|
+
processor.processResponse({ numAttempts });
|
|
323
|
+
} catch (error) {
|
|
324
|
+
this.#applyOutcomes([{ identifier: "numAttempts", value: String(numAttempts) }]);
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
336
328
|
}
|
|
337
|
-
this
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
329
|
+
dispatchPublic(this, "qc-item-set-outcomes", {
|
|
330
|
+
outcomes: [{ identifier: "numAttempts", value: String(numAttempts) }],
|
|
331
|
+
responseProcessed: true
|
|
332
|
+
});
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* QTI info model §2.4.5: when an attempt ends any other way than through an end-attempt
|
|
337
|
+
* interaction, that interaction's response is `false`.
|
|
338
|
+
*/
|
|
339
|
+
#resetOtherEndAttempts(endedBy) {
|
|
340
|
+
const others = Array.from(this.querySelectorAll("qti-end-attempt-interaction"), (el) => el.getAttribute("response-identifier")).filter((id) => id && id !== endedBy);
|
|
341
|
+
if (others.length === 0)
|
|
342
|
+
return;
|
|
343
|
+
this._context = {
|
|
344
|
+
...this._context,
|
|
345
|
+
variables: this._context.variables.map((v) => others.includes(v.identifier) ? { ...v, value: "false" } : v)
|
|
346
|
+
};
|
|
343
347
|
}
|
|
344
348
|
resetResponses() {
|
|
345
349
|
this._context = this.#initialContext;
|
|
350
|
+
if (this.isConnected)
|
|
351
|
+
this.#beginFirstAttempt();
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* QTI info model §2.2.2: completionStatus is `not_attempted` until the first attempt starts, then
|
|
355
|
+
* `unknown`. The attempt starts when the candidate gets the item, so an item on screen is never
|
|
356
|
+
* `not_attempted` — also not after a reset or a restore that says so.
|
|
357
|
+
*/
|
|
358
|
+
#beginFirstAttempt() {
|
|
359
|
+
if (this.getVariable("completionStatus")?.value !== "not_attempted")
|
|
360
|
+
return;
|
|
361
|
+
this._context = {
|
|
362
|
+
...this._context,
|
|
363
|
+
variables: this._context.variables.map((v) => v.identifier === "completionStatus" ? { ...v, value: "unknown" } : v)
|
|
364
|
+
};
|
|
346
365
|
}
|
|
347
366
|
getResponse(identifier) {
|
|
348
367
|
return this.getVariable(identifier);
|
|
@@ -374,14 +393,12 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
374
393
|
variables: this._context.variables.map((v) => v.identifier !== identifier ? v : { ...v, value })
|
|
375
394
|
};
|
|
376
395
|
this.afterResponseVariableUpdated();
|
|
377
|
-
dispatchPublic(this, "
|
|
396
|
+
dispatchPublic(this, "qc-item-response-changed", {
|
|
378
397
|
item: this.identifier,
|
|
379
398
|
responseIdentifier: identifier,
|
|
380
399
|
response: Array.isArray(value) ? [...value] : value
|
|
381
400
|
});
|
|
382
|
-
|
|
383
|
-
this.updateOutcomeVariable("completionStatus", this.#getCompletionStatus());
|
|
384
|
-
}
|
|
401
|
+
this.validate(false);
|
|
385
402
|
}
|
|
386
403
|
/**
|
|
387
404
|
* Updates the template variable with the specified identifier to the given value.
|
|
@@ -449,32 +466,53 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
449
466
|
* @param value - The new value for the response variable.
|
|
450
467
|
*/
|
|
451
468
|
updateOutcomeVariable(identifier, value) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
469
|
+
this.#applyOutcomes([{ identifier, value }]);
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Publishes the outcomes (and the validity) in one update, then a `qc-item-outcome-changed` per
|
|
473
|
+
* outcome with its final value and one `qc-item-outcomes-changed` with all of them.
|
|
474
|
+
* An identifier the item does not declare is skipped with a warning; a later entry for the same
|
|
475
|
+
* identifier wins.
|
|
476
|
+
*/
|
|
477
|
+
#applyOutcomes(outcomes, valid) {
|
|
478
|
+
const values = /* @__PURE__ */ new Map();
|
|
479
|
+
for (const { identifier, value } of outcomes) {
|
|
480
|
+
const variable = this.getVariable(identifier);
|
|
481
|
+
if (!variable) {
|
|
482
|
+
console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
values.set(identifier, variable.cardinality === "single" ? value : Array.isArray(value) ? value : [value]);
|
|
456
486
|
}
|
|
487
|
+
const validChanged = valid !== void 0 && valid !== this._context.valid;
|
|
488
|
+
if (values.size === 0 && !validChanged)
|
|
489
|
+
return;
|
|
457
490
|
this._context = {
|
|
458
491
|
...this._context,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
return v;
|
|
462
|
-
}
|
|
463
|
-
return {
|
|
464
|
-
...v,
|
|
465
|
-
value: outcomeVariable.cardinality === "single" ? value : Array.isArray(value) ? value : [value]
|
|
466
|
-
};
|
|
467
|
-
})
|
|
492
|
+
...validChanged ? { valid } : {},
|
|
493
|
+
variables: this._context.variables.map((v) => values.has(v.identifier) ? { ...v, value: values.get(v.identifier) } : v)
|
|
468
494
|
};
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
495
|
+
if (values.size > 0) {
|
|
496
|
+
for (const [outcomeIdentifier, value] of values) {
|
|
497
|
+
dispatchPublic(this, "qc-item-outcome-changed", {
|
|
498
|
+
item: this.identifier,
|
|
499
|
+
outcomeIdentifier,
|
|
500
|
+
value
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
dispatchPublic(this, "qc-item-outcomes-changed", {
|
|
504
|
+
item: this.identifier,
|
|
505
|
+
outcomes: [...values].map(([identifier, value]) => ({ identifier, value }))
|
|
506
|
+
});
|
|
507
|
+
}
|
|
474
508
|
}
|
|
475
509
|
validate(reportValidity = true) {
|
|
476
|
-
const isValid = this
|
|
510
|
+
const isValid = this.#checkValidity(reportValidity);
|
|
477
511
|
this.#publishValidity(isValid);
|
|
512
|
+
return isValid;
|
|
513
|
+
}
|
|
514
|
+
#checkValidity(reportValidity) {
|
|
515
|
+
const isValid = this.interactionElements.every((interactionElement) => interactionElement.validate());
|
|
478
516
|
if (reportValidity) {
|
|
479
517
|
this.reportValidity();
|
|
480
518
|
}
|
|
@@ -506,34 +544,6 @@ var QtiAssessmentItem = class extends LitElement {
|
|
|
506
544
|
interactionElement.reportValidity();
|
|
507
545
|
}
|
|
508
546
|
}
|
|
509
|
-
#getCompletionStatus() {
|
|
510
|
-
const valid = this.validate(false);
|
|
511
|
-
if (valid === true)
|
|
512
|
-
return "completed";
|
|
513
|
-
if (valid === false)
|
|
514
|
-
return "incomplete";
|
|
515
|
-
return "not_attempted";
|
|
516
|
-
}
|
|
517
|
-
#resetOutcomeVariablesBeforeResponseProcessing() {
|
|
518
|
-
this._context = {
|
|
519
|
-
...this._context,
|
|
520
|
-
variables: this._context.variables.map((variable) => {
|
|
521
|
-
if (variable.type !== "outcome") {
|
|
522
|
-
return variable;
|
|
523
|
-
}
|
|
524
|
-
const hasDefaultValue = "defaultValue" in variable;
|
|
525
|
-
const declaredDefault = hasDefaultValue ? variable.defaultValue : null;
|
|
526
|
-
let value = declaredDefault ?? null;
|
|
527
|
-
if ((value === null || value === void 0) && (variable.baseType === "integer" || variable.baseType === "float")) {
|
|
528
|
-
value = "0";
|
|
529
|
-
}
|
|
530
|
-
return {
|
|
531
|
-
...variable,
|
|
532
|
-
value
|
|
533
|
-
};
|
|
534
|
-
})
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
547
|
};
|
|
538
548
|
__decorate([
|
|
539
549
|
property({ type: String })
|
|
@@ -797,16 +807,6 @@ var QtiCustomOperator = class extends LitElement7 {
|
|
|
797
807
|
value
|
|
798
808
|
}
|
|
799
809
|
}));
|
|
800
|
-
},
|
|
801
|
-
updateResponseVariable: (responseIdentifier, response) => {
|
|
802
|
-
this.dispatchEvent(new CustomEvent("qti-interaction-response", {
|
|
803
|
-
bubbles: true,
|
|
804
|
-
composed: true,
|
|
805
|
-
detail: {
|
|
806
|
-
responseIdentifier,
|
|
807
|
-
response
|
|
808
|
-
}
|
|
809
|
-
}));
|
|
810
810
|
}
|
|
811
811
|
};
|
|
812
812
|
return this.#operatorFunction(this._context, fn, item);
|
|
@@ -837,6 +837,21 @@ __decorate5([
|
|
|
837
837
|
|
|
838
838
|
// ../qti-elements/dist/components/qti-feedback-block/qti-feedback-block.js
|
|
839
839
|
import { css as css3, html as html6 } from "lit";
|
|
840
|
+
|
|
841
|
+
// ../qti-elements/dist/internal/feedback-events.js
|
|
842
|
+
function dispatchFeedback(element, name, kind, identifier) {
|
|
843
|
+
const itemIdentifier = element.closest("qti-assessment-item")?.getAttribute("identifier") ?? void 0;
|
|
844
|
+
const detail = {
|
|
845
|
+
kind,
|
|
846
|
+
identifier,
|
|
847
|
+
outcomeIdentifier: element.outcomeIdentifier,
|
|
848
|
+
element,
|
|
849
|
+
...itemIdentifier ? { itemIdentifier } : {}
|
|
850
|
+
};
|
|
851
|
+
return dispatchPublic(element, name, detail, true);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// ../qti-elements/dist/components/qti-feedback-block/qti-feedback-block.js
|
|
840
855
|
var QtiFeedbackBlock = class extends QtiFeedback {
|
|
841
856
|
static {
|
|
842
857
|
this.styles = css3`
|
|
@@ -854,6 +869,13 @@ var QtiFeedbackBlock = class extends QtiFeedback {
|
|
|
854
869
|
render() {
|
|
855
870
|
return html6` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `;
|
|
856
871
|
}
|
|
872
|
+
/** `qc-feedback-show`: a listener that calls `preventDefault()` keeps this hidden and shows it itself. */
|
|
873
|
+
feedbackShowing() {
|
|
874
|
+
return dispatchFeedback(this, "qc-feedback-show", "block", this.identifier);
|
|
875
|
+
}
|
|
876
|
+
feedbackHiding() {
|
|
877
|
+
return dispatchFeedback(this, "qc-feedback-hide", "block", this.identifier);
|
|
878
|
+
}
|
|
857
879
|
connectedCallback() {
|
|
858
880
|
super.connectedCallback();
|
|
859
881
|
this.checkShowFeedback(this.outcomeIdentifier);
|
|
@@ -878,6 +900,13 @@ var QtiFeedbackInline = class extends QtiFeedback {
|
|
|
878
900
|
}
|
|
879
901
|
`;
|
|
880
902
|
}
|
|
903
|
+
/** `qc-feedback-show`: a listener that calls `preventDefault()` keeps this hidden and shows it itself. */
|
|
904
|
+
feedbackShowing() {
|
|
905
|
+
return dispatchFeedback(this, "qc-feedback-show", "inline", this.identifier);
|
|
906
|
+
}
|
|
907
|
+
feedbackHiding() {
|
|
908
|
+
return dispatchFeedback(this, "qc-feedback-hide", "inline", this.identifier);
|
|
909
|
+
}
|
|
881
910
|
connectedCallback() {
|
|
882
911
|
super.connectedCallback();
|
|
883
912
|
this.checkShowFeedback(this.outcomeIdentifier);
|
|
@@ -901,7 +930,7 @@ var QtiItemBody = class extends LitElement8 {
|
|
|
901
930
|
this.styles = qti_item_body_styles_default;
|
|
902
931
|
}
|
|
903
932
|
render() {
|
|
904
|
-
return html8`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`;
|
|
933
|
+
return html8`<slot part="rubrics qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`;
|
|
905
934
|
}
|
|
906
935
|
};
|
|
907
936
|
|
|
@@ -972,6 +1001,13 @@ var QtiModalFeedback = class extends QtiFeedback {
|
|
|
972
1001
|
this.showStatus = "off";
|
|
973
1002
|
}
|
|
974
1003
|
}
|
|
1004
|
+
/** `qc-feedback-show`: a listener that calls `preventDefault()` keeps this hidden and shows it itself. */
|
|
1005
|
+
feedbackShowing() {
|
|
1006
|
+
return dispatchFeedback(this, "qc-feedback-show", "modal", this.identifier);
|
|
1007
|
+
}
|
|
1008
|
+
feedbackHiding() {
|
|
1009
|
+
return dispatchFeedback(this, "qc-feedback-hide", "modal", this.identifier);
|
|
1010
|
+
}
|
|
975
1011
|
connectedCallback() {
|
|
976
1012
|
super.connectedCallback();
|
|
977
1013
|
if (this.showStatus === "on") {
|
|
@@ -1135,11 +1171,13 @@ var QtiResponseDeclaration = class extends QtiVariableDeclaration {
|
|
|
1135
1171
|
}
|
|
1136
1172
|
connectedCallback() {
|
|
1137
1173
|
super.connectedCallback();
|
|
1138
|
-
const defaultValue = this.defaultValues(this.cardinality);
|
|
1174
|
+
const defaultValue = this.cardinality === "record" ? this.#recordDefaultValue : this.defaultValues(this.cardinality);
|
|
1175
|
+
const { correctResponse, fieldBaseTypes } = this.#readCorrectResponse();
|
|
1139
1176
|
const responseVariable = {
|
|
1140
1177
|
baseType: this.baseType,
|
|
1141
1178
|
identifier: this.identifier,
|
|
1142
|
-
correctResponse
|
|
1179
|
+
correctResponse,
|
|
1180
|
+
...fieldBaseTypes ? { fieldBaseTypes } : {},
|
|
1143
1181
|
cardinality: this.cardinality || "single",
|
|
1144
1182
|
mapping: this.#mapping,
|
|
1145
1183
|
defaultValue,
|
|
@@ -1155,6 +1193,38 @@ var QtiResponseDeclaration = class extends QtiVariableDeclaration {
|
|
|
1155
1193
|
detail: { variable: responseVariable }
|
|
1156
1194
|
}));
|
|
1157
1195
|
}
|
|
1196
|
+
/**
|
|
1197
|
+
* The correct response, and for `record` cardinality the declared base type of each field.
|
|
1198
|
+
*
|
|
1199
|
+
* A record's correct response is a field map, `{ time: '4.0', point: '460 245' }`, read from
|
|
1200
|
+
* `qti-value field-identifier="…" base-type="…"`. The field base types are kept beside it, since
|
|
1201
|
+
* the record declaration itself has no `base-type` to say how a field is to be compared.
|
|
1202
|
+
*/
|
|
1203
|
+
#readCorrectResponse() {
|
|
1204
|
+
if (this.cardinality !== "record") {
|
|
1205
|
+
return { correctResponse: this.#correctResponse };
|
|
1206
|
+
}
|
|
1207
|
+
const correctResponse = this.querySelector("qti-correct-response");
|
|
1208
|
+
if (!correctResponse) {
|
|
1209
|
+
return { correctResponse: void 0 };
|
|
1210
|
+
}
|
|
1211
|
+
const values = Array.from(correctResponse.querySelectorAll("qti-value"));
|
|
1212
|
+
const { value, baseTypes } = readRecordFieldValues(values);
|
|
1213
|
+
values.forEach((element) => element.remove());
|
|
1214
|
+
return {
|
|
1215
|
+
// The variable types hold string | string[]; a record is stored as its field map.
|
|
1216
|
+
correctResponse: Object.keys(value).length ? value : void 0,
|
|
1217
|
+
fieldBaseTypes: baseTypes
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
/** A record's `qti-default-value`, as a field map like its correct response. */
|
|
1221
|
+
get #recordDefaultValue() {
|
|
1222
|
+
const values = this.querySelectorAll("qti-default-value > qti-value");
|
|
1223
|
+
if (values.length === 0)
|
|
1224
|
+
return null;
|
|
1225
|
+
const { value } = readRecordFieldValues(values);
|
|
1226
|
+
return Object.keys(value).length ? value : null;
|
|
1227
|
+
}
|
|
1158
1228
|
get #correctResponse() {
|
|
1159
1229
|
let result;
|
|
1160
1230
|
const correctResponse = this.querySelector("qti-correct-response");
|
|
@@ -1223,6 +1293,7 @@ __decorate7([
|
|
|
1223
1293
|
], QtiResponseDeclaration.prototype, "itemContext", void 0);
|
|
1224
1294
|
|
|
1225
1295
|
// ../qti-elements/dist/components/qti-response-processing/qti-response-processing.js
|
|
1296
|
+
import { ContextConsumer, ContextProvider } from "@lit/context";
|
|
1226
1297
|
import { css as css9, html as html12, LitElement as LitElement9 } from "lit";
|
|
1227
1298
|
|
|
1228
1299
|
// ../qti-elements/dist/internal/template-strings.js
|
|
@@ -1289,13 +1360,64 @@ var QtiResponseProcessing = class extends LitElement9 {
|
|
|
1289
1360
|
`
|
|
1290
1361
|
];
|
|
1291
1362
|
}
|
|
1363
|
+
/**
|
|
1364
|
+
* The rules inside read and write this element's copy of the item context, never the item's. It
|
|
1365
|
+
* is provided under the same `itemContext`: the nearest provider wins, so every expression in
|
|
1366
|
+
* here gets the copy without knowing about it.
|
|
1367
|
+
*/
|
|
1368
|
+
#provider = new ContextProvider(this, { context: itemContext });
|
|
1369
|
+
#copy;
|
|
1370
|
+
constructor() {
|
|
1371
|
+
super();
|
|
1372
|
+
new ContextConsumer(this, {
|
|
1373
|
+
context: itemContext,
|
|
1374
|
+
subscribe: true,
|
|
1375
|
+
// Every variable its own object, so a write changes the copy and not the item's context.
|
|
1376
|
+
callback: (context) => {
|
|
1377
|
+
this.#copy = { ...context, variables: context.variables.map((v) => ({ ...v })) };
|
|
1378
|
+
this.#provider.setValue(this.#copy);
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
this.addEventListener("qti-set-outcome-value", (e) => {
|
|
1382
|
+
e.stopImmediatePropagation();
|
|
1383
|
+
const variable = this.#copy?.variables.find((v) => v.identifier === e.detail.outcomeIdentifier);
|
|
1384
|
+
if (!variable) {
|
|
1385
|
+
console.warn(`Can not set qti-outcome-identifier: ${e.detail.outcomeIdentifier}, it is not available`);
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
const { value } = e.detail;
|
|
1389
|
+
variable.value = variable.cardinality === "single" ? value : Array.isArray(value) ? value : [value];
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1292
1392
|
render() {
|
|
1293
1393
|
return html12`<slot></slot>`;
|
|
1294
1394
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1395
|
+
/**
|
|
1396
|
+
* Scores the attempt on the copy: sets `numAttempts` to the count the item hands over, resets a
|
|
1397
|
+
* non-adaptive item's outcomes to their defaults (QTI info model §2.5), runs the rules and sends
|
|
1398
|
+
* every outcome and `numAttempts` in one `qc-item-set-outcomes`. The item applies them and publishes, which gives this element a
|
|
1399
|
+
* fresh copy. A rule that throws ends the run and the error propagates; nothing is sent, and the
|
|
1400
|
+
* run's writes stay in the copy until the item's next update.
|
|
1401
|
+
*/
|
|
1402
|
+
processResponse({ numAttempts }) {
|
|
1403
|
+
const copy = this.#copy;
|
|
1404
|
+
if (!copy)
|
|
1298
1405
|
return;
|
|
1406
|
+
const reset = this.closest("qti-assessment-item")?.getAttribute("adaptive") !== "true";
|
|
1407
|
+
for (const variable of copy.variables) {
|
|
1408
|
+
if (variable.identifier === "numAttempts")
|
|
1409
|
+
variable.value = String(numAttempts);
|
|
1410
|
+
if (variable.type === "outcome" && reset && variable.identifier !== "completionStatus") {
|
|
1411
|
+
variable.value = defaultValueOf(variable);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
this.#runRules();
|
|
1415
|
+
dispatchPublic(this, "qc-item-set-outcomes", {
|
|
1416
|
+
outcomes: copy.variables.filter((v) => v.type === "outcome" || v.identifier === "numAttempts").map(({ identifier, value }) => ({ identifier, value })),
|
|
1417
|
+
responseProcessed: true
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
#runRules() {
|
|
1299
1421
|
const rules = [...this.children];
|
|
1300
1422
|
try {
|
|
1301
1423
|
for (const rule of rules) {
|
|
@@ -1317,6 +1439,12 @@ var QtiResponseProcessing = class extends LitElement9 {
|
|
|
1317
1439
|
this.innerHTML = rules;
|
|
1318
1440
|
}
|
|
1319
1441
|
};
|
|
1442
|
+
function defaultValueOf(variable) {
|
|
1443
|
+
const value = ("defaultValue" in variable ? variable.defaultValue : null) ?? null;
|
|
1444
|
+
if (value === null && (variable.baseType === "integer" || variable.baseType === "float"))
|
|
1445
|
+
return "0";
|
|
1446
|
+
return value;
|
|
1447
|
+
}
|
|
1320
1448
|
|
|
1321
1449
|
// ../qti-elements/dist/components/qti-rubric-block/qti-rubric-block.js
|
|
1322
1450
|
import { LitElement as LitElement10, css as css10, html as html13 } from "lit";
|
|
@@ -1334,7 +1462,7 @@ var QtiRubricBlock = class extends LitElement10 {
|
|
|
1334
1462
|
switch (className) {
|
|
1335
1463
|
case "qti-rubric-discretionary-placement":
|
|
1336
1464
|
{
|
|
1337
|
-
const notCancelled = dispatchPublic(this, "
|
|
1465
|
+
const notCancelled = dispatchPublic(this, "qc-item-rubric-placement", { className, element: this }, true);
|
|
1338
1466
|
if (!notCancelled)
|
|
1339
1467
|
return;
|
|
1340
1468
|
this.setAttribute("slot", "qti-rubric-block");
|
|
@@ -1678,11 +1806,6 @@ var qtiContentElements = [
|
|
|
1678
1806
|
];
|
|
1679
1807
|
|
|
1680
1808
|
export {
|
|
1681
|
-
PUBLIC_ITEM_EVENTS,
|
|
1682
|
-
dispatchDeclared,
|
|
1683
|
-
listenDeclared,
|
|
1684
|
-
dispatchPublic,
|
|
1685
|
-
listenPublic,
|
|
1686
1809
|
QtiAssessmentItem,
|
|
1687
1810
|
QtiAssessmentStimulus,
|
|
1688
1811
|
QtiAssessmentStimulusRefConnectedEvent,
|
|
@@ -1705,4 +1828,4 @@ export {
|
|
|
1705
1828
|
QtiTemplateProcessing,
|
|
1706
1829
|
qtiContentElements
|
|
1707
1830
|
};
|
|
1708
|
-
//# sourceMappingURL=chunk-
|
|
1831
|
+
//# sourceMappingURL=chunk-H6DO5UHC.js.map
|