@citolab/qti-components 7.0.4 → 7.0.6-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/chunk-25BMUTLC.js +1 -0
- package/cdn/chunk-3DWLPGTE.js +1 -0
- package/cdn/chunk-7BKWTY4S.js +1 -0
- package/cdn/chunk-7CQ4ETXL.js +1 -0
- package/cdn/chunk-7ENNZNJ4.js +1 -0
- package/cdn/chunk-7LGM2TQA.js +1 -0
- package/cdn/chunk-CYJMNT76.js +0 -0
- package/cdn/chunk-DLMFCDQX.js +1 -0
- package/cdn/chunk-DPR6SGCZ.js +1 -0
- package/cdn/chunk-EQGXFSYL.js +8 -0
- package/cdn/chunk-F5VW77RE.js +1 -0
- package/cdn/chunk-FNVXN5CO.js +1 -0
- package/cdn/chunk-GB7DLBFM.js +0 -0
- package/cdn/chunk-GBB54IPA.js +8 -0
- package/cdn/chunk-GPDDPZFH.js +1 -0
- package/cdn/chunk-H4A34YRT.js +0 -0
- package/cdn/chunk-ITXNNGVQ.js +0 -0
- package/cdn/chunk-IV7UP34N.js +5 -0
- package/cdn/chunk-IZZ36JQV.js +0 -0
- package/cdn/chunk-JNT54FPI.js +1 -0
- package/cdn/chunk-JS4S7ZI7.js +1 -0
- package/cdn/chunk-L26FOTPN.js +17 -0
- package/cdn/chunk-LA7TBIPQ.js +0 -0
- package/cdn/chunk-LVW3MHTI.js +23 -0
- package/cdn/chunk-POT65ZY7.js +1 -0
- package/cdn/chunk-Q7PVZA43.js +5 -0
- package/cdn/chunk-QJPHXAUE.js +1 -0
- package/cdn/chunk-QP57JHGY.js +11 -0
- package/cdn/chunk-RB6CONZW.js +3 -0
- package/cdn/chunk-RSRX5JYB.js +1 -0
- package/cdn/chunk-TG6AE3DB.js +0 -0
- package/cdn/chunk-V6YPUNZC.js +0 -0
- package/cdn/chunk-VI2WKTN4.js +1 -0
- package/cdn/chunk-W7X6GNEX.js +902 -0
- package/cdn/chunk-Y63VPWCG.js +3523 -0
- package/cdn/chunk-ZEX7TYC7.js +8 -0
- package/cdn/index.global.js +45 -45
- package/cdn/index.js +1 -4783
- package/cdn/qti-components/index.global.js +226 -0
- package/cdn/qti-components/index.js +1 -0
- package/cdn/qti-item/components/index.global.js +149 -0
- package/cdn/qti-item/components/index.js +1 -0
- package/cdn/qti-item/components/item-container.global.js +149 -0
- package/cdn/qti-item/components/item-container.js +1 -0
- package/cdn/qti-item/index.global.js +149 -0
- package/cdn/qti-item/index.js +1 -0
- package/cdn/qti-item/qti-item.global.js +114 -0
- package/cdn/qti-item/qti-item.js +1 -0
- package/cdn/qti-loader/index.global.js +1 -0
- package/cdn/qti-loader/index.js +1 -0
- package/cdn/qti-test/components/index.global.js +242 -0
- package/cdn/qti-test/components/index.js +1 -0
- package/cdn/qti-test/components/styles.global.js +44 -0
- package/cdn/qti-test/components/styles.js +1 -0
- package/cdn/qti-test/components/test-component.abstract.global.js +170 -0
- package/cdn/qti-test/components/test-component.abstract.js +1 -0
- package/cdn/qti-test/components/test-container.global.js +149 -0
- package/cdn/qti-test/components/test-container.js +1 -0
- package/cdn/qti-test/components/test-item-link.global.js +170 -0
- package/cdn/qti-test/components/test-item-link.js +1 -0
- package/cdn/qti-test/components/test-next.global.js +170 -0
- package/cdn/qti-test/components/test-next.js +1 -0
- package/cdn/qti-test/components/test-next.spec.global.js +297 -0
- package/cdn/qti-test/components/test-next.spec.js +713 -0
- package/cdn/qti-test/components/test-paging-buttons-stamp.global.js +207 -0
- package/cdn/qti-test/components/test-paging-buttons-stamp.js +1 -0
- package/cdn/qti-test/components/test-prev.global.js +170 -0
- package/cdn/qti-test/components/test-prev.js +1 -0
- package/cdn/qti-test/components/test-view.global.js +170 -0
- package/cdn/qti-test/components/test-view.js +1 -0
- package/cdn/qti-test/context/index.global.js +58 -0
- package/cdn/qti-test/context/index.js +1 -0
- package/cdn/qti-test/context/test.context.global.js +58 -0
- package/cdn/qti-test/context/test.context.js +1 -0
- package/cdn/qti-test/index.global.js +242 -0
- package/cdn/qti-test/index.js +1 -0
- package/cdn/qti-test/mixins/index.global.js +1 -0
- package/cdn/qti-test/mixins/index.js +1 -0
- package/cdn/qti-test/mixins/test-loader.mixin.global.js +1 -0
- package/cdn/qti-test/mixins/test-loader.mixin.js +1 -0
- package/cdn/qti-test/mixins/test-navigation.mixin.global.js +1 -0
- package/cdn/qti-test/mixins/test-navigation.mixin.js +1 -0
- package/cdn/qti-test/mixins/test-view.mixin.global.js +1 -0
- package/cdn/qti-test/mixins/test-view.mixin.js +1 -0
- package/cdn/qti-test/qti-assessment-test/index.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/index.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-item-ref.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-item-ref.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-section.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-section.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-test.global.js +170 -0
- package/cdn/qti-test/qti-assessment-test/qti-assessment-test.js +1 -0
- package/cdn/qti-test/qti-assessment-test/qti-test-part.global.js +114 -0
- package/cdn/qti-test/qti-assessment-test/qti-test-part.js +1 -0
- package/cdn/qti-test/qti-test.global.js +170 -0
- package/cdn/qti-test/qti-test.js +1 -0
- package/cdn/qti-test/test-base.global.js +170 -0
- package/cdn/qti-test/test-base.js +1 -0
- package/cdn/qti-transformers/index.global.js +1 -0
- package/cdn/qti-transformers/index.js +1 -0
- package/dist/{transformers/index.js → chunk-2OA7E3E7.js} +2 -1
- package/dist/chunk-2OA7E3E7.js.map +1 -0
- package/dist/chunk-37X6KZO3.js +1 -0
- package/dist/chunk-37X6KZO3.js.map +1 -0
- package/dist/chunk-3WLCQQN7.js +3529 -0
- package/dist/chunk-3WLCQQN7.js.map +1 -0
- package/dist/chunk-3YVIK6LO.js +1 -0
- package/dist/chunk-3YVIK6LO.js.map +1 -0
- package/dist/chunk-44VE5POH.js +55 -0
- package/dist/chunk-44VE5POH.js.map +1 -0
- package/dist/chunk-4CSM2PCC.js +37 -0
- package/dist/chunk-4CSM2PCC.js.map +1 -0
- package/dist/chunk-4YG2FPKK.js +31 -0
- package/dist/chunk-4YG2FPKK.js.map +1 -0
- package/dist/chunk-7A6KCSAU.js +44 -0
- package/dist/chunk-7A6KCSAU.js.map +1 -0
- package/dist/chunk-ENVUIH2A.js +118 -0
- package/dist/chunk-ENVUIH2A.js.map +1 -0
- package/dist/chunk-ENZVY5X6.js +20 -0
- package/dist/chunk-ENZVY5X6.js.map +1 -0
- package/dist/chunk-EUCEENQQ.js +6253 -0
- package/dist/chunk-EUCEENQQ.js.map +1 -0
- package/dist/chunk-FNFNAV3G.js +56 -0
- package/dist/chunk-FNFNAV3G.js.map +1 -0
- package/dist/chunk-GSFDTSLL.js +1 -0
- package/dist/chunk-GSFDTSLL.js.map +1 -0
- package/dist/chunk-GTYLWGDG.js +43 -0
- package/dist/chunk-GTYLWGDG.js.map +1 -0
- package/dist/chunk-IAFQ5ZPI.js +29 -0
- package/dist/chunk-IAFQ5ZPI.js.map +1 -0
- package/dist/chunk-JDHBXMKF.js +78 -0
- package/dist/chunk-JDHBXMKF.js.map +1 -0
- package/dist/chunk-L7MBIXEX.js +50 -0
- package/dist/chunk-L7MBIXEX.js.map +1 -0
- package/dist/chunk-LYFMLDNV.js +1 -0
- package/dist/chunk-LYFMLDNV.js.map +1 -0
- package/dist/chunk-NNPTSZGC.js +1 -0
- package/dist/chunk-NNPTSZGC.js.map +1 -0
- package/dist/chunk-NQM35JUI.js +1 -0
- package/dist/chunk-NQM35JUI.js.map +1 -0
- package/dist/chunk-ODUHPWTX.js +65 -0
- package/dist/chunk-ODUHPWTX.js.map +1 -0
- package/dist/chunk-OGHHCP23.js +36 -0
- package/dist/chunk-OGHHCP23.js.map +1 -0
- package/dist/chunk-OQZW2B47.js +75 -0
- package/dist/chunk-OQZW2B47.js.map +1 -0
- package/dist/chunk-OXDOQVRL.js +63 -0
- package/dist/chunk-OXDOQVRL.js.map +1 -0
- package/dist/chunk-PBSMP6VF.js +128 -0
- package/dist/chunk-PBSMP6VF.js.map +1 -0
- package/dist/chunk-Q7OPFS4A.js +1 -0
- package/dist/chunk-Q7OPFS4A.js.map +1 -0
- package/dist/chunk-R4HSV7U7.js +10 -0
- package/dist/chunk-R4HSV7U7.js.map +1 -0
- package/dist/chunk-TXRSYXG3.js +50 -0
- package/dist/chunk-TXRSYXG3.js.map +1 -0
- package/dist/chunk-U3RLYKL5.js +51 -0
- package/dist/chunk-U3RLYKL5.js.map +1 -0
- package/dist/chunk-UB5K44DB.js +30 -0
- package/dist/chunk-UB5K44DB.js.map +1 -0
- package/dist/chunk-VODOQFTJ.js +72 -0
- package/dist/chunk-VODOQFTJ.js.map +1 -0
- package/dist/chunk-VW7VIQBE.js +34 -0
- package/dist/chunk-VW7VIQBE.js.map +1 -0
- package/dist/chunk-X4ZBUCOD.js +94 -0
- package/dist/chunk-X4ZBUCOD.js.map +1 -0
- package/dist/chunk-XFHB6KQW.js +1 -0
- package/dist/chunk-XFHB6KQW.js.map +1 -0
- package/dist/chunk-XNBWN7N2.js +94 -0
- package/dist/chunk-XNBWN7N2.js.map +1 -0
- package/dist/index.d.ts +18 -503
- package/dist/index.js +169 -13584
- package/dist/index.js.map +1 -1
- package/dist/item.css +10 -10
- package/dist/qti-components/index.d.ts +150 -0
- package/dist/qti-components/index.js +189 -0
- package/dist/qti-components/index.js.map +1 -0
- package/dist/qti-components-jsx.d.ts +93 -147
- package/dist/qti-item/components/index.d.ts +3 -0
- package/dist/qti-item/components/index.js +12 -0
- package/dist/qti-item/components/index.js.map +1 -0
- package/dist/qti-item/components/item-container.d.ts +40 -0
- package/dist/qti-item/components/item-container.js +11 -0
- package/dist/qti-item/components/item-container.js.map +1 -0
- package/dist/qti-item/index.d.ts +4 -0
- package/dist/qti-item/index.js +17 -0
- package/dist/qti-item/index.js.map +1 -0
- package/dist/qti-item/qti-item.d.ts +25 -0
- package/dist/qti-item/qti-item.js +8 -0
- package/dist/qti-item/qti-item.js.map +1 -0
- package/dist/{loader → qti-loader}/index.d.ts +1 -1
- package/dist/qti-loader/index.js +11 -0
- package/dist/qti-loader/index.js.map +1 -0
- package/dist/{qti-simple-choice-D0GiMrqD.d.ts → qti-simple-choice-DxWcdKHi.d.ts} +30 -40
- package/dist/qti-test/components/index.d.ts +13 -0
- package/dist/qti-test/components/index.js +40 -0
- package/dist/qti-test/components/index.js.map +1 -0
- package/dist/qti-test/components/styles.d.ts +8 -0
- package/dist/qti-test/components/styles.js +14 -0
- package/dist/qti-test/components/styles.js.map +1 -0
- package/dist/qti-test/components/test-component.abstract.d.ts +23 -0
- package/dist/qti-test/components/test-component.abstract.js +12 -0
- package/dist/qti-test/components/test-component.abstract.js.map +1 -0
- package/dist/qti-test/components/test-container.d.ts +37 -0
- package/dist/qti-test/components/test-container.js +11 -0
- package/dist/qti-test/components/test-container.js.map +1 -0
- package/dist/qti-test/components/test-item-link.d.ts +21 -0
- package/dist/qti-test/components/test-item-link.js +14 -0
- package/dist/qti-test/components/test-item-link.js.map +1 -0
- package/dist/qti-test/components/test-next.d.ts +32 -0
- package/dist/qti-test/components/test-next.js +14 -0
- package/dist/qti-test/components/test-next.js.map +1 -0
- package/dist/qti-test/components/test-next.spec.d.ts +16 -0
- package/dist/qti-test/components/test-next.spec.js +45923 -0
- package/dist/qti-test/components/test-next.spec.js.map +1 -0
- package/dist/qti-test/components/test-paging-buttons-stamp.d.ts +22 -0
- package/dist/qti-test/components/test-paging-buttons-stamp.js +13 -0
- package/dist/qti-test/components/test-paging-buttons-stamp.js.map +1 -0
- package/dist/qti-test/components/test-prev.d.ts +32 -0
- package/dist/qti-test/components/test-prev.js +14 -0
- package/dist/qti-test/components/test-prev.js.map +1 -0
- package/dist/qti-test/components/test-view.d.ts +27 -0
- package/dist/qti-test/components/test-view.js +13 -0
- package/dist/qti-test/components/test-view.js.map +1 -0
- package/dist/qti-test/context/index.d.ts +6 -0
- package/dist/qti-test/context/index.js +11 -0
- package/dist/qti-test/context/index.js.map +1 -0
- package/dist/qti-test/context/test.context.d.ts +6 -0
- package/dist/qti-test/context/test.context.js +10 -0
- package/dist/qti-test/context/test.context.js.map +1 -0
- package/dist/qti-test/index.d.ts +14 -0
- package/dist/qti-test/index.js +72 -0
- package/dist/qti-test/index.js.map +1 -0
- package/dist/qti-test/mixins/index.d.ts +8 -0
- package/dist/qti-test/mixins/index.js +18 -0
- package/dist/qti-test/mixins/index.js.map +1 -0
- package/dist/qti-test/mixins/test-loader.mixin.d.ts +8 -0
- package/dist/qti-test/mixins/test-loader.mixin.js +9 -0
- package/dist/qti-test/mixins/test-loader.mixin.js.map +1 -0
- package/dist/qti-test/mixins/test-navigation.mixin.d.ts +22 -0
- package/dist/qti-test/mixins/test-navigation.mixin.js +8 -0
- package/dist/qti-test/mixins/test-navigation.mixin.js.map +1 -0
- package/dist/qti-test/mixins/test-view.mixin.d.ts +6 -0
- package/dist/qti-test/mixins/test-view.mixin.js +8 -0
- package/dist/qti-test/mixins/test-view.mixin.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/index.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/index.js +23 -0
- package/dist/qti-test/qti-assessment-test/index.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.js +10 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-section.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-section.js +10 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-section.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-test.d.ts +6 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-test.js +10 -0
- package/dist/qti-test/qti-assessment-test/qti-assessment-test.js.map +1 -0
- package/dist/qti-test/qti-assessment-test/qti-test-part.d.ts +19 -0
- package/dist/qti-test/qti-assessment-test/qti-test-part.js +8 -0
- package/dist/qti-test/qti-assessment-test/qti-test-part.js.map +1 -0
- package/dist/qti-test/qti-test.d.ts +68 -0
- package/dist/qti-test/qti-test.js +16 -0
- package/dist/qti-test/qti-test.js.map +1 -0
- package/dist/qti-test/test-base.d.ts +6 -0
- package/dist/qti-test/test-base.js +10 -0
- package/dist/qti-test/test-base.js.map +1 -0
- package/dist/qti-transformers/index.js +12 -0
- package/dist/qti-transformers/index.js.map +1 -0
- package/dist/test-base-BJwG9Ie8.d.ts +109 -0
- package/dist/vscode.html-custom-data.json +49 -38
- package/package.json +28 -52
- package/dist/custom-element-eslint-rules.js +0 -329
- package/dist/custom-elements.json +0 -27271
- package/dist/loader/index.js +0 -310
- package/dist/loader/index.js.map +0 -1
- package/dist/qti-simple-choice-CfgBEvdI.d.ts +0 -1143
- package/dist/qti-simple-choice-UTrFa_RQ.d.ts +0 -1177
- package/dist/qti-simple-choice-zEsDq3c0.d.ts +0 -1147
- package/dist/transformers/index.js.map +0 -1
- /package/dist/{transformers → qti-transformers}/index.d.ts +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
testContext,
|
|
3
|
+
testElement
|
|
4
|
+
} from "./chunk-R4HSV7U7.js";
|
|
5
|
+
import {
|
|
6
|
+
__decorateClass
|
|
7
|
+
} from "./chunk-44VE5POH.js";
|
|
8
|
+
|
|
9
|
+
// src/lib/qti-test/test-base.ts
|
|
10
|
+
import { provide } from "@lit/context";
|
|
11
|
+
import { LitElement } from "lit";
|
|
12
|
+
import { state } from "lit/decorators.js";
|
|
13
|
+
var TestBase = class extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this._testContext = { items: [], testOutcomeVariables: [] };
|
|
17
|
+
this.testElement = { el: null };
|
|
18
|
+
/**
|
|
19
|
+
* Updates the variables of an assessment item in the test context.
|
|
20
|
+
* - Matches the assessment item with the corresponding test context item.
|
|
21
|
+
* - If the item is not found, logs a warning.
|
|
22
|
+
* - Updates variables in the test context if exactly one variable exists.
|
|
23
|
+
* - Otherwise, syncs the assessment item's variables with the test context.
|
|
24
|
+
*
|
|
25
|
+
* @param assessmentItem - The assessment item to update.
|
|
26
|
+
*/
|
|
27
|
+
this._updateItemInTestContext = (assessmentItem) => {
|
|
28
|
+
const { identifier, variables } = assessmentItem;
|
|
29
|
+
const itemContext = this._testContext.items.find((i) => i?.identifier === identifier);
|
|
30
|
+
if (!itemContext) {
|
|
31
|
+
console.warn(`Item IDs between assessment.xml and item.xml should match: ${identifier} is not found!`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (itemContext.variables?.length === 1) {
|
|
35
|
+
this._updateItemVariablesInTestContext(identifier, variables);
|
|
36
|
+
} else {
|
|
37
|
+
assessmentItem.variables = [...itemContext.variables || []];
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.addEventListener("qti-assessment-test-connected", (e) => {
|
|
41
|
+
const qtiAssessmentTest = e.detail;
|
|
42
|
+
const items = Array.from(qtiAssessmentTest.querySelectorAll("qti-assessment-item-ref")).map(
|
|
43
|
+
(itemRef) => ({
|
|
44
|
+
href: itemRef.href,
|
|
45
|
+
identifier: itemRef.identifier,
|
|
46
|
+
category: itemRef.category,
|
|
47
|
+
variables: [{ identifier: "completionStatus", value: "not_attempted", type: "outcome" }]
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
this.testElement = { el: qtiAssessmentTest };
|
|
51
|
+
this._testContext = { ...this._testContext, items };
|
|
52
|
+
});
|
|
53
|
+
this.addEventListener("qti-assessment-item-connected", (e) => {
|
|
54
|
+
this._updateItemInTestContext(e.detail);
|
|
55
|
+
});
|
|
56
|
+
this.addEventListener("qti-outcome-changed", (e) => {
|
|
57
|
+
const assessmentitem = e.composedPath()[0];
|
|
58
|
+
this._updateItemVariablesInTestContext(assessmentitem.identifier, assessmentitem.variables);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
get context() {
|
|
62
|
+
return this._testContext;
|
|
63
|
+
}
|
|
64
|
+
// /* restores the context by updating existing items and adding new items from the "contextToRestore" parameter into the "this._context.items" array. */
|
|
65
|
+
set context(testContext2) {
|
|
66
|
+
if (testContext2 === null || testContext2 === void 0) return;
|
|
67
|
+
this._testContext = { ...testContext2 };
|
|
68
|
+
testContext2.items?.forEach((itemContext) => {
|
|
69
|
+
const existingItemContext = this._testContext.items.find((i) => i.identifier === itemContext.identifier);
|
|
70
|
+
if (existingItemContext) {
|
|
71
|
+
existingItemContext.variables = itemContext.variables;
|
|
72
|
+
} else {
|
|
73
|
+
this._testContext.items.push(itemContext);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
_updateItemVariablesInTestContext(identifier, variables) {
|
|
78
|
+
this._testContext = {
|
|
79
|
+
...this._testContext,
|
|
80
|
+
// Spread existing test context properties
|
|
81
|
+
items: this._testContext.items.map((itemContext) => {
|
|
82
|
+
if (itemContext.identifier !== identifier) {
|
|
83
|
+
return itemContext;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
...itemContext,
|
|
87
|
+
// Keep other properties of the item context
|
|
88
|
+
variables: variables.map((variable) => {
|
|
89
|
+
const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
|
|
90
|
+
return matchingVariable ? { ...matchingVariable, ...variable } : variable;
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
})
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// private _addItemToTestContext(
|
|
97
|
+
// e: CustomEvent<{ href: string; identifier: string; category: string }> & { target: QtiAssessmentItemRef }
|
|
98
|
+
// ): void {
|
|
99
|
+
// const { href, identifier, category } = e.detail;
|
|
100
|
+
// // Update test context items, adding a new item if the identifier is not already in the list
|
|
101
|
+
// if (!this._testContext.items.some(item => item.identifier === identifier)) {
|
|
102
|
+
// this._testContext.items.push({
|
|
103
|
+
// href,
|
|
104
|
+
// identifier,
|
|
105
|
+
// category,
|
|
106
|
+
// variables: [{ identifier: 'completionStatus', value: 'not_attempted', type: 'outcome' }]
|
|
107
|
+
// // category: e.target.category
|
|
108
|
+
// });
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
connectedCallback() {
|
|
112
|
+
super.connectedCallback();
|
|
113
|
+
this.setAttribute("qti-test", "");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
__decorateClass([
|
|
117
|
+
state(),
|
|
118
|
+
provide({ context: testContext })
|
|
119
|
+
], TestBase.prototype, "_testContext", 2);
|
|
120
|
+
__decorateClass([
|
|
121
|
+
state(),
|
|
122
|
+
provide({ context: testElement })
|
|
123
|
+
], TestBase.prototype, "testElement", 2);
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
TestBase
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=chunk-PBSMP6VF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/qti-test/test-base.ts"],"sourcesContent":["import { provide } from '@lit/context';\nimport { LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\nimport { TestContext, testContext, TestElement, testElement } from './context';\nimport { QtiAssessmentTest } from './qti-assessment-test';\nimport { ItemContext, QtiAssessmentItem, VariableValue } from '../qti-components';\n\nexport abstract class TestBase extends LitElement {\n @state()\n @provide({ context: testContext })\n protected _testContext: Readonly<TestContext> = { items: [], testOutcomeVariables: [] };\n\n @state()\n @provide({ context: testElement })\n protected testElement: TestElement = { el: null };\n\n constructor() {\n super();\n\n this.addEventListener('qti-assessment-test-connected', (e: CustomEvent<QtiAssessmentTest>) => {\n const qtiAssessmentTest = e.detail;\n\n const items = Array.from(qtiAssessmentTest.querySelectorAll('qti-assessment-item-ref')).map(\n (itemRef): ItemContext & { category: string } => ({\n href: itemRef.href,\n identifier: itemRef.identifier,\n category: itemRef.category,\n variables: [{ identifier: 'completionStatus', value: 'not_attempted', type: 'outcome' }]\n })\n );\n this.testElement = { el: qtiAssessmentTest };\n this._testContext = { ...this._testContext, items };\n });\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent<QtiAssessmentItem>) => {\n this._updateItemInTestContext(e.detail);\n });\n this.addEventListener('qti-outcome-changed', e => {\n const assessmentitem = e.composedPath()[0] as QtiAssessmentItem;\n this._updateItemVariablesInTestContext(assessmentitem.identifier, assessmentitem.variables);\n });\n\n // this.addEventListener(\n // 'qti-assessment-item-ref-connected',\n // (e: CustomEvent<{ href: string; identifier: string; category: string }> & { target: QtiAssessmentItemRef }) => {\n // this._addItemToTestContext(e);\n // }\n // );\n }\n\n get context(): TestContext {\n return this._testContext;\n }\n\n // /* restores the context by updating existing items and adding new items from the \"contextToRestore\" parameter into the \"this._context.items\" array. */\n set context(testContext: TestContext) {\n if (testContext === null || testContext === undefined) return;\n this._testContext = { ...testContext }; // Clone the context to avoid modifying the original object\n // // append the items that are not yet in the context and replace the ones that are\n testContext.items?.forEach(itemContext => {\n const existingItemContext = this._testContext.items.find(i => i.identifier === itemContext.identifier);\n if (existingItemContext) {\n existingItemContext.variables = itemContext.variables;\n } else {\n this._testContext.items.push(itemContext);\n }\n });\n }\n\n private _updateItemVariablesInTestContext(\n identifier: string,\n variables: VariableValue<string | string[] | null>[]\n ): void {\n // Update the test context with modified variables for the specified item\n this._testContext = {\n ...this._testContext, // Spread existing test context properties\n items: this._testContext.items.map(itemContext => {\n // If the item identifier doesn't match, keep it unchanged\n if (itemContext.identifier !== identifier) {\n return itemContext;\n }\n\n // Update the matching item with new variables\n return {\n ...itemContext, // Keep other properties of the item context\n variables: variables.map(variable => {\n // Find a matching variable in the current item context\n const matchingVariable = itemContext.variables.find(v => v.identifier === variable.identifier);\n\n // Merge matching variable with the new one, or use the new variable if no match\n return matchingVariable ? { ...matchingVariable, ...variable } : variable;\n })\n };\n })\n };\n }\n\n /**\n * Updates the variables of an assessment item in the test context.\n * - Matches the assessment item with the corresponding test context item.\n * - If the item is not found, logs a warning.\n * - Updates variables in the test context if exactly one variable exists.\n * - Otherwise, syncs the assessment item's variables with the test context.\n *\n * @param assessmentItem - The assessment item to update.\n */\n private _updateItemInTestContext = (assessmentItem: QtiAssessmentItem): void => {\n const { identifier, variables } = assessmentItem;\n\n // console.log(this._testContext);\n\n // Find the corresponding item in the test context by identifier\n const itemContext = this._testContext.items.find(i => i?.identifier === identifier);\n\n if (!itemContext) {\n console.warn(`Item IDs between assessment.xml and item.xml should match: ${identifier} is not found!`);\n return;\n }\n\n // Update variables in the test context or sync them to the assessment item\n if (itemContext.variables?.length === 1) {\n // The loaded qti-assessment-item itself has variables which are not in test context yet.\n this._updateItemVariablesInTestContext(identifier, variables);\n } else {\n // Sync the assessment item's variables with the test context\n assessmentItem.variables = [...(itemContext.variables || [])];\n }\n };\n\n // private _addItemToTestContext(\n // e: CustomEvent<{ href: string; identifier: string; category: string }> & { target: QtiAssessmentItemRef }\n // ): void {\n // const { href, identifier, category } = e.detail;\n\n // // Update test context items, adding a new item if the identifier is not already in the list\n // if (!this._testContext.items.some(item => item.identifier === identifier)) {\n // this._testContext.items.push({\n // href,\n // identifier,\n // category,\n // variables: [{ identifier: 'completionStatus', value: 'not_attempted', type: 'outcome' }]\n // // category: e.target.category\n // });\n // }\n // }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.setAttribute('qti-test', '');\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AAKf,IAAe,WAAf,cAAgC,WAAW;AAAA,EAShD,cAAc;AACZ,UAAM;AAPR,SAAU,eAAsC,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC,EAAE;AAItF,SAAU,cAA2B,EAAE,IAAI,KAAK;AA2FhD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,2BAA2B,CAAC,mBAA4C;AAC9E,YAAM,EAAE,YAAY,UAAU,IAAI;AAKlC,YAAM,cAAc,KAAK,aAAa,MAAM,KAAK,OAAK,GAAG,eAAe,UAAU;AAElF,UAAI,CAAC,aAAa;AAChB,gBAAQ,KAAK,8DAA8D,UAAU,gBAAgB;AACrG;AAAA,MACF;AAGA,UAAI,YAAY,WAAW,WAAW,GAAG;AAEvC,aAAK,kCAAkC,YAAY,SAAS;AAAA,MAC9D,OAAO;AAEL,uBAAe,YAAY,CAAC,GAAI,YAAY,aAAa,CAAC,CAAE;AAAA,MAC9D;AAAA,IACF;AA3GE,SAAK,iBAAiB,iCAAiC,CAAC,MAAsC;AAC5F,YAAM,oBAAoB,EAAE;AAE5B,YAAM,QAAQ,MAAM,KAAK,kBAAkB,iBAAiB,yBAAyB,CAAC,EAAE;AAAA,QACtF,CAAC,aAAiD;AAAA,UAChD,MAAM,QAAQ;AAAA,UACd,YAAY,QAAQ;AAAA,UACpB,UAAU,QAAQ;AAAA,UAClB,WAAW,CAAC,EAAE,YAAY,oBAAoB,OAAO,iBAAiB,MAAM,UAAU,CAAC;AAAA,QACzF;AAAA,MACF;AACA,WAAK,cAAc,EAAE,IAAI,kBAAkB;AAC3C,WAAK,eAAe,EAAE,GAAG,KAAK,cAAc,MAAM;AAAA,IACpD,CAAC;AACD,SAAK,iBAAiB,iCAAiC,CAAC,MAAsC;AAC5F,WAAK,yBAAyB,EAAE,MAAM;AAAA,IACxC,CAAC;AACD,SAAK,iBAAiB,uBAAuB,OAAK;AAChD,YAAM,iBAAiB,EAAE,aAAa,EAAE,CAAC;AACzC,WAAK,kCAAkC,eAAe,YAAY,eAAe,SAAS;AAAA,IAC5F,CAAC;AAAA,EAQH;AAAA,EAEA,IAAI,UAAuB;AACzB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,QAAQA,cAA0B;AACpC,QAAIA,iBAAgB,QAAQA,iBAAgB,OAAW;AACvD,SAAK,eAAe,EAAE,GAAGA,aAAY;AAErC,IAAAA,aAAY,OAAO,QAAQ,iBAAe;AACxC,YAAM,sBAAsB,KAAK,aAAa,MAAM,KAAK,OAAK,EAAE,eAAe,YAAY,UAAU;AACrG,UAAI,qBAAqB;AACvB,4BAAoB,YAAY,YAAY;AAAA,MAC9C,OAAO;AACL,aAAK,aAAa,MAAM,KAAK,WAAW;AAAA,MAC1C;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,kCACN,YACA,WACM;AAEN,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA;AAAA,MACR,OAAO,KAAK,aAAa,MAAM,IAAI,iBAAe;AAEhD,YAAI,YAAY,eAAe,YAAY;AACzC,iBAAO;AAAA,QACT;AAGA,eAAO;AAAA,UACL,GAAG;AAAA;AAAA,UACH,WAAW,UAAU,IAAI,cAAY;AAEnC,kBAAM,mBAAmB,YAAY,UAAU,KAAK,OAAK,EAAE,eAAe,SAAS,UAAU;AAG7F,mBAAO,mBAAmB,EAAE,GAAG,kBAAkB,GAAG,SAAS,IAAI;AAAA,UACnE,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmDA,oBAA0B;AACxB,UAAM,kBAAkB;AACxB,SAAK,aAAa,YAAY,EAAE;AAAA,EAClC;AACF;AA3IY;AAAA,EAFT,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,YAAY,CAAC;AAAA,GAFb,SAGV;AAIA;AAAA,EAFT,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,YAAY,CAAC;AAAA,GANb,SAOV;","names":["testContext"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-Q7OPFS4A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/lib/qti-test/context/test.context.ts
|
|
2
|
+
import { createContext } from "@lit/context";
|
|
3
|
+
var testContext = createContext(Symbol("test"));
|
|
4
|
+
var testElement = createContext(Symbol("testElement"));
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
testContext,
|
|
8
|
+
testElement
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-R4HSV7U7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/qti-test/context/test.context.ts"],"sourcesContent":["import { createContext } from '@lit/context';\nimport { QtiAssessmentTest } from '../qti-assessment-test';\nimport { ItemContext, VariableDeclaration } from '../../qti-components';\nimport { View } from '../mixins/test-view.mixin';\n\nexport interface TestContext {\n items: (ItemContext & { category?: string })[];\n testOutcomeVariables: VariableDeclaration<string | string[]>[];\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemId?: string | null;\n navItemLoading?: boolean;\n navTestLoading?: boolean;\n view?: View;\n}\n\nexport const testContext = createContext<Readonly<TestContext>>(Symbol('test'));\n\nexport type TestElement = {\n el: QtiAssessmentTest;\n};\n\nexport const testElement = createContext<Readonly<TestElement>>(Symbol('testElement'));\n"],"mappings":";AAAA,SAAS,qBAAqB;AAgBvB,IAAM,cAAc,cAAqC,OAAO,MAAM,CAAC;AAMvE,IAAM,cAAc,cAAqC,OAAO,aAAa,CAAC;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
btn,
|
|
3
|
+
dis
|
|
4
|
+
} from "./chunk-UB5K44DB.js";
|
|
5
|
+
import {
|
|
6
|
+
TestComponent
|
|
7
|
+
} from "./chunk-ENVUIH2A.js";
|
|
8
|
+
import {
|
|
9
|
+
__decorateClass
|
|
10
|
+
} from "./chunk-44VE5POH.js";
|
|
11
|
+
|
|
12
|
+
// src/lib/qti-test/components/test-prev.ts
|
|
13
|
+
import { css, html } from "lit";
|
|
14
|
+
import { customElement } from "lit/decorators.js";
|
|
15
|
+
var TestPrev = class extends TestComponent {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this._internals.role = "button";
|
|
19
|
+
this._internals.ariaLabel = "Next item";
|
|
20
|
+
this.addEventListener("click", (e) => {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
if (!this.disabled) this._requestItem(this.items[this.itemIndex - 1].identifier);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
willUpdate(changedProperties) {
|
|
26
|
+
super.willUpdate(changedProperties);
|
|
27
|
+
if (changedProperties.has("_testContext")) {
|
|
28
|
+
this.disabled = !this._testElement?.el || this.itemIndex === 0 || this.itemIndex === -1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
return html`<slot></slot>`;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
TestPrev.styles = css`
|
|
36
|
+
:host {
|
|
37
|
+
${btn};
|
|
38
|
+
}
|
|
39
|
+
:host([disabled]) {
|
|
40
|
+
${dis};
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
TestPrev = __decorateClass([
|
|
44
|
+
customElement("test-prev")
|
|
45
|
+
], TestPrev);
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
TestPrev
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-TXRSYXG3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/qti-test/components/test-prev.ts"],"sourcesContent":["import { css, html } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { TestComponent } from './test-component.abstract';\nimport * as styles from './styles';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n@customElement('test-prev')\nexport class TestPrev extends TestComponent {\n static styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this._internals.role = 'button';\n this._internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this.disabled) this._requestItem(this.items[this.itemIndex - 1].identifier);\n });\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate(changedProperties);\n if (changedProperties.has('_testContext')) {\n this.disabled = !this._testElement?.el || this.itemIndex === 0 || this.itemIndex === -1;\n }\n }\n\n render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-previous': TestPrev;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,KAAK,YAAY;AAC1B,SAAS,qBAAqB;AAgBvB,IAAM,WAAN,cAAuB,cAAc;AAAA,EAU1C,cAAc;AACZ,UAAM;AACN,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,YAAY;AAE5B,SAAK,iBAAiB,SAAS,OAAK;AAClC,QAAE,eAAe;AACjB,UAAI,CAAC,KAAK,SAAU,MAAK,aAAa,KAAK,MAAM,KAAK,YAAY,CAAC,EAAE,UAAU;AAAA,IACjF,CAAC;AAAA,EACH;AAAA,EAEA,WAAW,mBAA2D;AACpE,UAAM,WAAW,iBAAiB;AAClC,QAAI,kBAAkB,IAAI,cAAc,GAAG;AACzC,WAAK,WAAW,CAAC,KAAK,cAAc,MAAM,KAAK,cAAc,KAAK,KAAK,cAAc;AAAA,IACvF;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,EACT;AACF;AA/Ba,SACJ,SAAS;AAAA;AAAA,QAEH,GAAG;AAAA;AAAA;AAAA,QAGH,GAAG;AAAA;AAAA;AANL,WAAN;AAAA,EADN,cAAc,WAAW;AAAA,GACb;","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/lib/qti-test/mixins/test-view.mixin.ts
|
|
2
|
+
var TestViewMixin = (superClass) => {
|
|
3
|
+
class TestViewClass extends superClass {
|
|
4
|
+
constructor(...args) {
|
|
5
|
+
super(...args);
|
|
6
|
+
this._testContext = { ...this._testContext, view: "candidate" };
|
|
7
|
+
this.addEventListener("on-test-switch-view", (e) => {
|
|
8
|
+
this._testContext = { ...this._testContext, view: e.detail };
|
|
9
|
+
this._updateElementView();
|
|
10
|
+
});
|
|
11
|
+
this.addEventListener("qti-assessment-test-connected", () => {
|
|
12
|
+
this._updateElementView();
|
|
13
|
+
});
|
|
14
|
+
this.addEventListener("qti-assessment-item-connected", (e) => {
|
|
15
|
+
this._updateElementView();
|
|
16
|
+
this._setCorrectResponseVisibility(e.detail);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
willUpdate(changedProperties) {
|
|
20
|
+
super.willUpdate(changedProperties);
|
|
21
|
+
if (changedProperties.has("_testContext")) {
|
|
22
|
+
this._updateElementView();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Method to handle view updates for elements based on the current context view
|
|
26
|
+
_updateElementView() {
|
|
27
|
+
if (this.testElement && this.testElement.el) {
|
|
28
|
+
const viewElements = Array.from(this.testElement.el.querySelectorAll("[view]"));
|
|
29
|
+
viewElements.forEach((element) => {
|
|
30
|
+
element.classList.toggle("show", element.getAttribute("view") === this._testContext.view);
|
|
31
|
+
});
|
|
32
|
+
const assessmentItem = this.testElement.el.querySelector(
|
|
33
|
+
`qti-assessment-item[identifier="${this._testContext.navItemId}"]`
|
|
34
|
+
);
|
|
35
|
+
if (assessmentItem) {
|
|
36
|
+
assessmentItem.showCorrectResponse(this._testContext.view === "scorer");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Event handler for connected QTI assessment items
|
|
41
|
+
_setCorrectResponseVisibility(assessmentItem) {
|
|
42
|
+
assessmentItem.showCorrectResponse(this._testContext.view === "scorer");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return TestViewClass;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
TestViewMixin
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=chunk-U3RLYKL5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/qti-test/mixins/test-view.mixin.ts"],"sourcesContent":["import { QtiAssessmentItem } from '../../qti-components';\nimport { TestBase } from '../test-base';\n\nexport type View = 'author' | 'candidate' | 'proctor' | 'scorer' | 'testConstructor' | 'tutor' | '';\n\ndeclare module '../context' {\n interface TestContext {\n view?: View;\n }\n}\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestViewInterface {}\n\nexport const TestViewMixin = <T extends Constructor<TestBase>>(superClass: T) => {\n abstract class TestViewClass extends superClass {\n constructor(...args: any[]) {\n super(...args);\n this._testContext = { ...this._testContext, view: 'candidate' };\n\n this.addEventListener('on-test-switch-view', (e: CustomEvent<View>) => {\n this._testContext = { ...this._testContext, view: e.detail };\n this._updateElementView();\n });\n this.addEventListener('qti-assessment-test-connected', () => {\n this._updateElementView();\n });\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent) => {\n this._updateElementView();\n this._setCorrectResponseVisibility(e.detail);\n });\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate(changedProperties);\n if (changedProperties.has('_testContext')) {\n // if (previousContext && previousContext.view !== this._testContext.view) {\n this._updateElementView();\n // }\n }\n }\n\n // Method to handle view updates for elements based on the current context view\n private _updateElementView() {\n if (this.testElement && this.testElement.el) {\n const viewElements = Array.from(this.testElement.el.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', element.getAttribute('view') === this._testContext.view);\n });\n\n const assessmentItem = this.testElement.el.querySelector<QtiAssessmentItem>(\n `qti-assessment-item[identifier=\"${this._testContext.navItemId}\"]`\n );\n if (assessmentItem) {\n assessmentItem.showCorrectResponse(this._testContext.view === 'scorer');\n }\n }\n }\n\n // Event handler for connected QTI assessment items\n private _setCorrectResponseVisibility(assessmentItem: QtiAssessmentItem): void {\n assessmentItem.showCorrectResponse(this._testContext.view === 'scorer');\n }\n }\n\n return TestViewClass as Constructor<TestViewInterface> & T;\n};\n"],"mappings":";AAeO,IAAM,gBAAgB,CAAkC,eAAkB;AAAA,EAC/E,MAAe,sBAAsB,WAAW;AAAA,IAC9C,eAAe,MAAa;AAC1B,YAAM,GAAG,IAAI;AACb,WAAK,eAAe,EAAE,GAAG,KAAK,cAAc,MAAM,YAAY;AAE9D,WAAK,iBAAiB,uBAAuB,CAAC,MAAyB;AACrE,aAAK,eAAe,EAAE,GAAG,KAAK,cAAc,MAAM,EAAE,OAAO;AAC3D,aAAK,mBAAmB;AAAA,MAC1B,CAAC;AACD,WAAK,iBAAiB,iCAAiC,MAAM;AAC3D,aAAK,mBAAmB;AAAA,MAC1B,CAAC;AACD,WAAK,iBAAiB,iCAAiC,CAAC,MAAmB;AACzE,aAAK,mBAAmB;AACxB,aAAK,8BAA8B,EAAE,MAAM;AAAA,MAC7C,CAAC;AAAA,IACH;AAAA,IAEA,WAAW,mBAA2D;AACpE,YAAM,WAAW,iBAAiB;AAClC,UAAI,kBAAkB,IAAI,cAAc,GAAG;AAEzC,aAAK,mBAAmB;AAAA,MAE1B;AAAA,IACF;AAAA;AAAA,IAGQ,qBAAqB;AAC3B,UAAI,KAAK,eAAe,KAAK,YAAY,IAAI;AAC3C,cAAM,eAAe,MAAM,KAAK,KAAK,YAAY,GAAG,iBAAiB,QAAQ,CAAC;AAE9E,qBAAa,QAAQ,CAAC,YAAyB;AAC7C,kBAAQ,UAAU,OAAO,QAAQ,QAAQ,aAAa,MAAM,MAAM,KAAK,aAAa,IAAI;AAAA,QAC1F,CAAC;AAED,cAAM,iBAAiB,KAAK,YAAY,GAAG;AAAA,UACzC,mCAAmC,KAAK,aAAa,SAAS;AAAA,QAChE;AACA,YAAI,gBAAgB;AAClB,yBAAe,oBAAoB,KAAK,aAAa,SAAS,QAAQ;AAAA,QACxE;AAAA,MACF;AAAA,IACF;AAAA;AAAA,IAGQ,8BAA8B,gBAAyC;AAC7E,qBAAe,oBAAoB,KAAK,aAAa,SAAS,QAAQ;AAAA,IACxE;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/lib/qti-test/components/styles.ts
|
|
2
|
+
import { css } from "lit";
|
|
3
|
+
var form = css`
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
padding: 0.5rem 1rem;
|
|
8
|
+
border-radius: 0.25rem;
|
|
9
|
+
user-select: none;
|
|
10
|
+
`;
|
|
11
|
+
var btn = css`
|
|
12
|
+
background-color: lightgray;
|
|
13
|
+
${form};
|
|
14
|
+
`;
|
|
15
|
+
var dis = css`
|
|
16
|
+
cursor: not-allowed;
|
|
17
|
+
opacity: 0.5;
|
|
18
|
+
`;
|
|
19
|
+
var ind = css`
|
|
20
|
+
${form};
|
|
21
|
+
border: 1px solid gray;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
form,
|
|
26
|
+
btn,
|
|
27
|
+
dis,
|
|
28
|
+
ind
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-UB5K44DB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/qti-test/components/styles.ts"],"sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n padding: 0.5rem 1rem;\n border-radius: 0.25rem;\n user-select: none;\n`;\n\nexport const btn = css`\n background-color: lightgray;\n ${form};\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.5;\n`;\n\nexport const ind = css`\n ${form};\n border: 1px solid gray;\n`;\n"],"mappings":";AACA,SAAS,WAAW;AAEb,IAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASb,IAAM,MAAM;AAAA;AAAA,IAEf,IAAI;AAAA;AAGD,IAAM,MAAM;AAAA;AAAA;AAAA;AAKZ,IAAM,MAAM;AAAA,IACf,IAAI;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TestComponent
|
|
3
|
+
} from "./chunk-ENVUIH2A.js";
|
|
4
|
+
import {
|
|
5
|
+
watch
|
|
6
|
+
} from "./chunk-4YG2FPKK.js";
|
|
7
|
+
import {
|
|
8
|
+
__decorateClass
|
|
9
|
+
} from "./chunk-44VE5POH.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/qti-test/components/test-view.ts
|
|
12
|
+
import { html } from "lit";
|
|
13
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
14
|
+
var TestView = class extends TestComponent {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.label = "view";
|
|
18
|
+
this._handleViewOptionsChange = () => {
|
|
19
|
+
this.updateViewOptions();
|
|
20
|
+
};
|
|
21
|
+
this._viewOptions = TestView.DEFAULT_VIEW_OPTIONS;
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.updateViewOptions();
|
|
26
|
+
}
|
|
27
|
+
updateViewOptions() {
|
|
28
|
+
if (this.viewOptions) {
|
|
29
|
+
const options = this.viewOptions.split(",").map((opt) => opt.trim());
|
|
30
|
+
this._viewOptions = options.filter((opt) => TestView.DEFAULT_VIEW_OPTIONS.includes(opt));
|
|
31
|
+
} else {
|
|
32
|
+
this._viewOptions = TestView.DEFAULT_VIEW_OPTIONS;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
return html`
|
|
37
|
+
<label part="label" for="viewSelect">${this.label}</label>
|
|
38
|
+
<select
|
|
39
|
+
part="select"
|
|
40
|
+
id="viewSelect"
|
|
41
|
+
.disabled=${this.disabled}
|
|
42
|
+
@change=${(e) => {
|
|
43
|
+
const el = e.target;
|
|
44
|
+
this._switchView(el.value);
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
${this._viewOptions.map((v) => html`<option value="${v}" ?selected=${v === this.view}>${v}</option>`)}
|
|
48
|
+
</select>
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
TestView.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
|
|
53
|
+
__decorateClass([
|
|
54
|
+
property({ type: String })
|
|
55
|
+
], TestView.prototype, "label", 2);
|
|
56
|
+
__decorateClass([
|
|
57
|
+
property({ type: String, attribute: "view-options" })
|
|
58
|
+
], TestView.prototype, "viewOptions", 2);
|
|
59
|
+
__decorateClass([
|
|
60
|
+
watch("viewOptions", { waitUntilFirstUpdate: true })
|
|
61
|
+
], TestView.prototype, "_handleViewOptionsChange", 2);
|
|
62
|
+
__decorateClass([
|
|
63
|
+
state()
|
|
64
|
+
], TestView.prototype, "_viewOptions", 2);
|
|
65
|
+
TestView = __decorateClass([
|
|
66
|
+
customElement("test-view")
|
|
67
|
+
], TestView);
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
TestView
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=chunk-VODOQFTJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/qti-test/components/test-view.ts"],"sourcesContent":["import { html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { TestComponent } from './test-component.abstract';\nimport { watch } from '../../decorators/watch';\n\n@customElement('test-view')\nexport class TestView extends TestComponent {\n static DEFAULT_VIEW_OPTIONS = ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'];\n\n /** label accompanying the select view dropdown */\n @property({ type: String })\n label = 'view';\n\n /** The options to display in the dropdown, default: ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'] */\n @property({ type: String, attribute: 'view-options' }) viewOptions;\n @watch('viewOptions', { waitUntilFirstUpdate: true })\n protected _handleViewOptionsChange = () => {\n this.updateViewOptions();\n };\n\n connectedCallback(): void {\n super.connectedCallback();\n this.updateViewOptions();\n }\n\n @state()\n private _viewOptions: string[] = TestView.DEFAULT_VIEW_OPTIONS;\n\n private updateViewOptions() {\n if (this.viewOptions) {\n const options = this.viewOptions.split(',').map(opt => opt.trim());\n this._viewOptions = options.filter(opt => TestView.DEFAULT_VIEW_OPTIONS.includes(opt));\n } else {\n this._viewOptions = TestView.DEFAULT_VIEW_OPTIONS;\n }\n }\n\n render() {\n return html`\n <label part=\"label\" for=\"viewSelect\">${this.label}</label>\n <select\n part=\"select\"\n id=\"viewSelect\"\n .disabled=${this.disabled}\n @change=${(e: Event) => {\n const el = e.target as HTMLSelectElement;\n this._switchView(el.value);\n }}\n >\n ${this._viewOptions.map(v => html`<option value=\"${v}\" ?selected=${v === this.view}>${v}</option>`)}\n </select>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-view': TestView;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAAS,eAAe,UAAU,aAAa;AAKxC,IAAM,WAAN,cAAuB,cAAc;AAAA,EAArC;AAAA;AAKL,iBAAQ;AAKR,SAAU,2BAA2B,MAAM;AACzC,WAAK,kBAAkB;AAAA,IACzB;AAQA,SAAQ,eAAyB,SAAS;AAAA;AAAA,EAN1C,oBAA0B;AACxB,UAAM,kBAAkB;AACxB,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAKQ,oBAAoB;AAC1B,QAAI,KAAK,aAAa;AACpB,YAAM,UAAU,KAAK,YAAY,MAAM,GAAG,EAAE,IAAI,SAAO,IAAI,KAAK,CAAC;AACjE,WAAK,eAAe,QAAQ,OAAO,SAAO,SAAS,qBAAqB,SAAS,GAAG,CAAC;AAAA,IACvF,OAAO;AACL,WAAK,eAAe,SAAS;AAAA,IAC/B;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,6CACkC,KAAK,KAAK;AAAA;AAAA;AAAA;AAAA,oBAInC,KAAK,QAAQ;AAAA,kBACf,CAAC,MAAa;AACtB,YAAM,KAAK,EAAE;AACb,WAAK,YAAY,GAAG,KAAK;AAAA,IAC3B,CAAC;AAAA;AAAA,UAEC,KAAK,aAAa,IAAI,OAAK,sBAAsB,CAAC,eAAe,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC;AAAA;AAAA;AAAA,EAGzG;AACF;AA/Ca,SACJ,uBAAuB,CAAC,UAAU,aAAa,WAAW,UAAU,mBAAmB,OAAO;AAIrG;AAAA,EADC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAJf,SAKX;AAGuD;AAAA,EAAtD,SAAS,EAAE,MAAM,QAAQ,WAAW,eAAe,CAAC;AAAA,GAR1C,SAQ4C;AAE7C;AAAA,EADT,MAAM,eAAe,EAAE,sBAAsB,KAAK,CAAC;AAAA,GATzC,SAUD;AAUF;AAAA,EADP,MAAM;AAAA,GAnBI,SAoBH;AApBG,WAAN;AAAA,EADN,cAAc,WAAW;AAAA,GACb;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
qtiTransformItem
|
|
3
|
+
} from "./chunk-2OA7E3E7.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/qti-test/mixins/test-loader.mixin.ts
|
|
6
|
+
var TestLoaderMixin = (superClass) => {
|
|
7
|
+
class TestLoaderClass extends superClass {
|
|
8
|
+
// private testURL = '';
|
|
9
|
+
constructor(...args) {
|
|
10
|
+
super(...args);
|
|
11
|
+
this.addEventListener("qti-assessment-test-connected", () => {
|
|
12
|
+
});
|
|
13
|
+
this.addEventListener("qti-load-item-request", ({ detail }) => {
|
|
14
|
+
detail.promise = (async () => {
|
|
15
|
+
const api = await qtiTransformItem().load(
|
|
16
|
+
`${detail.href}`,
|
|
17
|
+
detail.cancelPreviousRequest
|
|
18
|
+
);
|
|
19
|
+
return api.htmlDoc();
|
|
20
|
+
})();
|
|
21
|
+
});
|
|
22
|
+
this.addEventListener("qti-interaction-changed", (_e) => {
|
|
23
|
+
});
|
|
24
|
+
this.addEventListener("qti-outcome-changed", () => {
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return TestLoaderClass;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
TestLoaderMixin
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=chunk-VW7VIQBE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/qti-test/mixins/test-loader.mixin.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { qtiTransformItem } from '../../qti-transformers';\n\n// const setSessionData = <T>(key: string, value?: T): void => sessionStorage.setItem(key, JSON.stringify(value));\n// const getSessionData = <T>(key: string): T | null => (sessionStorage.getItem(key) ? JSON.parse(sessionStorage.getItem(key)!) : null);\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestLoaderInterface {}\nexport const TestLoaderMixin = <T extends Constructor<LitElement>>(superClass: T) => {\n abstract class TestLoaderClass extends superClass {\n // private testURL = '';\n\n constructor(...args: any[]) {\n super(...args);\n\n // this.addEventListener('qti-load-test-request', (e: CustomEvent /* 1. Request the test */) => {\n // const { testURL } = e.detail;\n // if (!testURL) {\n // console.warn(\n // 'No test found, there should be an attribute test-url with the path to the test on the test-container'\n // );\n // } else {\n // this.testURL = testURL;\n // }\n\n // e.detail.promise = (async () => {\n // e.preventDefault(); /* indicates that the event was catched and handled */\n // const api = await qtiTransformTest().load(`${this.testURL}`); /* 6. load the item */\n // return api.htmlDoc(); /* 3. Return html version of the assessment.xml */\n // })();\n // });\n\n this.addEventListener('qti-assessment-test-connected', () => {\n // this.context = getSessionData(`testcontext-${this.testURL}`); /* 4. Set the context */\n });\n\n this.addEventListener('qti-load-item-request' /* 5. Request the item */, ({ detail }: CustomEvent) => {\n // if (!this.testURL) return;\n detail.promise = (async () => {\n const api = await qtiTransformItem().load(\n `${detail.href}`,\n detail.cancelPreviousRequest\n ); /* 6. load the item */\n return api.htmlDoc(); /* 7. Return HTML version of the item.xml */\n })();\n });\n\n this.addEventListener('qti-interaction-changed', _e => {\n /* 8. Interaction changed */\n // const scoreOutcomeIdentifier = qtiAssessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n // if (scoreOutcomeIdentifier.externalScored === null && qtiAssessmentItem.adaptive === 'false') {\n // qtiAssessmentItem.processResponse(); /* 9. Process the response */\n // }\n // setSessionData(`testcontext-${this.testURL}`, this.context); /* 10. Update the context */\n });\n\n this.addEventListener('qti-outcome-changed', () => {\n // setSessionData(`testcontext-${this.testURL}`, this.context); /* 10. Update the context */\n });\n }\n }\n\n return TestLoaderClass as Constructor<TestLoaderInterface> & T;\n};\n"],"mappings":";;;;;AASO,IAAM,kBAAkB,CAAoC,eAAkB;AAAA,EACnF,MAAe,wBAAwB,WAAW;AAAA;AAAA,IAGhD,eAAe,MAAa;AAC1B,YAAM,GAAG,IAAI;AAmBb,WAAK,iBAAiB,iCAAiC,MAAM;AAAA,MAE7D,CAAC;AAED,WAAK,iBAAiB,yBAAmD,CAAC,EAAE,OAAO,MAAmB;AAEpG,eAAO,WAAW,YAAY;AAC5B,gBAAM,MAAM,MAAM,iBAAiB,EAAE;AAAA,YACnC,GAAG,OAAO,IAAI;AAAA,YACd,OAAO;AAAA,UACT;AACA,iBAAO,IAAI,QAAQ;AAAA,QACrB,GAAG;AAAA,MACL,CAAC;AAED,WAAK,iBAAiB,2BAA2B,QAAM;AAAA,MAOvD,CAAC;AAED,WAAK,iBAAiB,uBAAuB,MAAM;AAAA,MAEnD,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
item_default
|
|
3
|
+
} from "./chunk-3WLCQQN7.js";
|
|
4
|
+
import {
|
|
5
|
+
watch
|
|
6
|
+
} from "./chunk-4YG2FPKK.js";
|
|
7
|
+
import {
|
|
8
|
+
qtiTransformTest
|
|
9
|
+
} from "./chunk-2OA7E3E7.js";
|
|
10
|
+
import {
|
|
11
|
+
__decorateClass
|
|
12
|
+
} from "./chunk-44VE5POH.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-X4ZBUCOD.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';\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-container class=\"m-4 bg-white\" test-url=\"./path/to/assessmenttest.xml\"></test-container>\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,YAAY,YAAY;AACjC,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,aAAa;AAiBf,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,MAAM,MAAM,iBAAiB,EAAE,KAAK,KAAK,OAAO;AACtD,WAAK,UAAU,IAAI,QAAQ;AAAA,IAC7B,SAAS,OAAO;AACd,cAAQ,MAAM,iCAAiC,KAAK;AAAA,IACtD;AAAA,EACF;AAAA,EAGU,sBAAsB;AAC9B,QAAI,CAAC,KAAK,QAAS;AACnB,QAAI;AACF,WAAK,UAAU,iBAAiB,EAAE,MAAM,KAAK,OAAO,EAAE,QAAQ;AAAA,IAChE,SAAS,OAAO;AACd,cAAQ,MAAM,sBAAsB,KAAK;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,MAAM,oBAAmC;AACvC,UAAM,kBAAkB;AACxB,SAAK,0BAA0B;AAC/B,SAAK,YAAY;AACjB,QAAI,KAAK,SAAS;AAChB,WAAK,oBAAoB;AAAA,IAC3B;AACA,QAAI,KAAK,SAAS;AAChB,WAAK,oBAAoB;AAAA,IAC3B;AAAA,EACF;AAAA,EAEQ,4BAA4B;AAClC,UAAM,WAAW,KAAK,cAAc,UAAU;AAC9C,SAAK,kBAAkB,WAAW,SAAS,UAAU;AAAA,EACvD;AAAA,EAEQ,cAAc;AACpB,UAAM,QAAQ,IAAI,cAAc;AAChC,UAAM,YAAY,YAAO;AACzB,SAAK,WAAW,qBAAqB,CAAC,KAAK;AAAA,EAC7C;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,QACH,KAAK,eAAe;AAAA;AAAA,QAEpB,MAAM,KAAK,SAAS,6BAA6B,CAAC;AAAA;AAAA,EAExD;AACF;AAhEE;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,WAAW,WAAW,CAAC;AAAA,GAFtC,cAGX;AAIA;AAAA,EADC,MAAM;AAAA,GANI,cAOX;AAIA;AAAA,EADC,MAAM;AAAA,GAVI,cAWX;AAMgB;AAAA,EADf,MAAM,WAAW,EAAE,sBAAsB,KAAK,CAAC;AAAA,GAhBrC,cAiBK;AAWN;AAAA,EADT,MAAM,WAAW,EAAE,sBAAsB,KAAK,CAAC;AAAA,GA3BrC,cA4BD;AA5BC,gBAAN;AAAA,EADN,cAAc,gBAAgB;AAAA,GAClB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-XFHB6KQW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
item_default
|
|
3
|
+
} from "./chunk-3WLCQQN7.js";
|
|
4
|
+
import {
|
|
5
|
+
watch
|
|
6
|
+
} from "./chunk-4YG2FPKK.js";
|
|
7
|
+
import {
|
|
8
|
+
qtiTransformItem
|
|
9
|
+
} from "./chunk-2OA7E3E7.js";
|
|
10
|
+
import {
|
|
11
|
+
__decorateClass
|
|
12
|
+
} from "./chunk-44VE5POH.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 api = await qtiTransformItem().load(this.itemURL);
|
|
31
|
+
this.itemDoc = 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-XNBWN7N2.js.map
|