@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-order/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AA6BxE;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAuC;IAChF,EAAE,EAAE,+BAA+B;IACnC,IAAI,EAAE,wCAAwC;IAC9C,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,yBAAyB,CAAC;IACzC,WAAW,EAAE,sEAAsE;IAEnF,SAAS,CAAC,OAAO,EAAE,OAAO;QACzB,oDAAoD;QACpD,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;IACrE,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,EAAE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,CAAC,CAAC,SAAS;SACpD,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["/**\n * Standard QTI graphicOrderInteraction extractor\n *\n * Extracts data from graphicOrderInteraction elements (order 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 order 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 order data extracted from graphicOrderInteraction elements\n */\nexport interface GraphicOrderData {\n\timageData: ImageData | null;\n\thotspotChoices: Array<{\n\t\tidentifier: string;\n\t\tlabel: string;\n\t\tshape: string;\n\t\tcoords: string;\n\t\tfixed?: boolean;\n\t\tclasses?: string[];\n\t}>;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI graphic order interaction extractor\n * Handles graphicOrderInteraction elements (ordering hotspots on an image)\n */\nexport const standardGraphicOrderExtractor: ElementExtractor<GraphicOrderData> = {\n\tid: 'qti:graphic-order-interaction',\n\tname: 'QTI Standard Graphic Order Interaction',\n\tpriority: 10,\n\telementTypes: ['graphicOrderInteraction'],\n\tdescription: 'Extracts standard QTI graphicOrderInteraction (order items on image)',\n\n\tcanHandle(element, context) {\n\t\t// All graphicOrderInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'graphicOrderInteraction');\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 hotspotChoice children\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'hotspotChoice');\n\t\tconst hotspotChoices = 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 fixed = utils.getBooleanAttribute(hotspot, 'fixed');\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\t...(fixed ? { fixed } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\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\treturn {\n\t\t\timageData,\n\t\t\thotspotChoices,\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('graphicOrderInteraction has no image data');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('graphicOrderInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('graphicOrderInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate hotspot choices exist\n\t\tif (!data.hotspotChoices || data.hotspotChoices.length < 2) {\n\t\t\terrors.push('graphicOrderInteraction must have at least 2 hotspots');\n\t\t}\n\n\t\t// Validate hotspot choice identifiers and coords\n\t\tif (data.hotspotChoices) {\n\t\t\tconst identifiers = new Set<string>();\n\t\t\tfor (const hotspot of data.hotspotChoices) {\n\t\t\t\tif (!hotspot.identifier) {\n\t\t\t\t\terrors.push('All hotspot choices 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-order/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,uBAA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,CAAC;QAED,iDAAiD;QACjD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,yBAAyB,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;YAEvG,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBAC3C,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 graphicOrderInteraction extractor\n *\n * Extracts data from graphicOrderInteraction elements (order 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 order 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 order data extracted from graphicOrderInteraction elements\n */\nexport interface GraphicOrderData {\n\timageData: ImageData | null;\n\thotspotChoices: Array<{\n\t\tidentifier: string;\n\t\t/**\n\t\t * The hotspot's authored text. Empty when the author gave none: the\n\t\t * renderer then names it by position. Never the identifier, which can\n\t\t * leak the answer key to assistive technology.\n\t\t */\n\t\tlabel: string;\n\t\tshape: string;\n\t\tcoords: string;\n\t\tfixed?: boolean;\n\t\tclasses?: string[];\n\t}>;\n\tprompt: string | null;\n\t/** Minimum number of hotspots the response must order (QTI minChoices); omitted when 0. */\n\tminChoices?: number;\n\t/** Maximum number of hotspots the response may order (QTI maxChoices); omitted when 0. */\n\tmaxChoices?: number;\n}\n\n/**\n * Standard QTI graphic order interaction extractor\n * Handles graphicOrderInteraction elements (ordering hotspots on an image)\n */\nexport const standardGraphicOrderExtractor: ElementExtractor<GraphicOrderData> = {\n\tid: 'qti:graphic-order-interaction',\n\tname: 'QTI Standard Graphic Order Interaction',\n\tpriority: 10,\n\telementTypes: ['graphicOrderInteraction'],\n\tdescription: 'Extracts standard QTI graphicOrderInteraction (order items on image)',\n\n\tcanHandle(element, context) {\n\t\t// All graphicOrderInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'graphicOrderInteraction');\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 areas 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 hotspotChoice children\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'hotspotChoice');\n\t\tconst hotspotChoices = 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 fixed = utils.getBooleanAttribute(hotspot, 'fixed');\n\n\t\t\t// The authored label: hotspotLabel (QTI 2.2 / 3.0), else the choice'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\t...(fixed ? { fixed } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\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 minChoices = utils.getNumberAttribute(element, 'minChoices', 0);\n\t\tconst maxChoices = utils.getNumberAttribute(element, 'maxChoices', 0);\n\n\t\treturn {\n\t\t\timageData,\n\t\t\thotspotChoices,\n\t\t\tprompt,\n\t\t\t...(minChoices > 0 ? { minChoices } : {}),\n\t\t\t...(maxChoices > 0 ? { maxChoices } : {}),\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('graphicOrderInteraction has no image data');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('graphicOrderInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('graphicOrderInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate hotspot choices exist\n\t\tif (!data.hotspotChoices || data.hotspotChoices.length < 2) {\n\t\t\terrors.push('graphicOrderInteraction must have at least 2 hotspots');\n\t\t}\n\n\t\t// Validate hotspot choice identifiers and coords\n\t\tif (data.hotspotChoices) {\n\t\t\tvalidateUniqueIdentifiers(data.hotspotChoices, errors, { plural: 'hotspot choices', noun: 'hotspot' });\n\n\t\t\tfor (const hotspot of data.hotspotChoices) {\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"]}
@@ -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
  * Hotspot data extracted from hotspotInteraction elements
@@ -3,7 +3,10 @@
3
3
  *
4
4
  * Extracts data from hotspotInteraction elements (clickable areas 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 hotspot interaction extractor
9
12
  * Handles hotspotInteraction elements (clickable areas on an image)
@@ -19,16 +22,19 @@ export const standardHotspotExtractor = {
19
22
  return context.utils.matchesTag(element, 'hotspotInteraction');
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
34
  const width = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''));
31
35
  const height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''));
36
+ // Author-provided text alternative (WCAG 1.1.1): aria-* on the element,
37
+ // inline SVG <title>/<desc>, or the <object>'s fallback text content.
32
38
  if (type.startsWith('image/svg')) {
33
39
  // Inline SVG: <object type="image/svg+xml"><svg>...</svg></object>
34
40
  // External SVG: <object type="image/svg+xml" data="path/to/file.svg"/>
@@ -41,6 +47,7 @@ export const standardHotspotExtractor = {
41
47
  content,
42
48
  ...(width ? { width } : {}),
43
49
  ...(height ? { height } : {}),
50
+ ...extractImageAlternative(objectElement, utils, dom, { inlineSvgContent: content }),
44
51
  };
45
52
  }
46
53
  else {
@@ -50,6 +57,7 @@ export const standardHotspotExtractor = {
50
57
  src: data,
51
58
  ...(width ? { width } : {}),
52
59
  ...(height ? { height } : {}),
60
+ ...extractImageAlternative(objectElement, utils, dom),
53
61
  };
54
62
  }
55
63
  }
@@ -60,9 +68,23 @@ export const standardHotspotExtractor = {
60
68
  src: data,
61
69
  ...(width ? { width } : {}),
62
70
  ...(height ? { height } : {}),
71
+ ...extractImageAlternative(objectElement, utils, dom),
63
72
  };
64
73
  }
65
74
  }
75
+ else if (interactionImage) {
76
+ // QTI 3.0 <img>: the alt attribute is the text alternative (alt="" = decorative)
77
+ const imgElement = interactionImage.element;
78
+ const width = normalizePixelDimension(utils.getAttribute(imgElement, 'width', ''));
79
+ const height = normalizePixelDimension(utils.getAttribute(imgElement, 'height', ''));
80
+ imageData = {
81
+ type: 'image',
82
+ src: utils.getAttribute(imgElement, 'src', ''),
83
+ ...(width ? { width } : {}),
84
+ ...(height ? { height } : {}),
85
+ ...extractImageAlternative(imgElement, utils, dom, imgAlternativeSource(imgElement)),
86
+ };
87
+ }
66
88
  // Extract hotspotChoice children
67
89
  const hotspotElements = utils.getChildrenByTag(element, 'hotspotChoice');
68
90
  const hotspotChoices = hotspotElements.map((hotspot) => {
@@ -117,18 +139,11 @@ export const standardHotspotExtractor = {
117
139
  }
118
140
  // Validate hotspot identifiers and coords
119
141
  if (data.hotspotChoices && data.hotspotChoices.length > 0) {
120
- const identifiers = new Set();
142
+ validateUniqueIdentifiers(data.hotspotChoices, errors, { plural: 'hotspots', noun: 'hotspot' });
121
143
  for (const hotspot of data.hotspotChoices) {
122
- if (!hotspot.identifier) {
123
- errors.push('All hotspots must have an identifier');
124
- }
125
- else if (identifiers.has(hotspot.identifier)) {
126
- errors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);
127
- }
128
- else {
129
- identifiers.add(hotspot.identifier);
130
- }
131
- if (!hotspot.coords) {
144
+ // The default shape is the whole image (QTI 3.0 §8.29 ShapeEnum), so its coords
145
+ // say nothing; every other shape is placed by them.
146
+ if (!hotspot.coords && hotspot.shape !== 'default') {
132
147
  errors.push(`Hotspot ${hotspot.identifier} must have coords`);
133
148
  }
134
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/hotspot/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AA8BxE;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkC;IACtE,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,kCAAkC;IACxC,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,oBAAoB,CAAC;IACpC,WAAW,EAAE,qEAAqE;IAElF,SAAS,CAAC,OAAO,EAAE,OAAO;QACzB,+CAA+C;QAC/C,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACv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,CAAC;QACpD,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 hotspotInteraction extractor\n *\n * Extracts data from hotspotInteraction elements (clickable areas on image)\n */\n\nimport type { ElementExtractor } from '../../extraction/types.js';\nimport { normalizePixelDimension } from '../../security/styleValues.js';\n\n/**\n * Image data for hotspot 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 * Hotspot data extracted from hotspotInteraction elements\n */\nexport interface HotspotData {\n\timageData: ImageData | null;\n\thotspotChoices: Array<{\n\t\tidentifier: string;\n\t\tshape: 'circle' | 'rect' | 'poly' | 'ellipse' | 'default';\n\t\tcoords: string;\n\t\thotspotLabel?: string;\n\t\tclasses?: string[];\n\t}>;\n\tmaxChoices: number;\n\tminChoices?: number;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI hotspot interaction extractor\n * Handles hotspotInteraction elements (clickable areas on an image)\n */\nexport const standardHotspotExtractor: ElementExtractor<HotspotData> = {\n\tid: 'qti:hotspot-interaction',\n\tname: 'QTI Standard Hotspot Interaction',\n\tpriority: 10,\n\telementTypes: ['hotspotInteraction'],\n\tdescription: 'Extracts standard QTI hotspotInteraction (clickable areas on image)',\n\n\tcanHandle(element, context) {\n\t\t// All hotspotInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'hotspotInteraction');\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(utils.getAttribute(objectElement, 'width', ''));\n\t\t\tconst height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''));\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> (SVG renders in img tags)\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 hotspotChoice children\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'hotspotChoice');\n\t\tconst hotspotChoices = hotspotElements.map((hotspot) => {\n\t\t\tconst classes = utils.getClasses(hotspot);\n\t\t\tconst shape = utils.getAttribute(hotspot, 'shape', 'rect');\n\t\t\tconst coords = utils.getAttribute(hotspot, 'coords', '');\n\t\t\tconst hotspotLabel = utils.getAttribute(hotspot, 'hotspotLabel', '');\n\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(hotspot, 'identifier', ''),\n\t\t\t\tshape: shape as 'circle' | 'rect' | 'poly' | 'ellipse' | 'default',\n\t\t\t\tcoords,\n\t\t\t\t...(hotspotLabel ? { hotspotLabel } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract attributes\n\t\tconst maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);\n\t\tconst minChoices = utils.getNumberAttribute(element, 'minChoices', 0);\n\t\tconst interactionClasses = utils.getClasses(element);\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\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\thotspotChoices,\n\t\t\tmaxChoices,\n\t\t\t...(minChoices > 0 ? { minChoices } : {}),\n\t\t\tprompt,\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\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\n\t\tif (!data.imageData) {\n\t\t\twarnings.push('hotspotInteraction has no image data');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('hotspotInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('hotspotInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate hotspots exist\n\t\tif (!data.hotspotChoices || data.hotspotChoices.length === 0) {\n\t\t\terrors.push('hotspotInteraction must have at least one hotspot');\n\t\t}\n\n\t\t// Validate hotspot identifiers and coords\n\t\tif (data.hotspotChoices && data.hotspotChoices.length > 0) {\n\t\t\tconst identifiers = new Set<string>();\n\t\t\tfor (const hotspot of data.hotspotChoices) {\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\n\t\t\t// Warn if maxChoices exceeds hotspot count\n\t\t\tif (data.maxChoices > data.hotspotChoices.length) {\n\t\t\t\twarnings.push(\n\t\t\t\t\t`maxChoices (${data.maxChoices}) exceeds the number of hotspots (${data.hotspotChoices.length})`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Validate maxChoices\n\t\tif (data.maxChoices < 0) {\n\t\t\terrors.push('maxChoices must be non-negative');\n\t\t}\n\n\t\t// Validate minChoices\n\t\tif (data.minChoices !== undefined && data.minChoices < 0) {\n\t\t\terrors.push('minChoices must be non-negative');\n\t\t}\n\n\t\t// Validate minChoices <= maxChoices\n\t\tif (\n\t\t\tdata.minChoices !== undefined &&\n\t\t\tdata.maxChoices > 0 &&\n\t\t\tdata.minChoices > data.maxChoices\n\t\t) {\n\t\t\terrors.push('minChoices cannot exceed maxChoices');\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/hotspot/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;AAoCrE;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkC;IACtE,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,kCAAkC;IACxC,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,oBAAoB,CAAC;IACpC,WAAW,EAAE,qEAAqE;IAElF,SAAS,CAAC,OAAO,EAAE,OAAO;QACzB,+CAA+C;QAC/C,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QAE/B,yEAAyE;QACzE,oDAAoD;QACpD,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC9D,IAAI,SAAS,GAAqB,IAAI,CAAC;QAEvC,IAAI,gBAAgB,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC;YAC/C,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa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AAsB;QACtB,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAChD,CAAC;QAED,oCAAoC;QACpC,IACC,IAAI,CAAC,UAAU,KAAK,SAAS;YAC7B,IAAI,CAAC,UAAU,GAAG,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAChC,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACpD,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 hotspotInteraction extractor\n *\n * Extracts data from hotspotInteraction elements (clickable areas 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 hotspot 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 * Hotspot data extracted from hotspotInteraction elements\n */\nexport interface HotspotData {\n\timageData: ImageData | null;\n\thotspotChoices: Array<{\n\t\tidentifier: string;\n\t\tshape: 'circle' | 'rect' | 'poly' | 'ellipse' | 'default';\n\t\tcoords: string;\n\t\thotspotLabel?: string;\n\t\tclasses?: string[];\n\t}>;\n\tmaxChoices: number;\n\tminChoices?: number;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI hotspot interaction extractor\n * Handles hotspotInteraction elements (clickable areas on an image)\n */\nexport const standardHotspotExtractor: ElementExtractor<HotspotData> = {\n\tid: 'qti:hotspot-interaction',\n\tname: 'QTI Standard Hotspot Interaction',\n\tpriority: 10,\n\telementTypes: ['hotspotInteraction'],\n\tdescription: 'Extracts standard QTI hotspotInteraction (clickable areas on image)',\n\n\tcanHandle(element, context) {\n\t\t// All hotspotInteraction elements are standard\n\t\treturn context.utils.matchesTag(element, 'hotspotInteraction');\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 width = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''));\n\t\t\tconst height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''));\n\n\t\t\t// Author-provided text alternative (WCAG 1.1.1): aria-* on the element,\n\t\t\t// inline SVG <title>/<desc>, or the <object>'s fallback text content.\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> (SVG renders in img tags)\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 width = normalizePixelDimension(utils.getAttribute(imgElement, 'width', ''));\n\t\t\tconst height = 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...(width ? { width } : {}),\n\t\t\t\t...(height ? { height } : {}),\n\t\t\t\t...extractImageAlternative(imgElement, utils, dom, imgAlternativeSource(imgElement)),\n\t\t\t};\n\t\t}\n\n\t\t// Extract hotspotChoice children\n\t\tconst hotspotElements = utils.getChildrenByTag(element, 'hotspotChoice');\n\t\tconst hotspotChoices = hotspotElements.map((hotspot) => {\n\t\t\tconst classes = utils.getClasses(hotspot);\n\t\t\tconst shape = utils.getAttribute(hotspot, 'shape', 'rect');\n\t\t\tconst coords = utils.getAttribute(hotspot, 'coords', '');\n\t\t\tconst hotspotLabel = utils.getAttribute(hotspot, 'hotspotLabel', '');\n\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(hotspot, 'identifier', ''),\n\t\t\t\tshape: shape as 'circle' | 'rect' | 'poly' | 'ellipse' | 'default',\n\t\t\t\tcoords,\n\t\t\t\t...(hotspotLabel ? { hotspotLabel } : {}),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract attributes\n\t\tconst maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);\n\t\tconst minChoices = utils.getNumberAttribute(element, 'minChoices', 0);\n\t\tconst interactionClasses = utils.getClasses(element);\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\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\thotspotChoices,\n\t\t\tmaxChoices,\n\t\t\t...(minChoices > 0 ? { minChoices } : {}),\n\t\t\tprompt,\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\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\n\t\tif (!data.imageData) {\n\t\t\twarnings.push('hotspotInteraction has no image data');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('hotspotInteraction must have an image URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('hotspotInteraction must have SVG content');\n\t\t}\n\n\t\t// Validate hotspots exist\n\t\tif (!data.hotspotChoices || data.hotspotChoices.length === 0) {\n\t\t\terrors.push('hotspotInteraction must have at least one hotspot');\n\t\t}\n\n\t\t// Validate hotspot identifiers and coords\n\t\tif (data.hotspotChoices && data.hotspotChoices.length > 0) {\n\t\t\tvalidateUniqueIdentifiers(data.hotspotChoices, errors, { plural: 'hotspots', noun: 'hotspot' });\n\n\t\t\tfor (const hotspot of data.hotspotChoices) {\n\t\t\t\t// The default shape is the whole image (QTI 3.0 §8.29 ShapeEnum), so its coords\n\t\t\t\t// say nothing; every other shape is placed by them.\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\n\t\t\t// Warn if maxChoices exceeds hotspot count\n\t\t\tif (data.maxChoices > data.hotspotChoices.length) {\n\t\t\t\twarnings.push(\n\t\t\t\t\t`maxChoices (${data.maxChoices}) exceeds the number of hotspots (${data.hotspotChoices.length})`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Validate maxChoices\n\t\tif (data.maxChoices < 0) {\n\t\t\terrors.push('maxChoices must be non-negative');\n\t\t}\n\n\t\t// Validate minChoices\n\t\tif (data.minChoices !== undefined && data.minChoices < 0) {\n\t\t\terrors.push('minChoices must be non-negative');\n\t\t}\n\n\t\t// Validate minChoices <= maxChoices\n\t\tif (\n\t\t\tdata.minChoices !== undefined &&\n\t\t\tdata.maxChoices > 0 &&\n\t\t\tdata.minChoices > data.maxChoices\n\t\t) {\n\t\t\terrors.push('minChoices cannot exceed maxChoices');\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"]}
@@ -4,6 +4,7 @@
4
4
  * Extracts data from hottextInteraction elements (select text spans)
5
5
  */
6
6
  import { sanitizeHtml } from '../../core/sanitizer.js';
7
+ import { validateUniqueIdentifiers } from '../../extraction/utils.js';
7
8
  /**
8
9
  * Standard QTI hottext interaction extractor
9
10
  * Handles hottextInteraction elements (selectable text spans)
@@ -88,18 +89,7 @@ export const standardHottextExtractor = {
88
89
  }
89
90
  // Validate hottext identifiers
90
91
  if (data.hottextChoices) {
91
- const identifiers = new Set();
92
- for (const hottext of data.hottextChoices) {
93
- if (!hottext.identifier) {
94
- errors.push('All hottext elements must have an identifier');
95
- }
96
- else if (identifiers.has(hottext.identifier)) {
97
- errors.push(`Duplicate hottext identifier: ${hottext.identifier}`);
98
- }
99
- else {
100
- identifiers.add(hottext.identifier);
101
- }
102
- }
92
+ validateUniqueIdentifiers(data.hottextChoices, errors, { plural: 'hottext elements', noun: 'hottext' });
103
93
  }
104
94
  // Validate maxChoices
105
95
  if (data.maxChoices < 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/hottext/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAevD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkC;IACtE,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,kCAAkC;IACxC,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,oBAAoB,CAAC;IACpC,WAAW,EAAE,8DAA8D;IAE3E,SAAS,CAAC,OAAO,EAAE,QAAQ;QAC1B,+CAA+C;QAC/C,OAAO,OAAO,CAAC,UAAU,KAAK,oBAAoB,IAAI,OAAO,CAAC,UAAU,KAAK,yBAAyB,CAAC;IACxG,CAAC;IAED,OAAO,CAAC,OAA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AAG,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAChD,CAAC;QAED,2CAA2C;QAC3C,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;YACzE,QAAQ,CAAC,IAAI,CACZ,eAAe,IAAI,CAAC,UAAU,4CAA4C,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CACvG,CAAC;QACH,CAAC;QAED,sBAAsB;QACtB,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAChD,CAAC;QAED,oCAAoC;QACpC,IACC,IAAI,CAAC,UAAU,KAAK,SAAS;YAC7B,IAAI,CAAC,UAAU,GAAG,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAChC,CAAC;YACF,QAAQ,CAAC,IAAI,CACZ,eAAe,IAAI,CAAC,UAAU,yBAAyB,IAAI,CAAC,UAAU,4DAA4D,CAClI,CAAC;QACH,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 hottextInteraction extractor\n *\n * Extracts data from hottextInteraction elements (select text spans)\n */\n\nimport { sanitizeHtml } from '../../core/sanitizer.js';\nimport type { QTIElement } from '../shared/types.js';\nimport type { ElementExtractor } from '../../extraction/types.js';\n\n/**\n * Hottext data extracted from hottextInteraction elements\n */\nexport interface HottextData {\n\thottextChoices: Array<{ identifier: string; text: string; classes?: string[] }>;\n\tcontentHtml: string;\n\tmaxChoices: number;\n\tminChoices: number;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI hottext interaction extractor\n * Handles hottextInteraction elements (selectable text spans)\n */\nexport const standardHottextExtractor: ElementExtractor<HottextData> = {\n\tid: 'qti:hottext-interaction',\n\tname: 'QTI Standard Hottext Interaction',\n\tpriority: 10,\n\telementTypes: ['hottextInteraction'],\n\tdescription: 'Extracts standard QTI hottextInteraction (select text spans)',\n\n\tcanHandle(element, _context) {\n\t\t// All hottextInteraction elements are standard\n\t\treturn element.rawTagName === 'hottextInteraction' || element.rawTagName === 'qti-hottext-interaction';\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\n\t\t// Extract hottext children (selectable text spans) - recursively search entire tree\n\t\tconst findHottextElements = (el: any): any[] => {\n\t\t\tconst results: any[] = [];\n\t\t\tif (el.rawTagName === 'hottext' || el.rawTagName === 'qti-hottext') {\n\t\t\t\tresults.push(el);\n\t\t\t}\n\t\t\tif (el.childNodes) {\n\t\t\t\tfor (const child of el.childNodes) {\n\t\t\t\t\tif (typeof child !== 'string') {\n\t\t\t\t\t\tresults.push(...findHottextElements(child));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t};\n\n\t\tconst hottextElements = findHottextElements(element);\n\t\tconst hottextChoices = hottextElements.map((hottext) => {\n\t\t\tconst classes = utils.getClasses(hottext);\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(hottext, 'identifier', ''),\n\t\t\t\ttext: utils.getTextContent(hottext),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract attributes\n\t\tconst maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);\n\t\tconst minChoices = utils.getNumberAttribute(element, 'minChoices', 0);\n\t\tconst interactionClasses = utils.getClasses(element);\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\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\t// Extract content HTML (all content except prompt)\n\t\tlet contentHtml = '';\n\t\tfor (const child of element.childNodes) {\n\t\t\t// Skip prompt elements\n\t\t\tif (\n\t\t\t\ttypeof child !== 'string' &&\n\t\t\t\t(child as QTIElement).rawTagName !== 'prompt' &&\n\t\t\t\t(child as QTIElement).rawTagName !== 'qti-prompt'\n\t\t\t) {\n\t\t\t\tcontentHtml += (child as QTIElement).outerHTML || child.toString();\n\t\t\t} else if (typeof child === 'string') {\n\t\t\t\tcontentHtml += child;\n\t\t\t}\n\t\t}\n\n\t\t// Sanitize extracted HTML before rendering via {@html} in the component.\n\t\tcontentHtml = sanitizeHtml(contentHtml, { security: context.config.security });\n\n\t\treturn {\n\t\t\thottextChoices,\n\t\t\tcontentHtml,\n\t\t\tmaxChoices,\n\t\t\tminChoices,\n\t\t\tprompt,\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\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 hottextChoices exist\n\t\tif (!data.hottextChoices || data.hottextChoices.length === 0) {\n\t\t\terrors.push('hottextInteraction must have at least one hottext');\n\t\t}\n\n\t\t// Validate hottext identifiers\n\t\tif (data.hottextChoices) {\n\t\t\tconst identifiers = new Set<string>();\n\t\t\tfor (const hottext of data.hottextChoices) {\n\t\t\t\tif (!hottext.identifier) {\n\t\t\t\t\terrors.push('All hottext elements must have an identifier');\n\t\t\t\t} else if (identifiers.has(hottext.identifier)) {\n\t\t\t\t\terrors.push(`Duplicate hottext identifier: ${hottext.identifier}`);\n\t\t\t\t} else {\n\t\t\t\t\tidentifiers.add(hottext.identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Validate maxChoices\n\t\tif (data.maxChoices < 0) {\n\t\t\terrors.push('maxChoices must be non-negative');\n\t\t}\n\n\t\t// Warn if maxChoices exceeds hottext count\n\t\tif (data.hottextChoices && data.maxChoices > data.hottextChoices.length) {\n\t\t\twarnings.push(\n\t\t\t\t`maxChoices (${data.maxChoices}) exceeds the number of hottext choices (${data.hottextChoices.length})`\n\t\t\t);\n\t\t}\n\n\t\t// Validate minChoices\n\t\tif (data.minChoices !== undefined && data.minChoices < 0) {\n\t\t\terrors.push('minChoices must be non-negative');\n\t\t}\n\n\t\t// Validate minChoices <= maxChoices\n\t\tif (\n\t\t\tdata.minChoices !== undefined &&\n\t\t\tdata.maxChoices > 0 &&\n\t\t\tdata.minChoices > data.maxChoices\n\t\t) {\n\t\t\twarnings.push(\n\t\t\t\t`minChoices (${data.minChoices}) exceeds maxChoices (${data.maxChoices}); rendering interaction with authoring constraint warning`\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/hottext/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAatE;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkC;IACtE,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,kCAAkC;IACxC,QAAQ,EAAE,EAAE;IACZ,YAAY,EAA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AI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;YACzE,QAAQ,CAAC,IAAI,CACZ,eAAe,IAAI,CAAC,UAAU,4CAA4C,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CACvG,CAAC;QACH,CAAC;QAED,sBAAsB;QACtB,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAChD,CAAC;QAED,oCAAoC;QACpC,IACC,IAAI,CAAC,UAAU,KAAK,SAAS;YAC7B,IAAI,CAAC,UAAU,GAAG,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAChC,CAAC;YACF,QAAQ,CAAC,IAAI,CACZ,eAAe,IAAI,CAAC,UAAU,yBAAyB,IAAI,CAAC,UAAU,4DAA4D,CAClI,CAAC;QACH,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 hottextInteraction extractor\n *\n * Extracts data from hottextInteraction elements (select text spans)\n */\n\nimport { sanitizeHtml } from '../../core/sanitizer.js';\nimport type { QTIElement } from '../shared/types.js';\nimport type { ElementExtractor } from '../../extraction/types.js';\nimport { validateUniqueIdentifiers } from '../../extraction/utils.js';\n\n/**\n * Hottext data extracted from hottextInteraction elements\n */\nexport interface HottextData {\n\thottextChoices: Array<{ identifier: string; text: string; classes?: string[] }>;\n\tcontentHtml: string;\n\tmaxChoices: number;\n\tminChoices: number;\n\tprompt: string | null;\n}\n\n/**\n * Standard QTI hottext interaction extractor\n * Handles hottextInteraction elements (selectable text spans)\n */\nexport const standardHottextExtractor: ElementExtractor<HottextData> = {\n\tid: 'qti:hottext-interaction',\n\tname: 'QTI Standard Hottext Interaction',\n\tpriority: 10,\n\telementTypes: ['hottextInteraction'],\n\tdescription: 'Extracts standard QTI hottextInteraction (select text spans)',\n\n\tcanHandle(element, _context) {\n\t\t// All hottextInteraction elements are standard\n\t\treturn element.rawTagName === 'hottextInteraction' || element.rawTagName === 'qti-hottext-interaction';\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\n\t\t// Extract hottext children (selectable text spans) - recursively search entire tree\n\t\tconst findHottextElements = (el: any): any[] => {\n\t\t\tconst results: any[] = [];\n\t\t\tif (el.rawTagName === 'hottext' || el.rawTagName === 'qti-hottext') {\n\t\t\t\tresults.push(el);\n\t\t\t}\n\t\t\tif (el.childNodes) {\n\t\t\t\tfor (const child of el.childNodes) {\n\t\t\t\t\tif (typeof child !== 'string') {\n\t\t\t\t\t\tresults.push(...findHottextElements(child));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t};\n\n\t\tconst hottextElements = findHottextElements(element);\n\t\tconst hottextChoices = hottextElements.map((hottext) => {\n\t\t\tconst classes = utils.getClasses(hottext);\n\t\t\treturn {\n\t\t\t\tidentifier: utils.getAttribute(hottext, 'identifier', ''),\n\t\t\t\ttext: utils.getTextContent(hottext),\n\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t};\n\t\t});\n\n\t\t// Extract attributes\n\t\tconst maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);\n\t\tconst minChoices = utils.getNumberAttribute(element, 'minChoices', 0);\n\t\tconst interactionClasses = utils.getClasses(element);\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\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\t// Extract content HTML (all content except prompt)\n\t\tlet contentHtml = '';\n\t\tfor (const child of element.childNodes) {\n\t\t\t// Skip prompt elements\n\t\t\tif (\n\t\t\t\ttypeof child !== 'string' &&\n\t\t\t\t(child as QTIElement).rawTagName !== 'prompt' &&\n\t\t\t\t(child as QTIElement).rawTagName !== 'qti-prompt'\n\t\t\t) {\n\t\t\t\tcontentHtml += (child as QTIElement).outerHTML || child.toString();\n\t\t\t} else if (typeof child === 'string') {\n\t\t\t\tcontentHtml += child;\n\t\t\t}\n\t\t}\n\n\t\t// Sanitize extracted HTML before rendering via {@html} in the component.\n\t\tcontentHtml = sanitizeHtml(contentHtml, { security: context.config.security });\n\n\t\treturn {\n\t\t\thottextChoices,\n\t\t\tcontentHtml,\n\t\t\tmaxChoices,\n\t\t\tminChoices,\n\t\t\tprompt,\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\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 hottextChoices exist\n\t\tif (!data.hottextChoices || data.hottextChoices.length === 0) {\n\t\t\terrors.push('hottextInteraction must have at least one hottext');\n\t\t}\n\n\t\t// Validate hottext identifiers\n\t\tif (data.hottextChoices) {\n\t\t\tvalidateUniqueIdentifiers(data.hottextChoices, errors, { plural: 'hottext elements', noun: 'hottext' });\n\t\t}\n\n\t\t// Validate maxChoices\n\t\tif (data.maxChoices < 0) {\n\t\t\terrors.push('maxChoices must be non-negative');\n\t\t}\n\n\t\t// Warn if maxChoices exceeds hottext count\n\t\tif (data.hottextChoices && data.maxChoices > data.hottextChoices.length) {\n\t\t\twarnings.push(\n\t\t\t\t`maxChoices (${data.maxChoices}) exceeds the number of hottext choices (${data.hottextChoices.length})`\n\t\t\t);\n\t\t}\n\n\t\t// Validate minChoices\n\t\tif (data.minChoices !== undefined && data.minChoices < 0) {\n\t\t\terrors.push('minChoices must be non-negative');\n\t\t}\n\n\t\t// Validate minChoices <= maxChoices\n\t\tif (\n\t\t\tdata.minChoices !== undefined &&\n\t\t\tdata.maxChoices > 0 &&\n\t\t\tdata.minChoices > data.maxChoices\n\t\t) {\n\t\t\twarnings.push(\n\t\t\t\t`minChoices (${data.minChoices}) exceeds maxChoices (${data.maxChoices}); rendering interaction with authoring constraint warning`\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"]}
@@ -0,0 +1,29 @@
1
+ import { type I18nProvider } from '@pie-qti/i18n';
2
+ import type { InlineInteractionPosition } from '../../presentation/itemPresentationPlan.js';
3
+ interface NameableInlineInteraction {
4
+ readonly accessibility?: {
5
+ readonly label?: string;
6
+ };
7
+ readonly title?: string;
8
+ }
9
+ /**
10
+ * The accessible name of an inline interaction: its authored label (`aria-labelledby`,
11
+ * `aria-label`, then `title`), else its position among the item's inline interactions in
12
+ * document order ("Blank 2 of 4").
13
+ *
14
+ * Never the response identifier. Identifiers are author data (`RESPONSE_3`, or worse
15
+ * `CAPITAL_PARIS`): they mean nothing to a candidate and can hint at the answer, and an
16
+ * accessible name exposes them to screen-reader users only, which makes the item unequal.
17
+ */
18
+ export declare function inlineInteractionLabel(i18n: I18nProvider | undefined, interaction: NameableInlineInteraction, position: InlineInteractionPosition): string;
19
+ /**
20
+ * The message for a text entry whose answer does not match its pattern mask: the author's own
21
+ * message when there is one, else a localized sentence that names the expected format by the
22
+ * item's placeholder hint when it has one. The pattern mask itself is an XSD regular expression,
23
+ * which no candidate can be expected to read, so it is never shown.
24
+ */
25
+ export declare function textEntryPatternMessage(i18n: I18nProvider | undefined, interaction: {
26
+ readonly patternMaskMessage?: string | null;
27
+ readonly placeholderText?: string;
28
+ }): string;
29
+ export {};
@@ -0,0 +1,35 @@
1
+ import { translate } from '@pie-qti/i18n';
2
+ /**
3
+ * The accessible name of an inline interaction: its authored label (`aria-labelledby`,
4
+ * `aria-label`, then `title`), else its position among the item's inline interactions in
5
+ * document order ("Blank 2 of 4").
6
+ *
7
+ * Never the response identifier. Identifiers are author data (`RESPONSE_3`, or worse
8
+ * `CAPITAL_PARIS`): they mean nothing to a candidate and can hint at the answer, and an
9
+ * accessible name exposes them to screen-reader users only, which makes the item unequal.
10
+ */
11
+ export function inlineInteractionLabel(i18n, interaction, position) {
12
+ const authored = interaction.accessibility?.label?.trim() || interaction.title?.trim();
13
+ if (authored)
14
+ return authored;
15
+ return translate(i18n, 'interactions.inline.blankLabel', 'Blank {index} of {count}', {
16
+ index: position.index,
17
+ count: position.count,
18
+ });
19
+ }
20
+ /**
21
+ * The message for a text entry whose answer does not match its pattern mask: the author's own
22
+ * message when there is one, else a localized sentence that names the expected format by the
23
+ * item's placeholder hint when it has one. The pattern mask itself is an XSD regular expression,
24
+ * which no candidate can be expected to read, so it is never shown.
25
+ */
26
+ export function textEntryPatternMessage(i18n, interaction) {
27
+ const authored = interaction.patternMaskMessage?.trim();
28
+ if (authored)
29
+ return authored;
30
+ const hint = interaction.placeholderText?.trim();
31
+ return hint
32
+ ? translate(i18n, 'interactions.inline.patternMismatchWithHint', 'This answer is not in the expected format. Use this format: {hint}', { hint })
33
+ : translate(i18n, 'interactions.inline.patternMismatch', 'This answer is not in the expected format.');
34
+ }
35
+ //# sourceMappingURL=accessibleName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessibleName.js","sourceRoot":"","sources":["../../../src/interactions/inline/accessibleName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,eAAe,CAAC;AAQ7D;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACrC,IAA8B,EAC9B,WAAsC,EACtC,QAAmC;IAEnC,MAAM,QAAQ,GAAG,WAAW,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;IACvF,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,OAAO,SAAS,CAAC,IAAI,EAAE,gCAAgC,EAAE,0BAA0B,EAAE;QACpF,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,KAAK,EAAE,QAAQ,CAAC,KAAK;KACrB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACtC,IAA8B,EAC9B,WAA+F;IAE/F,MAAM,QAAQ,GAAG,WAAW,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC;IACxD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,IAAI,GAAG,WAAW,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;IACjD,OAAO,IAAI;QACV,CAAC,CAAC,SAAS,CACT,IAAI,EACJ,6CAA6C,EAC7C,oEAAoE,EACpE,EAAE,IAAI,EAAE,CACR;QACF,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,qCAAqC,EAAE,4CAA4C,CAAC,CAAC;AACzG,CAAC","sourcesContent":["import { translate, type I18nProvider } from '@pie-qti/i18n';\nimport type { InlineInteractionPosition } from '../../presentation/itemPresentationPlan.js';\n\ninterface NameableInlineInteraction {\n\treadonly accessibility?: { readonly label?: string };\n\treadonly title?: string;\n}\n\n/**\n * The accessible name of an inline interaction: its authored label (`aria-labelledby`,\n * `aria-label`, then `title`), else its position among the item's inline interactions in\n * document order (\"Blank 2 of 4\").\n *\n * Never the response identifier. Identifiers are author data (`RESPONSE_3`, or worse\n * `CAPITAL_PARIS`): they mean nothing to a candidate and can hint at the answer, and an\n * accessible name exposes them to screen-reader users only, which makes the item unequal.\n */\nexport function inlineInteractionLabel(\n\ti18n: I18nProvider | undefined,\n\tinteraction: NameableInlineInteraction,\n\tposition: InlineInteractionPosition\n): string {\n\tconst authored = interaction.accessibility?.label?.trim() || interaction.title?.trim();\n\tif (authored) return authored;\n\treturn translate(i18n, 'interactions.inline.blankLabel', 'Blank {index} of {count}', {\n\t\tindex: position.index,\n\t\tcount: position.count,\n\t});\n}\n\n/**\n * The message for a text entry whose answer does not match its pattern mask: the author's own\n * message when there is one, else a localized sentence that names the expected format by the\n * item's placeholder hint when it has one. The pattern mask itself is an XSD regular expression,\n * which no candidate can be expected to read, so it is never shown.\n */\nexport function textEntryPatternMessage(\n\ti18n: I18nProvider | undefined,\n\tinteraction: { readonly patternMaskMessage?: string | null; readonly placeholderText?: string }\n): string {\n\tconst authored = interaction.patternMaskMessage?.trim();\n\tif (authored) return authored;\n\tconst hint = interaction.placeholderText?.trim();\n\treturn hint\n\t\t? translate(\n\t\t\t\ti18n,\n\t\t\t\t'interactions.inline.patternMismatchWithHint',\n\t\t\t\t'This answer is not in the expected format. Use this format: {hint}',\n\t\t\t\t{ hint }\n\t\t\t)\n\t\t: translate(i18n, 'interactions.inline.patternMismatch', 'This answer is not in the expected format.');\n}\n"]}
@@ -1,16 +1,7 @@
1
- import type { BaseInteractionData, InlineChoiceInteractionData, TextEntryInteractionData } from '../shared/types.js';
1
+ import type { InlineChoiceInteractionData, TextEntryInteractionData } from '../shared/types.js';
2
2
  export type InlineInteractionData = TextEntryInteractionData | InlineChoiceInteractionData;
3
- export type InlineRenderSegment = {
4
- type: 'html';
5
- content: string;
6
- } | {
7
- type: 'textEntry';
8
- interaction: TextEntryInteractionData;
9
- } | {
10
- type: 'inlineChoice';
11
- interaction: InlineChoiceInteractionData;
12
- };
3
+ /**
4
+ * Whether an interaction renders in sentence flow. Inline interactions are rendered by the item
5
+ * player itself, mounted into the slot that marks their authored position in the item body.
6
+ */
13
7
  export declare function isInlineInteractionType(type: string): type is InlineInteractionData['type'];
14
- export declare function isInlineInteractionTagName(tagName: string): boolean;
15
- export declare function createInlinePlaceholderHtml(html: string, interactions: readonly BaseInteractionData[]): string;
16
- export declare function createInlineRenderPlan(html: string, interactions: readonly BaseInteractionData[]): InlineRenderSegment[];
@@ -1,60 +1,9 @@
1
- import { isStandardInlineInteractionTagName, isStandardInlineInteractionType, } from '../modules.js';
1
+ import { isStandardInlineInteractionType } from '../modules.js';
2
+ /**
3
+ * Whether an interaction renders in sentence flow. Inline interactions are rendered by the item
4
+ * player itself, mounted into the slot that marks their authored position in the item body.
5
+ */
2
6
  export function isInlineInteractionType(type) {
3
7
  return isStandardInlineInteractionType(type);
4
8
  }
5
- export function isInlineInteractionTagName(tagName) {
6
- return isStandardInlineInteractionTagName(tagName);
7
- }
8
- export function createInlinePlaceholderHtml(html, interactions) {
9
- return html
10
- .replace(/<textEntryInteraction[^>]*responseIdentifier="([^"]+)"[^>]*?(?:\/>|><\/textEntryInteraction>)/gi, (match, responseId) => hasInlineInteraction(interactions, responseId, 'textEntryInteraction')
11
- ? placeholder('textEntry', responseId)
12
- : match)
13
- .replace(/<qti-text-entry-interaction[^>]*response-identifier="([^"]+)"[^>]*?(?:\/>|><\/qti-text-entry-interaction>)/gi, (match, responseId) => hasInlineInteraction(interactions, responseId, 'textEntryInteraction')
14
- ? placeholder('textEntry', responseId)
15
- : match)
16
- .replace(/<inlineChoiceInteraction[^>]*responseIdentifier="([^"]+)"[^>]*>[\s\S]*?<\/inlineChoiceInteraction>/gi, (match, responseId) => hasInlineInteraction(interactions, responseId, 'inlineChoiceInteraction')
17
- ? placeholder('inlineChoice', responseId)
18
- : match)
19
- .replace(/<qti-inline-choice-interaction[^>]*response-identifier="([^"]+)"[^>]*>[\s\S]*?<\/qti-inline-choice-interaction>/gi, (match, responseId) => hasInlineInteraction(interactions, responseId, 'inlineChoiceInteraction')
20
- ? placeholder('inlineChoice', responseId)
21
- : match);
22
- }
23
- export function createInlineRenderPlan(html, interactions) {
24
- const placeholderHtml = createInlinePlaceholderHtml(html, interactions);
25
- const result = [];
26
- const combinedPattern = /\[TEXTENTRY:([^\]]+)\]|\[INLINECHOICE:([^\]]+)\]/g;
27
- let lastIndex = 0;
28
- let match;
29
- while ((match = combinedPattern.exec(placeholderHtml)) !== null) {
30
- if (match.index > lastIndex) {
31
- result.push({ type: 'html', content: placeholderHtml.substring(lastIndex, match.index) });
32
- }
33
- if (match[0].startsWith('[TEXTENTRY:')) {
34
- const interaction = findInlineInteraction(interactions, match[1], 'textEntryInteraction');
35
- if (interaction)
36
- result.push({ type: 'textEntry', interaction });
37
- }
38
- else {
39
- const interaction = findInlineInteraction(interactions, match[2], 'inlineChoiceInteraction');
40
- if (interaction)
41
- result.push({ type: 'inlineChoice', interaction });
42
- }
43
- lastIndex = match.index + match[0].length;
44
- }
45
- if (lastIndex < placeholderHtml.length) {
46
- result.push({ type: 'html', content: placeholderHtml.substring(lastIndex) });
47
- }
48
- return result.length > 0 ? result : [{ type: 'html', content: placeholderHtml }];
49
- }
50
- function placeholder(kind, responseId) {
51
- return kind === 'textEntry' ? `[TEXTENTRY:${responseId}]` : `[INLINECHOICE:${responseId}]`;
52
- }
53
- function hasInlineInteraction(interactions, responseId, type) {
54
- return Boolean(findInlineInteraction(interactions, responseId, type));
55
- }
56
- function findInlineInteraction(interactions, responseId, type) {
57
- return (interactions.find((interaction) => interaction.responseId === responseId && interaction.type === type) ??
58
- null);
59
- }
60
9
  //# sourceMappingURL=render-plan.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-plan.js","sourceRoot":"","sources":["../../../src/interactions/inline/render-plan.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,eAAe,CAAC;AASvB,MAAM,UAAU,uBAAuB,CAAC,IAAY;IACnD,OAAO,+BAA+B,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACzD,OAAO,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EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,WAAW,CAAC,IAAkC,EAAE,UAAkB;IAC1E,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,UAAU,GAAG,CAAC,CAAC,CAAC,iBAAiB,UAAU,GAAG,CAAC;AAC5F,CAAC;AAED,SAAS,oBAAoB,CAC5B,YAA4C,EAC5C,UAAkB,EAClB,IAAmC;IAEnC,OAAO,OAAO,CAAC,qBAAqB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,qBAAqB,CAC7B,YAA4C,EAC5C,UAAkB,EAClB,IAAO;IAEP,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,KAAK,UAAU,IAAI,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC;QAC7G,IAAI,CAAuD,CAAC;AAC9D,CAAC","sourcesContent":["import type {\n\tBaseInteractionData,\n\tInlineChoiceInteractionData,\n\tTextEntryInteractionData,\n} from '../shared/types.js';\nimport {\n\tisStandardInlineInteractionTagName,\n\tisStandardInlineInteractionType,\n} from '../modules.js';\n\nexport type InlineInteractionData = TextEntryInteractionData | InlineChoiceInteractionData;\n\nexport type InlineRenderSegment =\n\t| { type: 'html'; content: string }\n\t| { type: 'textEntry'; interaction: TextEntryInteractionData }\n\t| { type: 'inlineChoice'; interaction: InlineChoiceInteractionData };\n\nexport function isInlineInteractionType(type: string): type is InlineInteractionData['type'] {\n\treturn isStandardInlineInteractionType(type);\n}\n\nexport function isInlineInteractionTagName(tagName: string): boolean {\n\treturn isStandardInlineInteractionTagName(tagName);\n}\n\nexport function createInlinePlaceholderHtml(\n\thtml: string,\n\tinteractions: readonly BaseInteractionData[],\n): string {\n\treturn html\n\t\t.replace(\n\t\t\t/<textEntryInteraction[^>]*responseIdentifier=\"([^\"]+)\"[^>]*?(?:\\/>|><\\/textEntryInteraction>)/gi,\n\t\t\t(match, responseId: string) =>\n\t\t\t\thasInlineInteraction(interactions, responseId, 'textEntryInteraction')\n\t\t\t\t\t? placeholder('textEntry', responseId)\n\t\t\t\t\t: match\n\t\t)\n\t\t.replace(\n\t\t\t/<qti-text-entry-interaction[^>]*response-identifier=\"([^\"]+)\"[^>]*?(?:\\/>|><\\/qti-text-entry-interaction>)/gi,\n\t\t\t(match, responseId: string) =>\n\t\t\t\thasInlineInteraction(interactions, responseId, 'textEntryInteraction')\n\t\t\t\t\t? placeholder('textEntry', responseId)\n\t\t\t\t\t: match\n\t\t)\n\t\t.replace(\n\t\t\t/<inlineChoiceInteraction[^>]*responseIdentifier=\"([^\"]+)\"[^>]*>[\\s\\S]*?<\\/inlineChoiceInteraction>/gi,\n\t\t\t(match, responseId: string) =>\n\t\t\t\thasInlineInteraction(interactions, responseId, 'inlineChoiceInteraction')\n\t\t\t\t\t? placeholder('inlineChoice', responseId)\n\t\t\t\t\t: match\n\t\t)\n\t\t.replace(\n\t\t\t/<qti-inline-choice-interaction[^>]*response-identifier=\"([^\"]+)\"[^>]*>[\\s\\S]*?<\\/qti-inline-choice-interaction>/gi,\n\t\t\t(match, responseId: string) =>\n\t\t\t\thasInlineInteraction(interactions, responseId, 'inlineChoiceInteraction')\n\t\t\t\t\t? placeholder('inlineChoice', responseId)\n\t\t\t\t\t: match\n\t\t);\n}\n\nexport function createInlineRenderPlan(\n\thtml: string,\n\tinteractions: readonly BaseInteractionData[],\n): InlineRenderSegment[] {\n\tconst placeholderHtml = createInlinePlaceholderHtml(html, interactions);\n\tconst result: InlineRenderSegment[] = [];\n\tconst combinedPattern = /\\[TEXTENTRY:([^\\]]+)\\]|\\[INLINECHOICE:([^\\]]+)\\]/g;\n\tlet lastIndex = 0;\n\tlet match: RegExpExecArray | null;\n\n\twhile ((match = combinedPattern.exec(placeholderHtml)) !== null) {\n\t\tif (match.index > lastIndex) {\n\t\t\tresult.push({ type: 'html', content: placeholderHtml.substring(lastIndex, match.index) });\n\t\t}\n\n\t\tif (match[0].startsWith('[TEXTENTRY:')) {\n\t\t\tconst interaction = findInlineInteraction(interactions, match[1], 'textEntryInteraction');\n\t\t\tif (interaction) result.push({ type: 'textEntry', interaction });\n\t\t} else {\n\t\t\tconst interaction = findInlineInteraction(interactions, match[2], 'inlineChoiceInteraction');\n\t\t\tif (interaction) result.push({ type: 'inlineChoice', interaction });\n\t\t}\n\n\t\tlastIndex = match.index + match[0].length;\n\t}\n\n\tif (lastIndex < placeholderHtml.length) {\n\t\tresult.push({ type: 'html', content: placeholderHtml.substring(lastIndex) });\n\t}\n\n\treturn result.length > 0 ? result : [{ type: 'html', content: placeholderHtml }];\n}\n\nfunction placeholder(kind: 'textEntry' | 'inlineChoice', responseId: string): string {\n\treturn kind === 'textEntry' ? `[TEXTENTRY:${responseId}]` : `[INLINECHOICE:${responseId}]`;\n}\n\nfunction hasInlineInteraction(\n\tinteractions: readonly BaseInteractionData[],\n\tresponseId: string,\n\ttype: InlineInteractionData['type']\n): boolean {\n\treturn Boolean(findInlineInteraction(interactions, responseId, type));\n}\n\nfunction findInlineInteraction<T extends InlineInteractionData['type']>(\n\tinteractions: readonly BaseInteractionData[],\n\tresponseId: string,\n\ttype: T\n): Extract<InlineInteractionData, { type: T }> | null {\n\treturn (interactions.find((interaction) => interaction.responseId === responseId && interaction.type === type) ??\n\t\tnull) as Extract<InlineInteractionData, { type: T }> | null;\n}\n"]}
1
+ {"version":3,"file":"render-plan.js","sourceRoot":"","sources":["../../../src/interactions/inline/render-plan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAIhE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY;IACnD,OAAO,+BAA+B,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import type { InlineChoiceInteractionData, TextEntryInteractionData } from '../shared/types.js';\nimport { isStandardInlineInteractionType } from '../modules.js';\n\nexport type InlineInteractionData = TextEntryInteractionData | InlineChoiceInteractionData;\n\n/**\n * Whether an interaction renders in sentence flow. Inline interactions are rendered by the item\n * player itself, mounted into the slot that marks their authored position in the item body.\n */\nexport function isInlineInteractionType(type: string): type is InlineInteractionData['type'] {\n\treturn isStandardInlineInteractionType(type);\n}\n"]}
@@ -16,6 +16,10 @@ export interface InlineChoiceData {
16
16
  shuffle: boolean;
17
17
  /** Text from the QTI <label> child element; used as the placeholder "Select…" option */
18
18
  label: string | null;
19
+ /** Choices a valid response selects (QTI 3.0 min-choices; required="true" is 1); omitted when 0. */
20
+ minChoices?: number;
21
+ /** The author's `data-min-selections-message` (QTI 3.0, inlineChoiceInteraction); omitted when none is authored. */
22
+ minSelectionsMessage?: string;
19
23
  }
20
24
  /**
21
25
  * Standard QTI inline choice interaction extractor
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Extracts data from inlineChoiceInteraction elements (dropdown in text)
5
5
  */
6
+ import { validateUniqueIdentifiers } from '../../extraction/utils.js';
6
7
  import { maybeShuffle } from '../../core/shuffle.js';
7
8
  /**
8
9
  * Standard QTI inline choice interaction extractor
@@ -35,14 +36,25 @@ export const standardInlineChoiceExtractor = {
35
36
  const label = labelElements.length > 0 ? utils.getTextContent(labelElements[0]) : null;
36
37
  // data-prompt: alternative placeholder for the dropdown default option
37
38
  const dataPrompt = utils.getAttribute(element, 'data-prompt', '') || null;
39
+ // An authored title names the dropdown when no aria label is authored.
40
+ const title = utils.getAttribute(element, 'title', '').trim();
38
41
  // Extract attributes
39
42
  const shuffle = utils.getBooleanAttribute(element, 'shuffle');
40
43
  const interactionClasses = utils.getClasses(element);
44
+ // A valid response selects a choice when `required` (QTI 2.1; QTI 3.0 §5.74.2) or at
45
+ // least `min-choices` (QTI 3.0 §5.74.3).
46
+ const minChoices = Math.max(utils.getNumberAttribute(element, 'minChoices', 0), utils.getBooleanAttribute(element, 'required', false) ? 1 : 0);
47
+ // QTI 3.0 defines data-min-selections-message (and no max) on inlineChoiceInteraction:
48
+ // it describes the requirement a valid response must meet.
49
+ const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
41
50
  return {
42
51
  choices: maybeShuffle(choices, shuffle, context.shuffleRng),
43
52
  shuffle,
44
53
  label,
54
+ ...(minChoices > 0 ? { minChoices } : {}),
55
+ ...(minSelectionsMessage ? { minSelectionsMessage } : {}),
45
56
  ...(dataPrompt ? { dataPrompt } : {}),
57
+ ...(title ? { title } : {}),
46
58
  ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
47
59
  };
48
60
  },
@@ -55,18 +67,7 @@ export const standardInlineChoiceExtractor = {
55
67
  }
56
68
  // Validate choice identifiers
57
69
  if (data.choices) {
58
- const identifiers = new Set();
59
- for (const choice of data.choices) {
60
- if (!choice.identifier) {
61
- errors.push('All choices must have an identifier');
62
- }
63
- else if (identifiers.has(choice.identifier)) {
64
- errors.push(`Duplicate choice identifier: ${choice.identifier}`);
65
- }
66
- else {
67
- identifiers.add(choice.identifier);
68
- }
69
- }
70
+ validateUniqueIdentifiers(data.choices, errors, { plural: 'choices', noun: 'choice' });
70
71
  // Warn if too many choices
71
72
  if (data.choices.length >= 10) {
72
73
  warnings.push(`inlineChoiceInteraction has ${data.choices.length} choices - consider limiting for better usability`);