@pie-qti/item-player 0.1.5 → 0.1.6

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 (432) hide show
  1. package/dist/core/ComponentRegistry.d.ts +5 -4
  2. package/dist/core/ComponentRegistry.d.ts.map +1 -1
  3. package/dist/core/ComponentRegistry.js +11 -4
  4. package/dist/core/ItemRenderer.d.ts.map +1 -1
  5. package/dist/core/ItemRenderer.js +5 -18
  6. package/dist/core/Player.d.ts +2 -2
  7. package/dist/core/Player.d.ts.map +1 -1
  8. package/dist/core/Player.js +46 -147
  9. package/dist/document/AssessmentItemDocument.d.ts +42 -0
  10. package/dist/document/AssessmentItemDocument.d.ts.map +1 -0
  11. package/dist/document/AssessmentItemDocument.js +116 -0
  12. package/dist/element.js +2515 -2294
  13. package/dist/element.js.map +1 -1
  14. package/dist/extraction/extractors/associateExtractor.d.ts +1 -28
  15. package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
  16. package/dist/extraction/extractors/associateExtractor.js +1 -97
  17. package/dist/extraction/extractors/choiceExtractor.d.ts +1 -26
  18. package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
  19. package/dist/extraction/extractors/choiceExtractor.js +1 -93
  20. package/dist/extraction/extractors/customExtractor.d.ts +1 -19
  21. package/dist/extraction/extractors/customExtractor.d.ts.map +1 -1
  22. package/dist/extraction/extractors/customExtractor.js +1 -51
  23. package/dist/extraction/extractors/drawingExtractor.d.ts +1 -29
  24. package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -1
  25. package/dist/extraction/extractors/drawingExtractor.js +1 -78
  26. package/dist/extraction/extractors/endAttemptExtractor.d.ts +1 -19
  27. package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -1
  28. package/dist/extraction/extractors/endAttemptExtractor.js +1 -53
  29. package/dist/extraction/extractors/extendedTextExtractor.d.ts +1 -20
  30. package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
  31. package/dist/extraction/extractors/extendedTextExtractor.js +1 -63
  32. package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -28
  33. package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
  34. package/dist/extraction/extractors/gapMatchExtractor.js +1 -155
  35. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -40
  36. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
  37. package/dist/extraction/extractors/graphicAssociateExtractor.js +1 -143
  38. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +1 -52
  39. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
  40. package/dist/extraction/extractors/graphicGapMatchExtractor.js +1 -205
  41. package/dist/extraction/extractors/graphicOrderExtractor.d.ts +1 -36
  42. package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -1
  43. package/dist/extraction/extractors/graphicOrderExtractor.js +1 -121
  44. package/dist/extraction/extractors/hotspotExtractor.d.ts +1 -37
  45. package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
  46. package/dist/extraction/extractors/hotspotExtractor.js +1 -159
  47. package/dist/extraction/extractors/hottextExtractor.d.ts +1 -25
  48. package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
  49. package/dist/extraction/extractors/hottextExtractor.js +1 -128
  50. package/dist/extraction/extractors/index.d.ts +5 -59
  51. package/dist/extraction/extractors/index.d.ts.map +1 -1
  52. package/dist/extraction/extractors/index.js +5 -85
  53. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +1 -24
  54. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
  55. package/dist/extraction/extractors/inlineChoiceExtractor.js +1 -80
  56. package/dist/extraction/extractors/matchExtractor.d.ts +1 -36
  57. package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
  58. package/dist/extraction/extractors/matchExtractor.js +1 -160
  59. package/dist/extraction/extractors/mediaExtractor.d.ts +1 -32
  60. package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -1
  61. package/dist/extraction/extractors/mediaExtractor.js +1 -125
  62. package/dist/extraction/extractors/orderExtractor.d.ts +1 -27
  63. package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
  64. package/dist/extraction/extractors/orderExtractor.js +1 -90
  65. package/dist/extraction/extractors/portableCustomExtractor.d.ts +1 -13
  66. package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -1
  67. package/dist/extraction/extractors/portableCustomExtractor.js +1 -96
  68. package/dist/extraction/extractors/positionObjectExtractor.d.ts +1 -58
  69. package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -1
  70. package/dist/extraction/extractors/positionObjectExtractor.js +1 -191
  71. package/dist/extraction/extractors/selectPointExtractor.d.ts +1 -30
  72. package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -1
  73. package/dist/extraction/extractors/selectPointExtractor.js +1 -109
  74. package/dist/extraction/extractors/sliderExtractor.d.ts +1 -23
  75. package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -1
  76. package/dist/extraction/extractors/sliderExtractor.js +1 -73
  77. package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -20
  78. package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
  79. package/dist/extraction/extractors/textEntryExtractor.js +1 -54
  80. package/dist/extraction/extractors/uploadExtractor.d.ts +1 -19
  81. package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
  82. package/dist/extraction/extractors/uploadExtractor.js +1 -59
  83. package/dist/extraction/index.d.ts +1 -1
  84. package/dist/extraction/index.d.ts.map +1 -1
  85. package/dist/extraction/index.js +2 -2
  86. package/dist/extraction/interactionExtractionPipeline.d.ts +13 -0
  87. package/dist/extraction/interactionExtractionPipeline.d.ts.map +1 -0
  88. package/dist/extraction/interactionExtractionPipeline.js +39 -0
  89. package/dist/extraction/interactionSecurity.d.ts +4 -0
  90. package/dist/extraction/interactionSecurity.d.ts.map +1 -0
  91. package/dist/extraction/interactionSecurity.js +48 -0
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +3 -3
  95. package/dist/interactions/associate/extractor.d.ts +29 -0
  96. package/dist/interactions/associate/extractor.d.ts.map +1 -0
  97. package/dist/interactions/associate/extractor.js +97 -0
  98. package/dist/interactions/associate/index.d.ts +3 -0
  99. package/dist/interactions/associate/index.d.ts.map +1 -0
  100. package/dist/interactions/associate/index.js +1 -0
  101. package/dist/interactions/associate/types.d.ts +2 -0
  102. package/dist/interactions/associate/types.d.ts.map +1 -0
  103. package/dist/interactions/associate/types.js +1 -0
  104. package/dist/interactions/choice/extractor.d.ts +27 -0
  105. package/dist/interactions/choice/extractor.d.ts.map +1 -0
  106. package/dist/interactions/choice/extractor.js +93 -0
  107. package/dist/interactions/choice/index.d.ts +3 -0
  108. package/dist/interactions/choice/index.d.ts.map +1 -0
  109. package/dist/interactions/choice/index.js +1 -0
  110. package/dist/interactions/choice/types.d.ts +2 -0
  111. package/dist/interactions/choice/types.d.ts.map +1 -0
  112. package/dist/interactions/choice/types.js +1 -0
  113. package/dist/interactions/custom/extractor.d.ts +20 -0
  114. package/dist/interactions/custom/extractor.d.ts.map +1 -0
  115. package/dist/interactions/custom/extractor.js +51 -0
  116. package/dist/interactions/custom/index.d.ts +3 -0
  117. package/dist/interactions/custom/index.d.ts.map +1 -0
  118. package/dist/interactions/custom/index.js +1 -0
  119. package/dist/interactions/custom/types.d.ts +2 -0
  120. package/dist/interactions/custom/types.d.ts.map +1 -0
  121. package/dist/interactions/custom/types.js +1 -0
  122. package/dist/interactions/drawing/extractor.d.ts +30 -0
  123. package/dist/interactions/drawing/extractor.d.ts.map +1 -0
  124. package/dist/interactions/drawing/extractor.js +78 -0
  125. package/dist/interactions/drawing/index.d.ts +3 -0
  126. package/dist/interactions/drawing/index.d.ts.map +1 -0
  127. package/dist/interactions/drawing/index.js +1 -0
  128. package/dist/interactions/drawing/types.d.ts +2 -0
  129. package/dist/interactions/drawing/types.d.ts.map +1 -0
  130. package/dist/interactions/drawing/types.js +1 -0
  131. package/dist/interactions/end-attempt/extractor.d.ts +20 -0
  132. package/dist/interactions/end-attempt/extractor.d.ts.map +1 -0
  133. package/dist/interactions/end-attempt/extractor.js +53 -0
  134. package/dist/interactions/end-attempt/index.d.ts +3 -0
  135. package/dist/interactions/end-attempt/index.d.ts.map +1 -0
  136. package/dist/interactions/end-attempt/index.js +1 -0
  137. package/dist/interactions/end-attempt/types.d.ts +2 -0
  138. package/dist/interactions/end-attempt/types.d.ts.map +1 -0
  139. package/dist/interactions/end-attempt/types.js +1 -0
  140. package/dist/interactions/extended-text/extractor.d.ts +21 -0
  141. package/dist/interactions/extended-text/extractor.d.ts.map +1 -0
  142. package/dist/interactions/extended-text/extractor.js +63 -0
  143. package/dist/interactions/extended-text/index.d.ts +3 -0
  144. package/dist/interactions/extended-text/index.d.ts.map +1 -0
  145. package/dist/interactions/extended-text/index.js +1 -0
  146. package/dist/interactions/extended-text/types.d.ts +2 -0
  147. package/dist/interactions/extended-text/types.d.ts.map +1 -0
  148. package/dist/interactions/extended-text/types.js +1 -0
  149. package/dist/interactions/gap-match/extractor.d.ts +29 -0
  150. package/dist/interactions/gap-match/extractor.d.ts.map +1 -0
  151. package/dist/interactions/gap-match/extractor.js +155 -0
  152. package/dist/interactions/gap-match/index.d.ts +3 -0
  153. package/dist/interactions/gap-match/index.d.ts.map +1 -0
  154. package/dist/interactions/gap-match/index.js +1 -0
  155. package/dist/interactions/gap-match/types.d.ts +2 -0
  156. package/dist/interactions/gap-match/types.d.ts.map +1 -0
  157. package/dist/interactions/gap-match/types.js +1 -0
  158. package/dist/interactions/graphic-associate/extractor.d.ts +41 -0
  159. package/dist/interactions/graphic-associate/extractor.d.ts.map +1 -0
  160. package/dist/interactions/graphic-associate/extractor.js +143 -0
  161. package/dist/interactions/graphic-associate/index.d.ts +3 -0
  162. package/dist/interactions/graphic-associate/index.d.ts.map +1 -0
  163. package/dist/interactions/graphic-associate/index.js +1 -0
  164. package/dist/interactions/graphic-associate/types.d.ts +2 -0
  165. package/dist/interactions/graphic-associate/types.d.ts.map +1 -0
  166. package/dist/interactions/graphic-associate/types.js +1 -0
  167. package/dist/interactions/graphic-gap-match/extractor.d.ts +53 -0
  168. package/dist/interactions/graphic-gap-match/extractor.d.ts.map +1 -0
  169. package/dist/interactions/graphic-gap-match/extractor.js +205 -0
  170. package/dist/interactions/graphic-gap-match/index.d.ts +3 -0
  171. package/dist/interactions/graphic-gap-match/index.d.ts.map +1 -0
  172. package/dist/interactions/graphic-gap-match/index.js +1 -0
  173. package/dist/interactions/graphic-gap-match/types.d.ts +2 -0
  174. package/dist/interactions/graphic-gap-match/types.d.ts.map +1 -0
  175. package/dist/interactions/graphic-gap-match/types.js +1 -0
  176. package/dist/interactions/graphic-order/extractor.d.ts +37 -0
  177. package/dist/interactions/graphic-order/extractor.d.ts.map +1 -0
  178. package/dist/interactions/graphic-order/extractor.js +121 -0
  179. package/dist/interactions/graphic-order/index.d.ts +3 -0
  180. package/dist/interactions/graphic-order/index.d.ts.map +1 -0
  181. package/dist/interactions/graphic-order/index.js +1 -0
  182. package/dist/interactions/graphic-order/types.d.ts +2 -0
  183. package/dist/interactions/graphic-order/types.d.ts.map +1 -0
  184. package/dist/interactions/graphic-order/types.js +1 -0
  185. package/dist/interactions/hotspot/extractor.d.ts +38 -0
  186. package/dist/interactions/hotspot/extractor.d.ts.map +1 -0
  187. package/dist/interactions/hotspot/extractor.js +159 -0
  188. package/dist/interactions/hotspot/index.d.ts +3 -0
  189. package/dist/interactions/hotspot/index.d.ts.map +1 -0
  190. package/dist/interactions/hotspot/index.js +1 -0
  191. package/dist/interactions/hotspot/types.d.ts +2 -0
  192. package/dist/interactions/hotspot/types.d.ts.map +1 -0
  193. package/dist/interactions/hotspot/types.js +1 -0
  194. package/dist/interactions/hottext/extractor.d.ts +26 -0
  195. package/dist/interactions/hottext/extractor.d.ts.map +1 -0
  196. package/dist/interactions/hottext/extractor.js +128 -0
  197. package/dist/interactions/hottext/index.d.ts +3 -0
  198. package/dist/interactions/hottext/index.d.ts.map +1 -0
  199. package/dist/interactions/hottext/index.js +1 -0
  200. package/dist/interactions/hottext/types.d.ts +2 -0
  201. package/dist/interactions/hottext/types.d.ts.map +1 -0
  202. package/dist/interactions/hottext/types.js +1 -0
  203. package/dist/interactions/index.d.ts +33 -0
  204. package/dist/interactions/index.d.ts.map +1 -0
  205. package/dist/interactions/index.js +30 -0
  206. package/dist/interactions/inline/index.d.ts +2 -0
  207. package/dist/interactions/inline/index.d.ts.map +1 -0
  208. package/dist/interactions/inline/index.js +1 -0
  209. package/dist/interactions/inline/render-plan.d.ts +19 -0
  210. package/dist/interactions/inline/render-plan.d.ts.map +1 -0
  211. package/dist/interactions/inline/render-plan.js +59 -0
  212. package/dist/interactions/inline-choice/extractor.d.ts +25 -0
  213. package/dist/interactions/inline-choice/extractor.d.ts.map +1 -0
  214. package/dist/interactions/inline-choice/extractor.js +80 -0
  215. package/dist/interactions/inline-choice/index.d.ts +3 -0
  216. package/dist/interactions/inline-choice/index.d.ts.map +1 -0
  217. package/dist/interactions/inline-choice/index.js +1 -0
  218. package/dist/interactions/inline-choice/types.d.ts +2 -0
  219. package/dist/interactions/inline-choice/types.d.ts.map +1 -0
  220. package/dist/interactions/inline-choice/types.js +1 -0
  221. package/dist/interactions/match/extractor.d.ts +37 -0
  222. package/dist/interactions/match/extractor.d.ts.map +1 -0
  223. package/dist/interactions/match/extractor.js +160 -0
  224. package/dist/interactions/match/index.d.ts +3 -0
  225. package/dist/interactions/match/index.d.ts.map +1 -0
  226. package/dist/interactions/match/index.js +1 -0
  227. package/dist/interactions/match/types.d.ts +2 -0
  228. package/dist/interactions/match/types.d.ts.map +1 -0
  229. package/dist/interactions/match/types.js +1 -0
  230. package/dist/interactions/media/extractor.d.ts +33 -0
  231. package/dist/interactions/media/extractor.d.ts.map +1 -0
  232. package/dist/interactions/media/extractor.js +125 -0
  233. package/dist/interactions/media/index.d.ts +3 -0
  234. package/dist/interactions/media/index.d.ts.map +1 -0
  235. package/dist/interactions/media/index.js +1 -0
  236. package/dist/interactions/media/types.d.ts +2 -0
  237. package/dist/interactions/media/types.d.ts.map +1 -0
  238. package/dist/interactions/media/types.js +1 -0
  239. package/dist/interactions/modules.d.ts +105 -0
  240. package/dist/interactions/modules.d.ts.map +1 -0
  241. package/dist/interactions/modules.js +86 -0
  242. package/dist/interactions/order/extractor.d.ts +28 -0
  243. package/dist/interactions/order/extractor.d.ts.map +1 -0
  244. package/dist/interactions/order/extractor.js +90 -0
  245. package/dist/interactions/order/index.d.ts +3 -0
  246. package/dist/interactions/order/index.d.ts.map +1 -0
  247. package/dist/interactions/order/index.js +1 -0
  248. package/dist/interactions/order/types.d.ts +2 -0
  249. package/dist/interactions/order/types.d.ts.map +1 -0
  250. package/dist/interactions/order/types.js +1 -0
  251. package/dist/interactions/portable-custom/extractor.d.ts +14 -0
  252. package/dist/interactions/portable-custom/extractor.d.ts.map +1 -0
  253. package/dist/interactions/portable-custom/extractor.js +96 -0
  254. package/dist/interactions/portable-custom/index.d.ts +3 -0
  255. package/dist/interactions/portable-custom/index.d.ts.map +1 -0
  256. package/dist/interactions/portable-custom/index.js +1 -0
  257. package/dist/interactions/portable-custom/types.d.ts +2 -0
  258. package/dist/interactions/portable-custom/types.d.ts.map +1 -0
  259. package/dist/interactions/portable-custom/types.js +1 -0
  260. package/dist/interactions/position-object/extractor.d.ts +59 -0
  261. package/dist/interactions/position-object/extractor.d.ts.map +1 -0
  262. package/dist/interactions/position-object/extractor.js +191 -0
  263. package/dist/interactions/position-object/index.d.ts +3 -0
  264. package/dist/interactions/position-object/index.d.ts.map +1 -0
  265. package/dist/interactions/position-object/index.js +1 -0
  266. package/dist/interactions/position-object/types.d.ts +2 -0
  267. package/dist/interactions/position-object/types.d.ts.map +1 -0
  268. package/dist/interactions/position-object/types.js +1 -0
  269. package/dist/interactions/select-point/extractor.d.ts +31 -0
  270. package/dist/interactions/select-point/extractor.d.ts.map +1 -0
  271. package/dist/interactions/select-point/extractor.js +109 -0
  272. package/dist/interactions/select-point/index.d.ts +3 -0
  273. package/dist/interactions/select-point/index.d.ts.map +1 -0
  274. package/dist/interactions/select-point/index.js +1 -0
  275. package/dist/interactions/select-point/types.d.ts +2 -0
  276. package/dist/interactions/select-point/types.d.ts.map +1 -0
  277. package/dist/interactions/select-point/types.js +1 -0
  278. package/dist/interactions/shared/index.d.ts +2 -0
  279. package/dist/interactions/shared/index.d.ts.map +1 -0
  280. package/dist/interactions/shared/index.js +1 -0
  281. package/dist/interactions/shared/types.d.ts +412 -0
  282. package/dist/interactions/shared/types.d.ts.map +1 -0
  283. package/dist/interactions/shared/types.js +7 -0
  284. package/dist/interactions/slider/extractor.d.ts +24 -0
  285. package/dist/interactions/slider/extractor.d.ts.map +1 -0
  286. package/dist/interactions/slider/extractor.js +73 -0
  287. package/dist/interactions/slider/index.d.ts +3 -0
  288. package/dist/interactions/slider/index.d.ts.map +1 -0
  289. package/dist/interactions/slider/index.js +1 -0
  290. package/dist/interactions/slider/types.d.ts +2 -0
  291. package/dist/interactions/slider/types.d.ts.map +1 -0
  292. package/dist/interactions/slider/types.js +1 -0
  293. package/dist/interactions/text-entry/extractor.d.ts +21 -0
  294. package/dist/interactions/text-entry/extractor.d.ts.map +1 -0
  295. package/dist/interactions/text-entry/extractor.js +54 -0
  296. package/dist/interactions/text-entry/index.d.ts +3 -0
  297. package/dist/interactions/text-entry/index.d.ts.map +1 -0
  298. package/dist/interactions/text-entry/index.js +1 -0
  299. package/dist/interactions/text-entry/types.d.ts +2 -0
  300. package/dist/interactions/text-entry/types.d.ts.map +1 -0
  301. package/dist/interactions/text-entry/types.js +1 -0
  302. package/dist/interactions/upload/extractor.d.ts +20 -0
  303. package/dist/interactions/upload/extractor.d.ts.map +1 -0
  304. package/dist/interactions/upload/extractor.js +59 -0
  305. package/dist/interactions/upload/index.d.ts +3 -0
  306. package/dist/interactions/upload/index.d.ts.map +1 -0
  307. package/dist/interactions/upload/index.js +1 -0
  308. package/dist/interactions/upload/types.d.ts +2 -0
  309. package/dist/interactions/upload/types.d.ts.map +1 -0
  310. package/dist/interactions/upload/types.js +1 -0
  311. package/dist/types/interactions.d.ts +4 -408
  312. package/dist/types/interactions.d.ts.map +1 -1
  313. package/dist/types/interactions.js +3 -3
  314. package/dist/web-components/QTIInteractionBase.d.ts +5 -5
  315. package/dist/web-components/QTIInteractionBase.d.ts.map +1 -1
  316. package/dist/web-components/QTIInteractionElement.d.ts +11 -8
  317. package/dist/web-components/QTIInteractionElement.d.ts.map +1 -1
  318. package/dist/web-components/index.d.ts +1 -1
  319. package/dist/web-components/index.d.ts.map +1 -1
  320. package/package.json +6 -6
  321. package/src/components/ItemBody.svelte +35 -173
  322. package/src/components/ItemPlayer.svelte +9 -5
  323. package/src/components/ModalFeedbackDisplay.svelte +15 -5
  324. package/src/core/ComponentRegistry.ts +22 -7
  325. package/src/core/Player.ts +48 -163
  326. package/src/document/AssessmentItemDocument.ts +178 -0
  327. package/src/extraction/extractors/associateExtractor.ts +1 -133
  328. package/src/extraction/extractors/choiceExtractor.ts +1 -121
  329. package/src/extraction/extractors/customExtractor.ts +1 -72
  330. package/src/extraction/extractors/drawingExtractor.ts +1 -113
  331. package/src/extraction/extractors/endAttemptExtractor.ts +1 -74
  332. package/src/extraction/extractors/extendedTextExtractor.ts +1 -89
  333. package/src/extraction/extractors/gapMatchExtractor.ts +1 -193
  334. package/src/extraction/extractors/graphicAssociateExtractor.ts +1 -192
  335. package/src/extraction/extractors/graphicGapMatchExtractor.ts +1 -257
  336. package/src/extraction/extractors/graphicOrderExtractor.ts +1 -162
  337. package/src/extraction/extractors/hotspotExtractor.ts +1 -208
  338. package/src/extraction/extractors/hottextExtractor.ts +1 -163
  339. package/src/extraction/extractors/index.ts +5 -111
  340. package/src/extraction/extractors/inlineChoiceExtractor.ts +1 -105
  341. package/src/extraction/extractors/matchExtractor.ts +1 -187
  342. package/src/extraction/extractors/mediaExtractor.ts +1 -168
  343. package/src/extraction/extractors/orderExtractor.ts +1 -120
  344. package/src/extraction/extractors/portableCustomExtractor.ts +1 -122
  345. package/src/extraction/extractors/positionObjectExtractor.ts +1 -243
  346. package/src/extraction/extractors/selectPointExtractor.ts +1 -143
  347. package/src/extraction/extractors/sliderExtractor.ts +1 -102
  348. package/src/extraction/extractors/textEntryExtractor.ts +1 -79
  349. package/src/extraction/extractors/uploadExtractor.ts +1 -81
  350. package/src/extraction/index.ts +1 -2
  351. package/src/extraction/interactionExtractionPipeline.ts +70 -0
  352. package/src/extraction/interactionSecurity.ts +60 -0
  353. package/src/index.ts +2 -7
  354. package/src/interactions/associate/extractor.ts +133 -0
  355. package/src/interactions/associate/index.ts +2 -0
  356. package/src/interactions/associate/types.ts +1 -0
  357. package/src/interactions/choice/extractor.ts +121 -0
  358. package/src/interactions/choice/index.ts +2 -0
  359. package/src/interactions/choice/types.ts +1 -0
  360. package/src/interactions/custom/extractor.ts +72 -0
  361. package/src/interactions/custom/index.ts +2 -0
  362. package/src/interactions/custom/types.ts +1 -0
  363. package/src/interactions/drawing/extractor.ts +113 -0
  364. package/src/interactions/drawing/index.ts +2 -0
  365. package/src/interactions/drawing/types.ts +1 -0
  366. package/src/interactions/end-attempt/extractor.ts +74 -0
  367. package/src/interactions/end-attempt/index.ts +2 -0
  368. package/src/interactions/end-attempt/types.ts +1 -0
  369. package/src/interactions/extended-text/extractor.ts +89 -0
  370. package/src/interactions/extended-text/index.ts +2 -0
  371. package/src/interactions/extended-text/types.ts +1 -0
  372. package/src/interactions/gap-match/extractor.ts +193 -0
  373. package/src/interactions/gap-match/index.ts +2 -0
  374. package/src/interactions/gap-match/types.ts +1 -0
  375. package/src/interactions/graphic-associate/extractor.ts +192 -0
  376. package/src/interactions/graphic-associate/index.ts +2 -0
  377. package/src/interactions/graphic-associate/types.ts +1 -0
  378. package/src/interactions/graphic-gap-match/extractor.ts +257 -0
  379. package/src/interactions/graphic-gap-match/index.ts +2 -0
  380. package/src/interactions/graphic-gap-match/types.ts +1 -0
  381. package/src/interactions/graphic-order/extractor.ts +162 -0
  382. package/src/interactions/graphic-order/index.ts +2 -0
  383. package/src/interactions/graphic-order/types.ts +1 -0
  384. package/src/interactions/hotspot/extractor.ts +208 -0
  385. package/src/interactions/hotspot/index.ts +2 -0
  386. package/src/interactions/hotspot/types.ts +1 -0
  387. package/src/interactions/hottext/extractor.ts +163 -0
  388. package/src/interactions/hottext/index.ts +2 -0
  389. package/src/interactions/hottext/types.ts +1 -0
  390. package/src/interactions/index.ts +52 -0
  391. package/src/interactions/inline/index.ts +1 -0
  392. package/src/interactions/inline/render-plan.ts +105 -0
  393. package/src/interactions/inline-choice/InlineChoice.svelte +57 -0
  394. package/src/interactions/inline-choice/extractor.ts +105 -0
  395. package/src/interactions/inline-choice/index.ts +2 -0
  396. package/src/interactions/inline-choice/types.ts +1 -0
  397. package/src/interactions/match/extractor.ts +187 -0
  398. package/src/interactions/match/index.ts +2 -0
  399. package/src/interactions/match/types.ts +1 -0
  400. package/src/interactions/media/extractor.ts +168 -0
  401. package/src/interactions/media/index.ts +2 -0
  402. package/src/interactions/media/types.ts +1 -0
  403. package/src/interactions/modules.ts +111 -0
  404. package/src/interactions/order/extractor.ts +120 -0
  405. package/src/interactions/order/index.ts +2 -0
  406. package/src/interactions/order/types.ts +1 -0
  407. package/src/interactions/portable-custom/extractor.ts +122 -0
  408. package/src/interactions/portable-custom/index.ts +2 -0
  409. package/src/interactions/portable-custom/types.ts +1 -0
  410. package/src/interactions/position-object/extractor.ts +243 -0
  411. package/src/interactions/position-object/index.ts +2 -0
  412. package/src/interactions/position-object/types.ts +1 -0
  413. package/src/interactions/select-point/extractor.ts +143 -0
  414. package/src/interactions/select-point/index.ts +2 -0
  415. package/src/interactions/select-point/types.ts +1 -0
  416. package/src/interactions/shared/index.ts +1 -0
  417. package/src/interactions/shared/types.ts +429 -0
  418. package/src/interactions/slider/extractor.ts +102 -0
  419. package/src/interactions/slider/index.ts +2 -0
  420. package/src/interactions/slider/types.ts +1 -0
  421. package/src/interactions/text-entry/InlineTextEntry.svelte +75 -0
  422. package/src/interactions/text-entry/extractor.ts +79 -0
  423. package/src/interactions/text-entry/index.ts +2 -0
  424. package/src/interactions/text-entry/types.ts +1 -0
  425. package/src/interactions/upload/extractor.ts +81 -0
  426. package/src/interactions/upload/index.ts +2 -0
  427. package/src/interactions/upload/types.ts +1 -0
  428. package/src/types/interactions.ts +4 -425
  429. package/src/web-components/QTIInteractionBase.ts +6 -5
  430. package/src/web-components/QTIInteractionElement.ts +15 -8
  431. package/src/web-components/index.ts +1 -0
  432. package/src/core/ItemRenderer.ts +0 -371
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Standard QTI hottextInteraction extractor
3
+ *
4
+ * Extracts data from hottextInteraction elements (select text spans)
5
+ */
6
+
7
+ import { sanitizeHtml } from '../../core/sanitizer.js';
8
+ import type { QTIElement } from '../shared/types.js';
9
+ import type { ElementExtractor } from '../../extraction/types.js';
10
+
11
+ /**
12
+ * Hottext data extracted from hottextInteraction elements
13
+ */
14
+ export interface HottextData {
15
+ hottextChoices: Array<{ identifier: string; text: string; classes?: string[] }>;
16
+ contentHtml: string;
17
+ maxChoices: number;
18
+ minChoices: number;
19
+ prompt: string | null;
20
+ }
21
+
22
+ /**
23
+ * Standard QTI hottext interaction extractor
24
+ * Handles hottextInteraction elements (selectable text spans)
25
+ */
26
+ export const standardHottextExtractor: ElementExtractor<HottextData> = {
27
+ id: 'qti:hottext-interaction',
28
+ name: 'QTI Standard Hottext Interaction',
29
+ priority: 10,
30
+ elementTypes: ['hottextInteraction'],
31
+ description: 'Extracts standard QTI hottextInteraction (select text spans)',
32
+
33
+ canHandle(element, _context) {
34
+ // All hottextInteraction elements are standard
35
+ return element.rawTagName === 'hottextInteraction' || element.rawTagName === 'qti-hottext-interaction';
36
+ },
37
+
38
+ extract(element, context) {
39
+ const { utils } = context;
40
+
41
+ // Extract hottext children (selectable text spans) - recursively search entire tree
42
+ const findHottextElements = (el: any): any[] => {
43
+ const results: any[] = [];
44
+ if (el.rawTagName === 'hottext' || el.rawTagName === 'qti-hottext') {
45
+ results.push(el);
46
+ }
47
+ if (el.childNodes) {
48
+ for (const child of el.childNodes) {
49
+ if (typeof child !== 'string') {
50
+ results.push(...findHottextElements(child));
51
+ }
52
+ }
53
+ }
54
+ return results;
55
+ };
56
+
57
+ const hottextElements = findHottextElements(element);
58
+ const hottextChoices = hottextElements.map((hottext) => {
59
+ const classes = utils.getClasses(hottext);
60
+ return {
61
+ identifier: utils.getAttribute(hottext, 'identifier', ''),
62
+ text: utils.getTextContent(hottext),
63
+ ...(classes.length > 0 ? { classes } : {}),
64
+ };
65
+ });
66
+
67
+ // Extract attributes
68
+ const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);
69
+ const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
70
+ const interactionClasses = utils.getClasses(element);
71
+ const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
72
+ const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
73
+
74
+ // Extract prompt (optional)
75
+ const promptElements = utils.getChildrenByTag(element, 'prompt');
76
+ const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
77
+
78
+ // Extract content HTML (all content except prompt)
79
+ let contentHtml = '';
80
+ for (const child of element.childNodes) {
81
+ // Skip prompt elements
82
+ if (
83
+ typeof child !== 'string' &&
84
+ (child as QTIElement).rawTagName !== 'prompt' &&
85
+ (child as QTIElement).rawTagName !== 'qti-prompt'
86
+ ) {
87
+ contentHtml += (child as QTIElement).outerHTML || child.toString();
88
+ } else if (typeof child === 'string') {
89
+ contentHtml += child;
90
+ }
91
+ }
92
+
93
+ // Sanitize extracted HTML before rendering via {@html} in the component.
94
+ contentHtml = sanitizeHtml(contentHtml, { security: context.config.security });
95
+
96
+ return {
97
+ hottextChoices,
98
+ contentHtml,
99
+ maxChoices,
100
+ minChoices,
101
+ prompt,
102
+ ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
103
+ ...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
104
+ ...(minSelectionsMessage ? { minSelectionsMessage } : {}),
105
+ };
106
+ },
107
+
108
+ validate(data) {
109
+ const errors: string[] = [];
110
+ const warnings: string[] = [];
111
+
112
+ // Validate hottextChoices exist
113
+ if (!data.hottextChoices || data.hottextChoices.length === 0) {
114
+ errors.push('hottextInteraction must have at least one hottext');
115
+ }
116
+
117
+ // Validate hottext identifiers
118
+ if (data.hottextChoices) {
119
+ const identifiers = new Set<string>();
120
+ for (const hottext of data.hottextChoices) {
121
+ if (!hottext.identifier) {
122
+ errors.push('All hottext elements must have an identifier');
123
+ } else if (identifiers.has(hottext.identifier)) {
124
+ errors.push(`Duplicate hottext identifier: ${hottext.identifier}`);
125
+ } else {
126
+ identifiers.add(hottext.identifier);
127
+ }
128
+ }
129
+ }
130
+
131
+ // Validate maxChoices
132
+ if (data.maxChoices < 0) {
133
+ errors.push('maxChoices must be non-negative');
134
+ }
135
+
136
+ // Warn if maxChoices exceeds hottext count
137
+ if (data.hottextChoices && data.maxChoices > data.hottextChoices.length) {
138
+ warnings.push(
139
+ `maxChoices (${data.maxChoices}) exceeds the number of hottext choices (${data.hottextChoices.length})`
140
+ );
141
+ }
142
+
143
+ // Validate minChoices
144
+ if (data.minChoices !== undefined && data.minChoices < 0) {
145
+ errors.push('minChoices must be non-negative');
146
+ }
147
+
148
+ // Validate minChoices <= maxChoices
149
+ if (
150
+ data.minChoices !== undefined &&
151
+ data.maxChoices > 0 &&
152
+ data.minChoices > data.maxChoices
153
+ ) {
154
+ errors.push('minChoices cannot exceed maxChoices');
155
+ }
156
+
157
+ return {
158
+ valid: errors.length === 0,
159
+ errors: errors.length > 0 ? errors : undefined,
160
+ warnings: warnings.length > 0 ? warnings : undefined,
161
+ };
162
+ },
163
+ };
@@ -0,0 +1,2 @@
1
+ export * from './extractor.js';
2
+ export type { HottextInteractionData } from './types.js';
@@ -0,0 +1 @@
1
+ export type { HottextInteractionData, HottextChoice } from '../shared/types.js';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Vertical QTI interaction modules.
3
+ *
4
+ * Each interaction folder owns the extractor entrypoint and interaction-specific
5
+ * type exports. Legacy extractor and type paths re-export from this module layer.
6
+ */
7
+
8
+ export type {
9
+ AssociableChoice,
10
+ AssociableHotspot,
11
+ BaseInteractionData,
12
+ GraphicAssociateHotspot,
13
+ GraphicOrderChoice,
14
+ HotspotChoice,
15
+ ImageData,
16
+ MediaElement,
17
+ Point,
18
+ PositionObjectStage,
19
+ QTIElement,
20
+ } from './shared/index.js';
21
+
22
+ export * from './associate/index.js';
23
+ export * from './choice/index.js';
24
+ export * from './custom/index.js';
25
+ export * from './drawing/index.js';
26
+ export * from './end-attempt/index.js';
27
+ export * from './extended-text/index.js';
28
+ export * from './gap-match/index.js';
29
+ export * from './graphic-associate/index.js';
30
+ export * from './graphic-gap-match/index.js';
31
+ export * from './graphic-order/index.js';
32
+ export * from './hotspot/index.js';
33
+ export * from './hottext/index.js';
34
+ export * from './inline/index.js';
35
+ export * from './inline-choice/index.js';
36
+ export * from './match/index.js';
37
+ export * from './media/index.js';
38
+ export * from './modules.js';
39
+ export * from './order/index.js';
40
+ export * from './portable-custom/index.js';
41
+ export * from './position-object/index.js';
42
+ export * from './select-point/index.js';
43
+ export * from './slider/index.js';
44
+ export * from './text-entry/index.js';
45
+ export * from './upload/index.js';
46
+
47
+ export type {
48
+ InteractionData,
49
+ InteractionDataMap,
50
+ InteractionType,
51
+ InteractionValueMap,
52
+ } from './shared/types.js';
@@ -0,0 +1 @@
1
+ export * from './render-plan.js';
@@ -0,0 +1,105 @@
1
+ import type { InlineChoiceInteractionData } from '../inline-choice/types.js';
2
+ import type { TextEntryInteractionData } from '../text-entry/types.js';
3
+ import type { InteractionData } from '../shared/types.js';
4
+ import {
5
+ isStandardInlineInteractionTagName,
6
+ isStandardInlineInteractionType,
7
+ } from '../modules.js';
8
+
9
+ export type InlineInteractionData = TextEntryInteractionData | InlineChoiceInteractionData;
10
+
11
+ export type InlineRenderSegment =
12
+ | { type: 'html'; content: string }
13
+ | { type: 'textEntry'; interaction: TextEntryInteractionData }
14
+ | { type: 'inlineChoice'; interaction: InlineChoiceInteractionData };
15
+
16
+ export function isInlineInteractionType(type: string): type is InlineInteractionData['type'] {
17
+ return isStandardInlineInteractionType(type);
18
+ }
19
+
20
+ export function isInlineInteractionTagName(tagName: string): boolean {
21
+ return isStandardInlineInteractionTagName(tagName);
22
+ }
23
+
24
+ export function createInlinePlaceholderHtml(html: string, interactions: InteractionData[]): string {
25
+ return html
26
+ .replace(
27
+ /<textEntryInteraction[^>]*responseIdentifier="([^"]+)"[^>]*?(?:\/>|><\/textEntryInteraction>)/gi,
28
+ (match, responseId: string) =>
29
+ hasInlineInteraction(interactions, responseId, 'textEntryInteraction')
30
+ ? placeholder('textEntry', responseId)
31
+ : match
32
+ )
33
+ .replace(
34
+ /<qti-text-entry-interaction[^>]*response-identifier="([^"]+)"[^>]*?(?:\/>|><\/qti-text-entry-interaction>)/gi,
35
+ (match, responseId: string) =>
36
+ hasInlineInteraction(interactions, responseId, 'textEntryInteraction')
37
+ ? placeholder('textEntry', responseId)
38
+ : match
39
+ )
40
+ .replace(
41
+ /<inlineChoiceInteraction[^>]*responseIdentifier="([^"]+)"[^>]*>[\s\S]*?<\/inlineChoiceInteraction>/gi,
42
+ (match, responseId: string) =>
43
+ hasInlineInteraction(interactions, responseId, 'inlineChoiceInteraction')
44
+ ? placeholder('inlineChoice', responseId)
45
+ : match
46
+ )
47
+ .replace(
48
+ /<qti-inline-choice-interaction[^>]*response-identifier="([^"]+)"[^>]*>[\s\S]*?<\/qti-inline-choice-interaction>/gi,
49
+ (match, responseId: string) =>
50
+ hasInlineInteraction(interactions, responseId, 'inlineChoiceInteraction')
51
+ ? placeholder('inlineChoice', responseId)
52
+ : match
53
+ );
54
+ }
55
+
56
+ export function createInlineRenderPlan(html: string, interactions: InteractionData[]): InlineRenderSegment[] {
57
+ const placeholderHtml = createInlinePlaceholderHtml(html, interactions);
58
+ const result: InlineRenderSegment[] = [];
59
+ const combinedPattern = /\[TEXTENTRY:([^\]]+)\]|\[INLINECHOICE:([^\]]+)\]/g;
60
+ let lastIndex = 0;
61
+ let match: RegExpExecArray | null;
62
+
63
+ while ((match = combinedPattern.exec(placeholderHtml)) !== null) {
64
+ if (match.index > lastIndex) {
65
+ result.push({ type: 'html', content: placeholderHtml.substring(lastIndex, match.index) });
66
+ }
67
+
68
+ if (match[0].startsWith('[TEXTENTRY:')) {
69
+ const interaction = findInlineInteraction(interactions, match[1], 'textEntryInteraction');
70
+ if (interaction) result.push({ type: 'textEntry', interaction });
71
+ } else {
72
+ const interaction = findInlineInteraction(interactions, match[2], 'inlineChoiceInteraction');
73
+ if (interaction) result.push({ type: 'inlineChoice', interaction });
74
+ }
75
+
76
+ lastIndex = match.index + match[0].length;
77
+ }
78
+
79
+ if (lastIndex < placeholderHtml.length) {
80
+ result.push({ type: 'html', content: placeholderHtml.substring(lastIndex) });
81
+ }
82
+
83
+ return result.length > 0 ? result : [{ type: 'html', content: placeholderHtml }];
84
+ }
85
+
86
+ function placeholder(kind: 'textEntry' | 'inlineChoice', responseId: string): string {
87
+ return kind === 'textEntry' ? `[TEXTENTRY:${responseId}]` : `[INLINECHOICE:${responseId}]`;
88
+ }
89
+
90
+ function hasInlineInteraction(
91
+ interactions: InteractionData[],
92
+ responseId: string,
93
+ type: InlineInteractionData['type']
94
+ ): boolean {
95
+ return Boolean(findInlineInteraction(interactions, responseId, type));
96
+ }
97
+
98
+ function findInlineInteraction<T extends InlineInteractionData['type']>(
99
+ interactions: InteractionData[],
100
+ responseId: string,
101
+ type: T
102
+ ): Extract<InlineInteractionData, { type: T }> | null {
103
+ return (interactions.find((interaction) => interaction.responseId === responseId && interaction.type === type) ??
104
+ null) as Extract<InlineInteractionData, { type: T }> | null;
105
+ }
@@ -0,0 +1,57 @@
1
+ <script lang="ts">
2
+ import type { I18nProvider } from '@pie-qti/i18n';
3
+ import type { InlineChoiceInteractionData } from './types.js';
4
+
5
+ interface Props {
6
+ interaction: InlineChoiceInteractionData;
7
+ response?: string;
8
+ correctAnswer?: string | null;
9
+ disabled?: boolean;
10
+ i18n?: I18nProvider;
11
+ onResponseChange?: (responseId: string, value: string) => void;
12
+ }
13
+
14
+ let {
15
+ interaction,
16
+ response = '',
17
+ correctAnswer = null,
18
+ disabled = false,
19
+ i18n,
20
+ onResponseChange = () => {},
21
+ }: Props = $props();
22
+
23
+ const displayValue = $derived(correctAnswer !== null ? correctAnswer : response);
24
+ const correctChoice = $derived(correctAnswer ? interaction.choices.find((choice) => choice.identifier === correctAnswer) : null);
25
+
26
+ function handleChange(event: Event) {
27
+ const value = (event.currentTarget as HTMLSelectElement | null)?.value ?? '';
28
+ onResponseChange(interaction.responseId, value);
29
+ }
30
+ </script>
31
+
32
+ <span class="inline-choice-wrapper" style="display: inline-block; position: relative;">
33
+ <select
34
+ class="select select-bordered select-sm inline-select"
35
+ class:border-success={correctAnswer !== null}
36
+ class:bg-success={correctAnswer !== null}
37
+ class:bg-opacity-10={correctAnswer !== null}
38
+ style="display: inline-block; margin: 0 4px; width: auto; min-width: 120px;"
39
+ aria-label={`Inline choice ${interaction.responseId}${correctAnswer && correctChoice ? '. Correct answer: ' + correctChoice.text : ''}`}
40
+ value={displayValue}
41
+ onchange={handleChange}
42
+ {disabled}
43
+ >
44
+ <option value="">{interaction.label ?? interaction.dataPrompt ?? i18n?.t('interactions.inline.selectPlaceholder', 'Select...')}</option>
45
+ {#each interaction.choices as choice}
46
+ {@const isCorrect = correctAnswer === choice.identifier}
47
+ <option value={choice.identifier}>
48
+ {choice.text}{isCorrect ? ' ✓' : ''}
49
+ </option>
50
+ {/each}
51
+ </select>
52
+ {#if correctAnswer !== null && correctChoice}
53
+ <span class="badge badge-success badge-sm" style="position: absolute; top: -1.5rem; left: 0; white-space: nowrap; font-size: 0.7rem;">
54
+ {i18n?.t('interactions.choice.correct', 'Correct') ?? 'Correct'}: {correctChoice.text}
55
+ </span>
56
+ {/if}
57
+ </span>
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Standard QTI inlineChoiceInteraction extractor
3
+ *
4
+ * Extracts data from inlineChoiceInteraction elements (dropdown in text)
5
+ */
6
+
7
+ import type { ElementExtractor } from '../../extraction/types.js';
8
+
9
+ /**
10
+ * Inline choice data extracted from inlineChoiceInteraction elements
11
+ */
12
+ export interface InlineChoiceData {
13
+ choices: Array<{ identifier: string; text: string; fixed?: boolean }>;
14
+ shuffle: boolean;
15
+ /** Text from the QTI <label> child element; used as the placeholder "Select…" option */
16
+ label: string | null;
17
+ }
18
+
19
+ /**
20
+ * Standard QTI inline choice interaction extractor
21
+ * Handles inlineChoiceInteraction elements (dropdown selections within text)
22
+ */
23
+ export const standardInlineChoiceExtractor: ElementExtractor<InlineChoiceData> = {
24
+ id: 'qti:inline-choice-interaction',
25
+ name: 'QTI Standard Inline Choice Interaction',
26
+ priority: 10,
27
+ elementTypes: ['inlineChoiceInteraction'],
28
+ description: 'Extracts standard QTI inlineChoiceInteraction (dropdown in text)',
29
+
30
+ canHandle(element, _context) {
31
+ // All inlineChoiceInteraction elements are standard
32
+ return element.rawTagName === 'inlineChoiceInteraction' || element.rawTagName === 'qti-inline-choice-interaction';
33
+ },
34
+
35
+ extract(element, context) {
36
+ const { utils } = context;
37
+
38
+ // Extract choices (inlineChoice children)
39
+ const inlineChoices = utils.getChildrenByTag(element, 'inlineChoice');
40
+ const choices = inlineChoices.map((choice) => {
41
+ const fixed = utils.getBooleanAttribute(choice, 'fixed');
42
+ return {
43
+ identifier: utils.getAttribute(choice, 'identifier', ''),
44
+ text: utils.getTextContent(choice),
45
+ ...(fixed ? { fixed } : {}),
46
+ };
47
+ });
48
+
49
+ // Extract <label> child — used as placeholder text in the dropdown
50
+ const labelElements = utils.getChildrenByTag(element, 'label');
51
+ const label = labelElements.length > 0 ? utils.getTextContent(labelElements[0]) : null;
52
+
53
+ // data-prompt: alternative placeholder for the dropdown default option
54
+ const dataPrompt = utils.getAttribute(element, 'data-prompt', '') || null;
55
+
56
+ // Extract attributes
57
+ const shuffle = utils.getBooleanAttribute(element, 'shuffle');
58
+ const interactionClasses = utils.getClasses(element);
59
+
60
+ return {
61
+ choices,
62
+ shuffle,
63
+ label,
64
+ ...(dataPrompt ? { dataPrompt } : {}),
65
+ ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
66
+ };
67
+ },
68
+
69
+ validate(data) {
70
+ const errors: string[] = [];
71
+ const warnings: string[] = [];
72
+
73
+ // Validate choices exist
74
+ if (!data.choices || data.choices.length === 0) {
75
+ errors.push('inlineChoiceInteraction must have at least one choice');
76
+ }
77
+
78
+ // Validate choice identifiers
79
+ if (data.choices) {
80
+ const identifiers = new Set<string>();
81
+ for (const choice of data.choices) {
82
+ if (!choice.identifier) {
83
+ errors.push('All choices must have an identifier');
84
+ } else if (identifiers.has(choice.identifier)) {
85
+ errors.push(`Duplicate choice identifier: ${choice.identifier}`);
86
+ } else {
87
+ identifiers.add(choice.identifier);
88
+ }
89
+ }
90
+
91
+ // Warn if too many choices
92
+ if (data.choices.length >= 10) {
93
+ warnings.push(
94
+ `inlineChoiceInteraction has ${data.choices.length} choices - consider limiting for better usability`
95
+ );
96
+ }
97
+ }
98
+
99
+ return {
100
+ valid: errors.length === 0,
101
+ errors: errors.length > 0 ? errors : undefined,
102
+ warnings: warnings.length > 0 ? warnings : undefined,
103
+ };
104
+ },
105
+ };
@@ -0,0 +1,2 @@
1
+ export * from './extractor.js';
2
+ export type { InlineChoiceInteractionData } from './types.js';
@@ -0,0 +1 @@
1
+ export type { InlineChoiceInteractionData } from '../shared/types.js';
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Standard QTI matchInteraction extractor
3
+ *
4
+ * Extracts data from matchInteraction elements (matching pairs)
5
+ */
6
+
7
+ import type { ElementExtractor } from '../../extraction/types.js';
8
+
9
+ /**
10
+ * Match data extracted from matchInteraction elements
11
+ */
12
+ export interface MatchData {
13
+ sourceSet: Array<{ identifier: string; text: string; matchMax: number; matchMin?: number; matchGroup?: string[]; classes?: string[] }>;
14
+ targetSet: Array<{ identifier: string; text: string; matchMax: number; matchMin?: number; matchGroup?: string[]; classes?: string[] }>;
15
+ shuffle: boolean;
16
+ maxAssociations: number;
17
+ minAssociations?: number;
18
+ prompt: string | null;
19
+ }
20
+
21
+ /**
22
+ * Standard QTI match interaction extractor
23
+ * Handles matchInteraction elements (matching pairs between two sets)
24
+ */
25
+ export const standardMatchExtractor: ElementExtractor<MatchData> = {
26
+ id: 'qti:match-interaction',
27
+ name: 'QTI Standard Match Interaction',
28
+ priority: 10,
29
+ elementTypes: ['matchInteraction'],
30
+ description: 'Extracts standard QTI matchInteraction (matching pairs)',
31
+
32
+ canHandle(element, _context) {
33
+ // All matchInteraction elements are standard (both QTI 2.x and 3.0)
34
+ return element.rawTagName === 'matchInteraction' || element.rawTagName === 'qti-match-interaction';
35
+ },
36
+
37
+ extract(element, context) {
38
+ const { utils } = context;
39
+
40
+ // Extract all simpleAssociableChoice children
41
+ const allChoices = utils.getChildrenByTag(element, 'simpleAssociableChoice');
42
+
43
+ // Determine which are source vs target based on matchSet structure
44
+ // In QTI, matchInteraction can have two simpleMatchSet elements
45
+ const matchSets = utils.getChildrenByTag(element, 'simpleMatchSet');
46
+
47
+ let sourceSet: Array<{ identifier: string; text: string; matchMax: number; matchMin?: number; matchGroup?: string[]; classes?: string[] }> = [];
48
+ let targetSet: Array<{ identifier: string; text: string; matchMax: number; matchMin?: number; matchGroup?: string[]; classes?: string[] }> = [];
49
+
50
+ if (matchSets.length >= 2) {
51
+ // Extract choices from first matchSet (source)
52
+ const sourceMatchSet = matchSets[0];
53
+ const sourceElements = utils.getChildrenByTag(sourceMatchSet, 'simpleAssociableChoice');
54
+ sourceSet = sourceElements.map((choice) => {
55
+ const classes = utils.getClasses(choice);
56
+ const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
57
+ const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
58
+ const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
59
+ const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
60
+ return {
61
+ identifier: utils.getAttribute(choice, 'identifier', ''),
62
+ text: utils.getHtmlContent(choice),
63
+ matchMax,
64
+ ...(matchMin > 0 ? { matchMin } : {}),
65
+ ...(matchGroup.length > 0 ? { matchGroup } : {}),
66
+ ...(classes.length > 0 ? { classes } : {}),
67
+ };
68
+ });
69
+
70
+ // Extract choices from second matchSet (target)
71
+ const targetMatchSet = matchSets[1];
72
+ const targetElements = utils.getChildrenByTag(targetMatchSet, 'simpleAssociableChoice');
73
+ targetSet = targetElements.map((choice) => {
74
+ const classes = utils.getClasses(choice);
75
+ const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
76
+ const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
77
+ const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
78
+ const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
79
+ return {
80
+ identifier: utils.getAttribute(choice, 'identifier', ''),
81
+ text: utils.getHtmlContent(choice),
82
+ matchMax,
83
+ ...(matchMin > 0 ? { matchMin } : {}),
84
+ ...(matchGroup.length > 0 ? { matchGroup } : {}),
85
+ ...(classes.length > 0 ? { classes } : {}),
86
+ };
87
+ });
88
+ } else {
89
+ // Fallback: treat all choices as both source and target
90
+ const extractedChoices = allChoices.map((choice) => {
91
+ const classes = utils.getClasses(choice);
92
+ const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
93
+ const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
94
+ const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
95
+ const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
96
+ return {
97
+ identifier: utils.getAttribute(choice, 'identifier', ''),
98
+ text: utils.getHtmlContent(choice),
99
+ matchMax,
100
+ ...(matchMin > 0 ? { matchMin } : {}),
101
+ ...(matchGroup.length > 0 ? { matchGroup } : {}),
102
+ ...(classes.length > 0 ? { classes } : {}),
103
+ };
104
+ });
105
+ sourceSet = extractedChoices;
106
+ targetSet = extractedChoices;
107
+ }
108
+
109
+ // Extract attributes
110
+ const shuffle = utils.getBooleanAttribute(element, 'shuffle');
111
+ const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 1);
112
+ const minAssociationsRaw = utils.getNumberAttribute(element, 'minAssociations', 0);
113
+ const minAssociations = minAssociationsRaw > 0 ? minAssociationsRaw : undefined;
114
+ const interactionClasses = utils.getClasses(element);
115
+ const maxSelectionsMessage = utils.getAttribute(element, 'data-qti-max-selections-message', '') || null;
116
+ const minSelectionsMessage = utils.getAttribute(element, 'data-qti-min-selections-message', '') || null;
117
+ const firstColumnHeader = utils.getAttribute(element, 'data-qti-first-column-header', '') || null;
118
+
119
+ // Extract prompt (optional)
120
+ const promptElements = utils.getChildrenByTag(element, 'prompt');
121
+ const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
122
+
123
+ return {
124
+ sourceSet,
125
+ targetSet,
126
+ shuffle,
127
+ maxAssociations,
128
+ ...(minAssociations !== undefined ? { minAssociations } : {}),
129
+ prompt,
130
+ ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
131
+ ...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
132
+ ...(minSelectionsMessage ? { minSelectionsMessage } : {}),
133
+ ...(firstColumnHeader ? { firstColumnHeader } : {}),
134
+ };
135
+ },
136
+
137
+ validate(data) {
138
+ const errors: string[] = [];
139
+
140
+ // Validate source choices exist
141
+ if (!data.sourceSet || data.sourceSet.length === 0) {
142
+ errors.push('matchInteraction must have at least one source choice');
143
+ }
144
+
145
+ // Validate target choices exist
146
+ if (!data.targetSet || data.targetSet.length === 0) {
147
+ errors.push('matchInteraction must have at least one target choice');
148
+ }
149
+
150
+ // Validate choice identifiers
151
+ if (data.sourceSet) {
152
+ const identifiers = new Set<string>();
153
+ for (const choice of data.sourceSet) {
154
+ if (!choice.identifier) {
155
+ errors.push('All source choices must have an identifier');
156
+ } else if (identifiers.has(choice.identifier)) {
157
+ errors.push(`Duplicate source identifier: ${choice.identifier}`);
158
+ } else {
159
+ identifiers.add(choice.identifier);
160
+ }
161
+ }
162
+ }
163
+
164
+ if (data.targetSet) {
165
+ const identifiers = new Set<string>();
166
+ for (const choice of data.targetSet) {
167
+ if (!choice.identifier) {
168
+ errors.push('All target choices must have an identifier');
169
+ } else if (identifiers.has(choice.identifier)) {
170
+ errors.push(`Duplicate target identifier: ${choice.identifier}`);
171
+ } else {
172
+ identifiers.add(choice.identifier);
173
+ }
174
+ }
175
+ }
176
+
177
+ // Validate maxAssociations
178
+ if (data.maxAssociations < 0) {
179
+ errors.push('maxAssociations must be non-negative');
180
+ }
181
+
182
+ return {
183
+ valid: errors.length === 0,
184
+ errors: errors.length > 0 ? errors : undefined,
185
+ };
186
+ },
187
+ };