@longsightgroup/qti3-player 0.4.0 → 0.5.4

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 (291) hide show
  1. package/README.md +146 -13
  2. package/dist/content/content-dom.d.ts +11 -0
  3. package/dist/content/content-dom.d.ts.map +1 -0
  4. package/dist/content/content-dom.js +262 -0
  5. package/dist/content/content-dom.js.map +1 -0
  6. package/dist/content/content-renderer.d.ts +17 -0
  7. package/dist/content/content-renderer.d.ts.map +1 -0
  8. package/dist/content/content-renderer.js +82 -0
  9. package/dist/content/content-renderer.js.map +1 -0
  10. package/dist/controls/remove-button.d.ts +3 -0
  11. package/dist/controls/remove-button.d.ts.map +1 -0
  12. package/dist/controls/remove-button.js +12 -0
  13. package/dist/controls/remove-button.js.map +1 -0
  14. package/dist/index.d.ts +13 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +6 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/interactions/choice-interaction.d.ts +4 -0
  19. package/dist/interactions/choice-interaction.d.ts.map +1 -0
  20. package/dist/interactions/choice-interaction.js +81 -0
  21. package/dist/interactions/choice-interaction.js.map +1 -0
  22. package/dist/interactions/drawing-interaction.d.ts +6 -0
  23. package/dist/interactions/drawing-interaction.d.ts.map +1 -0
  24. package/dist/interactions/drawing-interaction.js +401 -0
  25. package/dist/interactions/drawing-interaction.js.map +1 -0
  26. package/dist/interactions/end-attempt-interaction.d.ts +4 -0
  27. package/dist/interactions/end-attempt-interaction.d.ts.map +1 -0
  28. package/dist/interactions/end-attempt-interaction.js +13 -0
  29. package/dist/interactions/end-attempt-interaction.js.map +1 -0
  30. package/dist/interactions/gap-match-interaction.d.ts +4 -0
  31. package/dist/interactions/gap-match-interaction.d.ts.map +1 -0
  32. package/dist/interactions/gap-match-interaction.js +277 -0
  33. package/dist/interactions/gap-match-interaction.js.map +1 -0
  34. package/dist/interactions/graphic-associate-interaction.d.ts +4 -0
  35. package/dist/interactions/graphic-associate-interaction.d.ts.map +1 -0
  36. package/dist/interactions/graphic-associate-interaction.js +297 -0
  37. package/dist/interactions/graphic-associate-interaction.js.map +1 -0
  38. package/dist/interactions/graphic-context.d.ts +3 -0
  39. package/dist/interactions/graphic-context.d.ts.map +1 -0
  40. package/dist/interactions/graphic-context.js +35 -0
  41. package/dist/interactions/graphic-context.js.map +1 -0
  42. package/dist/interactions/hotspot-interaction.d.ts +4 -0
  43. package/dist/interactions/hotspot-interaction.d.ts.map +1 -0
  44. package/dist/interactions/hotspot-interaction.js +68 -0
  45. package/dist/interactions/hotspot-interaction.js.map +1 -0
  46. package/dist/interactions/hottext-interaction.d.ts +3 -0
  47. package/dist/interactions/hottext-interaction.d.ts.map +1 -0
  48. package/dist/interactions/hottext-interaction.js +66 -0
  49. package/dist/interactions/hottext-interaction.js.map +1 -0
  50. package/dist/interactions/inline-choice-interaction.d.ts +4 -0
  51. package/dist/interactions/inline-choice-interaction.d.ts.map +1 -0
  52. package/dist/interactions/inline-choice-interaction.js +31 -0
  53. package/dist/interactions/inline-choice-interaction.js.map +1 -0
  54. package/dist/interactions/inline-controls.d.ts +6 -0
  55. package/dist/interactions/inline-controls.d.ts.map +1 -0
  56. package/dist/interactions/inline-controls.js +15 -0
  57. package/dist/interactions/inline-controls.js.map +1 -0
  58. package/dist/interactions/interaction-diagnostics.d.ts +7 -0
  59. package/dist/interactions/interaction-diagnostics.d.ts.map +1 -0
  60. package/dist/interactions/interaction-diagnostics.js +137 -0
  61. package/dist/interactions/interaction-diagnostics.js.map +1 -0
  62. package/dist/interactions/interaction-dispatch.d.ts +2 -0
  63. package/dist/interactions/interaction-dispatch.d.ts.map +1 -0
  64. package/dist/interactions/interaction-dispatch.js +2 -0
  65. package/dist/interactions/interaction-dispatch.js.map +1 -0
  66. package/dist/interactions/interaction-label.d.ts +4 -0
  67. package/dist/interactions/interaction-label.d.ts.map +1 -0
  68. package/dist/interactions/interaction-label.js +8 -0
  69. package/dist/interactions/interaction-label.js.map +1 -0
  70. package/dist/interactions/interaction-registry.d.ts +24 -0
  71. package/dist/interactions/interaction-registry.d.ts.map +1 -0
  72. package/dist/interactions/interaction-registry.js +138 -0
  73. package/dist/interactions/interaction-registry.js.map +1 -0
  74. package/dist/interactions/match-interaction.d.ts +4 -0
  75. package/dist/interactions/match-interaction.d.ts.map +1 -0
  76. package/dist/interactions/match-interaction.js +188 -0
  77. package/dist/interactions/match-interaction.js.map +1 -0
  78. package/dist/interactions/object-asset.d.ts +8 -0
  79. package/dist/interactions/object-asset.d.ts.map +1 -0
  80. package/dist/interactions/object-asset.js +182 -0
  81. package/dist/interactions/object-asset.js.map +1 -0
  82. package/dist/interactions/pair-interaction.d.ts +4 -0
  83. package/dist/interactions/pair-interaction.d.ts.map +1 -0
  84. package/dist/interactions/pair-interaction.js +125 -0
  85. package/dist/interactions/pair-interaction.js.map +1 -0
  86. package/dist/interactions/point-value.d.ts +16 -0
  87. package/dist/interactions/point-value.d.ts.map +1 -0
  88. package/dist/interactions/point-value.js +37 -0
  89. package/dist/interactions/point-value.js.map +1 -0
  90. package/dist/interactions/portable-custom-interaction.d.ts +16 -0
  91. package/dist/interactions/portable-custom-interaction.d.ts.map +1 -0
  92. package/dist/interactions/portable-custom-interaction.js +97 -0
  93. package/dist/interactions/portable-custom-interaction.js.map +1 -0
  94. package/dist/interactions/position-object-interaction.d.ts +4 -0
  95. package/dist/interactions/position-object-interaction.d.ts.map +1 -0
  96. package/dist/interactions/position-object-interaction.js +177 -0
  97. package/dist/interactions/position-object-interaction.js.map +1 -0
  98. package/dist/interactions/routing.d.ts +5 -0
  99. package/dist/interactions/routing.d.ts.map +1 -0
  100. package/dist/interactions/routing.js +24 -0
  101. package/dist/interactions/routing.js.map +1 -0
  102. package/dist/interactions/select-point-interaction.d.ts +4 -0
  103. package/dist/interactions/select-point-interaction.d.ts.map +1 -0
  104. package/dist/interactions/select-point-interaction.js +166 -0
  105. package/dist/interactions/select-point-interaction.js.map +1 -0
  106. package/dist/interactions/shared.d.ts +12 -0
  107. package/dist/interactions/shared.d.ts.map +1 -0
  108. package/dist/interactions/shared.js +65 -0
  109. package/dist/interactions/shared.js.map +1 -0
  110. package/dist/interactions/text-interaction.d.ts +6 -0
  111. package/dist/interactions/text-interaction.d.ts.map +1 -0
  112. package/dist/interactions/text-interaction.js +110 -0
  113. package/dist/interactions/text-interaction.js.map +1 -0
  114. package/dist/interactions/unsupported-interaction.d.ts +4 -0
  115. package/dist/interactions/unsupported-interaction.d.ts.map +1 -0
  116. package/dist/interactions/unsupported-interaction.js +23 -0
  117. package/dist/interactions/unsupported-interaction.js.map +1 -0
  118. package/dist/interactions/upload-interaction.d.ts +4 -0
  119. package/dist/interactions/upload-interaction.d.ts.map +1 -0
  120. package/dist/interactions/upload-interaction.js +10 -0
  121. package/dist/interactions/upload-interaction.js.map +1 -0
  122. package/dist/player/attempt-availability.d.ts +6 -0
  123. package/dist/player/attempt-availability.d.ts.map +1 -0
  124. package/dist/player/attempt-availability.js +27 -0
  125. package/dist/player/attempt-availability.js.map +1 -0
  126. package/dist/player/content-state.d.ts +19 -0
  127. package/dist/player/content-state.d.ts.map +1 -0
  128. package/dist/player/content-state.js +39 -0
  129. package/dist/player/content-state.js.map +1 -0
  130. package/dist/player/dynamic-body.d.ts +7 -0
  131. package/dist/player/dynamic-body.d.ts.map +1 -0
  132. package/dist/player/dynamic-body.js +28 -0
  133. package/dist/player/dynamic-body.js.map +1 -0
  134. package/dist/player/feedback-panel.d.ts +3 -0
  135. package/dist/player/feedback-panel.d.ts.map +1 -0
  136. package/dist/player/feedback-panel.js +14 -0
  137. package/dist/player/feedback-panel.js.map +1 -0
  138. package/dist/player/fetch-xml.d.ts +2 -0
  139. package/dist/player/fetch-xml.d.ts.map +1 -0
  140. package/dist/player/fetch-xml.js +10 -0
  141. package/dist/player/fetch-xml.js.map +1 -0
  142. package/dist/player/interaction-render.d.ts +14 -0
  143. package/dist/player/interaction-render.d.ts.map +1 -0
  144. package/dist/player/interaction-render.js +51 -0
  145. package/dist/player/interaction-render.js.map +1 -0
  146. package/dist/player/render-shell.d.ts +8 -0
  147. package/dist/player/render-shell.d.ts.map +1 -0
  148. package/dist/player/render-shell.js +37 -0
  149. package/dist/player/render-shell.js.map +1 -0
  150. package/dist/player/resolve-assets.d.ts +3 -0
  151. package/dist/player/resolve-assets.d.ts.map +1 -0
  152. package/dist/player/resolve-assets.js +12 -0
  153. package/dist/player/resolve-assets.js.map +1 -0
  154. package/dist/player/validation-messages.d.ts +17 -0
  155. package/dist/player/validation-messages.d.ts.map +1 -0
  156. package/dist/player/validation-messages.js +33 -0
  157. package/dist/player/validation-messages.js.map +1 -0
  158. package/dist/player-adapter.d.ts +62 -0
  159. package/dist/player-adapter.d.ts.map +1 -0
  160. package/dist/player-adapter.js +119 -0
  161. package/dist/player-adapter.js.map +1 -0
  162. package/dist/player-dev.d.ts +4 -0
  163. package/dist/player-dev.d.ts.map +1 -0
  164. package/dist/player-dev.js +14 -0
  165. package/dist/player-dev.js.map +1 -0
  166. package/dist/player-element.d.ts +14 -1
  167. package/dist/player-element.d.ts.map +1 -1
  168. package/dist/player-element.js +57 -5
  169. package/dist/player-element.js.map +1 -1
  170. package/dist/player-locale.d.ts +8 -3
  171. package/dist/player-locale.d.ts.map +1 -1
  172. package/dist/player-locale.js +16 -175
  173. package/dist/player-locale.js.map +1 -1
  174. package/dist/player-message-catalog-default.d.ts +4 -0
  175. package/dist/player-message-catalog-default.d.ts.map +1 -0
  176. package/dist/player-message-catalog-default.js +118 -0
  177. package/dist/player-message-catalog-default.js.map +1 -0
  178. package/dist/player-message-catalog-validate.d.ts +31 -0
  179. package/dist/player-message-catalog-validate.d.ts.map +1 -0
  180. package/dist/player-message-catalog-validate.js +327 -0
  181. package/dist/player-message-catalog-validate.js.map +1 -0
  182. package/dist/player-message-catalog.d.ts +18 -0
  183. package/dist/player-message-catalog.d.ts.map +1 -0
  184. package/dist/player-message-catalog.js +40 -0
  185. package/dist/player-message-catalog.js.map +1 -0
  186. package/dist/player-message-keys.d.ts +6 -0
  187. package/dist/player-message-keys.d.ts.map +1 -0
  188. package/dist/player-message-keys.js +7 -0
  189. package/dist/player-message-keys.js.map +1 -0
  190. package/dist/player-message-manifest.d.ts +272 -0
  191. package/dist/player-message-manifest.d.ts.map +1 -0
  192. package/dist/player-message-manifest.js +83 -0
  193. package/dist/player-message-manifest.js.map +1 -0
  194. package/dist/player-message-overrides.d.ts +3 -0
  195. package/dist/player-message-overrides.d.ts.map +1 -0
  196. package/dist/player-message-overrides.js +28 -0
  197. package/dist/player-message-overrides.js.map +1 -0
  198. package/dist/player-message-resolver.d.ts +31 -0
  199. package/dist/player-message-resolver.d.ts.map +1 -0
  200. package/dist/player-message-resolver.js +110 -0
  201. package/dist/player-message-resolver.js.map +1 -0
  202. package/dist/player-messages.d.ts +0 -38
  203. package/dist/player-messages.d.ts.map +1 -1
  204. package/dist/player-types.d.ts +12 -2
  205. package/dist/player-types.d.ts.map +1 -1
  206. package/dist/reorder/a11y.d.ts +7 -0
  207. package/dist/reorder/a11y.d.ts.map +1 -0
  208. package/dist/reorder/a11y.js +34 -0
  209. package/dist/reorder/a11y.js.map +1 -0
  210. package/dist/reorder/graphic-order-interaction.d.ts +4 -0
  211. package/dist/reorder/graphic-order-interaction.d.ts.map +1 -0
  212. package/dist/reorder/graphic-order-interaction.js +205 -0
  213. package/dist/reorder/graphic-order-interaction.js.map +1 -0
  214. package/dist/reorder/list-controls.d.ts +22 -0
  215. package/dist/reorder/list-controls.d.ts.map +1 -0
  216. package/dist/reorder/list-controls.js +75 -0
  217. package/dist/reorder/list-controls.js.map +1 -0
  218. package/dist/reorder/order-interaction.d.ts +4 -0
  219. package/dist/reorder/order-interaction.d.ts.map +1 -0
  220. package/dist/reorder/order-interaction.js +54 -0
  221. package/dist/reorder/order-interaction.js.map +1 -0
  222. package/dist/styles/base-styles.d.ts +2 -0
  223. package/dist/styles/base-styles.d.ts.map +1 -0
  224. package/dist/styles/base-styles.js +133 -0
  225. package/dist/styles/base-styles.js.map +1 -0
  226. package/dist/styles/choice-hottext-styles.d.ts +2 -0
  227. package/dist/styles/choice-hottext-styles.d.ts.map +1 -0
  228. package/dist/styles/choice-hottext-styles.js +76 -0
  229. package/dist/styles/choice-hottext-styles.js.map +1 -0
  230. package/dist/styles/control-styles.d.ts +2 -0
  231. package/dist/styles/control-styles.d.ts.map +1 -0
  232. package/dist/styles/control-styles.js +114 -0
  233. package/dist/styles/control-styles.js.map +1 -0
  234. package/dist/styles/drawing-styles.d.ts +2 -0
  235. package/dist/styles/drawing-styles.d.ts.map +1 -0
  236. package/dist/styles/drawing-styles.js +30 -0
  237. package/dist/styles/drawing-styles.js.map +1 -0
  238. package/dist/styles/gap-match-styles.d.ts +2 -0
  239. package/dist/styles/gap-match-styles.d.ts.map +1 -0
  240. package/dist/styles/gap-match-styles.js +33 -0
  241. package/dist/styles/gap-match-styles.js.map +1 -0
  242. package/dist/styles/graphic-styles.d.ts +2 -0
  243. package/dist/styles/graphic-styles.d.ts.map +1 -0
  244. package/dist/styles/graphic-styles.js +289 -0
  245. package/dist/styles/graphic-styles.js.map +1 -0
  246. package/dist/styles/match-pair-styles.d.ts +2 -0
  247. package/dist/styles/match-pair-styles.d.ts.map +1 -0
  248. package/dist/styles/match-pair-styles.js +62 -0
  249. package/dist/styles/match-pair-styles.js.map +1 -0
  250. package/dist/styles/text-slider-styles.d.ts +2 -0
  251. package/dist/styles/text-slider-styles.d.ts.map +1 -0
  252. package/dist/styles/text-slider-styles.js +35 -0
  253. package/dist/styles/text-slider-styles.js.map +1 -0
  254. package/package.json +8 -8
  255. package/src/controls/remove-button.ts +8 -5
  256. package/src/index.ts +61 -5
  257. package/src/interactions/choice-interaction.ts +6 -2
  258. package/src/interactions/drawing-interaction.ts +14 -9
  259. package/src/interactions/end-attempt-interaction.ts +3 -3
  260. package/src/interactions/gap-match-interaction.ts +32 -13
  261. package/src/interactions/graphic-associate-interaction.ts +15 -10
  262. package/src/interactions/hotspot-interaction.ts +10 -6
  263. package/src/interactions/inline-choice-interaction.ts +4 -4
  264. package/src/interactions/interaction-registry.ts +12 -12
  265. package/src/interactions/match-interaction.ts +9 -6
  266. package/src/interactions/pair-interaction.ts +22 -14
  267. package/src/interactions/position-object-interaction.ts +22 -13
  268. package/src/interactions/select-point-interaction.ts +25 -13
  269. package/src/interactions/shared.ts +21 -4
  270. package/src/interactions/text-interaction.ts +14 -4
  271. package/src/interactions/upload-interaction.ts +6 -3
  272. package/src/player/interaction-render.ts +4 -4
  273. package/src/player-adapter.ts +253 -0
  274. package/src/player-dev.ts +14 -0
  275. package/src/player-element.ts +78 -8
  276. package/src/player-locale.ts +28 -199
  277. package/src/player-message-catalog-default.ts +119 -0
  278. package/src/player-message-catalog-validate.ts +425 -0
  279. package/src/player-message-catalog.ts +72 -0
  280. package/src/player-message-keys.ts +12 -0
  281. package/src/player-message-manifest.ts +103 -0
  282. package/src/player-message-overrides.ts +38 -0
  283. package/src/player-message-resolver.ts +205 -0
  284. package/src/player-messages.ts +0 -30
  285. package/src/player-types.ts +15 -4
  286. package/src/reorder/a11y.ts +22 -7
  287. package/src/reorder/graphic-order-interaction.ts +23 -16
  288. package/src/reorder/list-controls.ts +8 -6
  289. package/src/reorder/order-interaction.ts +7 -5
  290. package/src/styles/base-styles.ts +20 -5
  291. package/src/styles/graphic-styles.ts +0 -6
@@ -0,0 +1,35 @@
1
+ import { objectIsImage } from "../interaction-support.js";
2
+ export function appendGraphicContext(group, interaction) {
3
+ if (!interaction.type.startsWith("graphic") || !interaction.object)
4
+ return;
5
+ const context = document.createElement("div");
6
+ context.className = "qti3-graphic-context";
7
+ const object = interaction.object;
8
+ const label = interaction.prompt ?? object.text ?? "Graphic interaction";
9
+ if (object.data && objectIsImage(object)) {
10
+ const image = document.createElement("img");
11
+ image.src = object.data;
12
+ image.alt = label;
13
+ image.style.maxInlineSize = "100%";
14
+ image.style.blockSize = "auto";
15
+ if (object.width)
16
+ image.width = Number(object.width);
17
+ if (object.height)
18
+ image.height = Number(object.height);
19
+ context.append(image);
20
+ }
21
+ else {
22
+ const fallbackHref = object.data ?? object.sources.find((source) => source.src)?.src;
23
+ if (fallbackHref) {
24
+ const link = document.createElement("a");
25
+ link.href = fallbackHref;
26
+ link.textContent = object.text || fallbackHref;
27
+ context.append(link);
28
+ }
29
+ else {
30
+ context.textContent = label;
31
+ }
32
+ }
33
+ group.append(context);
34
+ }
35
+ //# sourceMappingURL=graphic-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphic-context.js","sourceRoot":"","sources":["../../src/interactions/graphic-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,UAAU,oBAAoB,CAAC,KAAkB,EAAE,WAA2B;IAClF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM;QAAE,OAAO;IAC3E,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,SAAS,GAAG,sBAAsB,CAAC;IAC3C,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,IAAI,qBAAqB,CAAC;IAEzE,IAAI,MAAM,CAAC,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC5C,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC;QAClB,KAAK,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;QACnC,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;QAC/B,IAAI,MAAM,CAAC,KAAK;YAAE,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,MAAM,CAAC,MAAM;YAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;QACrF,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACzC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,IAAI,YAAY,CAAC;YAC/C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { QtiInteraction, QtiValue } from "@longsightgroup/qti3-core";
2
+ import type { PlayerMessageResolver } from "../player-message-resolver.js";
3
+ export declare function renderHotspotResponse(interaction: QtiInteraction, update: (value: QtiValue) => void, currentValue: QtiValue, messages: PlayerMessageResolver): HTMLElement;
4
+ //# sourceMappingURL=hotspot-interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hotspot-interaction.d.ts","sourceRoot":"","sources":["../../src/interactions/hotspot-interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAY1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,cAAc,EAC3B,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,EACjC,YAAY,EAAE,QAAQ,EACtB,QAAQ,EAAE,qBAAqB,GAC9B,WAAW,CAuEb"}
@@ -0,0 +1,68 @@
1
+ import { applyGraphicSurfaceLayout, appendGraphicObjectImage, interactionChoices, missingChoicesMessage, objectHeight, objectWidth, placeHotspotButton, responseGroup, valueToStrings, } from "../interaction-support.js";
2
+ export function renderHotspotResponse(interaction, update, currentValue, messages) {
3
+ const group = responseGroup();
4
+ const surface = document.createElement("div");
5
+ const width = objectWidth(interaction);
6
+ const height = objectHeight(interaction);
7
+ applyGraphicSurfaceLayout(surface, width, height, "qti3-hotspot-surface");
8
+ const choices = interactionChoices(interaction);
9
+ if (choices.length === 0) {
10
+ group.append(missingChoicesMessage(interaction));
11
+ return group;
12
+ }
13
+ const object = interaction.object;
14
+ if (object) {
15
+ appendGraphicObjectImage(surface, object, object.text || messages.message("interactionImageAlt", { type: interaction.type }));
16
+ }
17
+ const selected = new Set(valueToStrings(currentValue));
18
+ const multiple = interaction.responseCardinality === "multiple";
19
+ const selectedSummary = document.createElement("p");
20
+ selectedSummary.className = "qti3-selection-summary";
21
+ selectedSummary.setAttribute("aria-live", "polite");
22
+ selectedSummary.textContent = messages.message("noRegionSelected");
23
+ const syncSelected = () => {
24
+ for (const button of surface.querySelectorAll("button")) {
25
+ const isSelected = selected.has(button.dataset.choiceIdentifier ?? "");
26
+ button.setAttribute("aria-pressed", isSelected ? "true" : "false");
27
+ button.dataset.selected = isSelected ? "true" : "false";
28
+ }
29
+ selectedSummary.textContent =
30
+ selected.size > 0
31
+ ? messages.message("hotspotSelectionSummary", {
32
+ selection: [...selected].join(", "),
33
+ count: selected.size,
34
+ })
35
+ : messages.message("noRegionSelected");
36
+ };
37
+ for (const choice of choices) {
38
+ const button = document.createElement("button");
39
+ button.type = "button";
40
+ button.className = "qti3-hotspot-button";
41
+ button.dataset.choiceIdentifier = choice.identifier;
42
+ button.textContent = choice.text;
43
+ button.title = choice.text;
44
+ button.setAttribute("aria-pressed", "false");
45
+ placeHotspotButton(button, choice, width, height);
46
+ button.addEventListener("click", () => {
47
+ if (multiple) {
48
+ if (selected.has(choice.identifier))
49
+ selected.delete(choice.identifier);
50
+ else
51
+ selected.add(choice.identifier);
52
+ syncSelected();
53
+ update([...selected]);
54
+ }
55
+ else {
56
+ selected.clear();
57
+ selected.add(choice.identifier);
58
+ syncSelected();
59
+ update(choice.identifier);
60
+ }
61
+ });
62
+ surface.append(button);
63
+ }
64
+ syncSelected();
65
+ group.append(surface, selectedSummary);
66
+ return group;
67
+ }
68
+ //# sourceMappingURL=hotspot-interaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hotspot-interaction.js","sourceRoot":"","sources":["../../src/interactions/hotspot-interaction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,GACf,MAAM,2BAA2B,CAAC;AAGnC,MAAM,UAAU,qBAAqB,CACnC,WAA2B,EAC3B,MAAiC,EACjC,YAAsB,EACtB,QAA+B;IAE/B,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAE9B,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IACzC,yBAAyB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAE1E,MAAM,OAAO,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;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C;gBACjB,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBAChC,YAAY,EAAE,CAAC;gBACf,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,YAAY,EAAE,CAAC;IACf,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { QtiInteraction, QtiValue } from "@longsightgroup/qti3-core";
2
+ export declare function renderHottextResponse(interaction: QtiInteraction, update: (value: QtiValue) => void, currentValue: QtiValue): HTMLElement;
3
+ //# sourceMappingURL=hottext-interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hottext-interaction.d.ts","sourceRoot":"","sources":["../../src/interactions/hottext-interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAQ1E,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,cAAc,EAC3B,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,EACjC,YAAY,EAAE,QAAQ,GACrB,WAAW,CAoEb"}
@@ -0,0 +1,66 @@
1
+ import { interactionChoices, missingChoicesMessage, valueToStrings, } from "../interaction-support.js";
2
+ import { appendInlineControl, normalizeInlineSegmentText } from "./inline-controls.js";
3
+ export function renderHottextResponse(interaction, update, currentValue) {
4
+ const group = document.createElement("div");
5
+ group.className = "qti3-hottext-group";
6
+ group.role = "group";
7
+ group.setAttribute("aria-label", "Hottext options");
8
+ const selected = new Set(valueToStrings(currentValue));
9
+ const multiple = interaction.responseCardinality === "multiple" || interaction.responseCardinality === "ordered";
10
+ const passage = document.createElement("p");
11
+ passage.className = "qti3-hottext-passage";
12
+ const syncSelected = () => {
13
+ for (const button of passage.querySelectorAll(".qti3-hottext-token")) {
14
+ const identifier = button.dataset.choiceIdentifier ?? "";
15
+ const isSelected = selected.has(identifier);
16
+ button.dataset.selected = isSelected ? "true" : "false";
17
+ button.setAttribute("aria-pressed", String(isSelected));
18
+ }
19
+ };
20
+ const segments = interaction.hottextSegments && interaction.hottextSegments.length > 0
21
+ ? interaction.hottextSegments
22
+ : interactionChoices(interaction).map((choice) => ({
23
+ kind: "hottext",
24
+ identifier: choice.identifier,
25
+ text: choice.text,
26
+ attributes: choice.attributes,
27
+ source: choice.source,
28
+ }));
29
+ if (segments.length === 0) {
30
+ group.append(missingChoicesMessage(interaction));
31
+ return group;
32
+ }
33
+ const content = [];
34
+ for (const [segmentIndex, segment] of segments.entries()) {
35
+ if (segment.kind === "text") {
36
+ content.push(document.createTextNode(normalizeInlineSegmentText(segment.text)));
37
+ continue;
38
+ }
39
+ const button = document.createElement("button");
40
+ button.type = "button";
41
+ button.className = "qti3-hottext-token";
42
+ button.dataset.choiceIdentifier = segment.identifier;
43
+ button.textContent = segment.text;
44
+ button.addEventListener("click", () => {
45
+ if (multiple) {
46
+ if (selected.has(segment.identifier))
47
+ selected.delete(segment.identifier);
48
+ else
49
+ selected.add(segment.identifier);
50
+ update([...selected]);
51
+ }
52
+ else {
53
+ selected.clear();
54
+ selected.add(segment.identifier);
55
+ update(segment.identifier);
56
+ }
57
+ syncSelected();
58
+ });
59
+ appendInlineControl(content, button, segments[segmentIndex + 1]);
60
+ }
61
+ passage.append(...content);
62
+ syncSelected();
63
+ group.append(passage);
64
+ return group;
65
+ }
66
+ //# sourceMappingURL=hottext-interaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hottext-interaction.js","sourceRoot":"","sources":["../../src/interactions/hottext-interaction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,0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AC,UAAU,CAAC,CAAC;;oBACrE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACtC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACjB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACjC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC7B,CAAC;YACD,YAAY,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;IAC3B,YAAY,EAAE,CAAC;IACf,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { QtiInteraction, QtiValue } from "@longsightgroup/qti3-core";
2
+ import type { PlayerMessageResolver } from "../player-message-resolver.js";
3
+ export declare function renderSelect(interaction: QtiInteraction, update: (value: QtiValue) => void, currentValue: QtiValue, messages: PlayerMessageResolver): HTMLElement;
4
+ //# sourceMappingURL=inline-choice-interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-choice-interaction.d.ts","sourceRoot":"","sources":["../../src/interactions/inline-choice-interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAMrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAoB3E,wBAAgB,YAAY,CAC1B,WAAW,EAAE,cAAc,EAC3B,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,EACjC,YAAY,EAAE,QAAQ,EACtB,QAAQ,EAAE,qBAAqB,GAC9B,WAAW,CAab"}
@@ -0,0 +1,31 @@
1
+ import { interactionChoices, missingChoicesMessage, valueToStrings, } from "../interaction-support.js";
2
+ import { interactionLabel } from "./interaction-label.js";
3
+ function appendOptions(select, choices, messages) {
4
+ const empty = document.createElement("option");
5
+ empty.value = "";
6
+ empty.textContent = messages.message("inlineChoicePrompt");
7
+ select.append(empty);
8
+ for (const choice of choices) {
9
+ const option = document.createElement("option");
10
+ option.value = choice.identifier;
11
+ option.textContent = choice.text;
12
+ select.append(option);
13
+ }
14
+ }
15
+ export function renderSelect(interaction, update, currentValue, messages) {
16
+ const choices = interactionChoices(interaction);
17
+ if (choices.length === 0)
18
+ return missingChoicesMessage(interaction);
19
+ const select = document.createElement("select");
20
+ select.className = "qti3-inline-select";
21
+ if (interaction.responseIdentifier)
22
+ select.name = interaction.responseIdentifier;
23
+ select.setAttribute("aria-label", interactionLabel(interaction));
24
+ appendOptions(select, choices, messages);
25
+ const [selected] = valueToStrings(currentValue);
26
+ if (selected)
27
+ select.value = selected;
28
+ select.addEventListener("change", () => update(select.value === "" ? null : select.value));
29
+ return select;
30
+ }
31
+ //# sourceMappingURL=inline-choice-interaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-choice-interaction.js","sourceRoot":"","sources":["../../src/interactions/inline-choice-interaction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,SAAS,aAAa,CACpB,MAAyB,EACzB,OAAoB,EACpB,QAA+B;IAE/B,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,CAAC,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,oBAAoB,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C,CAAC;IAC3F,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function appendInlineControl(content: Array<Node | string>, control: HTMLElement, nextSegment: {
2
+ kind: string;
3
+ text?: string;
4
+ } | undefined): void;
5
+ export declare function normalizeInlineSegmentText(value: string | undefined): string;
6
+ //# sourceMappingURL=inline-controls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-controls.d.ts","sourceRoot":"","sources":["../../src/interactions/inline-controls.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,EAC7B,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GACvD,IAAI,CAYN;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE5E"}
@@ -0,0 +1,15 @@
1
+ export function appendInlineControl(content, control, nextSegment) {
2
+ const previous = content.at(-1);
3
+ if (previous instanceof Text && !/\s$/.test(previous.data)) {
4
+ content.push(document.createTextNode(" "));
5
+ }
6
+ content.push(control);
7
+ const nextText = nextSegment?.kind === "text" ? normalizeInlineSegmentText(nextSegment.text) : undefined;
8
+ if (nextText && !/^\s|^[,.;:!?]/.test(nextText)) {
9
+ content.push(document.createTextNode(" "));
10
+ }
11
+ }
12
+ export function normalizeInlineSegmentText(value) {
13
+ return (value ?? "").replace(/\s+([,.;:!?])/g, "$1");
14
+ }
15
+ //# sourceMappingURL=inline-controls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-controls.js","sourceRoot":"","sources":["../../src/interactions/inline-controls.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CACjC,OAA6B,EAC7B,OAAoB,EACpB,WAAwD;IAExD,MAAM,QAAQ,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,QAAQ,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEtB,MAAM,QAAQ,GACZ,WAAW,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,0BAA0B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,IAAI,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,KAAyB;IAClE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { QtiAssessmentItem, QtiDiagnostic, QtiInteraction } from "@longsightgroup/qti3-core";
2
+ export declare function interactionMissingChoiceDiagnostics(interaction: QtiInteraction): QtiDiagnostic[];
3
+ export declare function interactionUnsupportedDiagnostics(interaction: QtiInteraction): QtiDiagnostic[];
4
+ export declare function collectInteractionRenderDiagnostics(interactions: QtiInteraction[]): QtiDiagnostic[];
5
+ export declare function interactionEmbeddedDiagnostics(interaction: QtiInteraction): QtiDiagnostic[];
6
+ export declare function collectEmbeddedInteractionDiagnostics(item: QtiAssessmentItem): QtiDiagnostic[];
7
+ //# sourceMappingURL=interaction-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-diagnostics.d.ts","sourceRoot":"","sources":["../../src/interactions/interaction-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,aAAa,EACb,cAAc,EACf,MAAM,2BAA2B,CAAC;AAUnC,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,cAAc,GAAG,aAAa,EAAE,CAahG;AAED,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,cAAc,GAAG,aAAa,EAAE,CAa9F;AAED,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,cAAc,EAAE,GAC7B,aAAa,EAAE,CAKjB;AAID,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,cAAc,GAAG,aAAa,EAAE,CAa3F;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,EAAE,CAM9F"}
@@ -0,0 +1,137 @@
1
+ import { contentElementName } from "../content/content-dom.js";
2
+ import { interactionChoices } from "../interaction-support.js";
3
+ import { sourceChoices, targetChoices } from "./shared.js";
4
+ import { isInteractionSupported } from "./interaction-registry.js";
5
+ function diagnosticPath(interaction) {
6
+ return interaction.responseIdentifier ?? undefined;
7
+ }
8
+ export function interactionMissingChoiceDiagnostics(interaction) {
9
+ if (!interactionRequiresChoices(interaction) || interactionHasRequiredChoices(interaction)) {
10
+ return [];
11
+ }
12
+ const path = diagnosticPath(interaction);
13
+ return [
14
+ {
15
+ code: "interaction.choices.missing",
16
+ severity: "error",
17
+ message: `No choices are defined for the ${interaction.type} interaction${path ? ` (${path})` : ""}.`,
18
+ path,
19
+ },
20
+ ];
21
+ }
22
+ export function interactionUnsupportedDiagnostics(interaction) {
23
+ if (isInteractionSupported(interaction))
24
+ return [];
25
+ const path = diagnosticPath(interaction);
26
+ return [
27
+ {
28
+ code: "interaction.unsupported",
29
+ severity: "error",
30
+ message: path
31
+ ? `Interaction type "${interaction.type}" (${path}) is not supported.`
32
+ : `Interaction type "${interaction.type}" is not supported.`,
33
+ path,
34
+ },
35
+ ];
36
+ }
37
+ export function collectInteractionRenderDiagnostics(interactions) {
38
+ return interactions.flatMap((interaction) => [
39
+ ...interactionUnsupportedDiagnostics(interaction),
40
+ ...interactionMissingChoiceDiagnostics(interaction),
41
+ ]);
42
+ }
43
+ const embeddableInteractionTypes = new Set(["inlineChoice", "textEntry"]);
44
+ export function interactionEmbeddedDiagnostics(interaction) {
45
+ if (embeddableInteractionTypes.has(interaction.type))
46
+ return [];
47
+ const path = diagnosticPath(interaction);
48
+ return [
49
+ {
50
+ code: "interaction.embed.unsupported",
51
+ severity: "error",
52
+ message: path
53
+ ? `Interaction type "${interaction.type}" (${path}) cannot be embedded inline in item body.`
54
+ : `Interaction type "${interaction.type}" cannot be embedded inline in item body.`,
55
+ path,
56
+ },
57
+ ];
58
+ }
59
+ export function collectEmbeddedInteractionDiagnostics(item) {
60
+ const embeddedIndices = findEmbeddedInteractionIndices(item.body);
61
+ return embeddedIndices.flatMap((index) => {
62
+ const interaction = item.interactions[index];
63
+ return interaction ? interactionEmbeddedDiagnostics(interaction) : [];
64
+ });
65
+ }
66
+ function findEmbeddedInteractionIndices(nodes) {
67
+ return nodes.flatMap((node) => findEmbeddedInteractionIndicesInContext(node, false));
68
+ }
69
+ function findEmbeddedInteractionIndicesInContext(node, insideInlineFlow) {
70
+ if (node.kind === "interaction") {
71
+ return insideInlineFlow ? [node.interactionIndex] : [];
72
+ }
73
+ if ("children" in node) {
74
+ const childInsideInlineFlow = insideInlineFlow || isInlineFlowContainer(node);
75
+ return node.children.flatMap((child) => findEmbeddedInteractionIndicesInContext(child, childInsideInlineFlow));
76
+ }
77
+ return [];
78
+ }
79
+ function isInlineFlowContainer(node) {
80
+ if (node.kind !== "element")
81
+ return false;
82
+ if (node.qtiName === "qti-template-inline")
83
+ return true;
84
+ if (node.qtiName === "p")
85
+ return true;
86
+ const tag = contentElementName(node.qtiName);
87
+ if (!tag)
88
+ return false;
89
+ return new Set(["span", "label", "a", "em", "strong", "b", "i", "sub", "sup", "small"]).has(tag);
90
+ }
91
+ function interactionRequiresChoices(interaction) {
92
+ switch (interaction.type) {
93
+ case "choice":
94
+ case "order":
95
+ case "graphicOrder":
96
+ case "hotspot":
97
+ case "hottext":
98
+ case "inlineChoice":
99
+ case "match":
100
+ case "associate":
101
+ case "gapMatch":
102
+ case "graphicGapMatch":
103
+ case "graphicAssociate":
104
+ return true;
105
+ default:
106
+ return false;
107
+ }
108
+ }
109
+ function interactionHasRequiredChoices(interaction) {
110
+ switch (interaction.type) {
111
+ case "choice":
112
+ case "inlineChoice":
113
+ return interactionChoices(interaction).length > 0;
114
+ case "order":
115
+ return interactionChoices(interaction).some((choice) => choice.role !== "gap");
116
+ case "graphicOrder":
117
+ case "hotspot":
118
+ case "graphicAssociate":
119
+ return interactionChoices(interaction).some((choice) => choice.role === "hotspot");
120
+ case "hottext":
121
+ return (Boolean(interaction.hottextSegments?.length) || interactionChoices(interaction).length > 0);
122
+ case "match":
123
+ case "associate":
124
+ return sourceChoices(interaction).length > 0 && targetChoices(interaction).length > 0;
125
+ case "gapMatch":
126
+ return sourceChoices(interaction).length > 0 && targetChoices(interaction).length > 0;
127
+ case "graphicGapMatch":
128
+ if (interaction.object && interaction.choices.some((choice) => choice.role === "hotspot")) {
129
+ return (sourceChoices(interaction).length > 0 &&
130
+ targetChoices(interaction).filter((choice) => choice.role === "hotspot").length > 0);
131
+ }
132
+ return sourceChoices(interaction).length > 0 && targetChoices(interaction).length > 0;
133
+ default:
134
+ return true;
135
+ }
136
+ }
137
+ //# sourceMappingURL=interaction-diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-diagnostics.js","sourceRoot":"","sources":["../../src/interactions/interaction-diagnostics.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,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,MAAM,GAAG,CAAC;oBACrC,aAAa,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CACpF,CAAC;YACJ,CAAC;YACD,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACxF;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { interactionRegistry, isInteractionSupported, matchInteractionRegistryEntry, renderInteractionResponse, type InteractionRegistryEntry, type InteractionRendererId, type InteractionResponseContext, } from "./interaction-registry.js";
2
+ //# sourceMappingURL=interaction-dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-dispatch.d.ts","sourceRoot":"","sources":["../../src/interactions/interaction-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,yBAAyB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,GAChC,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { interactionRegistry, isInteractionSupported, matchInteractionRegistryEntry, renderInteractionResponse, } from "./interaction-registry.js";
2
+ //# sourceMappingURL=interaction-dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-dispatch.js","sourceRoot":"","sources":["../../src/interactions/interaction-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,yBAAyB,GAI1B,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { QtiInteraction } from "@longsightgroup/qti3-core";
2
+ export declare function interactionLabel(interaction: QtiInteraction): string;
3
+ export declare function qtiSharedClassNames(value: string | undefined): string[];
4
+ //# sourceMappingURL=interaction-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-label.d.ts","sourceRoot":"","sources":["../../src/interactions/interaction-label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,cAAc,GAAG,MAAM,CAEpE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAEvE"}
@@ -0,0 +1,8 @@
1
+ import { readableType } from "../interaction-support.js";
2
+ export function interactionLabel(interaction) {
3
+ return interaction.prompt ?? interaction.contextText ?? readableType(interaction.type);
4
+ }
5
+ export function qtiSharedClassNames(value) {
6
+ return (value ?? "").split(/\s+/).filter((className) => className.startsWith("qti-"));
7
+ }
8
+ //# sourceMappingURL=interaction-label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-label.js","sourceRoot":"","sources":["../../src/interactions/interaction-label.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,UAAU,gBAAgB,CAAC,WAA2B;IAC1D,OAAO,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,WAAW,IAAI,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAyB;IAC3D,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AACxF,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { QtiInteraction, QtiValue } from "@longsightgroup/qti3-core";
2
+ import type { PlayerMessageResolver } from "../player-message-resolver.js";
3
+ export interface InteractionResponseContext {
4
+ interaction: QtiInteraction;
5
+ update: (value: QtiValue) => void;
6
+ currentValue: QtiValue;
7
+ messages: PlayerMessageResolver;
8
+ isCompleted: () => boolean;
9
+ endAttempt: () => void;
10
+ renderPortableCustom: (interaction: QtiInteraction, update: (value: QtiValue) => void, currentValue: QtiValue) => HTMLElement;
11
+ }
12
+ export type InteractionRendererId = "graphicOrder" | "ordered" | "gapMatch" | "graphicAssociate" | "match" | "pair" | "hotspot" | "hottext" | "choice" | "inlineChoice" | "extendedText" | "selectPoint" | "positionObject" | "drawing" | "portableCustom" | "textEntry" | "slider" | "upload" | "endAttempt" | "media";
13
+ type InteractionRenderer = (context: InteractionResponseContext) => HTMLElement;
14
+ export interface InteractionRegistryEntry {
15
+ id: InteractionRendererId;
16
+ matches: (interaction: QtiInteraction) => boolean;
17
+ render: InteractionRenderer;
18
+ }
19
+ export declare const interactionRegistry: InteractionRegistryEntry[];
20
+ export declare function matchInteractionRegistryEntry(interaction: QtiInteraction): InteractionRegistryEntry | undefined;
21
+ export declare function isInteractionSupported(interaction: QtiInteraction): boolean;
22
+ export declare function renderInteractionResponse(context: InteractionResponseContext): HTMLElement;
23
+ export {};
24
+ //# sourceMappingURL=interaction-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-registry.d.ts","sourceRoot":"","sources":["../../src/interactions/interaction-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAqB3E,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,cAAc,CAAC;IAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IAClC,YAAY,EAAE,QAAQ,CAAC;IACvB,QAAQ,EAAE,qBAAqB,CAAC;IAChC,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,UAAU,EAAE,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