@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 @@
|
|
|
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;AACtF,UAAM,oBAAoB;AAAA,MACxB,GAAG;AAAA,MACH,O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TUQ.js";
|
|
7
|
+
import {
|
|
8
|
+
qtiTransformTest
|
|
9
|
+
} from "./chunk-VEWD22O5.js";
|
|
10
|
+
import {
|
|
11
|
+
__decorateClass
|
|
12
|
+
} from "./chunk-H2JE6IVU.js";
|
|
13
|
+
|
|
14
|
+
// src/lib/qti-test/components/test-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 TestContainer = class extends LitElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.testURL = null;
|
|
22
|
+
this.testDoc = null;
|
|
23
|
+
this.testXML = null;
|
|
24
|
+
/** Template content if provided */
|
|
25
|
+
this.templateContent = null;
|
|
26
|
+
}
|
|
27
|
+
async handleTestURLChange() {
|
|
28
|
+
if (!this.testURL) return;
|
|
29
|
+
try {
|
|
30
|
+
const api = await qtiTransformTest().load(this.testURL);
|
|
31
|
+
this.testDoc = api.htmlDoc();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("Error loading or parsing XML:", error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
handleTestXMLChange() {
|
|
37
|
+
if (!this.testXML) return;
|
|
38
|
+
try {
|
|
39
|
+
this.testDoc = qtiTransformTest().parse(this.testXML).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.testURL) {
|
|
49
|
+
this.handleTestURLChange();
|
|
50
|
+
}
|
|
51
|
+
if (this.testXML) {
|
|
52
|
+
this.handleTestXMLChange();
|
|
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.testDoc, html`<span>Loading...</span>`)}
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
__decorateClass([
|
|
73
|
+
property({ type: String, attribute: "test-url" })
|
|
74
|
+
], TestContainer.prototype, "testURL", 2);
|
|
75
|
+
__decorateClass([
|
|
76
|
+
state()
|
|
77
|
+
], TestContainer.prototype, "testDoc", 2);
|
|
78
|
+
__decorateClass([
|
|
79
|
+
state()
|
|
80
|
+
], TestContainer.prototype, "testXML", 2);
|
|
81
|
+
__decorateClass([
|
|
82
|
+
watch("testURL", { waitUntilFirstUpdate: true })
|
|
83
|
+
], TestContainer.prototype, "handleTestURLChange", 1);
|
|
84
|
+
__decorateClass([
|
|
85
|
+
watch("testXML", { waitUntilFirstUpdate: true })
|
|
86
|
+
], TestContainer.prototype, "handleTestXMLChange", 1);
|
|
87
|
+
TestContainer = __decorateClass([
|
|
88
|
+
customElement("test-container")
|
|
89
|
+
], TestContainer);
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
TestContainer
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-VGGCSCVL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-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 { qtiTransformTest } from '../../qti-transformers';\n\n/**\n * `<test-container>` is a custom element designed for hosting the qti-assessment-item.\n * The `qti-assessment-test` will be placed inside the shadow DOM of this element.\n * The element loads the test from the provided URL and renders it inside the shadow DOM.\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container class=\"m-4 bg-white\" test-url=\"./path/to/assessmenttest.xml\"></test-container>\n * </test-navigation>\n * </qti-test>\n * ```\n */\n@customElement('test-container')\nexport class TestContainer extends LitElement {\n /** URL of the item to load */\n @property({ type: String, attribute: 'test-url' })\n testURL: string = null;\n\n /** A parsed HTML document */\n @state()\n testDoc: DocumentFragment = null;\n\n /** The raw XML string */\n @state()\n testXML: string = null;\n\n /** Template content if provided */\n private templateContent = null;\n\n @watch('testURL', { waitUntilFirstUpdate: true })\n protected async handleTestURLChange() {\n if (!this.testURL) return;\n try {\n const api = await qtiTransformTest().load(this.testURL);\n this.testDoc = api.htmlDoc();\n } catch (error) {\n console.error('Error loading or parsing XML:', error);\n }\n }\n\n @watch('testXML', { waitUntilFirstUpdate: true })\n protected handleTestXMLChange() {\n if (!this.testXML) return;\n try {\n this.testDoc = qtiTransformTest().parse(this.testXML).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.testURL) {\n this.handleTestURLChange();\n }\n if (this.testXML) {\n this.handleTestXMLChange();\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.testDoc, html`<span>Loading...</span>`)}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-container': TestContainer;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,YAA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S,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,74 @@
|
|
|
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
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
26
|
+
}
|
|
27
|
+
willUpdate(_changedProperties) {
|
|
28
|
+
if (!this.computedContext) {
|
|
29
|
+
this.stampContext = null;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
33
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
34
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
35
|
+
if (!activeTestPart || !activeItem) {
|
|
36
|
+
this.stampContext = null;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const augmentedTestPart = {
|
|
40
|
+
...activeTestPart,
|
|
41
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
42
|
+
};
|
|
43
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
44
|
+
this.stampContext = {
|
|
45
|
+
test: activeTest,
|
|
46
|
+
testpart: augmentedTestPart,
|
|
47
|
+
section: activeSection,
|
|
48
|
+
item: activeItem
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
if (!this.stampContext || !this.myTemplate) return html``;
|
|
53
|
+
return html`${this.myTemplate(this.stampContext)}
|
|
54
|
+
${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>` : nothing}`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
__decorateClass([
|
|
58
|
+
property({ type: Boolean, reflect: true })
|
|
59
|
+
], TestStamp.prototype, "debug", 2);
|
|
60
|
+
__decorateClass([
|
|
61
|
+
state(),
|
|
62
|
+
consume({ context: computedContext, subscribe: true })
|
|
63
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
64
|
+
__decorateClass([
|
|
65
|
+
state()
|
|
66
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
67
|
+
TestStamp = __decorateClass([
|
|
68
|
+
customElement("test-stamp")
|
|
69
|
+
], TestStamp);
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
TestStamp
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=chunk-WTN76Y5P.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 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 html``;\n return html`${this.myTemplate(this.stampContext)}\n ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>` : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAA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K,UAAU,KAAK,cAAc,MAAM,CAAC,CAAC,WAAW,OAAO;AAAA,EACzF;AACF;AAjES;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,74 @@
|
|
|
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
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
26
|
+
}
|
|
27
|
+
willUpdate(_changedProperties) {
|
|
28
|
+
if (!this.computedContext) {
|
|
29
|
+
this.stampContext = null;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
33
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
34
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
35
|
+
if (!activeTestPart || !activeItem) {
|
|
36
|
+
this.stampContext = null;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const augmentedTestPart = {
|
|
40
|
+
...activeTestPart,
|
|
41
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
42
|
+
};
|
|
43
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
44
|
+
this.stampContext = {
|
|
45
|
+
test: activeTest,
|
|
46
|
+
testpart: augmentedTestPart,
|
|
47
|
+
section: activeSection,
|
|
48
|
+
item: activeItem
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
if (!this.stampContext || !this.myTemplate) return html``;
|
|
53
|
+
return html` ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>` : nothing} asdsad
|
|
54
|
+
${this.myTemplate(this.stampContext)}`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
__decorateClass([
|
|
58
|
+
property({ type: Boolean, reflect: true })
|
|
59
|
+
], TestStamp.prototype, "debug", 2);
|
|
60
|
+
__decorateClass([
|
|
61
|
+
state(),
|
|
62
|
+
consume({ context: computedContext, subscribe: true })
|
|
63
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
64
|
+
__decorateClass([
|
|
65
|
+
state()
|
|
66
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
67
|
+
TestStamp = __decorateClass([
|
|
68
|
+
customElement("test-stamp")
|
|
69
|
+
], TestStamp);
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
TestStamp
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=chunk-WVMOFVRE.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 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 html``;\n return html` ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>` : nothing} asdsad\n ${this.myTemplate(this.stampContext)}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YA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AO;AAAA,MAClG,KAAK,WAAW,KAAK,YAAY,CAAC;AAAA,EACtC;AACF;AAjES;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,73 @@
|
|
|
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 } 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
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
26
|
+
}
|
|
27
|
+
willUpdate(_changedProperties) {
|
|
28
|
+
if (!this.computedContext) {
|
|
29
|
+
this.stampContext = null;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
33
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
34
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
35
|
+
if (!activeTestPart || !activeItem) {
|
|
36
|
+
this.stampContext = null;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const augmentedTestPart = {
|
|
40
|
+
...activeTestPart,
|
|
41
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
42
|
+
};
|
|
43
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
44
|
+
this.stampContext = {
|
|
45
|
+
test: activeTest,
|
|
46
|
+
testpart: augmentedTestPart,
|
|
47
|
+
section: activeSection,
|
|
48
|
+
item: activeItem
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
if (!this.stampContext || !this.myTemplate) return html``;
|
|
53
|
+
return html`${this.myTemplate(this.stampContext)}`;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__decorateClass([
|
|
57
|
+
property({ type: Boolean, reflect: true })
|
|
58
|
+
], TestStamp.prototype, "debug", 2);
|
|
59
|
+
__decorateClass([
|
|
60
|
+
state(),
|
|
61
|
+
consume({ context: computedContext, subscribe: true })
|
|
62
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
63
|
+
__decorateClass([
|
|
64
|
+
state()
|
|
65
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
66
|
+
TestStamp = __decorateClass([
|
|
67
|
+
customElement("test-stamp")
|
|
68
|
+
], TestStamp);
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
TestStamp
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-WXQLAXP4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/qti-test/components/test-stamp.ts"],"sourcesContent":["import { html, LitElement } 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 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 html``;\n return html`${this.myTemplate(this.stampContext)}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,kBAAkB;AACjC,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,uBAAuB;AAChC,SAAS,eAAe;AASjB,IAAM,YAAN,cAAwB,WAAW;AAAA,EAAnC;AAAA;AAEL,SAAO,QAAQ;AAOf,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AGA;AAAA,EADP,MAAM;AAAA,GARI,UASH;AATG,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;","names":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
if (!activeTestPart) {
|
|
38
|
+
this.stampContext = null;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const augmentedTestPart = {
|
|
42
|
+
...activeTestPart,
|
|
43
|
+
items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables, ...rest }) => rest)),
|
|
44
|
+
sections: activeTestPart.sections.map((section) => ({
|
|
45
|
+
...section,
|
|
46
|
+
items: section.items.map(({ variables, ...rest }) => rest)
|
|
47
|
+
}))
|
|
48
|
+
};
|
|
49
|
+
const activeSection = augmentedTestPart.sections.find((section) => section.active);
|
|
50
|
+
const augmentedSection = { ...activeSection, items: activeSection.items };
|
|
51
|
+
const augmentedItem = augmentedSection.items.find((item) => item.active);
|
|
52
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
53
|
+
this.stampContext = {
|
|
54
|
+
item: augmentedItem,
|
|
55
|
+
section: augmentedSection,
|
|
56
|
+
testpart: augmentedTestPart,
|
|
57
|
+
test: activeTest
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
|
+
return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}
|
|
62
|
+
${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
__decorateClass([
|
|
66
|
+
property({ type: Boolean, reflect: true })
|
|
67
|
+
], TestStamp.prototype, "debug", 2);
|
|
68
|
+
__decorateClass([
|
|
69
|
+
state(),
|
|
70
|
+
consume({ context: computedContext, subscribe: true })
|
|
71
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
72
|
+
__decorateClass([
|
|
73
|
+
state()
|
|
74
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
75
|
+
TestStamp = __decorateClass([
|
|
76
|
+
customElement("test-stamp")
|
|
77
|
+
], TestStamp);
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
TestStamp
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=chunk-X2ZV2OFN.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 if (!activeTestPart) {\n this.stampContext = null;\n return;\n }\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),\n sections: activeTestPart.sections.map(section => ({\n ...section,\n items: section.items.map(({ variables, ...rest }) => rest)\n }))\n };\n\n const activeSection = augmentedTestPart.sections.find(section => section.active);\n const augmentedSection = { ...activeSection, items: activeSection.items };\n\n const augmentedItem = augmentedSection.items.find(item => item.active);\n\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n item: augmentedItem,\n section: augmentedSection,\n testpart: augmentedTestPart,\n test: activeTest\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":";;;;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AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,MACV,MAAM;AAAA,IACR;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;AArES;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,74 @@
|
|
|
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
|
+
this.myTemplate = prepareTemplate(templateElement);
|
|
26
|
+
}
|
|
27
|
+
willUpdate(_changedProperties) {
|
|
28
|
+
if (!this.computedContext) {
|
|
29
|
+
this.stampContext = null;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
|
|
33
|
+
const activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
34
|
+
const activeItem = this.computedContext.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
|
|
35
|
+
if (!activeTestPart || !activeItem) {
|
|
36
|
+
this.stampContext = null;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const augmentedTestPart = {
|
|
40
|
+
...activeTestPart,
|
|
41
|
+
items: activeTestPart.sections.flatMap((section) => section.items)
|
|
42
|
+
};
|
|
43
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
44
|
+
this.stampContext = {
|
|
45
|
+
test: activeTest,
|
|
46
|
+
testpart: augmentedTestPart,
|
|
47
|
+
section: activeSection,
|
|
48
|
+
item: activeItem
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
if (!this.stampContext || !this.myTemplate) return html``;
|
|
53
|
+
return html` ${this.debug ? html`<pre>${JSON.stringify(this.stampContext, null, 2)}</pre>` : nothing}
|
|
54
|
+
${this.myTemplate(this.stampContext)}`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
__decorateClass([
|
|
58
|
+
property({ type: Boolean, reflect: true })
|
|
59
|
+
], TestStamp.prototype, "debug", 2);
|
|
60
|
+
__decorateClass([
|
|
61
|
+
state(),
|
|
62
|
+
consume({ context: computedContext, subscribe: true })
|
|
63
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
64
|
+
__decorateClass([
|
|
65
|
+
state()
|
|
66
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
67
|
+
TestStamp = __decorateClass([
|
|
68
|
+
customElement("test-stamp")
|
|
69
|
+
], TestStamp);
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
TestStamp
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=chunk-XAJNR7FS.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 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 html``;\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,KAAK,cAAmC,UAAU;AAC1E,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;AACtF,UAAM,gBAAgB,KAAK,gBAAgB,UACxC,QAAQ,cAAY,SAAS,QAAQ,EACrC,KAAK,aAAW,QAAQ,MAAM;AACjC,UAAM,aAAa,KAAK,gBAAgB,UACrC,QAAQ,cAAY,SAAS,SAAS,QAAQ,aAAW,QAAQ,KAAK,CAAC,EACvE,KAAK,UAAQ,KAAK,MAAM;AAE3B,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,QAAI,CAAC,KAAK,gBAAgB,CAAC,KAAK,WAAY,QAAO;AACnD,WAAO,QAAQ,KAAK,QAAQ,YAAY,KAAK,UAAU,KAAK,cAAc,MAAM,CAAC,CAAC,WAAW,OAAO;AAAA,MAClG,KAAK,WAAW,KAAK,YAAY,CAAC;AAAA,EACtC;AACF;AAjES;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,69 @@
|
|
|
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 activeSection = this.computedContext.testParts.flatMap((testPart) => testPart.sections).find((section) => section.active);
|
|
37
|
+
const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables, ...rest }) => rest) };
|
|
38
|
+
const augmentedItem = augmentedSection.items.find((item) => item.active);
|
|
39
|
+
const { testParts, ...activeTest } = this.computedContext;
|
|
40
|
+
this.stampContext = {
|
|
41
|
+
test: activeTest,
|
|
42
|
+
// testpart: augmentedTestPart,
|
|
43
|
+
section: augmentedSection,
|
|
44
|
+
item: augmentedItem
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}
|
|
49
|
+
${this.stampContext && this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
__decorateClass([
|
|
53
|
+
property({ type: Boolean, reflect: true })
|
|
54
|
+
], TestStamp.prototype, "debug", 2);
|
|
55
|
+
__decorateClass([
|
|
56
|
+
state(),
|
|
57
|
+
consume({ context: computedContext, subscribe: true })
|
|
58
|
+
], TestStamp.prototype, "computedContext", 2);
|
|
59
|
+
__decorateClass([
|
|
60
|
+
state()
|
|
61
|
+
], TestStamp.prototype, "stampContext", 2);
|
|
62
|
+
TestStamp = __decorateClass([
|
|
63
|
+
customElement("test-stamp")
|
|
64
|
+
], TestStamp);
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
TestStamp
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=chunk-YBDDKT65.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.map(({ variables, ...rest }) => rest)),\n // sections: activeTestPart.sections.map(section => ({\n // ...section,\n // items: section.items.map(({ variables, ...rest }) => rest)\n // }))\n // };\n\n const activeSection = this.computedContext.testParts\n .flatMap(testPart => testPart.sections)\n .find(section => section.active);\n const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables, ...rest }) => rest) };\n\n const augmentedItem = augmentedSection.items.find(item => item.active);\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;AAYA,UAAM,gBAAgB,KAAK,gBAAgB,UACxC,QAAQ,cAAY,SAAS,QAAQ,EACrC,KAAK,aAAW,QAAQ,MAAM;AACjC,UAAM,mBAAmB,EAAE,GAAG,eAAe,OAAO,cAAc,MAAM,IAAI,CAAC,EAAE,WAAW,GAAG,KAAK,MAAM,IAAI,EAAE;AAE9G,UAAM,gBAAgB,iBAAiB,MAAM,KAAK,UAAQ,KAAK,MAAM;AAOrE,UAAM,EAAE,WAAW,GAAG,WAAW,IAAI,KAAK;AAE1C,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA;AAAA,MAEN,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO,QAAQ,KAAK,QAAQ,mBAAmB,KAAK,UAAU,KAAK,cAAc,MAAM,CAAC,CAAC,mB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