@pie-qti/item-player 0.1.5 → 0.1.7

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 (461) hide show
  1. package/dist/catalog/applyGlossaryTriggers.d.ts +2 -1
  2. package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
  3. package/dist/catalog/applyGlossaryTriggers.js +145 -30
  4. package/dist/catalog/glossaryAction.d.ts.map +1 -1
  5. package/dist/catalog/glossaryAction.js +14 -4
  6. package/dist/components/utils/stimulusRender.d.ts +17 -0
  7. package/dist/components/utils/stimulusRender.d.ts.map +1 -0
  8. package/dist/components/utils/stimulusRender.js +70 -0
  9. package/dist/components/utils/stylesheetRender.d.ts +4 -0
  10. package/dist/components/utils/stylesheetRender.d.ts.map +1 -0
  11. package/dist/components/utils/stylesheetRender.js +57 -0
  12. package/dist/core/ComponentRegistry.d.ts +5 -4
  13. package/dist/core/ComponentRegistry.d.ts.map +1 -1
  14. package/dist/core/ComponentRegistry.js +11 -4
  15. package/dist/core/ItemRenderer.d.ts.map +1 -1
  16. package/dist/core/ItemRenderer.js +5 -18
  17. package/dist/core/Player.d.ts +39 -4
  18. package/dist/core/Player.d.ts.map +1 -1
  19. package/dist/core/Player.js +364 -193
  20. package/dist/document/AssessmentItemDocument.d.ts +42 -0
  21. package/dist/document/AssessmentItemDocument.d.ts.map +1 -0
  22. package/dist/document/AssessmentItemDocument.js +116 -0
  23. package/dist/element.js +3318 -2733
  24. package/dist/element.js.map +1 -1
  25. package/dist/extraction/extractors/associateExtractor.d.ts +1 -28
  26. package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
  27. package/dist/extraction/extractors/associateExtractor.js +1 -97
  28. package/dist/extraction/extractors/choiceExtractor.d.ts +1 -26
  29. package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
  30. package/dist/extraction/extractors/choiceExtractor.js +1 -93
  31. package/dist/extraction/extractors/customExtractor.d.ts +1 -19
  32. package/dist/extraction/extractors/customExtractor.d.ts.map +1 -1
  33. package/dist/extraction/extractors/customExtractor.js +1 -51
  34. package/dist/extraction/extractors/drawingExtractor.d.ts +1 -29
  35. package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -1
  36. package/dist/extraction/extractors/drawingExtractor.js +1 -78
  37. package/dist/extraction/extractors/endAttemptExtractor.d.ts +1 -19
  38. package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -1
  39. package/dist/extraction/extractors/endAttemptExtractor.js +1 -53
  40. package/dist/extraction/extractors/extendedTextExtractor.d.ts +1 -20
  41. package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
  42. package/dist/extraction/extractors/extendedTextExtractor.js +1 -63
  43. package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -28
  44. package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
  45. package/dist/extraction/extractors/gapMatchExtractor.js +1 -155
  46. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -40
  47. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
  48. package/dist/extraction/extractors/graphicAssociateExtractor.js +1 -143
  49. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +1 -52
  50. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
  51. package/dist/extraction/extractors/graphicGapMatchExtractor.js +1 -205
  52. package/dist/extraction/extractors/graphicOrderExtractor.d.ts +1 -36
  53. package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -1
  54. package/dist/extraction/extractors/graphicOrderExtractor.js +1 -121
  55. package/dist/extraction/extractors/hotspotExtractor.d.ts +1 -37
  56. package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
  57. package/dist/extraction/extractors/hotspotExtractor.js +1 -159
  58. package/dist/extraction/extractors/hottextExtractor.d.ts +1 -25
  59. package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
  60. package/dist/extraction/extractors/hottextExtractor.js +1 -128
  61. package/dist/extraction/extractors/index.d.ts +5 -59
  62. package/dist/extraction/extractors/index.d.ts.map +1 -1
  63. package/dist/extraction/extractors/index.js +5 -85
  64. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +1 -24
  65. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
  66. package/dist/extraction/extractors/inlineChoiceExtractor.js +1 -80
  67. package/dist/extraction/extractors/matchExtractor.d.ts +1 -36
  68. package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
  69. package/dist/extraction/extractors/matchExtractor.js +1 -160
  70. package/dist/extraction/extractors/mediaExtractor.d.ts +1 -32
  71. package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -1
  72. package/dist/extraction/extractors/mediaExtractor.js +1 -125
  73. package/dist/extraction/extractors/orderExtractor.d.ts +1 -27
  74. package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
  75. package/dist/extraction/extractors/orderExtractor.js +1 -90
  76. package/dist/extraction/extractors/portableCustomExtractor.d.ts +1 -13
  77. package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -1
  78. package/dist/extraction/extractors/portableCustomExtractor.js +1 -96
  79. package/dist/extraction/extractors/positionObjectExtractor.d.ts +1 -58
  80. package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -1
  81. package/dist/extraction/extractors/positionObjectExtractor.js +1 -191
  82. package/dist/extraction/extractors/selectPointExtractor.d.ts +1 -30
  83. package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -1
  84. package/dist/extraction/extractors/selectPointExtractor.js +1 -109
  85. package/dist/extraction/extractors/sliderExtractor.d.ts +1 -23
  86. package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -1
  87. package/dist/extraction/extractors/sliderExtractor.js +1 -73
  88. package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -20
  89. package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
  90. package/dist/extraction/extractors/textEntryExtractor.js +1 -54
  91. package/dist/extraction/extractors/uploadExtractor.d.ts +1 -19
  92. package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
  93. package/dist/extraction/extractors/uploadExtractor.js +1 -59
  94. package/dist/extraction/index.d.ts +1 -1
  95. package/dist/extraction/index.d.ts.map +1 -1
  96. package/dist/extraction/index.js +2 -2
  97. package/dist/extraction/interactionExtractionPipeline.d.ts +13 -0
  98. package/dist/extraction/interactionExtractionPipeline.d.ts.map +1 -0
  99. package/dist/extraction/interactionExtractionPipeline.js +39 -0
  100. package/dist/extraction/interactionSecurity.d.ts +4 -0
  101. package/dist/extraction/interactionSecurity.d.ts.map +1 -0
  102. package/dist/extraction/interactionSecurity.js +48 -0
  103. package/dist/index.d.ts +2 -1
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +3 -3
  106. package/dist/interactions/associate/extractor.d.ts +29 -0
  107. package/dist/interactions/associate/extractor.d.ts.map +1 -0
  108. package/dist/interactions/associate/extractor.js +97 -0
  109. package/dist/interactions/associate/index.d.ts +3 -0
  110. package/dist/interactions/associate/index.d.ts.map +1 -0
  111. package/dist/interactions/associate/index.js +1 -0
  112. package/dist/interactions/associate/types.d.ts +2 -0
  113. package/dist/interactions/associate/types.d.ts.map +1 -0
  114. package/dist/interactions/associate/types.js +1 -0
  115. package/dist/interactions/choice/extractor.d.ts +27 -0
  116. package/dist/interactions/choice/extractor.d.ts.map +1 -0
  117. package/dist/interactions/choice/extractor.js +93 -0
  118. package/dist/interactions/choice/index.d.ts +3 -0
  119. package/dist/interactions/choice/index.d.ts.map +1 -0
  120. package/dist/interactions/choice/index.js +1 -0
  121. package/dist/interactions/choice/types.d.ts +2 -0
  122. package/dist/interactions/choice/types.d.ts.map +1 -0
  123. package/dist/interactions/choice/types.js +1 -0
  124. package/dist/interactions/custom/extractor.d.ts +20 -0
  125. package/dist/interactions/custom/extractor.d.ts.map +1 -0
  126. package/dist/interactions/custom/extractor.js +51 -0
  127. package/dist/interactions/custom/index.d.ts +3 -0
  128. package/dist/interactions/custom/index.d.ts.map +1 -0
  129. package/dist/interactions/custom/index.js +1 -0
  130. package/dist/interactions/custom/types.d.ts +2 -0
  131. package/dist/interactions/custom/types.d.ts.map +1 -0
  132. package/dist/interactions/custom/types.js +1 -0
  133. package/dist/interactions/drawing/extractor.d.ts +30 -0
  134. package/dist/interactions/drawing/extractor.d.ts.map +1 -0
  135. package/dist/interactions/drawing/extractor.js +78 -0
  136. package/dist/interactions/drawing/index.d.ts +3 -0
  137. package/dist/interactions/drawing/index.d.ts.map +1 -0
  138. package/dist/interactions/drawing/index.js +1 -0
  139. package/dist/interactions/drawing/types.d.ts +2 -0
  140. package/dist/interactions/drawing/types.d.ts.map +1 -0
  141. package/dist/interactions/drawing/types.js +1 -0
  142. package/dist/interactions/end-attempt/extractor.d.ts +20 -0
  143. package/dist/interactions/end-attempt/extractor.d.ts.map +1 -0
  144. package/dist/interactions/end-attempt/extractor.js +53 -0
  145. package/dist/interactions/end-attempt/index.d.ts +3 -0
  146. package/dist/interactions/end-attempt/index.d.ts.map +1 -0
  147. package/dist/interactions/end-attempt/index.js +1 -0
  148. package/dist/interactions/end-attempt/types.d.ts +2 -0
  149. package/dist/interactions/end-attempt/types.d.ts.map +1 -0
  150. package/dist/interactions/end-attempt/types.js +1 -0
  151. package/dist/interactions/extended-text/extractor.d.ts +21 -0
  152. package/dist/interactions/extended-text/extractor.d.ts.map +1 -0
  153. package/dist/interactions/extended-text/extractor.js +63 -0
  154. package/dist/interactions/extended-text/index.d.ts +3 -0
  155. package/dist/interactions/extended-text/index.d.ts.map +1 -0
  156. package/dist/interactions/extended-text/index.js +1 -0
  157. package/dist/interactions/extended-text/types.d.ts +2 -0
  158. package/dist/interactions/extended-text/types.d.ts.map +1 -0
  159. package/dist/interactions/extended-text/types.js +1 -0
  160. package/dist/interactions/gap-match/extractor.d.ts +29 -0
  161. package/dist/interactions/gap-match/extractor.d.ts.map +1 -0
  162. package/dist/interactions/gap-match/extractor.js +155 -0
  163. package/dist/interactions/gap-match/index.d.ts +3 -0
  164. package/dist/interactions/gap-match/index.d.ts.map +1 -0
  165. package/dist/interactions/gap-match/index.js +1 -0
  166. package/dist/interactions/gap-match/types.d.ts +2 -0
  167. package/dist/interactions/gap-match/types.d.ts.map +1 -0
  168. package/dist/interactions/gap-match/types.js +1 -0
  169. package/dist/interactions/graphic-associate/extractor.d.ts +41 -0
  170. package/dist/interactions/graphic-associate/extractor.d.ts.map +1 -0
  171. package/dist/interactions/graphic-associate/extractor.js +143 -0
  172. package/dist/interactions/graphic-associate/index.d.ts +3 -0
  173. package/dist/interactions/graphic-associate/index.d.ts.map +1 -0
  174. package/dist/interactions/graphic-associate/index.js +1 -0
  175. package/dist/interactions/graphic-associate/types.d.ts +2 -0
  176. package/dist/interactions/graphic-associate/types.d.ts.map +1 -0
  177. package/dist/interactions/graphic-associate/types.js +1 -0
  178. package/dist/interactions/graphic-gap-match/extractor.d.ts +53 -0
  179. package/dist/interactions/graphic-gap-match/extractor.d.ts.map +1 -0
  180. package/dist/interactions/graphic-gap-match/extractor.js +205 -0
  181. package/dist/interactions/graphic-gap-match/index.d.ts +3 -0
  182. package/dist/interactions/graphic-gap-match/index.d.ts.map +1 -0
  183. package/dist/interactions/graphic-gap-match/index.js +1 -0
  184. package/dist/interactions/graphic-gap-match/types.d.ts +2 -0
  185. package/dist/interactions/graphic-gap-match/types.d.ts.map +1 -0
  186. package/dist/interactions/graphic-gap-match/types.js +1 -0
  187. package/dist/interactions/graphic-order/extractor.d.ts +37 -0
  188. package/dist/interactions/graphic-order/extractor.d.ts.map +1 -0
  189. package/dist/interactions/graphic-order/extractor.js +121 -0
  190. package/dist/interactions/graphic-order/index.d.ts +3 -0
  191. package/dist/interactions/graphic-order/index.d.ts.map +1 -0
  192. package/dist/interactions/graphic-order/index.js +1 -0
  193. package/dist/interactions/graphic-order/types.d.ts +2 -0
  194. package/dist/interactions/graphic-order/types.d.ts.map +1 -0
  195. package/dist/interactions/graphic-order/types.js +1 -0
  196. package/dist/interactions/hotspot/extractor.d.ts +38 -0
  197. package/dist/interactions/hotspot/extractor.d.ts.map +1 -0
  198. package/dist/interactions/hotspot/extractor.js +159 -0
  199. package/dist/interactions/hotspot/index.d.ts +3 -0
  200. package/dist/interactions/hotspot/index.d.ts.map +1 -0
  201. package/dist/interactions/hotspot/index.js +1 -0
  202. package/dist/interactions/hotspot/types.d.ts +2 -0
  203. package/dist/interactions/hotspot/types.d.ts.map +1 -0
  204. package/dist/interactions/hotspot/types.js +1 -0
  205. package/dist/interactions/hottext/extractor.d.ts +26 -0
  206. package/dist/interactions/hottext/extractor.d.ts.map +1 -0
  207. package/dist/interactions/hottext/extractor.js +128 -0
  208. package/dist/interactions/hottext/index.d.ts +3 -0
  209. package/dist/interactions/hottext/index.d.ts.map +1 -0
  210. package/dist/interactions/hottext/index.js +1 -0
  211. package/dist/interactions/hottext/types.d.ts +2 -0
  212. package/dist/interactions/hottext/types.d.ts.map +1 -0
  213. package/dist/interactions/hottext/types.js +1 -0
  214. package/dist/interactions/index.d.ts +33 -0
  215. package/dist/interactions/index.d.ts.map +1 -0
  216. package/dist/interactions/index.js +30 -0
  217. package/dist/interactions/inline/index.d.ts +2 -0
  218. package/dist/interactions/inline/index.d.ts.map +1 -0
  219. package/dist/interactions/inline/index.js +1 -0
  220. package/dist/interactions/inline/render-plan.d.ts +19 -0
  221. package/dist/interactions/inline/render-plan.d.ts.map +1 -0
  222. package/dist/interactions/inline/render-plan.js +59 -0
  223. package/dist/interactions/inline-choice/extractor.d.ts +25 -0
  224. package/dist/interactions/inline-choice/extractor.d.ts.map +1 -0
  225. package/dist/interactions/inline-choice/extractor.js +80 -0
  226. package/dist/interactions/inline-choice/index.d.ts +3 -0
  227. package/dist/interactions/inline-choice/index.d.ts.map +1 -0
  228. package/dist/interactions/inline-choice/index.js +1 -0
  229. package/dist/interactions/inline-choice/types.d.ts +2 -0
  230. package/dist/interactions/inline-choice/types.d.ts.map +1 -0
  231. package/dist/interactions/inline-choice/types.js +1 -0
  232. package/dist/interactions/match/extractor.d.ts +37 -0
  233. package/dist/interactions/match/extractor.d.ts.map +1 -0
  234. package/dist/interactions/match/extractor.js +160 -0
  235. package/dist/interactions/match/index.d.ts +3 -0
  236. package/dist/interactions/match/index.d.ts.map +1 -0
  237. package/dist/interactions/match/index.js +1 -0
  238. package/dist/interactions/match/types.d.ts +2 -0
  239. package/dist/interactions/match/types.d.ts.map +1 -0
  240. package/dist/interactions/match/types.js +1 -0
  241. package/dist/interactions/media/extractor.d.ts +33 -0
  242. package/dist/interactions/media/extractor.d.ts.map +1 -0
  243. package/dist/interactions/media/extractor.js +125 -0
  244. package/dist/interactions/media/index.d.ts +3 -0
  245. package/dist/interactions/media/index.d.ts.map +1 -0
  246. package/dist/interactions/media/index.js +1 -0
  247. package/dist/interactions/media/types.d.ts +2 -0
  248. package/dist/interactions/media/types.d.ts.map +1 -0
  249. package/dist/interactions/media/types.js +1 -0
  250. package/dist/interactions/modules.d.ts +105 -0
  251. package/dist/interactions/modules.d.ts.map +1 -0
  252. package/dist/interactions/modules.js +86 -0
  253. package/dist/interactions/order/extractor.d.ts +28 -0
  254. package/dist/interactions/order/extractor.d.ts.map +1 -0
  255. package/dist/interactions/order/extractor.js +90 -0
  256. package/dist/interactions/order/index.d.ts +3 -0
  257. package/dist/interactions/order/index.d.ts.map +1 -0
  258. package/dist/interactions/order/index.js +1 -0
  259. package/dist/interactions/order/types.d.ts +2 -0
  260. package/dist/interactions/order/types.d.ts.map +1 -0
  261. package/dist/interactions/order/types.js +1 -0
  262. package/dist/interactions/portable-custom/extractor.d.ts +14 -0
  263. package/dist/interactions/portable-custom/extractor.d.ts.map +1 -0
  264. package/dist/interactions/portable-custom/extractor.js +96 -0
  265. package/dist/interactions/portable-custom/index.d.ts +3 -0
  266. package/dist/interactions/portable-custom/index.d.ts.map +1 -0
  267. package/dist/interactions/portable-custom/index.js +1 -0
  268. package/dist/interactions/portable-custom/types.d.ts +2 -0
  269. package/dist/interactions/portable-custom/types.d.ts.map +1 -0
  270. package/dist/interactions/portable-custom/types.js +1 -0
  271. package/dist/interactions/position-object/extractor.d.ts +59 -0
  272. package/dist/interactions/position-object/extractor.d.ts.map +1 -0
  273. package/dist/interactions/position-object/extractor.js +191 -0
  274. package/dist/interactions/position-object/index.d.ts +3 -0
  275. package/dist/interactions/position-object/index.d.ts.map +1 -0
  276. package/dist/interactions/position-object/index.js +1 -0
  277. package/dist/interactions/position-object/types.d.ts +2 -0
  278. package/dist/interactions/position-object/types.d.ts.map +1 -0
  279. package/dist/interactions/position-object/types.js +1 -0
  280. package/dist/interactions/select-point/extractor.d.ts +31 -0
  281. package/dist/interactions/select-point/extractor.d.ts.map +1 -0
  282. package/dist/interactions/select-point/extractor.js +109 -0
  283. package/dist/interactions/select-point/index.d.ts +3 -0
  284. package/dist/interactions/select-point/index.d.ts.map +1 -0
  285. package/dist/interactions/select-point/index.js +1 -0
  286. package/dist/interactions/select-point/types.d.ts +2 -0
  287. package/dist/interactions/select-point/types.d.ts.map +1 -0
  288. package/dist/interactions/select-point/types.js +1 -0
  289. package/dist/interactions/shared/index.d.ts +2 -0
  290. package/dist/interactions/shared/index.d.ts.map +1 -0
  291. package/dist/interactions/shared/index.js +1 -0
  292. package/dist/interactions/shared/types.d.ts +412 -0
  293. package/dist/interactions/shared/types.d.ts.map +1 -0
  294. package/dist/interactions/shared/types.js +7 -0
  295. package/dist/interactions/slider/extractor.d.ts +24 -0
  296. package/dist/interactions/slider/extractor.d.ts.map +1 -0
  297. package/dist/interactions/slider/extractor.js +73 -0
  298. package/dist/interactions/slider/index.d.ts +3 -0
  299. package/dist/interactions/slider/index.d.ts.map +1 -0
  300. package/dist/interactions/slider/index.js +1 -0
  301. package/dist/interactions/slider/types.d.ts +2 -0
  302. package/dist/interactions/slider/types.d.ts.map +1 -0
  303. package/dist/interactions/slider/types.js +1 -0
  304. package/dist/interactions/text-entry/extractor.d.ts +21 -0
  305. package/dist/interactions/text-entry/extractor.d.ts.map +1 -0
  306. package/dist/interactions/text-entry/extractor.js +54 -0
  307. package/dist/interactions/text-entry/index.d.ts +3 -0
  308. package/dist/interactions/text-entry/index.d.ts.map +1 -0
  309. package/dist/interactions/text-entry/index.js +1 -0
  310. package/dist/interactions/text-entry/types.d.ts +2 -0
  311. package/dist/interactions/text-entry/types.d.ts.map +1 -0
  312. package/dist/interactions/text-entry/types.js +1 -0
  313. package/dist/interactions/upload/extractor.d.ts +20 -0
  314. package/dist/interactions/upload/extractor.d.ts.map +1 -0
  315. package/dist/interactions/upload/extractor.js +59 -0
  316. package/dist/interactions/upload/index.d.ts +3 -0
  317. package/dist/interactions/upload/index.d.ts.map +1 -0
  318. package/dist/interactions/upload/index.js +1 -0
  319. package/dist/interactions/upload/types.d.ts +2 -0
  320. package/dist/interactions/upload/types.d.ts.map +1 -0
  321. package/dist/interactions/upload/types.js +1 -0
  322. package/dist/pnp/applyPnp.d.ts.map +1 -1
  323. package/dist/pnp/applyPnp.js +9 -2
  324. package/dist/pnp/parsePnpXml.d.ts.map +1 -1
  325. package/dist/pnp/parsePnpXml.js +91 -3
  326. package/dist/pnp/types.d.ts +24 -1
  327. package/dist/pnp/types.d.ts.map +1 -1
  328. package/dist/types/index.d.ts +47 -0
  329. package/dist/types/index.d.ts.map +1 -1
  330. package/dist/types/interactions.d.ts +4 -408
  331. package/dist/types/interactions.d.ts.map +1 -1
  332. package/dist/types/interactions.js +3 -3
  333. package/dist/web-components/QTIInteractionBase.d.ts +5 -5
  334. package/dist/web-components/QTIInteractionBase.d.ts.map +1 -1
  335. package/dist/web-components/QTIInteractionElement.d.ts +11 -8
  336. package/dist/web-components/QTIInteractionElement.d.ts.map +1 -1
  337. package/dist/web-components/index.d.ts +1 -1
  338. package/dist/web-components/index.d.ts.map +1 -1
  339. package/package.json +6 -6
  340. package/src/catalog/applyGlossaryTriggers.ts +174 -34
  341. package/src/catalog/glossaryAction.ts +14 -4
  342. package/src/components/ItemBody.svelte +71 -200
  343. package/src/components/ItemPlayer.svelte +9 -5
  344. package/src/components/ModalFeedbackDisplay.svelte +15 -5
  345. package/src/components/utils/stimulusRender.ts +93 -0
  346. package/src/components/utils/stylesheetRender.ts +58 -0
  347. package/src/core/ComponentRegistry.ts +22 -7
  348. package/src/core/Player.ts +401 -209
  349. package/src/document/AssessmentItemDocument.ts +178 -0
  350. package/src/extraction/extractors/associateExtractor.ts +1 -133
  351. package/src/extraction/extractors/choiceExtractor.ts +1 -121
  352. package/src/extraction/extractors/customExtractor.ts +1 -72
  353. package/src/extraction/extractors/drawingExtractor.ts +1 -113
  354. package/src/extraction/extractors/endAttemptExtractor.ts +1 -74
  355. package/src/extraction/extractors/extendedTextExtractor.ts +1 -89
  356. package/src/extraction/extractors/gapMatchExtractor.ts +1 -193
  357. package/src/extraction/extractors/graphicAssociateExtractor.ts +1 -192
  358. package/src/extraction/extractors/graphicGapMatchExtractor.ts +1 -257
  359. package/src/extraction/extractors/graphicOrderExtractor.ts +1 -162
  360. package/src/extraction/extractors/hotspotExtractor.ts +1 -208
  361. package/src/extraction/extractors/hottextExtractor.ts +1 -163
  362. package/src/extraction/extractors/index.ts +5 -111
  363. package/src/extraction/extractors/inlineChoiceExtractor.ts +1 -105
  364. package/src/extraction/extractors/matchExtractor.ts +1 -187
  365. package/src/extraction/extractors/mediaExtractor.ts +1 -168
  366. package/src/extraction/extractors/orderExtractor.ts +1 -120
  367. package/src/extraction/extractors/portableCustomExtractor.ts +1 -122
  368. package/src/extraction/extractors/positionObjectExtractor.ts +1 -243
  369. package/src/extraction/extractors/selectPointExtractor.ts +1 -143
  370. package/src/extraction/extractors/sliderExtractor.ts +1 -102
  371. package/src/extraction/extractors/textEntryExtractor.ts +1 -79
  372. package/src/extraction/extractors/uploadExtractor.ts +1 -81
  373. package/src/extraction/index.ts +1 -2
  374. package/src/extraction/interactionExtractionPipeline.ts +70 -0
  375. package/src/extraction/interactionSecurity.ts +60 -0
  376. package/src/index.ts +3 -7
  377. package/src/interactions/associate/extractor.ts +133 -0
  378. package/src/interactions/associate/index.ts +2 -0
  379. package/src/interactions/associate/types.ts +1 -0
  380. package/src/interactions/choice/extractor.ts +121 -0
  381. package/src/interactions/choice/index.ts +2 -0
  382. package/src/interactions/choice/types.ts +1 -0
  383. package/src/interactions/custom/extractor.ts +72 -0
  384. package/src/interactions/custom/index.ts +2 -0
  385. package/src/interactions/custom/types.ts +1 -0
  386. package/src/interactions/drawing/extractor.ts +113 -0
  387. package/src/interactions/drawing/index.ts +2 -0
  388. package/src/interactions/drawing/types.ts +1 -0
  389. package/src/interactions/end-attempt/extractor.ts +74 -0
  390. package/src/interactions/end-attempt/index.ts +2 -0
  391. package/src/interactions/end-attempt/types.ts +1 -0
  392. package/src/interactions/extended-text/extractor.ts +89 -0
  393. package/src/interactions/extended-text/index.ts +2 -0
  394. package/src/interactions/extended-text/types.ts +1 -0
  395. package/src/interactions/gap-match/extractor.ts +193 -0
  396. package/src/interactions/gap-match/index.ts +2 -0
  397. package/src/interactions/gap-match/types.ts +1 -0
  398. package/src/interactions/graphic-associate/extractor.ts +192 -0
  399. package/src/interactions/graphic-associate/index.ts +2 -0
  400. package/src/interactions/graphic-associate/types.ts +1 -0
  401. package/src/interactions/graphic-gap-match/extractor.ts +257 -0
  402. package/src/interactions/graphic-gap-match/index.ts +2 -0
  403. package/src/interactions/graphic-gap-match/types.ts +1 -0
  404. package/src/interactions/graphic-order/extractor.ts +162 -0
  405. package/src/interactions/graphic-order/index.ts +2 -0
  406. package/src/interactions/graphic-order/types.ts +1 -0
  407. package/src/interactions/hotspot/extractor.ts +208 -0
  408. package/src/interactions/hotspot/index.ts +2 -0
  409. package/src/interactions/hotspot/types.ts +1 -0
  410. package/src/interactions/hottext/extractor.ts +163 -0
  411. package/src/interactions/hottext/index.ts +2 -0
  412. package/src/interactions/hottext/types.ts +1 -0
  413. package/src/interactions/index.ts +52 -0
  414. package/src/interactions/inline/index.ts +1 -0
  415. package/src/interactions/inline/render-plan.ts +105 -0
  416. package/src/interactions/inline-choice/InlineChoice.svelte +57 -0
  417. package/src/interactions/inline-choice/extractor.ts +105 -0
  418. package/src/interactions/inline-choice/index.ts +2 -0
  419. package/src/interactions/inline-choice/types.ts +1 -0
  420. package/src/interactions/match/extractor.ts +187 -0
  421. package/src/interactions/match/index.ts +2 -0
  422. package/src/interactions/match/types.ts +1 -0
  423. package/src/interactions/media/extractor.ts +168 -0
  424. package/src/interactions/media/index.ts +2 -0
  425. package/src/interactions/media/types.ts +1 -0
  426. package/src/interactions/modules.ts +111 -0
  427. package/src/interactions/order/extractor.ts +120 -0
  428. package/src/interactions/order/index.ts +2 -0
  429. package/src/interactions/order/types.ts +1 -0
  430. package/src/interactions/portable-custom/extractor.ts +122 -0
  431. package/src/interactions/portable-custom/index.ts +2 -0
  432. package/src/interactions/portable-custom/types.ts +1 -0
  433. package/src/interactions/position-object/extractor.ts +243 -0
  434. package/src/interactions/position-object/index.ts +2 -0
  435. package/src/interactions/position-object/types.ts +1 -0
  436. package/src/interactions/select-point/extractor.ts +143 -0
  437. package/src/interactions/select-point/index.ts +2 -0
  438. package/src/interactions/select-point/types.ts +1 -0
  439. package/src/interactions/shared/index.ts +1 -0
  440. package/src/interactions/shared/types.ts +429 -0
  441. package/src/interactions/slider/extractor.ts +102 -0
  442. package/src/interactions/slider/index.ts +2 -0
  443. package/src/interactions/slider/types.ts +1 -0
  444. package/src/interactions/text-entry/InlineTextEntry.svelte +75 -0
  445. package/src/interactions/text-entry/extractor.ts +79 -0
  446. package/src/interactions/text-entry/index.ts +2 -0
  447. package/src/interactions/text-entry/types.ts +1 -0
  448. package/src/interactions/upload/extractor.ts +81 -0
  449. package/src/interactions/upload/index.ts +2 -0
  450. package/src/interactions/upload/types.ts +1 -0
  451. package/src/pnp/applyPnp.ts +8 -2
  452. package/src/pnp/parsePnpXml.ts +102 -5
  453. package/src/pnp/types.ts +43 -1
  454. package/src/types/index.ts +53 -0
  455. package/src/types/interactions.ts +4 -425
  456. package/src/web-components/QTIInteractionBase.ts +6 -5
  457. package/src/web-components/QTIInteractionElement.ts +15 -8
  458. package/src/web-components/index.ts +1 -0
  459. package/src/__tests__/glossaryTriggers.test.ts +0 -411
  460. package/src/__tests__/pnp.test.ts +0 -250
  461. package/src/core/ItemRenderer.ts +0 -371
@@ -1,26 +1,46 @@
1
+ <script lang="ts" module>
2
+ let nextItemBodyScopeId = 0;
3
+ </script>
4
+
1
5
  <script lang="ts">
2
6
  import type { InteractionData } from '../types';
3
7
  import type { Player } from '../core/Player';
8
+ import type { InteractionResponseValue, QTIChangeEventDetail } from '../web-components';
4
9
  import type { I18nProvider } from '@pie-qti/i18n';
5
- import { normalizeHeuristicsConfig, type QtiHeuristicsConfig } from '@pie-qti/ims-cp-core';
10
+ import {
11
+ normalizeHeuristicsConfig,
12
+ type QtiHeuristicsConfig,
13
+ type ResolvedItemDeliveryContext
14
+ } from '@pie-qti/ims-cp-core';
6
15
  import { processFeedbackInline } from './utils/feedbackUtils';
7
16
  import { typesetAction } from './actions/typesetAction';
8
17
  import { glossaryAction } from '../catalog/glossaryAction';
9
18
  import { assignProps } from './utils/assignProps';
19
+ import { buildScopedStylesheetCss } from './utils/stylesheetRender';
20
+ import { buildEffectiveStimulusContent, injectStimulusContent } from './utils/stimulusRender';
10
21
  import { getRoleCapabilities } from '../core/rolePolicy';
22
+ import InlineChoice from '../interactions/inline-choice/InlineChoice.svelte';
23
+ import InlineTextEntry from '../interactions/text-entry/InlineTextEntry.svelte';
24
+ import { createInlineRenderPlan, isInlineInteractionTagName, isInlineInteractionType } from '../interactions/inline/render-plan';
25
+
26
+ type ItemResponseValue = InteractionResponseValue | null;
27
+ type ItemResponseMap = Record<string, ItemResponseValue>;
28
+ type QtiChangeDomEvent = CustomEvent<QTIChangeEventDetail<ItemResponseValue>>;
11
29
 
12
30
  interface Props {
13
31
  player: Player;
14
- responses?: Record<string, any>;
32
+ responses?: ItemResponseMap;
15
33
  disabled?: boolean;
16
34
  role?: 'candidate' | 'scorer' | 'author' | 'tutor' | 'proctor' | 'testConstructor';
17
35
  i18n?: I18nProvider;
18
36
  typeset?: (element: HTMLElement) => void;
19
- onResponseChange?: (responseId: string, value: any) => void;
37
+ onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
20
38
  outcomeValues?: Record<string, any>; // Needed for feedbackInline visibility
21
39
  heuristicsConfig?: QtiHeuristicsConfig; // Optional heuristics configuration
22
40
  /** QTI 3.0 shared stimulus content: map of stimulus identifier → HTML string */
23
41
  stimulusContent?: Record<string, string>;
42
+ /** Package/assessment-resolved QTI 3 delivery context. */
43
+ deliveryContext?: ResolvedItemDeliveryContext;
24
44
  }
25
45
 
26
46
  let {
@@ -34,7 +54,10 @@
34
54
  outcomeValues = {},
35
55
  heuristicsConfig,
36
56
  stimulusContent = {},
57
+ deliveryContext,
37
58
  }: Props = $props();
59
+ const itemBodyScope = `qti-item-body-${++nextItemBodyScopeId}`;
60
+ const itemBodyScopeSelector = `[data-qti-item-body-scope="${itemBodyScope}"]`;
38
61
 
39
62
  // Normalize heuristics configuration with defaults
40
63
  const heuristics = $derived(normalizeHeuristicsConfig(heuristicsConfig));
@@ -58,8 +81,7 @@
58
81
  interactions
59
82
  .filter(
60
83
  (interaction) =>
61
- interaction.type !== 'textEntryInteraction' &&
62
- interaction.type !== 'inlineChoiceInteraction'
84
+ !isInlineInteractionType(interaction.type)
63
85
  )
64
86
  .map((interaction) => {
65
87
  try {
@@ -82,58 +104,19 @@
82
104
  // Inline interactions are replaced with placeholders
83
105
  const itemBodyHtml = $derived.by(() => {
84
106
  let html = player.getItemBodyHtml();
107
+ const resolvedDeliveryContext = deliveryContext ?? player.getDeliveryContext();
108
+ const stylesheetCss = buildScopedStylesheetCss(resolvedDeliveryContext, itemBodyScopeSelector);
109
+ const effectiveStimulusContent = buildEffectiveStimulusContent(
110
+ resolvedDeliveryContext,
111
+ stimulusContent,
112
+ (content) => player.sanitizeHtmlContent(content)
113
+ );
85
114
 
86
- // QTI 3.0 Shared Stimulus: inject stimulus HTML at data-stimulus-idref docking points.
87
- // Any stimulus identifier that has no docking div is prepended to the body.
88
- if (stimulusContent && Object.keys(stimulusContent).length > 0) {
89
- const docked = new Set<string>();
90
- // Replace docking divs: <div ... data-stimulus-idref="ID" ...></div>
91
- html = html.replace(
92
- /<div([^>]*)\bdata-stimulus-idref="([^"]+)"([^>]*)>\s*<\/div>/gi,
93
- (match, before, identifier, after) => {
94
- const content = stimulusContent[identifier];
95
- if (content) {
96
- docked.add(identifier);
97
- // Preserve any other attributes on the docking div
98
- return `<div${before} data-stimulus-idref="${identifier}"${after} class="qti-stimulus-dock">${content}</div>`;
99
- }
100
- return match; // no content found — leave as-is
101
- }
102
- );
103
- // Prepend any stimuli that had no docking div
104
- const undocked = Object.entries(stimulusContent)
105
- .filter(([id]) => !docked.has(id))
106
- .map(([, content]) => `<div class="qti-stimulus-block">${content}</div>`)
107
- .join('');
108
- if (undocked) {
109
- html = undocked + html;
110
- }
115
+ html = injectStimulusContent(html, effectiveStimulusContent);
116
+ if (stylesheetCss) {
117
+ html = `<style data-qti-stylesheets="resolved">${stylesheetCss}</style>${html}`;
111
118
  }
112
119
 
113
- // Replace inline interactions with placeholders (they need to be rendered in-flow).
114
- // Handles both QTI 2.x camelCase and QTI 3.0 kebab-case element names.
115
- html = html
116
- // QTI 2.x: <textEntryInteraction responseIdentifier="..." />
117
- .replace(
118
- /<textEntryInteraction[^>]*responseIdentifier="([^"]+)"[^>]*?(?:\/>|><\/textEntryInteraction>)/gi,
119
- '[TEXTENTRY:$1]'
120
- )
121
- // QTI 3.0: <qti-text-entry-interaction response-identifier="..." />
122
- .replace(
123
- /<qti-text-entry-interaction[^>]*response-identifier="([^"]+)"[^>]*?(?:\/>|><\/qti-text-entry-interaction>)/gi,
124
- '[TEXTENTRY:$1]'
125
- )
126
- // QTI 2.x: <inlineChoiceInteraction responseIdentifier="...">...</inlineChoiceInteraction>
127
- .replace(
128
- /<inlineChoiceInteraction[^>]*responseIdentifier="([^"]+)"[^>]*>[\s\S]*?<\/inlineChoiceInteraction>/gi,
129
- '[INLINECHOICE:$1]'
130
- )
131
- // QTI 3.0: <qti-inline-choice-interaction response-identifier="...">...</qti-inline-choice-interaction>
132
- .replace(
133
- /<qti-inline-choice-interaction[^>]*response-identifier="([^"]+)"[^>]*>[\s\S]*?<\/qti-inline-choice-interaction>/gi,
134
- '[INLINECHOICE:$1]'
135
- );
136
-
137
120
  // Process feedbackInline elements - conditionally show/hide based on outcome values
138
121
  html = processFeedbackInline(html, {
139
122
  outcomeValues,
@@ -147,9 +130,8 @@
147
130
  /<(\w+Interaction|qti-[\w-]+-interaction)(\s[^>]*)?>[\s\S]*?<\/\1>/gi,
148
131
  (match, tagName) => {
149
132
  const lower = tagName.toLowerCase();
150
- // Skip inline interactions (already replaced with placeholders above)
151
- if (lower === 'textentryinteraction' || lower === 'inlinechoiceinteraction' ||
152
- lower === 'qti-text-entry-interaction' || lower === 'qti-inline-choice-interaction') {
133
+ // Inline interactions are rendered in-flow by the inline render plan.
134
+ if (isInlineInteractionTagName(lower)) {
153
135
  return match;
154
136
  }
155
137
  // Wrap block interactions with a hidden span
@@ -160,95 +142,19 @@
160
142
  return html;
161
143
  });
162
144
 
163
- // Inline interaction parsing (textEntry, inlineChoice) — kept local to avoid TS issues
164
- // around component props inference in runes mode.
165
- interface ParsedSegment {
166
- type: 'html' | 'textEntry' | 'inlineChoice';
167
- content?: string;
168
- interaction?: any;
169
- }
170
-
171
- const inlineSegments = $derived.by(() => {
172
- const html = itemBodyHtml;
173
- const result: ParsedSegment[] = [];
174
-
175
- let lastIndex = 0;
176
- let match: RegExpExecArray | null;
177
-
178
- // Find placeholders in order.
179
- const combinedPattern = /\[TEXTENTRY:([^\]]+)\]|\[INLINECHOICE:([^\]]+)\]/g;
180
-
181
- while ((match = combinedPattern.exec(html)) !== null) {
182
- if (match.index > lastIndex) {
183
- result.push({ type: 'html', content: html.substring(lastIndex, match.index) });
184
- }
185
-
186
- if (match[0].startsWith('[TEXTENTRY:')) {
187
- const responseId = match[1];
188
- const interaction = (interactions as any[]).find((i) => i.responseId === responseId);
189
- if (interaction) result.push({ type: 'textEntry', interaction });
190
- } else if (match[0].startsWith('[INLINECHOICE:')) {
191
- const responseId = match[2];
192
- const interaction = (interactions as any[]).find((i) => i.responseId === responseId);
193
- if (interaction) result.push({ type: 'inlineChoice', interaction });
194
- }
195
-
196
- lastIndex = match.index + match[0].length;
197
- }
198
-
199
- if (lastIndex < html.length) {
200
- result.push({ type: 'html', content: html.substring(lastIndex) });
201
- }
202
-
203
- if (result.length === 0) {
204
- result.push({ type: 'html', content: html });
205
- }
206
-
207
- return result;
208
- });
209
-
210
- function handleResponseChange(responseId: string, value: any) {
211
- onResponseChange(responseId, value);
212
- }
213
-
214
- let textEntryErrors = $state<Map<string, string>>(new Map());
145
+ const inlineSegments = $derived(createInlineRenderPlan(itemBodyHtml, interactions));
215
146
 
216
- function handleTextEntryInput(responseId: string, e: Event) {
217
- const input = e.currentTarget as HTMLInputElement | null;
218
- const value = input?.value ?? '';
219
- handleResponseChange(responseId, value);
220
- if (input?.validity.valid) {
221
- const m = new Map(textEntryErrors);
222
- m.delete(responseId);
223
- textEntryErrors = m;
224
- }
147
+ function getStringResponse(responseId: string): string {
148
+ const response = responses[responseId];
149
+ return typeof response === 'string' ? response : '';
225
150
  }
226
151
 
227
- function handleTextEntryInvalid(responseId: string, e: Event, customMessage?: string | null) {
228
- e.preventDefault();
229
- const msg = customMessage
230
- ?? i18n?.t('interactions.textEntry.patternError', 'Please match the required format')
231
- ?? 'Please match the required format';
232
- textEntryErrors = new Map(textEntryErrors).set(responseId, msg);
233
- }
234
-
235
- function handleTextEntryBlur(e: Event) {
236
- (e.currentTarget as HTMLInputElement | null)?.checkValidity();
237
- }
238
-
239
- function handleInlineChoiceChange(responseId: string, e: Event) {
240
- const value = (e.currentTarget as HTMLSelectElement | null)?.value ?? '';
241
- handleResponseChange(responseId, value);
242
- }
243
-
244
- // Helper to find correct choice for inline choice interactions
245
- function findCorrectChoice(choices: any[], correctAnswer: string | null): any {
246
- if (!correctAnswer) return null;
247
- return choices.find((c: any) => c.identifier === correctAnswer) || null;
152
+ function handleResponseChange(responseId: string, value: ItemResponseValue) {
153
+ onResponseChange(responseId, value);
248
154
  }
249
155
 
250
156
  // Handle qti:change events from web components
251
- function handleQtiChange(event: CustomEvent) {
157
+ function handleQtiChange(event: QtiChangeDomEvent) {
252
158
  const { responseId, value } = event.detail;
253
159
  handleResponseChange(responseId, value);
254
160
  }
@@ -258,7 +164,8 @@
258
164
  let rootEl: HTMLDivElement | null = $state(null);
259
165
  $effect(() => {
260
166
  if (!rootEl) return;
261
- const handler = (e: Event) => handleQtiChange(e as CustomEvent);
167
+ player.applyPnp(rootEl);
168
+ const handler = (e: Event) => handleQtiChange(e as QtiChangeDomEvent);
262
169
  const el = rootEl; // Capture reference for cleanup
263
170
  el.addEventListener('qti-change', handler as EventListener);
264
171
  return () => {
@@ -309,7 +216,13 @@
309
216
  }
310
217
  </script>
311
218
 
312
- <div bind:this={rootEl} class="qti-item-body" use:typesetAction={{ typeset }} use:glossaryAction={{ player }}>
219
+ <div
220
+ bind:this={rootEl}
221
+ class="qti-item-body"
222
+ data-qti-item-body-scope={itemBodyScope}
223
+ use:typesetAction={{ typeset }}
224
+ use:glossaryAction={{ player }}
225
+ >
313
226
  <!-- Item body with inline interactions -->
314
227
  <div class="prose max-w-none mb-4">
315
228
  <div class="inline-interaction-container">
@@ -318,68 +231,24 @@
318
231
  {@html segment.content}
319
232
  {:else if segment.type === 'textEntry'}
320
233
  {@const correctAnswer = roleCapabilities.canViewCorrectResponses ? (correctResponses[segment.interaction.responseId] ?? null) : null}
321
- {@const displayValue = roleCapabilities.canViewCorrectResponses && correctAnswer !== null ? correctAnswer : (responses[segment.interaction.responseId] || '')}
322
- {@const inputWidthClass = (segment.interaction.interactionClasses ?? []).find((c: string) => c.startsWith('qti-input-width-'))}
323
- {@const extraClasses = (segment.interaction.interactionClasses ?? []).filter((c: string) => !c.startsWith('qti-input-width-')).join(' ')}
324
- <input
325
- type="text"
326
- class={['input input-bordered input-sm inline-input', inputWidthClass ?? '', extraClasses].filter(Boolean).join(' ')}
327
- class:border-success={correctAnswer !== null}
328
- class:bg-success={correctAnswer !== null}
329
- class:bg-opacity-10={correctAnswer !== null}
330
- style={inputWidthClass ? 'min-width: 100px; display: inline-block; margin: 0 4px;' : `width: ${segment.interaction.expectedLength * 8}px; min-width: 100px; display: inline-block; margin: 0 4px;`}
331
- placeholder={segment.interaction.placeholderText || '...'}
332
- pattern={segment.interaction.patternMask || undefined}
333
- title={segment.interaction.patternMask ? `Format: ${segment.interaction.patternMask}` : undefined}
334
- data-format={segment.interaction.format || undefined}
335
- aria-label={`Text entry ${segment.interaction.responseId}${correctAnswer ? '. Correct answer: ' + correctAnswer : ''}`}
336
- aria-invalid={textEntryErrors.has(segment.interaction.responseId) ? 'true' : undefined}
337
- aria-describedby={textEntryErrors.has(segment.interaction.responseId) ? `${segment.interaction.responseId}-error` : undefined}
338
- value={displayValue}
339
- oninput={(e) => handleTextEntryInput(segment.interaction.responseId, e)}
340
- oninvalid={(e) => handleTextEntryInvalid(segment.interaction.responseId, e, segment.interaction.patternMaskMessage)}
341
- onblur={handleTextEntryBlur}
234
+ <InlineTextEntry
235
+ interaction={segment.interaction}
236
+ response={getStringResponse(segment.interaction.responseId)}
237
+ correctAnswer={roleCapabilities.canViewCorrectResponses ? correctAnswer : null}
342
238
  disabled={effectiveDisabled}
239
+ {i18n}
240
+ onResponseChange={handleResponseChange}
343
241
  />
344
- {#if textEntryErrors.has(segment.interaction.responseId)}
345
- <span
346
- id="{segment.interaction.responseId}-error"
347
- role="alert"
348
- class="qti-text-entry-error text-error text-xs"
349
- style="display: block;"
350
- >{textEntryErrors.get(segment.interaction.responseId)}</span>
351
- {/if}
352
242
  {:else if segment.type === 'inlineChoice'}
353
243
  {@const correctAnswer = roleCapabilities.canViewCorrectResponses ? (correctResponses[segment.interaction.responseId] ?? null) : null}
354
- {@const userResponse = responses[segment.interaction.responseId] || ''}
355
- {@const displayValue = roleCapabilities.canViewCorrectResponses && correctAnswer !== null ? correctAnswer : userResponse}
356
- {@const correctChoice = findCorrectChoice(segment.interaction.choices, correctAnswer)}
357
- <span class="inline-choice-wrapper" style="display: inline-block; position: relative;">
358
- <select
359
- class="select select-bordered select-sm inline-select"
360
- class:border-success={correctAnswer !== null}
361
- class:bg-success={correctAnswer !== null}
362
- class:bg-opacity-10={correctAnswer !== null}
363
- style="display: inline-block; margin: 0 4px; width: auto; min-width: 120px;"
364
- aria-label={`Inline choice ${segment.interaction.responseId}${correctAnswer && correctChoice ? '. Correct answer: ' + (correctChoice as any).text : ''}`}
365
- value={displayValue}
366
- onchange={(e) => handleInlineChoiceChange(segment.interaction.responseId, e)}
367
- disabled={effectiveDisabled}
368
- >
369
- <option value="">{segment.interaction.label ?? i18n?.t('interactions.inline.selectPlaceholder', 'Select...')}</option>
370
- {#each segment.interaction.choices as choice}
371
- {@const isCorrect = correctAnswer === choice.identifier}
372
- <option value={choice.identifier}>
373
- {choice.text}{isCorrect ? ' ✓' : ''}
374
- </option>
375
- {/each}
376
- </select>
377
- {#if correctAnswer !== null && correctChoice}
378
- <span class="badge badge-success badge-sm" style="position: absolute; top: -1.5rem; left: 0; white-space: nowrap; font-size: 0.7rem;">
379
- {i18n?.t('interactions.choice.correct', 'Correct') ?? 'Correct'}: {(correctChoice as any).text}
380
- </span>
381
- {/if}
382
- </span>
244
+ <InlineChoice
245
+ interaction={segment.interaction}
246
+ response={getStringResponse(segment.interaction.responseId)}
247
+ correctAnswer={roleCapabilities.canViewCorrectResponses ? correctAnswer : null}
248
+ disabled={effectiveDisabled}
249
+ {i18n}
250
+ onResponseChange={handleResponseChange}
251
+ />
383
252
  {/if}
384
253
  {/each}
385
254
  </div>
@@ -396,6 +265,8 @@
396
265
  interaction,
397
266
  response: responses[interaction.responseId] ?? null,
398
267
  correctResponse: roleCapabilities.canViewCorrectResponses ? correctRespForInteraction : null,
268
+ pnp: player.getPnp(),
269
+ eliminationTool: player.getPnp()?.cognitive?.eliminationTool === true,
399
270
  disabled: effectiveDisabled,
400
271
  // Avoid invalid ARIA role values on custom-element hosts.
401
272
  // Components default to candidate when role is omitted.
@@ -1,11 +1,15 @@
1
1
  <script lang="ts">
2
2
  import { Player } from '../core/Player';
3
- import type { AdaptiveAttemptResult, ModalFeedback, PlayerSecurityConfig, QTIRole } from '../types';
3
+ import type { AdaptiveAttemptResult, ModalFeedback, PlayerSecurityConfig, QTIRole, ScoringResult } from '../types';
4
+ import type { InteractionResponseValue } from '../web-components';
4
5
  import type { I18nProvider } from '@pie-qti/i18n';
5
6
  import { typesetMathInElement } from '@pie-qti/typeset-katex';
6
7
  import ItemBody from './ItemBody.svelte';
7
8
  import ModalFeedbackDisplay from './ModalFeedbackDisplay.svelte';
8
9
 
10
+ type ItemResponseValue = InteractionResponseValue | null;
11
+ type ItemResponseMap = Record<string, ItemResponseValue>;
12
+
9
13
  interface Props {
10
14
  itemXml: string;
11
15
  role?: QTIRole;
@@ -14,8 +18,8 @@
14
18
  disabled?: boolean;
15
19
  typeset?: (element: HTMLElement) => void;
16
20
  i18n?: I18nProvider;
17
- onResponseChange?: (responseId: string, value: any) => void;
18
- onSubmit?: (responses: Record<string, any>, scoringResult: any) => void;
21
+ onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
22
+ onSubmit?: (responses: ItemResponseMap, scoringResult: ScoringResult) => void;
19
23
  /** Called when adaptive item completes (all attempts exhausted) */
20
24
  onComplete?: (finalResult: AdaptiveAttemptResult) => void;
21
25
  }
@@ -37,7 +41,7 @@
37
41
 
38
42
  // Create player instance
39
43
  let player = $state<Player | null>(null);
40
- let responses = $state<Record<string, any>>({});
44
+ let responses = $state<ItemResponseMap>({});
41
45
  let error = $state<string | null>(null);
42
46
  let modalFeedback = $state<ModalFeedback[]>([]);
43
47
  let outcomeValues = $state<Record<string, any>>({});
@@ -63,7 +67,7 @@
63
67
  }
64
68
  });
65
69
 
66
- function handleResponseChange(responseId: string, value: any) {
70
+ function handleResponseChange(responseId: string, value: ItemResponseValue) {
67
71
  responses = { ...responses, [responseId]: value };
68
72
  onResponseChange?.(responseId, value);
69
73
  }
@@ -14,6 +14,8 @@
14
14
 
15
15
  // Show modal if there's feedback
16
16
  const hasActiveFeedback = $derived(feedback.length > 0);
17
+ const modalTitleId = 'item-player-modal-feedback-title';
18
+ const firstTitle = $derived(feedback.find((item) => item.title)?.title);
17
19
 
18
20
  function handleClose() {
19
21
  onClose?.();
@@ -29,13 +31,21 @@
29
31
 
30
32
  {#if hasActiveFeedback}
31
33
  <!-- DaisyUI Modal -->
32
- <dialog class="modal modal-open" onclick={handleBackdropClick}>
34
+ <dialog
35
+ open
36
+ class="modal modal-open"
37
+ aria-modal="true"
38
+ aria-labelledby={firstTitle ? modalTitleId : undefined}
39
+ aria-label={firstTitle ? undefined : (i18n?.t('feedback.title') ?? 'Feedback')}
40
+ onclick={handleBackdropClick}
41
+ >
33
42
  <div class="modal-box max-w-3xl">
34
43
  <!-- Close button -->
35
44
  <button
36
45
  class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"
46
+ type="button"
37
47
  onclick={handleClose}
38
- aria-label={i18n?.t('feedback.closeFeedback') ?? 'feedback.closeFeedback'}
48
+ aria-label={i18n?.t('feedback.closeFeedback') ?? 'Close feedback'}
39
49
  >
40
50
  ✕
41
51
  </button>
@@ -44,7 +54,7 @@
44
54
  {#each feedback as item, index}
45
55
  <div class="mb-4 {index < feedback.length - 1 ? 'border-b pb-4' : ''}">
46
56
  {#if item.title}
47
- <h3 class="font-bold text-lg mb-2">{item.title}</h3>
57
+ <h3 id={index === 0 ? modalTitleId : undefined} class="font-bold text-lg mb-2">{item.title}</h3>
48
58
  {/if}
49
59
 
50
60
  <!-- Render HTML content with MathJax support -->
@@ -65,8 +75,8 @@
65
75
 
66
76
  <!-- Action buttons -->
67
77
  <div class="modal-action">
68
- <button class="btn btn-primary" onclick={handleClose}>
69
- {i18n?.t('common.continue') ?? 'common.continue'}
78
+ <button class="btn btn-primary" type="button" onclick={handleClose}>
79
+ {i18n?.t('common.continue') ?? 'Continue'}
70
80
  </button>
71
81
  </div>
72
82
  </div>
@@ -0,0 +1,93 @@
1
+ import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';
2
+
3
+ export type StimulusSanitizer = (html: string) => string;
4
+
5
+ /**
6
+ * Build the effective stimulus content map for an item render.
7
+ *
8
+ * Resolved delivery-context content is the package/assessment source of truth.
9
+ * Explicit content remains as a compatibility override for older host wiring.
10
+ */
11
+ export function buildEffectiveStimulusContent(
12
+ deliveryContext: ResolvedItemDeliveryContext | undefined,
13
+ explicitStimulusContent: Record<string, string>,
14
+ sanitize: StimulusSanitizer
15
+ ): Record<string, string> {
16
+ const resolved = Object.fromEntries(
17
+ Object.entries(deliveryContext?.stimuli ?? {}).map(([identifier, stimulus]) => [
18
+ identifier,
19
+ sanitize(stimulus.bodyHtml),
20
+ ])
21
+ );
22
+ const explicit = Object.fromEntries(
23
+ Object.entries(explicitStimulusContent).map(([identifier, content]) => [identifier, sanitize(content)])
24
+ );
25
+ return { ...resolved, ...explicit };
26
+ }
27
+
28
+ /**
29
+ * Inject shared stimulus bodies at QTI refs or host-authored docking points.
30
+ *
31
+ * Any resolved stimulus that has no matching docking point is prepended in
32
+ * delivery-context order so undocked package content is still visible.
33
+ */
34
+ export function injectStimulusContent(itemBodyHtml: string, stimulusContent: Record<string, string>): string {
35
+ if (Object.keys(stimulusContent).length === 0) return itemBodyHtml;
36
+
37
+ const docked = new Set<string>();
38
+ let html = itemBodyHtml.replace(
39
+ /<([a-z][\w:-]*)([^>]*\bdata-stimulus-idref=(["'])([^"']+)\3[^>]*)>\s*<\/\1>/gi,
40
+ (match, tagName, attrs, _quote, identifier) => {
41
+ const content = stimulusContent[identifier];
42
+ if (!content) return match;
43
+ docked.add(identifier);
44
+ return `<${tagName}${mergeClassAttribute(attrs, 'qti-stimulus-dock')}>${content}</${tagName}>`;
45
+ }
46
+ );
47
+
48
+ html = html.replace(
49
+ /<qti-assessment-stimulus-ref\b([^>]*)\/?>\s*(?:<\/qti-assessment-stimulus-ref>)?/gi,
50
+ (match, attrs) => {
51
+ const identifier = extractAttribute(attrs, 'identifier');
52
+ if (!identifier) return match;
53
+ if (docked.has(identifier)) return '';
54
+ const content = stimulusContent[identifier];
55
+ if (!content) return match;
56
+ docked.add(identifier);
57
+ return `<div data-stimulus-idref="${escapeHtmlAttribute(identifier)}" class="qti-stimulus-dock">${content}</div>`;
58
+ }
59
+ );
60
+
61
+ const undocked = Object.entries(stimulusContent)
62
+ .filter(([identifier]) => !docked.has(identifier))
63
+ .map(
64
+ ([identifier, content]) =>
65
+ `<div data-stimulus-idref="${escapeHtmlAttribute(identifier)}" class="qti-stimulus-block">${content}</div>`
66
+ )
67
+ .join('');
68
+
69
+ return undocked ? undocked + html : html;
70
+ }
71
+
72
+ function extractAttribute(attrs: string, name: string): string | null {
73
+ const match = attrs.match(new RegExp(`\\b${name}\\s*=\\s*["']([^"']+)["']`, 'i'));
74
+ return match?.[1] ?? null;
75
+ }
76
+
77
+ function mergeClassAttribute(attrs: string, className: string): string {
78
+ const classMatch = attrs.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
79
+ if (!classMatch) return `${attrs} class="${className}"`;
80
+ const quote = classMatch[1]!;
81
+ const existing = classMatch[2] ?? '';
82
+ const classes = new Set(existing.split(/\s+/).filter(Boolean));
83
+ classes.add(className);
84
+ return attrs.replace(classMatch[0], `class=${quote}${Array.from(classes).join(' ')}${quote}`);
85
+ }
86
+
87
+ function escapeHtmlAttribute(value: string): string {
88
+ return value
89
+ .replace(/&/g, '&amp;')
90
+ .replace(/"/g, '&quot;')
91
+ .replace(/</g, '&lt;')
92
+ .replace(/>/g, '&gt;');
93
+ }
@@ -0,0 +1,58 @@
1
+ import type { ResolvedItemDeliveryContext, ResolvedQtiStylesheetRef } from '@pie-qti/ims-cp-core';
2
+
3
+ const BLOCKED_CSS = /@import\b|url\s*\(|<\/style|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:/i;
4
+
5
+ export function buildScopedStylesheetCss(
6
+ deliveryContext: ResolvedItemDeliveryContext | undefined,
7
+ scopeSelector = '[data-qti-item-body-scope]'
8
+ ): string {
9
+ if (!deliveryContext) return '';
10
+ return deliveryContext.stylesheets
11
+ .map((stylesheet) => stylesheetToScopedCss(stylesheet, scopeSelector))
12
+ .filter(Boolean)
13
+ .join('\n');
14
+ }
15
+
16
+ function stylesheetToScopedCss(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {
17
+ const css = stylesheet.cssText?.trim();
18
+ if (!css || BLOCKED_CSS.test(css)) return '';
19
+ const stylesheetScope = getStylesheetScopeSelector(stylesheet, scopeSelector);
20
+ const scoped = scopeCssRules(css, stylesheetScope);
21
+ if (!scoped) return '';
22
+ return scoped;
23
+ }
24
+
25
+ export function scopeCssRules(css: string, scopeSelector = '[data-qti-item-body-scope]'): string {
26
+ const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, '');
27
+ let scoped = '';
28
+ const rulePattern = /([^{}@]+)\{([^{}]*)\}/g;
29
+ for (const match of withoutComments.matchAll(rulePattern)) {
30
+ const selectorList = match[1]?.trim();
31
+ const declarations = match[2]?.trim();
32
+ if (!selectorList || !declarations) continue;
33
+ const selectors = selectorList
34
+ .split(',')
35
+ .map((selector) => scopeSelectorText(selector.trim(), scopeSelector))
36
+ .filter(Boolean);
37
+ if (selectors.length === 0) continue;
38
+ scoped += `${selectors.join(', ')} { ${declarations} }\n`;
39
+ }
40
+ return scoped.trim();
41
+ }
42
+
43
+ function getStylesheetScopeSelector(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {
44
+ if (stylesheet.source !== 'stimulus' || !stylesheet.stimulusIdentifier) return scopeSelector;
45
+ return `${scopeSelector} [data-stimulus-idref="${escapeCssString(stylesheet.stimulusIdentifier)}"]`;
46
+ }
47
+
48
+ function scopeSelectorText(selector: string, scopeSelector: string): string {
49
+ if (!selector) return '';
50
+ if (selector.startsWith(scopeSelector)) return selector;
51
+ if (selector === ':root' || selector === 'html' || selector === 'body') return scopeSelector;
52
+ if (selector.startsWith(':')) return `${scopeSelector}${selector}`;
53
+ return `${scopeSelector} ${selector}`;
54
+ }
55
+
56
+ function escapeCssString(value: string): string {
57
+ return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n|\r|\f/g, ' ');
58
+ }