@pie-qti/item-player 0.1.1 → 0.1.5

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 (547) hide show
  1. package/README.md +22 -19
  2. package/dist/catalog/applyGlossaryTriggers.d.ts +15 -0
  3. package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -0
  4. package/dist/catalog/applyGlossaryTriggers.js +193 -0
  5. package/dist/catalog/catalogExtractor.d.ts +18 -0
  6. package/dist/catalog/catalogExtractor.d.ts.map +1 -0
  7. package/dist/catalog/catalogExtractor.js +114 -0
  8. package/dist/catalog/catalogLookup.d.ts +18 -0
  9. package/dist/catalog/catalogLookup.d.ts.map +1 -0
  10. package/dist/catalog/catalogLookup.js +44 -0
  11. package/dist/catalog/glossaryAction.d.ts +17 -0
  12. package/dist/catalog/glossaryAction.d.ts.map +1 -0
  13. package/dist/catalog/glossaryAction.js +21 -0
  14. package/dist/catalog/types.d.ts +26 -0
  15. package/dist/catalog/types.d.ts.map +1 -0
  16. package/dist/catalog/types.js +6 -0
  17. package/dist/components/actions/typesetAction.d.ts +24 -0
  18. package/dist/components/actions/typesetAction.d.ts.map +1 -0
  19. package/dist/components/actions/typesetAction.js +59 -0
  20. package/dist/components/utils/assignProps.d.ts +2 -0
  21. package/dist/components/utils/assignProps.d.ts.map +1 -0
  22. package/dist/components/utils/assignProps.js +1 -0
  23. package/dist/components/utils/feedbackUtils.d.ts +73 -0
  24. package/dist/components/utils/feedbackUtils.d.ts.map +1 -0
  25. package/dist/components/utils/feedbackUtils.js +93 -0
  26. package/dist/components/utils/index.d.ts +6 -0
  27. package/dist/components/utils/index.d.ts.map +1 -0
  28. package/dist/components/utils/index.js +5 -0
  29. package/dist/core/ComponentRegistry.d.ts +128 -0
  30. package/dist/core/ComponentRegistry.d.ts.map +1 -0
  31. package/dist/core/ComponentRegistry.js +137 -0
  32. package/dist/core/ItemRenderer.d.ts +91 -0
  33. package/dist/core/ItemRenderer.d.ts.map +1 -0
  34. package/dist/core/ItemRenderer.js +261 -0
  35. package/dist/core/Player.d.ts +195 -0
  36. package/dist/core/Player.d.ts.map +1 -0
  37. package/dist/core/Player.js +1235 -0
  38. package/dist/core/Plugin.d.ts +105 -0
  39. package/dist/core/Plugin.d.ts.map +1 -0
  40. package/dist/core/Plugin.js +7 -0
  41. package/dist/core/PluginManager.d.ts +56 -0
  42. package/dist/core/PluginManager.d.ts.map +1 -0
  43. package/dist/core/PluginManager.js +147 -0
  44. package/dist/core/constants.d.ts +68 -0
  45. package/dist/core/constants.d.ts.map +1 -0
  46. package/dist/core/constants.js +106 -0
  47. package/dist/core/declarations.d.ts +45 -0
  48. package/dist/core/declarations.d.ts.map +1 -0
  49. package/dist/core/declarations.js +133 -0
  50. package/dist/core/parsingLimits.d.ts +12 -0
  51. package/dist/core/parsingLimits.d.ts.map +1 -0
  52. package/dist/core/parsingLimits.js +45 -0
  53. package/dist/core/random.d.ts +12 -0
  54. package/dist/core/random.d.ts.map +1 -0
  55. package/dist/core/random.js +21 -0
  56. package/dist/core/rolePolicy.d.ts +16 -0
  57. package/dist/core/rolePolicy.d.ts.map +1 -0
  58. package/dist/core/rolePolicy.js +15 -0
  59. package/dist/core/sanitizer.d.ts +34 -0
  60. package/dist/core/sanitizer.d.ts.map +1 -0
  61. package/dist/core/sanitizer.js +198 -0
  62. package/dist/core/trustedTypes.d.ts +16 -0
  63. package/dist/core/trustedTypes.d.ts.map +1 -0
  64. package/dist/core/trustedTypes.js +55 -0
  65. package/dist/core/urlPolicy.d.ts +8 -0
  66. package/dist/core/urlPolicy.d.ts.map +1 -0
  67. package/dist/core/urlPolicy.js +90 -0
  68. package/dist/element.d.ts +22 -0
  69. package/dist/element.js +5327 -0
  70. package/dist/element.js.map +1 -0
  71. package/dist/extensions/MathLiveEditor.d.ts +32 -0
  72. package/dist/extensions/MathLiveEditor.d.ts.map +1 -0
  73. package/dist/extensions/MathLiveEditor.js +249 -0
  74. package/dist/extraction/ExtractionRegistry.d.ts +112 -0
  75. package/dist/extraction/ExtractionRegistry.d.ts.map +1 -0
  76. package/dist/extraction/ExtractionRegistry.js +260 -0
  77. package/dist/extraction/createContext.d.ts +30 -0
  78. package/dist/extraction/createContext.d.ts.map +1 -0
  79. package/dist/extraction/createContext.js +39 -0
  80. package/dist/extraction/extractors/associateExtractor.d.ts +29 -0
  81. package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -0
  82. package/dist/extraction/extractors/associateExtractor.js +97 -0
  83. package/dist/extraction/extractors/choiceExtractor.d.ts +27 -0
  84. package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -0
  85. package/dist/extraction/extractors/choiceExtractor.js +93 -0
  86. package/dist/extraction/extractors/customExtractor.d.ts +20 -0
  87. package/dist/extraction/extractors/customExtractor.d.ts.map +1 -0
  88. package/dist/extraction/extractors/customExtractor.js +51 -0
  89. package/dist/extraction/extractors/drawingExtractor.d.ts +30 -0
  90. package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -0
  91. package/dist/extraction/extractors/drawingExtractor.js +78 -0
  92. package/dist/extraction/extractors/endAttemptExtractor.d.ts +20 -0
  93. package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -0
  94. package/dist/extraction/extractors/endAttemptExtractor.js +53 -0
  95. package/dist/extraction/extractors/extendedTextExtractor.d.ts +21 -0
  96. package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -0
  97. package/dist/extraction/extractors/extendedTextExtractor.js +63 -0
  98. package/dist/extraction/extractors/gapMatchExtractor.d.ts +29 -0
  99. package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -0
  100. package/dist/extraction/extractors/gapMatchExtractor.js +155 -0
  101. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +41 -0
  102. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -0
  103. package/dist/extraction/extractors/graphicAssociateExtractor.js +143 -0
  104. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +53 -0
  105. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -0
  106. package/dist/extraction/extractors/graphicGapMatchExtractor.js +205 -0
  107. package/dist/extraction/extractors/graphicOrderExtractor.d.ts +37 -0
  108. package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -0
  109. package/dist/extraction/extractors/graphicOrderExtractor.js +121 -0
  110. package/dist/extraction/extractors/hotspotExtractor.d.ts +38 -0
  111. package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -0
  112. package/dist/extraction/extractors/hotspotExtractor.js +159 -0
  113. package/dist/extraction/extractors/hottextExtractor.d.ts +26 -0
  114. package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -0
  115. package/dist/extraction/extractors/hottextExtractor.js +128 -0
  116. package/dist/extraction/extractors/index.d.ts +63 -0
  117. package/dist/extraction/extractors/index.d.ts.map +1 -0
  118. package/dist/extraction/extractors/index.js +88 -0
  119. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +25 -0
  120. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -0
  121. package/dist/extraction/extractors/inlineChoiceExtractor.js +80 -0
  122. package/dist/extraction/extractors/matchExtractor.d.ts +37 -0
  123. package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -0
  124. package/dist/extraction/extractors/matchExtractor.js +160 -0
  125. package/dist/extraction/extractors/mediaExtractor.d.ts +33 -0
  126. package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -0
  127. package/dist/extraction/extractors/mediaExtractor.js +125 -0
  128. package/dist/extraction/extractors/orderExtractor.d.ts +28 -0
  129. package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -0
  130. package/dist/extraction/extractors/orderExtractor.js +90 -0
  131. package/dist/extraction/extractors/portableCustomExtractor.d.ts +14 -0
  132. package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -0
  133. package/dist/extraction/extractors/portableCustomExtractor.js +96 -0
  134. package/dist/extraction/extractors/positionObjectExtractor.d.ts +59 -0
  135. package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -0
  136. package/dist/extraction/extractors/positionObjectExtractor.js +191 -0
  137. package/dist/extraction/extractors/selectPointExtractor.d.ts +31 -0
  138. package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -0
  139. package/dist/extraction/extractors/selectPointExtractor.js +109 -0
  140. package/dist/extraction/extractors/sliderExtractor.d.ts +24 -0
  141. package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -0
  142. package/dist/extraction/extractors/sliderExtractor.js +73 -0
  143. package/dist/extraction/extractors/textEntryExtractor.d.ts +21 -0
  144. package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -0
  145. package/dist/extraction/extractors/textEntryExtractor.js +54 -0
  146. package/dist/extraction/extractors/uploadExtractor.d.ts +20 -0
  147. package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -0
  148. package/dist/extraction/extractors/uploadExtractor.js +59 -0
  149. package/dist/extraction/index.d.ts +49 -0
  150. package/dist/extraction/index.d.ts.map +1 -0
  151. package/dist/extraction/index.js +49 -0
  152. package/dist/extraction/types.d.ts +209 -0
  153. package/dist/extraction/types.d.ts.map +1 -0
  154. package/dist/extraction/types.js +30 -0
  155. package/dist/extraction/utils.d.ts +15 -0
  156. package/dist/extraction/utils.d.ts.map +1 -0
  157. package/dist/extraction/utils.js +178 -0
  158. package/dist/iframe/IFramePlayerHost.d.ts +122 -0
  159. package/dist/iframe/IFramePlayerHost.d.ts.map +1 -0
  160. package/dist/iframe/IFramePlayerHost.js +172 -0
  161. package/dist/iframe/index.d.ts +9 -0
  162. package/dist/iframe/index.d.ts.map +1 -0
  163. package/dist/iframe/index.js +8 -0
  164. package/dist/iframe/protocol.d.ts +75 -0
  165. package/dist/iframe/protocol.d.ts.map +1 -0
  166. package/dist/iframe/protocol.js +53 -0
  167. package/dist/index.d.ts +38 -0
  168. package/dist/index.d.ts.map +1 -0
  169. package/dist/index.js +42 -0
  170. package/dist/pci/PciHost.d.ts +53 -0
  171. package/dist/pci/PciHost.d.ts.map +1 -0
  172. package/dist/pci/PciHost.js +116 -0
  173. package/dist/pci/types.d.ts +57 -0
  174. package/dist/pci/types.d.ts.map +1 -0
  175. package/dist/pci/types.js +19 -0
  176. package/dist/pnp/applyPnp.d.ts +9 -0
  177. package/dist/pnp/applyPnp.d.ts.map +1 -0
  178. package/dist/pnp/applyPnp.js +19 -0
  179. package/dist/pnp/parsePnpXml.d.ts +9 -0
  180. package/dist/pnp/parsePnpXml.d.ts.map +1 -0
  181. package/dist/pnp/parsePnpXml.js +101 -0
  182. package/dist/pnp/types.d.ts +40 -0
  183. package/dist/pnp/types.d.ts.map +1 -0
  184. package/dist/pnp/types.js +1 -0
  185. package/dist/server.d.ts +10 -0
  186. package/dist/server.d.ts.map +1 -0
  187. package/dist/server.js +10 -0
  188. package/dist/types/index.d.ts +304 -0
  189. package/dist/types/index.d.ts.map +1 -0
  190. package/dist/types/index.js +7 -0
  191. package/dist/types/interactions.d.ts +412 -0
  192. package/dist/types/interactions.d.ts.map +1 -0
  193. package/dist/types/interactions.js +7 -0
  194. package/dist/types/responseValidation.d.ts +25 -0
  195. package/dist/types/responseValidation.d.ts.map +1 -0
  196. package/dist/types/responseValidation.js +1 -0
  197. package/dist/utils/PerformanceMonitor.d.ts +170 -0
  198. package/dist/utils/PerformanceMonitor.d.ts.map +1 -0
  199. package/dist/utils/PerformanceMonitor.js +242 -0
  200. package/dist/utils/drawingUtils.d.ts +39 -0
  201. package/dist/utils/drawingUtils.d.ts.map +1 -0
  202. package/dist/utils/drawingUtils.js +57 -0
  203. package/dist/utils/responseUtils.d.ts +16 -0
  204. package/dist/utils/responseUtils.d.ts.map +1 -0
  205. package/dist/utils/responseUtils.js +45 -0
  206. package/dist/utils/touchDragHelper.d.ts +2 -0
  207. package/dist/utils/touchDragHelper.d.ts.map +1 -0
  208. package/dist/utils/touchDragHelper.js +1 -0
  209. package/dist/web-components/QTIInteractionBase.d.ts +120 -0
  210. package/dist/web-components/QTIInteractionBase.d.ts.map +1 -0
  211. package/dist/web-components/QTIInteractionBase.js +243 -0
  212. package/dist/web-components/QTIInteractionElement.d.ts +77 -0
  213. package/dist/web-components/QTIInteractionElement.d.ts.map +1 -0
  214. package/dist/web-components/QTIInteractionElement.js +61 -0
  215. package/dist/web-components/index.d.ts +8 -0
  216. package/dist/web-components/index.d.ts.map +1 -0
  217. package/dist/web-components/index.js +10 -0
  218. package/package.json +104 -76
  219. package/src/__tests__/catalog.test.ts +267 -0
  220. package/src/__tests__/fixtures/pci/echo-pci.js +49 -0
  221. package/src/__tests__/glossaryTriggers.test.ts +411 -0
  222. package/src/__tests__/pci.test.ts +353 -0
  223. package/src/__tests__/pnp.test.ts +250 -0
  224. package/src/__tests__/qti3-attribute-extraction.test.ts +174 -0
  225. package/src/__tests__/qti3-debug.test.ts +140 -0
  226. package/src/__tests__/qti3-extraction.test.ts +309 -0
  227. package/src/catalog/applyGlossaryTriggers.ts +232 -0
  228. package/src/catalog/catalogExtractor.ts +130 -0
  229. package/src/catalog/catalogLookup.ts +53 -0
  230. package/src/catalog/glossaryAction.ts +28 -0
  231. package/src/catalog/types.ts +37 -0
  232. package/src/components/ItemBody.svelte +136 -26
  233. package/src/components/ItemPlayer.svelte +6 -2
  234. package/src/components/index.ts +3 -0
  235. package/src/components/utils/assignProps.ts +1 -23
  236. package/src/core/ComponentRegistry.ts +14 -0
  237. package/src/core/ItemRenderer.ts +4 -0
  238. package/src/core/Player.ts +312 -38
  239. package/src/core/parsingLimits.ts +1 -1
  240. package/src/core/rolePolicy.ts +34 -0
  241. package/src/core/urlPolicy.ts +5 -2
  242. package/src/element.ts +128 -0
  243. package/src/extensions/MathLiveEditor.ts +6 -3
  244. package/src/extraction/ExtractionRegistry.ts +51 -11
  245. package/src/extraction/createContext.ts +6 -1
  246. package/src/extraction/extractors/associateExtractor.ts +4 -0
  247. package/src/extraction/extractors/choiceExtractor.ts +12 -1
  248. package/src/extraction/extractors/conformance-qti3-advanced.test.ts +239 -0
  249. package/src/extraction/extractors/conformance-qti3-basic.test.ts +82 -0
  250. package/src/extraction/extractors/conformance.test.ts +208 -0
  251. package/src/extraction/extractors/extendedTextExtractor.ts +11 -2
  252. package/src/extraction/extractors/gapMatchExtractor.ts +36 -21
  253. package/src/extraction/extractors/graphicAssociateExtractor.ts +4 -0
  254. package/src/extraction/extractors/graphicGapMatchExtractor.ts +82 -10
  255. package/src/extraction/extractors/hotspotExtractor.ts +26 -8
  256. package/src/extraction/extractors/hottextExtractor.ts +15 -5
  257. package/src/extraction/extractors/index.ts +4 -0
  258. package/src/extraction/extractors/inlineChoiceExtractor.ts +22 -5
  259. package/src/extraction/extractors/matchExtractor.ts +33 -6
  260. package/src/extraction/extractors/orderExtractor.ts +6 -0
  261. package/src/extraction/extractors/portableCustomExtractor.ts +122 -0
  262. package/src/extraction/extractors/selectPointExtractor.ts +5 -5
  263. package/src/extraction/extractors/textEntryExtractor.ts +11 -2
  264. package/src/extraction/extractors/uploadExtractor.ts +10 -2
  265. package/src/extraction/utils.ts +99 -16
  266. package/src/index.ts +19 -1
  267. package/src/pci/PciHost.ts +138 -0
  268. package/src/pci/types.ts +70 -0
  269. package/src/pnp/applyPnp.ts +23 -0
  270. package/src/pnp/parsePnpXml.ts +118 -0
  271. package/src/pnp/types.ts +33 -0
  272. package/src/types/index.ts +50 -16
  273. package/src/types/interactions.ts +81 -6
  274. package/src/types/xmldom.d.ts +12 -0
  275. package/src/utils/drawingUtils.ts +73 -0
  276. package/src/utils/touchDragHelper.ts +1 -211
  277. package/.turbo/turbo-build.log +0 -1
  278. package/CHANGELOG.md +0 -9
  279. package/docs/QTI-COMPLIANCE.md +0 -197
  280. package/docs/WCAG-2.2-COMPLIANCE.md +0 -466
  281. package/docs/custom-extractors.md +0 -679
  282. package/docs/iframe-mode.md +0 -78
  283. package/docs/security-audit.md +0 -236
  284. package/docs/server-api.md +0 -691
  285. package/tests/conformance/FIXTURE_POLICY.md +0 -29
  286. package/tests/conformance/README.md +0 -70
  287. package/tests/conformance/fixtures/baseTypes_all/cases.json +0 -61
  288. package/tests/conformance/fixtures/baseTypes_all/item.xml +0 -131
  289. package/tests/conformance/fixtures/baseTypes_all/manifest.json +0 -7
  290. package/tests/conformance/fixtures/choice_match_correct/cases.json +0 -17
  291. package/tests/conformance/fixtures/choice_match_correct/item.xml +0 -55
  292. package/tests/conformance/fixtures/choice_match_correct/manifest.json +0 -14
  293. package/tests/conformance/fixtures/contains_multiple/cases.json +0 -12
  294. package/tests/conformance/fixtures/contains_multiple/item.xml +0 -37
  295. package/tests/conformance/fixtures/contains_multiple/manifest.json +0 -13
  296. package/tests/conformance/fixtures/isNull_isNotNull/cases.json +0 -9
  297. package/tests/conformance/fixtures/isNull_isNotNull/item.xml +0 -41
  298. package/tests/conformance/fixtures/isNull_isNotNull/manifest.json +0 -23
  299. package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/cases.json +0 -27
  300. package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/item.xml +0 -30
  301. package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/manifest.json +0 -15
  302. package/tests/conformance/fixtures/mapResponse_integer_mapKey/cases.json +0 -11
  303. package/tests/conformance/fixtures/mapResponse_integer_mapKey/item.xml +0 -26
  304. package/tests/conformance/fixtures/mapResponse_integer_mapKey/manifest.json +0 -13
  305. package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/cases.json +0 -27
  306. package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/item.xml +0 -32
  307. package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/manifest.json +0 -7
  308. package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/cases.json +0 -9
  309. package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/item.xml +0 -25
  310. package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/manifest.json +0 -12
  311. package/tests/conformance/fixtures/mapResponse_multiple_cardinality/cases.json +0 -12
  312. package/tests/conformance/fixtures/mapResponse_multiple_cardinality/item.xml +0 -35
  313. package/tests/conformance/fixtures/mapResponse_multiple_cardinality/manifest.json +0 -11
  314. package/tests/conformance/fixtures/mapping_bounds_upperLower/cases.json +0 -12
  315. package/tests/conformance/fixtures/mapping_bounds_upperLower/item.xml +0 -37
  316. package/tests/conformance/fixtures/mapping_bounds_upperLower/manifest.json +0 -11
  317. package/tests/conformance/fixtures/mapping_mapResponse/cases.json +0 -22
  318. package/tests/conformance/fixtures/mapping_mapResponse/item.xml +0 -53
  319. package/tests/conformance/fixtures/mapping_mapResponse/manifest.json +0 -16
  320. package/tests/conformance/fixtures/member_multiple/cases.json +0 -12
  321. package/tests/conformance/fixtures/member_multiple/item.xml +0 -37
  322. package/tests/conformance/fixtures/member_multiple/manifest.json +0 -13
  323. package/tests/conformance/fixtures/modalFeedback_basic/cases.json +0 -17
  324. package/tests/conformance/fixtures/modalFeedback_basic/item.xml +0 -52
  325. package/tests/conformance/fixtures/modalFeedback_basic/manifest.json +0 -13
  326. package/tests/conformance/fixtures/multiple_unordered_match/cases.json +0 -17
  327. package/tests/conformance/fixtures/multiple_unordered_match/item.xml +0 -44
  328. package/tests/conformance/fixtures/multiple_unordered_match/manifest.json +0 -11
  329. package/tests/conformance/fixtures/ordered_match/cases.json +0 -17
  330. package/tests/conformance/fixtures/ordered_match/item.xml +0 -48
  331. package/tests/conformance/fixtures/ordered_match/manifest.json +0 -13
  332. package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/cases.json +0 -27
  333. package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/item.xml +0 -103
  334. package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/manifest.json +0 -7
  335. package/tests/conformance/fixtures/outcomeProcessing_exitTest/cases.json +0 -15
  336. package/tests/conformance/fixtures/outcomeProcessing_exitTest/item.xml +0 -33
  337. package/tests/conformance/fixtures/outcomeProcessing_exitTest/manifest.json +0 -10
  338. package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/cases.json +0 -14
  339. package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/item.xml +0 -26
  340. package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/manifest.json +0 -8
  341. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/cases.json +0 -17
  342. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/item.xml +0 -43
  343. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/manifest.json +0 -16
  344. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/cases.json +0 -27
  345. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/item.xml +0 -37
  346. package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/manifest.json +0 -16
  347. package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/cases.json +0 -14
  348. package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/item.xml +0 -35
  349. package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/manifest.json +0 -8
  350. package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/cases.json +0 -14
  351. package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/item.xml +0 -35
  352. package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/manifest.json +0 -8
  353. package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/cases.json +0 -15
  354. package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/item.xml +0 -39
  355. package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/manifest.json +0 -11
  356. package/tests/conformance/fixtures/outcomeProcessing_testVariables/cases.json +0 -14
  357. package/tests/conformance/fixtures/outcomeProcessing_testVariables/item.xml +0 -35
  358. package/tests/conformance/fixtures/outcomeProcessing_testVariables/manifest.json +0 -8
  359. package/tests/conformance/fixtures/pair_unordered_match/cases.json +0 -22
  360. package/tests/conformance/fixtures/pair_unordered_match/item.xml +0 -44
  361. package/tests/conformance/fixtures/pair_unordered_match/manifest.json +0 -13
  362. package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/cases.json +0 -95
  363. package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/item.xml +0 -53
  364. package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/cases.json +0 -115
  365. package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/item.xml +0 -45
  366. package/tests/conformance/fixtures/positionObject_mapResponse_wrong/cases.json +0 -29
  367. package/tests/conformance/fixtures/positionObject_mapResponse_wrong/item.xml +0 -40
  368. package/tests/conformance/fixtures/responseCondition_elseIf_chain/cases.json +0 -10
  369. package/tests/conformance/fixtures/responseCondition_elseIf_chain/item.xml +0 -49
  370. package/tests/conformance/fixtures/responseCondition_elseIf_chain/manifest.json +0 -15
  371. package/tests/conformance/fixtures/responseProcessing_anyN/cases.json +0 -27
  372. package/tests/conformance/fixtures/responseProcessing_anyN/item.xml +0 -47
  373. package/tests/conformance/fixtures/responseProcessing_anyN/manifest.json +0 -16
  374. package/tests/conformance/fixtures/responseProcessing_anyN_allN/cases.json +0 -27
  375. package/tests/conformance/fixtures/responseProcessing_anyN_allN/item.xml +0 -69
  376. package/tests/conformance/fixtures/responseProcessing_anyN_allN/manifest.json +0 -23
  377. package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/cases.json +0 -15
  378. package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/item.xml +0 -58
  379. package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/manifest.json +0 -15
  380. package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/cases.json +0 -37
  381. package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/item.xml +0 -94
  382. package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/manifest.json +0 -27
  383. package/tests/conformance/fixtures/responseProcessing_containerSize_index/cases.json +0 -33
  384. package/tests/conformance/fixtures/responseProcessing_containerSize_index/item.xml +0 -79
  385. package/tests/conformance/fixtures/responseProcessing_containerSize_index/manifest.json +0 -16
  386. package/tests/conformance/fixtures/responseProcessing_customOperator/cases.json +0 -15
  387. package/tests/conformance/fixtures/responseProcessing_customOperator/item.xml +0 -30
  388. package/tests/conformance/fixtures/responseProcessing_customOperator/manifest.json +0 -12
  389. package/tests/conformance/fixtures/responseProcessing_default_expression/cases.json +0 -12
  390. package/tests/conformance/fixtures/responseProcessing_default_expression/item.xml +0 -48
  391. package/tests/conformance/fixtures/responseProcessing_default_expression/manifest.json +0 -13
  392. package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/cases.json +0 -29
  393. package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/item.xml +0 -68
  394. package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/manifest.json +0 -17
  395. package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/cases.json +0 -39
  396. package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/item.xml +0 -39
  397. package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/manifest.json +0 -17
  398. package/tests/conformance/fixtures/responseProcessing_exitResponse/cases.json +0 -12
  399. package/tests/conformance/fixtures/responseProcessing_exitResponse/item.xml +0 -25
  400. package/tests/conformance/fixtures/responseProcessing_exitResponse/manifest.json +0 -12
  401. package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/cases.json +0 -26
  402. package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/item.xml +0 -134
  403. package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/manifest.json +0 -16
  404. package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/cases.json +0 -27
  405. package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/item.xml +0 -33
  406. package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/manifest.json +0 -13
  407. package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/cases.json +0 -22
  408. package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/item.xml +0 -33
  409. package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/manifest.json +0 -13
  410. package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/cases.json +0 -27
  411. package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/item.xml +0 -40
  412. package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/manifest.json +0 -18
  413. package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/cases.json +0 -22
  414. package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/item.xml +0 -33
  415. package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/manifest.json +0 -12
  416. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/cases.json +0 -29
  417. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/item.xml +0 -26
  418. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/manifest.json +0 -7
  419. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/cases.json +0 -23
  420. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/item.xml +0 -28
  421. package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/manifest.json +0 -11
  422. package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/cases.json +0 -29
  423. package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/item.xml +0 -26
  424. package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/manifest.json +0 -7
  425. package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/cases.json +0 -31
  426. package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/item.xml +0 -102
  427. package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/manifest.json +0 -18
  428. package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/cases.json +0 -22
  429. package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/item.xml +0 -45
  430. package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/manifest.json +0 -21
  431. package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/cases.json +0 -26
  432. package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/item.xml +0 -157
  433. package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/manifest.json +0 -22
  434. package/tests/conformance/fixtures/responseProcessing_notEqual_basic/cases.json +0 -22
  435. package/tests/conformance/fixtures/responseProcessing_notEqual_basic/item.xml +0 -39
  436. package/tests/conformance/fixtures/responseProcessing_notEqual_basic/manifest.json +0 -18
  437. package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/cases.json +0 -22
  438. package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/item.xml +0 -51
  439. package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/manifest.json +0 -19
  440. package/tests/conformance/fixtures/responseProcessing_preCondition/cases.json +0 -31
  441. package/tests/conformance/fixtures/responseProcessing_preCondition/item.xml +0 -44
  442. package/tests/conformance/fixtures/responseProcessing_preCondition/manifest.json +0 -12
  443. package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/cases.json +0 -27
  444. package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/item.xml +0 -42
  445. package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/manifest.json +0 -14
  446. package/tests/conformance/fixtures/responseProcessing_record_fieldValue/cases.json +0 -12
  447. package/tests/conformance/fixtures/responseProcessing_record_fieldValue/item.xml +0 -40
  448. package/tests/conformance/fixtures/responseProcessing_record_fieldValue/manifest.json +0 -17
  449. package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/cases.json +0 -17
  450. package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/item.xml +0 -63
  451. package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/manifest.json +0 -9
  452. package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/cases.json +0 -12
  453. package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/item.xml +0 -40
  454. package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/manifest.json +0 -13
  455. package/tests/conformance/fixtures/responseProcessing_setDefaultValue/cases.json +0 -15
  456. package/tests/conformance/fixtures/responseProcessing_setDefaultValue/item.xml +0 -67
  457. package/tests/conformance/fixtures/responseProcessing_setDefaultValue/manifest.json +0 -9
  458. package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/cases.json +0 -27
  459. package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/item.xml +0 -69
  460. package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/manifest.json +0 -10
  461. package/tests/conformance/fixtures/responseProcessing_subtract_divide/cases.json +0 -15
  462. package/tests/conformance/fixtures/responseProcessing_subtract_divide/item.xml +0 -35
  463. package/tests/conformance/fixtures/responseProcessing_subtract_divide/manifest.json +0 -11
  464. package/tests/conformance/fixtures/responseProcessing_template_map_response/cases.json +0 -17
  465. package/tests/conformance/fixtures/responseProcessing_template_map_response/item.xml +0 -31
  466. package/tests/conformance/fixtures/responseProcessing_template_map_response/manifest.json +0 -8
  467. package/tests/conformance/fixtures/responseProcessing_template_map_response_point/cases.json +0 -22
  468. package/tests/conformance/fixtures/responseProcessing_template_map_response_point/item.xml +0 -27
  469. package/tests/conformance/fixtures/responseProcessing_template_map_response_point/manifest.json +0 -8
  470. package/tests/conformance/fixtures/responseProcessing_template_match_correct/cases.json +0 -17
  471. package/tests/conformance/fixtures/responseProcessing_template_match_correct/item.xml +0 -34
  472. package/tests/conformance/fixtures/responseProcessing_template_match_correct/manifest.json +0 -8
  473. package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/cases.json +0 -22
  474. package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/item.xml +0 -30
  475. package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/manifest.json +0 -7
  476. package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/cases.json +0 -17
  477. package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/item.xml +0 -30
  478. package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/manifest.json +0 -9
  479. package/tests/conformance/fixtures/responseProcessing_template_match_nothing/cases.json +0 -17
  480. package/tests/conformance/fixtures/responseProcessing_template_match_nothing/item.xml +0 -30
  481. package/tests/conformance/fixtures/responseProcessing_template_match_nothing/manifest.json +0 -8
  482. package/tests/conformance/fixtures/responseProcessing_xiInclude/cases.json +0 -14
  483. package/tests/conformance/fixtures/responseProcessing_xiInclude/item.xml +0 -25
  484. package/tests/conformance/fixtures/responseProcessing_xiInclude/manifest.json +0 -9
  485. package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/cases.json +0 -12
  486. package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/item.xml +0 -52
  487. package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/manifest.json +0 -14
  488. package/tests/conformance/fixtures/templateProcessing_exitTemplate/cases.json +0 -12
  489. package/tests/conformance/fixtures/templateProcessing_exitTemplate/item.xml +0 -48
  490. package/tests/conformance/fixtures/templateProcessing_exitTemplate/manifest.json +0 -13
  491. package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/cases.json +0 -27
  492. package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/item.xml +0 -74
  493. package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/manifest.json +0 -22
  494. package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/cases.json +0 -17
  495. package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/item.xml +0 -133
  496. package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/manifest.json +0 -22
  497. package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/cases.json +0 -12
  498. package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/item.xml +0 -107
  499. package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/manifest.json +0 -16
  500. package/tests/conformance/fixtures/templateProcessing_templateConstraint/cases.json +0 -15
  501. package/tests/conformance/fixtures/templateProcessing_templateConstraint/item.xml +0 -52
  502. package/tests/conformance/fixtures/templateProcessing_templateConstraint/manifest.json +0 -14
  503. package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/cases.json +0 -16
  504. package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/item.xml +0 -49
  505. package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/manifest.json +0 -15
  506. package/tests/conformance/fixtures/template_randomInteger_printedVariable/cases.json +0 -16
  507. package/tests/conformance/fixtures/template_randomInteger_printedVariable/item.xml +0 -38
  508. package/tests/conformance/fixtures/template_randomInteger_printedVariable/manifest.json +0 -13
  509. package/tests/conformance/harness.ts +0 -84
  510. package/tests/conformance/run-fixtures.test.ts +0 -127
  511. package/tests/conformance/scripts/normalize-covers.ts +0 -152
  512. package/tests/conformance/types.ts +0 -53
  513. package/tests/core/Player.test.ts +0 -563
  514. package/tests/core/adaptiveItems.test.ts +0 -442
  515. package/tests/core/correctResponse.test.ts +0 -280
  516. package/tests/core/interaction-plumbing.test.ts +0 -141
  517. package/tests/core/modalFeedback.test.ts +0 -308
  518. package/tests/core/outcome-reset.test.ts +0 -43
  519. package/tests/extraction/extractors/associateExtractor.test.ts +0 -182
  520. package/tests/extraction/extractors/choiceExtractor.test.ts +0 -239
  521. package/tests/extraction/extractors/customExtractor.test.ts +0 -83
  522. package/tests/extraction/extractors/drawingExtractor.test.ts +0 -94
  523. package/tests/extraction/extractors/endAttemptExtractor.test.ts +0 -188
  524. package/tests/extraction/extractors/extendedTextExtractor.test.ts +0 -178
  525. package/tests/extraction/extractors/gapMatchExtractor.test.ts +0 -318
  526. package/tests/extraction/extractors/graphicAssociateExtractor.test.ts +0 -260
  527. package/tests/extraction/extractors/graphicGapMatchExtractor.test.ts +0 -320
  528. package/tests/extraction/extractors/graphicOrderExtractor.test.ts +0 -223
  529. package/tests/extraction/extractors/hotspotExtractor.test.ts +0 -298
  530. package/tests/extraction/extractors/hottextExtractor.test.ts +0 -240
  531. package/tests/extraction/extractors/inlineChoiceExtractor.test.ts +0 -292
  532. package/tests/extraction/extractors/matchExtractor.test.ts +0 -241
  533. package/tests/extraction/extractors/mediaExtractor.test.ts +0 -295
  534. package/tests/extraction/extractors/orderExtractor.test.ts +0 -212
  535. package/tests/extraction/extractors/positionObjectExtractor.test.ts +0 -363
  536. package/tests/extraction/extractors/selectPointExtractor.test.ts +0 -214
  537. package/tests/extraction/extractors/sliderExtractor.test.ts +0 -293
  538. package/tests/extraction/extractors/textEntryExtractor.test.ts +0 -133
  539. package/tests/extraction/extractors/uploadExtractor.test.ts +0 -119
  540. package/tests/extraction/test-utils.ts +0 -57
  541. package/tests/iframe/host.test.ts +0 -145
  542. package/tests/iframe/protocol.test.ts +0 -42
  543. package/tests/performance/player-benchmarks.bench.ts +0 -191
  544. package/tests/security/dos-limits.test.ts +0 -56
  545. package/tests/security/xss-prevention.test.ts +0 -522
  546. package/tsconfig.json +0 -20
  547. package/tsconfig.svelte.json +0 -14
@@ -27,8 +27,14 @@ import {
27
27
  toNumber,
28
28
  toStringValue,
29
29
  } from '@pie-qti/qti-processing';
30
- import type { ElementNameMapper } from '@pie-qti/qti-common';
31
- import { Qti2xElementNameMapper } from '@pie-qti/qti-common';
30
+ import type { ElementNameMapper, AttributeNameMapper } from '@pie-qti/qti-common';
31
+ import {
32
+ Qti2xElementNameMapper,
33
+ Qti2xAttributeNameMapper,
34
+ Qti3ElementNameMapper,
35
+ Qti3AttributeNameMapper,
36
+ detectQtiVersion,
37
+ } from '@pie-qti/qti-common';
32
38
  import { parse } from 'node-html-parser';
33
39
  import type { ExtractionRegistry } from '../extraction/ExtractionRegistry.js';
34
40
  import { createExtractionRegistry } from '../extraction/ExtractionRegistry.js';
@@ -38,13 +44,13 @@ import type {
38
44
  AdaptiveAttemptResult,
39
45
  CompletionStatus,
40
46
  HtmlContent,
47
+ ItemSessionState,
41
48
  ModalFeedback,
42
49
  PlayerConfig,
43
50
  PlayerSecurityConfig,
44
51
  QTIRole,
45
52
  RubricBlock,
46
53
  ScoringResult,
47
- SessionState,
48
54
  } from '../types/index.js';
49
55
  import type { InteractionData, QTIElement } from '../types/interactions.js';
50
56
  import type { ResponseValidationResult } from '../types/responseValidation.js';
@@ -55,6 +61,13 @@ import { createSeededRng } from './random.js';
55
61
  import { sanitizeHtml } from './sanitizer.js';
56
62
  import { toTrustedHtml } from './trustedTypes.js';
57
63
  import { sanitizeResourceUrl } from './urlPolicy.js';
64
+ import type { PnpProfile } from '../pnp/types.js';
65
+ import { applyPnpToRoot } from '../pnp/applyPnp.js';
66
+ import type { CatalogIndex } from '../catalog/types.js';
67
+ import { extractCatalogFromItemXml, mergeCatalogs } from '../catalog/catalogExtractor.js';
68
+ import { getCatalogEntry } from '../catalog/catalogLookup.js';
69
+ import { PciHost } from '../pci/PciHost.js';
70
+ import type { ExtractedPci } from '../pci/types.js';
58
71
 
59
72
  type DeclKind = 'response' | 'outcome' | 'template';
60
73
 
@@ -76,13 +89,38 @@ export class Player {
76
89
  private responseProcessingProgram: ProcessingProgram | null = null;
77
90
  private templateProcessingProgram: ProcessingProgram | null = null;
78
91
  private outcomeProcessingProgram: ProcessingProgram | null = null;
92
+ private _pnp: PnpProfile | undefined;
93
+ private _rootEl: HTMLElement | undefined;
94
+ private _catalogIndex: CatalogIndex = new Map();
95
+ private _pciHosts: Map<string, PciHost> = new Map();
79
96
 
80
97
  constructor(config: PlayerConfig) {
81
98
  this.config = config;
82
99
  this.itemXml = config.itemXml ?? '';
83
100
  this.role = config.role ?? 'candidate';
84
101
  this.rng = config.rng ?? (typeof config.seed === 'number' ? createSeededRng(config.seed) : Math.random);
85
- this.mapper = (config.elementNameMapper as ElementNameMapper | undefined) ?? new Qti2xElementNameMapper();
102
+
103
+ // Auto-detect QTI version and create appropriate mappers if not provided
104
+ if (!config.elementNameMapper) {
105
+ const version = detectQtiVersion(this.itemXml);
106
+ if (version === '3.0') {
107
+ this.mapper = new Qti3ElementNameMapper();
108
+ // Set in config so it's available to extraction utils
109
+ (config as any).elementNameMapper = this.mapper;
110
+ // Also set attribute mapper if not provided
111
+ if (!config.attributeNameMapper) {
112
+ (config as any).attributeNameMapper = new Qti3AttributeNameMapper();
113
+ }
114
+ } else {
115
+ this.mapper = new Qti2xElementNameMapper();
116
+ (config as any).elementNameMapper = this.mapper;
117
+ if (!config.attributeNameMapper) {
118
+ (config as any).attributeNameMapper = new Qti2xAttributeNameMapper();
119
+ }
120
+ }
121
+ } else {
122
+ this.mapper = config.elementNameMapper as ElementNameMapper;
123
+ }
86
124
 
87
125
  // Optional DoS guardrails for untrusted content (compat-by-default; disabled unless enabled).
88
126
  enforceItemXmlLimits(this.itemXml, this.config.security);
@@ -101,7 +139,8 @@ export class Player {
101
139
  }
102
140
 
103
141
  // Extraction + rendering registries (for interaction rendering)
104
- this.extractionRegistry = (config.extractionRegistry as ExtractionRegistry | undefined) ?? createExtractionRegistry();
142
+ // Pass the element name mapper to the extraction registry for QTI version handling
143
+ this.extractionRegistry = (config.extractionRegistry as ExtractionRegistry | undefined) ?? createExtractionRegistry(this.mapper);
105
144
  this.componentRegistry = (config.componentRegistry as ComponentRegistry | undefined) ?? createComponentRegistry();
106
145
 
107
146
  // I18n provider (defaults to a simple fallback if not provided)
@@ -168,12 +207,111 @@ export class Player {
168
207
  );
169
208
  }
170
209
 
210
+ // Store PNP profile for later use (applyPnpToRoot is called once a root element is available).
211
+ this._pnp = config.pnp;
212
+
213
+ // Build catalog index from item XML and optional shared catalog.
214
+ const itemCatalog = extractCatalogFromItemXml(this.itemXml);
215
+ if (config.catalogXml) {
216
+ const sharedCatalog = extractCatalogFromItemXml(config.catalogXml);
217
+ // Item-level wins on collision: merge shared first, then override with item entries.
218
+ this._catalogIndex = mergeCatalogs(sharedCatalog, itemCatalog);
219
+ } else {
220
+ this._catalogIndex = itemCatalog;
221
+ }
222
+
171
223
  // Check strict compliance if enabled
172
224
  if (this.config.strictQtiCompliance?.enabled) {
173
225
  this.validateStrictCompliance();
174
226
  }
175
227
  }
176
228
 
229
+ /**
230
+ * Apply the PNP profile to a player root element.
231
+ * Call this once the root DOM element is available (e.g. after mounting).
232
+ * The player stores the element reference so updatePnp() can re-apply without re-parsing the item.
233
+ */
234
+ public applyPnp(rootEl: HTMLElement): void {
235
+ this._rootEl = rootEl;
236
+ applyPnpToRoot(rootEl, this._pnp);
237
+ }
238
+
239
+ /**
240
+ * Update the PNP profile mid-session without re-parsing the item XML.
241
+ * Deep-merges the partial profile into the current profile and re-applies.
242
+ */
243
+ public updatePnp(partial: Partial<PnpProfile>): void {
244
+ this._pnp = mergePnp(this._pnp, partial);
245
+ if (this._rootEl) {
246
+ applyPnpToRoot(this._rootEl, this._pnp);
247
+ }
248
+ }
249
+
250
+ /** Return the current resolved PNP profile. */
251
+ public getPnp(): PnpProfile | undefined {
252
+ return this._pnp;
253
+ }
254
+
255
+ /**
256
+ * Look up a catalog entry by card identifier, usage type, and optional language.
257
+ * Returns the HTML string for the matched entry, or null if not found.
258
+ *
259
+ * Language fallback: exact match → prefix match → no-lang entry → null.
260
+ */
261
+ public getCatalogEntry(idref: string, usage: string, lang?: string): string | null {
262
+ return getCatalogEntry(this._catalogIndex, idref, usage, lang);
263
+ }
264
+
265
+ /**
266
+ * Create a PciHost for an extracted PCI and register it for response tracking.
267
+ * The caller (typically ItemRenderer) is responsible for calling host.load() and
268
+ * host.initialize(domNode) once the DOM element is available.
269
+ */
270
+ public createPciHost(data: ExtractedPci): PciHost {
271
+ const baseUrl = this.config.pciBaseUrl ?? (typeof document !== 'undefined' ? document.baseURI : '');
272
+ const host = new PciHost(data, baseUrl);
273
+
274
+ // Wire response changes back into the player's declaration context
275
+ host.onResponseChange((responseId: string, value: unknown) => {
276
+ const d = this.decls[responseId];
277
+ if (d) {
278
+ d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, value);
279
+ }
280
+ });
281
+
282
+ this._pciHosts.set(data.responseIdentifier, host);
283
+ return host;
284
+ }
285
+
286
+ /**
287
+ * Push a response value into the PCI identified by responseIdentifier.
288
+ * Called from setResponses() so session restore reaches PCI modules.
289
+ */
290
+ public setPciResponse(responseIdentifier: string, value: unknown): void {
291
+ this._pciHosts.get(responseIdentifier)?.setResponse(value);
292
+ }
293
+
294
+ /**
295
+ * Disable/enable all PCI hosts based on role.
296
+ * 'candidate' = enabled; any other role = disabled.
297
+ */
298
+ public syncPciDisabledState(): void {
299
+ const disabled = this.role !== 'candidate';
300
+ for (const host of this._pciHosts.values()) {
301
+ if (disabled) host.disable(); else host.enable();
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Destroy all PCI hosts. Call on player teardown.
307
+ */
308
+ public destroyPciHosts(): void {
309
+ for (const host of this._pciHosts.values()) {
310
+ host.destroy();
311
+ }
312
+ this._pciHosts.clear();
313
+ }
314
+
177
315
  /** Breaking-change API: returns the typed declaration map */
178
316
  public getDeclarations(): DeclarationMap {
179
317
  return this.decls;
@@ -184,9 +322,19 @@ export class Player {
184
322
  const d = this.decls[id];
185
323
  if (!d) continue;
186
324
  d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, raw);
325
+ // Push restored responses into any mounted PCI modules
326
+ this.setPciResponse(id, raw);
187
327
  }
188
328
  }
189
329
 
330
+ /**
331
+ * Destroy all resources owned by this player instance (PCI modules, etc.).
332
+ * Call when unmounting to prevent memory leaks.
333
+ */
334
+ public destroy(): void {
335
+ this.destroyPciHosts();
336
+ }
337
+
190
338
  public processResponses(): ScoringResult {
191
339
  // Spec-aligned behavior: each processing run starts from outcome defaults.
192
340
  // This prevents stale outcomes when response/outcome processing doesn't set every variable.
@@ -206,10 +354,21 @@ export class Player {
206
354
  }
207
355
  }
208
356
 
357
+
209
358
  // Execute outcome processing if present (runs after responseProcessing)
210
359
  this.execOutcomeProcessingProgram();
211
360
 
361
+ // For non-adaptive items, update completionStatus and numAttempts after processing
362
+ if (!this.isAdaptive()) {
363
+ // Set completionStatus to 'completed' for non-adaptive items (single submission)
364
+ this.ctx.setValue('completionStatus', qtiValue('identifier', 'single', 'completed'));
365
+ // Increment numAttempts for non-adaptive items (tracks total submissions, including retries)
366
+ const currentAttempts = this.getNumAttempts();
367
+ this.ctx.setValue('numAttempts', qtiValue('integer', 'single', currentAttempts + 1));
368
+ }
369
+
212
370
  const outcomes = this.collectOutcomes();
371
+
213
372
  const score = Number(outcomes.SCORE ?? 0);
214
373
  const maxScore = Number(outcomes.MAXSCORE ?? 1);
215
374
  const completionStatus = (outcomes.completionStatus as CompletionStatus | undefined) ?? 'not_attempted';
@@ -240,6 +399,24 @@ export class Player {
240
399
  return this.i18nProvider;
241
400
  }
242
401
 
402
+ /**
403
+ * Get attribute value with QTI version support.
404
+ * Tries the attribute mapper's native form first, then falls back to direct lookup.
405
+ * @param el - Element to get attribute from
406
+ * @param canonicalName - Canonical (lowercase) attribute name
407
+ * @returns Attribute value or null
408
+ */
409
+ private getAttrMapped(el: Element, canonicalName: string): string | null {
410
+ // Try mapped attribute name first (e.g., 'mapkey' -> 'map-key' for QTI 3.0)
411
+ if (this.config.attributeNameMapper) {
412
+ const nativeName = this.config.attributeNameMapper.toNative(canonicalName);
413
+ const value = el.getAttribute(nativeName);
414
+ if (value !== null) return value;
415
+ }
416
+ // Fallback to canonical name (for QTI 2.x compatibility)
417
+ return getAttr(el, canonicalName);
418
+ }
419
+
243
420
  /**
244
421
  * Create a simple fallback i18n provider when none is provided
245
422
  * This avoids a hard dependency on @pie-qti/i18n
@@ -263,11 +440,19 @@ export class Player {
263
440
  */
264
441
  private detectQTIVersion(): string {
265
442
  const ns = (this.assessmentItem as any).namespaceURI;
443
+ if (ns?.includes('v3p0') || ns?.includes('imsqtiasi_v3p0')) return '3.0';
266
444
  if (ns?.includes('v2p2') || ns?.includes('imsqti_v2p2')) return '2.2';
267
445
  if (ns?.includes('v2p1') || ns?.includes('imsqti_v2p1')) return '2.1';
268
446
  if (ns?.includes('v2p0') || ns?.includes('imsqti_v2p0')) return '2.0';
269
447
 
448
+ // Check element name for QTI 3.0
449
+ const localName = (this.assessmentItem as any).localName || (this.assessmentItem as any).tagName;
450
+ if (localName === 'qti-assessment-item' || localName === 'qti-assessment-test') {
451
+ return '3.0';
452
+ }
453
+
270
454
  const versionAttr = getAttr(this.assessmentItem, 'version');
455
+ if (versionAttr?.startsWith('3.')) return '3.0';
271
456
  if (versionAttr === '2.0') return '2.0';
272
457
  if (versionAttr === '2.1') return '2.1';
273
458
  if (versionAttr === '2.2') return '2.2';
@@ -368,7 +553,9 @@ export class Player {
368
553
  enforceItemXmlLimits(this.itemXml, this.config.security);
369
554
  const docRoot = parse(this.itemXml, { lowerCaseTagName: false, comment: false }) as any as QTIElement;
370
555
  // node-html-parser's CSS selectors match lowercase tag names.
371
- const parsedItemBody = (docRoot.querySelector?.('itembody') as any as QTIElement | null) ?? null;
556
+ // Search for itemBody in the native form for this QTI version (itembody for 2.x, qti-item-body for 3.0)
557
+ const itemBodyTag = this.mapper.toNative('itembody').toLowerCase();
558
+ const parsedItemBody = (docRoot.querySelector?.(itemBodyTag) as any as QTIElement | null) ?? null;
372
559
  const root = parsedItemBody ?? docRoot;
373
560
 
374
561
  const declMap = new Map<string, ExtractionVariableDeclaration>();
@@ -380,10 +567,18 @@ export class Player {
380
567
  });
381
568
  }
382
569
 
383
- // Discover all elements that match any standard extractor elementType
570
+ // Discover all elements that match any standard extractor elementType.
571
+ // Extractors specify element types in QTI 2.x form (e.g., 'choiceInteraction').
572
+ // We use the mapper to convert to the appropriate form for this QTI version
573
+ // (e.g., 'choiceInteraction' for QTI 2.x, 'qti-choice-interaction' for QTI 3.0).
384
574
  const tagSet = new Set<string>();
385
575
  for (const ex of ALL_STANDARD_EXTRACTORS) {
386
- for (const t of ex.elementTypes ?? []) tagSet.add(t.toLowerCase());
576
+ for (const t of ex.elementTypes ?? []) {
577
+ // Convert to canonical form (lowercase), then to native form using mapper
578
+ const canonical = t.toLowerCase();
579
+ const native = this.mapper.toNative(canonical);
580
+ tagSet.add(native.toLowerCase());
581
+ }
387
582
  }
388
583
 
389
584
  const elements: QTIElement[] = [];
@@ -397,15 +592,27 @@ export class Player {
397
592
 
398
593
  const interactions: InteractionData[] = [];
399
594
  for (const el of elements) {
400
- const responseId = el.getAttribute?.('responseIdentifier') || el.getAttribute?.('responseidentifier') || '';
595
+ // Try both QTI 2.x (responseIdentifier) and QTI 3.0 (response-identifier) attribute names
596
+ const responseId = el.getAttribute?.('responseIdentifier') ||
597
+ el.getAttribute?.('response-identifier') ||
598
+ el.getAttribute?.('responseidentifier') ||
599
+ '';
401
600
  if (!responseId) continue;
402
601
 
403
602
  const ctx = createExtractionContext(el, responseId, root, declMap, this.config);
404
603
  const res = this.extractionRegistry.extract<any>(el, ctx);
405
604
  if (!res.success) continue;
406
605
 
606
+ // Normalize raw tag to QTI 2.x camelCase for ComponentRegistry compatibility.
607
+ // QTI 3.0 elements use kebab-case with 'qti-' prefix:
608
+ // 'qti-choice-interaction' → 'choiceInteraction'
609
+ const rawTag = el.rawTagName;
610
+ const normalizedType = rawTag.startsWith('qti-')
611
+ ? rawTag.slice(4).replace(/-([a-z])/g, (_: string, c: string) => c.toUpperCase())
612
+ : rawTag;
613
+
407
614
  interactions.push({
408
- type: el.rawTagName as any,
615
+ type: normalizedType as any,
409
616
  responseId,
410
617
  ...res.data,
411
618
  });
@@ -476,6 +683,16 @@ export class Player {
476
683
  return this.getInteractions().filter((i) => i.type !== 'endAttemptInteraction');
477
684
  }
478
685
 
686
+ /**
687
+ * Returns response identifiers of endAttempt interactions with countAttempt="false".
688
+ * Used to detect hint-only submissions (e.g. Request Hint button).
689
+ */
690
+ public getHintEndAttemptIdentifiers(): string[] {
691
+ return this.getInteractions()
692
+ .filter((i: any) => i.type === 'endAttemptInteraction' && i.countAttempt === false)
693
+ .map((i: any) => i.responseIdentifier);
694
+ }
695
+
479
696
  public getResponseIdentifiers(): string[] {
480
697
  return this.getResponseInteractions().map((i) => i.responseIdentifier);
481
698
  }
@@ -581,8 +798,8 @@ export class Player {
581
798
  }
582
799
  }
583
800
 
584
- public getSessionState(): SessionState {
585
- const out: SessionState = {};
801
+ public getSessionState(): ItemSessionState {
802
+ const out: ItemSessionState = {};
586
803
  for (const d of Object.values(this.decls)) {
587
804
  out[d.identifier] = d.value.kind === 'value' ? d.value.value : null;
588
805
  }
@@ -608,8 +825,40 @@ export class Player {
608
825
  const minPlays = Number(i.minPlays || 0);
609
826
  complete = Number(value || 0) >= minPlays;
610
827
  } else if (required) {
611
- if (Array.isArray(value)) complete = value.length > 0;
612
- else complete = value !== null && value !== undefined && value !== '';
828
+ if (Array.isArray(value)) {
829
+ complete = value.length > 0;
830
+ // Enforce minChoices / minAssociations where applicable
831
+ const minChoices = Number(i.minChoices || i.minAssociations || 0);
832
+ if (complete && minChoices > 0) {
833
+ complete = value.length >= minChoices;
834
+ }
835
+ // Enforce matchMin per-choice: each pairing entry "id1 id2" in value must
836
+ // appear at least matchMin times for the relevant choice.
837
+ // Collect all choice arrays that can carry matchMin across all pairing interaction types.
838
+ const choices: Array<{ identifier: string; matchMin?: number }> = [
839
+ ...(i.choices ?? []),
840
+ ...(i.gapTexts ?? []),
841
+ ...(i.gapImages ?? []),
842
+ ...(i.sourceSet ?? []),
843
+ ...(i.targetSet ?? []),
844
+ ...(i.associableHotspots ?? []),
845
+ ];
846
+ for (const choice of choices) {
847
+ const min = Number(choice.matchMin || 0);
848
+ if (min > 0) {
849
+ const count = (value as string[]).filter((p) => {
850
+ const parts = p.split(' ');
851
+ return parts[0] === choice.identifier || parts[1] === choice.identifier;
852
+ }).length;
853
+ if (count < min) {
854
+ complete = false;
855
+ break;
856
+ }
857
+ }
858
+ }
859
+ } else {
860
+ complete = value !== null && value !== undefined && value !== '';
861
+ }
613
862
  }
614
863
 
615
864
  const errors: string[] = [];
@@ -731,7 +980,7 @@ export class Player {
731
980
  }
732
981
 
733
982
  private execResponseProcessingTemplate(templateUrl: string): void {
734
- const name = templateUrl.split('/').pop()?.toLowerCase();
983
+ const name = templateUrl.split('/').pop()?.toLowerCase().replace(/\.xml$/, '');
735
984
  if (!name) {
736
985
  console.warn(`[QTI Player] Could not extract template name from URL: ${templateUrl}`);
737
986
  return;
@@ -820,9 +1069,9 @@ export class Player {
820
1069
  const decls: DeclarationMap = {};
821
1070
 
822
1071
  const addDecl = (kind: DeclKind, el: Element) => {
823
- const identifier = getAttr(el, 'identifier');
824
- const cardinality = (getAttr(el, 'cardinality') || 'single') as Cardinality;
825
- const baseType = (getAttr(el, 'baseType') || 'string') as BaseType;
1072
+ const identifier = this.getAttrMapped(el, 'identifier');
1073
+ const cardinality = (this.getAttrMapped(el, 'cardinality') || 'single') as Cardinality;
1074
+ const baseType = (this.getAttrMapped(el, 'baseType') || 'string') as BaseType;
826
1075
  if (!identifier) return;
827
1076
 
828
1077
  const defaultValue = this.parseDefaultValue(el, baseType, cardinality);
@@ -840,7 +1089,7 @@ export class Player {
840
1089
  // Response + outcome declarations may define mappings used by mapResponse/mapOutcome.
841
1090
  // (Templates do not participate in mapping.)
842
1091
  if (kind === 'response' || kind === 'outcome') {
843
- const mappingEl = findFirstDescendant(el, 'mapping');
1092
+ const mappingEl = findFirstDescendant(el, this.mapper.toNative('mapping'));
844
1093
  if (mappingEl) {
845
1094
  decls[identifier].mapping = this.parseMapping(mappingEl, baseType);
846
1095
  }
@@ -849,8 +1098,8 @@ export class Player {
849
1098
  // Outcome declarations may define a lookup table (matchTable or interpolationTable)
850
1099
  // used by the lookupOutcomeValue rule.
851
1100
  if (kind === 'outcome') {
852
- const matchTableEl = findFirstDescendant(el, 'matchTable');
853
- const interpolationTableEl = findFirstDescendant(el, 'interpolationTable');
1101
+ const matchTableEl = findFirstDescendant(el, this.mapper.toNative('matchtable'));
1102
+ const interpolationTableEl = findFirstDescendant(el, this.mapper.toNative('interpolationtable'));
854
1103
  if (matchTableEl) {
855
1104
  decls[identifier].lookupTable = this.parseMatchTable(matchTableEl);
856
1105
  } else if (interpolationTableEl) {
@@ -859,11 +1108,11 @@ export class Player {
859
1108
  }
860
1109
 
861
1110
  if (kind === 'response') {
862
- const correctEl = findFirstDescendant(el, 'correctResponse');
1111
+ const correctEl = findFirstDescendant(el, this.mapper.toNative('correctresponse'));
863
1112
  if (correctEl) {
864
1113
  decls[identifier].correctResponse = this.parseCorrectResponse(correctEl, baseType, cardinality);
865
1114
  }
866
- const areaMappingEl = findFirstDescendant(el, 'areaMapping');
1115
+ const areaMappingEl = findFirstDescendant(el, this.mapper.toNative('areamapping'));
867
1116
  if (areaMappingEl) {
868
1117
  decls[identifier].areaMapping = this.parseAreaMapping(areaMappingEl);
869
1118
  }
@@ -883,7 +1132,7 @@ export class Player {
883
1132
  return {
884
1133
  kind: 'table.matchTable' as const,
885
1134
  defaultValue: Number.isFinite(defaultValue as any) ? defaultValue : undefined,
886
- entries: findDescendants(el, 'matchTableEntry').map((e) => ({
1135
+ entries: findDescendants(el, this.mapper.toNative('matchtableentry')).map((e) => ({
887
1136
  sourceValue: (getAttr(e, 'sourceValue') || '').trim(),
888
1137
  targetValue: (getAttr(e, 'targetValue') || '').trim(),
889
1138
  })),
@@ -898,7 +1147,7 @@ export class Player {
898
1147
  kind: 'table.interpolationTable' as const,
899
1148
  defaultValue: Number.isFinite(defaultValue as any) ? defaultValue : undefined,
900
1149
  interpolationMethod,
901
- entries: findDescendants(el, 'interpolationTableEntry')
1150
+ entries: findDescendants(el, this.mapper.toNative('interpolationtableentry'))
902
1151
  .map((e) => ({
903
1152
  sourceValue: Number((getAttr(e, 'sourceValue') || '').trim()),
904
1153
  targetValue: Number((getAttr(e, 'targetValue') || '').trim()),
@@ -959,7 +1208,7 @@ export class Player {
959
1208
  }
960
1209
  }
961
1210
 
962
- private applySessionState(state: SessionState): void {
1211
+ private applySessionState(state: ItemSessionState): void {
963
1212
  for (const [id, raw] of Object.entries(state)) {
964
1213
  const d = this.decls[id];
965
1214
  if (!d) continue;
@@ -968,9 +1217,9 @@ export class Player {
968
1217
  }
969
1218
 
970
1219
  private parseDefaultValue(declEl: Element, baseType: BaseType, cardinality: Cardinality): QtiValue {
971
- const defaultEl = findFirstDescendant(declEl, 'defaultValue');
1220
+ const defaultEl = findFirstDescendant(declEl, this.mapper.toNative('defaultvalue'));
972
1221
  if (!defaultEl) return qtiNull(baseType, cardinality);
973
- const values = findDescendants(defaultEl, 'value').map((v) => (v.textContent || '').trim());
1222
+ const values = findDescendants(defaultEl, this.mapper.toNative('value')).map((v) => (v.textContent || '').trim());
974
1223
  if (cardinality === 'multiple' || cardinality === 'ordered') {
975
1224
  return qtiValue(
976
1225
  baseType,
@@ -985,7 +1234,7 @@ export class Player {
985
1234
  }
986
1235
 
987
1236
  private parseCorrectResponse(correctEl: Element, baseType: BaseType, cardinality: Cardinality): QtiValue {
988
- const values = findDescendants(correctEl, 'value').map((v) => (v.textContent || '').trim());
1237
+ const values = findDescendants(correctEl, this.mapper.toNative('value')).map((v) => (v.textContent || '').trim());
989
1238
  if (cardinality === 'multiple' || cardinality === 'ordered') {
990
1239
  return qtiValue(
991
1240
  baseType,
@@ -1000,10 +1249,10 @@ export class Player {
1000
1249
  }
1001
1250
 
1002
1251
  private parseMapping(mappingEl: Element, baseType: BaseType) {
1003
- const defaultValue = Number(getAttr(mappingEl, 'defaultValue') || 0);
1004
- const lowerBound = getAttr(mappingEl, 'lowerBound') ? Number(getAttr(mappingEl, 'lowerBound')) : undefined;
1005
- const upperBound = getAttr(mappingEl, 'upperBound') ? Number(getAttr(mappingEl, 'upperBound')) : undefined;
1006
- const mappingCaseSensitive = getAttr(mappingEl, 'caseSensitive') || 'true';
1252
+ const defaultValue = Number(this.getAttrMapped(mappingEl, 'defaultValue') || 0);
1253
+ const lowerBound = this.getAttrMapped(mappingEl, 'lowerBound') ? Number(this.getAttrMapped(mappingEl, 'lowerBound')) : undefined;
1254
+ const upperBound = this.getAttrMapped(mappingEl, 'upperBound') ? Number(this.getAttrMapped(mappingEl, 'upperBound')) : undefined;
1255
+ const mappingCaseSensitive = this.getAttrMapped(mappingEl, 'caseSensitive') || 'true';
1007
1256
  const entries: Record<string, any> = {};
1008
1257
 
1009
1258
  const normalizePairKey = (k: string): string => {
@@ -1018,11 +1267,11 @@ export class Player {
1018
1267
  return k.trim();
1019
1268
  };
1020
1269
 
1021
- for (const e of findDescendants(mappingEl, 'mapEntry')) {
1022
- const mapKey = getAttr(e, 'mapKey');
1023
- const mappedValue = getAttr(e, 'mappedValue');
1270
+ for (const e of findDescendants(mappingEl, this.mapper.toNative('mapentry'))) {
1271
+ const mapKey = this.getAttrMapped(e, 'mapKey');
1272
+ const mappedValue = this.getAttrMapped(e, 'mappedValue');
1024
1273
  if (!mapKey || mappedValue === null) continue;
1025
- const effectiveCaseSensitive = getAttr(e, 'caseSensitive') || mappingCaseSensitive || 'true';
1274
+ const effectiveCaseSensitive = this.getAttrMapped(e, 'caseSensitive') || mappingCaseSensitive || 'true';
1026
1275
  const storedKey =
1027
1276
  baseType === 'pair'
1028
1277
  ? normalizePairKey(mapKey)
@@ -1053,7 +1302,7 @@ export class Player {
1053
1302
  : undefined;
1054
1303
 
1055
1304
  const entries: AreaMapEntry[] = [];
1056
- for (const e of findDescendants(areaMappingEl, 'areaMapEntry')) {
1305
+ for (const e of findDescendants(areaMappingEl, this.mapper.toNative('areamapentry'))) {
1057
1306
  const shape = (getAttr(e, 'shape') || 'default') as AreaMapEntry['shape'];
1058
1307
  const coords = String(getAttr(e, 'coords') || '');
1059
1308
  const mappedValue = Number(getAttr(e, 'mappedValue') || 0);
@@ -1071,6 +1320,17 @@ export class Player {
1071
1320
  return raw as QtiValue;
1072
1321
  }
1073
1322
 
1323
+ // For file types, preserve QTIFileResponse objects directly
1324
+ if (baseType === 'file') {
1325
+ if (cardinality === 'multiple' || cardinality === 'ordered') {
1326
+ const arr = Array.isArray(raw) ? raw : [raw];
1327
+ // For file types, preserve objects (QTIFileResponse) directly
1328
+ return qtiValue(baseType, cardinality, arr.filter((v) => v !== null && v !== undefined));
1329
+ }
1330
+ // For single file, preserve the object directly
1331
+ return qtiValue(baseType, cardinality, raw);
1332
+ }
1333
+
1074
1334
  if (cardinality === 'multiple' || cardinality === 'ordered') {
1075
1335
  const arr = Array.isArray(raw) ? raw : [raw];
1076
1336
  const coerced = arr
@@ -1097,6 +1357,10 @@ export class Player {
1097
1357
  if (d.value.kind === 'value') out[d.identifier] = d.value.value;
1098
1358
  else if (d.value.kind === 'null') out[d.identifier] = null;
1099
1359
  }
1360
+ // Ensure MAXSCORE always has a value (fallback to 1.0 if null or missing)
1361
+ if (out.MAXSCORE === null || out.MAXSCORE === undefined) {
1362
+ out.MAXSCORE = 1.0;
1363
+ }
1100
1364
  return out;
1101
1365
  }
1102
1366
 
@@ -1149,4 +1413,14 @@ export class Player {
1149
1413
  }
1150
1414
  }
1151
1415
 
1416
+ // ---------------------------------------------------------------------------
1417
+ // Module-level helpers
1418
+ // ---------------------------------------------------------------------------
1152
1419
 
1420
+ function mergePnp(base: PnpProfile | undefined, partial: Partial<PnpProfile>): PnpProfile {
1421
+ return {
1422
+ display: { ...(base?.display ?? {}), ...(partial.display ?? {}) },
1423
+ content: { ...(base?.content ?? {}), ...(partial.content ?? {}) },
1424
+ cognitive: { ...(base?.cognitive ?? {}), ...(partial.cognitive ?? {}) },
1425
+ };
1426
+ }
@@ -18,7 +18,7 @@ const DEFAULTS: Omit<NormalizedParsingLimits, 'enabled'> = {
18
18
  };
19
19
 
20
20
  function getByteLengthUtf8(s: string): number {
21
- // TextEncoder is available in modern runtimes (browser + Bun/node 18+).
21
+ // TextEncoder is available in modern runtimes (browser + Bun/node 20+).
22
22
  // Fall back to a conservative approximation if unavailable.
23
23
  const TE: typeof TextEncoder | undefined = (globalThis as any).TextEncoder;
24
24
  if (!TE) return s.length * 2;
@@ -0,0 +1,34 @@
1
+ import type { QTIRole } from '../types/index.js';
2
+
3
+ /**
4
+ * Product policy layered on top of QTI role/view semantics.
5
+ *
6
+ * QTI defines these roles as audience markers for view-controlled content
7
+ * (for example rubric/outcome visibility). It does not define a universal
8
+ * interaction UI behavior matrix. The player policy below keeps runtime
9
+ * behavior explicit and consistent across integrations.
10
+ */
11
+ export interface RoleCapabilities {
12
+ isCandidate: boolean;
13
+ isReadOnly: boolean;
14
+ canViewCorrectResponses: boolean;
15
+ }
16
+
17
+ const ROLES_WITH_CORRECT_RESPONSE_ACCESS: ReadonlySet<QTIRole> = new Set([
18
+ 'scorer',
19
+ 'author',
20
+ 'tutor',
21
+ 'testConstructor',
22
+ ]);
23
+
24
+ export function getRoleCapabilities(role: QTIRole): RoleCapabilities {
25
+ const isCandidate = role === 'candidate';
26
+ const canViewCorrectResponses = ROLES_WITH_CORRECT_RESPONSE_ACCESS.has(role);
27
+
28
+ return {
29
+ isCandidate,
30
+ isReadOnly: !isCandidate,
31
+ canViewCorrectResponses,
32
+ };
33
+ }
34
+
@@ -62,14 +62,17 @@ export function sanitizeResourceUrl(raw: string, policy?: UrlPolicyConfig, kind:
62
62
  if (s.startsWith('//')) return p.allowProtocolRelative ? `https:${s}` : null;
63
63
 
64
64
  // Relative/absolute-path URLs: allow and optionally resolve.
65
- if (s.startsWith('/') || s.startsWith('./') || s.startsWith('../')) {
65
+ // Bare relative paths (e.g. "images/foo.png" from IMS CP manifests) are treated
66
+ // the same as "./" paths — they have no scheme and are safe to pass through.
67
+ if (s.startsWith('/') || s.startsWith('./') || s.startsWith('../') || !/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(s)) {
66
68
  if (p.assetBaseUrl) {
67
69
  try {
68
70
  // Strip leading '/' to make URL constructor resolve relative to base path, not origin
69
71
  const relativePath = s.startsWith('/') ? s.slice(1) : s;
70
72
  return new URL(relativePath, p.assetBaseUrl).toString();
71
73
  } catch {
72
- return null;
74
+ // assetBaseUrl resolution failed; return the raw relative path as-is
75
+ return s;
73
76
  }
74
77
  }
75
78
  return s;