@pie-qti/item-player 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +21 -18
  2. package/dist/catalog/applyGlossaryTriggers.d.ts +15 -0
  3. package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -0
  4. package/dist/catalog/applyGlossaryTriggers.js +193 -0
  5. package/dist/catalog/catalogExtractor.d.ts +18 -0
  6. package/dist/catalog/catalogExtractor.d.ts.map +1 -0
  7. package/dist/catalog/catalogExtractor.js +114 -0
  8. package/dist/catalog/catalogLookup.d.ts +18 -0
  9. package/dist/catalog/catalogLookup.d.ts.map +1 -0
  10. package/dist/catalog/catalogLookup.js +44 -0
  11. package/dist/catalog/glossaryAction.d.ts +17 -0
  12. package/dist/catalog/glossaryAction.d.ts.map +1 -0
  13. package/dist/catalog/glossaryAction.js +21 -0
  14. package/dist/catalog/types.d.ts +26 -0
  15. package/dist/catalog/types.d.ts.map +1 -0
  16. package/dist/catalog/types.js +6 -0
  17. package/dist/core/ComponentRegistry.d.ts +9 -0
  18. package/dist/core/ComponentRegistry.d.ts.map +1 -1
  19. package/dist/core/ComponentRegistry.js +14 -0
  20. package/dist/core/ItemRenderer.d.ts.map +1 -1
  21. package/dist/core/ItemRenderer.js +3 -0
  22. package/dist/core/Player.d.ts +52 -0
  23. package/dist/core/Player.d.ts.map +1 -1
  24. package/dist/core/Player.js +158 -4
  25. package/dist/core/rolePolicy.d.ts +16 -0
  26. package/dist/core/rolePolicy.d.ts.map +1 -0
  27. package/dist/core/rolePolicy.js +15 -0
  28. package/dist/core/urlPolicy.d.ts.map +1 -1
  29. package/dist/core/urlPolicy.js +5 -2
  30. package/dist/element.d.ts +22 -0
  31. package/dist/element.js +5327 -0
  32. package/dist/element.js.map +1 -0
  33. package/dist/extraction/ExtractionRegistry.d.ts.map +1 -1
  34. package/dist/extraction/ExtractionRegistry.js +3 -1
  35. package/dist/extraction/extractors/associateExtractor.d.ts +1 -0
  36. package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
  37. package/dist/extraction/extractors/associateExtractor.js +3 -0
  38. package/dist/extraction/extractors/choiceExtractor.d.ts +2 -0
  39. package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
  40. package/dist/extraction/extractors/choiceExtractor.js +10 -0
  41. package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
  42. package/dist/extraction/extractors/extendedTextExtractor.js +6 -0
  43. package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -0
  44. package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
  45. package/dist/extraction/extractors/gapMatchExtractor.js +33 -20
  46. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -0
  47. package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
  48. package/dist/extraction/extractors/graphicAssociateExtractor.js +3 -0
  49. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +11 -0
  50. package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
  51. package/dist/extraction/extractors/graphicGapMatchExtractor.js +71 -10
  52. package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
  53. package/dist/extraction/extractors/hotspotExtractor.js +27 -8
  54. package/dist/extraction/extractors/hottextExtractor.d.ts +1 -1
  55. package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
  56. package/dist/extraction/extractors/hottextExtractor.js +12 -4
  57. package/dist/extraction/extractors/index.d.ts +1 -0
  58. package/dist/extraction/extractors/index.d.ts.map +1 -1
  59. package/dist/extraction/extractors/index.js +4 -0
  60. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +3 -0
  61. package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
  62. package/dist/extraction/extractors/inlineChoiceExtractor.js +17 -4
  63. package/dist/extraction/extractors/matchExtractor.d.ts +5 -0
  64. package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
  65. package/dist/extraction/extractors/matchExtractor.js +26 -0
  66. package/dist/extraction/extractors/orderExtractor.d.ts +2 -0
  67. package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
  68. package/dist/extraction/extractors/orderExtractor.js +4 -0
  69. package/dist/extraction/extractors/portableCustomExtractor.d.ts +14 -0
  70. package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -0
  71. package/dist/extraction/extractors/portableCustomExtractor.js +96 -0
  72. package/dist/extraction/extractors/selectPointExtractor.js +5 -5
  73. package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -0
  74. package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
  75. package/dist/extraction/extractors/textEntryExtractor.js +6 -0
  76. package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
  77. package/dist/extraction/extractors/uploadExtractor.js +9 -2
  78. package/dist/index.d.ts +11 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +8 -1
  81. package/dist/pci/PciHost.d.ts +53 -0
  82. package/dist/pci/PciHost.d.ts.map +1 -0
  83. package/dist/pci/PciHost.js +116 -0
  84. package/dist/pci/types.d.ts +57 -0
  85. package/dist/pci/types.d.ts.map +1 -0
  86. package/dist/pci/types.js +19 -0
  87. package/dist/pnp/applyPnp.d.ts +9 -0
  88. package/dist/pnp/applyPnp.d.ts.map +1 -0
  89. package/dist/pnp/applyPnp.js +19 -0
  90. package/dist/pnp/parsePnpXml.d.ts +9 -0
  91. package/dist/pnp/parsePnpXml.d.ts.map +1 -0
  92. package/dist/pnp/parsePnpXml.js +101 -0
  93. package/dist/pnp/types.d.ts +40 -0
  94. package/dist/pnp/types.d.ts.map +1 -0
  95. package/dist/pnp/types.js +1 -0
  96. package/dist/types/index.d.ts +22 -8
  97. package/dist/types/index.d.ts.map +1 -1
  98. package/dist/types/interactions.d.ts +90 -1
  99. package/dist/types/interactions.d.ts.map +1 -1
  100. package/package.json +19 -9
  101. package/src/__tests__/catalog.test.ts +267 -0
  102. package/src/__tests__/fixtures/pci/echo-pci.js +49 -0
  103. package/src/__tests__/glossaryTriggers.test.ts +411 -0
  104. package/src/__tests__/pci.test.ts +353 -0
  105. package/src/__tests__/pnp.test.ts +250 -0
  106. package/src/__tests__/qti3-extraction.test.ts +5 -5
  107. package/src/catalog/applyGlossaryTriggers.ts +232 -0
  108. package/src/catalog/catalogExtractor.ts +130 -0
  109. package/src/catalog/catalogLookup.ts +53 -0
  110. package/src/catalog/glossaryAction.ts +28 -0
  111. package/src/catalog/types.ts +37 -0
  112. package/src/components/ItemBody.svelte +134 -26
  113. package/src/components/ItemPlayer.svelte +6 -2
  114. package/src/components/index.ts +3 -0
  115. package/src/core/ComponentRegistry.ts +14 -0
  116. package/src/core/ItemRenderer.ts +4 -0
  117. package/src/core/Player.ts +174 -4
  118. package/src/core/rolePolicy.ts +34 -0
  119. package/src/core/urlPolicy.ts +5 -2
  120. package/src/element.ts +128 -0
  121. package/src/extraction/ExtractionRegistry.ts +5 -1
  122. package/src/extraction/extractors/associateExtractor.ts +4 -0
  123. package/src/extraction/extractors/choiceExtractor.ts +12 -1
  124. package/src/extraction/extractors/conformance-qti3-advanced.test.ts +239 -0
  125. package/src/extraction/extractors/conformance-qti3-basic.test.ts +82 -0
  126. package/src/extraction/extractors/conformance.test.ts +208 -0
  127. package/src/extraction/extractors/extendedTextExtractor.ts +6 -0
  128. package/src/extraction/extractors/gapMatchExtractor.ts +36 -21
  129. package/src/extraction/extractors/graphicAssociateExtractor.ts +4 -0
  130. package/src/extraction/extractors/graphicGapMatchExtractor.ts +82 -10
  131. package/src/extraction/extractors/hotspotExtractor.ts +26 -8
  132. package/src/extraction/extractors/hottextExtractor.ts +15 -5
  133. package/src/extraction/extractors/index.ts +4 -0
  134. package/src/extraction/extractors/inlineChoiceExtractor.ts +22 -5
  135. package/src/extraction/extractors/matchExtractor.ts +31 -4
  136. package/src/extraction/extractors/orderExtractor.ts +6 -0
  137. package/src/extraction/extractors/portableCustomExtractor.ts +122 -0
  138. package/src/extraction/extractors/selectPointExtractor.ts +5 -5
  139. package/src/extraction/extractors/textEntryExtractor.ts +7 -0
  140. package/src/extraction/extractors/uploadExtractor.ts +10 -2
  141. package/src/index.ts +17 -1
  142. package/src/pci/PciHost.ts +138 -0
  143. package/src/pci/types.ts +70 -0
  144. package/src/pnp/applyPnp.ts +23 -0
  145. package/src/pnp/parsePnpXml.ts +118 -0
  146. package/src/pnp/types.ts +33 -0
  147. package/src/types/index.ts +22 -8
  148. package/src/types/interactions.ts +81 -6
@@ -0,0 +1,118 @@
1
+ import { parse as parseHtml } from 'node-html-parser';
2
+ import type { HTMLElement as NhpElement } from 'node-html-parser';
3
+ import type { PnpProfile } from './types.js';
4
+
5
+ /**
6
+ * Parse a QTI 3.0 <personalNeedsProfile> element (or legacy <pnp> element) into a PnpProfile.
7
+ *
8
+ * Accepts either an XML/HTML string containing the profile element, or a live DOM Element.
9
+ * Unknown child elements are silently ignored for forward-compatibility.
10
+ */
11
+ export function parsePnpXml(xml: string | Element): PnpProfile {
12
+ if (typeof xml !== 'string') {
13
+ // Live DOM Element — serialise to string and re-parse via node-html-parser
14
+ return parsePnpXml((xml as Element).outerHTML ?? '');
15
+ }
16
+
17
+ const trimmed = xml.trim();
18
+ if (!trimmed) return {};
19
+
20
+ // Wrap so node-html-parser treats the outer tag as the root
21
+ const doc = parseHtml(`<root>${trimmed}</root>`, { lowerCaseTagName: true });
22
+ const root = doc.querySelector('personalneedsprofile') ?? doc.querySelector('pnp');
23
+ if (!root) return {};
24
+
25
+ return extractProfile(root);
26
+ }
27
+
28
+ function extractProfile(root: NhpElement): PnpProfile {
29
+ const profile: PnpProfile = {};
30
+
31
+ // <display>
32
+ const displayEl = findChild(root, ['display']);
33
+ if (displayEl) {
34
+ profile.display = {};
35
+
36
+ const colorSchemeEl = findChild(displayEl, ['colorscheme', 'color-scheme']);
37
+ if (colorSchemeEl) {
38
+ const val = (colorSchemeEl.getAttribute('value') ?? colorSchemeEl.text ?? '').trim().toLowerCase();
39
+ if (isColorScheme(val)) profile.display.colorScheme = val;
40
+ }
41
+
42
+ const magEl = findChild(displayEl, ['magnification']);
43
+ if (magEl) {
44
+ const val = parseFloat(magEl.getAttribute('value') ?? magEl.text ?? '');
45
+ if (Number.isFinite(val) && val > 0) profile.display.magnification = val;
46
+ }
47
+ }
48
+
49
+ // <content>
50
+ const contentEl = findChild(root, ['content']);
51
+ if (contentEl) {
52
+ profile.content = {};
53
+
54
+ const glossaryEl = findChild(contentEl, ['glossaryonscreen', 'glossary-on-screen']);
55
+ if (glossaryEl) {
56
+ profile.content.glossaryOnScreen = parseBool(glossaryEl.getAttribute('enabled') ?? glossaryEl.text ?? 'true');
57
+ }
58
+
59
+ const kwEl = findChild(contentEl, ['keywordtranslation', 'keyword-translation']);
60
+ if (kwEl) {
61
+ const active = parseBool(kwEl.getAttribute('active') ?? 'true');
62
+ const languageCode = (kwEl.getAttribute('languagecode') ?? kwEl.getAttribute('language-code') ?? kwEl.getAttribute('lang') ?? '').trim();
63
+ if (languageCode) profile.content.keywordTranslation = { active, languageCode };
64
+ }
65
+
66
+ const etEl = findChild(contentEl, ['extendedtime', 'extended-time']);
67
+ if (etEl) {
68
+ const active = parseBool(etEl.getAttribute('active') ?? 'true');
69
+ const rawMultiplier = etEl.getAttribute('multiplier') ?? etEl.text ?? '';
70
+ const multiplier = rawMultiplier.trim().toLowerCase() === 'infinity'
71
+ ? Infinity
72
+ : parseFloat(rawMultiplier);
73
+ if (Number.isFinite(multiplier) || multiplier === Infinity) {
74
+ profile.content.extendedTime = { active, multiplier };
75
+ }
76
+ }
77
+ }
78
+
79
+ // <cognitive>
80
+ const cogEl = findChild(root, ['cognitive']);
81
+ if (cogEl) {
82
+ profile.cognitive = {};
83
+
84
+ const elTool = findChild(cogEl, ['eliminationtool', 'elimination-tool']);
85
+ if (elTool) {
86
+ profile.cognitive.eliminationTool = parseBool(
87
+ elTool.getAttribute('enabled') ?? elTool.getAttribute('active') ?? elTool.text ?? 'true'
88
+ );
89
+ }
90
+ }
91
+
92
+ return profile;
93
+ }
94
+
95
+ // ---------------------------------------------------------------------------
96
+ // Helpers
97
+ // ---------------------------------------------------------------------------
98
+
99
+ function findChild(parent: NhpElement, names: string[]): NhpElement | null {
100
+ for (const child of parent.childNodes) {
101
+ if (child.nodeType !== 1) continue; // element nodes only
102
+ const el = child as NhpElement;
103
+ const tag = (el.rawTagName ?? '').toLowerCase();
104
+ if (names.includes(tag)) return el;
105
+ }
106
+ return null;
107
+ }
108
+
109
+ function parseBool(value: string): boolean {
110
+ const v = (value ?? '').trim().toLowerCase();
111
+ return v !== 'false' && v !== '0' && v !== 'no';
112
+ }
113
+
114
+ type ColorScheme = PnpProfile['display'] extends { colorScheme?: infer C } ? Exclude<C, undefined> : never;
115
+ const COLOR_SCHEMES = new Set<string>(['default', 'blackwhite', 'whitenav', 'blackcream', 'yellowblue', 'medgray']);
116
+ function isColorScheme(v: string): v is ColorScheme {
117
+ return COLOR_SCHEMES.has(v);
118
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * QTI 3.0 §6.2 Personal Needs and Preferences profile.
3
+ * All fields are optional; absent means "use platform default".
4
+ */
5
+ export interface PnpProfile {
6
+ display?: {
7
+ /**
8
+ * Named color scheme. Maps to the data-qti-colorscheme attribute on the player root.
9
+ * 'default' or undefined → attribute removed (browser/host default).
10
+ */
11
+ colorScheme?: 'default' | 'blackwhite' | 'whitenav' | 'blackcream' | 'yellowblue' | 'medgray';
12
+ /**
13
+ * CSS zoom factor (1.0 = 100%). Deferred — set by browser zoom or host stylesheet.
14
+ * Stored here for forward-compatibility but not yet applied by the player.
15
+ */
16
+ magnification?: number;
17
+ };
18
+ content?: {
19
+ /** Show glossary trigger buttons on [data-catalog-idref] terms (G-10). */
20
+ glossaryOnScreen?: boolean;
21
+ /** Show keyword-translation trigger buttons using the given language code. */
22
+ keywordTranslation?: { active: boolean; languageCode: string };
23
+ /**
24
+ * Scale assessment time limits. multiplier: 1.5 means 50% extra time.
25
+ * multiplier: Infinity removes the time limit entirely.
26
+ */
27
+ extendedTime?: { active: boolean; multiplier: number };
28
+ };
29
+ cognitive?: {
30
+ /** Render per-choice elimination toggle buttons in choiceInteraction and orderInteraction. */
31
+ eliminationTool?: boolean;
32
+ };
33
+ }
@@ -52,7 +52,7 @@ export interface AreaMapping {
52
52
  defaultValue?: number;
53
53
  lowerBound?: number;
54
54
  upperBound?: number;
55
- entries: Record<string, AreaMapEntry>;
55
+ entries: AreaMapEntry[];
56
56
  }
57
57
 
58
58
  export interface AreaMapEntry {
@@ -149,13 +149,9 @@ export interface AdaptiveAttemptResult extends ScoringResult {
149
149
  }
150
150
 
151
151
  /**
152
- * QTI 2.2 standard roles
153
- * - candidate: Student/test-taker
154
- * - scorer: Automated or human scoring system
155
- * - proctor: Test administrator/invigilator
156
- * - testConstructor: Test author/developer
157
- * - tutor: Instructional/learning mode
158
- * - author: Content author
152
+ * QTI role/view actors used for audience filtering (for example rubric/outcome visibility).
153
+ * Runtime interaction behavior (readonly vs editable, correct-answer visibility) is a player
154
+ * policy layered on top of these roles.
159
155
  */
160
156
  export type QTIRole = 'candidate' | 'scorer' | 'proctor' | 'testConstructor' | 'tutor' | 'author';
161
157
 
@@ -181,6 +177,19 @@ export interface QTIComplianceConfig {
181
177
 
182
178
  export interface PlayerConfig {
183
179
  itemXml?: string;
180
+ /**
181
+ * QTI 3.0 §6.2 Personal Needs and Preferences profile.
182
+ * Color scheme is applied immediately as data-qti-colorscheme on the player root.
183
+ * Use player.updatePnp() to change mid-session without re-parsing the item.
184
+ */
185
+ pnp?: import('../pnp/types.js').PnpProfile;
186
+ /**
187
+ * Optional shared catalog XML string (QTI 3.0 §6.3).
188
+ * Parsed and merged with any catalog embedded in the item XML.
189
+ * Item-level catalog entries take precedence over shared entries with the same identifier.
190
+ * Deferred: external catalog files from IMS manifest (G-15) are not yet supported.
191
+ */
192
+ catalogXml?: string;
184
193
  sessionState?: ItemSessionState;
185
194
  responses?: InteractionResponse;
186
195
  role?: QTIRole;
@@ -216,6 +225,11 @@ export interface PlayerConfig {
216
225
  * Keyed by operator `class` (preferred) or `definition` URI.
217
226
  */
218
227
  customOperators?: Record<string, (args: QtiValue[], meta: { class?: string; definition?: string }) => QtiValue>;
228
+ /**
229
+ * Optional base URL for resolving relative PCI module paths.
230
+ * Defaults to document.baseURI when running in a browser.
231
+ */
232
+ pciBaseUrl?: string;
219
233
 
220
234
  /**
221
235
  * Security-related controls for untrusted QTI rendered into the host DOM.
@@ -23,10 +23,15 @@ export interface ChoiceInteractionData extends BaseInteractionData {
23
23
  type: 'choiceInteraction';
24
24
  shuffle: boolean;
25
25
  maxChoices: number;
26
+ minChoices: number;
26
27
  prompt: string | null;
27
- choices: Array<{ identifier: string; text: HtmlContent; classes?: string[] }>;
28
+ choices: Array<{ identifier: string; text: HtmlContent; fixed?: boolean; classes?: string[] }>;
28
29
  /** CSS classes from the choiceInteraction element for custom renderer detection */
29
30
  interactionClasses?: string[];
31
+ /** Message shown when candidate exceeds maxChoices (data-max-selections-message) */
32
+ maxSelectionsMessage?: string | null;
33
+ /** Message shown when candidate submits below minChoices (data-min-selections-message) */
34
+ minSelectionsMessage?: string | null;
30
35
  }
31
36
 
32
37
  export interface TextEntryInteractionData extends BaseInteractionData {
@@ -34,6 +39,11 @@ export interface TextEntryInteractionData extends BaseInteractionData {
34
39
  expectedLength: number;
35
40
  patternMask: string | null;
36
41
  placeholderText: string;
42
+ format?: string;
43
+ /** CSS classes from the textEntryInteraction element (e.g. qti-input-width-N) */
44
+ interactionClasses?: string[];
45
+ /** Pattern mask validation message (data-patternmask-message) */
46
+ patternMaskMessage?: string | null;
37
47
  }
38
48
 
39
49
  export interface ExtendedTextInteractionData extends BaseInteractionData {
@@ -42,40 +52,68 @@ export interface ExtendedTextInteractionData extends BaseInteractionData {
42
52
  expectedLength: number;
43
53
  placeholderText: string;
44
54
  format: string;
55
+ patternMask?: string | null;
56
+ patternMaskMessage?: string | null;
57
+ /** CSS classes from the extendedTextInteraction element (e.g. qti-height-lines-N) */
58
+ interactionClasses?: string[];
45
59
  }
46
60
 
47
61
  export interface InlineChoiceInteractionData extends BaseInteractionData {
48
62
  type: 'inlineChoiceInteraction';
49
63
  shuffle: boolean;
50
- choices: Array<{ identifier: string; text: string }>;
64
+ /** Placeholder label from the QTI <label> child element; shown as the unselected "Select…" option */
65
+ label: string | null;
66
+ /** Placeholder text from data-prompt attribute; alternative to <label> for dropdown default option */
67
+ dataPrompt?: string | null;
68
+ choices: Array<{ identifier: string; text: string; fixed?: boolean }>;
69
+ /** CSS classes from the inlineChoiceInteraction element (e.g. qti-input-width-N) */
70
+ interactionClasses?: string[];
51
71
  }
52
72
 
53
73
  export interface OrderInteractionData extends BaseInteractionData {
54
74
  type: 'orderInteraction';
55
75
  shuffle: boolean;
76
+ minChoices: number;
77
+ maxChoices: number;
56
78
  prompt: string | null;
57
- choices: Array<{ identifier: string; text: string }>;
79
+ choices: Array<{ identifier: string; text: string; fixed?: boolean }>;
58
80
  }
59
81
 
60
82
  export interface AssociableChoice {
61
83
  identifier: string;
62
84
  text: string;
63
85
  matchMax: number;
86
+ /** Minimum number of times this choice must appear in the response (QTI matchMin) */
87
+ matchMin?: number;
88
+ /** Pairing constraint: choice can only be paired with others sharing a group value (QTI matchGroup) */
89
+ matchGroup?: string[];
90
+ /** CSS classes from the choice element for custom renderer detection */
91
+ classes?: string[];
64
92
  }
65
93
 
66
94
  export interface MatchInteractionData extends BaseInteractionData {
67
95
  type: 'matchInteraction';
68
96
  shuffle: boolean;
69
97
  maxAssociations: number;
98
+ minAssociations?: number;
70
99
  prompt: string | null;
71
100
  sourceSet: AssociableChoice[];
72
101
  targetSet: AssociableChoice[];
102
+ /** CSS classes from the matchInteraction element (e.g. qti-choices-top, qti-match-tabular) */
103
+ interactionClasses?: string[];
104
+ /** Message shown when candidate exceeds maxAssociations */
105
+ maxSelectionsMessage?: string | null;
106
+ /** Message shown when candidate submits below minAssociations */
107
+ minSelectionsMessage?: string | null;
108
+ /** Label for first column header in tabular mode (data-qti-first-column-header) */
109
+ firstColumnHeader?: string | null;
73
110
  }
74
111
 
75
112
  export interface AssociateInteractionData extends BaseInteractionData {
76
113
  type: 'associateInteraction';
77
114
  shuffle: boolean;
78
115
  maxAssociations: number;
116
+ minAssociations?: number;
79
117
  prompt: string | null;
80
118
  choices: AssociableChoice[];
81
119
  }
@@ -84,9 +122,17 @@ export interface GapMatchInteractionData extends BaseInteractionData {
84
122
  type: 'gapMatchInteraction';
85
123
  shuffle: boolean;
86
124
  prompt: string | null;
87
- gapTexts: Array<{ identifier: string; text: string; matchMax: number }>;
125
+ gapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[]; inputWidth?: number }>;
88
126
  gaps: Array<{ identifier: string; index: number }>;
89
127
  promptText: string;
128
+ /** CSS classes from the gapMatchInteraction element (e.g. qti-choices-top, qti-choices-bottom) */
129
+ interactionClasses?: string[];
130
+ /** Width of the choice container in px (data-choices-container-width) */
131
+ choicesContainerWidth?: string | null;
132
+ /** Message shown when candidate exceeds max associations */
133
+ maxSelectionsMessage?: string | null;
134
+ /** Message shown when candidate submits below min associations */
135
+ minSelectionsMessage?: string | null;
90
136
  }
91
137
 
92
138
  export interface SliderInteractionData extends BaseInteractionData {
@@ -111,14 +157,23 @@ export interface HotspotChoice {
111
157
  identifier: string;
112
158
  shape: string;
113
159
  coords: string;
160
+ /** Author-provided label for the hotspot; used as accessible aria-label */
161
+ hotspotLabel?: string;
114
162
  }
115
163
 
116
164
  export interface HotspotInteractionData extends BaseInteractionData {
117
165
  type: 'hotspotInteraction';
118
166
  maxChoices: number;
167
+ minChoices?: number;
119
168
  prompt: string | null;
120
169
  imageData: ImageData | null;
121
170
  hotspotChoices: HotspotChoice[];
171
+ /** CSS classes from the hotspotInteraction element (e.g. qti-selections-light, qti-selections-dark) */
172
+ interactionClasses?: string[];
173
+ /** Message shown when candidate exceeds maxChoices */
174
+ maxSelectionsMessage?: string | null;
175
+ /** Message shown when candidate submits below minChoices */
176
+ minSelectionsMessage?: string | null;
122
177
  }
123
178
 
124
179
  export interface AssociableHotspot {
@@ -132,8 +187,19 @@ export interface GraphicGapMatchInteractionData extends BaseInteractionData {
132
187
  type: 'graphicGapMatchInteraction';
133
188
  prompt: string | null;
134
189
  imageData: ImageData | null;
135
- gapTexts: Array<{ identifier: string; text: string; matchMax: number }>;
190
+ maxAssociations: number;
191
+ gapTexts: Array<{ identifier: string; text: string; matchMax: number; matchGroup?: string[] }>;
192
+ /** Image-based draggable labels (gapImg elements); rendered as <img> in the choice pool */
193
+ gapImages: Array<{ identifier: string; src: string; alt: string; matchMax: number; matchGroup?: string[]; width?: number; height?: number }>;
136
194
  hotspots: AssociableHotspot[];
195
+ /** CSS classes from the graphicGapMatchInteraction element (e.g. qti-choices-top, qti-selections-dark) */
196
+ interactionClasses?: string[];
197
+ /** Width of the choice container in px (data-choices-container-width) */
198
+ choicesContainerWidth?: string | null;
199
+ /** Message shown when candidate exceeds max associations */
200
+ maxSelectionsMessage?: string | null;
201
+ /** Message shown when candidate submits below min associations */
202
+ minSelectionsMessage?: string | null;
137
203
  }
138
204
 
139
205
  export interface UploadInteractionData extends BaseInteractionData {
@@ -189,8 +255,15 @@ export interface HottextInteractionData extends BaseInteractionData {
189
255
  type: 'hottextInteraction';
190
256
  prompt: string | null;
191
257
  maxChoices: number;
258
+ minChoices: number;
192
259
  contentHtml: HtmlContent;
193
260
  hottextChoices: HottextChoice[];
261
+ /** CSS classes from the hottextInteraction element (e.g. qti-input-control-hidden) */
262
+ interactionClasses?: string[];
263
+ /** Message shown when candidate exceeds maxChoices */
264
+ maxSelectionsMessage?: string | null;
265
+ /** Message shown when candidate submits below minChoices */
266
+ minSelectionsMessage?: string | null;
194
267
  }
195
268
 
196
269
  export interface Point {
@@ -226,6 +299,8 @@ export interface GraphicAssociateHotspot {
226
299
  coords: string;
227
300
  matchMax: number;
228
301
  label: string;
302
+ /** Pairing constraint: hotspot can only be associated with others sharing a group value (QTI matchGroup) */
303
+ matchGroup?: string[];
229
304
  }
230
305
 
231
306
  export interface GraphicAssociateInteractionData extends BaseInteractionData {
@@ -341,7 +416,7 @@ export interface InteractionValueMap {
341
416
  sliderInteraction: number;
342
417
  hotspotInteraction: string[];
343
418
  graphicGapMatchInteraction: Record<string, string>;
344
- uploadInteraction: import('../types/index.js').QTIFileResponse[];
419
+ uploadInteraction: import('../types/index.js').QTIFileResponse | null;
345
420
  drawingInteraction: string;
346
421
  customInteraction: any;
347
422
  mediaInteraction: any;