@pie-qti/item-player 1.0.0-beta.3 → 1.0.0-beta.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 (300) hide show
  1. package/README.md +33 -5
  2. package/dist/catalog/applyGlossaryTriggers.js +14 -2
  3. package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
  4. package/dist/catalog/catalogExtractor.js +2 -4
  5. package/dist/catalog/catalogExtractor.js.map +1 -1
  6. package/dist/catalog/sessionCatalog.d.ts +46 -0
  7. package/dist/catalog/sessionCatalog.js +87 -0
  8. package/dist/catalog/sessionCatalog.js.map +1 -0
  9. package/dist/components/utils/endAttempt.d.ts +16 -0
  10. package/dist/components/utils/endAttempt.js +28 -0
  11. package/dist/components/utils/endAttempt.js.map +1 -0
  12. package/dist/components/utils/focus.d.ts +19 -0
  13. package/dist/components/utils/focus.js +67 -0
  14. package/dist/components/utils/focus.js.map +1 -0
  15. package/dist/components/utils/itemBodyRenderer.d.ts +44 -0
  16. package/dist/components/utils/itemBodyRenderer.js +177 -0
  17. package/dist/components/utils/itemBodyRenderer.js.map +1 -0
  18. package/dist/components/utils/sentenceContext.d.ts +6 -0
  19. package/dist/components/utils/sentenceContext.js +16 -0
  20. package/dist/components/utils/sentenceContext.js.map +1 -0
  21. package/dist/core/AssessmentItemDefinition.d.ts +20 -1
  22. package/dist/core/AssessmentItemDefinition.js +12 -31
  23. package/dist/core/AssessmentItemDefinition.js.map +1 -1
  24. package/dist/core/ComponentRegistry.d.ts +92 -0
  25. package/dist/core/ComponentRegistry.js +7 -1
  26. package/dist/core/ComponentRegistry.js.map +1 -1
  27. package/dist/core/ItemSession.d.ts +18 -1
  28. package/dist/core/ItemSession.js +79 -41
  29. package/dist/core/ItemSession.js.map +1 -1
  30. package/dist/core/Player.d.ts +118 -141
  31. package/dist/core/Player.js +387 -1233
  32. package/dist/core/Player.js.map +1 -1
  33. package/dist/core/compliance.d.ts +72 -0
  34. package/dist/core/compliance.js +147 -0
  35. package/dist/core/compliance.js.map +1 -0
  36. package/dist/core/declarations/declarationBuilder.d.ts +29 -0
  37. package/dist/core/declarations/declarationBuilder.js +284 -0
  38. package/dist/core/declarations/declarationBuilder.js.map +1 -0
  39. package/dist/core/declarations/declarationValues.d.ts +11 -0
  40. package/dist/core/declarations/declarationValues.js +168 -0
  41. package/dist/core/declarations/declarationValues.js.map +1 -0
  42. package/dist/core/matchGroups.d.ts +36 -0
  43. package/dist/core/matchGroups.js +100 -0
  44. package/dist/core/matchGroups.js.map +1 -0
  45. package/dist/core/nameMappers.d.ts +35 -0
  46. package/dist/core/nameMappers.js +47 -0
  47. package/dist/core/nameMappers.js.map +1 -0
  48. package/dist/core/parsingLimits.d.ts +4 -0
  49. package/dist/core/parsingLimits.js +5 -2
  50. package/dist/core/parsingLimits.js.map +1 -1
  51. package/dist/core/processing/responseProcessing.d.ts +88 -0
  52. package/dist/core/processing/responseProcessing.js +317 -0
  53. package/dist/core/processing/responseProcessing.js.map +1 -0
  54. package/dist/core/processing/responseValidation.d.ts +55 -0
  55. package/dist/core/processing/responseValidation.js +335 -0
  56. package/dist/core/processing/responseValidation.js.map +1 -0
  57. package/dist/core/rendering/contentPass.d.ts +31 -0
  58. package/dist/core/rendering/contentPass.js +152 -0
  59. package/dist/core/rendering/contentPass.js.map +1 -0
  60. package/dist/core/rendering/htmlRender.d.ts +21 -0
  61. package/dist/core/rendering/htmlRender.js +56 -0
  62. package/dist/core/rendering/htmlRender.js.map +1 -0
  63. package/dist/core/responseProcessingTemplates.d.ts +23 -0
  64. package/dist/core/responseProcessingTemplates.js +45 -0
  65. package/dist/core/responseProcessingTemplates.js.map +1 -0
  66. package/dist/core/rolePolicy.d.ts +5 -0
  67. package/dist/core/rolePolicy.js +21 -0
  68. package/dist/core/rolePolicy.js.map +1 -1
  69. package/dist/core/sanitizer.js +8 -14
  70. package/dist/core/sanitizer.js.map +1 -1
  71. package/dist/core/serialization/sessionState.d.ts +56 -0
  72. package/dist/core/serialization/sessionState.js +139 -0
  73. package/dist/core/serialization/sessionState.js.map +1 -0
  74. package/dist/core/serialization/valueForms.d.ts +32 -0
  75. package/dist/core/serialization/valueForms.js +112 -0
  76. package/dist/core/serialization/valueForms.js.map +1 -0
  77. package/dist/document/AssessmentItemDocument.d.ts +27 -1
  78. package/dist/document/AssessmentItemDocument.js +67 -31
  79. package/dist/document/AssessmentItemDocument.js.map +1 -1
  80. package/dist/element-class-BbF4Dj7F.js +3773 -0
  81. package/dist/element-class-BbF4Dj7F.js.map +1 -0
  82. package/dist/element-class.d.ts +34 -1
  83. package/dist/element-class.js +1 -1
  84. package/dist/element.js +1 -1
  85. package/dist/extraction/ExtractionRegistry.js +6 -12
  86. package/dist/extraction/ExtractionRegistry.js.map +1 -1
  87. package/dist/extraction/createContext.d.ts +2 -2
  88. package/dist/extraction/createContext.js.map +1 -1
  89. package/dist/extraction/index.d.ts +2 -2
  90. package/dist/extraction/index.js +1 -1
  91. package/dist/extraction/index.js.map +1 -1
  92. package/dist/extraction/interactionCoverage.d.ts +31 -0
  93. package/dist/extraction/interactionCoverage.js +40 -0
  94. package/dist/extraction/interactionCoverage.js.map +1 -0
  95. package/dist/extraction/interactionExtractionPipeline.js +5 -10
  96. package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
  97. package/dist/extraction/interactionSecurity.js +1 -28
  98. package/dist/extraction/interactionSecurity.js.map +1 -1
  99. package/dist/extraction/mergeDeliveryFields.d.ts +13 -0
  100. package/dist/extraction/mergeDeliveryFields.js +17 -0
  101. package/dist/extraction/mergeDeliveryFields.js.map +1 -0
  102. package/dist/extraction/responseIdentifier.d.ts +19 -0
  103. package/dist/extraction/responseIdentifier.js +29 -0
  104. package/dist/extraction/responseIdentifier.js.map +1 -0
  105. package/dist/extraction/types.d.ts +11 -18
  106. package/dist/extraction/types.js +0 -12
  107. package/dist/extraction/types.js.map +1 -1
  108. package/dist/extraction/utils.d.ts +14 -0
  109. package/dist/extraction/utils.js +35 -5
  110. package/dist/extraction/utils.js.map +1 -1
  111. package/dist/index.d.ts +16 -10
  112. package/dist/index.js +19 -8
  113. package/dist/index.js.map +1 -1
  114. package/dist/interactions/associate/extractor.d.ts +1 -0
  115. package/dist/interactions/associate/extractor.js +10 -12
  116. package/dist/interactions/associate/extractor.js.map +1 -1
  117. package/dist/interactions/choice/extractor.js +6 -13
  118. package/dist/interactions/choice/extractor.js.map +1 -1
  119. package/dist/interactions/drawing/extractor.d.ts +6 -0
  120. package/dist/interactions/drawing/extractor.js +30 -9
  121. package/dist/interactions/drawing/extractor.js.map +1 -1
  122. package/dist/interactions/end-attempt/extractor.js +2 -1
  123. package/dist/interactions/end-attempt/extractor.js.map +1 -1
  124. package/dist/interactions/extended-text/extractor.d.ts +6 -1
  125. package/dist/interactions/extended-text/extractor.js +10 -5
  126. package/dist/interactions/extended-text/extractor.js.map +1 -1
  127. package/dist/interactions/extended-text/response.js +18 -18
  128. package/dist/interactions/extended-text/response.js.map +1 -1
  129. package/dist/interactions/gap-match/extractor.d.ts +40 -2
  130. package/dist/interactions/gap-match/extractor.js +197 -39
  131. package/dist/interactions/gap-match/extractor.js.map +1 -1
  132. package/dist/interactions/graphic-associate/extractor.d.ts +11 -0
  133. package/dist/interactions/graphic-associate/extractor.js +35 -24
  134. package/dist/interactions/graphic-associate/extractor.js.map +1 -1
  135. package/dist/interactions/graphic-gap-match/extractor.d.ts +21 -0
  136. package/dist/interactions/graphic-gap-match/extractor.js +79 -43
  137. package/dist/interactions/graphic-gap-match/extractor.js.map +1 -1
  138. package/dist/interactions/graphic-order/extractor.d.ts +15 -0
  139. package/dist/interactions/graphic-order/extractor.js +39 -24
  140. package/dist/interactions/graphic-order/extractor.js.map +1 -1
  141. package/dist/interactions/hotspot/extractor.d.ts +6 -0
  142. package/dist/interactions/hotspot/extractor.js +31 -16
  143. package/dist/interactions/hotspot/extractor.js.map +1 -1
  144. package/dist/interactions/hottext/extractor.js +2 -12
  145. package/dist/interactions/hottext/extractor.js.map +1 -1
  146. package/dist/interactions/inline/accessibleName.d.ts +29 -0
  147. package/dist/interactions/inline/accessibleName.js +35 -0
  148. package/dist/interactions/inline/accessibleName.js.map +1 -0
  149. package/dist/interactions/inline/render-plan.d.ts +5 -14
  150. package/dist/interactions/inline/render-plan.js +5 -56
  151. package/dist/interactions/inline/render-plan.js.map +1 -1
  152. package/dist/interactions/inline-choice/extractor.d.ts +4 -0
  153. package/dist/interactions/inline-choice/extractor.js +13 -12
  154. package/dist/interactions/inline-choice/extractor.js.map +1 -1
  155. package/dist/interactions/match/extractor.d.ts +2 -0
  156. package/dist/interactions/match/extractor.js +14 -28
  157. package/dist/interactions/match/extractor.js.map +1 -1
  158. package/dist/interactions/media/extractor.d.ts +5 -11
  159. package/dist/interactions/media/extractor.js +100 -36
  160. package/dist/interactions/media/extractor.js.map +1 -1
  161. package/dist/interactions/modules.js +8 -2
  162. package/dist/interactions/modules.js.map +1 -1
  163. package/dist/interactions/order/extractor.d.ts +2 -0
  164. package/dist/interactions/order/extractor.js +8 -12
  165. package/dist/interactions/order/extractor.js.map +1 -1
  166. package/dist/interactions/order/limits.d.ts +29 -0
  167. package/dist/interactions/order/limits.js +28 -0
  168. package/dist/interactions/order/limits.js.map +1 -0
  169. package/dist/interactions/portable-custom/extractor.js +4 -2
  170. package/dist/interactions/portable-custom/extractor.js.map +1 -1
  171. package/dist/interactions/position-object/extractor.d.ts +18 -1
  172. package/dist/interactions/position-object/extractor.js +81 -22
  173. package/dist/interactions/position-object/extractor.js.map +1 -1
  174. package/dist/interactions/select-point/extractor.d.ts +6 -0
  175. package/dist/interactions/select-point/extractor.js +31 -19
  176. package/dist/interactions/select-point/extractor.js.map +1 -1
  177. package/dist/interactions/shared/imageAlt.d.ts +54 -0
  178. package/dist/interactions/shared/imageAlt.js +84 -0
  179. package/dist/interactions/shared/imageAlt.js.map +1 -0
  180. package/dist/interactions/shared/interactionImage.d.ts +32 -0
  181. package/dist/interactions/shared/interactionImage.js +39 -0
  182. package/dist/interactions/shared/interactionImage.js.map +1 -0
  183. package/dist/interactions/shared/specDefaults.d.ts +20 -0
  184. package/dist/interactions/shared/specDefaults.js +25 -0
  185. package/dist/interactions/shared/specDefaults.js.map +1 -0
  186. package/dist/interactions/shared/types.d.ts +212 -40
  187. package/dist/interactions/shared/types.js.map +1 -1
  188. package/dist/interactions/text-entry/extractor.d.ts +9 -0
  189. package/dist/interactions/text-entry/extractor.js +9 -0
  190. package/dist/interactions/text-entry/extractor.js.map +1 -1
  191. package/dist/interactions/text-entry/inlineInputStyle.d.ts +10 -0
  192. package/dist/interactions/text-entry/inlineInputStyle.js +12 -0
  193. package/dist/interactions/text-entry/inlineInputStyle.js.map +1 -0
  194. package/dist/interactions/text-entry/inputMode.d.ts +35 -0
  195. package/dist/interactions/text-entry/inputMode.js +134 -0
  196. package/dist/interactions/text-entry/inputMode.js.map +1 -0
  197. package/dist/interactions/text-entry/response.d.ts +15 -0
  198. package/dist/interactions/text-entry/response.js +25 -0
  199. package/dist/interactions/text-entry/response.js.map +1 -0
  200. package/dist/interactions/upload/extractor.js +2 -2
  201. package/dist/interactions/upload/extractor.js.map +1 -1
  202. package/dist/pci/PciHost.d.ts +1 -1
  203. package/dist/pci/PciHost.js +11 -11
  204. package/dist/pci/PciHost.js.map +1 -1
  205. package/dist/pci/index.d.ts +1 -0
  206. package/dist/pci/index.js.map +1 -1
  207. package/dist/pci/modulePaths.d.ts +16 -0
  208. package/dist/pci/modulePaths.js +33 -0
  209. package/dist/pci/modulePaths.js.map +1 -0
  210. package/dist/pci/pageRealmSession.js +3 -15
  211. package/dist/pci/pageRealmSession.js.map +1 -1
  212. package/dist/pci/qtiVariableJson.d.ts +46 -3
  213. package/dist/pci/qtiVariableJson.js +247 -53
  214. package/dist/pci/qtiVariableJson.js.map +1 -1
  215. package/dist/pci/sandbox/SandboxedPciSession.d.ts +3 -0
  216. package/dist/pci/sandbox/SandboxedPciSession.js +15 -14
  217. package/dist/pci/sandbox/SandboxedPciSession.js.map +1 -1
  218. package/dist/pci/sandbox/iframeConnector.d.ts +18 -4
  219. package/dist/pci/sandbox/iframeConnector.js +35 -6
  220. package/dist/pci/sandbox/iframeConnector.js.map +1 -1
  221. package/dist/pci/sandbox/protocol.d.ts +14 -0
  222. package/dist/pci/sandbox/protocol.js.map +1 -1
  223. package/dist/pci/sessionHosts.d.ts +47 -0
  224. package/dist/pci/sessionHosts.js +66 -0
  225. package/dist/pci/sessionHosts.js.map +1 -0
  226. package/dist/pci/types.d.ts +7 -1
  227. package/dist/pci/types.js.map +1 -1
  228. package/dist/pnp/applyPnp.d.ts +20 -3
  229. package/dist/pnp/applyPnp.js +84 -9
  230. package/dist/pnp/applyPnp.js.map +1 -1
  231. package/dist/pnp/parsePnpXml.js +2 -0
  232. package/dist/pnp/parsePnpXml.js.map +1 -1
  233. package/dist/pnp/types.d.ts +16 -8
  234. package/dist/pnp/types.js.map +1 -1
  235. package/dist/presentation/feedbackAnnouncement.d.ts +56 -0
  236. package/dist/presentation/feedbackAnnouncement.js +150 -0
  237. package/dist/presentation/feedbackAnnouncement.js.map +1 -0
  238. package/dist/presentation/interactionSlots.d.ts +31 -0
  239. package/dist/presentation/interactionSlots.js +101 -0
  240. package/dist/presentation/interactionSlots.js.map +1 -0
  241. package/dist/presentation/itemPresentationPlan.d.ts +69 -6
  242. package/dist/presentation/itemPresentationPlan.js +93 -81
  243. package/dist/presentation/itemPresentationPlan.js.map +1 -1
  244. package/dist/{components/utils → presentation}/stimulusRender.js +3 -12
  245. package/dist/presentation/stimulusRender.js.map +1 -0
  246. package/dist/presentation/stylesheetRender.js.map +1 -0
  247. package/dist/security/escapeHtml.d.ts +15 -0
  248. package/dist/security/escapeHtml.js +22 -0
  249. package/dist/security/escapeHtml.js.map +1 -0
  250. package/dist/security/index.d.ts +1 -0
  251. package/dist/security/index.js +1 -0
  252. package/dist/security/index.js.map +1 -1
  253. package/dist/server.d.ts +8 -1
  254. package/dist/server.js.map +1 -1
  255. package/dist/session-inputs.d.ts +108 -0
  256. package/dist/session-inputs.js +130 -0
  257. package/dist/session-inputs.js.map +1 -0
  258. package/dist/types/index.d.ts +67 -35
  259. package/dist/types/index.js.map +1 -1
  260. package/dist/utils/cloneFreeze.d.ts +52 -0
  261. package/dist/utils/cloneFreeze.js +113 -0
  262. package/dist/utils/cloneFreeze.js.map +1 -0
  263. package/dist/utils/htmlAttributes.d.ts +13 -0
  264. package/dist/utils/htmlAttributes.js +22 -0
  265. package/dist/utils/htmlAttributes.js.map +1 -0
  266. package/dist/web-components/QTIInteractionElement.d.ts +0 -29
  267. package/dist/web-components/QTIInteractionElement.js +0 -32
  268. package/dist/web-components/QTIInteractionElement.js.map +1 -1
  269. package/dist/web-components/index.d.ts +1 -2
  270. package/dist/web-components/index.js +2 -3
  271. package/dist/web-components/index.js.map +1 -1
  272. package/package.json +15 -18
  273. package/dist/components/utils/feedbackUtils.d.ts +0 -77
  274. package/dist/components/utils/feedbackUtils.js +0 -138
  275. package/dist/components/utils/feedbackUtils.js.map +0 -1
  276. package/dist/components/utils/index.d.ts +0 -4
  277. package/dist/components/utils/index.js +0 -5
  278. package/dist/components/utils/index.js.map +0 -1
  279. package/dist/components/utils/stimulusRender.js.map +0 -1
  280. package/dist/components/utils/stylesheetRender.js.map +0 -1
  281. package/dist/core/constants.d.ts +0 -65
  282. package/dist/core/constants.js +0 -74
  283. package/dist/core/constants.js.map +0 -1
  284. package/dist/element-class-X2XXDa29.js +0 -9299
  285. package/dist/element-class-X2XXDa29.js.map +0 -1
  286. package/dist/extensions/MathLiveEditor.d.ts +0 -31
  287. package/dist/extensions/MathLiveEditor.js +0 -248
  288. package/dist/extensions/MathLiveEditor.js.map +0 -1
  289. package/dist/utils/PerformanceMonitor.d.ts +0 -169
  290. package/dist/utils/PerformanceMonitor.js +0 -243
  291. package/dist/utils/PerformanceMonitor.js.map +0 -1
  292. package/dist/utils/responseUtils.d.ts +0 -15
  293. package/dist/utils/responseUtils.js +0 -46
  294. package/dist/utils/responseUtils.js.map +0 -1
  295. package/dist/web-components/QTIInteractionBase.d.ts +0 -119
  296. package/dist/web-components/QTIInteractionBase.js +0 -244
  297. package/dist/web-components/QTIInteractionBase.js.map +0 -1
  298. /package/dist/{components/utils → presentation}/stimulusRender.d.ts +0 -0
  299. /package/dist/{components/utils → presentation}/stylesheetRender.d.ts +0 -0
  300. /package/dist/{components/utils → presentation}/stylesheetRender.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/graphic-associate/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAiCxE;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAA2C;IACxF,EAAE,EAAE,mCAAmC;IACvC,IAAI,EAAE,4CAA4C;IAClD,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,6BAA6B,CAAC;IAC7C,WAAW,EAAE,8EAA8E;IAE3F,SAAS,CAAC,OAAO,EAAE,OAAO;QACzB,wDAAwD;QACxD,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAE1B,yCAAyC;QACzC,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,IAAI,SAAS,GAAqB,IAAI,CAAC;QAEvC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,EAA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QTI graphicAssociateInteraction extractor\n *\n * Extracts data from graphicAssociateInteraction elements (associate items on image)\n */\n\nimport type { ElementExtractor } from '../../extraction/types.js';\nimport { normalizePixelDimension } from '../../security/styleValues.js';\n\n/**\n * Image data for graphic associate interaction\n */\nexport interface ImageData {\n\ttype: 'image' | 'svg';\n\tsrc?: string;\n\tcontent?: string;\n\twidth?: string;\n\theight?: string;\n}\n\n/**\n * Graphic associate data extracted from graphicAssociateInteraction elements\n */\nexport interface GraphicAssociateData {\n\timageData: ImageData | null;\n\tassociableHotspots: Array<{\n\t\tidentifier: string;\n\t\tlabel: string;\n\t\tshape: string;\n\t\tcoords: string;\n\t\tmatchMax: number;\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\tclasses?: string[];\n\t}>;\n\tmaxAssociations: number;\n\tminAssociations: number;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI graphic associate interaction extractor\n * Handles graphicAssociateInteraction elements (creating associations between hotspots)\n */\nexport const standardGraphicAssociateExtractor: ElementExtractor<GraphicAssociateData> = {\n\tid: 'qti:graphic-associate-interaction',\n\tname: 'QTI Standard Graphic Associate Interaction',\n\tpriority: 10,\n\telementTypes: ['graphicAssociateInteraction'],\n\tdescription: 'Extracts standard QTI graphicAssociateInteraction (associate items on image)',\n\n\tcanHandle(element, context) {\n\t\t// All graphicAssociateInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'graphicAssociateInteraction');\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\n\t\t// Extract image data from object element\n\t\tconst objectElements = utils.getChildrenByTag(element, 'object');\n\t\tlet imageData: ImageData | null = null;\n\n\t\tif (objectElements.length > 0) {\n\t\t\tconst objectElement = objectElements[0];\n\t\t\tconst type = utils.getAttribute(objectElement, 'type', '');\n\t\t\tconst data = utils.getAttribute(objectElement, 'data', '');\n\t\t\tconst width = normalizePixelDimension(\n\t\t\t\tutils.getAttribute(objectElement, 'width', ''),\n\t\t\t\t'500',\n\t\t\t);\n\t\t\tconst height = normalizePixelDimension(\n\t\t\t\tutils.getAttribute(objectElement, 'height', ''),\n\t\t\t\t'300',\n\t\t\t);\n\n\t\t\tif (type.startsWith('image/svg')) {\n\t\t\t\t// Extract inline SVG content - get full content including <svg> tag\n\t\t\t\tconst content = utils.getHtmlContent(objectElement);\n\t\t\t\timageData = {\n\t\t\t\t\ttype: 'svg',\n\t\t\t\t\tcontent,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// External image reference\n\t\t\t\timageData = {\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tsrc: data,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Extract associableHotspot children\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');\n\t\tconst associableHotspots = hotspotElements.map((hotspot) => {\n\t\t\tconst classes = utils.getClasses(hotspot);\n\t\t\tconst identifier = utils.getAttribute(hotspot, 'identifier', '');\n\t\t\tconst shape = utils.getAttribute(hotspot, 'shape', 'rect');\n\t\t\tconst coords = utils.getAttribute(hotspot, 'coords', '0,0,50,50');\n\t\t\tconst matchMax = utils.getNumberAttribute(hotspot, 'matchMax', 1);\n\t\t\tconst matchMin = utils.getNumberAttribute(hotspot, 'matchMin', 0);\n\t\t\tconst matchGroupRaw = utils.getAttribute(hotspot, 'matchGroup', '');\n\t\t\tconst matchGroup = matchGroupRaw.split(/\\s+/).filter(Boolean);\n\n\t\t\t// Get text content as label, use identifier as fallback\n\t\t\tconst textContent = utils.getTextContent(hotspot).trim();\n\t\t\tconst label = textContent || identifier;\n\n\t\t\treturn {\n\t\t\t\tidentifier,\n\t\t\t\tlabel,\n\t\t\t\tshape,\n\t\t\t\tcoords,\n\t\t\t\tmatchMax,\n\t\t\t\t...(matchMin > 0 ? { matchMin } : {}),\n\t\t\t\t...(matchGroup.length > 0 ? { matchGroup } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract attributes with proper defaults\n\t\tconst maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 1);\n\t\tconst minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);\n\n\t\t// Extract prompt (optional)\n\t\tconst promptElements = utils.getChildrenByTag(element, 'prompt');\n\t\tconst prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;\n\n\t\treturn {\n\t\t\timageData,\n\t\t\tassociableHotspots,\n\t\t\tmaxAssociations,\n\t\t\tminAssociations,\n\t\t\tprompt,\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\t// Validate image data\n\t\tif (!data.imageData) {\n\t\t\twarnings.push('graphicAssociateInteraction has no image data');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('graphicAssociateInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('graphicAssociateInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate hotspots exist\n\t\tif (!data.associableHotspots || data.associableHotspots.length < 2) {\n\t\t\terrors.push('graphicAssociateInteraction must have at least 2 hotspots');\n\t\t}\n\n\t\t// Validate hotspot identifiers and coords\n\t\tif (data.associableHotspots && data.associableHotspots.length > 0) {\n\t\t\tconst identifiers = new Set<string>();\n\t\t\tfor (const hotspot of data.associableHotspots) {\n\t\t\t\tif (!hotspot.identifier) {\n\t\t\t\t\terrors.push('All hotspots must have an identifier');\n\t\t\t\t} else if (identifiers.has(hotspot.identifier)) {\n\t\t\t\t\terrors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);\n\t\t\t\t} else {\n\t\t\t\t\tidentifiers.add(hotspot.identifier);\n\t\t\t\t}\n\n\t\t\t\tif (!hotspot.coords) {\n\t\t\t\t\terrors.push(`Hotspot ${hotspot.identifier} must have coords`);\n\t\t\t\t}\n\n\t\t\t\t// Validate matchMax\n\t\t\t\tif (hotspot.matchMax < 0) {\n\t\t\t\t\terrors.push(`matchMax must be non-negative for hotspot ${hotspot.identifier}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Validate maxAssociations\n\t\tif (data.maxAssociations < 0) {\n\t\t\terrors.push('maxAssociations must be non-negative');\n\t\t}\n\n\t\t// Validate minAssociations\n\t\tif (data.minAssociations < 0) {\n\t\t\terrors.push('minAssociations must be non-negative');\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: errors.length === 0,\n\t\t\terrors: errors.length > 0 ? errors : undefined,\n\t\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\t};\n\t},\n};\n"]}
1
+ {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/graphic-associate/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AA4CrE;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAA2C;IACxF,EAAE,EAAE,mCAAmC;IACvC,IAAI,EAAE,4CAA4C;IAClD,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,6BAA6B,CAAC;IAC7C,WAAW,EAAE,8EAA8E;IAE3F,SAAS,CAAC,OAAO,EAAE,OAAO;QACzB,wDAAwD;QACxD,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QAE/B,yEAAyE;QACzE,oDA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;YAEpG,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;oBACrB,MAAM,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,UAAU,mBAAmB,CAAC,CAAC;gBAC/D,CAAC;gBAED,oBAAoB;gBACpB,IAAI,OAAO,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;oBAC1B,MAAM,CAAC,IAAI,CAAC,6CAA6C,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;gBAChF,CAAC;YACF,CAAC;QACF,CAAC;QAED,2BAA2B;QAC3B,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACrD,CAAC;QAED,2BAA2B;QAC3B,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO;YACN,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAC9C,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;SACpD,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/**\n * Standard QTI graphicAssociateInteraction extractor\n *\n * Extracts data from graphicAssociateInteraction elements (associate items on image)\n */\n\nimport type { ElementExtractor } from '../../extraction/types.js';\nimport { validateUniqueIdentifiers } from '../../extraction/utils.js';\nimport { normalizePixelDimension } from '../../security/styleValues.js';\nimport { extractImageAlternative, imgAlternativeSource } from '../shared/imageAlt.js';\nimport { findInteractionImage } from '../shared/interactionImage.js';\n\n/**\n * Image data for graphic associate interaction\n */\nexport interface ImageData {\n\ttype: 'image' | 'svg';\n\tsrc?: string;\n\tcontent?: string;\n\twidth?: string;\n\theight?: string;\n\t/** Short text alternative extracted from the QTI source. */\n\talt?: string;\n\t/** Longer description for complex images (SVG <desc>, aria description). */\n\taltDescription?: string;\n\t/** True only when the author explicitly marked the image decorative (`<img alt=\"\">`). */\n\tdecorative?: boolean;\n}\n\n/**\n * Graphic associate data extracted from graphicAssociateInteraction elements\n */\nexport interface GraphicAssociateData {\n\timageData: ImageData | null;\n\tassociableHotspots: Array<{\n\t\tidentifier: string;\n\t\t/**\n\t\t * The hotspot's authored text (`hotspotLabel` or element text). Empty when\n\t\t * the author gave none: the renderer then names it by position. Never the\n\t\t * identifier, which can leak the answer key to assistive technology.\n\t\t */\n\t\tlabel: string;\n\t\tshape: string;\n\t\tcoords: string;\n\t\tmatchMax: number;\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\tclasses?: string[];\n\t}>;\n\tmaxAssociations: number;\n\tminAssociations: number;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI graphic associate interaction extractor\n * Handles graphicAssociateInteraction elements (creating associations between hotspots)\n */\nexport const standardGraphicAssociateExtractor: ElementExtractor<GraphicAssociateData> = {\n\tid: 'qti:graphic-associate-interaction',\n\tname: 'QTI Standard Graphic Associate Interaction',\n\tpriority: 10,\n\telementTypes: ['graphicAssociateInteraction'],\n\tdescription: 'Extracts standard QTI graphicAssociateInteraction (associate items on image)',\n\n\tcanHandle(element, context) {\n\t\t// All graphicAssociateInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'graphicAssociateInteraction');\n\t},\n\n\textract(element, context) {\n\t\tconst { utils, dom } = context;\n\n\t\t// Extract image data from the object element (QTI 2.x) or an img element\n\t\t// (QTI 3.0, plain or as a <picture>'s fallback img)\n\t\tconst interactionImage = findInteractionImage(element, utils);\n\t\tlet imageData: ImageData | null = null;\n\n\t\tif (interactionImage?.kind === 'object') {\n\t\t\tconst objectElement = interactionImage.element;\n\t\t\tconst type = utils.getAttribute(objectElement, 'type', '');\n\t\t\tconst data = utils.getAttribute(objectElement, 'data', '');\n\t\t\t// The stage's pixel space: the authored width/height, when declared. Without\n\t\t\t// them the renderer stages the raster at its natural size; a default here\n\t\t\t// would silently place hotspots in a guessed space.\n\t\t\tconst width = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''));\n\t\t\tconst height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''));\n\t\t\tconst content = type.startsWith('image/svg') ? utils.getHtmlContent(objectElement) : '';\n\n\t\t\tif (/<svg[\\s>]/i.test(content)) {\n\t\t\t\t// Inline SVG: <object type=\"image/svg+xml\"><svg>...</svg></object>\n\t\t\t\timageData = {\n\t\t\t\t\ttype: 'svg',\n\t\t\t\t\tcontent,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\t...extractImageAlternative(objectElement, utils, dom, { inlineSvgContent: content }),\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// External image (or SVG file) reference; the <object>'s text is its alternative\n\t\t\t\timageData = {\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tsrc: data,\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\t...extractImageAlternative(objectElement, utils, dom),\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (interactionImage) {\n\t\t\t// QTI 3.0 <img>: the alt attribute is the text alternative (alt=\"\" = decorative)\n\t\t\tconst imgElement = interactionImage.element;\n\t\t\timageData = {\n\t\t\t\ttype: 'image',\n\t\t\t\tsrc: utils.getAttribute(imgElement, 'src', ''),\n\t\t\t\twidth: normalizePixelDimension(utils.getAttribute(imgElement, 'width', '')),\n\t\t\t\theight: normalizePixelDimension(utils.getAttribute(imgElement, 'height', '')),\n\t\t\t\t...extractImageAlternative(imgElement, utils, dom, imgAlternativeSource(imgElement)),\n\t\t\t};\n\t\t}\n\n\t\t// Extract associableHotspot children\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');\n\t\tconst associableHotspots = hotspotElements.map((hotspot) => {\n\t\t\tconst classes = utils.getClasses(hotspot);\n\t\t\tconst identifier = utils.getAttribute(hotspot, 'identifier', '');\n\t\t\tconst shape = utils.getAttribute(hotspot, 'shape', 'rect');\n\t\t\tconst coords = utils.getAttribute(hotspot, 'coords', '0,0,50,50');\n\t\t\tconst matchMax = utils.getNumberAttribute(hotspot, 'matchMax', 1);\n\t\t\tconst matchMin = utils.getNumberAttribute(hotspot, 'matchMin', 0);\n\t\t\tconst matchGroupRaw = utils.getAttribute(hotspot, 'matchGroup', '');\n\t\t\tconst matchGroup = matchGroupRaw.split(/\\s+/).filter(Boolean);\n\n\t\t\t// The authored label: hotspotLabel (QTI 2.2 / 3.0), else the hotspot's text.\n\t\t\t// No identifier fallback — identifiers can reveal the answer key.\n\t\t\tconst label =\n\t\t\t\tutils.getAttribute(hotspot, 'hotspotLabel', '').trim() || utils.getTextContent(hotspot).trim();\n\n\t\t\treturn {\n\t\t\t\tidentifier,\n\t\t\t\tlabel,\n\t\t\t\tshape,\n\t\t\t\tcoords,\n\t\t\t\tmatchMax,\n\t\t\t\t...(matchMin > 0 ? { matchMin } : {}),\n\t\t\t\t...(matchGroup.length > 0 ? { matchGroup } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract attributes with proper defaults\n\t\tconst maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 1);\n\t\tconst minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);\n\n\t\t// Extract prompt (optional)\n\t\tconst promptElements = utils.getChildrenByTag(element, 'prompt');\n\t\tconst prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;\n\n\t\treturn {\n\t\t\timageData,\n\t\t\tassociableHotspots,\n\t\t\tmaxAssociations,\n\t\t\tminAssociations,\n\t\t\tprompt,\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\t// Validate image data\n\t\tif (!data.imageData) {\n\t\t\twarnings.push('graphicAssociateInteraction has no image data');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('graphicAssociateInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('graphicAssociateInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate hotspots exist\n\t\tif (!data.associableHotspots || data.associableHotspots.length < 2) {\n\t\t\terrors.push('graphicAssociateInteraction must have at least 2 hotspots');\n\t\t}\n\n\t\t// Validate hotspot identifiers and coords\n\t\tif (data.associableHotspots && data.associableHotspots.length > 0) {\n\t\t\tvalidateUniqueIdentifiers(data.associableHotspots, errors, { plural: 'hotspots', noun: 'hotspot' });\n\n\t\t\tfor (const hotspot of data.associableHotspots) {\n\t\t\t\tif (!hotspot.coords) {\n\t\t\t\t\terrors.push(`Hotspot ${hotspot.identifier} must have coords`);\n\t\t\t\t}\n\n\t\t\t\t// Validate matchMax\n\t\t\t\tif (hotspot.matchMax < 0) {\n\t\t\t\t\terrors.push(`matchMax must be non-negative for hotspot ${hotspot.identifier}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Validate maxAssociations\n\t\tif (data.maxAssociations < 0) {\n\t\t\terrors.push('maxAssociations must be non-negative');\n\t\t}\n\n\t\t// Validate minAssociations\n\t\tif (data.minAssociations < 0) {\n\t\t\terrors.push('minAssociations must be non-negative');\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: errors.length === 0,\n\t\t\terrors: errors.length > 0 ? errors : undefined,\n\t\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\t};\n\t},\n};\n"]}
@@ -13,6 +13,12 @@ export interface ImageData {
13
13
  content?: string;
14
14
  width?: number;
15
15
  height?: number;
16
+ /** Short text alternative extracted from the QTI source. */
17
+ alt?: string;
18
+ /** Longer description for complex images (SVG <desc>, aria description). */
19
+ altDescription?: string;
20
+ /** True only when the author explicitly marked the image decorative (`<img alt="">`). */
21
+ decorative?: boolean;
16
22
  }
17
23
  /**
18
24
  * Graphic gap match data extracted from graphicGapMatchInteraction elements
@@ -20,6 +26,8 @@ export interface ImageData {
20
26
  export interface GraphicGapMatchData {
21
27
  imageData: ImageData | null;
22
28
  maxAssociations: number;
29
+ /** QTI `minAssociations`, the associations a valid response makes; omitted when 0. */
30
+ minAssociations?: number;
23
31
  gapTexts: Array<{
24
32
  identifier: string;
25
33
  text: string;
@@ -33,7 +41,15 @@ export interface GraphicGapMatchData {
33
41
  src: string;
34
42
  alt: string;
35
43
  matchMax: number;
44
+ /** Minimum number of hotspots this label must fill; omitted when 0. */
45
+ matchMin?: number;
36
46
  matchGroup?: string[];
47
+ /**
48
+ * The gapImg's authored `objectLabel` (QTI 2.1 `objectLabel.GapImg.Attr`,
49
+ * QTI 3.0 `object-label`). Names the label for assistive technology when
50
+ * the image itself carries no text alternative.
51
+ */
52
+ objectLabel?: string;
37
53
  width?: number;
38
54
  height?: number;
39
55
  }>;
@@ -42,6 +58,11 @@ export interface GraphicGapMatchData {
42
58
  shape: string;
43
59
  coords: string;
44
60
  matchMax: number;
61
+ /** Minimum number of labels this hotspot must take; omitted when 0. */
62
+ matchMin?: number;
63
+ matchGroup?: string[];
64
+ /** The authored `hotspotLabel`; names the zone for assistive technology. */
65
+ hotspotLabel?: string;
45
66
  }>;
46
67
  prompt: string | null;
47
68
  }
@@ -3,7 +3,11 @@
3
3
  *
4
4
  * Extracts data from graphicGapMatchInteraction elements (drag text/images into gaps on image)
5
5
  */
6
+ import { validateUniqueIdentifiers } from '../../extraction/utils.js';
6
7
  import { normalizeCssPixelLength, normalizePixelDimension, } from '../../security/styleValues.js';
8
+ import { extractImageAlternative, imgAlternativeSource } from '../shared/imageAlt.js';
9
+ import { findInteractionImage } from '../shared/interactionImage.js';
10
+ import { predatesQti22 } from '../shared/specDefaults.js';
7
11
  /**
8
12
  * Standard QTI graphic gap match interaction extractor
9
13
  * Handles graphicGapMatchInteraction elements (drag text/images into gaps on an image)
@@ -19,12 +23,13 @@ export const standardGraphicGapMatchExtractor = {
19
23
  return context.utils.matchesTag(element, 'graphicGapMatchInteraction');
20
24
  },
21
25
  extract(element, context) {
22
- const { utils } = context;
23
- // Extract image data from object element
24
- const objectElements = utils.getChildrenByTag(element, 'object');
26
+ const { utils, dom } = context;
27
+ // Extract image data from the object element (QTI 2.x) or an img element
28
+ // (QTI 3.0, plain or as a <picture>'s fallback img)
29
+ const interactionImage = findInteractionImage(element, utils);
25
30
  let imageData = null;
26
- if (objectElements.length > 0) {
27
- const objectElement = objectElements[0];
31
+ if (interactionImage?.kind === 'object') {
32
+ const objectElement = interactionImage.element;
28
33
  const type = utils.getAttribute(objectElement, 'type', '');
29
34
  const data = utils.getAttribute(objectElement, 'data', '');
30
35
  const normalizedWidth = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''));
@@ -43,6 +48,7 @@ export const standardGraphicGapMatchExtractor = {
43
48
  content,
44
49
  ...(width ? { width } : {}),
45
50
  ...(height ? { height } : {}),
51
+ ...extractImageAlternative(objectElement, utils, dom, { inlineSvgContent: content }),
46
52
  };
47
53
  }
48
54
  else {
@@ -52,6 +58,7 @@ export const standardGraphicGapMatchExtractor = {
52
58
  src: data,
53
59
  ...(width ? { width } : {}),
54
60
  ...(height ? { height } : {}),
61
+ ...extractImageAlternative(objectElement, utils, dom),
55
62
  };
56
63
  }
57
64
  }
@@ -62,11 +69,34 @@ export const standardGraphicGapMatchExtractor = {
62
69
  src: data,
63
70
  ...(width ? { width } : {}),
64
71
  ...(height ? { height } : {}),
72
+ ...extractImageAlternative(objectElement, utils, dom),
65
73
  };
66
74
  }
67
75
  }
68
- // Extract interaction-level attributes
69
- const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 0);
76
+ else if (interactionImage) {
77
+ // QTI 3.0 <img>: the alt attribute is the text alternative (alt="" = decorative)
78
+ const imgElement = interactionImage.element;
79
+ const normalizedWidth = normalizePixelDimension(utils.getAttribute(imgElement, 'width', ''));
80
+ const normalizedHeight = normalizePixelDimension(utils.getAttribute(imgElement, 'height', ''));
81
+ imageData = {
82
+ type: 'image',
83
+ src: utils.getAttribute(imgElement, 'src', ''),
84
+ ...(normalizedWidth ? { width: Number(normalizedWidth) } : {}),
85
+ ...(normalizedHeight ? { height: Number(normalizedHeight) } : {}),
86
+ ...extractImageAlternative(imgElement, utils, dom, imgAlternativeSource(imgElement)),
87
+ };
88
+ }
89
+ // Extract interaction-level attributes with the per-version spec default for an
90
+ // absent maxAssociations: QTI 2.2 (Table 5.41.2) and QTI 3.0 (Table 5.60.2) give
91
+ // it the default "1" (0 = no restriction), while the attribute does not exist on
92
+ // graphicGapMatchInteraction in QTI 2.1, so absent means no interaction cap there
93
+ // (the only 2.1 limits are the per-choice matchMax values). An explicit value is
94
+ // honoured in every version as leniency, with "0" meaning unlimited.
95
+ const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', predatesQti22(context) ? 0 : 1);
96
+ // minAssociations (QTI 2.2; QTI 3.0 §5.60.1 min-associations): "The minimum number of
97
+ // associations that the candidate is required to make to form a valid response. If
98
+ // min-associations is 0 then the candidate is not required to make any associations."
99
+ const minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);
70
100
  // Extract gapText children (draggable text labels)
71
101
  const gapTextElements = utils.getChildrenByTag(element, 'gapText');
72
102
  const gapTexts = gapTextElements.map((gapText) => {
@@ -89,19 +119,26 @@ export const standardGraphicGapMatchExtractor = {
89
119
  const gapImgElements = utils.getChildrenByTag(element, 'gapImg');
90
120
  const gapImages = gapImgElements.map((gapImg) => {
91
121
  const matchMax = utils.getNumberAttribute(gapImg, 'matchMax', 1);
122
+ const matchMin = utils.getNumberAttribute(gapImg, 'matchMin', 0);
92
123
  const matchGroupRaw = utils.getAttribute(gapImg, 'matchGroup', '');
93
124
  const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
94
- const objectChildren = utils.getChildrenByTag(gapImg, 'object');
125
+ const objectLabel = utils.getAttribute(gapImg, 'objectLabel', '').trim();
126
+ // QTI 3.0 GapImgDType allows object, img or picture (delivered via its img fallback)
127
+ const image = findInteractionImage(gapImg, utils);
95
128
  let src = '';
96
129
  let alt = '';
97
130
  let width;
98
131
  let height;
99
- if (objectChildren.length > 0) {
100
- const obj = objectChildren[0];
101
- src = utils.getAttribute(obj, 'data', '');
102
- alt = utils.getTextContent(obj);
103
- const w = normalizePixelDimension(utils.getAttribute(obj, 'width', ''));
104
- const h = normalizePixelDimension(utils.getAttribute(obj, 'height', ''));
132
+ // The image's text alternative names the draggable label for assistive
133
+ // technology; an empty alt never falls back to the identifier.
134
+ const imageElement = image?.element;
135
+ if (imageElement) {
136
+ const isImg = image?.kind === 'img';
137
+ src = utils.getAttribute(imageElement, isImg ? 'src' : 'data', '');
138
+ alt =
139
+ extractImageAlternative(imageElement, utils, dom, isImg ? imgAlternativeSource(imageElement) : {}).alt ?? '';
140
+ const w = normalizePixelDimension(utils.getAttribute(imageElement, 'width', ''));
141
+ const h = normalizePixelDimension(utils.getAttribute(imageElement, 'height', ''));
105
142
  if (w)
106
143
  width = Number(w);
107
144
  if (h)
@@ -112,19 +149,35 @@ export const standardGraphicGapMatchExtractor = {
112
149
  src,
113
150
  alt,
114
151
  matchMax,
152
+ ...(matchMin > 0 ? { matchMin } : {}),
115
153
  ...(matchGroup.length > 0 ? { matchGroup } : {}),
154
+ ...(objectLabel ? { objectLabel } : {}),
116
155
  ...(width !== undefined ? { width } : {}),
117
156
  ...(height !== undefined ? { height } : {}),
118
157
  };
119
158
  });
120
159
  // Extract associableHotspot elements (gap targets)
121
160
  const hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');
122
- const hotspots = hotspotElements.map((hotspot) => ({
123
- identifier: utils.getAttribute(hotspot, 'identifier', ''),
124
- shape: utils.getAttribute(hotspot, 'shape', 'rect'),
125
- coords: utils.getAttribute(hotspot, 'coords', ''),
126
- matchMax: utils.getNumberAttribute(hotspot, 'matchMax', 1),
127
- }));
161
+ const hotspots = hotspotElements.map((hotspot) => {
162
+ const matchGroup = utils
163
+ .getAttribute(hotspot, 'matchGroup', '')
164
+ .split(/\s+/)
165
+ .filter(Boolean);
166
+ const matchMin = utils.getNumberAttribute(hotspot, 'matchMin', 0);
167
+ const hotspotLabel = utils.getAttribute(hotspot, 'hotspotLabel', '').trim();
168
+ return {
169
+ identifier: utils.getAttribute(hotspot, 'identifier', ''),
170
+ shape: utils.getAttribute(hotspot, 'shape', 'rect'),
171
+ coords: utils.getAttribute(hotspot, 'coords', ''),
172
+ matchMax: utils.getNumberAttribute(hotspot, 'matchMax', 1),
173
+ ...(matchMin > 0 ? { matchMin } : {}),
174
+ // Authored matchGroup: the identifiers of the labels that may be matched with this hotspot.
175
+ ...(matchGroup.length > 0 ? { matchGroup } : {}),
176
+ // The authored zone name for assistive technology (2.1 hotspotLabel,
177
+ // 3.0 hotspot-label); an empty attribute never falls back to the identifier.
178
+ ...(hotspotLabel ? { hotspotLabel } : {}),
179
+ };
180
+ });
128
181
  // Extract prompt (optional)
129
182
  const promptElements = utils.getChildrenByTag(element, 'prompt');
130
183
  const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
@@ -135,6 +188,7 @@ export const standardGraphicGapMatchExtractor = {
135
188
  return {
136
189
  imageData,
137
190
  maxAssociations,
191
+ ...(minAssociations > 0 ? { minAssociations } : {}),
138
192
  gapTexts,
139
193
  gapImages,
140
194
  hotspots,
@@ -168,33 +222,15 @@ export const standardGraphicGapMatchExtractor = {
168
222
  }
169
223
  // Validate gapText identifiers
170
224
  if (data.gapTexts) {
171
- const identifiers = new Set();
172
- for (const gapText of data.gapTexts) {
173
- if (!gapText.identifier) {
174
- errors.push('All gapTexts must have an identifier');
175
- }
176
- else if (identifiers.has(gapText.identifier)) {
177
- errors.push(`Duplicate gapText identifier: ${gapText.identifier}`);
178
- }
179
- else {
180
- identifiers.add(gapText.identifier);
181
- }
182
- }
225
+ validateUniqueIdentifiers(data.gapTexts, errors, { plural: 'gapTexts', noun: 'gapText' });
183
226
  }
184
227
  // Validate hotspot identifiers
185
228
  if (data.hotspots) {
186
- const identifiers = new Set();
229
+ validateUniqueIdentifiers(data.hotspots, errors, { plural: 'hotspots', noun: 'hotspot' });
187
230
  for (const hotspot of data.hotspots) {
188
- if (!hotspot.identifier) {
189
- errors.push('All hotspots must have an identifier');
190
- }
191
- else if (identifiers.has(hotspot.identifier)) {
192
- errors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);
193
- }
194
- else {
195
- identifiers.add(hotspot.identifier);
196
- }
197
- if (!hotspot.coords) {
231
+ // The default shape is the whole image (QTI 3.0 §8.29), so its coords
232
+ // may be empty — the same rule the hotspot extractor applies.
233
+ if (!hotspot.coords && hotspot.shape !== 'default') {
198
234
  errors.push(`Hotspot ${hotspot.identifier} must have coords`);
199
235
  }
200
236
  }
@@ -1 +1 @@
1
- {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/graphic-gap-match/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACN,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,+BAA+B,CAAC;AAwCvC;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAA0C;IACtF,EAAE,EAAE,mCAAmC;IACvC,IAAI,EAAE,4CAA4C;IAClD,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,4BAA4B,CAAC;IAC5C,WAAW,EAAE,+EAA+E;IAE5F,SAAS,CAAC,OAAO,EAAE,OAAO;QACzB,uDAAuD;QACvD,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAE1B,yCAAyC;QACzC,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC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AM,CAAC,IAAI,CAAC,iCAAiC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;gBACpE,CAAC;qBAAM,CAAC;oBACP,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACrC,CAAC;gBAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;oBACrB,MAAM,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,UAAU,mBAAmB,CAAC,CAAC;gBAC/D,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO;YACN,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAC9C,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;SACpD,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/**\n * Standard QTI graphicGapMatchInteraction extractor\n *\n * Extracts data from graphicGapMatchInteraction elements (drag text/images into gaps on image)\n */\n\nimport type { ElementExtractor } from '../../extraction/types.js';\nimport {\n\tnormalizeCssPixelLength,\n\tnormalizePixelDimension,\n} from '../../security/styleValues.js';\n\n/**\n * Image data for graphic gap match interaction\n */\nexport interface ImageData {\n\ttype: 'image' | 'svg';\n\tsrc?: string;\n\tcontent?: string;\n\twidth?: number;\n\theight?: number;\n}\n\n/**\n * Graphic gap match data extracted from graphicGapMatchInteraction elements\n */\nexport interface GraphicGapMatchData {\n\timageData: ImageData | null;\n\tmaxAssociations: number;\n\tgapTexts: Array<{\n\t\tidentifier: string;\n\t\ttext: string;\n\t\tmatchMax: number;\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\tclasses?: string[];\n\t}>;\n\tgapImages: Array<{\n\t\tidentifier: string;\n\t\tsrc: string;\n\t\talt: string;\n\t\tmatchMax: number;\n\t\tmatchGroup?: string[];\n\t\twidth?: number;\n\t\theight?: number;\n\t}>;\n\thotspots: Array<{ identifier: string; shape: string; coords: string; matchMax: number }>;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI graphic gap match interaction extractor\n * Handles graphicGapMatchInteraction elements (drag text/images into gaps on an image)\n */\nexport const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchData> = {\n\tid: 'qti:graphic-gap-match-interaction',\n\tname: 'QTI Standard Graphic Gap Match Interaction',\n\tpriority: 10,\n\telementTypes: ['graphicGapMatchInteraction'],\n\tdescription: 'Extracts standard QTI graphicGapMatchInteraction (drag text/images into gaps)',\n\n\tcanHandle(element, context) {\n\t\t// All graphicGapMatchInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'graphicGapMatchInteraction');\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\n\t\t// Extract image data from object element\n\t\tconst objectElements = utils.getChildrenByTag(element, 'object');\n\t\tlet imageData: ImageData | null = null;\n\n\t\tif (objectElements.length > 0) {\n\t\t\tconst objectElement = objectElements[0];\n\t\t\tconst type = utils.getAttribute(objectElement, 'type', '');\n\t\t\tconst data = utils.getAttribute(objectElement, 'data', '');\n\t\t\tconst normalizedWidth = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''));\n\t\t\tconst normalizedHeight = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''));\n\t\t\tconst width = normalizedWidth ? Number(normalizedWidth) : undefined;\n\t\t\tconst height = normalizedHeight ? Number(normalizedHeight) : undefined;\n\n\t\t\tif (type.startsWith('image/svg')) {\n\t\t\t\t// Inline SVG: <object type=\"image/svg+xml\"><svg>...</svg></object>\n\t\t\t\t// External SVG: <object type=\"image/svg+xml\" data=\"path/to/file.svg\"/>\n\t\t\t\t// The <object> may contain alt text (not SVG markup) — only treat as inline if content has <svg.\n\t\t\t\tconst content = utils.getHtmlContent(objectElement);\n\t\t\t\tconst hasSvgMarkup = /<svg[\\s>]/i.test(content);\n\t\t\t\tif (hasSvgMarkup) {\n\t\t\t\t\timageData = {\n\t\t\t\t\t\ttype: 'svg',\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t...(width ? { width } : {}),\n\t\t\t\t\t\t...(height ? { height } : {}),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\t// External SVG file reference — render via <img src>\n\t\t\t\t\timageData = {\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\tsrc: data,\n\t\t\t\t\t\t...(width ? { width } : {}),\n\t\t\t\t\t\t...(height ? { height } : {}),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// External image reference\n\t\t\t\timageData = {\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tsrc: data,\n\t\t\t\t\t...(width ? { width } : {}),\n\t\t\t\t\t...(height ? { height } : {}),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Extract interaction-level attributes\n\t\tconst maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 0);\n\n\t\t// Extract gapText children (draggable text labels)\n\t\tconst gapTextElements = utils.getChildrenByTag(element, 'gapText');\n\t\tconst gapTexts = gapTextElements.map((gapText) => {\n\t\t\tconst classes = utils.getClasses(gapText);\n\t\t\tconst matchMax = utils.getNumberAttribute(gapText, 'matchMax', 1);\n\t\t\tconst matchMin = utils.getNumberAttribute(gapText, 'matchMin', 0);\n\t\t\tconst matchGroupRaw = utils.getAttribute(gapText, 'matchGroup', '');\n\t\t\tconst matchGroup = matchGroupRaw.split(/\\s+/).filter(Boolean);\n\t\t\tconst text = utils.getHtmlContent(gapText);\n\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(gapText, 'identifier', ''),\n\t\t\t\ttext,\n\t\t\t\tmatchMax,\n\t\t\t\t...(matchMin > 0 ? { matchMin } : {}),\n\t\t\t\t...(matchGroup.length > 0 ? { matchGroup } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract gapImg children (draggable image labels)\n\t\tconst gapImgElements = utils.getChildrenByTag(element, 'gapImg');\n\t\tconst gapImages = gapImgElements.map((gapImg) => {\n\t\t\tconst matchMax = utils.getNumberAttribute(gapImg, 'matchMax', 1);\n\t\t\tconst matchGroupRaw = utils.getAttribute(gapImg, 'matchGroup', '');\n\t\t\tconst matchGroup = matchGroupRaw.split(/\\s+/).filter(Boolean);\n\t\t\tconst objectChildren = utils.getChildrenByTag(gapImg, 'object');\n\t\t\tlet src = '';\n\t\t\tlet alt = '';\n\t\t\tlet width: number | undefined;\n\t\t\tlet height: number | undefined;\n\t\t\tif (objectChildren.length > 0) {\n\t\t\t\tconst obj = objectChildren[0];\n\t\t\t\tsrc = utils.getAttribute(obj, 'data', '');\n\t\t\t\talt = utils.getTextContent(obj);\n\t\t\t\tconst w = normalizePixelDimension(utils.getAttribute(obj, 'width', ''));\n\t\t\t\tconst h = normalizePixelDimension(utils.getAttribute(obj, 'height', ''));\n\t\t\t\tif (w) width = Number(w);\n\t\t\t\tif (h) height = Number(h);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(gapImg, 'identifier', ''),\n\t\t\t\tsrc,\n\t\t\t\talt,\n\t\t\t\tmatchMax,\n\t\t\t\t...(matchGroup.length > 0 ? { matchGroup } : {}),\n\t\t\t\t...(width !== undefined ? { width } : {}),\n\t\t\t\t...(height !== undefined ? { height } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract associableHotspot elements (gap targets)\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');\n\t\tconst hotspots = hotspotElements.map((hotspot) => ({\n\t\t\tidentifier: utils.getAttribute(hotspot, 'identifier', ''),\n\t\t\tshape: utils.getAttribute(hotspot, 'shape', 'rect'),\n\t\t\tcoords: utils.getAttribute(hotspot, 'coords', ''),\n\t\t\tmatchMax: utils.getNumberAttribute(hotspot, 'matchMax', 1),\n\t\t}));\n\n\t\t// Extract prompt (optional)\n\t\tconst promptElements = utils.getChildrenByTag(element, 'prompt');\n\t\tconst prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;\n\n\t\tconst interactionClasses = utils.getClasses(element);\n\t\tconst choicesContainerWidth = normalizeCssPixelLength(\n\t\t\tutils.getAttribute(element, 'data-choices-container-width', ''),\n\t\t);\n\t\tconst maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;\n\t\tconst minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;\n\n\t\treturn {\n\t\t\timageData,\n\t\t\tmaxAssociations,\n\t\t\tgapTexts,\n\t\t\tgapImages,\n\t\t\thotspots,\n\t\t\tprompt,\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\n\t\t\t...(choicesContainerWidth ? { choicesContainerWidth } : {}),\n\t\t\t...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),\n\t\t\t...(minSelectionsMessage ? { minSelectionsMessage } : {}),\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\t// Validate image data (optional but recommended)\n\t\tif (!data.imageData) {\n\t\t\twarnings.push('graphicGapMatchInteraction has no background image');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('graphicGapMatchInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('graphicGapMatchInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate that at least one draggable choice type is present\n\t\tif ((!data.gapTexts || data.gapTexts.length === 0) && (!data.gapImages || data.gapImages.length === 0)) {\n\t\t\terrors.push('graphicGapMatchInteraction must have at least one gapText or gapImg');\n\t\t}\n\n\t\t// Validate hotspots exist\n\t\tif (!data.hotspots || data.hotspots.length === 0) {\n\t\t\terrors.push('graphicGapMatchInteraction must have at least one hotspot');\n\t\t}\n\n\t\t// Validate gapText identifiers\n\t\tif (data.gapTexts) {\n\t\t\tconst identifiers = new Set<string>();\n\t\t\tfor (const gapText of data.gapTexts) {\n\t\t\t\tif (!gapText.identifier) {\n\t\t\t\t\terrors.push('All gapTexts must have an identifier');\n\t\t\t\t} else if (identifiers.has(gapText.identifier)) {\n\t\t\t\t\terrors.push(`Duplicate gapText identifier: ${gapText.identifier}`);\n\t\t\t\t} else {\n\t\t\t\t\tidentifiers.add(gapText.identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Validate hotspot identifiers\n\t\tif (data.hotspots) {\n\t\t\tconst identifiers = new Set<string>();\n\t\t\tfor (const hotspot of data.hotspots) {\n\t\t\t\tif (!hotspot.identifier) {\n\t\t\t\t\terrors.push('All hotspots must have an identifier');\n\t\t\t\t} else if (identifiers.has(hotspot.identifier)) {\n\t\t\t\t\terrors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);\n\t\t\t\t} else {\n\t\t\t\t\tidentifiers.add(hotspot.identifier);\n\t\t\t\t}\n\n\t\t\t\tif (!hotspot.coords) {\n\t\t\t\t\terrors.push(`Hotspot ${hotspot.identifier} must have coords`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: errors.length === 0,\n\t\t\terrors: errors.length > 0 ? errors : undefined,\n\t\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\t};\n\t},\n};\n"]}
1
+ {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/graphic-gap-match/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACN,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AA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yB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,+BAA+B;QAC/B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,yBAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;YAE1F,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACrC,sEAAsE;gBACtE,8DAA8D;gBAC9D,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;oBACpD,MAAM,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,UAAU,mBAAmB,CAAC,CAAC;gBAC/D,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO;YACN,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAC9C,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;SACpD,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/**\n * Standard QTI graphicGapMatchInteraction extractor\n *\n * Extracts data from graphicGapMatchInteraction elements (drag text/images into gaps on image)\n */\n\nimport type { ElementExtractor } from '../../extraction/types.js';\nimport { validateUniqueIdentifiers } from '../../extraction/utils.js';\nimport {\n\tnormalizeCssPixelLength,\n\tnormalizePixelDimension,\n} from '../../security/styleValues.js';\nimport { extractImageAlternative, imgAlternativeSource } from '../shared/imageAlt.js';\nimport { findInteractionImage } from '../shared/interactionImage.js';\nimport { predatesQti22 } from '../shared/specDefaults.js';\n\n/**\n * Image data for graphic gap match interaction\n */\nexport interface ImageData {\n\ttype: 'image' | 'svg';\n\tsrc?: string;\n\tcontent?: string;\n\twidth?: number;\n\theight?: number;\n\t/** Short text alternative extracted from the QTI source. */\n\talt?: string;\n\t/** Longer description for complex images (SVG <desc>, aria description). */\n\taltDescription?: string;\n\t/** True only when the author explicitly marked the image decorative (`<img alt=\"\">`). */\n\tdecorative?: boolean;\n}\n\n/**\n * Graphic gap match data extracted from graphicGapMatchInteraction elements\n */\nexport interface GraphicGapMatchData {\n\timageData: ImageData | null;\n\tmaxAssociations: number;\n\t/** QTI `minAssociations`, the associations a valid response makes; omitted when 0. */\n\tminAssociations?: number;\n\tgapTexts: Array<{\n\t\tidentifier: string;\n\t\ttext: string;\n\t\tmatchMax: number;\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\tclasses?: string[];\n\t}>;\n\tgapImages: Array<{\n\t\tidentifier: string;\n\t\tsrc: string;\n\t\talt: string;\n\t\tmatchMax: number;\n\t\t/** Minimum number of hotspots this label must fill; omitted when 0. */\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\t/**\n\t\t * The gapImg's authored `objectLabel` (QTI 2.1 `objectLabel.GapImg.Attr`,\n\t\t * QTI 3.0 `object-label`). Names the label for assistive technology when\n\t\t * the image itself carries no text alternative.\n\t\t */\n\t\tobjectLabel?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\t}>;\n\thotspots: Array<{\n\t\tidentifier: string;\n\t\tshape: string;\n\t\tcoords: string;\n\t\tmatchMax: number;\n\t\t/** Minimum number of labels this hotspot must take; omitted when 0. */\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\t/** The authored `hotspotLabel`; names the zone for assistive technology. */\n\t\thotspotLabel?: string;\n\t}>;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI graphic gap match interaction extractor\n * Handles graphicGapMatchInteraction elements (drag text/images into gaps on an image)\n */\nexport const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchData> = {\n\tid: 'qti:graphic-gap-match-interaction',\n\tname: 'QTI Standard Graphic Gap Match Interaction',\n\tpriority: 10,\n\telementTypes: ['graphicGapMatchInteraction'],\n\tdescription: 'Extracts standard QTI graphicGapMatchInteraction (drag text/images into gaps)',\n\n\tcanHandle(element, context) {\n\t\t// All graphicGapMatchInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'graphicGapMatchInteraction');\n\t},\n\n\textract(element, context) {\n\t\tconst { utils, dom } = context;\n\n\t\t// Extract image data from the object element (QTI 2.x) or an img element\n\t\t// (QTI 3.0, plain or as a <picture>'s fallback img)\n\t\tconst interactionImage = findInteractionImage(element, utils);\n\t\tlet imageData: ImageData | null = null;\n\n\t\tif (interactionImage?.kind === 'object') {\n\t\t\tconst objectElement = interactionImage.element;\n\t\t\tconst type = utils.getAttribute(objectElement, 'type', '');\n\t\t\tconst data = utils.getAttribute(objectElement, 'data', '');\n\t\t\tconst normalizedWidth = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''));\n\t\t\tconst normalizedHeight = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''));\n\t\t\tconst width = normalizedWidth ? Number(normalizedWidth) : undefined;\n\t\t\tconst height = normalizedHeight ? Number(normalizedHeight) : undefined;\n\n\t\t\tif (type.startsWith('image/svg')) {\n\t\t\t\t// Inline SVG: <object type=\"image/svg+xml\"><svg>...</svg></object>\n\t\t\t\t// External SVG: <object type=\"image/svg+xml\" data=\"path/to/file.svg\"/>\n\t\t\t\t// The <object> may contain alt text (not SVG markup) — only treat as inline if content has <svg.\n\t\t\t\tconst content = utils.getHtmlContent(objectElement);\n\t\t\t\tconst hasSvgMarkup = /<svg[\\s>]/i.test(content);\n\t\t\t\tif (hasSvgMarkup) {\n\t\t\t\t\timageData = {\n\t\t\t\t\t\ttype: 'svg',\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t...(width ? { width } : {}),\n\t\t\t\t\t\t...(height ? { height } : {}),\n\t\t\t\t\t\t...extractImageAlternative(objectElement, utils, dom, { inlineSvgContent: content }),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\t// External SVG file reference — render via <img src>\n\t\t\t\t\timageData = {\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\tsrc: data,\n\t\t\t\t\t\t...(width ? { width } : {}),\n\t\t\t\t\t\t...(height ? { height } : {}),\n\t\t\t\t\t\t...extractImageAlternative(objectElement, utils, dom),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// External image reference\n\t\t\t\timageData = {\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tsrc: data,\n\t\t\t\t\t...(width ? { width } : {}),\n\t\t\t\t\t...(height ? { height } : {}),\n\t\t\t\t\t...extractImageAlternative(objectElement, utils, dom),\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (interactionImage) {\n\t\t\t// QTI 3.0 <img>: the alt attribute is the text alternative (alt=\"\" = decorative)\n\t\t\tconst imgElement = interactionImage.element;\n\t\t\tconst normalizedWidth = normalizePixelDimension(utils.getAttribute(imgElement, 'width', ''));\n\t\t\tconst normalizedHeight = normalizePixelDimension(utils.getAttribute(imgElement, 'height', ''));\n\t\t\timageData = {\n\t\t\t\ttype: 'image',\n\t\t\t\tsrc: utils.getAttribute(imgElement, 'src', ''),\n\t\t\t\t...(normalizedWidth ? { width: Number(normalizedWidth) } : {}),\n\t\t\t\t...(normalizedHeight ? { height: Number(normalizedHeight) } : {}),\n\t\t\t\t...extractImageAlternative(imgElement, utils, dom, imgAlternativeSource(imgElement)),\n\t\t\t};\n\t\t}\n\n\t\t// Extract interaction-level attributes with the per-version spec default for an\n\t\t// absent maxAssociations: QTI 2.2 (Table 5.41.2) and QTI 3.0 (Table 5.60.2) give\n\t\t// it the default \"1\" (0 = no restriction), while the attribute does not exist on\n\t\t// graphicGapMatchInteraction in QTI 2.1, so absent means no interaction cap there\n\t\t// (the only 2.1 limits are the per-choice matchMax values). An explicit value is\n\t\t// honoured in every version as leniency, with \"0\" meaning unlimited.\n\t\tconst maxAssociations = utils.getNumberAttribute(\n\t\t\telement,\n\t\t\t'maxAssociations',\n\t\t\tpredatesQti22(context) ? 0 : 1,\n\t\t);\n\t\t// minAssociations (QTI 2.2; QTI 3.0 §5.60.1 min-associations): \"The minimum number of\n\t\t// associations that the candidate is required to make to form a valid response. If\n\t\t// min-associations is 0 then the candidate is not required to make any associations.\"\n\t\tconst minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);\n\n\t\t// Extract gapText children (draggable text labels)\n\t\tconst gapTextElements = utils.getChildrenByTag(element, 'gapText');\n\t\tconst gapTexts = gapTextElements.map((gapText) => {\n\t\t\tconst classes = utils.getClasses(gapText);\n\t\t\tconst matchMax = utils.getNumberAttribute(gapText, 'matchMax', 1);\n\t\t\tconst matchMin = utils.getNumberAttribute(gapText, 'matchMin', 0);\n\t\t\tconst matchGroupRaw = utils.getAttribute(gapText, 'matchGroup', '');\n\t\t\tconst matchGroup = matchGroupRaw.split(/\\s+/).filter(Boolean);\n\t\t\tconst text = utils.getHtmlContent(gapText);\n\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(gapText, 'identifier', ''),\n\t\t\t\ttext,\n\t\t\t\tmatchMax,\n\t\t\t\t...(matchMin > 0 ? { matchMin } : {}),\n\t\t\t\t...(matchGroup.length > 0 ? { matchGroup } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract gapImg children (draggable image labels)\n\t\tconst gapImgElements = utils.getChildrenByTag(element, 'gapImg');\n\t\tconst gapImages = gapImgElements.map((gapImg) => {\n\t\t\tconst matchMax = utils.getNumberAttribute(gapImg, 'matchMax', 1);\n\t\t\tconst matchMin = utils.getNumberAttribute(gapImg, 'matchMin', 0);\n\t\t\tconst matchGroupRaw = utils.getAttribute(gapImg, 'matchGroup', '');\n\t\t\tconst matchGroup = matchGroupRaw.split(/\\s+/).filter(Boolean);\n\t\t\tconst objectLabel = utils.getAttribute(gapImg, 'objectLabel', '').trim();\n\t\t\t// QTI 3.0 GapImgDType allows object, img or picture (delivered via its img fallback)\n\t\t\tconst image = findInteractionImage(gapImg, utils);\n\t\t\tlet src = '';\n\t\t\tlet alt = '';\n\t\t\tlet width: number | undefined;\n\t\t\tlet height: number | undefined;\n\t\t\t// The image's text alternative names the draggable label for assistive\n\t\t\t// technology; an empty alt never falls back to the identifier.\n\t\t\tconst imageElement = image?.element;\n\t\t\tif (imageElement) {\n\t\t\t\tconst isImg = image?.kind === 'img';\n\t\t\t\tsrc = utils.getAttribute(imageElement, isImg ? 'src' : 'data', '');\n\t\t\t\talt =\n\t\t\t\t\textractImageAlternative(\n\t\t\t\t\t\timageElement,\n\t\t\t\t\t\tutils,\n\t\t\t\t\t\tdom,\n\t\t\t\t\t\tisImg ? imgAlternativeSource(imageElement) : {},\n\t\t\t\t\t).alt ?? '';\n\t\t\t\tconst w = normalizePixelDimension(utils.getAttribute(imageElement, 'width', ''));\n\t\t\t\tconst h = normalizePixelDimension(utils.getAttribute(imageElement, 'height', ''));\n\t\t\t\tif (w) width = Number(w);\n\t\t\t\tif (h) height = Number(h);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(gapImg, 'identifier', ''),\n\t\t\t\tsrc,\n\t\t\t\talt,\n\t\t\t\tmatchMax,\n\t\t\t\t...(matchMin > 0 ? { matchMin } : {}),\n\t\t\t\t...(matchGroup.length > 0 ? { matchGroup } : {}),\n\t\t\t\t...(objectLabel ? { objectLabel } : {}),\n\t\t\t\t...(width !== undefined ? { width } : {}),\n\t\t\t\t...(height !== undefined ? { height } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract associableHotspot elements (gap targets)\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');\n\t\tconst hotspots = hotspotElements.map((hotspot) => {\n\t\t\tconst matchGroup = utils\n\t\t\t\t.getAttribute(hotspot, 'matchGroup', '')\n\t\t\t\t.split(/\\s+/)\n\t\t\t\t.filter(Boolean);\n\t\t\tconst matchMin = utils.getNumberAttribute(hotspot, 'matchMin', 0);\n\t\t\tconst hotspotLabel = utils.getAttribute(hotspot, 'hotspotLabel', '').trim();\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(hotspot, 'identifier', ''),\n\t\t\t\tshape: utils.getAttribute(hotspot, 'shape', 'rect'),\n\t\t\t\tcoords: utils.getAttribute(hotspot, 'coords', ''),\n\t\t\t\tmatchMax: utils.getNumberAttribute(hotspot, 'matchMax', 1),\n\t\t\t\t...(matchMin > 0 ? { matchMin } : {}),\n\t\t\t\t// Authored matchGroup: the identifiers of the labels that may be matched with this hotspot.\n\t\t\t\t...(matchGroup.length > 0 ? { matchGroup } : {}),\n\t\t\t\t// The authored zone name for assistive technology (2.1 hotspotLabel,\n\t\t\t\t// 3.0 hotspot-label); an empty attribute never falls back to the identifier.\n\t\t\t\t...(hotspotLabel ? { hotspotLabel } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract prompt (optional)\n\t\tconst promptElements = utils.getChildrenByTag(element, 'prompt');\n\t\tconst prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;\n\n\t\tconst interactionClasses = utils.getClasses(element);\n\t\tconst choicesContainerWidth = normalizeCssPixelLength(\n\t\t\tutils.getAttribute(element, 'data-choices-container-width', ''),\n\t\t);\n\t\tconst maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;\n\t\tconst minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;\n\n\t\treturn {\n\t\t\timageData,\n\t\t\tmaxAssociations,\n\t\t\t...(minAssociations > 0 ? { minAssociations } : {}),\n\t\t\tgapTexts,\n\t\t\tgapImages,\n\t\t\thotspots,\n\t\t\tprompt,\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\n\t\t\t...(choicesContainerWidth ? { choicesContainerWidth } : {}),\n\t\t\t...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),\n\t\t\t...(minSelectionsMessage ? { minSelectionsMessage } : {}),\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\t// Validate image data (optional but recommended)\n\t\tif (!data.imageData) {\n\t\t\twarnings.push('graphicGapMatchInteraction has no background image');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('graphicGapMatchInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('graphicGapMatchInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate that at least one draggable choice type is present\n\t\tif ((!data.gapTexts || data.gapTexts.length === 0) && (!data.gapImages || data.gapImages.length === 0)) {\n\t\t\terrors.push('graphicGapMatchInteraction must have at least one gapText or gapImg');\n\t\t}\n\n\t\t// Validate hotspots exist\n\t\tif (!data.hotspots || data.hotspots.length === 0) {\n\t\t\terrors.push('graphicGapMatchInteraction must have at least one hotspot');\n\t\t}\n\n\t\t// Validate gapText identifiers\n\t\tif (data.gapTexts) {\n\t\t\tvalidateUniqueIdentifiers(data.gapTexts, errors, { plural: 'gapTexts', noun: 'gapText' });\n\t\t}\n\n\t\t// Validate hotspot identifiers\n\t\tif (data.hotspots) {\n\t\t\tvalidateUniqueIdentifiers(data.hotspots, errors, { plural: 'hotspots', noun: 'hotspot' });\n\n\t\t\tfor (const hotspot of data.hotspots) {\n\t\t\t\t// The default shape is the whole image (QTI 3.0 §8.29), so its coords\n\t\t\t\t// may be empty — the same rule the hotspot extractor applies.\n\t\t\t\tif (!hotspot.coords && hotspot.shape !== 'default') {\n\t\t\t\t\terrors.push(`Hotspot ${hotspot.identifier} must have coords`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: errors.length === 0,\n\t\t\terrors: errors.length > 0 ? errors : undefined,\n\t\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\t};\n\t},\n};\n"]}
@@ -13,6 +13,12 @@ export interface ImageData {
13
13
  content?: string;
14
14
  width?: string;
15
15
  height?: string;
16
+ /** Short text alternative extracted from the QTI source. */
17
+ alt?: string;
18
+ /** Longer description for complex images (SVG <desc>, aria description). */
19
+ altDescription?: string;
20
+ /** True only when the author explicitly marked the image decorative (`<img alt="">`). */
21
+ decorative?: boolean;
16
22
  }
17
23
  /**
18
24
  * Graphic order data extracted from graphicOrderInteraction elements
@@ -21,6 +27,11 @@ export interface GraphicOrderData {
21
27
  imageData: ImageData | null;
22
28
  hotspotChoices: Array<{
23
29
  identifier: string;
30
+ /**
31
+ * The hotspot's authored text. Empty when the author gave none: the
32
+ * renderer then names it by position. Never the identifier, which can
33
+ * leak the answer key to assistive technology.
34
+ */
24
35
  label: string;
25
36
  shape: string;
26
37
  coords: string;
@@ -28,6 +39,10 @@ export interface GraphicOrderData {
28
39
  classes?: string[];
29
40
  }>;
30
41
  prompt: string | null;
42
+ /** Minimum number of hotspots the response must order (QTI minChoices); omitted when 0. */
43
+ minChoices?: number;
44
+ /** Maximum number of hotspots the response may order (QTI maxChoices); omitted when 0. */
45
+ maxChoices?: number;
31
46
  }
32
47
  /**
33
48
  * Standard QTI graphic order interaction extractor
@@ -3,7 +3,10 @@
3
3
  *
4
4
  * Extracts data from graphicOrderInteraction elements (order items on image)
5
5
  */
6
+ import { validateUniqueIdentifiers } from '../../extraction/utils.js';
6
7
  import { normalizePixelDimension } from '../../security/styleValues.js';
8
+ import { extractImageAlternative, imgAlternativeSource } from '../shared/imageAlt.js';
9
+ import { findInteractionImage } from '../shared/interactionImage.js';
7
10
  /**
8
11
  * Standard QTI graphic order interaction extractor
9
12
  * Handles graphicOrderInteraction elements (ordering hotspots on an image)
@@ -19,36 +22,53 @@ export const standardGraphicOrderExtractor = {
19
22
  return context.utils.matchesTag(element, 'graphicOrderInteraction');
20
23
  },
21
24
  extract(element, context) {
22
- const { utils } = context;
23
- // Extract image data from object element
24
- const objectElements = utils.getChildrenByTag(element, 'object');
25
+ const { utils, dom } = context;
26
+ // Extract image data from the object element (QTI 2.x) or an img element
27
+ // (QTI 3.0, plain or as a <picture>'s fallback img)
28
+ const interactionImage = findInteractionImage(element, utils);
25
29
  let imageData = null;
26
- if (objectElements.length > 0) {
27
- const objectElement = objectElements[0];
30
+ if (interactionImage?.kind === 'object') {
31
+ const objectElement = interactionImage.element;
28
32
  const type = utils.getAttribute(objectElement, 'type', '');
29
33
  const data = utils.getAttribute(objectElement, 'data', '');
30
- const width = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''), '500');
31
- const height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''), '300');
32
- if (type.startsWith('image/svg')) {
33
- // Extract inline SVG content - get full content including <svg> tag
34
- const content = utils.getHtmlContent(objectElement);
34
+ // The stage's pixel space: the authored width/height, when declared. Without
35
+ // them the renderer stages the raster at its natural size; a default here
36
+ // would silently place areas in a guessed space.
37
+ const width = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''));
38
+ const height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''));
39
+ const content = type.startsWith('image/svg') ? utils.getHtmlContent(objectElement) : '';
40
+ if (/<svg[\s>]/i.test(content)) {
41
+ // Inline SVG: <object type="image/svg+xml"><svg>...</svg></object>
35
42
  imageData = {
36
43
  type: 'svg',
37
44
  content,
38
45
  width,
39
46
  height,
47
+ ...extractImageAlternative(objectElement, utils, dom, { inlineSvgContent: content }),
40
48
  };
41
49
  }
42
50
  else {
43
- // External image reference
51
+ // External image (or SVG file) reference; the <object>'s text is its alternative
44
52
  imageData = {
45
53
  type: 'image',
46
54
  src: data,
47
55
  width,
48
56
  height,
57
+ ...extractImageAlternative(objectElement, utils, dom),
49
58
  };
50
59
  }
51
60
  }
61
+ else if (interactionImage) {
62
+ // QTI 3.0 <img>: the alt attribute is the text alternative (alt="" = decorative)
63
+ const imgElement = interactionImage.element;
64
+ imageData = {
65
+ type: 'image',
66
+ src: utils.getAttribute(imgElement, 'src', ''),
67
+ width: normalizePixelDimension(utils.getAttribute(imgElement, 'width', '')),
68
+ height: normalizePixelDimension(utils.getAttribute(imgElement, 'height', '')),
69
+ ...extractImageAlternative(imgElement, utils, dom, imgAlternativeSource(imgElement)),
70
+ };
71
+ }
52
72
  // Extract hotspotChoice children
53
73
  const hotspotElements = utils.getChildrenByTag(element, 'hotspotChoice');
54
74
  const hotspotChoices = hotspotElements.map((hotspot) => {
@@ -57,9 +77,9 @@ export const standardGraphicOrderExtractor = {
57
77
  const shape = utils.getAttribute(hotspot, 'shape', 'rect');
58
78
  const coords = utils.getAttribute(hotspot, 'coords', '0,0,50,50');
59
79
  const fixed = utils.getBooleanAttribute(hotspot, 'fixed');
60
- // Get text content as label, use identifier as fallback
61
- const textContent = utils.getTextContent(hotspot).trim();
62
- const label = textContent || identifier;
80
+ // The authored label: hotspotLabel (QTI 2.2 / 3.0), else the choice's text.
81
+ // No identifier fallback — identifiers can reveal the answer key.
82
+ const label = utils.getAttribute(hotspot, 'hotspotLabel', '').trim() || utils.getTextContent(hotspot).trim();
63
83
  return {
64
84
  identifier,
65
85
  label,
@@ -72,10 +92,14 @@ export const standardGraphicOrderExtractor = {
72
92
  // Extract prompt (optional)
73
93
  const promptElements = utils.getChildrenByTag(element, 'prompt');
74
94
  const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
95
+ const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
96
+ const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 0);
75
97
  return {
76
98
  imageData,
77
99
  hotspotChoices,
78
100
  prompt,
101
+ ...(minChoices > 0 ? { minChoices } : {}),
102
+ ...(maxChoices > 0 ? { maxChoices } : {}),
79
103
  };
80
104
  },
81
105
  validate(data) {
@@ -97,17 +121,8 @@ export const standardGraphicOrderExtractor = {
97
121
  }
98
122
  // Validate hotspot choice identifiers and coords
99
123
  if (data.hotspotChoices) {
100
- const identifiers = new Set();
124
+ validateUniqueIdentifiers(data.hotspotChoices, errors, { plural: 'hotspot choices', noun: 'hotspot' });
101
125
  for (const hotspot of data.hotspotChoices) {
102
- if (!hotspot.identifier) {
103
- errors.push('All hotspot choices must have an identifier');
104
- }
105
- else if (identifiers.has(hotspot.identifier)) {
106
- errors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);
107
- }
108
- else {
109
- identifiers.add(hotspot.identifier);
110
- }
111
126
  if (!hotspot.coords) {
112
127
  errors.push(`Hotspot ${hotspot.identifier} must have coords`);
113
128
  }