@pie-qti/item-player 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +466 -0
  4. package/docs/QTI-COMPLIANCE.md +197 -0
  5. package/docs/WCAG-2.2-COMPLIANCE.md +466 -0
  6. package/docs/custom-extractors.md +679 -0
  7. package/docs/iframe-mode.md +78 -0
  8. package/docs/security-audit.md +236 -0
  9. package/docs/server-api.md +691 -0
  10. package/package.json +78 -0
  11. package/src/components/ItemBody.svelte +382 -0
  12. package/src/components/ItemPlayer.svelte +155 -0
  13. package/src/components/ModalFeedbackDisplay.svelte +87 -0
  14. package/src/components/actions/typesetAction.ts +74 -0
  15. package/src/components/index.ts +19 -0
  16. package/src/components/utils/assignProps.ts +24 -0
  17. package/src/components/utils/feedbackUtils.ts +140 -0
  18. package/src/components/utils/index.ts +13 -0
  19. package/src/core/ComponentRegistry.ts +219 -0
  20. package/src/core/ItemRenderer.ts +367 -0
  21. package/src/core/Player.ts +1152 -0
  22. package/src/core/Plugin.ts +123 -0
  23. package/src/core/PluginManager.ts +182 -0
  24. package/src/core/constants.ts +117 -0
  25. package/src/core/declarations.ts +171 -0
  26. package/src/core/parsingLimits.ts +62 -0
  27. package/src/core/random.ts +24 -0
  28. package/src/core/sanitizer.ts +235 -0
  29. package/src/core/trustedTypes.ts +63 -0
  30. package/src/core/urlPolicy.ts +95 -0
  31. package/src/extensions/MathLiveEditor.ts +310 -0
  32. package/src/extraction/ExtractionRegistry.ts +295 -0
  33. package/src/extraction/createContext.ts +47 -0
  34. package/src/extraction/extractors/associateExtractor.ts +129 -0
  35. package/src/extraction/extractors/choiceExtractor.ts +110 -0
  36. package/src/extraction/extractors/customExtractor.ts +72 -0
  37. package/src/extraction/extractors/drawingExtractor.ts +113 -0
  38. package/src/extraction/extractors/endAttemptExtractor.ts +74 -0
  39. package/src/extraction/extractors/extendedTextExtractor.ts +80 -0
  40. package/src/extraction/extractors/gapMatchExtractor.ts +178 -0
  41. package/src/extraction/extractors/graphicAssociateExtractor.ts +188 -0
  42. package/src/extraction/extractors/graphicGapMatchExtractor.ts +185 -0
  43. package/src/extraction/extractors/graphicOrderExtractor.ts +162 -0
  44. package/src/extraction/extractors/hotspotExtractor.ts +190 -0
  45. package/src/extraction/extractors/hottextExtractor.ts +153 -0
  46. package/src/extraction/extractors/index.ts +111 -0
  47. package/src/extraction/extractors/inlineChoiceExtractor.ts +88 -0
  48. package/src/extraction/extractors/matchExtractor.ts +160 -0
  49. package/src/extraction/extractors/mediaExtractor.ts +168 -0
  50. package/src/extraction/extractors/orderExtractor.ts +114 -0
  51. package/src/extraction/extractors/positionObjectExtractor.ts +243 -0
  52. package/src/extraction/extractors/selectPointExtractor.ts +143 -0
  53. package/src/extraction/extractors/sliderExtractor.ts +102 -0
  54. package/src/extraction/extractors/textEntryExtractor.ts +70 -0
  55. package/src/extraction/extractors/uploadExtractor.ts +73 -0
  56. package/src/extraction/index.ts +109 -0
  57. package/src/extraction/types.ts +246 -0
  58. package/src/extraction/utils.ts +160 -0
  59. package/src/iframe/IFramePlayerHost.ts +265 -0
  60. package/src/iframe/index.ts +11 -0
  61. package/src/iframe/protocol.ts +137 -0
  62. package/src/index.ts +87 -0
  63. package/src/server.ts +14 -0
  64. package/src/types/index.ts +301 -0
  65. package/src/types/interactions.ts +354 -0
  66. package/src/types/responseValidation.ts +29 -0
  67. package/src/utils/PerformanceMonitor.ts +335 -0
  68. package/src/utils/responseUtils.ts +51 -0
  69. package/src/utils/touchDragHelper.ts +211 -0
  70. package/src/web-components/QTIInteractionBase.ts +302 -0
  71. package/src/web-components/QTIInteractionElement.ts +118 -0
  72. package/src/web-components/index.ts +21 -0
  73. package/tests/conformance/FIXTURE_POLICY.md +29 -0
  74. package/tests/conformance/README.md +70 -0
  75. package/tests/conformance/fixtures/baseTypes_all/cases.json +61 -0
  76. package/tests/conformance/fixtures/baseTypes_all/item.xml +131 -0
  77. package/tests/conformance/fixtures/baseTypes_all/manifest.json +7 -0
  78. package/tests/conformance/fixtures/choice_match_correct/cases.json +17 -0
  79. package/tests/conformance/fixtures/choice_match_correct/item.xml +55 -0
  80. package/tests/conformance/fixtures/choice_match_correct/manifest.json +14 -0
  81. package/tests/conformance/fixtures/contains_multiple/cases.json +12 -0
  82. package/tests/conformance/fixtures/contains_multiple/item.xml +37 -0
  83. package/tests/conformance/fixtures/contains_multiple/manifest.json +13 -0
  84. package/tests/conformance/fixtures/isNull_isNotNull/cases.json +9 -0
  85. package/tests/conformance/fixtures/isNull_isNotNull/item.xml +41 -0
  86. package/tests/conformance/fixtures/isNull_isNotNull/manifest.json +23 -0
  87. package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/cases.json +27 -0
  88. package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/item.xml +30 -0
  89. package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/manifest.json +15 -0
  90. package/tests/conformance/fixtures/mapResponse_integer_mapKey/cases.json +11 -0
  91. package/tests/conformance/fixtures/mapResponse_integer_mapKey/item.xml +26 -0
  92. package/tests/conformance/fixtures/mapResponse_integer_mapKey/manifest.json +13 -0
  93. package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/cases.json +27 -0
  94. package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/item.xml +32 -0
  95. package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/manifest.json +7 -0
  96. package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/cases.json +9 -0
  97. package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/item.xml +25 -0
  98. package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/manifest.json +12 -0
  99. package/tests/conformance/fixtures/mapResponse_multiple_cardinality/cases.json +12 -0
  100. package/tests/conformance/fixtures/mapResponse_multiple_cardinality/item.xml +35 -0
  101. package/tests/conformance/fixtures/mapResponse_multiple_cardinality/manifest.json +11 -0
  102. package/tests/conformance/fixtures/mapping_bounds_upperLower/cases.json +12 -0
  103. package/tests/conformance/fixtures/mapping_bounds_upperLower/item.xml +37 -0
  104. package/tests/conformance/fixtures/mapping_bounds_upperLower/manifest.json +11 -0
  105. package/tests/conformance/fixtures/mapping_mapResponse/cases.json +22 -0
  106. package/tests/conformance/fixtures/mapping_mapResponse/item.xml +53 -0
  107. package/tests/conformance/fixtures/mapping_mapResponse/manifest.json +16 -0
  108. package/tests/conformance/fixtures/member_multiple/cases.json +12 -0
  109. package/tests/conformance/fixtures/member_multiple/item.xml +37 -0
  110. package/tests/conformance/fixtures/member_multiple/manifest.json +13 -0
  111. package/tests/conformance/fixtures/modalFeedback_basic/cases.json +17 -0
  112. package/tests/conformance/fixtures/modalFeedback_basic/item.xml +52 -0
  113. package/tests/conformance/fixtures/modalFeedback_basic/manifest.json +13 -0
  114. package/tests/conformance/fixtures/multiple_unordered_match/cases.json +17 -0
  115. package/tests/conformance/fixtures/multiple_unordered_match/item.xml +44 -0
  116. package/tests/conformance/fixtures/multiple_unordered_match/manifest.json +11 -0
  117. package/tests/conformance/fixtures/ordered_match/cases.json +17 -0
  118. package/tests/conformance/fixtures/ordered_match/item.xml +48 -0
  119. package/tests/conformance/fixtures/ordered_match/manifest.json +13 -0
  120. package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/cases.json +27 -0
  121. package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/item.xml +103 -0
  122. package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/manifest.json +7 -0
  123. package/tests/conformance/fixtures/outcomeProcessing_exitTest/cases.json +15 -0
  124. package/tests/conformance/fixtures/outcomeProcessing_exitTest/item.xml +33 -0
  125. package/tests/conformance/fixtures/outcomeProcessing_exitTest/manifest.json +10 -0
  126. package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/cases.json +14 -0
  127. package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/item.xml +26 -0
  128. package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/manifest.json +8 -0
  129. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/cases.json +17 -0
  130. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/item.xml +43 -0
  131. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/manifest.json +16 -0
  132. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/cases.json +27 -0
  133. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/item.xml +37 -0
  134. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/manifest.json +16 -0
  135. package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/cases.json +14 -0
  136. package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/item.xml +35 -0
  137. package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/manifest.json +8 -0
  138. package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/cases.json +14 -0
  139. package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/item.xml +35 -0
  140. package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/manifest.json +8 -0
  141. package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/cases.json +15 -0
  142. package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/item.xml +39 -0
  143. package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/manifest.json +11 -0
  144. package/tests/conformance/fixtures/outcomeProcessing_testVariables/cases.json +14 -0
  145. package/tests/conformance/fixtures/outcomeProcessing_testVariables/item.xml +35 -0
  146. package/tests/conformance/fixtures/outcomeProcessing_testVariables/manifest.json +8 -0
  147. package/tests/conformance/fixtures/pair_unordered_match/cases.json +22 -0
  148. package/tests/conformance/fixtures/pair_unordered_match/item.xml +44 -0
  149. package/tests/conformance/fixtures/pair_unordered_match/manifest.json +13 -0
  150. package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/cases.json +95 -0
  151. package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/item.xml +53 -0
  152. package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/cases.json +115 -0
  153. package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/item.xml +45 -0
  154. package/tests/conformance/fixtures/positionObject_mapResponse_wrong/cases.json +29 -0
  155. package/tests/conformance/fixtures/positionObject_mapResponse_wrong/item.xml +40 -0
  156. package/tests/conformance/fixtures/responseCondition_elseIf_chain/cases.json +10 -0
  157. package/tests/conformance/fixtures/responseCondition_elseIf_chain/item.xml +49 -0
  158. package/tests/conformance/fixtures/responseCondition_elseIf_chain/manifest.json +15 -0
  159. package/tests/conformance/fixtures/responseProcessing_anyN/cases.json +27 -0
  160. package/tests/conformance/fixtures/responseProcessing_anyN/item.xml +47 -0
  161. package/tests/conformance/fixtures/responseProcessing_anyN/manifest.json +16 -0
  162. package/tests/conformance/fixtures/responseProcessing_anyN_allN/cases.json +27 -0
  163. package/tests/conformance/fixtures/responseProcessing_anyN_allN/item.xml +69 -0
  164. package/tests/conformance/fixtures/responseProcessing_anyN_allN/manifest.json +23 -0
  165. package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/cases.json +15 -0
  166. package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/item.xml +58 -0
  167. package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/manifest.json +15 -0
  168. package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/cases.json +37 -0
  169. package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/item.xml +94 -0
  170. package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/manifest.json +27 -0
  171. package/tests/conformance/fixtures/responseProcessing_containerSize_index/cases.json +33 -0
  172. package/tests/conformance/fixtures/responseProcessing_containerSize_index/item.xml +79 -0
  173. package/tests/conformance/fixtures/responseProcessing_containerSize_index/manifest.json +16 -0
  174. package/tests/conformance/fixtures/responseProcessing_customOperator/cases.json +15 -0
  175. package/tests/conformance/fixtures/responseProcessing_customOperator/item.xml +30 -0
  176. package/tests/conformance/fixtures/responseProcessing_customOperator/manifest.json +12 -0
  177. package/tests/conformance/fixtures/responseProcessing_default_expression/cases.json +12 -0
  178. package/tests/conformance/fixtures/responseProcessing_default_expression/item.xml +48 -0
  179. package/tests/conformance/fixtures/responseProcessing_default_expression/manifest.json +13 -0
  180. package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/cases.json +29 -0
  181. package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/item.xml +68 -0
  182. package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/manifest.json +17 -0
  183. package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/cases.json +39 -0
  184. package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/item.xml +39 -0
  185. package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/manifest.json +17 -0
  186. package/tests/conformance/fixtures/responseProcessing_exitResponse/cases.json +12 -0
  187. package/tests/conformance/fixtures/responseProcessing_exitResponse/item.xml +25 -0
  188. package/tests/conformance/fixtures/responseProcessing_exitResponse/manifest.json +12 -0
  189. package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/cases.json +26 -0
  190. package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/item.xml +134 -0
  191. package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/manifest.json +16 -0
  192. package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/cases.json +27 -0
  193. package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/item.xml +33 -0
  194. package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/manifest.json +13 -0
  195. package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/cases.json +22 -0
  196. package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/item.xml +33 -0
  197. package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/manifest.json +13 -0
  198. package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/cases.json +27 -0
  199. package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/item.xml +40 -0
  200. package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/manifest.json +18 -0
  201. package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/cases.json +22 -0
  202. package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/item.xml +33 -0
  203. package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/manifest.json +12 -0
  204. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/cases.json +29 -0
  205. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/item.xml +26 -0
  206. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/manifest.json +7 -0
  207. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/cases.json +23 -0
  208. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/item.xml +28 -0
  209. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/manifest.json +11 -0
  210. package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/cases.json +29 -0
  211. package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/item.xml +26 -0
  212. package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/manifest.json +7 -0
  213. package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/cases.json +31 -0
  214. package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/item.xml +102 -0
  215. package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/manifest.json +18 -0
  216. package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/cases.json +22 -0
  217. package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/item.xml +45 -0
  218. package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/manifest.json +21 -0
  219. package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/cases.json +26 -0
  220. package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/item.xml +157 -0
  221. package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/manifest.json +22 -0
  222. package/tests/conformance/fixtures/responseProcessing_notEqual_basic/cases.json +22 -0
  223. package/tests/conformance/fixtures/responseProcessing_notEqual_basic/item.xml +39 -0
  224. package/tests/conformance/fixtures/responseProcessing_notEqual_basic/manifest.json +18 -0
  225. package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/cases.json +22 -0
  226. package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/item.xml +51 -0
  227. package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/manifest.json +19 -0
  228. package/tests/conformance/fixtures/responseProcessing_preCondition/cases.json +31 -0
  229. package/tests/conformance/fixtures/responseProcessing_preCondition/item.xml +44 -0
  230. package/tests/conformance/fixtures/responseProcessing_preCondition/manifest.json +12 -0
  231. package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/cases.json +27 -0
  232. package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/item.xml +42 -0
  233. package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/manifest.json +14 -0
  234. package/tests/conformance/fixtures/responseProcessing_record_fieldValue/cases.json +12 -0
  235. package/tests/conformance/fixtures/responseProcessing_record_fieldValue/item.xml +40 -0
  236. package/tests/conformance/fixtures/responseProcessing_record_fieldValue/manifest.json +17 -0
  237. package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/cases.json +17 -0
  238. package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/item.xml +63 -0
  239. package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/manifest.json +9 -0
  240. package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/cases.json +12 -0
  241. package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/item.xml +40 -0
  242. package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/manifest.json +13 -0
  243. package/tests/conformance/fixtures/responseProcessing_setDefaultValue/cases.json +15 -0
  244. package/tests/conformance/fixtures/responseProcessing_setDefaultValue/item.xml +67 -0
  245. package/tests/conformance/fixtures/responseProcessing_setDefaultValue/manifest.json +9 -0
  246. package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/cases.json +27 -0
  247. package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/item.xml +69 -0
  248. package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/manifest.json +10 -0
  249. package/tests/conformance/fixtures/responseProcessing_subtract_divide/cases.json +15 -0
  250. package/tests/conformance/fixtures/responseProcessing_subtract_divide/item.xml +35 -0
  251. package/tests/conformance/fixtures/responseProcessing_subtract_divide/manifest.json +11 -0
  252. package/tests/conformance/fixtures/responseProcessing_template_map_response/cases.json +17 -0
  253. package/tests/conformance/fixtures/responseProcessing_template_map_response/item.xml +31 -0
  254. package/tests/conformance/fixtures/responseProcessing_template_map_response/manifest.json +8 -0
  255. package/tests/conformance/fixtures/responseProcessing_template_map_response_point/cases.json +22 -0
  256. package/tests/conformance/fixtures/responseProcessing_template_map_response_point/item.xml +27 -0
  257. package/tests/conformance/fixtures/responseProcessing_template_map_response_point/manifest.json +8 -0
  258. package/tests/conformance/fixtures/responseProcessing_template_match_correct/cases.json +17 -0
  259. package/tests/conformance/fixtures/responseProcessing_template_match_correct/item.xml +34 -0
  260. package/tests/conformance/fixtures/responseProcessing_template_match_correct/manifest.json +8 -0
  261. package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/cases.json +22 -0
  262. package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/item.xml +30 -0
  263. package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/manifest.json +7 -0
  264. package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/cases.json +17 -0
  265. package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/item.xml +30 -0
  266. package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/manifest.json +9 -0
  267. package/tests/conformance/fixtures/responseProcessing_template_match_nothing/cases.json +17 -0
  268. package/tests/conformance/fixtures/responseProcessing_template_match_nothing/item.xml +30 -0
  269. package/tests/conformance/fixtures/responseProcessing_template_match_nothing/manifest.json +8 -0
  270. package/tests/conformance/fixtures/responseProcessing_xiInclude/cases.json +14 -0
  271. package/tests/conformance/fixtures/responseProcessing_xiInclude/item.xml +25 -0
  272. package/tests/conformance/fixtures/responseProcessing_xiInclude/manifest.json +9 -0
  273. package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/cases.json +12 -0
  274. package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/item.xml +52 -0
  275. package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/manifest.json +14 -0
  276. package/tests/conformance/fixtures/templateProcessing_exitTemplate/cases.json +12 -0
  277. package/tests/conformance/fixtures/templateProcessing_exitTemplate/item.xml +48 -0
  278. package/tests/conformance/fixtures/templateProcessing_exitTemplate/manifest.json +13 -0
  279. package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/cases.json +27 -0
  280. package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/item.xml +74 -0
  281. package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/manifest.json +22 -0
  282. package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/cases.json +17 -0
  283. package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/item.xml +133 -0
  284. package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/manifest.json +22 -0
  285. package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/cases.json +12 -0
  286. package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/item.xml +107 -0
  287. package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/manifest.json +16 -0
  288. package/tests/conformance/fixtures/templateProcessing_templateConstraint/cases.json +15 -0
  289. package/tests/conformance/fixtures/templateProcessing_templateConstraint/item.xml +52 -0
  290. package/tests/conformance/fixtures/templateProcessing_templateConstraint/manifest.json +14 -0
  291. package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/cases.json +16 -0
  292. package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/item.xml +49 -0
  293. package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/manifest.json +15 -0
  294. package/tests/conformance/fixtures/template_randomInteger_printedVariable/cases.json +16 -0
  295. package/tests/conformance/fixtures/template_randomInteger_printedVariable/item.xml +38 -0
  296. package/tests/conformance/fixtures/template_randomInteger_printedVariable/manifest.json +13 -0
  297. package/tests/conformance/harness.ts +84 -0
  298. package/tests/conformance/run-fixtures.test.ts +127 -0
  299. package/tests/conformance/scripts/normalize-covers.ts +152 -0
  300. package/tests/conformance/types.ts +53 -0
  301. package/tests/core/Player.test.ts +563 -0
  302. package/tests/core/adaptiveItems.test.ts +442 -0
  303. package/tests/core/correctResponse.test.ts +280 -0
  304. package/tests/core/interaction-plumbing.test.ts +141 -0
  305. package/tests/core/modalFeedback.test.ts +308 -0
  306. package/tests/core/outcome-reset.test.ts +43 -0
  307. package/tests/extraction/extractors/associateExtractor.test.ts +182 -0
  308. package/tests/extraction/extractors/choiceExtractor.test.ts +239 -0
  309. package/tests/extraction/extractors/customExtractor.test.ts +83 -0
  310. package/tests/extraction/extractors/drawingExtractor.test.ts +94 -0
  311. package/tests/extraction/extractors/endAttemptExtractor.test.ts +188 -0
  312. package/tests/extraction/extractors/extendedTextExtractor.test.ts +178 -0
  313. package/tests/extraction/extractors/gapMatchExtractor.test.ts +318 -0
  314. package/tests/extraction/extractors/graphicAssociateExtractor.test.ts +260 -0
  315. package/tests/extraction/extractors/graphicGapMatchExtractor.test.ts +320 -0
  316. package/tests/extraction/extractors/graphicOrderExtractor.test.ts +223 -0
  317. package/tests/extraction/extractors/hotspotExtractor.test.ts +298 -0
  318. package/tests/extraction/extractors/hottextExtractor.test.ts +240 -0
  319. package/tests/extraction/extractors/inlineChoiceExtractor.test.ts +292 -0
  320. package/tests/extraction/extractors/matchExtractor.test.ts +241 -0
  321. package/tests/extraction/extractors/mediaExtractor.test.ts +295 -0
  322. package/tests/extraction/extractors/orderExtractor.test.ts +212 -0
  323. package/tests/extraction/extractors/positionObjectExtractor.test.ts +363 -0
  324. package/tests/extraction/extractors/selectPointExtractor.test.ts +214 -0
  325. package/tests/extraction/extractors/sliderExtractor.test.ts +293 -0
  326. package/tests/extraction/extractors/textEntryExtractor.test.ts +133 -0
  327. package/tests/extraction/extractors/uploadExtractor.test.ts +119 -0
  328. package/tests/extraction/test-utils.ts +57 -0
  329. package/tests/iframe/host.test.ts +145 -0
  330. package/tests/iframe/protocol.test.ts +42 -0
  331. package/tests/performance/player-benchmarks.bench.ts +191 -0
  332. package/tests/security/dos-limits.test.ts +56 -0
  333. package/tests/security/xss-prevention.test.ts +522 -0
  334. package/tsconfig.json +20 -0
  335. package/tsconfig.svelte.json +14 -0
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Core QTI types for the player
3
+ */
4
+
5
+ import type { QtiValue } from '@pie-qti/qti-processing';
6
+
7
+ /**
8
+ * QTI base type identifier
9
+ * Extensible string type allows custom base types
10
+ */
11
+ export type BaseType = string;
12
+
13
+ /**
14
+ * QTI cardinality identifier
15
+ * Extensible string type allows custom cardinality values
16
+ */
17
+ export type Cardinality = string;
18
+
19
+ export interface VariableDeclaration {
20
+ identifier: string;
21
+ baseType: BaseType;
22
+ cardinality: Cardinality;
23
+ value: any;
24
+ defaultValue?: any;
25
+ mapping?: Mapping;
26
+ areaMapping?: AreaMapping;
27
+ }
28
+
29
+ export interface Mapping {
30
+ defaultValue?: number;
31
+ lowerBound?: number;
32
+ upperBound?: number;
33
+ /**
34
+ * QTI attribute on <mapping>. When "false", string mappings are case-insensitive by default.
35
+ * Stored as raw string to match XML attribute values ("true"/"false").
36
+ */
37
+ caseSensitive?: string;
38
+ entries: Record<string, MapEntry>;
39
+ }
40
+
41
+ export interface MapEntry {
42
+ mapKey: string;
43
+ mappedValue: number;
44
+ caseSensitive?: string;
45
+ }
46
+
47
+ export interface AreaMapping {
48
+ defaultValue?: number;
49
+ lowerBound?: number;
50
+ upperBound?: number;
51
+ entries: Record<string, AreaMapEntry>;
52
+ }
53
+
54
+ export interface AreaMapEntry {
55
+ shape: 'circle' | 'rect' | 'poly' | 'ellipse' | 'default';
56
+ coords: string;
57
+ mappedValue: number;
58
+ }
59
+
60
+ export interface ResponseDeclaration extends VariableDeclaration {
61
+ correctResponse?: any;
62
+ }
63
+
64
+ export interface OutcomeDeclaration extends VariableDeclaration {
65
+ interpretation?: string;
66
+ longInterpretation?: string;
67
+ normalMaximum?: number;
68
+ normalMinimum?: number;
69
+ masteryValue?: number;
70
+ views?: string[];
71
+ }
72
+
73
+ export interface SessionState {
74
+ [variableId: string]: any;
75
+ }
76
+
77
+ export interface InteractionResponse {
78
+ [responseId: string]: any;
79
+ }
80
+
81
+ /**
82
+ * Serializable representation of a QTI baseType="file" response.
83
+ * (We cannot store a browser File object in session state / JSON exports.)
84
+ */
85
+ export interface QTIFileResponse {
86
+ name: string;
87
+ type: string;
88
+ size: number;
89
+ lastModified: number;
90
+ /** Base64 data URL, e.g. data:application/pdf;base64,... */
91
+ dataUrl: string;
92
+ }
93
+
94
+ export interface ModalFeedback {
95
+ /** Unique identifier for this feedback block */
96
+ identifier: string;
97
+ /** Outcome variable identifier this feedback is tied to */
98
+ outcomeIdentifier: string;
99
+ /** When to show: 'show' means display when outcome matches identifier */
100
+ showHide: 'show' | 'hide';
101
+ /** HTML content to display */
102
+ content: HtmlContent;
103
+ /** Optional title for the feedback */
104
+ title?: string;
105
+ }
106
+
107
+ export interface ScoringResult {
108
+ score: number;
109
+ maxScore: number;
110
+ completed: boolean;
111
+ outcomeValues: Record<string, any>;
112
+ /** Modal feedback elements that should be displayed based on outcome values */
113
+ modalFeedback?: ModalFeedback[];
114
+ }
115
+
116
+ /**
117
+ * QTI 2.2 completionStatus values for adaptive items
118
+ * - not_attempted: No interaction has occurred yet
119
+ * - unknown: Response exists but hasn't been scored/evaluated
120
+ * - incomplete: Item has been scored but is still active (can submit again)
121
+ * - completed: Item is finished (final state)
122
+ */
123
+ export type CompletionStatus = 'not_attempted' | 'unknown' | 'incomplete' | 'completed';
124
+
125
+ /**
126
+ * Extended scoring result for adaptive items with multi-attempt support
127
+ */
128
+ export interface AdaptiveAttemptResult extends ScoringResult {
129
+ /** Number of attempts made so far */
130
+ numAttempts: number;
131
+ /** Current completion status of the item */
132
+ completionStatus: CompletionStatus;
133
+ /** Whether the item can accept more submissions */
134
+ canContinue: boolean;
135
+ }
136
+
137
+ /**
138
+ * QTI 2.2 standard roles
139
+ * - candidate: Student/test-taker
140
+ * - scorer: Automated or human scoring system
141
+ * - proctor: Test administrator/invigilator
142
+ * - testConstructor: Test author/developer
143
+ * - tutor: Instructional/learning mode
144
+ * - author: Content author
145
+ */
146
+ export type QTIRole = 'candidate' | 'scorer' | 'proctor' | 'testConstructor' | 'tutor' | 'author';
147
+
148
+ export interface RubricBlock {
149
+ view: string[]; // Array of role strings that can see this rubric
150
+ html: HtmlContent; // HTML content of the rubric
151
+ }
152
+
153
+ /**
154
+ * QTI specification compliance configuration.
155
+ * Controls whether the player enforces strict QTI 2.2 spec or allows vendor extensions.
156
+ */
157
+ export interface QTIComplianceConfig {
158
+ /** Enable strict QTI 2.2 compliance mode. Default: false (lenient) */
159
+ enabled?: boolean;
160
+
161
+ /** Reject items with unknown or non-standard elements. Default: false */
162
+ rejectUnknownExtensions?: boolean;
163
+
164
+ /** Log warnings for spec deviations and vendor extensions. Default: true */
165
+ logDeviations?: boolean;
166
+ }
167
+
168
+ export interface PlayerConfig {
169
+ itemXml?: string;
170
+ sessionState?: SessionState;
171
+ responses?: InteractionResponse;
172
+ role?: QTIRole;
173
+ /** Optional seed for deterministic random operations (e.g. templateProcessing randomInteger) */
174
+ seed?: number;
175
+ /** Optional RNG override (takes precedence over seed if provided) */
176
+ rng?: () => number;
177
+ /**
178
+ * Optional element name mapper for handling different QTI versions.
179
+ * Defaults to Qti2xElementNameMapper for backward compatibility.
180
+ * @since 0.2.0
181
+ */
182
+ elementNameMapper?: any; // Will be ElementNameMapper from @pie-qti/qti-common
183
+ /** Optional web component registry for custom interaction components */
184
+ componentRegistry?: any; // Will be ComponentRegistry, but avoiding circular dependency
185
+ /** Optional extraction registry for custom element extractors */
186
+ extractionRegistry?: any; // Will be ExtractionRegistry, but avoiding circular dependency
187
+ /** Optional plugins to extend player functionality */
188
+ plugins?: any[]; // Will be QTIPlugin[], but avoiding circular dependency
189
+ /**
190
+ * Optional i18n provider for internationalization.
191
+ * If not provided, defaults to DefaultI18nProvider with English messages.
192
+ */
193
+ i18nProvider?: any; // Will be I18nProvider from @pie-qti/i18n
194
+ /**
195
+ * Optional registry for executing QTI <customOperator> expressions.
196
+ * Keyed by operator `class` (preferred) or `definition` URI.
197
+ */
198
+ customOperators?: Record<string, (args: QtiValue[], meta: { class?: string; definition?: string }) => QtiValue>;
199
+
200
+ /**
201
+ * Security-related controls for untrusted QTI rendered into the host DOM.
202
+ * Defaults are conservative for same-DOM embedding.
203
+ */
204
+ security?: PlayerSecurityConfig;
205
+
206
+ /**
207
+ * QTI specification compliance settings.
208
+ * Set strictQtiCompliance.enabled = true for strict QTI 2.2 validation.
209
+ */
210
+ strictQtiCompliance?: QTIComplianceConfig;
211
+ }
212
+
213
+ export interface UrlPolicyConfig {
214
+ /**
215
+ * Optional base URL used to resolve relative asset URLs (e.g. images/media).
216
+ * If omitted, relative URLs are preserved as-is.
217
+ */
218
+ assetBaseUrl?: string;
219
+ /** Allow https: URLs */
220
+ allowHttps?: boolean;
221
+ /** Allow http: URLs (default false; prefer https) */
222
+ allowHttp?: boolean;
223
+ /** Allow protocol-relative URLs (e.g. //cdn.example/asset). Default false. */
224
+ allowProtocolRelative?: boolean;
225
+ /** Allow data:image/* for <img src>. */
226
+ allowDataImages?: boolean;
227
+ /** Allow data:image/svg+xml (default false) */
228
+ allowSvgDataImages?: boolean;
229
+ /** Optional allowlist of hostnames for absolute URLs (exact match). */
230
+ allowedHosts?: string[];
231
+ }
232
+
233
+ /**
234
+ * Trusted Types support:
235
+ * - When enabled and supported by the host browser + CSP, HTML-returning APIs may return TrustedHTML instead of string.
236
+ * - When not enabled (default), APIs return plain strings as before.
237
+ */
238
+ export type TrustedTypesHtml = typeof globalThis extends { TrustedHTML: infer T } ? T : never;
239
+ export type HtmlContent = string | TrustedTypesHtml;
240
+
241
+ export interface PlayerSecurityConfig {
242
+ /** URL policy applied to extracted URL fields and HTML attribute URLs */
243
+ urlPolicy?: UrlPolicyConfig;
244
+ /** Allow <object>/<embed> usage (default false) */
245
+ allowObjectEmbeds?: boolean;
246
+ /** Allow <iframe> usage (default false) */
247
+ allowIframes?: boolean;
248
+ /**
249
+ * Optional parsing/processing guardrails to reduce DoS risk from untrusted QTI.
250
+ * Disabled by default for compatibility.
251
+ */
252
+ parsingLimits?: ParsingLimitsConfig;
253
+ /**
254
+ * Optional Trusted Types policy name (host-controlled).
255
+ * When set, and Trusted Types is available, the player will produce TrustedHTML for HTML injection sinks.
256
+ *
257
+ * Note: this is only effective when the host enables Trusted Types via CSP.
258
+ */
259
+ trustedTypesPolicyName?: string;
260
+ }
261
+
262
+ export interface ParsingLimitsConfig {
263
+ /**
264
+ * Enables parsing limits. When false/undefined, the player behaves exactly as before (compat default).
265
+ */
266
+ enabled?: boolean;
267
+ /**
268
+ * Reject any XML containing <!DOCTYPE ...> (case-insensitive) when enabled.
269
+ * Helps reduce entity-expansion and other parser edge-case risks.
270
+ */
271
+ rejectDoctype?: boolean;
272
+ /**
273
+ * Maximum bytes for `itemXml` input (UTF-8). Enforced when enabled.
274
+ */
275
+ maxItemXmlBytes?: number;
276
+ /**
277
+ * Maximum bytes for HTML strings passed to sanitizer (UTF-8). Enforced when enabled.
278
+ */
279
+ maxHtmlBytes?: number;
280
+ /**
281
+ * Maximum number of element nodes sanitized per HTML input. Enforced when enabled.
282
+ */
283
+ maxHtmlNodes?: number;
284
+ /**
285
+ * Maximum element depth sanitized per HTML input. Enforced when enabled.
286
+ */
287
+ maxHtmlDepth?: number;
288
+ }
289
+
290
+ export interface InteractionContext {
291
+ responseIdentifier: string;
292
+ maxChoices?: number;
293
+ minChoices?: number;
294
+ shuffle?: boolean;
295
+ orientation?: 'horizontal' | 'vertical';
296
+ }
297
+
298
+ // Interaction data shapes for the component/plugin system.
299
+ // Exported here so consumers can import them from `@pie-qti/item-player`.
300
+ export * from './interactions.js';
301
+ export * from './responseValidation.js';
@@ -0,0 +1,354 @@
1
+ /**
2
+ * Interaction type mappings for strongly-typed registry
3
+ *
4
+ * This file defines the complete type system for the plugin-based
5
+ * interaction renderer registry, ensuring compile-time type safety.
6
+ */
7
+
8
+ import type { HTMLElement } from 'node-html-parser';
9
+ import type { HtmlContent } from './index.js';
10
+
11
+ /**
12
+ * Type alias for parsed QTI XML elements
13
+ * Uses node-html-parser's HTMLElement type directly
14
+ */
15
+ export type QTIElement = HTMLElement;
16
+
17
+ export interface BaseInteractionData {
18
+ type: string;
19
+ responseId: string;
20
+ }
21
+
22
+ export interface ChoiceInteractionData extends BaseInteractionData {
23
+ type: 'choiceInteraction';
24
+ shuffle: boolean;
25
+ maxChoices: number;
26
+ prompt: string | null;
27
+ choices: Array<{ identifier: string; text: HtmlContent; classes?: string[] }>;
28
+ /** CSS classes from the choiceInteraction element for custom renderer detection */
29
+ interactionClasses?: string[];
30
+ }
31
+
32
+ export interface TextEntryInteractionData extends BaseInteractionData {
33
+ type: 'textEntryInteraction';
34
+ expectedLength: number;
35
+ patternMask: string | null;
36
+ placeholderText: string;
37
+ }
38
+
39
+ export interface ExtendedTextInteractionData extends BaseInteractionData {
40
+ type: 'extendedTextInteraction';
41
+ expectedLines: number;
42
+ expectedLength: number;
43
+ placeholderText: string;
44
+ format: string;
45
+ }
46
+
47
+ export interface InlineChoiceInteractionData extends BaseInteractionData {
48
+ type: 'inlineChoiceInteraction';
49
+ shuffle: boolean;
50
+ choices: Array<{ identifier: string; text: string }>;
51
+ }
52
+
53
+ export interface OrderInteractionData extends BaseInteractionData {
54
+ type: 'orderInteraction';
55
+ shuffle: boolean;
56
+ prompt: string | null;
57
+ choices: Array<{ identifier: string; text: string }>;
58
+ }
59
+
60
+ export interface AssociableChoice {
61
+ identifier: string;
62
+ text: string;
63
+ matchMax: number;
64
+ }
65
+
66
+ export interface MatchInteractionData extends BaseInteractionData {
67
+ type: 'matchInteraction';
68
+ shuffle: boolean;
69
+ maxAssociations: number;
70
+ prompt: string | null;
71
+ sourceSet: AssociableChoice[];
72
+ targetSet: AssociableChoice[];
73
+ }
74
+
75
+ export interface AssociateInteractionData extends BaseInteractionData {
76
+ type: 'associateInteraction';
77
+ shuffle: boolean;
78
+ maxAssociations: number;
79
+ prompt: string | null;
80
+ choices: AssociableChoice[];
81
+ }
82
+
83
+ export interface GapMatchInteractionData extends BaseInteractionData {
84
+ type: 'gapMatchInteraction';
85
+ shuffle: boolean;
86
+ prompt: string | null;
87
+ gapTexts: Array<{ identifier: string; text: string; matchMax: number }>;
88
+ gaps: Array<{ identifier: string; index: number }>;
89
+ promptText: string;
90
+ }
91
+
92
+ export interface SliderInteractionData extends BaseInteractionData {
93
+ type: 'sliderInteraction';
94
+ lowerBound: number;
95
+ upperBound: number;
96
+ step: number;
97
+ orientation: string;
98
+ reverse: boolean;
99
+ prompt: string | null;
100
+ }
101
+
102
+ export interface ImageData {
103
+ type: 'svg' | 'image';
104
+ content?: HtmlContent;
105
+ src?: string;
106
+ width: string;
107
+ height: string;
108
+ }
109
+
110
+ export interface HotspotChoice {
111
+ identifier: string;
112
+ shape: string;
113
+ coords: string;
114
+ }
115
+
116
+ export interface HotspotInteractionData extends BaseInteractionData {
117
+ type: 'hotspotInteraction';
118
+ maxChoices: number;
119
+ prompt: string | null;
120
+ imageData: ImageData | null;
121
+ hotspotChoices: HotspotChoice[];
122
+ }
123
+
124
+ export interface AssociableHotspot {
125
+ identifier: string;
126
+ shape: string;
127
+ coords: string;
128
+ matchMax: number;
129
+ }
130
+
131
+ export interface GraphicGapMatchInteractionData extends BaseInteractionData {
132
+ type: 'graphicGapMatchInteraction';
133
+ prompt: string | null;
134
+ imageData: ImageData | null;
135
+ gapTexts: Array<{ identifier: string; text: string; matchMax: number }>;
136
+ hotspots: AssociableHotspot[];
137
+ }
138
+
139
+ export interface UploadInteractionData extends BaseInteractionData {
140
+ type: 'uploadInteraction';
141
+ prompt: string | null;
142
+ /** Allowed MIME types / extensions (vendor-dependent); empty = accept any */
143
+ fileTypes: string[];
144
+ rawAttributes: Record<string, string>;
145
+ }
146
+
147
+ export interface DrawingInteractionData extends BaseInteractionData {
148
+ type: 'drawingInteraction';
149
+ prompt: string | null;
150
+ /** Optional background image/SVG to draw on top of */
151
+ imageData: ImageData | null;
152
+ rawAttributes: Record<string, string>;
153
+ }
154
+
155
+ export interface CustomInteractionData extends BaseInteractionData {
156
+ type: 'customInteraction';
157
+ prompt: string | null;
158
+ rawAttributes: Record<string, string>;
159
+ /** Outer XML snippet for debugging (best-effort) */
160
+ xml: string;
161
+ }
162
+
163
+ export interface MediaElement {
164
+ type: 'audio' | 'video' | 'object';
165
+ src: string;
166
+ mimeType: string;
167
+ width?: number;
168
+ height?: number;
169
+ }
170
+
171
+ export interface MediaInteractionData extends BaseInteractionData {
172
+ type: 'mediaInteraction';
173
+ prompt: string | null;
174
+ autostart: boolean;
175
+ minPlays: number;
176
+ maxPlays: number; // 0 = unlimited
177
+ loop: boolean;
178
+ mediaElement: MediaElement;
179
+ /** Whether the renderer should allow <object> embeds for this interaction (default false) */
180
+ allowObjectEmbeds?: boolean;
181
+ }
182
+
183
+ export interface HottextChoice {
184
+ identifier: string;
185
+ text: string;
186
+ }
187
+
188
+ export interface HottextInteractionData extends BaseInteractionData {
189
+ type: 'hottextInteraction';
190
+ prompt: string | null;
191
+ maxChoices: number;
192
+ contentHtml: HtmlContent;
193
+ hottextChoices: HottextChoice[];
194
+ }
195
+
196
+ export interface Point {
197
+ x: number;
198
+ y: number;
199
+ }
200
+
201
+ export interface SelectPointInteractionData extends BaseInteractionData {
202
+ type: 'selectPointInteraction';
203
+ prompt: string | null;
204
+ maxChoices: number;
205
+ minChoices: number;
206
+ imageData: ImageData | null;
207
+ }
208
+
209
+ export interface GraphicOrderChoice {
210
+ identifier: string;
211
+ shape: string;
212
+ coords: string;
213
+ label: string;
214
+ }
215
+
216
+ export interface GraphicOrderInteractionData extends BaseInteractionData {
217
+ type: 'graphicOrderInteraction';
218
+ prompt: string | null;
219
+ imageData: ImageData | null;
220
+ hotspotChoices: GraphicOrderChoice[];
221
+ }
222
+
223
+ export interface GraphicAssociateHotspot {
224
+ identifier: string;
225
+ shape: string;
226
+ coords: string;
227
+ matchMax: number;
228
+ label: string;
229
+ }
230
+
231
+ export interface GraphicAssociateInteractionData extends BaseInteractionData {
232
+ type: 'graphicAssociateInteraction';
233
+ prompt: string | null;
234
+ maxAssociations: number;
235
+ minAssociations: number;
236
+ imageData: ImageData | null;
237
+ associableHotspots: GraphicAssociateHotspot[];
238
+ }
239
+
240
+ export interface PositionObjectStage {
241
+ identifier: string;
242
+ matchMax: number;
243
+ objectData: {
244
+ type: 'image' | 'svg';
245
+ src?: string;
246
+ content?: HtmlContent;
247
+ width?: string;
248
+ height?: string;
249
+ } | null;
250
+ label: string;
251
+ }
252
+
253
+ export interface PositionObjectInteractionData extends BaseInteractionData {
254
+ type: 'positionObjectInteraction';
255
+ prompt: string | null;
256
+ maxChoices: number;
257
+ minChoices: number;
258
+ centerPoint: boolean;
259
+ imageData: ImageData | null;
260
+ positionObjectStages: PositionObjectStage[];
261
+ }
262
+
263
+ export interface EndAttemptInteractionData extends BaseInteractionData {
264
+ type: 'endAttemptInteraction';
265
+ prompt: string | null;
266
+ title: string;
267
+ /** Whether this interaction counts as an attempt (default: true) */
268
+ countAttempt: boolean;
269
+ }
270
+
271
+ export type InteractionData =
272
+ | ChoiceInteractionData
273
+ | TextEntryInteractionData
274
+ | ExtendedTextInteractionData
275
+ | InlineChoiceInteractionData
276
+ | OrderInteractionData
277
+ | MatchInteractionData
278
+ | AssociateInteractionData
279
+ | GapMatchInteractionData
280
+ | SliderInteractionData
281
+ | HotspotInteractionData
282
+ | GraphicGapMatchInteractionData
283
+ | UploadInteractionData
284
+ | DrawingInteractionData
285
+ | CustomInteractionData
286
+ | MediaInteractionData
287
+ | HottextInteractionData
288
+ | SelectPointInteractionData
289
+ | GraphicOrderInteractionData
290
+ | GraphicAssociateInteractionData
291
+ | PositionObjectInteractionData
292
+ | EndAttemptInteractionData;
293
+
294
+ /**
295
+ * QTI interaction type identifier
296
+ * Extensible string type allows custom interaction types
297
+ */
298
+ export type InteractionType = string;
299
+
300
+ /**
301
+ * Map interaction types to their data structures
302
+ * TypeScript will ensure registrations use the correct data type
303
+ */
304
+ export interface InteractionDataMap {
305
+ choiceInteraction: ChoiceInteractionData;
306
+ textEntryInteraction: TextEntryInteractionData;
307
+ extendedTextInteraction: ExtendedTextInteractionData;
308
+ inlineChoiceInteraction: InlineChoiceInteractionData;
309
+ orderInteraction: OrderInteractionData;
310
+ matchInteraction: MatchInteractionData;
311
+ associateInteraction: AssociateInteractionData;
312
+ gapMatchInteraction: GapMatchInteractionData;
313
+ sliderInteraction: SliderInteractionData;
314
+ hotspotInteraction: HotspotInteractionData;
315
+ graphicGapMatchInteraction: GraphicGapMatchInteractionData;
316
+ uploadInteraction: UploadInteractionData;
317
+ drawingInteraction: DrawingInteractionData;
318
+ customInteraction: CustomInteractionData;
319
+ mediaInteraction: MediaInteractionData;
320
+ hottextInteraction: HottextInteractionData;
321
+ selectPointInteraction: SelectPointInteractionData;
322
+ graphicOrderInteraction: GraphicOrderInteractionData;
323
+ graphicAssociateInteraction: GraphicAssociateInteractionData;
324
+ positionObjectInteraction: PositionObjectInteractionData;
325
+ endAttemptInteraction: EndAttemptInteractionData;
326
+ }
327
+
328
+ /**
329
+ * Map interaction types to their response value types
330
+ * Ensures getValue/setValue use the correct types
331
+ */
332
+ export interface InteractionValueMap {
333
+ choiceInteraction: string | string[];
334
+ textEntryInteraction: string;
335
+ extendedTextInteraction: string;
336
+ inlineChoiceInteraction: string;
337
+ orderInteraction: string[];
338
+ matchInteraction: Record<string, string>;
339
+ associateInteraction: Array<[string, string]>;
340
+ gapMatchInteraction: Record<string, string>;
341
+ sliderInteraction: number;
342
+ hotspotInteraction: string[];
343
+ graphicGapMatchInteraction: Record<string, string>;
344
+ uploadInteraction: import('../types/index.js').QTIFileResponse[];
345
+ drawingInteraction: string;
346
+ customInteraction: any;
347
+ mediaInteraction: any;
348
+ hottextInteraction: string[];
349
+ selectPointInteraction: Array<{ x: number; y: number }>;
350
+ graphicOrderInteraction: string[];
351
+ graphicAssociateInteraction: Array<[string, string]>;
352
+ positionObjectInteraction: Record<string, { x: number; y: number }>;
353
+ endAttemptInteraction: boolean;
354
+ }
@@ -0,0 +1,29 @@
1
+ export type ResponseValidationSeverity = 'error' | 'warning';
2
+
3
+ export interface ResponseValidationIssue {
4
+ responseId: string;
5
+ code: string;
6
+ message: string;
7
+ severity: ResponseValidationSeverity;
8
+ }
9
+
10
+ export interface ResponseValidationEntry {
11
+ responseId: string;
12
+ interactionType: string;
13
+ /** Whether this interaction is required for submission purposes (derived from constraints like minPlays/minChoices). */
14
+ required: boolean;
15
+ /** Whether the interaction is complete for submission purposes. */
16
+ complete: boolean;
17
+ /** Whether the response value is valid (shape + constraints). */
18
+ valid: boolean;
19
+ errors: string[];
20
+ warnings: string[];
21
+ }
22
+
23
+ export interface ResponseValidationResult {
24
+ valid: boolean;
25
+ entries: Record<string, ResponseValidationEntry>;
26
+ issues: ResponseValidationIssue[];
27
+ }
28
+
29
+