@pie-qti/item-player 1.0.0-beta.4 → 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 (294) 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 -14
  273. package/dist/components/utils/stimulusRender.js.map +0 -1
  274. package/dist/components/utils/stylesheetRender.js.map +0 -1
  275. package/dist/core/constants.d.ts +0 -65
  276. package/dist/core/constants.js +0 -74
  277. package/dist/core/constants.js.map +0 -1
  278. package/dist/element-class-DdpiTalY.js +0 -9226
  279. package/dist/element-class-DdpiTalY.js.map +0 -1
  280. package/dist/extensions/MathLiveEditor.d.ts +0 -31
  281. package/dist/extensions/MathLiveEditor.js +0 -248
  282. package/dist/extensions/MathLiveEditor.js.map +0 -1
  283. package/dist/utils/PerformanceMonitor.d.ts +0 -169
  284. package/dist/utils/PerformanceMonitor.js +0 -243
  285. package/dist/utils/PerformanceMonitor.js.map +0 -1
  286. package/dist/utils/responseUtils.d.ts +0 -15
  287. package/dist/utils/responseUtils.js +0 -46
  288. package/dist/utils/responseUtils.js.map +0 -1
  289. package/dist/web-components/QTIInteractionBase.d.ts +0 -119
  290. package/dist/web-components/QTIInteractionBase.js +0 -244
  291. package/dist/web-components/QTIInteractionBase.js.map +0 -1
  292. /package/dist/{components/utils → presentation}/stimulusRender.d.ts +0 -0
  293. /package/dist/{components/utils → presentation}/stylesheetRender.d.ts +0 -0
  294. /package/dist/{components/utils → presentation}/stylesheetRender.js +0 -0
@@ -5,6 +5,7 @@
5
5
  * interaction renderer registry, ensuring compile-time type safety.
6
6
  */
7
7
  import type { HTMLElement } from 'node-html-parser';
8
+ import type { ExtendedTextNumericRecord } from '../extended-text/response.js';
8
9
  import type { ExtractedPci } from '../../pci/types.js';
9
10
  import type { HtmlContent, QTIFileResponse } from '../../types/index.js';
10
11
  /**
@@ -60,6 +61,17 @@ export interface TextEntryInteractionData extends BaseInteractionData<'textEntry
60
61
  patternMask: string | null;
61
62
  placeholderText: string;
62
63
  format?: string;
64
+ /** The bound response declaration's baseType, e.g. `integer` or `float` for a numeric keyboard */
65
+ baseType?: string;
66
+ /** QTI stringInteraction `base`: the number base a numeric response is entered in, when not 10 */
67
+ base?: number;
68
+ /**
69
+ * QTI stringInteraction `stringIdentifier`: the response, of base-type string, that holds the
70
+ * text the candidate entered — "3.50" where the numeric response is 3.5 — or NULL when empty
71
+ */
72
+ stringIdentifier?: string;
73
+ /** The authored `title`, an accessible name when no aria label is authored */
74
+ title?: string;
63
75
  /** CSS classes from the textEntryInteraction element (e.g. qti-input-width-N) */
64
76
  interactionClasses?: string[];
65
77
  /** Pattern mask validation message (data-patternmask-message) */
@@ -74,7 +86,8 @@ export interface ExtendedTextInteractionData extends BaseInteractionData<'extend
74
86
  /** Zero means no authored upper bound. */
75
87
  maxStrings: number;
76
88
  expectedLines: number;
77
- expectedLength: number;
89
+ /** The authored expected length, a hint with no default in any QTI version; absent when not authored. */
90
+ expectedLength?: number;
78
91
  prompt: HtmlContent | null;
79
92
  placeholderText: string;
80
93
  format: string;
@@ -89,6 +102,15 @@ export interface InlineChoiceInteractionData extends BaseInteractionData<'inline
89
102
  label: string | null;
90
103
  /** Placeholder text from data-prompt attribute; alternative to <label> for dropdown default option */
91
104
  dataPrompt?: string | null;
105
+ /** The authored `title`, an accessible name when no aria label is authored */
106
+ title?: string;
107
+ /**
108
+ * Choices a valid response selects: QTI 3.0 `min-choices` (§5.74.3), or 1 when the
109
+ * interaction is `required` (QTI 2.1; QTI 3.0 §5.74.2). Omitted when no choice is required.
110
+ */
111
+ minChoices?: number;
112
+ /** The author's `data-min-selections-message` (QTI 3.0); omitted when none is authored. */
113
+ minSelectionsMessage?: string | null;
92
114
  choices: Array<{
93
115
  identifier: string;
94
116
  text: string;
@@ -111,6 +133,10 @@ export interface OrderInteractionData extends BaseInteractionData<'orderInteract
111
133
  orientation?: string;
112
134
  /** CSS classes from the orderInteraction element (orientation and `qti-labels-*`) */
113
135
  interactionClasses?: string[];
136
+ /** Message shown while the response orders fewer than minChoices (data-min-selections-message) */
137
+ minSelectionsMessage?: string | null;
138
+ /** Message shown when an add is refused at the subset cap (data-max-selections-message) */
139
+ maxSelectionsMessage?: string | null;
114
140
  }
115
141
  export interface AssociableChoice {
116
142
  identifier: string;
@@ -118,8 +144,13 @@ export interface AssociableChoice {
118
144
  matchMax: number;
119
145
  /** Minimum number of times this choice must appear in the response (QTI matchMin) */
120
146
  matchMin?: number;
121
- /** Pairing constraint: choice can only be paired with others sharing a group value (QTI matchGroup) */
147
+ /**
148
+ * Authored `matchGroup` (QTI 2.2/3.0: the identifiers of the choices this one may be paired
149
+ * with; content also uses the tokens as shared group labels). Empty/absent: unrestricted.
150
+ */
122
151
  matchGroup?: string[];
152
+ /** Authored `fixed` (QTI fixed.SimpleAssociableChoice.Attr): pins the choice under shuffle. */
153
+ fixed?: boolean;
123
154
  /** CSS classes from the choice element for custom renderer detection */
124
155
  classes?: string[];
125
156
  }
@@ -136,8 +167,6 @@ export interface MatchInteractionData extends BaseInteractionData<'matchInteract
136
167
  maxSelectionsMessage?: string | null;
137
168
  /** Message shown when candidate submits below minAssociations */
138
169
  minSelectionsMessage?: string | null;
139
- /** Label for first column header in tabular mode (data-qti-first-column-header) */
140
- firstColumnHeader?: string | null;
141
170
  }
142
171
  export interface AssociateInteractionData extends BaseInteractionData<'associateInteraction'> {
143
172
  shuffle: boolean;
@@ -153,13 +182,60 @@ export interface GapMatchInteractionData extends BaseInteractionData<'gapMatchIn
153
182
  identifier: string;
154
183
  text: string;
155
184
  matchMax: number;
185
+ /** Minimum number of gaps this choice must fill (QTI matchMin); absent means 0. */
186
+ matchMin?: number;
156
187
  matchGroup?: string[];
157
- inputWidth?: number;
188
+ /** Authored `fixed` (a QTI 2.1 attribute on gapText): pins the choice under shuffle. */
189
+ fixed?: boolean;
158
190
  }>;
159
- gaps: Array<{
191
+ /**
192
+ * Image choices from gapImg (QTI 2.x) / qti-gap-img (QTI 3.0); optional so
193
+ * hand-built text-only data stays valid. `src` passes the resource-URL policy
194
+ * through the module's delivery field.
195
+ */
196
+ gapImages?: Array<{
160
197
  identifier: string;
161
- index: number;
198
+ src: string;
199
+ alt: string;
200
+ matchMax: number;
201
+ /** Minimum number of gaps this choice must fill (QTI matchMin); absent means 0. */
202
+ matchMin?: number;
203
+ matchGroup?: string[];
204
+ /**
205
+ * The gapImg's authored `objectLabel` (QTI 2.1 `objectLabel.GapImg.Attr`,
206
+ * QTI 3.0 `object-label`). Names the label for assistive technology when
207
+ * the image itself carries no text alternative.
208
+ */
209
+ objectLabel?: string;
210
+ /** Authored `fixed` (a QTI 2.1 attribute on gapImg): pins the choice under shuffle. */
211
+ fixed?: boolean;
212
+ width?: number;
213
+ height?: number;
162
214
  }>;
215
+ /** Identifiers of the `<gap>` elements, in reading order (what the extractor delivers). */
216
+ gaps: string[];
217
+ /**
218
+ * The most associations the candidate may make (QTI `maxAssociations`); 0 means no
219
+ * restriction. The extractor always delivers it: absent means 1 in QTI 2.2 and 3.0 and
220
+ * 0 in QTI 2.1, which has no such attribute. Optional so hand-built data stays valid;
221
+ * missing is treated as 0.
222
+ */
223
+ maxAssociations?: number;
224
+ /**
225
+ * The associations a valid response makes (QTI 2.2 `minAssociations`; QTI 3.0 §5.57.2).
226
+ * Present only when above 0.
227
+ */
228
+ minAssociations?: number;
229
+ /**
230
+ * Authored `matchGroup` tokens per gap identifier (QTI 2.2/3.0: the identifiers of the
231
+ * choices that may be matched with this gap). Present only when a gap authors one.
232
+ */
233
+ gapMatchGroups?: Record<string, string[]>;
234
+ /**
235
+ * Identifiers of the gaps authored `required`: a valid response fills each of them (QTI 2.1
236
+ * gap; QTI 3.0 §5.55.5). Present only when a gap is required.
237
+ */
238
+ requiredGaps?: string[];
163
239
  /** Finalized HTML template containing `[GAP:identifier]` text markers. */
164
240
  promptText: HtmlContent;
165
241
  /** CSS classes from the gapMatchInteraction element (e.g. qti-choices-top, qti-choices-bottom) */
@@ -175,6 +251,8 @@ export interface SliderInteractionData extends BaseInteractionData<'sliderIntera
175
251
  lowerBound: number;
176
252
  upperBound: number;
177
253
  step: number;
254
+ /** Authored `stepLabel` attribute: render a label at each step interval. */
255
+ stepLabel?: boolean;
178
256
  orientation: string;
179
257
  reverse: boolean;
180
258
  prompt: HtmlContent | null;
@@ -183,8 +261,19 @@ export interface ImageData {
183
261
  type: 'svg' | 'image';
184
262
  content?: HtmlContent;
185
263
  src?: string;
186
- width: string;
187
- height: string;
264
+ /**
265
+ * The authored pixel dimensions, when the item declares them. Absent when it
266
+ * does not: a raster image's natural size (once loaded) is the pixel space
267
+ * the graphic interactions' coords and points are authored in.
268
+ */
269
+ width?: string;
270
+ height?: string;
271
+ /** Short text alternative extracted from the QTI source (see `shared/imageAlt.ts`). */
272
+ alt?: string;
273
+ /** Longer description for complex images (SVG `<desc>`, resolved aria description). */
274
+ altDescription?: string;
275
+ /** True only when the author explicitly marked the image decorative (`<img alt="">`). */
276
+ decorative?: boolean;
188
277
  }
189
278
  export interface HotspotChoice {
190
279
  identifier: string;
@@ -211,15 +300,31 @@ export interface AssociableHotspot {
211
300
  shape: string;
212
301
  coords: string;
213
302
  matchMax: number;
303
+ /** Minimum number of labels this hotspot must take (QTI matchMin); absent means 0. */
304
+ matchMin?: number;
305
+ /** Authored `matchGroup`: the identifiers of the labels that may be matched with this hotspot. */
306
+ matchGroup?: string[];
307
+ /**
308
+ * Authored `hotspotLabel`: the zone's name for assistive technology.
309
+ * Absent when the author gave none; the renderer then names the zone generically.
310
+ */
311
+ hotspotLabel?: string;
214
312
  }
215
313
  export interface GraphicGapMatchInteractionData extends BaseInteractionData<'graphicGapMatchInteraction'> {
216
314
  prompt: HtmlContent | null;
217
315
  imageData: ImageData | null;
218
316
  maxAssociations: number;
317
+ /**
318
+ * The associations a valid response makes (QTI 2.2 `minAssociations`; QTI 3.0 §5.60.1).
319
+ * Present only when above 0.
320
+ */
321
+ minAssociations?: number;
219
322
  gapTexts: Array<{
220
323
  identifier: string;
221
324
  text: string;
222
325
  matchMax: number;
326
+ /** Minimum number of hotspots this label must fill (QTI matchMin); absent means 0. */
327
+ matchMin?: number;
223
328
  matchGroup?: string[];
224
329
  }>;
225
330
  /** Image-based draggable labels (gapImg elements); rendered as <img> in the choice pool */
@@ -228,7 +333,15 @@ export interface GraphicGapMatchInteractionData extends BaseInteractionData<'gra
228
333
  src: string;
229
334
  alt: string;
230
335
  matchMax: number;
336
+ /** Minimum number of hotspots this label must fill (QTI matchMin); absent means 0. */
337
+ matchMin?: number;
231
338
  matchGroup?: string[];
339
+ /**
340
+ * The gapImg's authored `objectLabel` (QTI 2.1 `objectLabel.GapImg.Attr`,
341
+ * QTI 3.0 `object-label`). Names the label for assistive technology when
342
+ * the image itself carries no text alternative.
343
+ */
344
+ objectLabel?: string;
232
345
  width?: number;
233
346
  height?: number;
234
347
  }>;
@@ -263,12 +376,34 @@ export interface CustomInteractionData extends BaseInteractionData<'customIntera
263
376
  /** Canonical interaction data for QTI 2.x and 3.0 Portable Custom Interactions. */
264
377
  export interface PortableCustomInteractionData extends BaseInteractionData<'portableCustomInteraction'>, ExtractedPci {
265
378
  }
379
+ /** One authored `<source>` of an audio or video element. */
380
+ export interface MediaElementSource {
381
+ src: string;
382
+ mimeType: string;
383
+ }
384
+ /** The timed text track kinds HTML defines for `<track>`. */
385
+ export type MediaTrackKind = 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
386
+ /** One authored `<track>` of an audio or video element: captions, subtitles, descriptions. */
387
+ export interface MediaElementTrack {
388
+ src: string;
389
+ kind: MediaTrackKind;
390
+ srclang?: string;
391
+ label?: string;
392
+ default?: boolean;
393
+ }
266
394
  export interface MediaElement {
267
395
  type: 'audio' | 'video' | 'object';
396
+ /** The object's `data`, or the first source of an audio or video element. */
268
397
  src: string;
269
398
  mimeType: string;
270
399
  width?: number;
271
400
  height?: number;
401
+ /** Every source of an audio or video element, in document order (the browser picks the first it can play). */
402
+ sources?: MediaElementSource[];
403
+ /** Every text track of an audio or video element, in document order. */
404
+ tracks?: MediaElementTrack[];
405
+ /** The authored `crossorigin` mode; cross-origin caption files load only with one. */
406
+ crossOrigin?: 'anonymous' | 'use-credentials';
272
407
  }
273
408
  export interface MediaInteractionData extends BaseInteractionData<'mediaInteraction'> {
274
409
  prompt: HtmlContent | null;
@@ -317,6 +452,10 @@ export interface GraphicOrderInteractionData extends BaseInteractionData<'graphi
317
452
  prompt: HtmlContent | null;
318
453
  imageData: ImageData | null;
319
454
  hotspotChoices: GraphicOrderChoice[];
455
+ /** Minimum number of hotspots the response must order (QTI minChoices); absent means 0. */
456
+ minChoices?: number;
457
+ /** Maximum number of hotspots the response may order (QTI maxChoices); absent means 0, no limit. */
458
+ maxChoices?: number;
320
459
  }
321
460
  export interface GraphicAssociateHotspot {
322
461
  identifier: string;
@@ -324,7 +463,10 @@ export interface GraphicAssociateHotspot {
324
463
  coords: string;
325
464
  matchMax: number;
326
465
  label: string;
327
- /** Pairing constraint: hotspot can only be associated with others sharing a group value (QTI matchGroup) */
466
+ /**
467
+ * Authored `matchGroup` (QTI 2.2/3.0: the identifiers of the hotspots this one may be
468
+ * associated with; content also uses the tokens as shared group labels).
469
+ */
328
470
  matchGroup?: string[];
329
471
  }
330
472
  export interface GraphicAssociateInteractionData extends BaseInteractionData<'graphicAssociateInteraction'> {
@@ -346,11 +488,25 @@ export interface PositionObjectStage {
346
488
  } | null;
347
489
  label: string;
348
490
  }
491
+ /**
492
+ * A point on a draggable object image, in that image's own pixel coordinates,
493
+ * measured from its top-left corner (QTI `centerPoint`, horizontal then vertical).
494
+ */
495
+ export interface PositionObjectCenterPoint {
496
+ x: number;
497
+ y: number;
498
+ }
349
499
  export interface PositionObjectInteractionData extends BaseInteractionData<'positionObjectInteraction'> {
350
500
  prompt: HtmlContent | null;
351
501
  maxChoices: number;
352
502
  minChoices: number;
353
- centerPoint: boolean;
503
+ /**
504
+ * The point on the object image treated as the object's position: it is the
505
+ * point placed under the candidate's pointer and recorded, in stage
506
+ * coordinates, as the response. `null` is the QTI default, the centre of the
507
+ * object image's bounding rectangle.
508
+ */
509
+ centerPoint: PositionObjectCenterPoint | null;
354
510
  imageData: ImageData | null;
355
511
  positionObjectStages: PositionObjectStage[];
356
512
  }
@@ -362,11 +518,6 @@ export interface EndAttemptInteractionData extends BaseInteractionData<'endAttem
362
518
  }
363
519
  /** Closed union of the interaction shapes supplied by the standard modules. */
364
520
  export type StandardInteractionData = ChoiceInteractionData | TextEntryInteractionData | ExtendedTextInteractionData | InlineChoiceInteractionData | OrderInteractionData | MatchInteractionData | AssociateInteractionData | GapMatchInteractionData | SliderInteractionData | HotspotInteractionData | GraphicGapMatchInteractionData | UploadInteractionData | DrawingInteractionData | CustomInteractionData | PortableCustomInteractionData | MediaInteractionData | HottextInteractionData | SelectPointInteractionData | GraphicOrderInteractionData | GraphicAssociateInteractionData | PositionObjectInteractionData | EndAttemptInteractionData;
365
- /**
366
- * QTI interaction type identifier
367
- * Extensible string type allows custom interaction types
368
- */
369
- export type InteractionType = string;
370
521
  /**
371
522
  * Map interaction types to their data structures
372
523
  * TypeScript will ensure registrations use the correct data type
@@ -396,36 +547,57 @@ export interface InteractionDataMap {
396
547
  endAttemptInteraction: EndAttemptInteractionData;
397
548
  }
398
549
  /**
399
- * Map interaction types to their response value types
400
- * Ensures getValue/setValue use the correct types
550
+ * Map interaction types to the value a component's `qti-change` event (and its
551
+ * `onChange` callback) carries: the raw component output, before the player
552
+ * normalizes it into the QTI response declaration. The response variable the
553
+ * player stores is that normalized value, returned by `Player.getResponses`.
554
+ *
555
+ * Each entry is derived from the component's emission sites; see
556
+ * `tests/web-components/interaction-value-map.test.ts` for the compile-time pins.
401
557
  */
402
558
  export interface InteractionValueMap {
403
- choiceInteraction: string | string[];
559
+ /** ChoiceInteraction: the selected identifier, the selected identifiers, or null on "clear answer". */
560
+ choiceInteraction: string | string[] | null;
561
+ /** InlineTextEntry: the text as typed. */
404
562
  textEntryInteraction: string;
405
- extendedTextInteraction: string;
563
+ /** ExtendedTextInteraction: `createExtendedTextResponse`'s value; null once emptied. */
564
+ extendedTextInteraction: string | number | Array<string | number> | ExtendedTextNumericRecord | null;
565
+ /** InlineChoice: the chosen option identifier. */
406
566
  inlineChoiceInteraction: string;
407
- orderInteraction: string[];
408
- matchInteraction: Record<string, string>;
409
- associateInteraction: Array<[string, string]>;
410
- gapMatchInteraction: Record<string, string>;
567
+ /** OrderInteraction: the ordered identifiers; null when a subset order is cleared. */
568
+ orderInteraction: string[] | null;
569
+ /** MatchInteraction: pairs as `"source target"` strings. */
570
+ matchInteraction: string[];
571
+ /** AssociateInteraction: associations as `"A B"` strings. */
572
+ associateInteraction: string[];
573
+ /** GapMatchInteraction: pairs as `"gapText gap"` strings. */
574
+ gapMatchInteraction: string[];
575
+ /** SliderInteraction: the slider value. */
411
576
  sliderInteraction: number;
412
- hotspotInteraction: string[];
413
- graphicGapMatchInteraction: Record<string, string>;
577
+ /** HotspotInteraction: single select emits the identifier or null (cleared); multiple emits the identifiers ([] when cleared). */
578
+ hotspotInteraction: string | string[] | null;
579
+ /** GraphicGapMatchInteraction: pairs as `"gapText hotspot"` strings. */
580
+ graphicGapMatchInteraction: string[];
581
+ /** UploadInteraction: the file response; null when cleared. */
414
582
  uploadInteraction: QTIFileResponse | null;
415
- drawingInteraction: string;
416
- customInteraction: any;
583
+ /** DrawingInteraction: the drawing response; null when the canvas is cleared. */
584
+ drawingInteraction: QTIFileResponse | null;
585
+ /** CustomInteraction fallback: the manual-entry value; null when cleared. */
586
+ customInteraction: string | null;
587
+ /** PortableCustomInteraction: whatever the PCI module publishes. */
417
588
  portableCustomInteraction: unknown;
418
- mediaInteraction: any;
419
- hottextInteraction: string[];
420
- selectPointInteraction: Array<{
421
- x: number;
422
- y: number;
423
- }>;
424
- graphicOrderInteraction: string[];
425
- graphicAssociateInteraction: Array<[string, string]>;
426
- positionObjectInteraction: Record<string, {
427
- x: number;
428
- y: number;
429
- }>;
589
+ /** MediaInteraction: the play count so far. */
590
+ mediaInteraction: number;
591
+ /** HottextInteraction: single select emits the identifier or null (cleared); multiple emits the identifiers. */
592
+ hottextInteraction: string | string[] | null;
593
+ /** SelectPointInteraction: `maxChoices=1` emits `"x y"` or null (cleared); otherwise the `"x y"` strings. */
594
+ selectPointInteraction: string | string[] | null;
595
+ /** GraphicOrderInteraction: the ordered hotspot identifiers; null when a subset order is cleared. */
596
+ graphicOrderInteraction: string[] | null;
597
+ /** GraphicAssociateInteraction: associations as `"A B"` strings. */
598
+ graphicAssociateInteraction: string[];
599
+ /** PositionObjectInteraction: placements as `"x y"` strings in natural image pixels. */
600
+ positionObjectInteraction: string[];
601
+ /** EndAttemptInteraction: always emitted as `true`. */
430
602
  endAttemptInteraction: boolean;
431
603
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/interactions/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Interaction type mappings for strongly-typed registry\n *\n * This file defines the complete type system for the plugin-based\n * interaction renderer registry, ensuring compile-time type safety.\n */\n\nimport type { HTMLElement } from 'node-html-parser';\nimport type { ExtractedPci } from '../../pci/types.js';\nimport type { HtmlContent, QTIFileResponse } from '../../types/index.js';\n\n/**\n * Type alias for parsed QTI XML elements\n * Uses node-html-parser's HTMLElement type directly\n */\nexport type QTIElement = HTMLElement;\n\n/**\n * The interaction's authored accessible name and description, resolved to text from its\n * `aria-labelledby`, `aria-label`, `aria-describedby` and `aria-description`.\n */\nexport interface InteractionAccessibility {\n\tlabel?: string;\n\tdescription?: string;\n}\n\n/** The read-aloud attributes authored on an interaction element, for its renderer's host. */\nexport type InteractionReadAloud = Partial<Record<'lang' | 'data-catalog-idref' | 'data-tts-suppress', string>>;\n\nexport interface BaseInteractionData<TType extends string = string> {\n\treadonly type: TType;\n\treadonly responseId: string;\n\treadonly accessibility?: InteractionAccessibility;\n\treadonly readAloud?: InteractionReadAloud;\n}\n\n/**\n * An extractor payload after the delivery pipeline has attached its authoritative\n * renderer type and authored response identifier.\n *\n * Identity-looking properties in `TPayload` are deliberately omitted. The\n * pipeline applies the same rule at runtime by spreading payload first and\n * writing these two framework-owned fields last.\n */\nexport type DeliveredInteraction<\n\tTType extends string,\n\tTPayload extends object,\n> = Readonly<\n\tOmit<TPayload, keyof BaseInteractionData> & BaseInteractionData<TType>\n>;\n\nexport interface ChoiceInteractionData extends BaseInteractionData<'choiceInteraction'> {\n\tshuffle: boolean;\n\tmaxChoices: number;\n\tminChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean; classes?: string[] }>;\n\t/** CSS classes from the choiceInteraction element for custom renderer detection */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices (data-max-selections-message) */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices (data-min-selections-message) */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface TextEntryInteractionData extends BaseInteractionData<'textEntryInteraction'> {\n\texpectedLength: number;\n\tpatternMask: string | null;\n\tplaceholderText: string;\n\tformat?: string;\n\t/** CSS classes from the textEntryInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n\t/** Pattern mask validation message (data-patternmask-message) */\n\tpatternMaskMessage?: string | null;\n}\n\nexport interface ExtendedTextInteractionData extends BaseInteractionData<'extendedTextInteraction'> {\n\tcardinality: 'single' | 'multiple' | 'ordered' | 'record';\n\tbaseType?: string;\n\tbase: number;\n\tstringIdentifier?: string;\n\tminStrings: number;\n\t/** Zero means no authored upper bound. */\n\tmaxStrings: number;\n\texpectedLines: number;\n\texpectedLength: number;\n\tprompt: HtmlContent | null;\n\tplaceholderText: string;\n\tformat: string;\n\tpatternMask?: string | null;\n\tpatternMaskMessage?: string | null;\n\t/** CSS classes from the extendedTextInteraction element (e.g. qti-height-lines-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface InlineChoiceInteractionData extends BaseInteractionData<'inlineChoiceInteraction'> {\n\tshuffle: boolean;\n\t/** Placeholder label from the QTI <label> child element; shown as the unselected \"Select…\" option */\n\tlabel: string | null;\n\t/** Placeholder text from data-prompt attribute; alternative to <label> for dropdown default option */\n\tdataPrompt?: string | null;\n\tchoices: Array<{ identifier: string; text: string; fixed?: boolean }>;\n\t/** CSS classes from the inlineChoiceInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface OrderInteractionData extends BaseInteractionData<'orderInteraction'> {\n\tshuffle: boolean;\n\tminChoices: number;\n\tmaxChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean }>;\n\t/** The authored `orientation` attribute: `vertical` (default) or `horizontal` */\n\torientation?: string;\n\t/** CSS classes from the orderInteraction element (orientation and `qti-labels-*`) */\n\tinteractionClasses?: string[];\n}\n\nexport interface AssociableChoice {\n\tidentifier: string;\n\ttext: HtmlContent;\n\tmatchMax: number;\n\t/** Minimum number of times this choice must appear in the response (QTI matchMin) */\n\tmatchMin?: number;\n\t/** Pairing constraint: choice can only be paired with others sharing a group value (QTI matchGroup) */\n\tmatchGroup?: string[];\n\t/** CSS classes from the choice element for custom renderer detection */\n\tclasses?: string[];\n}\n\nexport interface MatchInteractionData extends BaseInteractionData<'matchInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tsourceSet: AssociableChoice[];\n\ttargetSet: AssociableChoice[];\n\t/** CSS classes from the matchInteraction element (e.g. qti-choices-top, qti-match-tabular) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxAssociations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minAssociations */\n\tminSelectionsMessage?: string | null;\n\t/** Label for first column header in tabular mode (data-qti-first-column-header) */\n\tfirstColumnHeader?: string | null;\n}\n\nexport interface AssociateInteractionData extends BaseInteractionData<'associateInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tchoices: AssociableChoice[];\n}\n\nexport interface GapMatchInteractionData extends BaseInteractionData<'gapMatchInteraction'> {\n\tshuffle: boolean;\n\tprompt: HtmlContent | null;\n\tgapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[]; inputWidth?: number }>;\n\tgaps: Array<{ identifier: string; index: number }>;\n\t/** Finalized HTML template containing `[GAP:identifier]` text markers. */\n\tpromptText: HtmlContent;\n\t/** CSS classes from the gapMatchInteraction element (e.g. qti-choices-top, qti-choices-bottom) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface SliderInteractionData extends BaseInteractionData<'sliderInteraction'> {\n\tlowerBound: number;\n\tupperBound: number;\n\tstep: number;\n\torientation: string;\n\treverse: boolean;\n\tprompt: HtmlContent | null;\n}\n\nexport interface ImageData {\n\ttype: 'svg' | 'image';\n\tcontent?: HtmlContent;\n\tsrc?: string;\n\twidth: string;\n\theight: string;\n}\n\nexport interface HotspotChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\t/** Author-provided label for the hotspot; used as accessible aria-label */\n\thotspotLabel?: string;\n}\n\nexport interface HotspotInteractionData extends BaseInteractionData<'hotspotInteraction'> {\n\tmaxChoices: number;\n\tminChoices?: number;\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: HotspotChoice[];\n\t/** CSS classes from the hotspotInteraction element (e.g. qti-selections-light, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface AssociableHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n}\n\nexport interface GraphicGapMatchInteractionData extends BaseInteractionData<'graphicGapMatchInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\tmaxAssociations: number;\n\tgapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[] }>;\n\t/** Image-based draggable labels (gapImg elements); rendered as <img> in the choice pool */\n\tgapImages: Array<{ identifier: string; src: string; alt: string; matchMax: number; matchGroup?: string[]; width?: number; height?: number }>;\n\thotspots: AssociableHotspot[];\n\t/** CSS classes from the graphicGapMatchInteraction element (e.g. qti-choices-top, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface UploadInteractionData extends BaseInteractionData<'uploadInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Allowed MIME types / extensions (vendor-dependent); empty = accept any */\n\tfileTypes: string[];\n\trawAttributes: Record<string, string>;\n}\n\nexport interface DrawingInteractionData extends BaseInteractionData<'drawingInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Optional background image/SVG to draw on top of */\n\timageData: ImageData | null;\n\trawAttributes: Record<string, string>;\n}\n\nexport interface CustomInteractionData extends BaseInteractionData<'customInteraction'> {\n\tprompt: HtmlContent | null;\n\trawAttributes: Record<string, string>;\n\t/** Outer XML snippet for debugging (best-effort) */\n\txml: string;\n}\n\n/** Canonical interaction data for QTI 2.x and 3.0 Portable Custom Interactions. */\nexport interface PortableCustomInteractionData\n\textends BaseInteractionData<'portableCustomInteraction'>,\n\t\tExtractedPci {}\n\nexport interface MediaElement {\n\ttype: 'audio' | 'video' | 'object';\n\tsrc: string;\n\tmimeType: string;\n\twidth?: number;\n\theight?: number;\n}\n\nexport interface MediaInteractionData extends BaseInteractionData<'mediaInteraction'> {\n\tprompt: HtmlContent | null;\n\tautostart: boolean;\n\tminPlays: number;\n\tmaxPlays: number; // 0 = unlimited\n\tloop: boolean;\n\tmediaElement: MediaElement;\n\t/** Whether the renderer should allow <object> embeds for this interaction (default false) */\n\tallowObjectEmbeds?: boolean;\n}\n\nexport interface HottextChoice {\n\tidentifier: string;\n\ttext: string;\n}\n\nexport interface HottextInteractionData extends BaseInteractionData<'hottextInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\tcontentHtml: HtmlContent;\n\thottextChoices: HottextChoice[];\n\t/** CSS classes from the hottextInteraction element (e.g. qti-input-control-hidden) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface SelectPointInteractionData extends BaseInteractionData<'selectPointInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\timageData: ImageData | null;\n}\n\nexport interface GraphicOrderChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tlabel: string;\n}\n\nexport interface GraphicOrderInteractionData extends BaseInteractionData<'graphicOrderInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: GraphicOrderChoice[];\n}\n\nexport interface GraphicAssociateHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n\tlabel: string;\n\t/** Pairing constraint: hotspot can only be associated with others sharing a group value (QTI matchGroup) */\n\tmatchGroup?: string[];\n}\n\nexport interface GraphicAssociateInteractionData extends BaseInteractionData<'graphicAssociateInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxAssociations: number;\n\tminAssociations: number;\n\timageData: ImageData | null;\n\tassociableHotspots: GraphicAssociateHotspot[];\n}\n\nexport interface PositionObjectStage {\n\tidentifier: string;\n\tmatchMax: number;\n\tobjectData: {\n\t\ttype: 'image' | 'svg';\n\t\tsrc?: string;\n\t\tcontent?: HtmlContent;\n\t\twidth?: string;\n\t\theight?: string;\n\t} | null;\n\tlabel: string;\n}\n\nexport interface PositionObjectInteractionData extends BaseInteractionData<'positionObjectInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\tcenterPoint: boolean;\n\timageData: ImageData | null;\n\tpositionObjectStages: PositionObjectStage[];\n}\n\nexport interface EndAttemptInteractionData extends BaseInteractionData<'endAttemptInteraction'> {\n\tprompt: HtmlContent | null;\n\ttitle: string;\n\t/** Whether this interaction counts as an attempt (default: true) */\n\tcountAttempt: boolean;\n}\n\n/** Closed union of the interaction shapes supplied by the standard modules. */\nexport type StandardInteractionData =\n\t| ChoiceInteractionData\n\t| TextEntryInteractionData\n\t| ExtendedTextInteractionData\n\t| InlineChoiceInteractionData\n\t| OrderInteractionData\n\t| MatchInteractionData\n\t| AssociateInteractionData\n\t| GapMatchInteractionData\n\t| SliderInteractionData\n\t| HotspotInteractionData\n\t| GraphicGapMatchInteractionData\n\t| UploadInteractionData\n\t| DrawingInteractionData\n\t| CustomInteractionData\n\t| PortableCustomInteractionData\n\t| MediaInteractionData\n\t| HottextInteractionData\n\t| SelectPointInteractionData\n\t| GraphicOrderInteractionData\n\t| GraphicAssociateInteractionData\n\t| PositionObjectInteractionData\n\t| EndAttemptInteractionData;\n\n/**\n * QTI interaction type identifier\n * Extensible string type allows custom interaction types\n */\nexport type InteractionType = string;\n\n/**\n * Map interaction types to their data structures\n * TypeScript will ensure registrations use the correct data type\n */\nexport interface InteractionDataMap {\n\tchoiceInteraction: ChoiceInteractionData;\n\ttextEntryInteraction: TextEntryInteractionData;\n\textendedTextInteraction: ExtendedTextInteractionData;\n\tinlineChoiceInteraction: InlineChoiceInteractionData;\n\torderInteraction: OrderInteractionData;\n\tmatchInteraction: MatchInteractionData;\n\tassociateInteraction: AssociateInteractionData;\n\tgapMatchInteraction: GapMatchInteractionData;\n\tsliderInteraction: SliderInteractionData;\n\thotspotInteraction: HotspotInteractionData;\n\tgraphicGapMatchInteraction: GraphicGapMatchInteractionData;\n\tuploadInteraction: UploadInteractionData;\n\tdrawingInteraction: DrawingInteractionData;\n\tcustomInteraction: CustomInteractionData;\n\tportableCustomInteraction: PortableCustomInteractionData;\n\tmediaInteraction: MediaInteractionData;\n\thottextInteraction: HottextInteractionData;\n\tselectPointInteraction: SelectPointInteractionData;\n\tgraphicOrderInteraction: GraphicOrderInteractionData;\n\tgraphicAssociateInteraction: GraphicAssociateInteractionData;\n\tpositionObjectInteraction: PositionObjectInteractionData;\n\tendAttemptInteraction: EndAttemptInteractionData;\n}\n\n/**\n * Map interaction types to their response value types\n * Ensures getValue/setValue use the correct types\n */\nexport interface InteractionValueMap {\n\tchoiceInteraction: string | string[];\n\ttextEntryInteraction: string;\n\textendedTextInteraction: string;\n\tinlineChoiceInteraction: string;\n\torderInteraction: string[];\n\tmatchInteraction: Record<string, string>;\n\tassociateInteraction: Array<[string, string]>;\n\tgapMatchInteraction: Record<string, string>;\n\tsliderInteraction: number;\n\thotspotInteraction: string[];\n\tgraphicGapMatchInteraction: Record<string, string>;\n\tuploadInteraction: QTIFileResponse | null;\n\tdrawingInteraction: string;\n\tcustomInteraction: any;\n\tportableCustomInteraction: unknown;\n\tmediaInteraction: any;\n\thottextInteraction: string[];\n\tselectPointInteraction: Array<{ x: number; y: number }>;\n\tgraphicOrderInteraction: string[];\n\tgraphicAssociateInteraction: Array<[string, string]>;\n\tpositionObjectInteraction: Record<string, { x: number; y: number }>;\n\tendAttemptInteraction: boolean;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/interactions/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * Interaction type mappings for strongly-typed registry\n *\n * This file defines the complete type system for the plugin-based\n * interaction renderer registry, ensuring compile-time type safety.\n */\n\nimport type { HTMLElement } from 'node-html-parser';\nimport type { ExtendedTextNumericRecord } from '../extended-text/response.js';\nimport type { ExtractedPci } from '../../pci/types.js';\nimport type { HtmlContent, QTIFileResponse } from '../../types/index.js';\n\n/**\n * Type alias for parsed QTI XML elements\n * Uses node-html-parser's HTMLElement type directly\n */\nexport type QTIElement = HTMLElement;\n\n/**\n * The interaction's authored accessible name and description, resolved to text from its\n * `aria-labelledby`, `aria-label`, `aria-describedby` and `aria-description`.\n */\nexport interface InteractionAccessibility {\n\tlabel?: string;\n\tdescription?: string;\n}\n\n/** The read-aloud attributes authored on an interaction element, for its renderer's host. */\nexport type InteractionReadAloud = Partial<Record<'lang' | 'data-catalog-idref' | 'data-tts-suppress', string>>;\n\nexport interface BaseInteractionData<TType extends string = string> {\n\treadonly type: TType;\n\treadonly responseId: string;\n\treadonly accessibility?: InteractionAccessibility;\n\treadonly readAloud?: InteractionReadAloud;\n}\n\n/**\n * An extractor payload after the delivery pipeline has attached its authoritative\n * renderer type and authored response identifier.\n *\n * Identity-looking properties in `TPayload` are deliberately omitted. The\n * pipeline applies the same rule at runtime by spreading payload first and\n * writing these two framework-owned fields last.\n */\nexport type DeliveredInteraction<\n\tTType extends string,\n\tTPayload extends object,\n> = Readonly<\n\tOmit<TPayload, keyof BaseInteractionData> & BaseInteractionData<TType>\n>;\n\nexport interface ChoiceInteractionData extends BaseInteractionData<'choiceInteraction'> {\n\tshuffle: boolean;\n\tmaxChoices: number;\n\tminChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean; classes?: string[] }>;\n\t/** CSS classes from the choiceInteraction element for custom renderer detection */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices (data-max-selections-message) */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices (data-min-selections-message) */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface TextEntryInteractionData extends BaseInteractionData<'textEntryInteraction'> {\n\texpectedLength: number;\n\tpatternMask: string | null;\n\tplaceholderText: string;\n\tformat?: string;\n\t/** The bound response declaration's baseType, e.g. `integer` or `float` for a numeric keyboard */\n\tbaseType?: string;\n\t/** QTI stringInteraction `base`: the number base a numeric response is entered in, when not 10 */\n\tbase?: number;\n\t/**\n\t * QTI stringInteraction `stringIdentifier`: the response, of base-type string, that holds the\n\t * text the candidate entered — \"3.50\" where the numeric response is 3.5 — or NULL when empty\n\t */\n\tstringIdentifier?: string;\n\t/** The authored `title`, an accessible name when no aria label is authored */\n\ttitle?: string;\n\t/** CSS classes from the textEntryInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n\t/** Pattern mask validation message (data-patternmask-message) */\n\tpatternMaskMessage?: string | null;\n}\n\nexport interface ExtendedTextInteractionData extends BaseInteractionData<'extendedTextInteraction'> {\n\tcardinality: 'single' | 'multiple' | 'ordered' | 'record';\n\tbaseType?: string;\n\tbase: number;\n\tstringIdentifier?: string;\n\tminStrings: number;\n\t/** Zero means no authored upper bound. */\n\tmaxStrings: number;\n\texpectedLines: number;\n\t/** The authored expected length, a hint with no default in any QTI version; absent when not authored. */\n\texpectedLength?: number;\n\tprompt: HtmlContent | null;\n\tplaceholderText: string;\n\tformat: string;\n\tpatternMask?: string | null;\n\tpatternMaskMessage?: string | null;\n\t/** CSS classes from the extendedTextInteraction element (e.g. qti-height-lines-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface InlineChoiceInteractionData extends BaseInteractionData<'inlineChoiceInteraction'> {\n\tshuffle: boolean;\n\t/** Placeholder label from the QTI <label> child element; shown as the unselected \"Select…\" option */\n\tlabel: string | null;\n\t/** Placeholder text from data-prompt attribute; alternative to <label> for dropdown default option */\n\tdataPrompt?: string | null;\n\t/** The authored `title`, an accessible name when no aria label is authored */\n\ttitle?: string;\n\t/**\n\t * Choices a valid response selects: QTI 3.0 `min-choices` (§5.74.3), or 1 when the\n\t * interaction is `required` (QTI 2.1; QTI 3.0 §5.74.2). Omitted when no choice is required.\n\t */\n\tminChoices?: number;\n\t/** The author's `data-min-selections-message` (QTI 3.0); omitted when none is authored. */\n\tminSelectionsMessage?: string | null;\n\tchoices: Array<{ identifier: string; text: string; fixed?: boolean }>;\n\t/** CSS classes from the inlineChoiceInteraction element (e.g. qti-input-width-N) */\n\tinteractionClasses?: string[];\n}\n\nexport interface OrderInteractionData extends BaseInteractionData<'orderInteraction'> {\n\tshuffle: boolean;\n\tminChoices: number;\n\tmaxChoices: number;\n\tprompt: HtmlContent | null;\n\tchoices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean }>;\n\t/** The authored `orientation` attribute: `vertical` (default) or `horizontal` */\n\torientation?: string;\n\t/** CSS classes from the orderInteraction element (orientation and `qti-labels-*`) */\n\tinteractionClasses?: string[];\n\t/** Message shown while the response orders fewer than minChoices (data-min-selections-message) */\n\tminSelectionsMessage?: string | null;\n\t/** Message shown when an add is refused at the subset cap (data-max-selections-message) */\n\tmaxSelectionsMessage?: string | null;\n}\n\nexport interface AssociableChoice {\n\tidentifier: string;\n\ttext: HtmlContent;\n\tmatchMax: number;\n\t/** Minimum number of times this choice must appear in the response (QTI matchMin) */\n\tmatchMin?: number;\n\t/**\n\t * Authored `matchGroup` (QTI 2.2/3.0: the identifiers of the choices this one may be paired\n\t * with; content also uses the tokens as shared group labels). Empty/absent: unrestricted.\n\t */\n\tmatchGroup?: string[];\n\t/** Authored `fixed` (QTI fixed.SimpleAssociableChoice.Attr): pins the choice under shuffle. */\n\tfixed?: boolean;\n\t/** CSS classes from the choice element for custom renderer detection */\n\tclasses?: string[];\n}\n\nexport interface MatchInteractionData extends BaseInteractionData<'matchInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tsourceSet: AssociableChoice[];\n\ttargetSet: AssociableChoice[];\n\t/** CSS classes from the matchInteraction element (e.g. qti-choices-top, qti-match-tabular) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxAssociations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minAssociations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface AssociateInteractionData extends BaseInteractionData<'associateInteraction'> {\n\tshuffle: boolean;\n\tmaxAssociations: number;\n\tminAssociations?: number;\n\tprompt: HtmlContent | null;\n\tchoices: AssociableChoice[];\n}\n\nexport interface GapMatchInteractionData extends BaseInteractionData<'gapMatchInteraction'> {\n\tshuffle: boolean;\n\tprompt: HtmlContent | null;\n\tgapTexts: Array<{\n\t\tidentifier: string;\n\t\ttext: string;\n\t\tmatchMax: number;\n\t\t/** Minimum number of gaps this choice must fill (QTI matchMin); absent means 0. */\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\t/** Authored `fixed` (a QTI 2.1 attribute on gapText): pins the choice under shuffle. */\n\t\tfixed?: boolean;\n\t}>;\n\t/**\n\t * Image choices from gapImg (QTI 2.x) / qti-gap-img (QTI 3.0); optional so\n\t * hand-built text-only data stays valid. `src` passes the resource-URL policy\n\t * through the module's delivery field.\n\t */\n\tgapImages?: Array<{\n\t\tidentifier: string;\n\t\tsrc: string;\n\t\talt: string;\n\t\tmatchMax: number;\n\t\t/** Minimum number of gaps this choice must fill (QTI matchMin); absent means 0. */\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\t/**\n\t\t * The gapImg's authored `objectLabel` (QTI 2.1 `objectLabel.GapImg.Attr`,\n\t\t * QTI 3.0 `object-label`). Names the label for assistive technology when\n\t\t * the image itself carries no text alternative.\n\t\t */\n\t\tobjectLabel?: string;\n\t\t/** Authored `fixed` (a QTI 2.1 attribute on gapImg): pins the choice under shuffle. */\n\t\tfixed?: boolean;\n\t\twidth?: number;\n\t\theight?: number;\n\t}>;\n\t/** Identifiers of the `<gap>` elements, in reading order (what the extractor delivers). */\n\tgaps: string[];\n\t/**\n\t * The most associations the candidate may make (QTI `maxAssociations`); 0 means no\n\t * restriction. The extractor always delivers it: absent means 1 in QTI 2.2 and 3.0 and\n\t * 0 in QTI 2.1, which has no such attribute. Optional so hand-built data stays valid;\n\t * missing is treated as 0.\n\t */\n\tmaxAssociations?: number;\n\t/**\n\t * The associations a valid response makes (QTI 2.2 `minAssociations`; QTI 3.0 §5.57.2).\n\t * Present only when above 0.\n\t */\n\tminAssociations?: number;\n\t/**\n\t * Authored `matchGroup` tokens per gap identifier (QTI 2.2/3.0: the identifiers of the\n\t * choices that may be matched with this gap). Present only when a gap authors one.\n\t */\n\tgapMatchGroups?: Record<string, string[]>;\n\t/**\n\t * Identifiers of the gaps authored `required`: a valid response fills each of them (QTI 2.1\n\t * gap; QTI 3.0 §5.55.5). Present only when a gap is required.\n\t */\n\trequiredGaps?: string[];\n\t/** Finalized HTML template containing `[GAP:identifier]` text markers. */\n\tpromptText: HtmlContent;\n\t/** CSS classes from the gapMatchInteraction element (e.g. qti-choices-top, qti-choices-bottom) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface SliderInteractionData extends BaseInteractionData<'sliderInteraction'> {\n\tlowerBound: number;\n\tupperBound: number;\n\tstep: number;\n\t/** Authored `stepLabel` attribute: render a label at each step interval. */\n\tstepLabel?: boolean;\n\torientation: string;\n\treverse: boolean;\n\tprompt: HtmlContent | null;\n}\n\nexport interface ImageData {\n\ttype: 'svg' | 'image';\n\tcontent?: HtmlContent;\n\tsrc?: string;\n\t/**\n\t * The authored pixel dimensions, when the item declares them. Absent when it\n\t * does not: a raster image's natural size (once loaded) is the pixel space\n\t * the graphic interactions' coords and points are authored in.\n\t */\n\twidth?: string;\n\theight?: string;\n\t/** Short text alternative extracted from the QTI source (see `shared/imageAlt.ts`). */\n\talt?: string;\n\t/** Longer description for complex images (SVG `<desc>`, resolved aria description). */\n\taltDescription?: string;\n\t/** True only when the author explicitly marked the image decorative (`<img alt=\"\">`). */\n\tdecorative?: boolean;\n}\n\nexport interface HotspotChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\t/** Author-provided label for the hotspot; used as accessible aria-label */\n\thotspotLabel?: string;\n}\n\nexport interface HotspotInteractionData extends BaseInteractionData<'hotspotInteraction'> {\n\tmaxChoices: number;\n\tminChoices?: number;\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: HotspotChoice[];\n\t/** CSS classes from the hotspotInteraction element (e.g. qti-selections-light, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface AssociableHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n\t/** Minimum number of labels this hotspot must take (QTI matchMin); absent means 0. */\n\tmatchMin?: number;\n\t/** Authored `matchGroup`: the identifiers of the labels that may be matched with this hotspot. */\n\tmatchGroup?: string[];\n\t/**\n\t * Authored `hotspotLabel`: the zone's name for assistive technology.\n\t * Absent when the author gave none; the renderer then names the zone generically.\n\t */\n\thotspotLabel?: string;\n}\n\nexport interface GraphicGapMatchInteractionData extends BaseInteractionData<'graphicGapMatchInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\tmaxAssociations: number;\n\t/**\n\t * The associations a valid response makes (QTI 2.2 `minAssociations`; QTI 3.0 §5.60.1).\n\t * Present only when above 0.\n\t */\n\tminAssociations?: number;\n\tgapTexts: Array<{\n\t\tidentifier: string;\n\t\ttext: string;\n\t\tmatchMax: number;\n\t\t/** Minimum number of hotspots this label must fill (QTI matchMin); absent means 0. */\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t}>;\n\t/** Image-based draggable labels (gapImg elements); rendered as <img> in the choice pool */\n\tgapImages: Array<{\n\t\tidentifier: string;\n\t\tsrc: string;\n\t\talt: string;\n\t\tmatchMax: number;\n\t\t/** Minimum number of hotspots this label must fill (QTI matchMin); absent means 0. */\n\t\tmatchMin?: number;\n\t\tmatchGroup?: string[];\n\t\t/**\n\t\t * The gapImg's authored `objectLabel` (QTI 2.1 `objectLabel.GapImg.Attr`,\n\t\t * QTI 3.0 `object-label`). Names the label for assistive technology when\n\t\t * the image itself carries no text alternative.\n\t\t */\n\t\tobjectLabel?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\t}>;\n\thotspots: AssociableHotspot[];\n\t/** CSS classes from the graphicGapMatchInteraction element (e.g. qti-choices-top, qti-selections-dark) */\n\tinteractionClasses?: string[];\n\t/** Width of the choice container in px (data-choices-container-width) */\n\tchoicesContainerWidth?: string | null;\n\t/** Message shown when candidate exceeds max associations */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below min associations */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface UploadInteractionData extends BaseInteractionData<'uploadInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Allowed MIME types / extensions (vendor-dependent); empty = accept any */\n\tfileTypes: string[];\n\trawAttributes: Record<string, string>;\n}\n\nexport interface DrawingInteractionData extends BaseInteractionData<'drawingInteraction'> {\n\tprompt: HtmlContent | null;\n\t/** Optional background image/SVG to draw on top of */\n\timageData: ImageData | null;\n\trawAttributes: Record<string, string>;\n}\n\nexport interface CustomInteractionData extends BaseInteractionData<'customInteraction'> {\n\tprompt: HtmlContent | null;\n\trawAttributes: Record<string, string>;\n\t/** Outer XML snippet for debugging (best-effort) */\n\txml: string;\n}\n\n/** Canonical interaction data for QTI 2.x and 3.0 Portable Custom Interactions. */\nexport interface PortableCustomInteractionData\n\textends BaseInteractionData<'portableCustomInteraction'>,\n\t\tExtractedPci {}\n\n/** One authored `<source>` of an audio or video element. */\nexport interface MediaElementSource {\n\tsrc: string;\n\tmimeType: string;\n}\n\n/** The timed text track kinds HTML defines for `<track>`. */\nexport type MediaTrackKind = 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';\n\n/** One authored `<track>` of an audio or video element: captions, subtitles, descriptions. */\nexport interface MediaElementTrack {\n\tsrc: string;\n\tkind: MediaTrackKind;\n\tsrclang?: string;\n\tlabel?: string;\n\tdefault?: boolean;\n}\n\nexport interface MediaElement {\n\ttype: 'audio' | 'video' | 'object';\n\t/** The object's `data`, or the first source of an audio or video element. */\n\tsrc: string;\n\tmimeType: string;\n\twidth?: number;\n\theight?: number;\n\t/** Every source of an audio or video element, in document order (the browser picks the first it can play). */\n\tsources?: MediaElementSource[];\n\t/** Every text track of an audio or video element, in document order. */\n\ttracks?: MediaElementTrack[];\n\t/** The authored `crossorigin` mode; cross-origin caption files load only with one. */\n\tcrossOrigin?: 'anonymous' | 'use-credentials';\n}\n\nexport interface MediaInteractionData extends BaseInteractionData<'mediaInteraction'> {\n\tprompt: HtmlContent | null;\n\tautostart: boolean;\n\tminPlays: number;\n\tmaxPlays: number; // 0 = unlimited\n\tloop: boolean;\n\tmediaElement: MediaElement;\n\t/** Whether the renderer should allow <object> embeds for this interaction (default false) */\n\tallowObjectEmbeds?: boolean;\n}\n\nexport interface HottextChoice {\n\tidentifier: string;\n\ttext: string;\n}\n\nexport interface HottextInteractionData extends BaseInteractionData<'hottextInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\tcontentHtml: HtmlContent;\n\thottextChoices: HottextChoice[];\n\t/** CSS classes from the hottextInteraction element (e.g. qti-input-control-hidden) */\n\tinteractionClasses?: string[];\n\t/** Message shown when candidate exceeds maxChoices */\n\tmaxSelectionsMessage?: string | null;\n\t/** Message shown when candidate submits below minChoices */\n\tminSelectionsMessage?: string | null;\n}\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface SelectPointInteractionData extends BaseInteractionData<'selectPointInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\timageData: ImageData | null;\n}\n\nexport interface GraphicOrderChoice {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tlabel: string;\n}\n\nexport interface GraphicOrderInteractionData extends BaseInteractionData<'graphicOrderInteraction'> {\n\tprompt: HtmlContent | null;\n\timageData: ImageData | null;\n\thotspotChoices: GraphicOrderChoice[];\n\t/** Minimum number of hotspots the response must order (QTI minChoices); absent means 0. */\n\tminChoices?: number;\n\t/** Maximum number of hotspots the response may order (QTI maxChoices); absent means 0, no limit. */\n\tmaxChoices?: number;\n}\n\nexport interface GraphicAssociateHotspot {\n\tidentifier: string;\n\tshape: string;\n\tcoords: string;\n\tmatchMax: number;\n\tlabel: string;\n\t/**\n\t * Authored `matchGroup` (QTI 2.2/3.0: the identifiers of the hotspots this one may be\n\t * associated with; content also uses the tokens as shared group labels).\n\t */\n\tmatchGroup?: string[];\n}\n\nexport interface GraphicAssociateInteractionData extends BaseInteractionData<'graphicAssociateInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxAssociations: number;\n\tminAssociations: number;\n\timageData: ImageData | null;\n\tassociableHotspots: GraphicAssociateHotspot[];\n}\n\nexport interface PositionObjectStage {\n\tidentifier: string;\n\tmatchMax: number;\n\tobjectData: {\n\t\ttype: 'image' | 'svg';\n\t\tsrc?: string;\n\t\tcontent?: HtmlContent;\n\t\twidth?: string;\n\t\theight?: string;\n\t} | null;\n\tlabel: string;\n}\n\n/**\n * A point on a draggable object image, in that image's own pixel coordinates,\n * measured from its top-left corner (QTI `centerPoint`, horizontal then vertical).\n */\nexport interface PositionObjectCenterPoint {\n\tx: number;\n\ty: number;\n}\n\nexport interface PositionObjectInteractionData extends BaseInteractionData<'positionObjectInteraction'> {\n\tprompt: HtmlContent | null;\n\tmaxChoices: number;\n\tminChoices: number;\n\t/**\n\t * The point on the object image treated as the object's position: it is the\n\t * point placed under the candidate's pointer and recorded, in stage\n\t * coordinates, as the response. `null` is the QTI default, the centre of the\n\t * object image's bounding rectangle.\n\t */\n\tcenterPoint: PositionObjectCenterPoint | null;\n\timageData: ImageData | null;\n\tpositionObjectStages: PositionObjectStage[];\n}\n\nexport interface EndAttemptInteractionData extends BaseInteractionData<'endAttemptInteraction'> {\n\tprompt: HtmlContent | null;\n\ttitle: string;\n\t/** Whether this interaction counts as an attempt (default: true) */\n\tcountAttempt: boolean;\n}\n\n/** Closed union of the interaction shapes supplied by the standard modules. */\nexport type StandardInteractionData =\n\t| ChoiceInteractionData\n\t| TextEntryInteractionData\n\t| ExtendedTextInteractionData\n\t| InlineChoiceInteractionData\n\t| OrderInteractionData\n\t| MatchInteractionData\n\t| AssociateInteractionData\n\t| GapMatchInteractionData\n\t| SliderInteractionData\n\t| HotspotInteractionData\n\t| GraphicGapMatchInteractionData\n\t| UploadInteractionData\n\t| DrawingInteractionData\n\t| CustomInteractionData\n\t| PortableCustomInteractionData\n\t| MediaInteractionData\n\t| HottextInteractionData\n\t| SelectPointInteractionData\n\t| GraphicOrderInteractionData\n\t| GraphicAssociateInteractionData\n\t| PositionObjectInteractionData\n\t| EndAttemptInteractionData;\n\n/**\n * Map interaction types to their data structures\n * TypeScript will ensure registrations use the correct data type\n */\nexport interface InteractionDataMap {\n\tchoiceInteraction: ChoiceInteractionData;\n\ttextEntryInteraction: TextEntryInteractionData;\n\textendedTextInteraction: ExtendedTextInteractionData;\n\tinlineChoiceInteraction: InlineChoiceInteractionData;\n\torderInteraction: OrderInteractionData;\n\tmatchInteraction: MatchInteractionData;\n\tassociateInteraction: AssociateInteractionData;\n\tgapMatchInteraction: GapMatchInteractionData;\n\tsliderInteraction: SliderInteractionData;\n\thotspotInteraction: HotspotInteractionData;\n\tgraphicGapMatchInteraction: GraphicGapMatchInteractionData;\n\tuploadInteraction: UploadInteractionData;\n\tdrawingInteraction: DrawingInteractionData;\n\tcustomInteraction: CustomInteractionData;\n\tportableCustomInteraction: PortableCustomInteractionData;\n\tmediaInteraction: MediaInteractionData;\n\thottextInteraction: HottextInteractionData;\n\tselectPointInteraction: SelectPointInteractionData;\n\tgraphicOrderInteraction: GraphicOrderInteractionData;\n\tgraphicAssociateInteraction: GraphicAssociateInteractionData;\n\tpositionObjectInteraction: PositionObjectInteractionData;\n\tendAttemptInteraction: EndAttemptInteractionData;\n}\n\n/**\n * Map interaction types to the value a component's `qti-change` event (and its\n * `onChange` callback) carries: the raw component output, before the player\n * normalizes it into the QTI response declaration. The response variable the\n * player stores is that normalized value, returned by `Player.getResponses`.\n *\n * Each entry is derived from the component's emission sites; see\n * `tests/web-components/interaction-value-map.test.ts` for the compile-time pins.\n */\nexport interface InteractionValueMap {\n\t/** ChoiceInteraction: the selected identifier, the selected identifiers, or null on \"clear answer\". */\n\tchoiceInteraction: string | string[] | null;\n\t/** InlineTextEntry: the text as typed. */\n\ttextEntryInteraction: string;\n\t/** ExtendedTextInteraction: `createExtendedTextResponse`'s value; null once emptied. */\n\textendedTextInteraction: string | number | Array<string | number> | ExtendedTextNumericRecord | null;\n\t/** InlineChoice: the chosen option identifier. */\n\tinlineChoiceInteraction: string;\n\t/** OrderInteraction: the ordered identifiers; null when a subset order is cleared. */\n\torderInteraction: string[] | null;\n\t/** MatchInteraction: pairs as `\"source target\"` strings. */\n\tmatchInteraction: string[];\n\t/** AssociateInteraction: associations as `\"A B\"` strings. */\n\tassociateInteraction: string[];\n\t/** GapMatchInteraction: pairs as `\"gapText gap\"` strings. */\n\tgapMatchInteraction: string[];\n\t/** SliderInteraction: the slider value. */\n\tsliderInteraction: number;\n\t/** HotspotInteraction: single select emits the identifier or null (cleared); multiple emits the identifiers ([] when cleared). */\n\thotspotInteraction: string | string[] | null;\n\t/** GraphicGapMatchInteraction: pairs as `\"gapText hotspot\"` strings. */\n\tgraphicGapMatchInteraction: string[];\n\t/** UploadInteraction: the file response; null when cleared. */\n\tuploadInteraction: QTIFileResponse | null;\n\t/** DrawingInteraction: the drawing response; null when the canvas is cleared. */\n\tdrawingInteraction: QTIFileResponse | null;\n\t/** CustomInteraction fallback: the manual-entry value; null when cleared. */\n\tcustomInteraction: string | null;\n\t/** PortableCustomInteraction: whatever the PCI module publishes. */\n\tportableCustomInteraction: unknown;\n\t/** MediaInteraction: the play count so far. */\n\tmediaInteraction: number;\n\t/** HottextInteraction: single select emits the identifier or null (cleared); multiple emits the identifiers. */\n\thottextInteraction: string | string[] | null;\n\t/** SelectPointInteraction: `maxChoices=1` emits `\"x y\"` or null (cleared); otherwise the `\"x y\"` strings. */\n\tselectPointInteraction: string | string[] | null;\n\t/** GraphicOrderInteraction: the ordered hotspot identifiers; null when a subset order is cleared. */\n\tgraphicOrderInteraction: string[] | null;\n\t/** GraphicAssociateInteraction: associations as `\"A B\"` strings. */\n\tgraphicAssociateInteraction: string[];\n\t/** PositionObjectInteraction: placements as `\"x y\"` strings in natural image pixels. */\n\tpositionObjectInteraction: string[];\n\t/** EndAttemptInteraction: always emitted as `true`. */\n\tendAttemptInteraction: boolean;\n}\n"]}
@@ -12,6 +12,15 @@ export interface TextEntryData {
12
12
  patternMask: string | null;
13
13
  placeholderText: string;
14
14
  format?: string;
15
+ baseType?: string;
16
+ /** QTI stringInteraction `base`: the number base a numeric response is entered in, when not 10. */
17
+ base?: number;
18
+ /**
19
+ * QTI stringInteraction `stringIdentifier`: a second response, of base-type string, that
20
+ * captures the text the candidate entered before a numeric response reads it.
21
+ */
22
+ stringIdentifier?: string;
23
+ title?: string;
15
24
  }
16
25
  /**
17
26
  * Standard QTI text entry interaction extractor
@@ -26,11 +26,20 @@ export const standardTextEntryExtractor = {
26
26
  const format = utils.getAttribute(element, 'format', '');
27
27
  const interactionClasses = utils.getClasses(element);
28
28
  const patternMaskMessage = utils.getAttribute(element, 'data-patternmask-message', '') || null;
29
+ // The response's baseType picks the on-screen keyboard (numeric for integer/float).
30
+ const baseType = context.declarations.get(context.responseId)?.baseType;
31
+ const base = utils.getNumberAttribute(element, 'base', 10);
32
+ const stringIdentifier = utils.getAttribute(element, 'stringIdentifier', '').trim() || undefined;
33
+ const title = utils.getAttribute(element, 'title', '').trim();
29
34
  return {
30
35
  expectedLength,
31
36
  patternMask: patternMask || null,
32
37
  placeholderText,
33
38
  ...(format ? { format } : {}),
39
+ ...(baseType ? { baseType } : {}),
40
+ ...(Number.isInteger(base) && base >= 2 && base <= 36 && base !== 10 ? { base } : {}),
41
+ ...(stringIdentifier ? { stringIdentifier } : {}),
42
+ ...(title ? { title } : {}),
34
43
  ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
35
44
  ...(patternMaskMessage ? { patternMaskMessage } : {}),
36
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/text-entry/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAoC;IAC1E,EAAE,EAAE,4BAA4B;IAChC,IAAI,EAAE,qCAAqC;IAC3C,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,sBAAsB,CAAC;IACtC,WAAW,EAAE,gEAAgE;IAE7E,SAAS,CAAC,OAAO,EAAE,QAAQ;QAC1B,wEAAwE;QACxE,OAAO,CACN,OAAO,CAAC,UAAU,KAAK,sBAAsB,IAAI,OAAO,CAAC,UAAU,KAAK,4BAA4B,CACpG,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAE1B,qBAAqB;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC/E,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;QACnE,MAAM,eAAe,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QACzD,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACrD,MAAM,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,0BAA0B,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC;QAE/F,OAAO;YACN,cAAc;YACd,WAAW,EAAE,WAAW,IAAI,IAAI;YAChC,eAAe;YACf,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7B,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrD,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,IAAI;QACZ,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,0BAA0B;QAC1B,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,IAAI,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC;YAChC,QAAQ,CAAC,IAAI,CACZ,mBAAmB,IAAI,CAAC,cAAc,0DAA0D,CAChG,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 textEntryInteraction extractor\n *\n * Extracts data from textEntryInteraction elements (inline text input)\n */\n\nimport type { ElementExtractor } from '../../extraction/types.js';\n\n/**\n * Text entry data extracted from textEntryInteraction elements\n */\nexport interface TextEntryData {\n\texpectedLength: number;\n\tpatternMask: string | null;\n\tplaceholderText: string;\n\tformat?: string;\n}\n\n/**\n * Standard QTI text entry interaction extractor\n * Handles textEntryInteraction elements (inline text input)\n */\nexport const standardTextEntryExtractor: ElementExtractor<TextEntryData> = {\n\tid: 'qti:text-entry-interaction',\n\tname: 'QTI Standard Text Entry Interaction',\n\tpriority: 10,\n\telementTypes: ['textEntryInteraction'],\n\tdescription: 'Extracts standard QTI textEntryInteraction (inline text input)',\n\n\tcanHandle(element, _context) {\n\t\t// All textEntryInteraction elements are standard (both QTI 2.x and 3.0)\n\t\treturn (\n\t\t\telement.rawTagName === 'textEntryInteraction' || element.rawTagName === 'qti-text-entry-interaction'\n\t\t);\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\n\t\t// Extract attributes\n\t\tconst expectedLength = utils.getNumberAttribute(element, 'expectedLength', 20);\n\t\tconst patternMask = utils.getAttribute(element, 'patternMask', '');\n\t\tconst placeholderText = utils.getAttribute(element, 'placeholderText', '');\n\t\tconst format = utils.getAttribute(element, 'format', '');\n\t\tconst interactionClasses = utils.getClasses(element);\n\t\tconst patternMaskMessage = utils.getAttribute(element, 'data-patternmask-message', '') || null;\n\n\t\treturn {\n\t\t\texpectedLength,\n\t\t\tpatternMask: patternMask || null,\n\t\t\tplaceholderText,\n\t\t\t...(format ? { format } : {}),\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\n\t\t\t...(patternMaskMessage ? { patternMaskMessage } : {}),\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\t// Validate expectedLength\n\t\tif (data.expectedLength < 1) {\n\t\t\terrors.push('expectedLength must be positive');\n\t\t}\n\n\t\tif (data.expectedLength > 1000) {\n\t\t\twarnings.push(\n\t\t\t\t`expectedLength (${data.expectedLength}) is very large - consider using extendedTextInteraction`\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/text-entry/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAoC;IAC1E,EAAE,EAAE,4BAA4B;IAChC,IAAI,EAAE,qCAAqC;IAC3C,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,sBAAsB,CAAC;IACtC,WAAW,EAAE,gEAAgE;IAE7E,SAAS,CAAC,OAAO,EAAE,QAAQ;QAC1B,wEAAwE;QACxE,OAAO,CACN,OAAO,CAAC,UAAU,KAAK,sBAAsB,IAAI,OAAO,CAAC,UAAU,KAAK,4BAA4B,CACpG,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAE1B,qBAAqB;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC/E,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;QACnE,MAAM,eAAe,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QACzD,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACrD,MAAM,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,0BAA0B,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC;QAC/F,oFAAoF;QACpF,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC;QACxE,MAAM,IAAI,GAAG,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAC3D,MAAM,gBAAgB,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;QACjG,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAE9D,OAAO;YACN,cAAc;YACd,WAAW,EAAE,WAAW,IAAI,IAAI;YAChC,eAAe;YACf,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrF,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrD,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,IAAI;QACZ,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,0BAA0B;QAC1B,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,IAAI,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC;YAChC,QAAQ,CAAC,IAAI,CACZ,mBAAmB,IAAI,CAAC,cAAc,0DAA0D,CAChG,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 textEntryInteraction extractor\n *\n * Extracts data from textEntryInteraction elements (inline text input)\n */\n\nimport type { ElementExtractor } from '../../extraction/types.js';\n\n/**\n * Text entry data extracted from textEntryInteraction elements\n */\nexport interface TextEntryData {\n\texpectedLength: number;\n\tpatternMask: string | null;\n\tplaceholderText: string;\n\tformat?: string;\n\tbaseType?: string;\n\t/** QTI stringInteraction `base`: the number base a numeric response is entered in, when not 10. */\n\tbase?: number;\n\t/**\n\t * QTI stringInteraction `stringIdentifier`: a second response, of base-type string, that\n\t * captures the text the candidate entered before a numeric response reads it.\n\t */\n\tstringIdentifier?: string;\n\ttitle?: string;\n}\n\n/**\n * Standard QTI text entry interaction extractor\n * Handles textEntryInteraction elements (inline text input)\n */\nexport const standardTextEntryExtractor: ElementExtractor<TextEntryData> = {\n\tid: 'qti:text-entry-interaction',\n\tname: 'QTI Standard Text Entry Interaction',\n\tpriority: 10,\n\telementTypes: ['textEntryInteraction'],\n\tdescription: 'Extracts standard QTI textEntryInteraction (inline text input)',\n\n\tcanHandle(element, _context) {\n\t\t// All textEntryInteraction elements are standard (both QTI 2.x and 3.0)\n\t\treturn (\n\t\t\telement.rawTagName === 'textEntryInteraction' || element.rawTagName === 'qti-text-entry-interaction'\n\t\t);\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\n\t\t// Extract attributes\n\t\tconst expectedLength = utils.getNumberAttribute(element, 'expectedLength', 20);\n\t\tconst patternMask = utils.getAttribute(element, 'patternMask', '');\n\t\tconst placeholderText = utils.getAttribute(element, 'placeholderText', '');\n\t\tconst format = utils.getAttribute(element, 'format', '');\n\t\tconst interactionClasses = utils.getClasses(element);\n\t\tconst patternMaskMessage = utils.getAttribute(element, 'data-patternmask-message', '') || null;\n\t\t// The response's baseType picks the on-screen keyboard (numeric for integer/float).\n\t\tconst baseType = context.declarations.get(context.responseId)?.baseType;\n\t\tconst base = utils.getNumberAttribute(element, 'base', 10);\n\t\tconst stringIdentifier = utils.getAttribute(element, 'stringIdentifier', '').trim() || undefined;\n\t\tconst title = utils.getAttribute(element, 'title', '').trim();\n\n\t\treturn {\n\t\t\texpectedLength,\n\t\t\tpatternMask: patternMask || null,\n\t\t\tplaceholderText,\n\t\t\t...(format ? { format } : {}),\n\t\t\t...(baseType ? { baseType } : {}),\n\t\t\t...(Number.isInteger(base) && base >= 2 && base <= 36 && base !== 10 ? { base } : {}),\n\t\t\t...(stringIdentifier ? { stringIdentifier } : {}),\n\t\t\t...(title ? { title } : {}),\n\t\t\t...(interactionClasses.length > 0 ? { interactionClasses } : {}),\n\t\t\t...(patternMaskMessage ? { patternMaskMessage } : {}),\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\t// Validate expectedLength\n\t\tif (data.expectedLength < 1) {\n\t\t\terrors.push('expectedLength must be positive');\n\t\t}\n\n\t\tif (data.expectedLength > 1000) {\n\t\t\twarnings.push(\n\t\t\t\t`expectedLength (${data.expectedLength}) is very large - consider using extendedTextInteraction`\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,10 @@
1
+ import type { TextEntryInteractionData } from '../shared/types.js';
2
+ /**
3
+ * The inline style of a text-entry blank: the authored `expectedLength` hint as its width, with
4
+ * the minimum usable size, and a cap that keeps the blank inside its container (WCAG 2.2
5
+ * SC 1.4.10 Reflow) — at a 320 CSS px viewport (400% zoom), an authored width larger than the
6
+ * viewport must not force two-dimensional scrolling.
7
+ */
8
+ export declare function textEntryInputStyle(interaction: Pick<TextEntryInteractionData, 'expectedLength'>, options?: {
9
+ widthClass?: string;
10
+ }): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The inline style of a text-entry blank: the authored `expectedLength` hint as its width, with
3
+ * the minimum usable size, and a cap that keeps the blank inside its container (WCAG 2.2
4
+ * SC 1.4.10 Reflow) — at a 320 CSS px viewport (400% zoom), an authored width larger than the
5
+ * viewport must not force two-dimensional scrolling.
6
+ */
7
+ export function textEntryInputStyle(interaction, options) {
8
+ // QTI 3.0 Shared Vocabulary: a qti-input-width-N class owns the width in character units.
9
+ const width = options?.widthClass ? '' : `width: ${interaction.expectedLength * 8}px; `;
10
+ return `${width}min-width: 100px; max-width: 100%; display: inline-block; margin: 0 4px;`;
11
+ }
12
+ //# sourceMappingURL=inlineInputStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineInputStyle.js","sourceRoot":"","sources":["../../../src/interactions/text-entry/inlineInputStyle.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAClC,WAA6D,EAC7D,OAAiC;IAEjC,0FAA0F;IAC1F,MAAM,KAAK,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,WAAW,CAAC,cAAc,GAAG,CAAC,MAAM,CAAC;IACxF,OAAO,GAAG,KAAK,0EAA0E,CAAC;AAC3F,CAAC","sourcesContent":["import type { TextEntryInteractionData } from '../shared/types.js';\n\n/**\n * The inline style of a text-entry blank: the authored `expectedLength` hint as its width, with\n * the minimum usable size, and a cap that keeps the blank inside its container (WCAG 2.2\n * SC 1.4.10 Reflow) — at a 320 CSS px viewport (400% zoom), an authored width larger than the\n * viewport must not force two-dimensional scrolling.\n */\nexport function textEntryInputStyle(\n\tinteraction: Pick<TextEntryInteractionData, 'expectedLength'>,\n\toptions?: { widthClass?: string },\n): string {\n\t// QTI 3.0 Shared Vocabulary: a qti-input-width-N class owns the width in character units.\n\tconst width = options?.widthClass ? '' : `width: ${interaction.expectedLength * 8}px; `;\n\treturn `${width}min-width: 100px; max-width: 100%; display: inline-block; margin: 0 4px;`;\n}\n"]}