@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 @@
1
+ $ tsc
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @pie-qti/item-player
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2243643: Publish the initial public release of all publishable PIE-QTI packages.
8
+ - Updated dependencies [2243643]
9
+ - @pie-qti/qti-processing@0.1.1
package/README.md ADDED
@@ -0,0 +1,466 @@
1
+ # @pie-qti/item-player
2
+
3
+ A modern, QTI 2.x compliant assessment item player with role-based rendering and optional backend scoring support.
4
+
5
+ ## Features
6
+
7
+ - ✅ **21 QTI Interaction Types Supported** - All QTI 2.2 interactions
8
+ - ✅ **QTI 2.x Standard Roles** - Candidate, scorer, author, tutor, proctor, testConstructor
9
+ - ✅ **Adaptive Items** - Multi-attempt workflow with progressive feedback
10
+ - ✅ **Full Keyboard Accessibility** (follows WCAG 2.2 Level AA guidelines)
11
+ - ✅ **Client-Side Response Processing** with 45/45 QTI operators
12
+ - ✅ **Framework-Agnostic Core** with a **Web Component interaction layer** (default implementations authored in Svelte)
13
+ - ✅ **TypeScript** with full type definitions
14
+ - ✅ **Minimal Dependencies** (node-html-parser for XML parsing)
15
+ - ✅ **Iframe mode (reference)** - Optional host helper + postMessage protocol for iframe-isolated deployments
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ bun add @pie-qti/item-player
21
+ ```
22
+
23
+ Alternatively:
24
+
25
+ ```bash
26
+ npm install @pie-qti/item-player
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ### Core Player (Framework-Agnostic)
32
+
33
+ ```typescript
34
+ import { Player } from '@pie-qti/item-player';
35
+
36
+ // Load QTI XML with role
37
+ const qtiXml = `<assessmentItem ...>...</assessmentItem>`;
38
+ const player = new Player({
39
+ itemXml: qtiXml,
40
+ role: 'candidate' // QTI 2.x standard role
41
+ });
42
+
43
+ // Get interactions
44
+ const interactions = player.getInteractions();
45
+ // [{ type: 'choiceInteraction', responseIdentifier: 'RESPONSE', element: ... }]
46
+
47
+ // Set response
48
+ player.setResponse('RESPONSE', 'A');
49
+
50
+ // Score the item
51
+ const result = player.score();
52
+ console.log(result.score); // 0.0 to 1.0
53
+ console.log(result.outcomes); // { SCORE: 1.0, ... }
54
+ ```
55
+
56
+ ### Iframe mode (optional, reference)
57
+
58
+ For deployments that need stronger isolation for **untrusted** QTI, you can run the player inside an iframe and communicate via a versioned `postMessage` protocol.
59
+
60
+ - Docs: `docs/iframe-mode.md`
61
+ - Import: `@pie-qti/item-player/iframe` (browser-only)
62
+
63
+ ## QTI 2.x Standard Roles
64
+
65
+ The player implements QTI 2.x standard roles to control rendering behavior:
66
+
67
+ | Role | Behavior |
68
+ |------|----------|
69
+ | `candidate` | Test-taker - inputs editable, no correct answers shown |
70
+ | `scorer` | Grader - inputs readonly, correct answers shown |
71
+ | `author` | Content author - inputs readonly, correct answers shown |
72
+ | `tutor` | Instructional mode - inputs readonly, correct answers shown |
73
+ | `proctor` | Test administrator - inputs readonly, limited feedback |
74
+ | `testConstructor` | Test developer - inputs readonly, correct answers shown |
75
+
76
+ ### Role-Based Rendering
77
+
78
+ ```typescript
79
+ // For test-takers (editable inputs)
80
+ const player = new Player({
81
+ itemXml: qtiXml,
82
+ role: 'candidate'
83
+ });
84
+
85
+ // For grading/review (readonly, show answers)
86
+ const player = new Player({
87
+ itemXml: qtiXml,
88
+ role: 'scorer'
89
+ });
90
+
91
+ // For instructional use (readonly, show answers)
92
+ const player = new Player({
93
+ itemXml: qtiXml,
94
+ role: 'tutor'
95
+ });
96
+ ```
97
+
98
+ ## Supported Interaction Types
99
+
100
+ | QTI Type | Component | Description |
101
+ |----------|-----------|-------------|
102
+ | `choiceInteraction` | Built-in | Single/multiple choice |
103
+ | `textEntryInteraction` | Built-in | Short text input |
104
+ | `extendedTextInteraction` | Built-in | Long-form text (essay) |
105
+ | `inlineChoiceInteraction` | `InlineInteractionRenderer` | Dropdown in text |
106
+ | `orderInteraction` | `SortableList` | Drag to reorder items |
107
+ | `matchInteraction` | `MatchDragDrop` | Match items between sets |
108
+ | `associateInteraction` | - | Create associations |
109
+ | `gapMatchInteraction` | - | Drag items into text gaps |
110
+ | `graphicGapMatchInteraction` | `GraphicGapMatch` | Drag labels onto image hotspots |
111
+ | `sliderInteraction` | Built-in | Slider input |
112
+ | `hotspotInteraction` | - | Click regions on image |
113
+ | `uploadInteraction` | `FileUpload` | Upload a file response |
114
+ | `drawingInteraction` | `DrawingCanvas` | Draw/annotate on a canvas |
115
+ | `customInteraction` | `CustomInteractionFallback` | Fallback display + optional manual response |
116
+
117
+ ## QTI Version Support
118
+
119
+ This player is designed for **QTI 2.2** but provides best-effort support for QTI 2.0 and 2.1:
120
+
121
+ - **QTI 2.2**: Full support (recommended)
122
+ - **QTI 2.1**: Supported with CC2 template aliases (`cc2_match`, `cc2_map_response`, etc.)
123
+ - **QTI 2.0**: Limited support - core interactions work, but some features may be unsupported
124
+
125
+ ### Version Detection
126
+
127
+ The player automatically detects QTI version from:
128
+
129
+ 1. Namespace URI (`xmlns="http://www.imsglobal.org/xsd/imsqti_v2pX"`)
130
+ 2. Version attribute (`<assessmentItem version="2.X">`)
131
+
132
+ Warnings are logged for older versions or when version cannot be detected.
133
+
134
+ ### Template Processing
135
+
136
+ Response processing templates are namespace-agnostic. The player supports:
137
+
138
+ - Standard QTI 2.2 templates: `match_correct`, `map_response`, etc.
139
+ - QTI 2.1 CC2 aliases: `cc2_match`, `cc2_map_response`, etc.
140
+
141
+ ### Strict Compliance Mode
142
+
143
+ For strict QTI 2.2 validation, enable strict compliance:
144
+
145
+ ```typescript
146
+ const player = new Player({
147
+ itemXml: qtiXml,
148
+ strictQtiCompliance: {
149
+ enabled: true, // Enable strict QTI 2.2 validation
150
+ rejectUnknownExtensions: true, // Throw errors on non-2.2 versions
151
+ logDeviations: true // Log warnings for spec deviations
152
+ }
153
+ });
154
+ ```
155
+
156
+ See [QTI Compliance Documentation](./docs/QTI-COMPLIANCE.md) for details.
157
+
158
+ ## Architecture
159
+
160
+ ### Three-Layer Design
161
+
162
+ ```
163
+ ┌─────────────────────────────────────────┐
164
+ │ Interaction UI (Web Components) │
165
+ │ - default implementations authored in │
166
+ │ Svelte (`@pie-qti/default-components`) │
167
+ └─────────────────────────────────────────┘
168
+ ↓
169
+ ┌─────────────────────────────────────────┐
170
+ │ Extraction │
171
+ │ - Player.getInteractionData() │
172
+ │ - ExtractionRegistry + extractors │
173
+ └─────────────────────────────────────────┘
174
+ ↓
175
+ ┌─────────────────────────────────────────┐
176
+ │ Core Player (Framework-Agnostic) │
177
+ │ - XML parsing │
178
+ │ - Response processing │
179
+ │ - Scoring engine │
180
+ │ - Role-based behavior │
181
+ └─────────────────────────────────────────┘
182
+ ```
183
+
184
+ ## API Reference
185
+
186
+ ### Player Class
187
+
188
+ ```typescript
189
+ interface PlayerConfig {
190
+ itemXml: string;
191
+ role?: QTIRole; // 'candidate' | 'scorer' | 'author' | 'tutor' | 'proctor' | 'testConstructor'
192
+ componentRegistry?: ComponentRegistry; // Custom web component registry
193
+ extractionRegistry?: ExtractionRegistry; // Custom extractors
194
+ plugins?: QTIPlugin[]; // Plugin-based extension point
195
+ }
196
+
197
+ class Player {
198
+ constructor(config: PlayerConfig)
199
+
200
+ // Get all interactions in the item
201
+ getInteractions(): Array<{
202
+ type: string;
203
+ responseIdentifier: string;
204
+ element: HTMLElement;
205
+ }>
206
+
207
+ // Get extracted interaction data (recommended API for UIs)
208
+ getInteractionData(): InteractionData[]
209
+
210
+ // Set a response value
211
+ setResponse(identifier: string, value: any): void
212
+
213
+ // Get a response value
214
+ getResponse(identifier: string): any
215
+
216
+ // Execute response processing and calculate score
217
+ score(): {
218
+ score: number; // 0.0 to 1.0
219
+ outcomes: Record<string, any>;
220
+ completed: boolean;
221
+ }
222
+
223
+ // Get item body HTML
224
+ getItemBodyHtml(): string
225
+
226
+ // Get rubric blocks for current role
227
+ getRubricBlocks(): RubricBlock[]
228
+ }
229
+ ```
230
+
231
+ ### Component Props
232
+
233
+ #### SortableList
234
+
235
+ ```typescript
236
+ interface Props {
237
+ items: Array<{ id: string; text: string }>;
238
+ orderedIds: string[];
239
+ orientation?: 'vertical' | 'horizontal';
240
+ disabled?: boolean;
241
+ onReorder: (newOrder: string[]) => void;
242
+ }
243
+ ```
244
+
245
+ #### MatchDragDrop
246
+
247
+ ```typescript
248
+ interface Props {
249
+ sourceSet: Array<{ identifier: string; text: string }>;
250
+ targetSet: Array<{ identifier: string; text: string }>;
251
+ pairs: string[]; // "sourceId targetId"
252
+ disabled?: boolean;
253
+ onPairsChange: (newPairs: string[]) => void;
254
+ }
255
+ ```
256
+
257
+ #### GraphicGapMatch
258
+
259
+ ```typescript
260
+ interface Props {
261
+ gapTexts: Array<{ identifier: string; text: string; matchMax: number }>;
262
+ hotspots: Array<{ identifier: string; shape: string; coords: string; matchMax: number }>;
263
+ pairs: string[]; // "gapTextId hotspotId"
264
+ imageData: { type: 'svg' | 'image'; content?: string; src?: string; width: string; height: string };
265
+ disabled?: boolean;
266
+ onPairsChange: (newPairs: string[]) => void;
267
+ }
268
+ ```
269
+
270
+ ## Extensibility
271
+
272
+ Use plugins/registries (`QTIPlugin`, `ExtractionRegistry`, `ComponentRegistry`) to support vendor extensions or custom rendering.
273
+
274
+ **Important**: interaction implementations are treated as **web components** by the player. The player creates elements by tag name and communicates via **standard properties** + the bubbling `qti-change` event. Svelte is an implementation detail of the default component package, not a requirement.
275
+
276
+ For details, see [PLUGGABILITY.md](PLUGGABILITY.md).
277
+
278
+ ## Adaptive Items
279
+
280
+ The player fully supports QTI 2.2 adaptive items with multi-attempt workflows:
281
+
282
+ ### Basic Adaptive Item
283
+
284
+ ```typescript
285
+ import { Player } from '@pie-qti/item-player';
286
+
287
+ const player = new Player({
288
+ itemXml: qtiXml, // With adaptive="true"
289
+ role: 'candidate'
290
+ });
291
+
292
+ // Check if item is adaptive
293
+ if (player.isAdaptive()) {
294
+ // Submit first attempt
295
+ player.setResponses({ RESPONSE: 'A' });
296
+ const result = player.submitAttempt();
297
+
298
+ console.log(result.numAttempts); // 1
299
+ console.log(result.completionStatus); // 'unknown' or 'completed'
300
+ console.log(result.canContinue); // true (if not completed)
301
+ console.log(result.modalFeedback); // Progressive feedback/hints
302
+
303
+ // Continue submitting until completed
304
+ while (!player.isCompleted()) {
305
+ player.setResponses({ RESPONSE: nextGuess });
306
+ const nextResult = player.submitAttempt();
307
+ // Show feedback, allow retry
308
+ }
309
+ }
310
+ ```
311
+
312
+ ### Hint Buttons (countAttempt="false")
313
+
314
+ Adaptive items can have hint buttons that don't increment the attempt counter:
315
+
316
+ ```xml
317
+ <endAttemptInteraction responseIdentifier="HINT"
318
+ title="Request Hint"
319
+ countAttempt="false"/>
320
+ ```
321
+
322
+ ```typescript
323
+ // Click hint button (doesn't increment attempts)
324
+ player.setResponses({ HINT: true });
325
+ const hint = player.submitAttempt(false); // Pass false for countAttempt
326
+ console.log(hint.numAttempts); // Unchanged
327
+ console.log(hint.modalFeedback); // Hint content
328
+ ```
329
+
330
+ ### Progressive Feedback Example
331
+
332
+ ```xml
333
+ <assessmentItem identifier="adaptive-item" adaptive="true">
334
+ <!-- ... interactions ... -->
335
+
336
+ <responseProcessing>
337
+ <responseCondition>
338
+ <responseIf>
339
+ <!-- First attempt: encourage -->
340
+ <lt>
341
+ <variable identifier="numAttempts"/>
342
+ <baseValue baseType="integer">2</baseValue>
343
+ </lt>
344
+ <setOutcomeValue identifier="FEEDBACK">
345
+ <baseValue baseType="identifier">tryagain</baseValue>
346
+ </setOutcomeValue>
347
+ </responseIf>
348
+ <responseElse>
349
+ <!-- Second+ attempt: show answer -->
350
+ <setOutcomeValue identifier="FEEDBACK">
351
+ <baseValue baseType="identifier">answer</baseValue>
352
+ </setOutcomeValue>
353
+ <setOutcomeValue identifier="completionStatus">
354
+ <baseValue baseType="identifier">completed</baseValue>
355
+ </setOutcomeValue>
356
+ </responseElse>
357
+ </responseCondition>
358
+ </responseProcessing>
359
+
360
+ <modalFeedback outcomeIdentifier="FEEDBACK" identifier="tryagain" showHide="show">
361
+ <p>Try again! You have one more attempt.</p>
362
+ </modalFeedback>
363
+
364
+ <modalFeedback outcomeIdentifier="FEEDBACK" identifier="answer" showHide="show">
365
+ <p>The correct answer is C. Here's why...</p>
366
+ </modalFeedback>
367
+ </assessmentItem>
368
+ ```
369
+
370
+ ### API Methods
371
+
372
+ | Method | Description |
373
+ | ---------------------------------------------------------------- | ----------------------------------------- |
374
+ | `isAdaptive(): boolean` | Check if item has `adaptive="true"` |
375
+ | `isCompleted(): boolean` | Check if `completionStatus="completed"` |
376
+ | `getNumAttempts(): number` | Get current attempt count |
377
+ | `submitAttempt(countAttempt?: boolean): AdaptiveAttemptResult` | Submit attempt with optional counting |
378
+
379
+ For complete documentation, see [ADAPTIVE-ITEMS-DESIGN.md](ADAPTIVE-ITEMS-DESIGN.md).
380
+
381
+ ## Accessibility
382
+
383
+ All components follow WCAG 2.2 Level AA guidelines:
384
+
385
+ - ✅ **Full keyboard navigation** (Tab, Space, Enter, Arrow keys, Escape)
386
+ - ✅ **Screen reader support** with ARIA labels and live regions
387
+ - ✅ **Focus management** with visible indicators
388
+ - ✅ **Alternative to drag-and-drop** for all interactions
389
+
390
+ ### Keyboard Shortcuts
391
+
392
+ | Component | Keys | Action |
393
+ |-----------|------|--------|
394
+ | SortableList | Space/Enter | Grab/drop item |
395
+ | | Arrow keys | Move grabbed item |
396
+ | | Escape | Cancel |
397
+ | MatchDragDrop | Space/Enter | Select source |
398
+ | | Tab → Space/Enter | Match to target |
399
+ | GraphicGapMatch | Space/Enter | Select label |
400
+ | | Tab → Space/Enter | Place on hotspot |
401
+
402
+ For detailed accessibility analysis, see [WCAG-2.2-COMPLIANCE.md](docs/WCAG-2.2-COMPLIANCE.md).
403
+
404
+ ## Backend Scoring (Optional)
405
+
406
+ The player supports optional backend scoring for items that require server-side processing:
407
+
408
+ ```typescript
409
+ // Check if backend scoring is available
410
+ if (player.getItemAttribute('adaptive') === 'true') {
411
+ // Send to backend for scoring
412
+ const response = await fetch('/api/score', {
413
+ method: 'POST',
414
+ body: JSON.stringify({
415
+ itemId: 'item-123',
416
+ responses: player.getAllResponses()
417
+ })
418
+ });
419
+
420
+ const result = await response.json();
421
+ // Apply backend scores
422
+ player.applyOutcomes(result.outcomes);
423
+ }
424
+ ```
425
+
426
+ For details, see [SERVER-API.md](SERVER-API.md).
427
+
428
+ ## Development
429
+
430
+ ```bash
431
+ # Install dependencies
432
+ bun install
433
+
434
+ # Build
435
+ bun run build
436
+
437
+ # Run tests
438
+ bun test
439
+
440
+ # Type check
441
+ bun run typecheck
442
+
443
+ # Lint
444
+ bun run lint
445
+ ```
446
+
447
+ ## License
448
+
449
+ ISC
450
+
451
+ ## Related Packages
452
+
453
+ - [@pie-qti/assessment-player](../assessment-player) - Multi-item test player
454
+ - [@pie-qti/player-elements](../player-elements) - Web components
455
+ - [@pie-qti/example](../example) - Demo application
456
+ - [@pie-qti/to-pie](../to-pie) - QTI to PIE transformer
457
+
458
+ ## Contributing
459
+
460
+ Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
461
+
462
+ ## Resources
463
+
464
+ - [QTI 2.x Specification](http://www.imsglobal.org/question/qtiv2p2/imsqti_v2p2.html)
465
+ - [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
466
+ - [PIE Framework](https://github.com/pie-framework)
@@ -0,0 +1,197 @@
1
+ # QTI 2.2 Specification Compliance
2
+
3
+ ## Compliance Level
4
+
5
+ This player implements **QTI 2.2** as the baseline specification with backward compatibility for QTI 2.0/2.1.
6
+
7
+ ## Supported QTI Features
8
+
9
+ ### Interactions (21 Standard Types)
10
+ All 21 standard QTI 2.2 interactions are supported:
11
+
12
+ - **Choice Interactions**: `choiceInteraction`, `inlineChoiceInteraction`, `orderInteraction`, `associateInteraction`
13
+ - **Text Interactions**: `textEntryInteraction`, `extendedTextInteraction`
14
+ - **Graphic Interactions**: `hotspotInteraction`, `hottext Interaction`, `graphicOrderInteraction`, `graphicAssociateInteraction`, `graphicGapMatchInteraction`, `selectPointInteraction`, `positionObjectInteraction`
15
+ - **Match Interactions**: `matchInteraction`, `gapMatchInteraction`
16
+ - **Media Interactions**: `mediaInteraction`, `uploadInteraction`
17
+ - **Drawing**: `drawingInteraction`
18
+ - **Slider**: `sliderInteraction`
19
+ - **Custom**: `customInteraction`
20
+ - **End Attempt**: `endAttemptInteraction`
21
+
22
+ See the [Interactions Guide](./interactions.md) for detailed documentation.
23
+
24
+ ### Response Processing Templates
25
+
26
+ The player supports both QTI 2.2 standard templates and QTI 2.1 Common Cartridge (CC2) aliases:
27
+
28
+ | QTI 2.2 Template | QTI 2.1 CC2 Alias | Description |
29
+ |------------------|-------------------|-------------|
30
+ | `match_correct` | `cc2_match` | Scores 1 if all responses match correct values, 0 otherwise |
31
+ | `match_nothing` | `cc2_match_nothing` | Scores 1 if all responses are empty, 0 otherwise |
32
+ | `map_response` | `cc2_map_response` | Maps response values using mapping definitions |
33
+ | `map_response_point` | `cc2_map_response_point` | Maps point responses using area mapping |
34
+
35
+ **Template Resolution:** The player extracts only the template filename from the full URL, making resolution namespace-agnostic. Templates from v2p0, v2p1, and v2p2 namespaces all work identically.
36
+
37
+ ### QTI Roles
38
+
39
+ All 6 standard QTI roles are supported:
40
+ - ✅ `candidate` - Student taking the assessment
41
+ - ✅ `scorer` - Person scoring responses
42
+ - ✅ `tutor` - Tutor/instructor viewing with feedback
43
+ - ✅ `author` - Content author with full visibility
44
+ - ✅ `testConstructor` - Assessment designer
45
+ - ✅ `proctor` - Test administrator
46
+
47
+ ## Known Vendor Extensions
48
+
49
+ ### positionObjectInteraction - Multiple Stages
50
+ **Status**: Non-standard extension (always enabled)
51
+
52
+ **QTI 2.2 Spec Limitation:**
53
+ The standard `positionObjectInteraction` only supports:
54
+ - Single `positionObjectStage` element
55
+ - Single draggable object (placed multiple times)
56
+ - Response format: `baseType="point"` with coordinates only
57
+
58
+ **Extension Behavior:**
59
+ This player allows multiple `positionObjectStage` elements with identifiers, enabling "place labeled objects on map" scenarios.
60
+
61
+ **Limitation:**
62
+ The response format cannot preserve object identity per QTI spec.
63
+
64
+ **Recommended Alternative:**
65
+ Use `graphicGapMatchInteraction` for spec-compliant labeled object placement.
66
+
67
+ **Rationale:**
68
+ The standard `positionObjectInteraction` is too limited for common educational use cases where different objects need to be placed on a map.
69
+
70
+ ## Strict Compliance Mode
71
+
72
+ Enable strict mode to enforce QTI 2.2 compliance and log/reject vendor extensions:
73
+
74
+ ```typescript
75
+ import { Player } from '@pie-qti/item-player';
76
+
77
+ const player = new Player({
78
+ itemXml: qtiXml,
79
+ strictQtiCompliance: {
80
+ enabled: true, // Enable strict QTI 2.2 validation
81
+ rejectUnknownExtensions: true, // Throw errors on non-2.2 versions
82
+ logDeviations: true // Log warnings for spec deviations
83
+ }
84
+ });
85
+ ```
86
+
87
+ ### Configuration Options
88
+
89
+ | Option | Default | Description |
90
+ |--------|---------|-------------|
91
+ | `enabled` | `false` | Enable strict QTI 2.2 compliance checking |
92
+ | `rejectUnknownExtensions` | `false` | Throw errors if item version is not 2.2 |
93
+ | `logDeviations` | `true` | Log console warnings for spec deviations |
94
+
95
+ ## Version Detection
96
+
97
+ The player automatically detects QTI version using multiple strategies:
98
+
99
+ ### Detection Order
100
+ 1. **Namespace URI** - Checks for `v2p0`, `v2p1`, or `v2p2` in namespace
101
+ ```xml
102
+ <assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
103
+ ```
104
+
105
+ 2. **Version Attribute** - Reads explicit version attribute
106
+ ```xml
107
+ <assessmentItem version="2.2">
108
+ ```
109
+
110
+ 3. **Fallback** - Assumes QTI 2.2 if version cannot be determined
111
+
112
+ ### Version Logging
113
+
114
+ The player logs version information to console:
115
+
116
+ ```
117
+ [QTI Player] QTI 2.1 detected. Using QTI 2.2 compatibility mode with CC2 template support.
118
+ [QTI Player] QTI 2.0 detected. Some features may not be fully supported. QTI 2.2 is recommended.
119
+ [QTI Player] Could not detect QTI version. Assuming QTI 2.2 compatibility.
120
+ ```
121
+
122
+ ## Known Limitations
123
+
124
+ ### QTI 2.0 Items
125
+ - ❌ `adaptive` attribute not supported (QTI 2.2 only feature)
126
+ - ⚠️ Some response processing rules may behave differently
127
+ - ✅ Template URLs must use standard filenames (namespace-agnostic matching)
128
+ - ⚠️ Limited testing with real QTI 2.0 content
129
+
130
+ ### QTI 2.1 Items
131
+ - ✅ Fully supported with CC2 template aliases
132
+ - ✅ Common Cartridge content packages work correctly
133
+ - ✅ Namespace differences handled transparently
134
+
135
+ ### QTI 2.2 Items
136
+ - ✅ Full support (recommended baseline)
137
+ - ✅ All 21 standard interactions
138
+ - ✅ Adaptive items supported
139
+ - ✅ All response processing templates
140
+
141
+ ## Namespace Handling
142
+
143
+ The player uses **namespace-agnostic** element matching:
144
+
145
+ ```typescript
146
+ // Uses Element.localName, ignoring namespace prefixes
147
+ findDescendants(element, 'responseDeclaration')
148
+ ```
149
+
150
+ This design choice ensures:
151
+ - QTI 2.0, 2.1, and 2.2 items work identically
152
+ - Namespace differences don't break element lookup
153
+ - Template filename-based matching (not full URL matching)
154
+
155
+ ## Testing
156
+
157
+ Test fixtures for different QTI versions are located in:
158
+ - `__tests__/fixtures/qti2.0/` - QTI 2.0 test items
159
+ - `__tests__/fixtures/qti2.1/` - QTI 2.1 test items
160
+ - `__tests__/fixtures/qti2.2/` - QTI 2.2 test items
161
+
162
+ Run tests with:
163
+ ```bash
164
+ cd packages/item-player
165
+ bun test
166
+ ```
167
+
168
+ ## Migration Guide
169
+
170
+ ### From QTI 2.0/2.1 to QTI 2.2
171
+
172
+ **Template Names:**
173
+ - Replace `cc2_match` with `match_correct` (both still supported)
174
+ - Replace `cc2_map_response` with `map_response` (both still supported)
175
+ - No breaking changes - old names work via aliases
176
+
177
+ **Namespace Updates:**
178
+ ```xml
179
+ <!-- QTI 2.1 -->
180
+ <assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1">
181
+
182
+ <!-- QTI 2.2 (recommended) -->
183
+ <assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
184
+ ```
185
+
186
+ **Adaptive Items:**
187
+ Only available in QTI 2.2. Add `adaptive="true"` attribute:
188
+ ```xml
189
+ <assessmentItem adaptive="true" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
190
+ ```
191
+
192
+ ## Additional Resources
193
+
194
+ - [QTI 2.2 Specification](http://www.imsglobal.org/question/qtiv2p2/imsqti_v2p2.html)
195
+ - [QTI 2.1 Specification](http://www.imsglobal.org/question/qtiv2p1/imsqti_v2p1.html)
196
+ - [Common Cartridge Profile](http://www.imsglobal.org/cc/)
197
+ - [PIE QTI Player Documentation](../README.md)