@citolab/qti-components 7.2.1 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/chunks/chunk-2EE5IVNF.js +1 -0
- package/cdn/chunks/chunk-2S62LLS5.js +2 -0
- package/cdn/chunks/chunk-33KVDPBT.js +5 -0
- package/cdn/chunks/chunk-4TNE5ZQS.js +5 -0
- package/cdn/chunks/chunk-57ZBXU3V.js +5 -0
- package/cdn/chunks/chunk-5RGC3O3Z.js +3 -0
- package/cdn/chunks/chunk-5WJBI6M7.js +1033 -0
- package/cdn/chunks/chunk-66BMMESW.js +2 -0
- package/cdn/chunks/chunk-6D53FU3U.js +2 -0
- package/cdn/chunks/chunk-72GJGEI2.js +2 -0
- package/cdn/chunks/chunk-73GTDWYG.js +2 -0
- package/cdn/chunks/chunk-7G2JKRYL.js +3 -0
- package/cdn/chunks/chunk-7HDBTHS7.js +2 -0
- package/cdn/chunks/chunk-7U6V7TMQ.js +1 -0
- package/cdn/chunks/chunk-BH7YS4N7.js +5 -0
- package/cdn/chunks/chunk-DAKW2UJX.js +3 -0
- package/cdn/chunks/chunk-DPW6VAG2.js +3441 -0
- package/cdn/chunks/chunk-DQCUGHMI.js +2 -0
- package/cdn/chunks/chunk-DTD5NE7V.js +2 -0
- package/cdn/chunks/chunk-EJE3C3VD.js +5 -0
- package/cdn/chunks/chunk-FGT2KVW2.js +1 -0
- package/cdn/chunks/chunk-FXG6JQNB.js +3 -0
- package/cdn/chunks/chunk-G3O7FTGW.js +2 -0
- package/cdn/chunks/chunk-GSDSRYPT.js +5 -0
- package/cdn/chunks/chunk-GW7MTJY4.js +2 -0
- package/cdn/chunks/chunk-HNZFDARC.js +2 -0
- package/cdn/chunks/chunk-I37HIF37.js +2 -0
- package/cdn/chunks/chunk-IFSRAUBH.js +1 -0
- package/cdn/chunks/chunk-IJ47QETV.js +2 -0
- package/cdn/chunks/chunk-JVY3MIVH.js +5 -0
- package/cdn/chunks/chunk-JXGYDOJM.js +3 -0
- package/cdn/chunks/chunk-K3HDRUZ2.js +2 -0
- package/cdn/chunks/chunk-KGNJ44AT.js +2 -0
- package/cdn/chunks/chunk-KM6BQLUW.js +2 -0
- package/cdn/chunks/chunk-KMPDXXNC.js +5 -0
- package/cdn/chunks/chunk-KPFC2HQR.js +3 -0
- package/cdn/chunks/chunk-KZQ2VXMQ.js +2 -0
- package/cdn/chunks/chunk-LEC3TBJ3.js +2 -0
- package/cdn/chunks/chunk-ME2BEQTK.js +3463 -0
- package/cdn/chunks/chunk-MM3TTGOD.js +5 -0
- package/cdn/chunks/chunk-NBXY7TMD.js +2 -0
- package/cdn/chunks/chunk-NCNOPEEF.js +2 -0
- package/cdn/chunks/chunk-O7JELRBY.js +2 -0
- package/cdn/chunks/chunk-OCQAZUB6.js +2 -0
- package/cdn/chunks/chunk-QBBWQ5J6.js +5 -0
- package/cdn/chunks/chunk-QPP7ZB2K.js +5 -0
- package/cdn/chunks/chunk-RSOX5VS5.js +3 -0
- package/cdn/chunks/chunk-SHXTMXYU.js +1 -0
- package/cdn/chunks/chunk-SNRRONMC.js +2 -0
- package/cdn/chunks/chunk-SUDAVHNM.js +1 -0
- package/cdn/chunks/chunk-UUKFU4BI.js +2 -0
- package/cdn/chunks/chunk-V65TZQVT.js +2 -0
- package/cdn/chunks/chunk-VIW7IGYG.js +2 -0
- package/cdn/chunks/chunk-W7LBE76A.js +5 -0
- package/cdn/chunks/chunk-WANQ7VHH.js +2 -0
- package/cdn/chunks/chunk-WI3S4WLU.js +2 -0
- package/cdn/chunks/chunk-WQK3JD6Q.js +5 -0
- package/cdn/chunks/chunk-WRAMSS3Q.js +3465 -0
- package/cdn/chunks/chunk-XLY6GBBJ.js +2 -0
- package/cdn/chunks/chunk-XNII2G63.js +3468 -0
- package/cdn/chunks/chunk-YSCJG7CX.js +3461 -0
- package/cdn/index.js +1 -1
- package/cdn/qti-item/components/item-container.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/test-container.js +1 -1
- package/cdn/qti-test/components/test-navigation.js +1 -1
- package/cdn/qti-test/components/test-print-context.js +1 -1
- package/cdn/qti-test/components/test-stamp.js +1 -1
- package/cdn/qti-test/core/index.js +1 -1
- package/dist/chunks/chunk-25AXOL6N.js +73 -0
- package/dist/chunks/chunk-25AXOL6N.js.map +1 -0
- package/dist/chunks/chunk-34ZMZ5GH.js +76 -0
- package/dist/chunks/chunk-34ZMZ5GH.js.map +1 -0
- package/dist/chunks/chunk-3UPSFFDF.js +45 -0
- package/dist/chunks/chunk-3UPSFFDF.js.map +1 -0
- package/dist/chunks/chunk-4NZYGJLT.js +94 -0
- package/dist/chunks/chunk-4NZYGJLT.js.map +1 -0
- package/dist/chunks/chunk-4UIDYSZL.js +78 -0
- package/dist/chunks/chunk-4UIDYSZL.js.map +1 -0
- package/dist/chunks/chunk-4V7ZPUTP.js +78 -0
- package/dist/chunks/chunk-4V7ZPUTP.js.map +1 -0
- package/dist/chunks/chunk-5IQUODBV.js +94 -0
- package/dist/chunks/chunk-5IQUODBV.js.map +1 -0
- package/dist/chunks/chunk-6B7USFAR.js +82 -0
- package/dist/chunks/chunk-6B7USFAR.js.map +1 -0
- package/dist/chunks/chunk-6IC436D3.js +95 -0
- package/dist/chunks/chunk-6IC436D3.js.map +1 -0
- package/dist/chunks/chunk-6MXANZQB.js +80 -0
- package/dist/chunks/chunk-6MXANZQB.js.map +1 -0
- package/dist/chunks/chunk-6UZG2X74.js +870 -0
- package/dist/chunks/chunk-6UZG2X74.js.map +1 -0
- package/dist/chunks/chunk-6XLSPSL3.js +94 -0
- package/dist/chunks/chunk-6XLSPSL3.js.map +1 -0
- package/dist/chunks/chunk-AXVMZW54.js +73 -0
- package/dist/chunks/chunk-AXVMZW54.js.map +1 -0
- package/dist/chunks/chunk-B5Y4EZF6.js +80 -0
- package/dist/chunks/chunk-B5Y4EZF6.js.map +1 -0
- package/dist/chunks/chunk-B7NLQTW7.js +69 -0
- package/dist/chunks/chunk-B7NLQTW7.js.map +1 -0
- package/dist/chunks/chunk-BAEQ4MHU.js +69 -0
- package/dist/chunks/chunk-BAEQ4MHU.js.map +1 -0
- package/dist/chunks/chunk-C2KEHCRU.js +80 -0
- package/dist/chunks/chunk-C2KEHCRU.js.map +1 -0
- package/dist/chunks/chunk-CL6HNHNL.js +72 -0
- package/dist/chunks/chunk-CL6HNHNL.js.map +1 -0
- package/dist/chunks/chunk-DH2EP5PV.js +81 -0
- package/dist/chunks/chunk-DH2EP5PV.js.map +1 -0
- package/dist/chunks/chunk-DIETZXSR.js +78 -0
- package/dist/chunks/chunk-DIETZXSR.js.map +1 -0
- package/dist/chunks/chunk-DOP7DN3W.js +78 -0
- package/dist/chunks/chunk-DOP7DN3W.js.map +1 -0
- package/dist/chunks/chunk-DTZHLZH2.js +8 -0
- package/dist/chunks/chunk-DTZHLZH2.js.map +1 -0
- package/dist/chunks/chunk-EBKJVMIY.js +79 -0
- package/dist/chunks/chunk-EBKJVMIY.js.map +1 -0
- package/dist/chunks/chunk-ECXRMWLT.js +94 -0
- package/dist/chunks/chunk-ECXRMWLT.js.map +1 -0
- package/dist/chunks/chunk-FDIYM6TD.js +68 -0
- package/dist/chunks/chunk-FDIYM6TD.js.map +1 -0
- package/dist/chunks/chunk-FROMX3AY.js +78 -0
- package/dist/chunks/chunk-FROMX3AY.js.map +1 -0
- package/dist/chunks/chunk-FVD3INZH.js +69 -0
- package/dist/chunks/chunk-FVD3INZH.js.map +1 -0
- package/dist/chunks/chunk-GJVATV62.js +43 -0
- package/dist/chunks/chunk-GJVATV62.js.map +1 -0
- package/dist/chunks/chunk-GWSHKTCL.js +33 -0
- package/dist/chunks/chunk-GWSHKTCL.js.map +1 -0
- package/dist/chunks/chunk-H2Z5FH4R.js +76 -0
- package/dist/chunks/chunk-H2Z5FH4R.js.map +1 -0
- package/dist/chunks/chunk-HAP6ALTQ.js +78 -0
- package/dist/chunks/chunk-HAP6ALTQ.js.map +1 -0
- package/dist/chunks/chunk-HL7H4ZGY.js +82 -0
- package/dist/chunks/chunk-HL7H4ZGY.js.map +1 -0
- package/dist/chunks/chunk-HQ7IWQPH.js +80 -0
- package/dist/chunks/chunk-HQ7IWQPH.js.map +1 -0
- package/dist/chunks/chunk-IA235UXD.js +79 -0
- package/dist/chunks/chunk-IA235UXD.js.map +1 -0
- package/dist/chunks/chunk-IIDUZWYL.js +78 -0
- package/dist/chunks/chunk-IIDUZWYL.js.map +1 -0
- package/dist/chunks/chunk-IKVCQGA6.js +79 -0
- package/dist/chunks/chunk-IKVCQGA6.js.map +1 -0
- package/dist/chunks/chunk-IT6EGJUH.js +68 -0
- package/dist/chunks/chunk-IT6EGJUH.js.map +1 -0
- package/dist/chunks/chunk-IWSVL7HX.js +94 -0
- package/dist/chunks/chunk-IWSVL7HX.js.map +1 -0
- package/dist/chunks/chunk-K5SSEHCG.js +92 -0
- package/dist/chunks/chunk-K5SSEHCG.js.map +1 -0
- package/dist/chunks/chunk-KYGAKC4X.js +82 -0
- package/dist/chunks/chunk-KYGAKC4X.js.map +1 -0
- package/dist/chunks/chunk-LT563K5H.js +78 -0
- package/dist/chunks/chunk-LT563K5H.js.map +1 -0
- package/dist/chunks/chunk-LVWZUV4A.js +86 -0
- package/dist/chunks/chunk-LVWZUV4A.js.map +1 -0
- package/dist/chunks/chunk-MCMAHBGE.js +3455 -0
- package/dist/chunks/chunk-MCMAHBGE.js.map +1 -0
- package/dist/chunks/chunk-NFPHKFFE.js +78 -0
- package/dist/chunks/chunk-NFPHKFFE.js.map +1 -0
- package/dist/chunks/chunk-NLW7S5TN.js +94 -0
- package/dist/chunks/chunk-NLW7S5TN.js.map +1 -0
- package/dist/chunks/chunk-O2YP7VIE.js +245 -0
- package/dist/chunks/chunk-O2YP7VIE.js.map +1 -0
- package/dist/chunks/chunk-OAKKH2XA.js +99 -0
- package/dist/chunks/chunk-OAKKH2XA.js.map +1 -0
- package/dist/chunks/chunk-OBIKEFCI.js +56 -0
- package/dist/chunks/chunk-OBIKEFCI.js.map +1 -0
- package/dist/chunks/chunk-OEJMOV45.js +78 -0
- package/dist/chunks/chunk-OEJMOV45.js.map +1 -0
- package/dist/chunks/chunk-OFYYP7AK.js +94 -0
- package/dist/chunks/chunk-OFYYP7AK.js.map +1 -0
- package/dist/chunks/chunk-PJMWNLXZ.js +80 -0
- package/dist/chunks/chunk-PJMWNLXZ.js.map +1 -0
- package/dist/chunks/chunk-QGVSNUAF.js +79 -0
- package/dist/chunks/chunk-QGVSNUAF.js.map +1 -0
- package/dist/chunks/chunk-QIN2S2F7.js +94 -0
- package/dist/chunks/chunk-QIN2S2F7.js.map +1 -0
- package/dist/chunks/chunk-QKYFFNPR.js +3453 -0
- package/dist/chunks/chunk-QKYFFNPR.js.map +1 -0
- package/dist/chunks/chunk-QMIYPOBM.js +3458 -0
- package/dist/chunks/chunk-QMIYPOBM.js.map +1 -0
- package/dist/chunks/chunk-QMYMPOQQ.js +69 -0
- package/dist/chunks/chunk-QMYMPOQQ.js.map +1 -0
- package/dist/chunks/chunk-RGQDJQVE.js +3451 -0
- package/dist/chunks/chunk-RGQDJQVE.js.map +1 -0
- package/dist/chunks/chunk-SWROECSL.js +82 -0
- package/dist/chunks/chunk-SWROECSL.js.map +1 -0
- package/dist/chunks/chunk-TGF5F45T.js +94 -0
- package/dist/chunks/chunk-TGF5F45T.js.map +1 -0
- package/dist/chunks/chunk-TUVS6HU4.js +85 -0
- package/dist/chunks/chunk-TUVS6HU4.js.map +1 -0
- package/dist/chunks/chunk-UHU4AWX2.js +28 -0
- package/dist/chunks/chunk-UHU4AWX2.js.map +1 -0
- package/dist/chunks/chunk-V53ESOPP.js +79 -0
- package/dist/chunks/chunk-V53ESOPP.js.map +1 -0
- package/dist/chunks/chunk-VGGCSCVL.js +94 -0
- package/dist/chunks/chunk-VGGCSCVL.js.map +1 -0
- package/dist/chunks/chunk-WTN76Y5P.js +74 -0
- package/dist/chunks/chunk-WTN76Y5P.js.map +1 -0
- package/dist/chunks/chunk-WVMOFVRE.js +74 -0
- package/dist/chunks/chunk-WVMOFVRE.js.map +1 -0
- package/dist/chunks/chunk-WXQLAXP4.js +73 -0
- package/dist/chunks/chunk-WXQLAXP4.js.map +1 -0
- package/dist/chunks/chunk-X2ZV2OFN.js +82 -0
- package/dist/chunks/chunk-X2ZV2OFN.js.map +1 -0
- package/dist/chunks/chunk-XAJNR7FS.js +74 -0
- package/dist/chunks/chunk-XAJNR7FS.js.map +1 -0
- package/dist/chunks/chunk-YBDDKT65.js +69 -0
- package/dist/chunks/chunk-YBDDKT65.js.map +1 -0
- package/dist/chunks/chunk-YKKQ6AI7.js +69 -0
- package/dist/chunks/chunk-YKKQ6AI7.js.map +1 -0
- package/dist/chunks/chunk-YLHGELZY.js +79 -0
- package/dist/chunks/chunk-YLHGELZY.js.map +1 -0
- package/dist/chunks/chunk-YQC26WHY.js +79 -0
- package/dist/chunks/chunk-YQC26WHY.js.map +1 -0
- package/dist/chunks/chunk-ZBUXIAEV.js +3431 -0
- package/dist/chunks/chunk-ZBUXIAEV.js.map +1 -0
- package/dist/chunks/chunk-ZU6ANMBF.js +28 -0
- package/dist/chunks/chunk-ZU6ANMBF.js.map +1 -0
- package/dist/exports/computed.context.d.ts +4 -0
- package/dist/exports/computed.context.js +1 -1
- package/dist/exports/session.context.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -28
- package/dist/item.css +6 -0
- package/dist/qti-components-jsx.d.ts +10 -7
- package/dist/qti-item/components/item-container.js +2 -2
- package/dist/qti-item/core/index.js +2 -2
- package/dist/qti-test/components/index.d.ts +1 -1
- package/dist/qti-test/components/index.js +19 -19
- package/dist/qti-test/components/test-container.js +2 -2
- package/dist/qti-test/components/test-navigation.d.ts +1 -1
- package/dist/qti-test/components/test-navigation.js +2 -2
- package/dist/qti-test/components/test-next.js +2 -2
- package/dist/qti-test/components/test-paging-buttons-stamp.js +2 -2
- package/dist/qti-test/components/test-prev.js +2 -2
- package/dist/qti-test/components/test-print-context.js +2 -2
- package/dist/qti-test/components/test-print-item-variables.js +2 -2
- package/dist/qti-test/components/test-scoring-buttons.js +2 -2
- package/dist/qti-test/components/test-scoring-feedback.js +2 -2
- package/dist/qti-test/components/test-section-buttons-stamp.js +2 -2
- package/dist/qti-test/components/test-show-correct-response.js +2 -2
- package/dist/qti-test/components/test-stamp.d.ts +8 -1
- package/dist/qti-test/components/test-stamp.js +2 -2
- package/dist/qti-test/core/index.d.ts +2 -2
- package/dist/qti-test/core/index.js +1 -1
- package/dist/qti-test-feedback-C4bd_5i4.d.ts +98 -0
- package/dist/vscode.html-custom-data.json +13 -7
- package/package.json +3 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computedContext
|
|
3
|
+
} from "./chunk-DTZHLZH2.js";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "./chunk-H2JE6IVU.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/qti-test/components/test-stamp.ts
|
|
9
|
+
import { html, LitElement, nothing } from "lit";
|
|
10
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
11
|
+
import { prepareTemplate } from "stampino";
|
|
12
|
+
import { consume } from "@lit/context";
|
|
13
|
+
var TestStamp = class extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.debug = false;
|
|
17
|
+
this.stampContext = null;
|
|
18
|
+
}
|
|
19
|
+
createRenderRoot() {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
const templateElement = this.querySelector("template");
|
|
25
|
+
if (!templateElement) {
|
|
26
|
+
this.myTemplate = null;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
30
|
+
}
|
|
31
|
+
willUpdate(_changedProperties) {
|
|
32
|
+
if (!this.computedContext) {
|
|
33
|
+
this.stampContext = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
37
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
38
|
+
const augmentedSection = delete activeSection.items;
|
|
39
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
40
|
+
const augmentedItem = delete activeItem.variables;
|
|
41
|
+
if (!activeTestPart || !activeItem) {
|
|
42
|
+
this.stampContext = null;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const augmentedTestPart = {
|
|
46
|
+
...activeTestPart,
|
|
47
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
48
|
+
};
|
|
49
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
50
|
+
this.stampContext = {
|
|
51
|
+
test: activeTest,
|
|
52
|
+
testpart: augmentedTestPart,
|
|
53
|
+
section: augmentedSection,
|
|
54
|
+
item: activeItem
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
return html` ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>
|
|
59
|
+
asd` : nothing}
|
|
60
|
+
${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
__decorateClass([
|
|
64
|
+
property({ type: Boolean, reflect: true })
|
|
65
|
+
], TestStamp.prototype, "debug", 2);
|
|
66
|
+
__decorateClass([
|
|
67
|
+
state(),
|
|
68
|
+
consume({ context: computedContext, subscribe: true })
|
|
69
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
70
|
+
__decorateClass([
|
|
71
|
+
state()
|
|
72
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
73
|
+
TestStamp = __decorateClass([
|
|
74
|
+
customElement("test-stamp")
|
|
75
|
+
], TestStamp);
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
TestStamp
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=chunk-C2KEHCRU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-stamp.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from 'stampino';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '../../exports/computed.context';\nimport type { TemplateFunction } from 'stampino';\n\n@customElement('test-stamp')\nexport class TestStamp extends LitElement {\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n test: unknown;\n testpart: unknown;\n section: unknown;\n item: unknown;\n } | null = null;\n\n myTemplate: TemplateFunction;\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n this.stampContext = null;\n return;\n }\n\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n\n const activeSection = this.computedContext.testParts\n .flatMap(testPart => testPart.sections)\n .find(section => section.active);\n const augmentedSection = delete activeSection.items;\n\n const activeItem = this.computedContext.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n const augmentedItem = delete activeItem.variables;\n\n if (!activeTestPart || !activeItem) {\n this.stampContext = null;\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items)\n };\n\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n test: activeTest,\n testpart: augmentedTestPart,\n section: augmentedSection,\n item: activeItem\n };\n }\n\n render() {\n return html` ${this.debug\n ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>\n asd`\n : nothing}\n ${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,uBAAuB;AAChC,SAAS,eAAe;AASjB,IAAM,YAAN,cAAwB,WAAW;AAAA,EAAnC;AAAA;AAEL,SAAO,QAAQ;AAOf,SAAQ,eAKG;AAAA;AAAA,EAID,mBAAmD;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,oBAA0B;AACxB,UAAM,kBAAkB;AACxB,UAAM,kBAAkB,KAAK,cAAmC,UAAU;AAC1E,QAAI,CAAC,iBAAiB;AACpB,WAAK,aAAa;AAClB;AAAA,IACF;AACA,SAAK,aAAa,gBAAgB,eAAe;AAAA,EACnD;AAAA,EAEU,WAAW,oBAA0C;AAC7D,QAAI,CAAC,KAAK,iBAAiB;AACzB,WAAK,eAAe;AACpB;AAAA,IACF;AAEA,UAAM,iBAAiB,KAAK,gBAAgB,UAAU,KAAK,cAAY,SAAS,MAAM;AAEtF,UAAM,gBAAgB,KAAK,gBAAgB,UACxC,QAAQ,cAAY,SAAS,QAAQ,EACrC,KAAK,aAAW,QAAQ,MAAM;AACjC,UAAM,mBAAmB,OAAO,cAAc;AAE9C,UAAM,aAAa,KAAK,gBAAgB,UACrC,QAAQ,cAAY,SAAS,SAAS,QAAQ,aAAW,QAAQ,KAAK,CAAC,EACvE,KAAK,UAAQ,KAAK,MAAM;AAC3B,UAAM,gBAAgB,OAAO,WAAW;AAExC,QAAI,CAAC,kBAAkB,CAAC,YAAY;AAClC,WAAK,eAAe;AACpB;AAAA,IACF;AAEA,UAAM,oBAAoB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO,eAAe,SAAS,QAAQ,aAAW,QAAQ,KAAK;AAAA,IACjE;AAEA,UAAM,EAAE,WAAW,GAAG,WAAW,IAAI,KAAK;AAE1C,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO,QAAQ,KAAK,QAChB,YAAY,KAAK,UAAU,KAAK,cAAc,MAAM,CAAC,CAAC;AAAA,iBAEtD,OAAO;AAAA,MACT,KAAK,gBAAgB,KAAK,aAAa,KAAK,WAAW,KAAK,YAAY,IAAI,OAAO;AAAA,EACvF;AACF;AA3ES;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAD/B,UAEJ;AAIC;AAAA,EAFP,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,iBAAiB,WAAW,KAAK,CAAC;AAAA,GAL3C,UAMH;AAGA;AAAA,EADP,MAAM;AAAA,GARI,UASH;AATG,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computedContext
|
|
3
|
+
} from "./chunk-DTZHLZH2.js";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "./chunk-H2JE6IVU.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/qti-test/components/test-stamp.ts
|
|
9
|
+
import { html, LitElement, nothing } from "lit";
|
|
10
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
11
|
+
import { prepareTemplate } from "stampino";
|
|
12
|
+
import { consume } from "@lit/context";
|
|
13
|
+
var TestStamp = class extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.debug = false;
|
|
17
|
+
this.stampContext = null;
|
|
18
|
+
}
|
|
19
|
+
createRenderRoot() {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
const templateElement = this.querySelector("template");
|
|
25
|
+
if (!templateElement) {
|
|
26
|
+
this.myTemplate = null;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
30
|
+
}
|
|
31
|
+
willUpdate(_changedProperties) {
|
|
32
|
+
if (!this.computedContext) {
|
|
33
|
+
this.stampContext = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
37
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
38
|
+
if (!activeTestPart || !activeItem) {
|
|
39
|
+
this.stampContext = null;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
43
|
+
this.stampContext = {
|
|
44
|
+
test: activeTest
|
|
45
|
+
// testpart: augmentedTestPart,
|
|
46
|
+
// section: augmentedSection,
|
|
47
|
+
// item: augmentedItem
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}
|
|
52
|
+
${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
__decorateClass([
|
|
56
|
+
property({ type: Boolean, reflect: true })
|
|
57
|
+
], TestStamp.prototype, "debug", 2);
|
|
58
|
+
__decorateClass([
|
|
59
|
+
state(),
|
|
60
|
+
consume({ context: computedContext, subscribe: true })
|
|
61
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
62
|
+
__decorateClass([
|
|
63
|
+
state()
|
|
64
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
65
|
+
TestStamp = __decorateClass([
|
|
66
|
+
customElement("test-stamp")
|
|
67
|
+
], TestStamp);
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
TestStamp
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=chunk-CL6HNHNL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-stamp.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from 'stampino';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '../../exports/computed.context';\nimport type { TemplateFunction } from 'stampino';\n\n@customElement('test-stamp')\nexport class TestStamp extends LitElement {\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n test?: unknown;\n testpart?: unknown;\n section?: unknown;\n item?: unknown;\n } | null = null;\n\n myTemplate: TemplateFunction;\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n this.stampContext = null;\n return;\n }\n\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n // const augmentedTestPart = {\n // ...activeTestPart,\n // items: activeTestPart.sections.flatMap(section => section.items)\n // };\n\n // const activeSection = this.computedContext.testParts\n // .flatMap(testPart => testPart.sections)\n // .find(section => section.active);\n // const { items, ...augmentedSection } = activeSection;\n\n const activeItem = this.computedContext.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n // const { variables, ...augmentedItem } = activeItem;\n\n if (!activeTestPart || !activeItem) {\n this.stampContext = null;\n return;\n }\n\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n test: activeTest\n // testpart: augmentedTestPart,\n // section: augmentedSection,\n // item: augmentedItem\n };\n }\n\n render() {\n return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}\n ${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,uBAAuB;AAChC,SAAS,eAAe;AASjB,IAAM,YAAN,cAAwB,WAAW;AAAA,EAAnC;AAAA;AAEL,SAAO,QAAQ;AAOf,SAAQ,eAKG;AAAA;AAAA,EAID,mBAAmD;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,oBAA0B;AACxB,UAAM,kBAAkB;AACxB,UAAM,kBAAkB,KAAK,cAAmC,UAAU;AAC1E,QAAI,CAAC,iBAAiB;AACpB,WAAK,aAAa;AAClB;AAAA,IACF;AACA,SAAK,aAAa,gBAAgB,eAAe;AAAA,EACnD;AAAA,EAEU,WAAW,oBAA0C;AAC7D,QAAI,CAAC,KAAK,iBAAiB;AACzB,WAAK,eAAe;AACpB;AAAA,IACF;AAEA,UAAM,iBAAiB,KAAK,gBAAgB,UAAU,KAAK,cAAY,SAAS,MAAM;AAWtF,UAAM,aAAa,KAAK,gBAAgB,UACrC,QAAQ,cAAY,SAAS,SAAS,QAAQ,aAAW,QAAQ,KAAK,CAAC,EACvE,KAAK,UAAQ,KAAK,MAAM;AAG3B,QAAI,CAAC,kBAAkB,CAAC,YAAY;AAClC,WAAK,eAAe;AACpB;AAAA,IACF;AAEA,UAAM,EAAE,WAAW,GAAG,WAAW,IAAI,KAAK;AAE1C,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA;AAAA;AAAA;AAAA,IAIR;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO,QAAQ,KAAK,QAAQ,mBAAmB,KAAK,UAAU,KAAK,cAAc,MAAM,CAAC,CAAC,mBAAmB,OAAO;AAAA,MACjH,KAAK,gBAAgB,KAAK,aAAa,KAAK,WAAW,KAAK,YAAY,IAAI,OAAO;AAAA,EACvF;AACF;AAvES;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAD/B,UAEJ;AAIC;AAAA,EAFP,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,iBAAiB,WAAW,KAAK,CAAC;AAAA,GAL3C,UAMH;AAGA;AAAA,EADP,MAAM;AAAA,GARI,UASH;AATG,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computedContext
|
|
3
|
+
} from "./chunk-DTZHLZH2.js";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "./chunk-H2JE6IVU.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/qti-test/components/test-scoring-buttons.ts
|
|
9
|
+
import { html, LitElement, nothing } from "lit";
|
|
10
|
+
import { consume } from "@lit/context";
|
|
11
|
+
import { customElement, property } from "lit/decorators.js";
|
|
12
|
+
var TestScoringButtons = class extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.view = "";
|
|
16
|
+
this.disabled = false;
|
|
17
|
+
}
|
|
18
|
+
createRenderRoot() {
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
_changeOutcomeScore(value) {
|
|
22
|
+
const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
|
|
23
|
+
const sectionItems = testPart.sections.flatMap((section) => section.items);
|
|
24
|
+
const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
|
|
25
|
+
this.dispatchEvent(
|
|
26
|
+
new CustomEvent("test-update-outcome-variable", {
|
|
27
|
+
detail: {
|
|
28
|
+
assessmentItemRefId: currentItemIdentifier,
|
|
29
|
+
outcomeVariableId: "SCORE",
|
|
30
|
+
value
|
|
31
|
+
},
|
|
32
|
+
bubbles: true
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
38
|
+
if (!activeItem || !activeItem.variables) return html``;
|
|
39
|
+
const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
|
|
40
|
+
const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
|
|
41
|
+
const score = scoreOutcome?.value;
|
|
42
|
+
this.disabled = !(scoreOutcome?.externalScored === "human");
|
|
43
|
+
return maxScore ? html`
|
|
44
|
+
<form part="form">
|
|
45
|
+
${[...Array(Number(maxScore) + 1).keys()].map((itemIndex) => {
|
|
46
|
+
const identifier = `scoring-buttons${itemIndex}${activeItem.identifier}`;
|
|
47
|
+
return html` <input
|
|
48
|
+
part="input"
|
|
49
|
+
type="radio"
|
|
50
|
+
?disabled=${this.disabled}
|
|
51
|
+
.checked=${itemIndex === Number(score)}
|
|
52
|
+
@change=${() => this._changeOutcomeScore(itemIndex)}
|
|
53
|
+
id=${identifier}
|
|
54
|
+
name=${`scoring-buttons-${activeItem.identifier}`}
|
|
55
|
+
value=${itemIndex}
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
<label part="label" for=${identifier}>${itemIndex}</label>`;
|
|
59
|
+
})}
|
|
60
|
+
</form>
|
|
61
|
+
<slot></slot>
|
|
62
|
+
` : nothing;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
__decorateClass([
|
|
66
|
+
property({ type: String, attribute: "view" })
|
|
67
|
+
], TestScoringButtons.prototype, "view", 2);
|
|
68
|
+
__decorateClass([
|
|
69
|
+
property({ type: Boolean })
|
|
70
|
+
], TestScoringButtons.prototype, "disabled", 2);
|
|
71
|
+
__decorateClass([
|
|
72
|
+
consume({ context: computedContext, subscribe: true })
|
|
73
|
+
], TestScoringButtons.prototype, "computedContext", 2);
|
|
74
|
+
TestScoringButtons = __decorateClass([
|
|
75
|
+
customElement("test-scoring-buttons")
|
|
76
|
+
], TestScoringButtons);
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
TestScoringButtons
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=chunk-DH2EP5PV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-scoring-buttons.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { consume } from '@lit/context';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { OutcomeVariable } from '../../exports/variables';\nimport type { ComputedContext } from '../../exports/computed.context';\n\n@customElement('test-scoring-buttons')\nexport class TestScoringButtons extends LitElement {\n @property({ type: String, attribute: 'view' }) view = ''; // is only an attribute, but this is here because.. react\n @property({ type: Boolean }) disabled: boolean = false;\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n private _changeOutcomeScore(value: number) {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const currentItemIdentifier = sectionItems.find(item => item.active)?.identifier;\n\n this.dispatchEvent(\n new CustomEvent('test-update-outcome-variable', {\n detail: {\n assessmentItemRefId: currentItemIdentifier,\n outcomeVariableId: 'SCORE',\n value\n },\n bubbles: true\n })\n );\n }\n\n render() {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const maxScore = activeItem.variables.find(vr => vr.identifier == 'MAXSCORE')?.value;\n const scoreOutcome = activeItem.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n\n const score = scoreOutcome?.value;\n\n this.disabled = !(scoreOutcome?.externalScored === 'human');\n\n return maxScore\n ? html`\n <form part=\"form\">\n ${[...Array(Number(maxScore) + 1).keys()].map(itemIndex => {\n const identifier = `scoring-buttons${itemIndex}${activeItem.identifier}`;\n return html` <input\n part=\"input\"\n type=\"radio\"\n ?disabled=${this.disabled}\n .checked=${itemIndex === Number(score)}\n @change=${() => this._changeOutcomeScore(itemIndex)}\n id=${identifier}\n name=${`scoring-buttons-${activeItem.identifier}`}\n value=${itemIndex}\n />\n\n <label part=\"label\" for=${identifier}>${itemIndex}</label>`;\n })}\n </form>\n <slot></slot>\n `\n : nothing;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-scoring-buttons': TestScoringButtons;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,eAAe;AACxB,SAAS,eAAe,gBAAgB;AAQjC,IAAM,qBAAN,cAAiC,WAAW;AAAA,EAA5C;AAAA;AAC0C,gBAAO;AACzB,oBAAoB;AAAA;AAAA,EAEvC,mBAAmD;AAC3D,WAAO;AAAA,EACT;AAAA,EAKQ,oBAAoB,OAAe;AACzC,UAAM,WAAW,KAAK,iBAAiB,UAAU,KAAK,CAAAA,cAAYA,UAAS,MAAM;AACjF,UAAM,eAAe,SAAS,SAAS,QAAQ,aAAW,QAAQ,KAAK;AACvE,UAAM,wBAAwB,aAAa,KAAK,UAAQ,KAAK,MAAM,GAAG;AAEtE,SAAK;AAAA,MACH,IAAI,YAAY,gCAAgC;AAAA,QAC9C,QAAQ;AAAA,UACN,qBAAqB;AAAA,UACrB,mBAAmB;AAAA,UACnB;AAAA,QACF;AAAA,QACA,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,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+
computedContext
|
|
3
|
+
} from "./chunk-DTZHLZH2.js";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "./chunk-H2JE6IVU.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/qti-test/components/test-stamp.ts
|
|
9
|
+
import { html, LitElement, nothing } from "lit";
|
|
10
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
11
|
+
import { prepareTemplate } from "stampino";
|
|
12
|
+
import { consume } from "@lit/context";
|
|
13
|
+
var TestStamp = class extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.debug = false;
|
|
17
|
+
this.stampContext = null;
|
|
18
|
+
}
|
|
19
|
+
createRenderRoot() {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
const templateElement = this.querySelector("template");
|
|
25
|
+
if (!templateElement) {
|
|
26
|
+
this.myTemplate = null;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
30
|
+
}
|
|
31
|
+
willUpdate(_changedProperties) {
|
|
32
|
+
if (!this.computedContext) {
|
|
33
|
+
this.stampContext = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
37
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
38
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
39
|
+
if (!activeTestPart || !activeItem) {
|
|
40
|
+
this.stampContext = null;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const augmentedTestPart = {
|
|
44
|
+
...activeTestPart,
|
|
45
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
46
|
+
};
|
|
47
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
48
|
+
this.stampContext = {
|
|
49
|
+
test: activeTest,
|
|
50
|
+
testpart: augmentedTestPart,
|
|
51
|
+
section: activeSection,
|
|
52
|
+
item: activeItem
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
if (!this.stampContext || !this.myTemplate) return nothing;
|
|
57
|
+
return html` ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>` : nothing}
|
|
58
|
+
${this.myTemplate(this.stampContext)}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
__decorateClass([
|
|
62
|
+
property({ type: Boolean, reflect: true })
|
|
63
|
+
], TestStamp.prototype, "debug", 2);
|
|
64
|
+
__decorateClass([
|
|
65
|
+
state(),
|
|
66
|
+
consume({ context: computedContext, subscribe: true })
|
|
67
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
68
|
+
__decorateClass([
|
|
69
|
+
state()
|
|
70
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
71
|
+
TestStamp = __decorateClass([
|
|
72
|
+
customElement("test-stamp")
|
|
73
|
+
], TestStamp);
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
TestStamp
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=chunk-DIETZXSR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-stamp.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from 'stampino';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '../../exports/computed.context';\nimport type { TemplateFunction } from 'stampino';\n\n@customElement('test-stamp')\nexport class TestStamp extends LitElement {\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n test: unknown;\n testpart: unknown;\n section: unknown;\n item: unknown;\n } | null = null;\n\n myTemplate: TemplateFunction;\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n this.stampContext = null;\n return;\n }\n\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = this.computedContext.testParts\n .flatMap(testPart => testPart.sections)\n .find(section => section.active);\n const activeItem = this.computedContext.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeTestPart || !activeItem) {\n this.stampContext = null;\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items)\n };\n\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n test: activeTest,\n testpart: augmentedTestPart,\n section: activeSection,\n item: activeItem\n };\n }\n\n render() {\n if (!this.stampContext || !this.myTemplate) return nothing;\n return html` ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>` : nothing}\n ${this.myTemplate(this.stampContext)}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,uBAAuB;AAChC,SAAS,eAAe;AASjB,IAAM,YAAN,cAAwB,WAAW;AAAA,EAAnC;AAAA;AAEL,SAAO,QAAQ;AAOf,SAAQ,eAKG;AAAA;AAAA,EAID,mBAAmD;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,oBAA0B;AACxB,UAAM,kBAAkB;AACxB,UAAM,kBAAkB,KA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AAA,GAL3C,UAMH;AAGA;AAAA,EADP,MAAM;AAAA,GARI,UASH;AATG,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computedContext
|
|
3
|
+
} from "./chunk-DTZHLZH2.js";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "./chunk-H2JE6IVU.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/qti-test/components/test-stamp.ts
|
|
9
|
+
import { html, LitElement, nothing } from "lit";
|
|
10
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
11
|
+
import { prepareTemplate } from "stampino";
|
|
12
|
+
import { consume } from "@lit/context";
|
|
13
|
+
var TestStamp = class extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.debug = false;
|
|
17
|
+
this.stampContext = null;
|
|
18
|
+
}
|
|
19
|
+
createRenderRoot() {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
const templateElement = this.querySelector("template");
|
|
25
|
+
if (!templateElement) {
|
|
26
|
+
this.myTemplate = null;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
30
|
+
}
|
|
31
|
+
willUpdate(_changedProperties) {
|
|
32
|
+
if (!this.computedContext) {
|
|
33
|
+
this.stampContext = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
37
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
38
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
39
|
+
if (!activeTestPart || !activeItem) {
|
|
40
|
+
this.stampContext = null;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const augmentedTestPart = {
|
|
44
|
+
...activeTestPart,
|
|
45
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
46
|
+
};
|
|
47
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
48
|
+
this.stampContext = {
|
|
49
|
+
test: activeTest,
|
|
50
|
+
testpart: augmentedTestPart,
|
|
51
|
+
section: activeSection,
|
|
52
|
+
item: activeItem
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
return html` ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>
|
|
57
|
+
asd` : nothing}
|
|
58
|
+
${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
__decorateClass([
|
|
62
|
+
property({ type: Boolean, reflect: true })
|
|
63
|
+
], TestStamp.prototype, "debug", 2);
|
|
64
|
+
__decorateClass([
|
|
65
|
+
state(),
|
|
66
|
+
consume({ context: computedContext, subscribe: true })
|
|
67
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
68
|
+
__decorateClass([
|
|
69
|
+
state()
|
|
70
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
71
|
+
TestStamp = __decorateClass([
|
|
72
|
+
customElement("test-stamp")
|
|
73
|
+
], TestStamp);
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
TestStamp
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=chunk-DOP7DN3W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-stamp.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from 'stampino';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '../../exports/computed.context';\nimport type { TemplateFunction } from 'stampino';\n\n@customElement('test-stamp')\nexport class TestStamp extends LitElement {\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n test: unknown;\n testpart: unknown;\n section: unknown;\n item: unknown;\n } | null = null;\n\n myTemplate: TemplateFunction;\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n this.stampContext = null;\n return;\n }\n\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = this.computedContext.testParts\n .flatMap(testPart => testPart.sections)\n .find(section => section.active);\n const activeItem = this.computedContext.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeTestPart || !activeItem) {\n this.stampContext = null;\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items)\n };\n\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n test: activeTest,\n testpart: augmentedTestPart,\n section: activeSection,\n item: activeItem\n };\n }\n\n render() {\n return html` ${this.debug\n ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>\n asd`\n : nothing}\n ${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,uBAAuB;AAChC,SAAS,eAAe;AASjB,IAAM,YAAN,cAAwB,WAAW;AAAA,EA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,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAD/B,UAEJ;AAIC;AAAA,EAFP,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,iBAAiB,WAAW,KAAK,CAAC;AAAA,GAL3C,UAMH;AAGA;AAAA,EADP,MAAM;AAAA,GARI,UASH;AATG,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/exports/computed.context.ts"],"sourcesContent":["import { createContext } from '@lit/context';\n\nimport type { ComputedItemContext } from './computed-item.context';\n\nexport type ComputedItem = ComputedItemContext & {\n // rawscore?: Readonly<string | string[]>; // not necessary for outside world\n // score?: number; // not necessary for outside world\n // completionStatus?: Readonly<string | string[]>; // not necessary for outside world\n // categories?: string[]; // not necessary for outside world\n type?: 'info' | 'regular';\n index?: number;\n active?: boolean;\n};\n\nexport type ComputedContext = {\n // testElement?: HTMLElement;\n identifier: string;\n title: string;\n testParts: {\n active?: boolean;\n identifier: string;\n navigationMode: 'linear' | 'nonlinear';\n submissionMode: 'individual' | 'simultaneous';\n sections: {\n active?: boolean;\n identifier: string;\n title: string;\n completed?: boolean;\n items: ComputedItem[];\n }[];\n }[];\n};\n\nexport const computedContext = createContext<Readonly<ComputedContext>>(Symbol('computedContext'));\n"],"mappings":";AAAA,SAAS,qBAAqB;AAiCvB,IAAM,kBAAkB,cAAyC,OAAO,iBAAiB,CAAC;","names":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computedContext
|
|
3
|
+
} from "./chunk-DTZHLZH2.js";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "./chunk-H2JE6IVU.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/qti-test/components/test-stamp.ts
|
|
9
|
+
import { html, LitElement, nothing } from "lit";
|
|
10
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
11
|
+
import { prepareTemplate } from "stampino";
|
|
12
|
+
import { consume } from "@lit/context";
|
|
13
|
+
var TestStamp = class extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.debug = false;
|
|
17
|
+
this.stampContext = null;
|
|
18
|
+
}
|
|
19
|
+
createRenderRoot() {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
const templateElement = this.querySelector("template");
|
|
25
|
+
if (!templateElement) {
|
|
26
|
+
this.myTemplate = null;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
30
|
+
}
|
|
31
|
+
willUpdate(_changedProperties) {
|
|
32
|
+
if (!this.computedContext) {
|
|
33
|
+
this.stampContext = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
37
|
+
const augmentedTestPart = {
|
|
38
|
+
...activeTestPart,
|
|
39
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
40
|
+
};
|
|
41
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
42
|
+
const { items, ...augmentedSection } = activeSection;
|
|
43
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
44
|
+
const { variables, ...augmentedItem } = activeItem;
|
|
45
|
+
if (!activeTestPart || !activeItem) {
|
|
46
|
+
this.stampContext = null;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
50
|
+
this.stampContext = {
|
|
51
|
+
test: activeTest,
|
|
52
|
+
testpart: augmentedTestPart,
|
|
53
|
+
section: augmentedSection,
|
|
54
|
+
item: augmentedItem
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small> asd` : nothing}
|
|
59
|
+
${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
__decorateClass([
|
|
63
|
+
property({ type: Boolean, reflect: true })
|
|
64
|
+
], TestStamp.prototype, "debug", 2);
|
|
65
|
+
__decorateClass([
|
|
66
|
+
state(),
|
|
67
|
+
consume({ context: computedContext, subscribe: true })
|
|
68
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
69
|
+
__decorateClass([
|
|
70
|
+
state()
|
|
71
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
72
|
+
TestStamp = __decorateClass([
|
|
73
|
+
customElement("test-stamp")
|
|
74
|
+
], TestStamp);
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
TestStamp
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=chunk-EBKJVMIY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-stamp.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from 'stampino';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '../../exports/computed.context';\nimport type { TemplateFunction } from 'stampino';\n\n@customElement('test-stamp')\nexport class TestStamp extends LitElement {\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n test: unknown;\n testpart: unknown;\n section: unknown;\n item: unknown;\n } | null = null;\n\n myTemplate: TemplateFunction;\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n this.stampContext = null;\n return;\n }\n\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items)\n };\n\n const activeSection = this.computedContext.testParts\n .flatMap(testPart => testPart.sections)\n .find(section => section.active);\n const { items, ...augmentedSection } = activeSection;\n\n const activeItem = this.computedContext.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n const { variables, ...augmentedItem } = activeItem;\n\n if (!activeTestPart || !activeItem) {\n this.stampContext = null;\n return;\n }\n\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n test: activeTest,\n testpart: augmentedTestPart,\n section: augmentedSection,\n item: augmentedItem\n };\n }\n\n render() {\n return html` ${this.debug\n ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small> asd`\n : nothing}\n ${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,uBAAuB;AAChC,SAAS,eAAe;AASjB,IAAM,YAAN,cAAwB,WAAW;AAAA,EAAnC;AAAA;AAEL,SAAO,QAAQ;AAOf,SAAQ,eAKG;AAAA;AAAA,EAID,mBAAmD;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,oBAA0B;AACxB,UAAM,kBAAkB;AACxB,UAAM,kBAAkB,KAAK,cAAmC,UAAU;AAC1E,QAAI,CAAC,iBAAiB;AACpB,WAAK,aAAa;AAClB;AAAA,IACF;AACA,SAAK,aAAa,gBAAgB,eAAe;AAAA,EACnD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H;AATG,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
item_default
|
|
3
|
+
} from "./chunk-ZBUXIAEV.js";
|
|
4
|
+
import {
|
|
5
|
+
watch
|
|
6
|
+
} from "./chunk-ELDMXTUQ.js";
|
|
7
|
+
import {
|
|
8
|
+
qtiTransformItem
|
|
9
|
+
} from "./chunk-VEWD22O5.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-ECXRMWLT.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,WAA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