@citolab/qti-components 7.3.10 → 7.3.12

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.
Files changed (201) hide show
  1. package/cdn/chunks/chunk-2JVQYBOL.js +3625 -0
  2. package/cdn/chunks/chunk-2VSEUIVB.js +1 -0
  3. package/cdn/chunks/chunk-47NHGZET.js +5 -0
  4. package/cdn/chunks/chunk-4AS52FL7.js +1465 -0
  5. package/cdn/chunks/chunk-5ID7SBIO.js +1465 -0
  6. package/cdn/chunks/chunk-5UMY7JCY.js +5 -0
  7. package/cdn/chunks/chunk-6BKNKZYM.js +1465 -0
  8. package/cdn/chunks/chunk-6IRC2RO4.js +5 -0
  9. package/cdn/chunks/chunk-6OKHEACJ.js +1 -0
  10. package/cdn/chunks/chunk-7HDB4M7P.js +1 -0
  11. package/cdn/chunks/chunk-7HMHA24S.js +5 -0
  12. package/cdn/chunks/chunk-7ME56ODO.js +1 -0
  13. package/cdn/chunks/chunk-AAH4ZU6F.js +5 -0
  14. package/cdn/chunks/chunk-B5GGBXUU.js +1465 -0
  15. package/cdn/chunks/chunk-BUBRM6YY.js +3626 -0
  16. package/cdn/chunks/chunk-CEB2JPDD.js +5 -0
  17. package/cdn/chunks/chunk-CWRTHMN6.js +5 -0
  18. package/cdn/chunks/chunk-DWTKI7M4.js +1465 -0
  19. package/cdn/chunks/chunk-EOD7IKRE.js +1465 -0
  20. package/cdn/chunks/chunk-ES5UNCNZ.js +5 -0
  21. package/cdn/chunks/chunk-EVV26CLF.js +1465 -0
  22. package/cdn/chunks/chunk-FC6TI6YR.js +5 -0
  23. package/cdn/chunks/chunk-FDHY7VVG.js +1 -0
  24. package/cdn/chunks/chunk-FUKWUXAF.js +1465 -0
  25. package/cdn/chunks/chunk-GUNBGKIR.js +5 -0
  26. package/cdn/chunks/chunk-HF3K3TIR.js +5 -0
  27. package/cdn/chunks/chunk-HGGB52KB.js +1465 -0
  28. package/cdn/chunks/chunk-HTMH5X57.js +5 -0
  29. package/cdn/chunks/chunk-ID5LDLCE.js +5 -0
  30. package/cdn/chunks/chunk-IOFQVOMT.js +1 -0
  31. package/cdn/chunks/chunk-IZNAKDMF.js +1465 -0
  32. package/cdn/chunks/chunk-J5BTJG36.js +5 -0
  33. package/cdn/chunks/chunk-JLMFCG5B.js +5 -0
  34. package/cdn/chunks/chunk-JYADQQSZ.js +1 -0
  35. package/cdn/chunks/chunk-KHAZF4GF.js +5 -0
  36. package/cdn/chunks/chunk-KOUKZSFD.js +1465 -0
  37. package/cdn/chunks/chunk-L26UM6DB.js +1465 -0
  38. package/cdn/chunks/chunk-LXVBBP43.js +1465 -0
  39. package/cdn/chunks/chunk-OAXNBPGW.js +1465 -0
  40. package/cdn/chunks/chunk-OEUBDZ2Z.js +5 -0
  41. package/cdn/chunks/chunk-PLC7R6KI.js +1 -0
  42. package/cdn/chunks/chunk-Q4JD7KR5.js +5 -0
  43. package/cdn/chunks/chunk-QNT3HJPP.js +5 -0
  44. package/cdn/chunks/chunk-RDREXATD.js +5 -0
  45. package/cdn/chunks/chunk-TEDCI6KU.js +5 -0
  46. package/cdn/chunks/chunk-U3EASCCV.js +5 -0
  47. package/cdn/chunks/chunk-U72LRX2H.js +5 -0
  48. package/cdn/chunks/chunk-V73WU5EM.js +1 -0
  49. package/cdn/chunks/chunk-VLDCTDHS.js +1465 -0
  50. package/cdn/chunks/chunk-WDYJY74D.js +1465 -0
  51. package/cdn/chunks/chunk-WE5ABYU7.js +5 -0
  52. package/cdn/chunks/chunk-WJNQU6A3.js +1465 -0
  53. package/cdn/chunks/chunk-X4R66SKH.js +5 -0
  54. package/cdn/chunks/chunk-XA3R7EW4.js +5 -0
  55. package/cdn/chunks/chunk-XVL4VYW3.js +5 -0
  56. package/cdn/chunks/chunk-YO2UHEKA.js +5 -0
  57. package/cdn/chunks/chunk-YPZTIY6E.js +5 -0
  58. package/cdn/chunks/chunk-ZMNRWM7K.js +2 -0
  59. package/cdn/exports/config.context.js +1 -1
  60. package/cdn/index.global.js +1 -1
  61. package/cdn/index.js +1 -1
  62. package/cdn/qti-components/index.js +1 -1
  63. package/cdn/qti-item/components/item-container.js +1 -1
  64. package/cdn/qti-item/core/index.js +1 -1
  65. package/cdn/qti-test/components/index.js +1 -1
  66. package/cdn/qti-test/components/test-container.js +1 -1
  67. package/cdn/qti-test/components/test-navigation.js +1 -1
  68. package/cdn/qti-test/core/index.js +1 -1
  69. package/dist/chunks/chunk-3FZAREOR.js +7997 -0
  70. package/dist/chunks/chunk-3FZAREOR.js.map +1 -0
  71. package/dist/chunks/chunk-6TDSFDGN.js +3616 -0
  72. package/dist/chunks/chunk-6TDSFDGN.js.map +1 -0
  73. package/dist/chunks/chunk-7D5T4KXV.js +887 -0
  74. package/dist/chunks/chunk-7D5T4KXV.js.map +1 -0
  75. package/dist/chunks/chunk-7YMQNW6O.js +887 -0
  76. package/dist/chunks/chunk-7YMQNW6O.js.map +1 -0
  77. package/dist/chunks/chunk-AME4WTQI.js +7980 -0
  78. package/dist/chunks/chunk-AME4WTQI.js.map +1 -0
  79. package/dist/chunks/chunk-CCD5MPND.js +887 -0
  80. package/dist/chunks/chunk-CCD5MPND.js.map +1 -0
  81. package/dist/chunks/chunk-DC4UUXIX.js +7979 -0
  82. package/dist/chunks/chunk-DC4UUXIX.js.map +1 -0
  83. package/dist/chunks/chunk-DJ76QOGD.js +887 -0
  84. package/dist/chunks/chunk-DJ76QOGD.js.map +1 -0
  85. package/dist/chunks/chunk-DXXQFGBU.js +7996 -0
  86. package/dist/chunks/chunk-DXXQFGBU.js.map +1 -0
  87. package/dist/chunks/chunk-EO7PHAA6.js +273 -0
  88. package/dist/chunks/chunk-EO7PHAA6.js.map +1 -0
  89. package/dist/chunks/chunk-FDN5O7AK.js +94 -0
  90. package/dist/chunks/chunk-FDN5O7AK.js.map +1 -0
  91. package/dist/chunks/chunk-G45ZYCYM.js +7979 -0
  92. package/dist/chunks/chunk-G45ZYCYM.js.map +1 -0
  93. package/dist/chunks/chunk-GH6YOT4Z.js +912 -0
  94. package/dist/chunks/chunk-GH6YOT4Z.js.map +1 -0
  95. package/dist/chunks/chunk-GMUWDW7R.js +887 -0
  96. package/dist/chunks/chunk-GMUWDW7R.js.map +1 -0
  97. package/dist/chunks/chunk-GTDTNVGA.js +7999 -0
  98. package/dist/chunks/chunk-GTDTNVGA.js.map +1 -0
  99. package/dist/chunks/chunk-HGZO22FW.js +8000 -0
  100. package/dist/chunks/chunk-HGZO22FW.js.map +1 -0
  101. package/dist/chunks/chunk-HMTEOQLK.js +887 -0
  102. package/dist/chunks/chunk-HMTEOQLK.js.map +1 -0
  103. package/dist/chunks/chunk-I6VNEIOO.js +887 -0
  104. package/dist/chunks/chunk-I6VNEIOO.js.map +1 -0
  105. package/dist/chunks/chunk-JIFNLBCM.js +899 -0
  106. package/dist/chunks/chunk-JIFNLBCM.js.map +1 -0
  107. package/dist/chunks/chunk-KQTYZJEP.js +887 -0
  108. package/dist/chunks/chunk-KQTYZJEP.js.map +1 -0
  109. package/dist/chunks/chunk-KU6OS7Z4.js +887 -0
  110. package/dist/chunks/chunk-KU6OS7Z4.js.map +1 -0
  111. package/dist/chunks/chunk-LHADXQQP.js +94 -0
  112. package/dist/chunks/chunk-LHADXQQP.js.map +1 -0
  113. package/dist/chunks/chunk-M64YSODV.js +7979 -0
  114. package/dist/chunks/chunk-M64YSODV.js.map +1 -0
  115. package/dist/chunks/chunk-MAVSEPMA.js +94 -0
  116. package/dist/chunks/chunk-MAVSEPMA.js.map +1 -0
  117. package/dist/chunks/chunk-MLFEYDT7.js +908 -0
  118. package/dist/chunks/chunk-MLFEYDT7.js.map +1 -0
  119. package/dist/chunks/chunk-MMXZGDAT.js +7997 -0
  120. package/dist/chunks/chunk-MMXZGDAT.js.map +1 -0
  121. package/dist/chunks/chunk-MPXKVZFC.js +887 -0
  122. package/dist/chunks/chunk-MPXKVZFC.js.map +1 -0
  123. package/dist/chunks/chunk-MTA2H3BU.js +7993 -0
  124. package/dist/chunks/chunk-MTA2H3BU.js.map +1 -0
  125. package/dist/chunks/chunk-MTL5444I.js +7973 -0
  126. package/dist/chunks/chunk-MTL5444I.js.map +1 -0
  127. package/dist/chunks/chunk-NKDBZGGD.js +887 -0
  128. package/dist/chunks/chunk-NKDBZGGD.js.map +1 -0
  129. package/dist/chunks/chunk-NRQLMN4X.js +7998 -0
  130. package/dist/chunks/chunk-NRQLMN4X.js.map +1 -0
  131. package/dist/chunks/chunk-NYQOS7KY.js +887 -0
  132. package/dist/chunks/chunk-NYQOS7KY.js.map +1 -0
  133. package/dist/chunks/chunk-O6WTIVSY.js +7993 -0
  134. package/dist/chunks/chunk-O6WTIVSY.js.map +1 -0
  135. package/dist/chunks/chunk-OANK3MTL.js +94 -0
  136. package/dist/chunks/chunk-OANK3MTL.js.map +1 -0
  137. package/dist/chunks/chunk-OJ3KRFOY.js +8 -0
  138. package/dist/chunks/chunk-OJ3KRFOY.js.map +1 -0
  139. package/dist/chunks/chunk-QXEVQJLD.js +887 -0
  140. package/dist/chunks/chunk-QXEVQJLD.js.map +1 -0
  141. package/dist/chunks/chunk-S6DAA5HB.js +7999 -0
  142. package/dist/chunks/chunk-S6DAA5HB.js.map +1 -0
  143. package/dist/chunks/chunk-TE67KAZB.js +887 -0
  144. package/dist/chunks/chunk-TE67KAZB.js.map +1 -0
  145. package/dist/chunks/chunk-UHX5D7CV.js +7999 -0
  146. package/dist/chunks/chunk-UHX5D7CV.js.map +1 -0
  147. package/dist/chunks/chunk-UQ7VZAR5.js +913 -0
  148. package/dist/chunks/chunk-UQ7VZAR5.js.map +1 -0
  149. package/dist/chunks/chunk-UQPIW2JA.js +273 -0
  150. package/dist/chunks/chunk-UQPIW2JA.js.map +1 -0
  151. package/dist/chunks/chunk-UWFLBL4E.js +887 -0
  152. package/dist/chunks/chunk-UWFLBL4E.js.map +1 -0
  153. package/dist/chunks/chunk-WDX4DGPI.js +887 -0
  154. package/dist/chunks/chunk-WDX4DGPI.js.map +1 -0
  155. package/dist/chunks/chunk-WFRYU2NH.js +7979 -0
  156. package/dist/chunks/chunk-WFRYU2NH.js.map +1 -0
  157. package/dist/chunks/chunk-XTCNSTB3.js +887 -0
  158. package/dist/chunks/chunk-XTCNSTB3.js.map +1 -0
  159. package/dist/chunks/chunk-YXL7SXEZ.js +887 -0
  160. package/dist/chunks/chunk-YXL7SXEZ.js.map +1 -0
  161. package/dist/chunks/chunk-Z3BYQNR3.js +7993 -0
  162. package/dist/chunks/chunk-Z3BYQNR3.js.map +1 -0
  163. package/dist/chunks/chunk-Z3HTYPLT.js +7999 -0
  164. package/dist/chunks/chunk-Z3HTYPLT.js.map +1 -0
  165. package/dist/chunks/chunk-Z3VRPKNG.js +3615 -0
  166. package/dist/chunks/chunk-Z3VRPKNG.js.map +1 -0
  167. package/dist/chunks/chunk-ZTEVAVEB.js +913 -0
  168. package/dist/chunks/chunk-ZTEVAVEB.js.map +1 -0
  169. package/dist/exports/computed.context.d.ts +1 -1
  170. package/dist/exports/config.context.d.ts +1 -0
  171. package/dist/exports/config.context.js +3 -4
  172. package/dist/exports/config.context.js.map +1 -1
  173. package/dist/exports/session.context.d.ts +1 -1
  174. package/dist/index.d.ts +1 -1
  175. package/dist/index.js +7 -6
  176. package/dist/item.css +9 -9
  177. package/dist/qti-components/index.js +2 -1
  178. package/dist/qti-components-jsx.d.ts +4 -5
  179. package/dist/qti-item/components/item-container.js +2 -2
  180. package/dist/qti-item/core/index.js +2 -2
  181. package/dist/qti-response-declaration-CfyDU6Kk.d.ts +1358 -0
  182. package/dist/qti-test/components/index.d.ts +1 -1
  183. package/dist/qti-test/components/index.js +4 -3
  184. package/dist/qti-test/components/test-container.js +2 -2
  185. package/dist/qti-test/components/test-navigation.d.ts +1 -1
  186. package/dist/qti-test/components/test-navigation.js +2 -1
  187. package/dist/qti-test/components/test-next.d.ts +1 -1
  188. package/dist/qti-test/components/test-prev.d.ts +1 -1
  189. package/dist/qti-test/components/test-print-context.d.ts +1 -1
  190. package/dist/qti-test/components/test-print-item-variables.d.ts +1 -1
  191. package/dist/qti-test/components/test-scoring-buttons.d.ts +1 -1
  192. package/dist/qti-test/components/test-scoring-feedback.d.ts +1 -1
  193. package/dist/qti-test/components/test-show-correct-response.d.ts +1 -1
  194. package/dist/qti-test/core/index.d.ts +2 -2
  195. package/dist/qti-test/core/index.js +3 -2
  196. package/dist/qti-test-feedback-Bvkxw9kw.d.ts +91 -0
  197. package/dist/qti-test-feedback-CQX4RUfl.d.ts +89 -0
  198. package/dist/qti-test-feedback-DIzpz0Rn.d.ts +90 -0
  199. package/dist/qti-test-feedback-DhpyFxel.d.ts +87 -0
  200. package/dist/vscode.html-custom-data.json +0 -2
  201. package/package.json +1 -1
@@ -0,0 +1,273 @@
1
+ import {
2
+ sessionContext
3
+ } from "./chunk-22IRJWWY.js";
4
+ import {
5
+ testContext
6
+ } from "./chunk-CJADUWEC.js";
7
+ import {
8
+ computedContext
9
+ } from "./chunk-AZIKAG7K.js";
10
+ import {
11
+ configContext
12
+ } from "./chunk-OJ3KRFOY.js";
13
+ import {
14
+ __decorateClass
15
+ } from "./chunk-H2JE6IVU.js";
16
+
17
+ // src/lib/qti-test/components/test-navigation.ts
18
+ import { consume, provide } from "@lit/context";
19
+ import { html, LitElement } from "lit";
20
+ import { customElement, property, state } from "lit/decorators.js";
21
+ var TestNavigation = class extends LitElement {
22
+ constructor() {
23
+ super();
24
+ this.identifier = void 0;
25
+ this.initContext = [];
26
+ this.configContext = {};
27
+ this.autoScoreItems = false;
28
+ this.addEventListener("qti-assessment-test-connected", this._handleTestConnected.bind(this));
29
+ this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
30
+ this.addEventListener("qti-interaction-changed", this._handleInteractionChanged.bind(this));
31
+ this.addEventListener("test-end-attempt", this._handleTestEndAttempt.bind(this));
32
+ this.addEventListener("test-show-correct-response", this._handleTestShowCorrectResponse.bind(this));
33
+ this.addEventListener("test-update-outcome-variable", this._handleTestUpdateOutcomeVariable.bind(this));
34
+ }
35
+ /**
36
+ * Handles the 'test-end-attempt' event.
37
+ * @private
38
+ * @listens TestNavigation#test-end-attempt
39
+ * @param {CustomEvent} event - The custom event object.
40
+ */
41
+ _handleTestEndAttempt(_event) {
42
+ const qtiItemEl = this._testElement.querySelector(
43
+ `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
44
+ );
45
+ const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
46
+ const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
47
+ qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
48
+ }
49
+ // protected createRenderRoot(): HTMLElement | DocumentFragment {
50
+ // return this;
51
+ // }
52
+ // myTemplate: TemplateFunction;
53
+ // connectedCallback(): void {
54
+ // super.connectedCallback();
55
+ // const templateElement = this.querySelector<HTMLTemplateElement>('template');
56
+ // if (!templateElement) {
57
+ // this.myTemplate = null;
58
+ // return;
59
+ // }
60
+ // this.myTemplate = prepareTemplate(templateElement);
61
+ // }
62
+ /**
63
+ * Handles the 'test-end-attempt' event.
64
+ * @private
65
+ * @listens TestNavigation#test-show-correct-response
66
+ * @param {CustomEvent} event - The custom event object.
67
+ */
68
+ _handleTestShowCorrectResponse(event) {
69
+ const qtiItemEl = this._testElement.querySelector(
70
+ `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
71
+ );
72
+ const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
73
+ qtiAssessmentItemEl.showCorrectResponse(event.detail);
74
+ }
75
+ _handleTestUpdateOutcomeVariable(event) {
76
+ const qtiItemEl = this._testElement.querySelector(
77
+ `qti-assessment-item-ref[identifier="${event.detail.assessmentItemRefId}"]`
78
+ );
79
+ const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
80
+ qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
81
+ }
82
+ _handleInteractionChanged(_event) {
83
+ if (this.autoScoreItems) {
84
+ const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
85
+ const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
86
+ if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
87
+ const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
88
+ assessmentItem.processResponse(true, reportValidityAfterScoring);
89
+ }
90
+ }
91
+ }
92
+ render() {
93
+ return html`<slot></slot>`;
94
+ }
95
+ /* PK: on test connected we can build the computed context */
96
+ _handleTestConnected(event) {
97
+ this._testElement = event.detail;
98
+ const testPartElements = Array.from(this._testElement?.querySelectorAll(`qti-test-part`) || []);
99
+ this.computedContext = {
100
+ identifier: this._testElement.identifier,
101
+ title: this._testElement.title,
102
+ view: this._sessionContext?.view,
103
+ testParts: testPartElements.map((testPart) => {
104
+ const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
105
+ return {
106
+ active: false,
107
+ identifier: testPart.identifier,
108
+ navigationMode: testPart.navigationMode,
109
+ submissionMode: testPart.submissionMode,
110
+ sections: sectionElements.map((section) => {
111
+ const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
112
+ return {
113
+ active: false,
114
+ identifier: section.identifier,
115
+ title: section.title,
116
+ items: itemElements.map((item) => ({
117
+ ...this.initContext?.find((i) => i.identifier === item.identifier),
118
+ active: false,
119
+ identifier: item.identifier,
120
+ categories: item.category ? item.category?.split(" ") : [],
121
+ href: item.href,
122
+ variables: []
123
+ }))
124
+ };
125
+ })
126
+ };
127
+ })
128
+ };
129
+ }
130
+ /* PK: on item connected we can add item only properties in the xml */
131
+ _handleItemConnected(event) {
132
+ const itemElement = event.detail;
133
+ this.computedContext = {
134
+ ...this.computedContext,
135
+ testParts: this.computedContext.testParts.map((testPart) => {
136
+ return {
137
+ ...testPart,
138
+ sections: testPart.sections.map((section) => {
139
+ return {
140
+ ...section,
141
+ items: section.items.map((item) => {
142
+ if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
143
+ return item;
144
+ }
145
+ const scoreOutcome = itemElement.querySelector(
146
+ "qti-outcome-declaration[identifier='SCORE']"
147
+ );
148
+ const externalScored = scoreOutcome?.getAttribute("externalScored");
149
+ const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
150
+ const containsCorrectResponse = Array.from(responseDeclarations).some(
151
+ (r) => r.querySelector("qti-correct-response")
152
+ );
153
+ const containsMapping = Array.from(responseDeclarations).some((r) => {
154
+ const mapping = r.querySelector("qti-mapping");
155
+ const areaMapping = r.querySelector("qti-area-mapping");
156
+ return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
157
+ });
158
+ const hasCorrectResponse = containsCorrectResponse || containsMapping;
159
+ const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
160
+ return {
161
+ ...item,
162
+ assessmentItemIdentifier: itemElement.getAttribute("identifier"),
163
+ label: itemElement.getAttribute("label"),
164
+ title: itemElement.title,
165
+ externalScored,
166
+ adaptive: itemElement.adaptive == "true" || false,
167
+ timeDependent: itemElement.timeDependent == "true" || false,
168
+ variables: itemElement.variables,
169
+ hasCorrectResponse,
170
+ hasResponseProcessing
171
+ };
172
+ })
173
+ };
174
+ })
175
+ };
176
+ })
177
+ };
178
+ }
179
+ /* PK: on every change of the candidate we will recomputed the computedContext */
180
+ willUpdate(_changedProperties) {
181
+ if (!this.computedContext) return;
182
+ let itemIndex = 1;
183
+ this.computedContext = {
184
+ ...this.computedContext,
185
+ view: this._sessionContext?.view,
186
+ testParts: this.computedContext.testParts.map((testPart) => {
187
+ return {
188
+ ...testPart,
189
+ active: this._sessionContext?.navPartId === testPart.identifier || false,
190
+ sections: testPart.sections.map((section) => {
191
+ return {
192
+ ...section,
193
+ active: this._sessionContext?.navSectionId === section.identifier || false,
194
+ completed: section.items.every(
195
+ (item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"
196
+ ),
197
+ items: section.items.map((item) => {
198
+ const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
199
+ const computedItem = {
200
+ ...item,
201
+ ...itemContext,
202
+ ...this.initContext?.find((i) => i.identifier === item.identifier)
203
+ };
204
+ const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
205
+ const score = parseInt(rawscore?.toString());
206
+ const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
207
+ const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
208
+ const numAttempts = computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value || 0;
209
+ const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
210
+ const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
211
+ const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
212
+ const maxScore = parseInt(rawMaxScore?.toString());
213
+ return {
214
+ ...computedItem,
215
+ completionStatus,
216
+ numAttempts,
217
+ score,
218
+ response,
219
+ index,
220
+ // type,
221
+ active,
222
+ // correct,
223
+ maxScore
224
+ // incorrect,
225
+ // completed
226
+ };
227
+ })
228
+ };
229
+ })
230
+ };
231
+ })
232
+ };
233
+ this.dispatchEvent(
234
+ new CustomEvent("qti-computed-context-updated", {
235
+ detail: this.computedContext,
236
+ bubbles: true
237
+ })
238
+ );
239
+ }
240
+ };
241
+ __decorateClass([
242
+ property({ type: String })
243
+ ], TestNavigation.prototype, "identifier", 2);
244
+ __decorateClass([
245
+ state()
246
+ ], TestNavigation.prototype, "initContext", 2);
247
+ __decorateClass([
248
+ state(),
249
+ provide({ context: configContext })
250
+ ], TestNavigation.prototype, "configContext", 2);
251
+ __decorateClass([
252
+ state(),
253
+ consume({ context: testContext, subscribe: true })
254
+ ], TestNavigation.prototype, "_testContext", 2);
255
+ __decorateClass([
256
+ state(),
257
+ consume({ context: sessionContext, subscribe: true })
258
+ ], TestNavigation.prototype, "_sessionContext", 2);
259
+ __decorateClass([
260
+ state(),
261
+ provide({ context: computedContext })
262
+ ], TestNavigation.prototype, "computedContext", 2);
263
+ __decorateClass([
264
+ property({ type: Boolean, attribute: "auto-score-items" })
265
+ ], TestNavigation.prototype, "autoScoreItems", 2);
266
+ TestNavigation = __decorateClass([
267
+ customElement("test-navigation")
268
+ ], TestNavigation);
269
+
270
+ export {
271
+ TestNavigation
272
+ };
273
+ //# sourceMappingURL=chunk-EO7PHAA6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/qti-test/components/test-navigation.ts"],"sourcesContent":["import { consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n// import { prepareTemplate } from 'stampino';\n\nimport { testContext } from '../../exports/test.context';\nimport { sessionContext } from '../../exports/session.context';\nimport { computedContext } from '../../exports/computed.context';\n\n// import type { View } from '../core/mixins/test-view.mixin';\n// import type { TemplateFunction } from 'stampino';\nimport { configContext, type ConfigContext } from '../../exports/config.context';\n\nimport type { QtiAssessmentItem } from '../../qti-components';\nimport type { OutcomeVariable } from '../../exports/variables';\nimport type { ComputedContext } from '../../exports/computed.context';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef, QtiAssessmentSection, QtiAssessmentTest, QtiTestPart } from '../core';\nimport type { SessionContext } from '../../exports/session.context';\nimport type { TestContext } from '../../exports/test.context';\n\ntype CustomEventMap = {\n 'test-end-attempt': CustomEvent;\n 'test-show-correct-response': CustomEvent<{ value: boolean }>;\n};\n\ndeclare global {\n interface GlobalEventHandlersEventMap extends CustomEventMap {}\n}\n\n@customElement('test-navigation')\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier = undefined;\n\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n // @state()\n // private stampContext: {\n // view?: View;\n // test?: unknown;\n // activeTestpart?: unknown;\n // activeSection?: unknown;\n // activeItem?: unknown;\n // } = {\n // view: 'candidate',\n // activeItem: {},\n // activeSection: {\n // items: []\n // },\n // activeTestpart: {\n // items: []\n // },\n // test: {}\n // };\n // @property({ type: Boolean, reflect: true }) public debug = false;\n\n private _testElement: QtiAssessmentTest;\n\n constructor() {\n super();\n this.addEventListener('qti-assessment-test-connected', this._handleTestConnected.bind(this));\n this.addEventListener('qti-assessment-item-connected', this._handleItemConnected.bind(this));\n\n this.addEventListener('qti-interaction-changed', this._handleInteractionChanged.bind(this));\n\n this.addEventListener('test-end-attempt', this._handleTestEndAttempt.bind(this));\n this.addEventListener('test-show-correct-response', this._handleTestShowCorrectResponse.bind(this));\n this.addEventListener('test-update-outcome-variable', this._handleTestUpdateOutcomeVariable.bind(this));\n }\n\n /**\n * Handles the 'test-end-attempt' event.\n * @private\n * @listens TestNavigation#test-end-attempt\n * @param {CustomEvent} event - The custom event object.\n */\n private _handleTestEndAttempt(_event: CustomEvent) {\n const qtiItemEl = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n );\n const qtiAssessmentItemEl = qtiItemEl.assessmentItem;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n // protected createRenderRoot(): HTMLElement | DocumentFragment {\n // return this;\n // }\n\n // myTemplate: TemplateFunction;\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 /**\n * Handles the 'test-end-attempt' event.\n * @private\n * @listens TestNavigation#test-show-correct-response\n * @param {CustomEvent} event - The custom event object.\n */\n private _handleTestShowCorrectResponse(event: CustomEvent) {\n const qtiItemEl = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n );\n const qtiAssessmentItemEl = qtiItemEl.assessmentItem;\n qtiAssessmentItemEl.showCorrectResponse(event.detail);\n }\n\n private _handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiItemEl = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${event.detail.assessmentItemRefId}\"]`\n );\n const qtiAssessmentItemEl = qtiItemEl.assessmentItem;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n private _handleInteractionChanged(_event: CustomEvent) {\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest('qti-assessment-item');\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n render() {\n // return this.myTemplate ? this.myTemplate(this.stampContext) : nothing;\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n private _handleTestConnected(event: CustomEvent) {\n this._testElement = event.detail as QtiAssessmentTest;\n const testPartElements = Array.from(this._testElement?.querySelectorAll<QtiTestPart>(`qti-test-part`) || []);\n this.computedContext = {\n identifier: this._testElement.identifier,\n title: this._testElement.title,\n view: this._sessionContext?.view,\n testParts: testPartElements.map(testPart => {\n const sectionElements = [...testPart.querySelectorAll<QtiAssessmentSection>(`qti-assessment-section`)];\n return {\n active: false,\n identifier: testPart.identifier,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n sections: sectionElements.map(section => {\n const itemElements = [...section.querySelectorAll<QtiAssessmentItemRef>(`qti-assessment-item-ref`)];\n return {\n active: false,\n identifier: section.identifier,\n title: section.title,\n items: itemElements.map(item => ({\n ...this.initContext?.find(i => i.identifier === item.identifier),\n active: false,\n identifier: item.identifier,\n categories: item.category ? item.category?.split(' ') : [],\n href: item.href,\n variables: []\n }))\n };\n })\n };\n })\n };\n }\n\n /* PK: on item connected we can add item only properties in the xml */\n private _handleItemConnected(event: CustomEvent) {\n const itemElement = event.detail as QtiAssessmentItem;\n\n this.computedContext = {\n ...this.computedContext,\n testParts: this.computedContext.testParts.map(testPart => {\n return {\n ...testPart,\n sections: testPart.sections.map(section => {\n return {\n ...section,\n items: section.items.map(item => {\n if (item.identifier !== itemElement.parentElement.getAttribute('identifier')) {\n return item;\n }\n\n const scoreOutcome = itemElement.querySelector<HTMLElement>(\n \"qti-outcome-declaration[identifier='SCORE']\"\n );\n // const scoreOutcome = item.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n const externalScored = scoreOutcome?.getAttribute('externalScored');\n\n const responseDeclarations = itemElement.querySelectorAll<HTMLElement>('qti-response-declaration');\n const containsCorrectResponse = Array.from(responseDeclarations).some(r =>\n r.querySelector('qti-correct-response')\n );\n // check if every responseDeclaration has a correctResponse\n const containsMapping = Array.from(responseDeclarations).some(r => {\n const mapping = r.querySelector('qti-mapping');\n const areaMapping = r.querySelector('qti-area-mapping');\n return mapping?.querySelector('qti-map-entry') || areaMapping?.querySelector('qti-area-map-entry');\n });\n\n const hasCorrectResponse = containsCorrectResponse || containsMapping;\n\n const hasResponseProcessing = itemElement.querySelector('qti-response-processing') ? true : false;\n\n return {\n ...item,\n assessmentItemIdentifier: itemElement.getAttribute('identifier'),\n label: itemElement.getAttribute('label'),\n title: itemElement.title,\n externalScored,\n adaptive: itemElement.adaptive == 'true' || false,\n timeDependent: itemElement.timeDependent == 'true' || false,\n variables: itemElement.variables,\n hasCorrectResponse,\n hasResponseProcessing\n };\n })\n };\n })\n };\n })\n };\n }\n\n /* PK: on every change of the candidate we will recomputed the computedContext */\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) return;\n\n let itemIndex = 1;\n this.computedContext = {\n ...this.computedContext,\n view: this._sessionContext?.view,\n testParts: this.computedContext.testParts.map(testPart => {\n return {\n ...testPart,\n active: this._sessionContext?.navPartId === testPart.identifier || false,\n sections: testPart.sections.map(section => {\n return {\n ...section,\n active: this._sessionContext?.navSectionId === section.identifier || false,\n completed: section.items.every(\n item =>\n this._testContext.items\n .find(i => i.identifier === item.identifier)\n ?.variables.find(v => v.identifier === 'completionStatus').value === 'completed'\n ),\n\n items: section.items.map(item => {\n const itemContext = this._testContext?.items.find(i => i.identifier === item.identifier);\n const computedItem = {\n ...item,\n ...itemContext,\n ...this.initContext?.find(i => i.identifier === item.identifier)\n };\n\n const rawscore = computedItem.variables?.find(vr => vr.identifier == 'SCORE')?.value;\n const score = parseInt(rawscore?.toString());\n\n const completionStatus = computedItem.variables?.find(v => v.identifier === 'completionStatus')\n ?.value as string;\n\n const response = computedItem.variables?.find(v => v.identifier === 'RESPONSE')?.value || '';\n const numAttempts = computedItem.variables?.find(v => v.identifier === 'numAttempts')?.value || 0;\n\n const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;\n\n // Computed and opiniated\n // const type = item.categories.includes(this.configContext?.infoItemCategory) ? 'info' : 'regular';\n // const correct = (type == 'regular' && score !== undefined && !isNaN(score) && score > 0) || false;\n // const incorrect = (type == 'regular' && score !== undefined && !isNaN(score) && score <= 0) || false;\n // const completed = completionStatus === 'completed';\n\n const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;\n const rawMaxScore = item.variables?.find(vr => vr.identifier == 'MAXSCORE')?.value;\n const maxScore = parseInt(rawMaxScore?.toString());\n\n return {\n ...computedItem,\n completionStatus,\n numAttempts,\n score,\n response,\n index,\n // type,\n active,\n // correct,\n maxScore\n // incorrect,\n // completed\n };\n })\n };\n })\n };\n })\n };\n\n // const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n // const activeSection = activeTestPart?.sections.find(section => section.active);\n // const activeItem = activeSection?.items.find(item => item.active);\n // const { variables, ...augmentedItem } = activeItem || {};\n\n // if (!activeTestPart || !activeSection || !activeItem) {\n // this.stampContext = null;\n // return;\n // }\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 augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables, ...rest }) => rest) };\n // const { testParts, ...activeTest } = this.computedContext;\n\n // this.stampContext = {\n // view: this.computedContext.view,\n // activeItem: augmentedItem,\n // activeSection: augmentedSection,\n // activeTestpart: augmentedTestPart,\n // test: activeTest\n // };\n\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,eAAe;AACjC,SAAS,MAAM,kBAAkB;AACjC,SAAS,eAAe,UAAU,aAAa;AA6BxC,IAAM,iBAAN,cAA6B,WAAW;AAAA,EA8C7C,cAAc;AACZ,UAAM;AA9CoB,sBAAa;AAGzC,SAAO,cAA4D,CAAC;AAIpE,SAAO,gBAA+B,CAAC;AAcqB,0BAAiB;AA0B3E,SAAK,iBAAiB,iCAAiC,KAAK,qBAAqB,KAAK,IAAI,CAAC;AAC3F,SAAK,iBAAiB,iCAAiC,KAAK,qBAAqB,KAAK,IAAI,CAAC;AAE3F,SAAK,iBAAiB,2BAA2B,KAAK,0BAA0B,KAAK,IAAI,CAAC;AAE1F,SAAK,iBAAiB,oBAAoB,KAAK,sBAAsB,KAAK,IAAI,CAAC;AAC/E,SAAK,iBAAiB,8BAA8B,KAAK,+BAA+B,KAAK,IAAI,CAA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unk-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-FDN5O7AK.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,YAAY,YAAY;AACjC,SAAS,eAAe,UAAU,aAAa;AAC/C,SAAS,aAAa;AAoBf,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;A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