@citolab/qti-components 7.3.23 → 7.4.1

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 (293) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +5485 -1
  3. package/custom-elements.json +29837 -0
  4. package/dist/chunks/chunk-4BDOB6KY.js +365 -0
  5. package/dist/chunks/chunk-4BDOB6KY.js.map +1 -0
  6. package/dist/chunks/{chunk-LF6SO3JU.js → chunk-7RW7LCEJ.js} +459 -587
  7. package/dist/chunks/chunk-7RW7LCEJ.js.map +1 -0
  8. package/dist/chunks/chunk-APBAIN6D.js +2237 -0
  9. package/dist/chunks/chunk-APBAIN6D.js.map +1 -0
  10. package/dist/chunks/{chunk-22IRJWWY.js → chunk-C5RLRG3L.js} +1 -1
  11. package/dist/chunks/chunk-C5RLRG3L.js.map +1 -0
  12. package/dist/chunks/{chunk-AZIKAG7K.js → chunk-DVQQ7I6Y.js} +1 -1
  13. package/dist/chunks/chunk-DVQQ7I6Y.js.map +1 -0
  14. package/dist/chunks/{chunk-QCB6P7DH.js → chunk-GAAFN7QF.js} +1 -1
  15. package/dist/chunks/{chunk-QCB6P7DH.js.map → chunk-GAAFN7QF.js.map} +1 -1
  16. package/dist/chunks/chunk-K47QFOQX.js +175 -0
  17. package/dist/chunks/chunk-K47QFOQX.js.map +1 -0
  18. package/dist/chunks/{chunk-FL72PF4D.js → chunk-SV4K25ZI.js} +2 -2
  19. package/dist/custom-elements.json +29837 -0
  20. package/dist/exports/computed-item.context.d.ts +1 -7
  21. package/dist/exports/computed.context.d.ts +2 -10
  22. package/dist/exports/computed.context.js +1 -1
  23. package/dist/exports/interaction.d.ts +45 -7
  24. package/dist/exports/item.context.d.ts +10 -7
  25. package/dist/exports/qti-assessment-item.context.d.ts +2 -7
  26. package/dist/exports/qti-condition-expression.d.ts +4 -5
  27. package/dist/exports/qti-condition-expression.js +2 -2
  28. package/dist/exports/qti-expression.d.ts +22 -7
  29. package/dist/exports/qti-expression.js +1 -1
  30. package/dist/exports/qti-test.d.ts +10 -38
  31. package/dist/exports/session.context.d.ts +2 -13
  32. package/dist/exports/session.context.js +1 -1
  33. package/dist/exports/test.context.d.ts +2 -7
  34. package/dist/exports/variables.d.ts +1 -7
  35. package/dist/index.d.ts +12 -31
  36. package/dist/index.js +38 -95
  37. package/{cdn/chunks/chunk-5TDBMEY5.js → dist/item.css} +7 -24
  38. package/dist/qti-assessment-item-l-mN3teH.d.ts +105 -0
  39. package/dist/qti-components/index.d.ts +1173 -16
  40. package/dist/qti-components/index.js +6 -5
  41. package/dist/qti-components-jsx.d.ts +4463 -0
  42. package/dist/qti-item/index.d.ts +114 -0
  43. package/dist/qti-item/index.js +19 -0
  44. package/dist/qti-loader/index.d.ts +2 -5
  45. package/dist/qti-loader/index.js +24 -4
  46. package/dist/qti-loader/index.js.map +1 -1
  47. package/dist/qti-modal-feedback-PKbhO-3w.d.ts +30 -0
  48. package/dist/qti-test/index.d.ts +480 -0
  49. package/dist/qti-test/index.js +69 -0
  50. package/dist/{qti-test-feedback-CZsbp6z4.d.ts → qti-test-BwvOhz_-.d.ts} +45 -18
  51. package/dist/variables-BCkyLoXK.d.ts +55 -0
  52. package/dist/vscode.css-custom-data.json +11 -0
  53. package/dist/vscode.html-custom-data.json +1135 -0
  54. package/package.json +74 -116
  55. package/cdn/chunks/chunk-2BSPQRNR.js +0 -6
  56. package/cdn/chunks/chunk-3CVBBZDT.js +0 -17
  57. package/cdn/chunks/chunk-3IBGLVHA.js +0 -1
  58. package/cdn/chunks/chunk-3YQMAZEO.js +0 -29
  59. package/cdn/chunks/chunk-5UQLGV7F.js +0 -5
  60. package/cdn/chunks/chunk-5WLHU3FH.js +0 -8
  61. package/cdn/chunks/chunk-6SGFGN34.js +0 -8
  62. package/cdn/chunks/chunk-6XVY32RS.js +0 -1
  63. package/cdn/chunks/chunk-7ME56ODO.js +0 -1
  64. package/cdn/chunks/chunk-CZDMOYYF.js +0 -1
  65. package/cdn/chunks/chunk-DNBBQ7LY.js +0 -1
  66. package/cdn/chunks/chunk-DP5FVJRS.js +0 -21
  67. package/cdn/chunks/chunk-E6IOJ4MV.js +0 -23
  68. package/cdn/chunks/chunk-G76Y52EL.js +0 -1471
  69. package/cdn/chunks/chunk-HCXHHI6V.js +0 -18
  70. package/cdn/chunks/chunk-HDMF4QZO.js +0 -48
  71. package/cdn/chunks/chunk-HKWYQB5Z.js +0 -37
  72. package/cdn/chunks/chunk-J5P2GBPV.js +0 -1
  73. package/cdn/chunks/chunk-KWPDTFYH.js +0 -1
  74. package/cdn/chunks/chunk-LIUOA3YV.js +0 -1
  75. package/cdn/chunks/chunk-LO2NM3CE.js +0 -1
  76. package/cdn/chunks/chunk-MD33BNWM.js +0 -1
  77. package/cdn/chunks/chunk-MRQ46JRY.js +0 -8
  78. package/cdn/chunks/chunk-NJP4VZB3.js +0 -8
  79. package/cdn/chunks/chunk-O4RAJ3LM.js +0 -25
  80. package/cdn/chunks/chunk-OSLUHYFD.js +0 -8
  81. package/cdn/chunks/chunk-P6SSTAJ2.js +0 -1
  82. package/cdn/chunks/chunk-PP62N3C4.js +0 -8
  83. package/cdn/chunks/chunk-PU7OABT3.js +0 -1
  84. package/cdn/chunks/chunk-PUI3LIFH.js +0 -0
  85. package/cdn/chunks/chunk-QBAXWCYQ.js +0 -5
  86. package/cdn/chunks/chunk-QEFO63QX.js +0 -8
  87. package/cdn/chunks/chunk-QQCGUVEV.js +0 -1
  88. package/cdn/chunks/chunk-QQR6POPY.js +0 -1
  89. package/cdn/chunks/chunk-RGNFAPWY.js +0 -2
  90. package/cdn/chunks/chunk-S5QDLZ6J.js +0 -1
  91. package/cdn/chunks/chunk-SEM2PEP6.js +0 -5
  92. package/cdn/chunks/chunk-SVVO2SFS.js +0 -1
  93. package/cdn/chunks/chunk-TCHROQU3.js +0 -1
  94. package/cdn/chunks/chunk-UMDZKG6K.js +0 -1
  95. package/cdn/chunks/chunk-VEG7LKS3.js +0 -48
  96. package/cdn/chunks/chunk-WCCTDLQ4.js +0 -8
  97. package/cdn/chunks/chunk-X4FA36TC.js +0 -1
  98. package/cdn/chunks/chunk-XJ2CFTZP.js +0 -1
  99. package/cdn/chunks/chunk-XUJ7TXHW.js +0 -1
  100. package/cdn/chunks/chunk-YCBNF5QU.js +0 -17
  101. package/cdn/chunks/chunk-YHLQ2JQ2.js +0 -1
  102. package/cdn/chunks/chunk-ZPCQH3EY.js +0 -10
  103. package/cdn/exports/computed-item.context.js +0 -1
  104. package/cdn/exports/computed.context.js +0 -1
  105. package/cdn/exports/config.context.js +0 -1
  106. package/cdn/exports/expression-result.js +0 -0
  107. package/cdn/exports/interaction.interface.js +0 -0
  108. package/cdn/exports/interaction.js +0 -1
  109. package/cdn/exports/item.context.js +0 -1
  110. package/cdn/exports/qti-assessment-item.context.js +0 -1
  111. package/cdn/exports/qti-condition-expression.js +0 -1
  112. package/cdn/exports/qti-expression.js +0 -1
  113. package/cdn/exports/qti-test.js +0 -0
  114. package/cdn/exports/qti.context.js +0 -1
  115. package/cdn/exports/session.context.js +0 -1
  116. package/cdn/exports/test.context.js +0 -1
  117. package/cdn/exports/variables.js +0 -0
  118. package/cdn/qti-components/index.js +0 -1
  119. package/cdn/qti-item/components/item-container.js +0 -1
  120. package/cdn/qti-item/components/item-correct-response-mode.js +0 -10
  121. package/cdn/qti-item/components/item-show-candidate-correction.js +0 -8
  122. package/cdn/qti-item/components/item-show-correct-response.js +0 -1
  123. package/cdn/qti-item/components/print-item-variables.js +0 -1
  124. package/cdn/qti-item/components/styles.js +0 -1
  125. package/cdn/qti-item/core/index.js +0 -1
  126. package/cdn/qti-loader/index.js +0 -1
  127. package/cdn/qti-test/components/index.js +0 -1
  128. package/cdn/qti-test/components/styles.js +0 -1
  129. package/cdn/qti-test/components/test-check-item.js +0 -1
  130. package/cdn/qti-test/components/test-container.js +0 -1
  131. package/cdn/qti-test/components/test-end-attempt.js +0 -1
  132. package/cdn/qti-test/components/test-item-link.js +0 -1
  133. package/cdn/qti-test/components/test-navigation.js +0 -1
  134. package/cdn/qti-test/components/test-next.js +0 -1
  135. package/cdn/qti-test/components/test-paging-buttons-stamp.js +0 -1
  136. package/cdn/qti-test/components/test-prev.js +0 -1
  137. package/cdn/qti-test/components/test-print-context.js +0 -1
  138. package/cdn/qti-test/components/test-print-item-variables.js +0 -1
  139. package/cdn/qti-test/components/test-scoring-buttons.js +0 -1
  140. package/cdn/qti-test/components/test-scoring-feedback.js +0 -1
  141. package/cdn/qti-test/components/test-section-buttons-stamp.js +0 -1
  142. package/cdn/qti-test/components/test-section-link.js +0 -1
  143. package/cdn/qti-test/components/test-show-correct-response.js +0 -1
  144. package/cdn/qti-test/components/test-stamp.js +0 -1
  145. package/cdn/qti-test/components/test-view-toggle.js +0 -1
  146. package/cdn/qti-test/components/test-view.js +0 -1
  147. package/cdn/qti-test/core/index.js +0 -1
  148. package/cdn/qti-transformers/index.js +0 -1
  149. package/dist/chunks/chunk-22IRJWWY.js.map +0 -1
  150. package/dist/chunks/chunk-36G5MQKR.js +0 -85
  151. package/dist/chunks/chunk-36G5MQKR.js.map +0 -1
  152. package/dist/chunks/chunk-5KCXO2RP.js +0 -36
  153. package/dist/chunks/chunk-5KCXO2RP.js.map +0 -1
  154. package/dist/chunks/chunk-5ZHHNEDA.js +0 -30
  155. package/dist/chunks/chunk-5ZHHNEDA.js.map +0 -1
  156. package/dist/chunks/chunk-7K44TDQO.js +0 -91
  157. package/dist/chunks/chunk-7K44TDQO.js.map +0 -1
  158. package/dist/chunks/chunk-7OMJMXHK.js +0 -50
  159. package/dist/chunks/chunk-7OMJMXHK.js.map +0 -1
  160. package/dist/chunks/chunk-AZIKAG7K.js.map +0 -1
  161. package/dist/chunks/chunk-BLBSZDQ4.js +0 -52
  162. package/dist/chunks/chunk-BLBSZDQ4.js.map +0 -1
  163. package/dist/chunks/chunk-CP34TICQ.js +0 -45
  164. package/dist/chunks/chunk-CP34TICQ.js.map +0 -1
  165. package/dist/chunks/chunk-CTESMSQO.js +0 -56
  166. package/dist/chunks/chunk-CTESMSQO.js.map +0 -1
  167. package/dist/chunks/chunk-DZAMXOSC.js +0 -30
  168. package/dist/chunks/chunk-DZAMXOSC.js.map +0 -1
  169. package/dist/chunks/chunk-E6V3JHVT.js +0 -31
  170. package/dist/chunks/chunk-E6V3JHVT.js.map +0 -1
  171. package/dist/chunks/chunk-EJZQSOHU.js +0 -85
  172. package/dist/chunks/chunk-EJZQSOHU.js.map +0 -1
  173. package/dist/chunks/chunk-EMVOKXSA.js +0 -84
  174. package/dist/chunks/chunk-EMVOKXSA.js.map +0 -1
  175. package/dist/chunks/chunk-ETLOKJAG.js +0 -94
  176. package/dist/chunks/chunk-ETLOKJAG.js.map +0 -1
  177. package/dist/chunks/chunk-GAHXUFMQ.js +0 -93
  178. package/dist/chunks/chunk-GAHXUFMQ.js.map +0 -1
  179. package/dist/chunks/chunk-KG5Z2CKO.js +0 -86
  180. package/dist/chunks/chunk-KG5Z2CKO.js.map +0 -1
  181. package/dist/chunks/chunk-KSXNC564.js +0 -43
  182. package/dist/chunks/chunk-KSXNC564.js.map +0 -1
  183. package/dist/chunks/chunk-LF6SO3JU.js.map +0 -1
  184. package/dist/chunks/chunk-ODHS7HDB.js +0 -94
  185. package/dist/chunks/chunk-ODHS7HDB.js.map +0 -1
  186. package/dist/chunks/chunk-QU7KR7VX.js +0 -367
  187. package/dist/chunks/chunk-QU7KR7VX.js.map +0 -1
  188. package/dist/chunks/chunk-TU6COU44.js +0 -82
  189. package/dist/chunks/chunk-TU6COU44.js.map +0 -1
  190. package/dist/chunks/chunk-TUKEQ36K.js +0 -60
  191. package/dist/chunks/chunk-TUKEQ36K.js.map +0 -1
  192. package/dist/chunks/chunk-TWYN56XO.js +0 -92
  193. package/dist/chunks/chunk-TWYN56XO.js.map +0 -1
  194. package/dist/chunks/chunk-UHQVQBCL.js +0 -89
  195. package/dist/chunks/chunk-UHQVQBCL.js.map +0 -1
  196. package/dist/chunks/chunk-WFFIUFJJ.js +0 -28
  197. package/dist/chunks/chunk-WFFIUFJJ.js.map +0 -1
  198. package/dist/chunks/chunk-WN6TJQI2.js +0 -103
  199. package/dist/chunks/chunk-WN6TJQI2.js.map +0 -1
  200. package/dist/chunks/chunk-WPEFNKMC.js +0 -923
  201. package/dist/chunks/chunk-WPEFNKMC.js.map +0 -1
  202. package/dist/chunks/chunk-YPMZLHGG.js +0 -52
  203. package/dist/chunks/chunk-YPMZLHGG.js.map +0 -1
  204. package/dist/chunks/chunk-YWEWSQJR.js +0 -40
  205. package/dist/chunks/chunk-YWEWSQJR.js.map +0 -1
  206. package/dist/chunks/chunk-ZGSNDSK3.js +0 -1
  207. package/dist/chunks/chunk-ZGSNDSK3.js.map +0 -1
  208. package/dist/qti-item/components/item-container.d.ts +0 -40
  209. package/dist/qti-item/components/item-container.js +0 -11
  210. package/dist/qti-item/components/item-container.js.map +0 -1
  211. package/dist/qti-item/components/item-correct-response-mode.d.ts +0 -17
  212. package/dist/qti-item/components/item-correct-response-mode.js +0 -62
  213. package/dist/qti-item/components/item-correct-response-mode.js.map +0 -1
  214. package/dist/qti-item/components/item-show-candidate-correction.d.ts +0 -34
  215. package/dist/qti-item/components/item-show-candidate-correction.js +0 -88
  216. package/dist/qti-item/components/item-show-candidate-correction.js.map +0 -1
  217. package/dist/qti-item/components/item-show-correct-response.d.ts +0 -33
  218. package/dist/qti-item/components/item-show-correct-response.js +0 -10
  219. package/dist/qti-item/components/item-show-correct-response.js.map +0 -1
  220. package/dist/qti-item/components/print-item-variables.d.ts +0 -23
  221. package/dist/qti-item/components/print-item-variables.js +0 -9
  222. package/dist/qti-item/components/print-item-variables.js.map +0 -1
  223. package/dist/qti-item/components/styles.d.ts +0 -8
  224. package/dist/qti-item/components/styles.js +0 -14
  225. package/dist/qti-item/components/styles.js.map +0 -1
  226. package/dist/qti-item/core/index.d.ts +0 -51
  227. package/dist/qti-item/core/index.js +0 -26
  228. package/dist/qti-response-declaration-DKr08ANy.d.ts +0 -1397
  229. package/dist/qti-test/components/index.d.ts +0 -33
  230. package/dist/qti-test/components/index.js +0 -87
  231. package/dist/qti-test/components/styles.d.ts +0 -8
  232. package/dist/qti-test/components/styles.js +0 -14
  233. package/dist/qti-test/components/styles.js.map +0 -1
  234. package/dist/qti-test/components/test-check-item.d.ts +0 -16
  235. package/dist/qti-test/components/test-check-item.js +0 -9
  236. package/dist/qti-test/components/test-check-item.js.map +0 -1
  237. package/dist/qti-test/components/test-container.d.ts +0 -39
  238. package/dist/qti-test/components/test-container.js +0 -11
  239. package/dist/qti-test/components/test-container.js.map +0 -1
  240. package/dist/qti-test/components/test-end-attempt.d.ts +0 -16
  241. package/dist/qti-test/components/test-end-attempt.js +0 -9
  242. package/dist/qti-test/components/test-end-attempt.js.map +0 -1
  243. package/dist/qti-test/components/test-item-link.d.ts +0 -18
  244. package/dist/qti-test/components/test-item-link.js +0 -9
  245. package/dist/qti-test/components/test-item-link.js.map +0 -1
  246. package/dist/qti-test/components/test-navigation.d.ts +0 -73
  247. package/dist/qti-test/components/test-navigation.js +0 -13
  248. package/dist/qti-test/components/test-navigation.js.map +0 -1
  249. package/dist/qti-test/components/test-next.d.ts +0 -48
  250. package/dist/qti-test/components/test-next.js +0 -12
  251. package/dist/qti-test/components/test-next.js.map +0 -1
  252. package/dist/qti-test/components/test-paging-buttons-stamp.d.ts +0 -23
  253. package/dist/qti-test/components/test-paging-buttons-stamp.js +0 -9
  254. package/dist/qti-test/components/test-paging-buttons-stamp.js.map +0 -1
  255. package/dist/qti-test/components/test-prev.d.ts +0 -46
  256. package/dist/qti-test/components/test-prev.js +0 -12
  257. package/dist/qti-test/components/test-prev.js.map +0 -1
  258. package/dist/qti-test/components/test-print-context.d.ts +0 -25
  259. package/dist/qti-test/components/test-print-context.js +0 -9
  260. package/dist/qti-test/components/test-print-context.js.map +0 -1
  261. package/dist/qti-test/components/test-print-item-variables.d.ts +0 -27
  262. package/dist/qti-test/components/test-print-item-variables.js +0 -9
  263. package/dist/qti-test/components/test-print-item-variables.js.map +0 -1
  264. package/dist/qti-test/components/test-scoring-buttons.d.ts +0 -32
  265. package/dist/qti-test/components/test-scoring-buttons.js +0 -9
  266. package/dist/qti-test/components/test-scoring-buttons.js.map +0 -1
  267. package/dist/qti-test/components/test-scoring-feedback.d.ts +0 -27
  268. package/dist/qti-test/components/test-scoring-feedback.js +0 -9
  269. package/dist/qti-test/components/test-scoring-feedback.js.map +0 -1
  270. package/dist/qti-test/components/test-section-buttons-stamp.d.ts +0 -23
  271. package/dist/qti-test/components/test-section-buttons-stamp.js +0 -9
  272. package/dist/qti-test/components/test-section-buttons-stamp.js.map +0 -1
  273. package/dist/qti-test/components/test-section-link.d.ts +0 -18
  274. package/dist/qti-test/components/test-section-link.js +0 -9
  275. package/dist/qti-test/components/test-section-link.js.map +0 -1
  276. package/dist/qti-test/components/test-show-correct-response.d.ts +0 -39
  277. package/dist/qti-test/components/test-show-correct-response.js +0 -10
  278. package/dist/qti-test/components/test-show-correct-response.js.map +0 -1
  279. package/dist/qti-test/components/test-stamp.d.ts +0 -31
  280. package/dist/qti-test/components/test-stamp.js +0 -9
  281. package/dist/qti-test/components/test-stamp.js.map +0 -1
  282. package/dist/qti-test/components/test-view-toggle.d.ts +0 -19
  283. package/dist/qti-test/components/test-view-toggle.js +0 -9
  284. package/dist/qti-test/components/test-view-toggle.js.map +0 -1
  285. package/dist/qti-test/components/test-view.d.ts +0 -24
  286. package/dist/qti-test/components/test-view.js +0 -10
  287. package/dist/qti-test/components/test-view.js.map +0 -1
  288. package/dist/qti-test/core/index.d.ts +0 -105
  289. package/dist/qti-test/core/index.js +0 -36
  290. package/dist/qti-test/core/index.js.map +0 -1
  291. /package/dist/chunks/{chunk-FL72PF4D.js.map → chunk-SV4K25ZI.js.map} +0 -0
  292. /package/dist/qti-item/{core/index.js.map → index.js.map} +0 -0
  293. /package/dist/qti-test/{components/index.js.map → index.js.map} +0 -0
@@ -1,94 +0,0 @@
1
- import {
2
- item_default
3
- } from "./chunk-LSEB52SP.js";
4
- import {
5
- watch
6
- } from "./chunk-ELDMXTUQ.js";
7
- import {
8
- qtiTransformTest
9
- } from "./chunk-WFUXZ4UT.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-ODHS7HDB.js.map
@@ -1 +0,0 @@
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;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":[]}
@@ -1,367 +0,0 @@
1
- import {
2
- qtiContext
3
- } from "./chunk-H6KHXSIO.js";
4
- import {
5
- sessionContext
6
- } from "./chunk-22IRJWWY.js";
7
- import {
8
- testContext
9
- } from "./chunk-CJADUWEC.js";
10
- import {
11
- computedContext
12
- } from "./chunk-AZIKAG7K.js";
13
- import {
14
- configContext
15
- } from "./chunk-ERYHQVOT.js";
16
- import {
17
- __decorateClass
18
- } from "./chunk-H2JE6IVU.js";
19
-
20
- // src/lib/qti-test/components/test-navigation.ts
21
- import { consume, provide } from "@lit/context";
22
- import { html, LitElement } from "lit";
23
- import { customElement, property, state } from "lit/decorators.js";
24
- var TestNavigation = class extends LitElement {
25
- constructor() {
26
- super();
27
- this.identifier = void 0;
28
- this.initContext = [];
29
- this.qtiContext = {
30
- QTI_CONTEXT: {
31
- testIdentifier: "",
32
- candidateIdentifier: "",
33
- environmentIdentifier: "default"
34
- }
35
- };
36
- this.configContext = {};
37
- this.autoScoreItems = false;
38
- this.addEventListener("qti-assessment-test-connected", this._handleTestConnected.bind(this));
39
- this.addEventListener("qti-assessment-item-connected", this._handleItemConnected.bind(this));
40
- this.addEventListener("qti-interaction-changed", this._handleInteractionChanged.bind(this));
41
- this.addEventListener("test-end-attempt", this._handleTestEndAttempt.bind(this));
42
- this.addEventListener("test-show-correct-response", this._handleTestShowCorrectResponse.bind(this));
43
- this.addEventListener("test-show-candidate-correction", this._handleTestShowCandidateCorrection.bind(this));
44
- this.addEventListener("test-update-outcome-variable", this._handleTestUpdateOutcomeVariable.bind(this));
45
- }
46
- /**
47
- * Handles the 'test-end-attempt' event.
48
- * @private
49
- * @listens TestNavigation#test-end-attempt
50
- * @param {CustomEvent} event - The custom event object.
51
- */
52
- _handleTestEndAttempt(_event) {
53
- const qtiItemEl = this._testElement.querySelector(
54
- `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
55
- );
56
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
57
- const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
58
- qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);
59
- }
60
- // protected createRenderRoot(): HTMLElement | DocumentFragment {
61
- // return this;
62
- // }
63
- // myTemplate: TemplateFunction;
64
- // connectedCallback(): void {
65
- // super.connectedCallback();
66
- // const templateElement = this.querySelector<HTMLTemplateElement>('template');
67
- // if (!templateElement) {
68
- // this.myTemplate = null;
69
- // return;
70
- // }
71
- // this.myTemplate = prepareTemplate(templateElement);
72
- // }
73
- /**
74
- * Handles the 'test-show-correct-response' event.
75
- * @private
76
- * @listens TestNavigation#test-show-correct-response
77
- * @param {CustomEvent} event - The custom event object.
78
- */
79
- _handleTestShowCorrectResponse(event) {
80
- const qtiItemEl = this._testElement.querySelector(
81
- `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
82
- );
83
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
84
- if (!qtiAssessmentItemEl) return;
85
- qtiAssessmentItemEl.showCorrectResponse(event.detail);
86
- }
87
- /**
88
- * Handles the 'test-show-candidate-correction' event.
89
- * @private
90
- * @listens TestNavigation#test-show-candidate-correction
91
- * @param {CustomEvent} event - The custom event object.
92
- */
93
- _handleTestShowCandidateCorrection(event) {
94
- const qtiItemEl = this._testElement.querySelector(
95
- `qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`
96
- );
97
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
98
- qtiAssessmentItemEl.showCandidateCorrection(event.detail);
99
- }
100
- _handleTestUpdateOutcomeVariable(event) {
101
- const qtiItemEl = this._testElement.querySelector(
102
- `qti-assessment-item-ref[identifier="${event.detail.assessmentItemRefId}"]`
103
- );
104
- const qtiAssessmentItemEl = qtiItemEl.assessmentItem;
105
- qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);
106
- }
107
- _handleInteractionChanged(_event) {
108
- if (this.autoScoreItems) {
109
- const assessmentItem = _event.composedPath()[0].closest("qti-assessment-item");
110
- const scoreOutcomeIdentifier = assessmentItem.variables.find((v) => v.identifier === "SCORE");
111
- if (scoreOutcomeIdentifier && scoreOutcomeIdentifier.externalScored === null && assessmentItem.adaptive === "false") {
112
- const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;
113
- assessmentItem.processResponse(true, reportValidityAfterScoring);
114
- }
115
- }
116
- }
117
- render() {
118
- return html`<slot></slot>`;
119
- }
120
- /* PK: on test connected we can build the computed context */
121
- _handleTestConnected(event) {
122
- this._testElement = event.detail;
123
- if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {
124
- const currentContext = this.qtiContext.QTI_CONTEXT || {
125
- testIdentifier: "",
126
- candidateIdentifier: "not set",
127
- environmentIdentifier: "default"
128
- };
129
- this.qtiContext = {
130
- QTI_CONTEXT: {
131
- ...currentContext,
132
- testIdentifier: this._testElement.identifier,
133
- environmentIdentifier: currentContext.environmentIdentifier || "default"
134
- }
135
- };
136
- }
137
- const contextDeclarations = this._testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
138
- contextDeclarations.forEach((declaration) => {
139
- const defaultValues = this._extractDefaultValues(declaration);
140
- if (Object.keys(defaultValues).length > 0) {
141
- this.qtiContext = {
142
- QTI_CONTEXT: {
143
- ...defaultValues,
144
- // Default values first
145
- ...this.qtiContext.QTI_CONTEXT
146
- // Runtime values override defaults
147
- }
148
- };
149
- }
150
- });
151
- const testPartElements = Array.from(this._testElement?.querySelectorAll(`qti-test-part`) || []);
152
- this.computedContext = {
153
- identifier: this._testElement.identifier,
154
- title: this._testElement.title,
155
- view: this._sessionContext?.view,
156
- testParts: testPartElements.map((testPart) => {
157
- const sectionElements = [...testPart.querySelectorAll(`qti-assessment-section`)];
158
- return {
159
- active: false,
160
- identifier: testPart.identifier,
161
- navigationMode: testPart.navigationMode,
162
- submissionMode: testPart.submissionMode,
163
- sections: sectionElements.map((section) => {
164
- const itemElements = [...section.querySelectorAll(`qti-assessment-item-ref`)];
165
- return {
166
- active: false,
167
- identifier: section.identifier,
168
- title: section.title,
169
- items: itemElements.map((item) => ({
170
- ...this.initContext?.find((i) => i.identifier === item.identifier),
171
- active: false,
172
- identifier: item.identifier,
173
- categories: item.category ? item.category?.split(" ") : [],
174
- href: item.href,
175
- variables: []
176
- }))
177
- };
178
- })
179
- };
180
- })
181
- };
182
- }
183
- /**
184
- * Extract default values from a qti-context-declaration element
185
- */
186
- _extractDefaultValues(declaration) {
187
- const defaultValues = {};
188
- const defaultValueElement = declaration.querySelector("qti-default-value");
189
- if (!defaultValueElement) {
190
- return defaultValues;
191
- }
192
- const valueElements = defaultValueElement.querySelectorAll("qti-value[field-identifier]");
193
- valueElements.forEach((valueElement) => {
194
- const fieldIdentifier = valueElement.getAttribute("field-identifier");
195
- const baseType = valueElement.getAttribute("base-type") || "string";
196
- const textContent = valueElement.textContent?.trim() || "";
197
- if (fieldIdentifier) {
198
- let value = textContent;
199
- switch (baseType) {
200
- case "integer":
201
- value = parseInt(textContent, 10);
202
- break;
203
- case "float":
204
- case "duration":
205
- value = parseFloat(textContent);
206
- break;
207
- case "boolean":
208
- value = textContent.toLowerCase() === "true";
209
- break;
210
- case "string":
211
- default:
212
- value = textContent;
213
- break;
214
- }
215
- defaultValues[fieldIdentifier] = value;
216
- }
217
- });
218
- return defaultValues;
219
- }
220
- /* PK: on item connected we can add item only properties in the xml */
221
- _handleItemConnected(event) {
222
- const itemElement = event.detail;
223
- this.computedContext = {
224
- ...this.computedContext,
225
- testParts: this.computedContext.testParts.map((testPart) => {
226
- return {
227
- ...testPart,
228
- sections: testPart.sections.map((section) => {
229
- return {
230
- ...section,
231
- items: section.items.map((item) => {
232
- if (item.identifier !== itemElement.parentElement.getAttribute("identifier")) {
233
- return item;
234
- }
235
- const scoreOutcome = itemElement.querySelector(
236
- "qti-outcome-declaration[identifier='SCORE']"
237
- );
238
- const externalScored = scoreOutcome?.getAttribute("externalScored");
239
- const responseDeclarations = itemElement.querySelectorAll("qti-response-declaration");
240
- const containsCorrectResponse = Array.from(responseDeclarations).some(
241
- (r) => r.querySelector("qti-correct-response")
242
- );
243
- const containsMapping = Array.from(responseDeclarations).some((r) => {
244
- const mapping = r.querySelector("qti-mapping");
245
- const areaMapping = r.querySelector("qti-area-mapping");
246
- return mapping?.querySelector("qti-map-entry") || areaMapping?.querySelector("qti-area-map-entry");
247
- });
248
- const hasCorrectResponse = containsCorrectResponse || containsMapping;
249
- const hasResponseProcessing = itemElement.querySelector("qti-response-processing") ? true : false;
250
- return {
251
- ...item,
252
- assessmentItemIdentifier: itemElement.getAttribute("identifier"),
253
- label: itemElement.getAttribute("label"),
254
- title: itemElement.title,
255
- externalScored,
256
- adaptive: itemElement.adaptive == "true" || false,
257
- timeDependent: itemElement.timeDependent == "true" || false,
258
- variables: itemElement.variables,
259
- hasCorrectResponse,
260
- hasResponseProcessing
261
- };
262
- })
263
- };
264
- })
265
- };
266
- })
267
- };
268
- }
269
- /* PK: on every change of the candidate we will recomputed the computedContext */
270
- willUpdate(_changedProperties) {
271
- if (!this.computedContext) return;
272
- let itemIndex = 1;
273
- this.computedContext = {
274
- ...this.computedContext,
275
- view: this._sessionContext?.view,
276
- testParts: this.computedContext.testParts.map((testPart) => {
277
- return {
278
- ...testPart,
279
- active: this._sessionContext?.navPartId === testPart.identifier || false,
280
- sections: testPart.sections.map((section) => {
281
- return {
282
- ...section,
283
- active: this._sessionContext?.navSectionId === section.identifier || false,
284
- completed: section.items.every(
285
- (item) => this._testContext.items.find((i) => i.identifier === item.identifier)?.variables.find((v) => v.identifier === "completionStatus").value === "completed"
286
- ),
287
- items: section.items.map((item) => {
288
- const itemContext = this._testContext?.items.find((i) => i.identifier === item.identifier);
289
- const computedItem = {
290
- ...item,
291
- ...itemContext,
292
- ...this.initContext?.find((i) => i.identifier === item.identifier)
293
- };
294
- const rawscore = computedItem.variables?.find((vr) => vr.identifier == "SCORE")?.value;
295
- const score = rawscore === void 0 || rawscore === null ? null : parseFloat(rawscore?.toString());
296
- const completionStatus = computedItem.variables?.find((v) => v.identifier === "completionStatus")?.value;
297
- const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
298
- const numAttempts = computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value || 0;
299
- const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
300
- const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;
301
- const rawMaxScore = item.variables?.find((vr) => vr.identifier == "MAXSCORE")?.value;
302
- const maxScore = rawMaxScore === void 0 || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());
303
- return {
304
- ...computedItem,
305
- completionStatus,
306
- numAttempts,
307
- score,
308
- response,
309
- index,
310
- // type,
311
- active,
312
- // correct,
313
- maxScore
314
- // incorrect,
315
- // completed
316
- };
317
- })
318
- };
319
- })
320
- };
321
- })
322
- };
323
- this.dispatchEvent(
324
- new CustomEvent("qti-computed-context-updated", {
325
- detail: this.computedContext,
326
- bubbles: true
327
- })
328
- );
329
- }
330
- };
331
- __decorateClass([
332
- property({ type: String })
333
- ], TestNavigation.prototype, "identifier", 2);
334
- __decorateClass([
335
- state()
336
- ], TestNavigation.prototype, "initContext", 2);
337
- __decorateClass([
338
- state(),
339
- provide({ context: qtiContext })
340
- ], TestNavigation.prototype, "qtiContext", 2);
341
- __decorateClass([
342
- state(),
343
- provide({ context: configContext })
344
- ], TestNavigation.prototype, "configContext", 2);
345
- __decorateClass([
346
- state(),
347
- consume({ context: testContext, subscribe: true })
348
- ], TestNavigation.prototype, "_testContext", 2);
349
- __decorateClass([
350
- state(),
351
- consume({ context: sessionContext, subscribe: true })
352
- ], TestNavigation.prototype, "_sessionContext", 2);
353
- __decorateClass([
354
- state(),
355
- provide({ context: computedContext })
356
- ], TestNavigation.prototype, "computedContext", 2);
357
- __decorateClass([
358
- property({ type: Boolean, attribute: "auto-score-items" })
359
- ], TestNavigation.prototype, "autoScoreItems", 2);
360
- TestNavigation = __decorateClass([
361
- customElement("test-navigation")
362
- ], TestNavigation);
363
-
364
- export {
365
- TestNavigation
366
- };
367
- //# sourceMappingURL=chunk-QU7KR7VX.js.map
@@ -1 +0,0 @@
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\nimport { computedContext } from '../../exports/computed.context';\nimport { configContext } from '../../exports/config.context';\nimport { testContext } from '../../exports/test.context';\nimport { sessionContext } from '../../exports/session.context';\nimport { qtiContext } from '../../exports/qti.context';\n\nimport type { QtiContext } from '../../exports/qti.context';\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 { ConfigContext } from '../../exports/config.context';\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: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\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-show-candidate-correction', this._handleTestShowCandidateCorrection.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-show-correct-response' 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 if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.showCorrectResponse(event.detail);\n }\n\n /**\n * Handles the 'test-show-candidate-correction' event.\n * @private\n * @listens TestNavigation#test-show-candidate-correction\n * @param {CustomEvent} event - The custom event object.\n */\n private _handleTestShowCandidateCorrection(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.showCandidateCorrection(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 // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.qtiContext = {\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this._testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n };\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this._testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this._extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.qtiContext = {\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n };\n }\n });\n\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 /**\n * Extract default values from a qti-context-declaration element\n */\n private _extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\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\n const score = rawscore === undefined || rawscore === null ? null : parseFloat(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 =\n rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(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;AA4BxC,IAAM,iBAAN,cAA6B,WAAW;AAAA,EAwD7C,cAAc;AACZ,UAAM;AAxDoB,sBAAa;AAGzC,SAAO,cAA4D,CAAC;AAIpE,SAAO,aAAyB;AAAA,MAC9B,aAAa;AAAA,QACX,gBAAgB;AAAA,QAChB,qBAAqB;AAAA,QACrB,uBAAuB;AAAA,MACzB;AAAA,IACF;AAIA,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;A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AA,EACN,QAAQ,EAAE,SAAS,cAAc,CAAC;AAAA,GAjBxB,eAkBJ;AAIG;AAAA,EAFT,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,aAAa,WAAW,KAAK,CAAC;AAAA,GArBvC,eAsBD;AAIA;AAAA,EAFT,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,gBAAgB,WAAW,KAAK,CAAC;AAAA,GAzB1C,eA0BD;AAIA;AAAA,EAFT,MAAM;AAAA,EACN,QAAQ,EAAE,SAAS,gBAAgB,CAAC;AAAA,GA7B1B,eA8BD;AAEkD;AAAA,EAA3D,SAAS,EAAE,MAAM,SAAS,WAAW,mBAAmB,CAAC;AAAA,GAhC/C,eAgCiD;AAhCjD,iBAAN;AAAA,EADN,cAAc,iBAAiB;AAAA,GACnB;","names":[]}
@@ -1,82 +0,0 @@
1
- import {
2
- computedContext
3
- } from "./chunk-AZIKAG7K.js";
4
- import {
5
- __decorateClass
6
- } from "./chunk-H2JE6IVU.js";
7
-
8
- // src/lib/qti-test/components/test-scoring-buttons.ts
9
- import { html, LitElement, nothing } from "lit";
10
- import { consume } from "@lit/context";
11
- import { customElement, property } from "lit/decorators.js";
12
- import { prepareTemplate } from "@heximal/templates";
13
- var TestScoringButtons = class extends LitElement {
14
- constructor() {
15
- super();
16
- this.view = "";
17
- this.disabled = false;
18
- this.myTemplate = null;
19
- this.addEventListener("click", (e) => {
20
- const target = e.target;
21
- const value = parseFloat(target.value);
22
- if (target.tagName === "INPUT") {
23
- this._changeOutcomeScore(value);
24
- }
25
- });
26
- }
27
- createRenderRoot() {
28
- return this;
29
- }
30
- connectedCallback() {
31
- super.connectedCallback();
32
- const templateElement = this.querySelector("template");
33
- if (!templateElement) {
34
- this.myTemplate = null;
35
- return;
36
- }
37
- this.myTemplate = prepareTemplate(templateElement);
38
- }
39
- _changeOutcomeScore(value) {
40
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
41
- const sectionItems = testPart.sections.flatMap((section) => section.items);
42
- const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
43
- this.dispatchEvent(
44
- new CustomEvent("test-update-outcome-variable", {
45
- detail: {
46
- assessmentItemRefId: currentItemIdentifier,
47
- outcomeVariableId: "SCORE",
48
- value
49
- },
50
- bubbles: true
51
- })
52
- );
53
- }
54
- render() {
55
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
56
- if (!activeItem || !activeItem.variables) return html``;
57
- const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
58
- const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
59
- const score = scoreOutcome?.value;
60
- const disabled = !(scoreOutcome?.externalScored === "human");
61
- if (!maxScore || !scoreOutcome) return nothing;
62
- const scores = [...Array(Number(maxScore) + 1).keys()];
63
- return html`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing}`;
64
- }
65
- };
66
- __decorateClass([
67
- property({ type: String, attribute: "view" })
68
- ], TestScoringButtons.prototype, "view", 2);
69
- __decorateClass([
70
- property({ type: Boolean })
71
- ], TestScoringButtons.prototype, "disabled", 2);
72
- __decorateClass([
73
- consume({ context: computedContext, subscribe: true })
74
- ], TestScoringButtons.prototype, "computedContext", 2);
75
- TestScoringButtons = __decorateClass([
76
- customElement("test-scoring-buttons")
77
- ], TestScoringButtons);
78
-
79
- export {
80
- TestScoringButtons
81
- };
82
- //# sourceMappingURL=chunk-TU6COU44.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/qti-test/components/test-scoring-buttons.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { consume } from '@lit/context';\nimport { customElement, property } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '../../exports/computed.context';\n\nimport type { TemplateFunction } from '@heximal/templates';\nimport type { OutcomeVariable } from '../../exports/variables';\nimport type { ComputedContext } from '../../exports/computed.context';\n\n@customElement('test-scoring-buttons')\nexport class TestScoringButtons extends LitElement {\n @property({ type: String, attribute: 'view' }) view = ''; // is only an attribute, but this is here because.. react\n @property({ type: Boolean }) disabled: boolean = false;\n myTemplate: TemplateFunction | null = null;\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n private _changeOutcomeScore(value: number) {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const currentItemIdentifier = sectionItems.find(item => item.active)?.identifier;\n\n this.dispatchEvent(\n new CustomEvent('test-update-outcome-variable', {\n detail: {\n assessmentItemRefId: currentItemIdentifier,\n outcomeVariableId: 'SCORE',\n value\n },\n bubbles: true\n })\n );\n }\n\n render() {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const maxScore = activeItem.variables.find(vr => vr.identifier == 'MAXSCORE')?.value;\n const scoreOutcome = activeItem.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n\n const score = scoreOutcome?.value;\n\n const disabled = !(scoreOutcome?.externalScored === 'human');\n\n if (!maxScore || !scoreOutcome) return nothing;\n const scores = [...Array(Number(maxScore) + 1).keys()];\n\n return html`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing}`;\n }\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n const target = e.target as HTMLInputElement;\n const value = parseFloat(target.value);\n if (target.tagName === 'INPUT') {\n this._changeOutcomeScore(value);\n }\n });\n\n // return maxScore\n // ? html`\n // <form part=\"form\">\n // ${[...Array(Number(maxScore) + 1).keys()].map(itemIndex => {\n // const identifier = `scoring-buttons${itemIndex}${activeItem.identifier}`;\n // return html` <input\n // part=\"input\"\n // type=\"radio\"\n // ?disabled=${this.disabled}\n // .checked=${itemIndex === Number(score)}\n // @change=${() => this._changeOutcomeScore(itemIndex)}\n // id=${identifier}\n // name=${`scoring-buttons-${activeItem.identifier}`}\n // value=${itemIndex}\n // />\n\n // <label part=\"label\" for=${identifier}>${itemIndex}</label>`;\n // })}\n // </form>\n // <slot></slot>\n // `\n // : nothing;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-scoring-buttons': TestScoringButtons;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,YAAY,eAAe;AAC1C,SAAS,eAAe;AACxB,SAAS,eAAe,gBAAgB;AACxC,SAAS,uBAAuB;AASzB,IAAM,qBAAN,cAAiC,WAAW;AAAA,EA2DjD,cAAc;AACZ,UAAM;AA3DuC,gBAAO;AACzB,oBAAoB;AACjD,sBAAsC;AA0DpC,SAAK,iBAAiB,SAAS,OAAK;AAClC,YAAM,SAAS,EAAE;AACjB,YAAM,QAAQ,WAAW,OAAO,KAAK;AACrC,UAAI,OAAO,YAAY,SAAS;AAC9B,aAAK,oBAAoB,KAAK;AAAA,MAChC;AAAA,IACF,CAAC;AAAA,EAwBH;AAAA,EAtFU,mBAAmD;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,oBAA0B;AACxB,UAAM,kBAAkB;AACxB,UAAM,kBAAkB,KAAK,cAAmC,UAAU;AAC1E,QAAI,CAAC,iBAAiB;AACpB,WAAK,aAAa;AAClB;AAAA,IACF;AACA,SAAK,aAAa,gBAAgB,eAAe;AAAA,EACnD;AAAA,EAKQ,oBAAoB,OAAe;AACzC,UAAM,WAAW,KAAK,iBAAiB,UAAU,KAAK,CAAAA,cAAYA,UAAS,MAAM;AACjF,UAAM,eAAe,SAAS,SAAS,QAAQ,aAAW,QAAQ,KAAK;AACvE,UAAM,wBAAwB,aAAa,KAAK,UAAQ,KAAK,MAAM,GAAG;AAEtE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