@citolab/qti-components 7.3.20 → 7.3.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/chunks/chunk-2BSPQRNR.js +6 -0
- package/cdn/chunks/chunk-2IJBTWWT.js +2 -0
- package/cdn/chunks/chunk-3BPUHYAN.js +1 -0
- package/cdn/chunks/chunk-3CVBBZDT.js +17 -0
- package/cdn/chunks/chunk-3IBGLVHA.js +1 -0
- package/cdn/chunks/chunk-4AGE7DVK.js +48 -0
- package/cdn/chunks/chunk-4DXCBZFR.js +3698 -0
- package/cdn/chunks/chunk-4FBS7ODL.js +6 -0
- package/cdn/chunks/chunk-4IWCVQQJ.js +8 -0
- package/cdn/chunks/chunk-522JFYKC.js +6 -0
- package/cdn/chunks/chunk-5L5JXKEA.js +1 -0
- package/cdn/chunks/chunk-5TEGKCEI.js +48 -0
- package/cdn/chunks/chunk-5WLHU3FH.js +8 -0
- package/cdn/chunks/chunk-6ELXCFB2.js +1 -0
- package/cdn/chunks/chunk-6Q3S6QYF.js +1471 -0
- package/cdn/chunks/chunk-6SGFGN34.js +8 -0
- package/cdn/chunks/chunk-6XVY32RS.js +1 -0
- package/cdn/chunks/chunk-6ZE2IMSJ.js +1471 -0
- package/cdn/chunks/chunk-73RDXCTO.js +1 -0
- package/cdn/chunks/chunk-73YTM4JU.js +8 -0
- package/cdn/chunks/chunk-A57EJSRU.js +1 -0
- package/cdn/chunks/chunk-AAZIKH5Z.js +3650 -0
- package/cdn/chunks/chunk-AMJIIPBQ.js +48 -0
- package/cdn/chunks/chunk-BGFVQO5N.js +8 -0
- package/cdn/chunks/chunk-BRXZ5HLX.js +8 -0
- package/cdn/chunks/chunk-BSBPPIVO.js +5 -0
- package/cdn/chunks/chunk-BURSTFDF.js +2 -0
- package/cdn/chunks/chunk-C7AO3IVZ.js +48 -0
- package/cdn/chunks/chunk-CTNAGYH7.js +1 -0
- package/cdn/chunks/chunk-DESMFZJW.js +5 -0
- package/cdn/chunks/chunk-DNBBQ7LY.js +1 -0
- package/cdn/chunks/chunk-DP5FVJRS.js +21 -0
- package/cdn/chunks/chunk-E46BCOOW.js +1 -0
- package/cdn/chunks/chunk-EGFC4XQG.js +5 -0
- package/cdn/chunks/chunk-EQ4LUVQK.js +8 -0
- package/cdn/chunks/chunk-EXVHRHST.js +8 -0
- package/cdn/chunks/chunk-FC7HXYUV.js +8 -0
- package/cdn/chunks/chunk-FEJUVLN4.js +6 -0
- package/cdn/chunks/chunk-FLQBFTRW.js +37 -0
- package/cdn/chunks/chunk-FUGKKQ6E.js +1 -0
- package/cdn/chunks/chunk-FWFPMNDO.js +5 -0
- package/cdn/chunks/chunk-FYXNIYGH.js +1 -0
- package/cdn/chunks/chunk-GFO3YUEH.js +1 -0
- package/cdn/chunks/chunk-HAE5ZHID.js +1 -0
- package/cdn/chunks/chunk-HCXHHI6V.js +18 -0
- package/cdn/chunks/chunk-HDMF4QZO.js +48 -0
- package/cdn/chunks/chunk-HKUIQBCM.js +1 -0
- package/cdn/chunks/chunk-HKWYQB5Z.js +37 -0
- package/cdn/chunks/chunk-HO6JOQX4.js +25 -0
- package/cdn/chunks/chunk-HTH5YCZO.js +8 -0
- package/cdn/chunks/chunk-IHVTWACH.js +8 -0
- package/cdn/chunks/chunk-ILEDSBLL.js +8 -0
- package/cdn/chunks/chunk-IYZLVTNL.js +5 -0
- package/cdn/chunks/chunk-J5P2GBPV.js +1 -0
- package/cdn/chunks/chunk-KASON6Y7.js +17 -0
- package/cdn/chunks/chunk-KKQK6WIG.js +1 -0
- package/cdn/chunks/chunk-LBMZYOKF.js +8 -0
- package/cdn/chunks/chunk-LC7KE332.js +1 -0
- package/cdn/chunks/chunk-LIUOA3YV.js +1 -0
- package/cdn/chunks/chunk-LO4MJ72X.js +8 -0
- package/cdn/chunks/chunk-LRGALTZX.js +1 -0
- package/cdn/chunks/chunk-LRIOWAOJ.js +8 -0
- package/cdn/chunks/chunk-LVKOQVTZ.js +17 -0
- package/cdn/chunks/chunk-M4VO4BD3.js +1471 -0
- package/cdn/chunks/chunk-M53CKFQE.js +5 -0
- package/cdn/chunks/chunk-MD33BNWM.js +1 -0
- package/cdn/chunks/chunk-MLEUGPRW.js +8 -0
- package/cdn/chunks/chunk-MM76ZODZ.js +8 -0
- package/cdn/chunks/chunk-MQVMYZ75.js +1 -0
- package/cdn/chunks/chunk-MRQ46JRY.js +8 -0
- package/cdn/chunks/chunk-MSOBQUON.js +10 -0
- package/cdn/chunks/chunk-NDMZ2RAB.js +48 -0
- package/cdn/chunks/chunk-NJP4VZB3.js +8 -0
- package/cdn/chunks/chunk-NO3TZB6T.js +5 -0
- package/cdn/chunks/chunk-NRY6IJSD.js +5 -0
- package/cdn/chunks/chunk-O4RAJ3LM.js +25 -0
- package/cdn/chunks/chunk-OEZI5WCY.js +18 -0
- package/cdn/chunks/chunk-OR67S36X.js +5 -0
- package/cdn/chunks/chunk-OSLUHYFD.js +8 -0
- package/cdn/chunks/chunk-P6L4B5GC.js +1 -0
- package/cdn/chunks/chunk-PF74FX32.js +1 -0
- package/cdn/chunks/chunk-PFCJVHJ3.js +10 -0
- package/cdn/chunks/chunk-PP62N3C4.js +8 -0
- package/cdn/chunks/chunk-PQLJWD6V.js +21 -0
- package/cdn/chunks/chunk-PTQFS3S5.js +2 -0
- package/cdn/chunks/chunk-PU7OABT3.js +1 -0
- package/cdn/chunks/chunk-Q2CKZUYX.js +1 -0
- package/cdn/chunks/chunk-QEFO63QX.js +8 -0
- package/cdn/chunks/chunk-QIZBL4QP.js +1 -0
- package/cdn/chunks/chunk-RGNFAPWY.js +2 -0
- package/cdn/chunks/chunk-RHEBGA4B.js +1 -0
- package/cdn/chunks/chunk-S5QDLZ6J.js +1 -0
- package/cdn/chunks/chunk-SBWSYKE5.js +5 -0
- package/cdn/chunks/chunk-SXRIA7VB.js +8 -0
- package/cdn/chunks/chunk-SYTQX5DA.js +1 -0
- package/cdn/chunks/chunk-TLK5RNXE.js +1 -0
- package/cdn/chunks/chunk-TR7WXOQR.js +1 -0
- package/cdn/chunks/chunk-UMDZKG6K.js +1 -0
- package/cdn/chunks/chunk-UNK5GKOK.js +5 -0
- package/cdn/chunks/chunk-V2AJKKRF.js +1470 -0
- package/cdn/chunks/chunk-VEG7LKS3.js +48 -0
- package/cdn/chunks/chunk-VQ2JX2OE.js +5 -0
- package/cdn/chunks/chunk-W73FT5JE.js +48 -0
- package/cdn/chunks/chunk-W7O6UFTQ.js +5 -0
- package/cdn/chunks/chunk-WCCTDLQ4.js +8 -0
- package/cdn/chunks/chunk-WV5B4HNF.js +1471 -0
- package/cdn/chunks/chunk-WWMMW7RJ.js +1 -0
- package/cdn/chunks/chunk-X3JAXGAZ.js +8 -0
- package/cdn/chunks/chunk-XJWUPDZ4.js +10 -0
- package/cdn/chunks/chunk-XMKJLLUL.js +1 -0
- package/cdn/chunks/chunk-XMS6AFBV.js +5 -0
- package/cdn/chunks/chunk-XSVPZFGN.js +1 -0
- package/cdn/chunks/chunk-Y2P4IF3E.js +1 -0
- package/cdn/chunks/chunk-YCBNF5QU.js +17 -0
- package/cdn/chunks/chunk-YEGYR7SL.js +5 -0
- package/cdn/chunks/chunk-YHLQ2JQ2.js +1 -0
- package/cdn/chunks/chunk-ZO5G6CHW.js +1470 -0
- package/cdn/chunks/chunk-ZPCQH3EY.js +10 -0
- package/cdn/chunks/chunk-ZUQ72RIQ.js +8 -0
- package/cdn/chunks/chunk-ZZNCHSYH.js +5 -0
- package/cdn/exports/computed-item.context.js +1 -1
- package/cdn/exports/computed.context.js +1 -1
- package/cdn/exports/config.context.js +1 -1
- package/cdn/exports/interaction.js +1 -1
- package/cdn/exports/qti-assessment-item.context.js +1 -1
- package/cdn/exports/qti-condition-expression.js +1 -1
- package/cdn/exports/qti-expression.js +1 -1
- package/cdn/exports/qti.context.js +1 -1
- package/cdn/exports/session.context.js +1 -1
- package/cdn/exports/test.context.js +1 -1
- package/cdn/index.global.js +1 -1
- package/cdn/index.js +1 -1
- package/cdn/qti-components/index.js +1 -1
- package/cdn/qti-item/components/item-container.js +1 -1
- package/cdn/qti-item/components/item-correct-response-mode.js +1 -1
- package/cdn/qti-item/components/item-show-candidate-correction.js +1 -1
- package/cdn/qti-item/components/item-show-correct-response.js +1 -1
- package/cdn/qti-item/components/print-item-variables.js +1 -1
- package/cdn/qti-item/components/styles.js +1 -1
- package/cdn/qti-item/core/index.js +1 -1
- package/cdn/qti-test/components/index.js +1 -1
- package/cdn/qti-test/components/styles.js +1 -1
- package/cdn/qti-test/components/test-check-item.js +1 -1
- package/cdn/qti-test/components/test-container.js +1 -1
- package/cdn/qti-test/components/test-end-attempt.js +1 -1
- package/cdn/qti-test/components/test-item-link.js +1 -1
- package/cdn/qti-test/components/test-navigation.js +1 -1
- package/cdn/qti-test/components/test-next.js +1 -1
- package/cdn/qti-test/components/test-paging-buttons-stamp.js +1 -1
- package/cdn/qti-test/components/test-prev.js +1 -1
- package/cdn/qti-test/components/test-print-context.js +1 -1
- package/cdn/qti-test/components/test-print-item-variables.js +1 -1
- package/cdn/qti-test/components/test-scoring-buttons.js +1 -1
- package/cdn/qti-test/components/test-scoring-feedback.js +1 -1
- package/cdn/qti-test/components/test-section-buttons-stamp.js +1 -1
- package/cdn/qti-test/components/test-section-link.js +1 -1
- package/cdn/qti-test/components/test-show-correct-response.js +1 -1
- package/cdn/qti-test/components/test-stamp.js +1 -1
- package/cdn/qti-test/components/test-view-toggle.js +1 -1
- package/cdn/qti-test/components/test-view.js +1 -1
- package/cdn/qti-test/core/index.js +1 -1
- package/dist/chunks/chunk-3JJM4BKK.js +367 -0
- package/dist/chunks/chunk-3JJM4BKK.js.map +1 -0
- package/dist/chunks/chunk-3LX4O663.js +3688 -0
- package/dist/chunks/chunk-3LX4O663.js.map +1 -0
- package/dist/chunks/chunk-4PG2PZHY.js +8924 -0
- package/dist/chunks/chunk-4PG2PZHY.js.map +1 -0
- package/dist/chunks/chunk-55C6NAK5.js +142 -0
- package/dist/chunks/chunk-55C6NAK5.js.map +1 -0
- package/dist/chunks/chunk-5P64MALP.js +3640 -0
- package/dist/chunks/chunk-5P64MALP.js.map +1 -0
- package/dist/chunks/chunk-65YQSKWV.js +94 -0
- package/dist/chunks/chunk-65YQSKWV.js.map +1 -0
- package/dist/chunks/chunk-ARBFS6D6.js +8924 -0
- package/dist/chunks/chunk-ARBFS6D6.js.map +1 -0
- package/dist/chunks/chunk-EB3ZESWL.js +367 -0
- package/dist/chunks/chunk-EB3ZESWL.js.map +1 -0
- package/dist/chunks/chunk-ERYHQVOT.js +8 -0
- package/dist/chunks/chunk-ERYHQVOT.js.map +1 -0
- package/dist/chunks/chunk-FL72PF4D.js +19 -0
- package/dist/chunks/chunk-FL72PF4D.js.map +1 -0
- package/dist/chunks/chunk-HFAUM56X.js +208 -0
- package/dist/chunks/chunk-HFAUM56X.js.map +1 -0
- package/dist/chunks/chunk-JOASLKRQ.js +914 -0
- package/dist/chunks/chunk-JOASLKRQ.js.map +1 -0
- package/dist/chunks/chunk-K4QJBUIX.js +367 -0
- package/dist/chunks/chunk-K4QJBUIX.js.map +1 -0
- package/dist/chunks/chunk-KYN4AAHS.js +8839 -0
- package/dist/chunks/chunk-KYN4AAHS.js.map +1 -0
- package/dist/chunks/chunk-MLRMRXGZ.js +367 -0
- package/dist/chunks/chunk-MLRMRXGZ.js.map +1 -0
- package/dist/chunks/chunk-MOIHNOX3.js +94 -0
- package/dist/chunks/chunk-MOIHNOX3.js.map +1 -0
- package/dist/chunks/chunk-P2PRB5IZ.js +94 -0
- package/dist/chunks/chunk-P2PRB5IZ.js.map +1 -0
- package/dist/chunks/chunk-PF5X3SZR.js +94 -0
- package/dist/chunks/chunk-PF5X3SZR.js.map +1 -0
- package/dist/chunks/chunk-QCB6P7DH.js +146 -0
- package/dist/chunks/chunk-QCB6P7DH.js.map +1 -0
- package/dist/chunks/chunk-QU7KR7VX.js +367 -0
- package/dist/chunks/chunk-QU7KR7VX.js.map +1 -0
- package/dist/chunks/chunk-RTSIFU3A.js +8924 -0
- package/dist/chunks/chunk-RTSIFU3A.js.map +1 -0
- package/dist/chunks/chunk-SZ3DDAJ7.js +142 -0
- package/dist/chunks/chunk-SZ3DDAJ7.js.map +1 -0
- package/dist/chunks/chunk-SZTQ6IWR.js +8835 -0
- package/dist/chunks/chunk-SZTQ6IWR.js.map +1 -0
- package/dist/chunks/chunk-UUM4KYBV.js +914 -0
- package/dist/chunks/chunk-UUM4KYBV.js.map +1 -0
- package/dist/chunks/chunk-V4L4ONOK.js +914 -0
- package/dist/chunks/chunk-V4L4ONOK.js.map +1 -0
- package/dist/chunks/chunk-V7ACRMW7.js +914 -0
- package/dist/chunks/chunk-V7ACRMW7.js.map +1 -0
- package/dist/chunks/chunk-WEKBCXNI.js +8839 -0
- package/dist/chunks/chunk-WEKBCXNI.js.map +1 -0
- package/dist/chunks/chunk-WN6TJQI2.js +103 -0
- package/dist/chunks/chunk-WN6TJQI2.js.map +1 -0
- package/dist/chunks/chunk-XM2JOPVU.js +914 -0
- package/dist/chunks/chunk-XM2JOPVU.js.map +1 -0
- package/dist/chunks/chunk-ZZIDNW4D.js +914 -0
- package/dist/chunks/chunk-ZZIDNW4D.js.map +1 -0
- package/dist/exports/computed-item.context.d.ts +2 -1
- package/dist/exports/computed.context.d.ts +3 -2
- package/dist/exports/config.context.d.ts +1 -0
- package/dist/exports/config.context.js +1 -1
- package/dist/exports/interaction.d.ts +2 -1
- package/dist/exports/interaction.js +5 -2
- package/dist/exports/item.context.d.ts +2 -1
- package/dist/exports/qti-assessment-item.context.d.ts +2 -1
- package/dist/exports/qti-condition-expression.d.ts +2 -1
- package/dist/exports/qti-condition-expression.js +3 -3
- package/dist/exports/qti-expression.d.ts +2 -1
- package/dist/exports/qti-expression.js +2 -2
- package/dist/exports/qti-test.d.ts +3 -2
- package/dist/exports/session.context.d.ts +3 -2
- package/dist/exports/test.context.d.ts +2 -1
- package/dist/exports/variables.d.ts +2 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/item.css +66 -6
- package/dist/qti-components/index.d.ts +16 -5
- package/dist/qti-components/index.js +6 -6
- package/dist/qti-components-jsx.d.ts +29 -18
- package/dist/qti-item/components/item-container.js +2 -2
- package/dist/qti-item/components/item-correct-response-mode.js +1 -1
- package/dist/qti-item/components/item-show-candidate-correction.d.ts +2 -1
- package/dist/qti-item/components/item-show-correct-response.d.ts +2 -1
- package/dist/qti-item/components/print-item-variables.d.ts +2 -1
- package/dist/qti-item/core/index.d.ts +1 -1
- package/dist/qti-item/core/index.js +4 -4
- package/dist/qti-loader/index.d.ts +2 -1
- package/dist/qti-response-declaration-BKOw2_Pl.d.ts +1378 -0
- package/dist/qti-response-declaration-DKr08ANy.d.ts +1397 -0
- package/dist/qti-response-declaration-Dz6D30cF.d.ts +1397 -0
- package/dist/qti-response-declaration-d_tAAEFq.d.ts +1378 -0
- package/dist/qti-test/components/index.d.ts +3 -3
- package/dist/qti-test/components/index.js +4 -4
- package/dist/qti-test/components/test-container.js +2 -2
- package/dist/qti-test/components/test-navigation.d.ts +2 -2
- package/dist/qti-test/components/test-navigation.js +2 -2
- package/dist/qti-test/components/test-next.d.ts +3 -2
- package/dist/qti-test/components/test-prev.d.ts +3 -2
- package/dist/qti-test/components/test-print-context.d.ts +3 -2
- package/dist/qti-test/components/test-print-item-variables.d.ts +3 -2
- package/dist/qti-test/components/test-scoring-buttons.d.ts +3 -2
- package/dist/qti-test/components/test-scoring-feedback.d.ts +3 -2
- package/dist/qti-test/components/test-show-correct-response.d.ts +3 -2
- package/dist/qti-test/core/index.d.ts +4 -3
- package/dist/qti-test/core/index.js +7 -7
- package/dist/qti-test-feedback-Bskvq3FE.d.ts +91 -0
- package/dist/qti-test-feedback-CZsbp6z4.d.ts +91 -0
- package/dist/qti-test-feedback-dSr4W5Ft.d.ts +91 -0
- package/dist/qti-test-feedback-jBGxkr5n.d.ts +91 -0
- package/dist/vscode.html-custom-data.json +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
item_default
|
|
3
|
+
} from "./chunk-5P64MALP.js";
|
|
4
|
+
import {
|
|
5
|
+
watch
|
|
6
|
+
} from "./chunk-ELDMXTUQ.js";
|
|
7
|
+
import {
|
|
8
|
+
qtiTransformItem
|
|
9
|
+
} from "./chunk-WFUXZ4UT.js";
|
|
10
|
+
import {
|
|
11
|
+
__decorateClass
|
|
12
|
+
} from "./chunk-H2JE6IVU.js";
|
|
13
|
+
|
|
14
|
+
// src/lib/qti-item/components/item-container.ts
|
|
15
|
+
import { LitElement, html } from "lit";
|
|
16
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
17
|
+
import { until } from "lit/directives/until.js";
|
|
18
|
+
var ItemContainer = class extends LitElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.itemURL = null;
|
|
22
|
+
this.itemDoc = null;
|
|
23
|
+
this.itemXML = null;
|
|
24
|
+
/** Template content if provided */
|
|
25
|
+
this.templateContent = null;
|
|
26
|
+
}
|
|
27
|
+
async handleItemURLChange() {
|
|
28
|
+
if (!this.itemURL) return;
|
|
29
|
+
try {
|
|
30
|
+
const { promise: api } = await qtiTransformItem().load(this.itemURL);
|
|
31
|
+
this.itemDoc = (await api).htmlDoc();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("Error loading or parsing XML:", error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
handleItemXMLChange() {
|
|
37
|
+
if (!this.itemXML) return;
|
|
38
|
+
try {
|
|
39
|
+
this.itemDoc = qtiTransformItem().parse(this.itemXML).htmlDoc();
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error("Error parsing XML:", error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async connectedCallback() {
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
this.initializeTemplateContent();
|
|
47
|
+
this.applyStyles();
|
|
48
|
+
if (this.itemURL) {
|
|
49
|
+
this.handleItemURLChange();
|
|
50
|
+
}
|
|
51
|
+
if (this.itemXML) {
|
|
52
|
+
this.handleItemXMLChange();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
initializeTemplateContent() {
|
|
56
|
+
const template = this.querySelector("template");
|
|
57
|
+
this.templateContent = template ? template.content : html``;
|
|
58
|
+
}
|
|
59
|
+
applyStyles() {
|
|
60
|
+
const sheet = new CSSStyleSheet();
|
|
61
|
+
sheet.replaceSync(item_default);
|
|
62
|
+
this.shadowRoot.adoptedStyleSheets = [sheet];
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
return html`
|
|
66
|
+
${this.templateContent}
|
|
67
|
+
<slot></slot>
|
|
68
|
+
${until(this.itemDoc, html`<span>Loading...</span>`)}
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
__decorateClass([
|
|
73
|
+
property({ type: String, attribute: "item-url" })
|
|
74
|
+
], ItemContainer.prototype, "itemURL", 2);
|
|
75
|
+
__decorateClass([
|
|
76
|
+
state()
|
|
77
|
+
], ItemContainer.prototype, "itemDoc", 2);
|
|
78
|
+
__decorateClass([
|
|
79
|
+
state()
|
|
80
|
+
], ItemContainer.prototype, "itemXML", 2);
|
|
81
|
+
__decorateClass([
|
|
82
|
+
watch("itemURL", { waitUntilFirstUpdate: true })
|
|
83
|
+
], ItemContainer.prototype, "handleItemURLChange", 1);
|
|
84
|
+
__decorateClass([
|
|
85
|
+
watch("itemXML", { waitUntilFirstUpdate: true })
|
|
86
|
+
], ItemContainer.prototype, "handleItemXMLChange", 1);
|
|
87
|
+
ItemContainer = __decorateClass([
|
|
88
|
+
customElement("item-container")
|
|
89
|
+
], ItemContainer);
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
ItemContainer
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-PF5X3SZR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-item/components/item-container.ts"],"sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { until } from 'lit/directives/until.js';\n\nimport { watch } from '../../decorators/watch';\nimport itemCss from '../../../item.css?inline';\nimport { qtiTransformItem } from '../../qti-transformers';\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@customElement('item-container')\nexport class ItemContainer extends LitElement {\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 /** Template content if provided */\n private templateContent = null;\n\n @watch('itemURL', { waitUntilFirstUpdate: true })\n protected async handleItemURLChange() {\n if (!this.itemURL) return;\n try {\n const { promise: api } = await qtiTransformItem().load(this.itemURL);\n this.itemDoc = (await api).htmlDoc();\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().parse(this.itemXML).htmlDoc();\n } catch (error) {\n console.error('Error parsing XML:', error);\n }\n }\n\n 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 private initializeTemplateContent() {\n const template = this.querySelector('template') as HTMLTemplateElement;\n this.templateContent = template ? template.content : html``;\n }\n\n private applyStyles() {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(itemCss);\n this.shadowRoot.adoptedStyleSheets = [sheet];\n }\n\n 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"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,YAAY,YAAY;AACjC,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,aAAa;AAqBf,IAAM,gBAAN,cAA4B,WAAW;AAAA,EAAvC;AAAA;AAGL,mBAAkB;AAIlB,mBAA4B;AAI5B,mBAAkB;AAGlB;AAAA,SAAQ,kBAAkB;AAAA;AAAA,EAG1B,MAAgB,sBAAsB;AACpC,QAAI,CAAC,KAAK,QAAS;AACnB,QAAI;AACF,YAAM,EAAE,SAAS,IAAI,IAAI,MAAM,iBAAiB,EAAE,KAAK,KAAK,OAAO;AACnE,WAAK,WAAW,MAAM,KAAK,QAAQ;AAAA,IACrC,SAAS,OAAO;AACd,cAAQ,MAAM,iCAAiC,KAAK;AAAA,IACtD;AAAA,EACF;AAAA,EAGU,sBAAsB;AAC9B,QAAI,CAAC,KAAK,QAAS;AACnB,QAAI;AACF,WAAK,UAAU,iBAAiB,EAAE,MAAM,KAAK,OAAO,EAAE,QAAQ;AAAA,IAChE,SAAS,OAAO;AACd,cAAQ,MAAM,sBAAsB,KAAK;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,MAAM,oBAAmC;AACvC,UAAM,kBAAkB;AACxB,SAAK,0BAA0B;AAC/B,SAAK,YAAY;AACjB,QAAI,KAAK,SAAS;AAChB,WAAK,oBAAoB;AAAA,IAC3B;AACA,QAAI,KAAK,SAAS;AAChB,WAAK,oBAAoB;AAAA,IAC3B;AAAA,EACF;AAAA,EAEQ,4BAA4B;AAClC,UAAM,WAAW,KAAK,cAAc,UAAU;AAC9C,SAAK,kBAAkB,WAAW,SAAS,UAAU;AAAA,EACvD;AAAA,EAEQ,cAAc;AACpB,UAAM,QAAQ,IAAI,cAAc;AAChC,UAAM,YAAY,YAAO;AACzB,SAAK,WAAW,qBAAqB,CAAC,KAAK;AAAA,EAC7C;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,QACH,KAAK,eAAe;AAAA;AAAA,QAEpB,MAAM,KAAK,SAAS,6BAA6B,CAAC;AAAA;AAAA,EAExD;AACF;AAhEE;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,WAAW,WAAW,CAAC;AAAA,GAFtC,cAGX;AAIA;AAAA,EADC,MAAM;AAAA,GANI,cAOX;AAIA;AAAA,EADC,MAAM;AAAA,GAVI,cAWX;AAMgB;AAAA,EADf,MAAM,WAAW,EAAE,sBAAsB,KAAK,CAAC;AAAA,GAhBrC,cAiBK;AAWN;AAAA,EADT,MAAM,WAAW,EAAE,sBAAsB,KAAK,CAAC;AAAA,GA3BrC,cA4BD;AA5BC,gBAAN;AAAA,EADN,cAAc,gBAAgB;AAAA,GAClB;","names":[]}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
qtiContext
|
|
3
|
+
} from "./chunk-H6KHXSIO.js";
|
|
4
|
+
import {
|
|
5
|
+
itemContext
|
|
6
|
+
} from "./chunk-NJNQOQUU.js";
|
|
7
|
+
import {
|
|
8
|
+
__decorateClass
|
|
9
|
+
} from "./chunk-H2JE6IVU.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/exports/qti-expression.ts
|
|
12
|
+
import { consume } from "@lit/context";
|
|
13
|
+
import { css, html, LitElement } from "lit";
|
|
14
|
+
import { state } from "lit/decorators.js";
|
|
15
|
+
var QtiExpression = class extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.getVariables = () => (
|
|
19
|
+
// FIXME: if this itself is multiple, this will never enter the qti-multiple switch
|
|
20
|
+
// See this example here: https://github.com/1EdTech/qti-examples/blob/master/qtiv3-examples/packaging/items/Example05-feedbackBlock-adaptive.xml
|
|
21
|
+
Array.from(this.children).map((e) => {
|
|
22
|
+
console.debug("getVariables", e.tagName.toLowerCase());
|
|
23
|
+
switch (e.tagName.toLowerCase()) {
|
|
24
|
+
case "qti-base-value": {
|
|
25
|
+
return {
|
|
26
|
+
baseType: e.getAttribute("base-type"),
|
|
27
|
+
value: e.textContent.trim(),
|
|
28
|
+
cardinality: "single"
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
case "qti-variable": {
|
|
32
|
+
const identifier = e.getAttribute("identifier") || "";
|
|
33
|
+
if (identifier === "QTI_CONTEXT") {
|
|
34
|
+
if (!this.qtiContext?.QTI_CONTEXT) {
|
|
35
|
+
console.warn("QTI_CONTEXT not available");
|
|
36
|
+
return {
|
|
37
|
+
identifier: "QTI_CONTEXT",
|
|
38
|
+
baseType: "record",
|
|
39
|
+
value: this.qtiContext.QTI_CONTEXT,
|
|
40
|
+
cardinality: "record",
|
|
41
|
+
type: "context"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
identifier: "QTI_CONTEXT",
|
|
46
|
+
baseType: "record",
|
|
47
|
+
value: this.qtiContext.QTI_CONTEXT,
|
|
48
|
+
cardinality: "record",
|
|
49
|
+
type: "context"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const variable = this.context.variables.find((v) => v.identifier === identifier) || null;
|
|
53
|
+
return variable;
|
|
54
|
+
}
|
|
55
|
+
case "qti-multiple": {
|
|
56
|
+
const multiple = e;
|
|
57
|
+
const values = multiple.getResult();
|
|
58
|
+
console.debug("values", values);
|
|
59
|
+
if (values?.length > 0) {
|
|
60
|
+
return {
|
|
61
|
+
identifier: "",
|
|
62
|
+
baseType: values[0].baseType,
|
|
63
|
+
value: values.map((v) => v.value),
|
|
64
|
+
cardinality: "multiple",
|
|
65
|
+
type: "response"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
case "qti-ordered": {
|
|
71
|
+
const multiple = e;
|
|
72
|
+
const values = multiple.getResult();
|
|
73
|
+
if (values?.length > 0) {
|
|
74
|
+
return {
|
|
75
|
+
identifier: "",
|
|
76
|
+
baseType: values[0].baseType,
|
|
77
|
+
value: values.map((v) => v.value),
|
|
78
|
+
cardinality: "ordered",
|
|
79
|
+
type: "response"
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
case "qti-correct": {
|
|
85
|
+
const identifier = e.getAttribute("identifier") || "";
|
|
86
|
+
const responseVariable = this.context.variables.find((v) => v.identifier === identifier) || null;
|
|
87
|
+
return {
|
|
88
|
+
baseType: responseVariable.baseType,
|
|
89
|
+
value: responseVariable.correctResponse,
|
|
90
|
+
cardinality: responseVariable.cardinality
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
default: {
|
|
94
|
+
try {
|
|
95
|
+
const expression = e;
|
|
96
|
+
const value = expression.getResult();
|
|
97
|
+
return {
|
|
98
|
+
baseType: "integer",
|
|
99
|
+
value: value?.toString() || null,
|
|
100
|
+
cardinality: "single"
|
|
101
|
+
};
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.warn("default not sufficient");
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}).filter((v) => v !== null)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
static {
|
|
112
|
+
// hide the slot with css
|
|
113
|
+
this.styles = css`
|
|
114
|
+
slot {
|
|
115
|
+
display: none;
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
return html`<pre>${JSON.stringify(this.result, null, 2)}</pre>
|
|
121
|
+
<slot></slot>`;
|
|
122
|
+
}
|
|
123
|
+
calculate() {
|
|
124
|
+
this.result = this.getResult();
|
|
125
|
+
return this.result;
|
|
126
|
+
}
|
|
127
|
+
getResult() {
|
|
128
|
+
throw new Error("Not implemented");
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
__decorateClass([
|
|
132
|
+
state()
|
|
133
|
+
], QtiExpression.prototype, "result", 2);
|
|
134
|
+
__decorateClass([
|
|
135
|
+
consume({ context: itemContext, subscribe: true }),
|
|
136
|
+
state()
|
|
137
|
+
], QtiExpression.prototype, "context", 2);
|
|
138
|
+
__decorateClass([
|
|
139
|
+
consume({ context: qtiContext, subscribe: true }),
|
|
140
|
+
state()
|
|
141
|
+
], QtiExpression.prototype, "qtiContext", 2);
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
QtiExpression
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=chunk-QCB6P7DH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/exports/qti-expression.ts"],"sourcesContent":["import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { itemContext } from './qti-assessment-item.context';\nimport { qtiContext } from './qti.context';\n\nimport type { QtiContext, QtiContextType } from './qti.context';\nimport type { ResponseVariable, VariableDeclaration } from './variables';\nimport type { QtiMultiple } from '../qti-components/qti-response-processing/qti-expression/qti-multiple/qti-multiple';\nimport type { QtiOrdered } from '../qti-components/qti-response-processing/qti-expression/qti-ordered/qti-ordered';\nimport type { ItemContext } from './item.context';\n\nexport interface QtiExpressionBase<T> {\n // get assessmentItem(): QtiAssessmentItem;\n\n // getVariables(): VariableDeclaration<number | string | (number | string)[] | null>[];\n calculate(): Readonly<T>;\n}\n\nexport abstract class QtiExpression<T> extends LitElement implements QtiExpressionBase<T> {\n @state()\n protected result: any;\n\n // hide the slot with css\n static styles = css`\n slot {\n display: none;\n }\n `;\n\n override render() {\n return html`<pre>${JSON.stringify(this.result, null, 2)}</pre>\n <slot></slot>`;\n }\n\n public calculate(): Readonly<T> {\n this.result = this.getResult();\n return this.result;\n }\n\n protected getResult(): Readonly<T> {\n throw new Error('Not implemented');\n }\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n protected context?: ItemContext;\n\n @consume({ context: qtiContext, subscribe: true })\n @state()\n protected qtiContext?: QtiContext;\n\n getVariables = (): (ResponseVariable | VariableDeclaration<QtiContextType>)[] =>\n // FIXME: if this itself is multiple, this will never enter the qti-multiple switch\n // See this example here: https://github.com/1EdTech/qti-examples/blob/master/qtiv3-examples/packaging/items/Example05-feedbackBlock-adaptive.xml\n\n Array.from(this.children)\n .map((e: Element) => {\n console.debug('getVariables', e.tagName.toLowerCase());\n switch (e.tagName.toLowerCase()) {\n case 'qti-base-value': {\n return {\n baseType: e.getAttribute('base-type'),\n value: e.textContent.trim(),\n cardinality: 'single'\n } as ResponseVariable;\n }\n case 'qti-variable': {\n const identifier = e.getAttribute('identifier') || '';\n\n // Special handling for QTI_CONTEXT\n if (identifier === 'QTI_CONTEXT') {\n if (!this.qtiContext?.QTI_CONTEXT) {\n console.warn('QTI_CONTEXT not available');\n return {\n identifier: 'QTI_CONTEXT',\n baseType: 'record',\n value: this.qtiContext.QTI_CONTEXT,\n cardinality: 'record',\n type: 'context'\n } as VariableDeclaration<QtiContextType>;\n }\n return {\n identifier: 'QTI_CONTEXT',\n baseType: 'record',\n value: this.qtiContext.QTI_CONTEXT,\n cardinality: 'record',\n type: 'context'\n } as VariableDeclaration<QtiContextType>;\n }\n\n const variable = this.context.variables.find(v => v.identifier === identifier) || null;\n return variable;\n }\n case 'qti-multiple': {\n const multiple = e as QtiMultiple;\n\n const values = multiple.getResult();\n console.debug('values', values);\n if (values?.length > 0) {\n return {\n identifier: '',\n baseType: values[0].baseType,\n value: values.map(v => v.value),\n cardinality: 'multiple',\n type: 'response'\n } as ResponseVariable;\n }\n return null;\n }\n case 'qti-ordered': {\n const multiple = e as QtiOrdered;\n const values = multiple.getResult();\n if (values?.length > 0) {\n return {\n identifier: '',\n baseType: values[0].baseType,\n value: values.map(v => v.value),\n cardinality: 'ordered',\n type: 'response'\n } as ResponseVariable;\n }\n return null;\n }\n case 'qti-correct': {\n const identifier = e.getAttribute('identifier') || '';\n const responseVariable: ResponseVariable =\n this.context.variables.find(v => v.identifier === identifier) || null;\n return {\n baseType: responseVariable.baseType,\n value: responseVariable.correctResponse,\n cardinality: responseVariable.cardinality\n } as ResponseVariable;\n }\n default: {\n // added for use of qti-equal-rounded\n try {\n const expression = e as QtiExpression<number>;\n const value = expression.getResult();\n return {\n baseType: 'integer',\n value: value?.toString() || null,\n cardinality: 'single'\n } as ResponseVariable;\n } catch (error) {\n console.warn('default not sufficient');\n }\n return null;\n }\n }\n })\n .filter(v => v !== null);\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import {
|
|
2
|
+
qtiContext
|
|
3
|
+
} from "./chunk-H6KHXSIO.js";
|
|
4
|
+
import {
|
|
5
|
+
sessionContext
|
|
6
|
+
} from "./chunk-22IRJWWY.js";
|
|
7
|
+
import {
|
|
8
|
+
testContext
|
|
9
|
+
} from "./chunk-CJADUWEC.js";
|
|
10
|
+
import {
|
|
11
|
+
computedContext
|
|
12
|
+
} from "./chunk-AZIKAG7K.js";
|
|
13
|
+
import {
|
|
14
|
+
configContext
|
|
15
|
+
} from "./chunk-ERYHQVOT.js";
|
|
16
|
+
import {
|
|
17
|
+
__decorateClass
|
|
18
|
+
} from "./chunk-H2JE6IVU.js";
|
|
19
|
+
|
|
20
|
+
// src/lib/qti-test/components/test-navigation.ts
|
|
21
|
+
import { consume, provide } from "@lit/context";
|
|
22
|
+
import { html, LitElement } from "lit";
|
|
23
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
24
|
+
var TestNavigation = class extends LitElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this.identifier = void 0;
|
|
28
|
+
this.initContext = [];
|
|
29
|
+
this.qtiContext = {
|
|
30
|
+
QTI_CONTEXT: {
|
|
31
|
+
testIdentifier: "",
|
|
32
|
+
candidateIdentifier: "",
|
|
33
|
+
environmentIdentifier: "default"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.configContext = {};
|
|
37
|
+
this.autoScoreItems = false;
|
|
38
|
+
this.addEventListener("qti-assessment-test-connected", this._handleTestConnected.bind(this));
|
|
39
|
+
this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
|
|
40
|
+
this.addEventListener("qti-interaction-changed", this._handleInteractionChanged.bind(this));
|
|
41
|
+
this.addEventListener("test-end-attempt", this._handleTestEndAttempt.bind(this));
|
|
42
|
+
this.addEventListener("test-show-correct-response", this._handleTestShowCorrectResponse.bind(this));
|
|
43
|
+
this.addEventListener("test-show-candidate-correction", this._handleTestShowCandidateCorrection.bind(this));
|
|
44
|
+
this.addEventListener("test-update-outcome-variable", this._handleTestUpdateOutcomeVariable.bind(this));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Handles the 'test-end-attempt' event.
|
|
48
|
+
* @private
|
|
49
|
+
* @listens TestNavigation#test-end-attempt
|
|
50
|
+
* @param {CustomEvent} event - The custom event object.
|
|
51
|
+
*/
|
|
52
|
+
_handleTestEndAttempt(_event) {
|
|
53
|
+
const qtiItemEl = this._testElement.querySelector(
|
|
54
|
+
`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
|
|
55
|
+
);
|
|
56
|
+
const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
|
|
57
|
+
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
58
|
+
qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
|
|
59
|
+
}
|
|
60
|
+
// protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
61
|
+
// return this;
|
|
62
|
+
// }
|
|
63
|
+
// myTemplate: TemplateFunction;
|
|
64
|
+
// connectedCallback(): void {
|
|
65
|
+
// super.connectedCallback();
|
|
66
|
+
// const templateElement = this.querySelector<HTMLTemplateElement>('template');
|
|
67
|
+
// if (!templateElement) {
|
|
68
|
+
// this.myTemplate = null;
|
|
69
|
+
// return;
|
|
70
|
+
// }
|
|
71
|
+
// this.myTemplate = prepareTemplate(templateElement);
|
|
72
|
+
// }
|
|
73
|
+
/**
|
|
74
|
+
* Handles the 'test-show-correct-response' event.
|
|
75
|
+
* @private
|
|
76
|
+
* @listens TestNavigation#test-show-correct-response
|
|
77
|
+
* @param {CustomEvent} event - The custom event object.
|
|
78
|
+
*/
|
|
79
|
+
_handleTestShowCorrectResponse(event) {
|
|
80
|
+
const qtiItemEl = this._testElement.querySelector(
|
|
81
|
+
`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
|
|
82
|
+
);
|
|
83
|
+
const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
|
|
84
|
+
if (!qtiAssessmentItemEl) return;
|
|
85
|
+
qtiAssessmentItemEl.showCorrectResponse(event.detail);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Handles the 'test-show-candidate-correction' event.
|
|
89
|
+
* @private
|
|
90
|
+
* @listens TestNavigation#test-show-candidate-correction
|
|
91
|
+
* @param {CustomEvent} event - The custom event object.
|
|
92
|
+
*/
|
|
93
|
+
_handleTestShowCandidateCorrection(event) {
|
|
94
|
+
const qtiItemEl = this._testElement.querySelector(
|
|
95
|
+
`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
|
|
96
|
+
);
|
|
97
|
+
const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
|
|
98
|
+
qtiAssessmentItemEl.showCandidateCorrection(event.detail);
|
|
99
|
+
}
|
|
100
|
+
_handleTestUpdateOutcomeVariable(event) {
|
|
101
|
+
const qtiItemEl = this._testElement.querySelector(
|
|
102
|
+
`qti-assessment-item-ref[identifier="${event.detail.assessmentItemRefId}"]`
|
|
103
|
+
);
|
|
104
|
+
const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
|
|
105
|
+
qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
|
|
106
|
+
}
|
|
107
|
+
_handleInteractionChanged(_event) {
|
|
108
|
+
if (this.autoScoreItems) {
|
|
109
|
+
const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
|
|
110
|
+
const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
|
|
111
|
+
if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
|
|
112
|
+
const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
|
|
113
|
+
assessmentItem.processResponse(true, reportValidityAfterScoring);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
return html`<slot></slot>`;
|
|
119
|
+
}
|
|
120
|
+
/* PK: on test connected we can build the computed context */
|
|
121
|
+
_handleTestConnected(event) {
|
|
122
|
+
this._testElement = event.detail;
|
|
123
|
+
if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
|
|
124
|
+
const currentContext = this.qtiContext.QTI_CONTEXT || {
|
|
125
|
+
testIdentifier: "",
|
|
126
|
+
candidateIdentifier: "not set",
|
|
127
|
+
environmentIdentifier: "default"
|
|
128
|
+
};
|
|
129
|
+
this.qtiContext = {
|
|
130
|
+
QTI_CONTEXT: {
|
|
131
|
+
...currentContext,
|
|
132
|
+
testIdentifier: this._testElement.identifier,
|
|
133
|
+
environmentIdentifier: currentContext.environmentIdentifier || "default"
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const contextDeclarations = this._testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
|
|
138
|
+
contextDeclarations.forEach((declaration) => {
|
|
139
|
+
const defaultValues = this._extractDefaultValues(declaration);
|
|
140
|
+
if (Object.keys(defaultValues).length > 0) {
|
|
141
|
+
this.qtiContext = {
|
|
142
|
+
QTI_CONTEXT: {
|
|
143
|
+
...defaultValues,
|
|
144
|
+
// Default values first
|
|
145
|
+
...this.qtiContext.QTI_CONTEXT
|
|
146
|
+
// Runtime values override defaults
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
const testPartElements = Array.from(this._testElement?.querySelectorAll(`qti-test-part`) || []);
|
|
152
|
+
this.computedContext = {
|
|
153
|
+
identifier: this._testElement.identifier,
|
|
154
|
+
title: this._testElement.title,
|
|
155
|
+
view: this._sessionContext?.view,
|
|
156
|
+
testParts: testPartElements.map((testPart) => {
|
|
157
|
+
const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
|
|
158
|
+
return {
|
|
159
|
+
active: false,
|
|
160
|
+
identifier: testPart.identifier,
|
|
161
|
+
navigationMode: testPart.navigationMode,
|
|
162
|
+
submissionMode: testPart.submissionMode,
|
|
163
|
+
sections: sectionElements.map((section) => {
|
|
164
|
+
const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
|
|
165
|
+
return {
|
|
166
|
+
active: false,
|
|
167
|
+
identifier: section.identifier,
|
|
168
|
+
title: section.title,
|
|
169
|
+
items: itemElements.map((item) => ({
|
|
170
|
+
...this.initContext?.find((i) => i.identifier === item.identifier),
|
|
171
|
+
active: false,
|
|
172
|
+
identifier: item.identifier,
|
|
173
|
+
categories: item.category ? item.category?.split(" ") : [],
|
|
174
|
+
href: item.href,
|
|
175
|
+
variables: []
|
|
176
|
+
}))
|
|
177
|
+
};
|
|
178
|
+
})
|
|
179
|
+
};
|
|
180
|
+
})
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Extract default values from a qti-context-declaration element
|
|
185
|
+
*/
|
|
186
|
+
_extractDefaultValues(declaration) {
|
|
187
|
+
const defaultValues = {};
|
|
188
|
+
const defaultValueElement = declaration.querySelector("qti-default-value");
|
|
189
|
+
if (!defaultValueElement) {
|
|
190
|
+
return defaultValues;
|
|
191
|
+
}
|
|
192
|
+
const valueElements = defaultValueElement.querySelectorAll("qti-value[field-identifier]");
|
|
193
|
+
valueElements.forEach((valueElement) => {
|
|
194
|
+
const fieldIdentifier = valueElement.getAttribute("field-identifier");
|
|
195
|
+
const baseType = valueElement.getAttribute("base-type") || "string";
|
|
196
|
+
const textContent = valueElement.textContent?.trim() || "";
|
|
197
|
+
if (fieldIdentifier) {
|
|
198
|
+
let value = textContent;
|
|
199
|
+
switch (baseType) {
|
|
200
|
+
case "integer":
|
|
201
|
+
value = parseInt(textContent, 10);
|
|
202
|
+
break;
|
|
203
|
+
case "float":
|
|
204
|
+
case "duration":
|
|
205
|
+
value = parseFloat(textContent);
|
|
206
|
+
break;
|
|
207
|
+
case "boolean":
|
|
208
|
+
value = textContent.toLowerCase() === "true";
|
|
209
|
+
break;
|
|
210
|
+
case "string":
|
|
211
|
+
default:
|
|
212
|
+
value = textContent;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
defaultValues[fieldIdentifier] = value;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return defaultValues;
|
|
219
|
+
}
|
|
220
|
+
/* PK: on item connected we can add item only properties in the xml */
|
|
221
|
+
_handleItemConnected(event) {
|
|
222
|
+
const itemElement = event.detail;
|
|
223
|
+
this.computedContext = {
|
|
224
|
+
...this.computedContext,
|
|
225
|
+
testParts: this.computedContext.testParts.map((testPart) => {
|
|
226
|
+
return {
|
|
227
|
+
...testPart,
|
|
228
|
+
sections: testPart.sections.map((section) => {
|
|
229
|
+
return {
|
|
230
|
+
...section,
|
|
231
|
+
items: section.items.map((item) => {
|
|
232
|
+
if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
|
|
233
|
+
return item;
|
|
234
|
+
}
|
|
235
|
+
const scoreOutcome = itemElement.querySelector(
|
|
236
|
+
"qti-outcome-declaration[identifier='SCORE']"
|
|
237
|
+
);
|
|
238
|
+
const externalScored = scoreOutcome?.getAttribute("externalScored");
|
|
239
|
+
const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
|
|
240
|
+
const containsCorrectResponse = Array.from(responseDeclarations).some(
|
|
241
|
+
(r) => r.querySelector("qti-correct-response")
|
|
242
|
+
);
|
|
243
|
+
const containsMapping = Array.from(responseDeclarations).some((r) => {
|
|
244
|
+
const mapping = r.querySelector("qti-mapping");
|
|
245
|
+
const areaMapping = r.querySelector("qti-area-mapping");
|
|
246
|
+
return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
|
|
247
|
+
});
|
|
248
|
+
const hasCorrectResponse = containsCorrectResponse || containsMapping;
|
|
249
|
+
const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
|
|
250
|
+
return {
|
|
251
|
+
...item,
|
|
252
|
+
assessmentItemIdentifier: itemElement.getAttribute("identifier"),
|
|
253
|
+
label: itemElement.getAttribute("label"),
|
|
254
|
+
title: itemElement.title,
|
|
255
|
+
externalScored,
|
|
256
|
+
adaptive: itemElement.adaptive == "true" || false,
|
|
257
|
+
timeDependent: itemElement.timeDependent == "true" || false,
|
|
258
|
+
variables: itemElement.variables,
|
|
259
|
+
hasCorrectResponse,
|
|
260
|
+
hasResponseProcessing
|
|
261
|
+
};
|
|
262
|
+
})
|
|
263
|
+
};
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
})
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/* PK: on every change of the candidate we will recomputed the computedContext */
|
|
270
|
+
willUpdate(_changedProperties) {
|
|
271
|
+
if (!this.computedContext) return;
|
|
272
|
+
let itemIndex = 1;
|
|
273
|
+
this.computedContext = {
|
|
274
|
+
...this.computedContext,
|
|
275
|
+
view: this._sessionContext?.view,
|
|
276
|
+
testParts: this.computedContext.testParts.map((testPart) => {
|
|
277
|
+
return {
|
|
278
|
+
...testPart,
|
|
279
|
+
active: this._sessionContext?.navPartId === testPart.identifier || false,
|
|
280
|
+
sections: testPart.sections.map((section) => {
|
|
281
|
+
return {
|
|
282
|
+
...section,
|
|
283
|
+
active: this._sessionContext?.navSectionId === section.identifier || false,
|
|
284
|
+
completed: section.items.every(
|
|
285
|
+
(item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"
|
|
286
|
+
),
|
|
287
|
+
items: section.items.map((item) => {
|
|
288
|
+
const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
|
|
289
|
+
const computedItem = {
|
|
290
|
+
...item,
|
|
291
|
+
...itemContext,
|
|
292
|
+
...this.initContext?.find((i) => i.identifier === item.identifier)
|
|
293
|
+
};
|
|
294
|
+
const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
|
|
295
|
+
const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
|
|
296
|
+
const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
|
|
297
|
+
const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
|
|
298
|
+
const numAttempts = computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value || 0;
|
|
299
|
+
const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
|
|
300
|
+
const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
|
|
301
|
+
const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
|
|
302
|
+
const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
|
|
303
|
+
return {
|
|
304
|
+
...computedItem,
|
|
305
|
+
completionStatus,
|
|
306
|
+
numAttempts,
|
|
307
|
+
score,
|
|
308
|
+
response,
|
|
309
|
+
index,
|
|
310
|
+
// type,
|
|
311
|
+
active,
|
|
312
|
+
// correct,
|
|
313
|
+
maxScore
|
|
314
|
+
// incorrect,
|
|
315
|
+
// completed
|
|
316
|
+
};
|
|
317
|
+
})
|
|
318
|
+
};
|
|
319
|
+
})
|
|
320
|
+
};
|
|
321
|
+
})
|
|
322
|
+
};
|
|
323
|
+
this.dispatchEvent(
|
|
324
|
+
new CustomEvent("qti-computed-context-updated", {
|
|
325
|
+
detail: this.computedContext,
|
|
326
|
+
bubbles: true
|
|
327
|
+
})
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
__decorateClass([
|
|
332
|
+
property({ type: String })
|
|
333
|
+
], TestNavigation.prototype, "identifier", 2);
|
|
334
|
+
__decorateClass([
|
|
335
|
+
state()
|
|
336
|
+
], TestNavigation.prototype, "initContext", 2);
|
|
337
|
+
__decorateClass([
|
|
338
|
+
state(),
|
|
339
|
+
provide({ context: qtiContext })
|
|
340
|
+
], TestNavigation.prototype, "qtiContext", 2);
|
|
341
|
+
__decorateClass([
|
|
342
|
+
state(),
|
|
343
|
+
provide({ context: configContext })
|
|
344
|
+
], TestNavigation.prototype, "configContext", 2);
|
|
345
|
+
__decorateClass([
|
|
346
|
+
state(),
|
|
347
|
+
consume({ context: testContext, subscribe: true })
|
|
348
|
+
], TestNavigation.prototype, "_testContext", 2);
|
|
349
|
+
__decorateClass([
|
|
350
|
+
state(),
|
|
351
|
+
consume({ context: sessionContext, subscribe: true })
|
|
352
|
+
], TestNavigation.prototype, "_sessionContext", 2);
|
|
353
|
+
__decorateClass([
|
|
354
|
+
state(),
|
|
355
|
+
provide({ context: computedContext })
|
|
356
|
+
], TestNavigation.prototype, "computedContext", 2);
|
|
357
|
+
__decorateClass([
|
|
358
|
+
property({ type: Boolean, attribute: "auto-score-items" })
|
|
359
|
+
], TestNavigation.prototype, "autoScoreItems", 2);
|
|
360
|
+
TestNavigation = __decorateClass([
|
|
361
|
+
customElement("test-navigation")
|
|
362
|
+
], TestNavigation);
|
|
363
|
+
|
|
364
|
+
export {
|
|
365
|
+
TestNavigation
|
|
366
|
+
};
|
|
367
|
+
//# sourceMappingURL=chunk-QU7KR7VX.js.map
|