@pie-qti/item-player 0.1.8 → 0.1.10

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 (199) hide show
  1. package/README.md +17 -0
  2. package/dist/catalog/applyGlossaryTriggers.d.ts +13 -2
  3. package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
  4. package/dist/catalog/glossaryAction.d.ts +4 -2
  5. package/dist/catalog/glossaryAction.d.ts.map +1 -1
  6. package/dist/components/utils/index.d.ts +1 -2
  7. package/dist/components/utils/index.d.ts.map +1 -1
  8. package/dist/components/utils/index.js +1 -2
  9. package/dist/core/ComponentRegistry.d.ts +10 -1
  10. package/dist/core/ComponentRegistry.d.ts.map +1 -1
  11. package/dist/core/ComponentRegistry.js +42 -1
  12. package/dist/core/Player.d.ts +10 -2
  13. package/dist/core/Player.d.ts.map +1 -1
  14. package/dist/core/Player.js +54 -46
  15. package/dist/document/AssessmentItemDocument.d.ts +1 -1
  16. package/dist/element.d.ts +15 -0
  17. package/dist/element.js +1921 -1785
  18. package/dist/element.js.map +1 -1
  19. package/dist/extraction/ExtractionRegistry.d.ts +1 -1
  20. package/dist/extraction/createContext.d.ts +1 -1
  21. package/dist/extraction/index.d.ts +2 -2
  22. package/dist/extraction/index.d.ts.map +1 -1
  23. package/dist/extraction/index.js +1 -1
  24. package/dist/extraction/interactionExtractionPipeline.d.ts +1 -1
  25. package/dist/extraction/interactionSecurity.d.ts +1 -1
  26. package/dist/extraction/types.d.ts +1 -1
  27. package/dist/presentation/itemPresentationPlan.d.ts +54 -0
  28. package/dist/presentation/itemPresentationPlan.d.ts.map +1 -0
  29. package/dist/presentation/itemPresentationPlan.js +98 -0
  30. package/dist/types/index.d.ts +17 -2
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/index.js +0 -3
  33. package/dist/web-components/QTIInteractionBase.d.ts +1 -1
  34. package/dist/web-components/QTIInteractionElement.d.ts +1 -1
  35. package/package.json +10 -12
  36. package/src/__tests__/catalog.test.ts +0 -267
  37. package/src/__tests__/fixtures/pci/echo-pci.js +0 -49
  38. package/src/__tests__/pci.test.ts +0 -353
  39. package/src/__tests__/qti3-attribute-extraction.test.ts +0 -174
  40. package/src/__tests__/qti3-debug.test.ts +0 -140
  41. package/src/__tests__/qti3-extraction.test.ts +0 -309
  42. package/src/catalog/applyGlossaryTriggers.ts +0 -372
  43. package/src/catalog/catalogExtractor.ts +0 -130
  44. package/src/catalog/catalogLookup.ts +0 -53
  45. package/src/catalog/glossaryAction.ts +0 -38
  46. package/src/catalog/types.ts +0 -37
  47. package/src/components/ItemBody.svelte +0 -363
  48. package/src/components/ItemPlayer.svelte +0 -163
  49. package/src/components/ModalFeedbackDisplay.svelte +0 -97
  50. package/src/components/actions/typesetAction.ts +0 -74
  51. package/src/components/index.ts +0 -22
  52. package/src/components/utils/assignProps.ts +0 -2
  53. package/src/components/utils/feedbackUtils.ts +0 -140
  54. package/src/components/utils/index.ts +0 -13
  55. package/src/components/utils/stimulusRender.ts +0 -93
  56. package/src/components/utils/stylesheetRender.ts +0 -58
  57. package/src/core/ComponentRegistry.ts +0 -248
  58. package/src/core/Player.ts +0 -1618
  59. package/src/core/Plugin.ts +0 -123
  60. package/src/core/PluginManager.ts +0 -182
  61. package/src/core/constants.ts +0 -117
  62. package/src/core/declarations.ts +0 -171
  63. package/src/core/parsingLimits.ts +0 -62
  64. package/src/core/random.ts +0 -24
  65. package/src/core/rolePolicy.ts +0 -34
  66. package/src/core/sanitizer.ts +0 -305
  67. package/src/core/trustedTypes.ts +0 -63
  68. package/src/core/urlPolicy.ts +0 -98
  69. package/src/document/AssessmentItemDocument.ts +0 -247
  70. package/src/element.ts +0 -128
  71. package/src/extensions/MathLiveEditor.ts +0 -313
  72. package/src/extraction/ExtractionRegistry.ts +0 -335
  73. package/src/extraction/createContext.ts +0 -52
  74. package/src/extraction/extractors/associateExtractor.ts +0 -1
  75. package/src/extraction/extractors/choiceExtractor.ts +0 -1
  76. package/src/extraction/extractors/conformance-qti3-advanced.test.ts +0 -239
  77. package/src/extraction/extractors/conformance-qti3-basic.test.ts +0 -82
  78. package/src/extraction/extractors/conformance.test.ts +0 -208
  79. package/src/extraction/extractors/customExtractor.ts +0 -1
  80. package/src/extraction/extractors/drawingExtractor.ts +0 -1
  81. package/src/extraction/extractors/endAttemptExtractor.ts +0 -1
  82. package/src/extraction/extractors/extendedTextExtractor.ts +0 -1
  83. package/src/extraction/extractors/gapMatchExtractor.ts +0 -1
  84. package/src/extraction/extractors/graphicAssociateExtractor.ts +0 -1
  85. package/src/extraction/extractors/graphicGapMatchExtractor.ts +0 -1
  86. package/src/extraction/extractors/graphicOrderExtractor.ts +0 -1
  87. package/src/extraction/extractors/hotspotExtractor.ts +0 -1
  88. package/src/extraction/extractors/hottextExtractor.ts +0 -1
  89. package/src/extraction/extractors/index.ts +0 -9
  90. package/src/extraction/extractors/inlineChoiceExtractor.ts +0 -1
  91. package/src/extraction/extractors/matchExtractor.ts +0 -1
  92. package/src/extraction/extractors/mediaExtractor.ts +0 -1
  93. package/src/extraction/extractors/orderExtractor.ts +0 -1
  94. package/src/extraction/extractors/portableCustomExtractor.ts +0 -1
  95. package/src/extraction/extractors/positionObjectExtractor.ts +0 -1
  96. package/src/extraction/extractors/selectPointExtractor.ts +0 -1
  97. package/src/extraction/extractors/sliderExtractor.ts +0 -1
  98. package/src/extraction/extractors/textEntryExtractor.ts +0 -1
  99. package/src/extraction/extractors/uploadExtractor.ts +0 -1
  100. package/src/extraction/index.ts +0 -108
  101. package/src/extraction/interactionExtractionPipeline.ts +0 -70
  102. package/src/extraction/interactionSecurity.ts +0 -60
  103. package/src/extraction/types.ts +0 -246
  104. package/src/extraction/utils.ts +0 -243
  105. package/src/iframe/IFramePlayerHost.ts +0 -265
  106. package/src/iframe/index.ts +0 -11
  107. package/src/iframe/protocol.ts +0 -137
  108. package/src/index.ts +0 -101
  109. package/src/interactions/associate/extractor.ts +0 -133
  110. package/src/interactions/associate/index.ts +0 -2
  111. package/src/interactions/associate/types.ts +0 -1
  112. package/src/interactions/choice/extractor.ts +0 -121
  113. package/src/interactions/choice/index.ts +0 -2
  114. package/src/interactions/choice/types.ts +0 -1
  115. package/src/interactions/custom/extractor.ts +0 -72
  116. package/src/interactions/custom/index.ts +0 -2
  117. package/src/interactions/custom/types.ts +0 -1
  118. package/src/interactions/drawing/extractor.ts +0 -113
  119. package/src/interactions/drawing/index.ts +0 -2
  120. package/src/interactions/drawing/types.ts +0 -1
  121. package/src/interactions/end-attempt/extractor.ts +0 -74
  122. package/src/interactions/end-attempt/index.ts +0 -2
  123. package/src/interactions/end-attempt/types.ts +0 -1
  124. package/src/interactions/extended-text/extractor.ts +0 -92
  125. package/src/interactions/extended-text/index.ts +0 -2
  126. package/src/interactions/extended-text/types.ts +0 -1
  127. package/src/interactions/gap-match/extractor.ts +0 -193
  128. package/src/interactions/gap-match/index.ts +0 -2
  129. package/src/interactions/gap-match/types.ts +0 -1
  130. package/src/interactions/graphic-associate/extractor.ts +0 -192
  131. package/src/interactions/graphic-associate/index.ts +0 -2
  132. package/src/interactions/graphic-associate/types.ts +0 -1
  133. package/src/interactions/graphic-gap-match/extractor.ts +0 -257
  134. package/src/interactions/graphic-gap-match/index.ts +0 -2
  135. package/src/interactions/graphic-gap-match/types.ts +0 -1
  136. package/src/interactions/graphic-order/extractor.ts +0 -162
  137. package/src/interactions/graphic-order/index.ts +0 -2
  138. package/src/interactions/graphic-order/types.ts +0 -1
  139. package/src/interactions/hotspot/extractor.ts +0 -208
  140. package/src/interactions/hotspot/index.ts +0 -2
  141. package/src/interactions/hotspot/types.ts +0 -1
  142. package/src/interactions/hottext/extractor.ts +0 -163
  143. package/src/interactions/hottext/index.ts +0 -2
  144. package/src/interactions/hottext/types.ts +0 -1
  145. package/src/interactions/index.ts +0 -52
  146. package/src/interactions/inline/index.ts +0 -1
  147. package/src/interactions/inline/render-plan.ts +0 -105
  148. package/src/interactions/inline-choice/InlineChoice.svelte +0 -57
  149. package/src/interactions/inline-choice/extractor.ts +0 -105
  150. package/src/interactions/inline-choice/index.ts +0 -2
  151. package/src/interactions/inline-choice/types.ts +0 -1
  152. package/src/interactions/match/extractor.ts +0 -187
  153. package/src/interactions/match/index.ts +0 -2
  154. package/src/interactions/match/types.ts +0 -1
  155. package/src/interactions/media/extractor.ts +0 -168
  156. package/src/interactions/media/index.ts +0 -2
  157. package/src/interactions/media/types.ts +0 -1
  158. package/src/interactions/modules.ts +0 -111
  159. package/src/interactions/order/extractor.ts +0 -120
  160. package/src/interactions/order/index.ts +0 -2
  161. package/src/interactions/order/types.ts +0 -1
  162. package/src/interactions/portable-custom/extractor.ts +0 -122
  163. package/src/interactions/portable-custom/index.ts +0 -2
  164. package/src/interactions/portable-custom/types.ts +0 -1
  165. package/src/interactions/position-object/extractor.ts +0 -243
  166. package/src/interactions/position-object/index.ts +0 -2
  167. package/src/interactions/position-object/types.ts +0 -1
  168. package/src/interactions/select-point/extractor.ts +0 -143
  169. package/src/interactions/select-point/index.ts +0 -2
  170. package/src/interactions/select-point/types.ts +0 -1
  171. package/src/interactions/shared/index.ts +0 -1
  172. package/src/interactions/shared/types.ts +0 -430
  173. package/src/interactions/slider/extractor.ts +0 -102
  174. package/src/interactions/slider/index.ts +0 -2
  175. package/src/interactions/slider/types.ts +0 -1
  176. package/src/interactions/text-entry/InlineTextEntry.svelte +0 -75
  177. package/src/interactions/text-entry/extractor.ts +0 -79
  178. package/src/interactions/text-entry/index.ts +0 -2
  179. package/src/interactions/text-entry/types.ts +0 -1
  180. package/src/interactions/upload/extractor.ts +0 -81
  181. package/src/interactions/upload/index.ts +0 -2
  182. package/src/interactions/upload/types.ts +0 -1
  183. package/src/pci/PciHost.ts +0 -138
  184. package/src/pci/types.ts +0 -70
  185. package/src/pnp/applyPnp.ts +0 -29
  186. package/src/pnp/parsePnpXml.ts +0 -215
  187. package/src/pnp/types.ts +0 -75
  188. package/src/server.ts +0 -14
  189. package/src/types/index.ts +0 -388
  190. package/src/types/interactions.ts +0 -8
  191. package/src/types/responseValidation.ts +0 -29
  192. package/src/types/xmldom.d.ts +0 -12
  193. package/src/utils/PerformanceMonitor.ts +0 -335
  194. package/src/utils/drawingUtils.ts +0 -73
  195. package/src/utils/responseUtils.ts +0 -51
  196. package/src/utils/touchDragHelper.ts +0 -1
  197. package/src/web-components/QTIInteractionBase.ts +0 -303
  198. package/src/web-components/QTIInteractionElement.ts +0 -125
  199. package/src/web-components/index.ts +0 -22
@@ -1,121 +0,0 @@
1
- /**
2
- * Standard QTI choiceInteraction extractor
3
- *
4
- * Extracts data from choiceInteraction elements with simpleChoice children
5
- */
6
-
7
- import type { ChoiceInteractionData } from '../shared/types.js';
8
- import type { ElementExtractor, ExtractionContext } from '../../extraction/types.js';
9
-
10
- /**
11
- * Choice data extracted from simpleChoice elements
12
- */
13
- export interface ChoiceData {
14
- choices: Array<{ identifier: string; text: string; fixed?: boolean; classes?: string[] }>;
15
- shuffle: boolean;
16
- maxChoices: number;
17
- minChoices: number;
18
- prompt: string | null;
19
- }
20
-
21
- /**
22
- * Standard QTI choice interaction extractor
23
- * Handles choiceInteraction elements with simpleChoice children
24
- */
25
- export const standardChoiceExtractor: ElementExtractor<ChoiceData> = {
26
- id: 'qti:choice-interaction',
27
- name: 'QTI Standard Choice Interaction',
28
- priority: 10,
29
- elementTypes: ['choiceInteraction'],
30
- description: 'Extracts standard QTI choiceInteraction with simpleChoice elements',
31
-
32
- canHandle(element, context) {
33
- // Standard QTI choice interactions have simpleChoice children
34
- return context.utils.hasChildWithTag(element, 'simpleChoice');
35
- },
36
-
37
- extract(element, context) {
38
- const { utils } = context;
39
-
40
- // Extract choices
41
- const simpleChoices = utils.getChildrenByTag(element, 'simpleChoice');
42
- const choices = simpleChoices.map((choice) => {
43
- const classes = utils.getClasses(choice);
44
- const fixed = utils.getBooleanAttribute(choice, 'fixed');
45
- return {
46
- identifier: utils.getAttribute(choice, 'identifier', ''),
47
- text: utils.getHtmlContent(choice),
48
- ...(fixed ? { fixed } : {}),
49
- ...(classes.length > 0 ? { classes } : {}),
50
- };
51
- });
52
-
53
- // Extract prompt
54
- const promptElement = utils.querySelector(element, 'prompt');
55
- const prompt = promptElement ? utils.getHtmlContent(promptElement) : null;
56
-
57
- // Extract attributes
58
- const shuffle = utils.getBooleanAttribute(element, 'shuffle');
59
- const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);
60
- const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
61
- const interactionClasses = utils.getClasses(element);
62
- const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
63
- const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
64
-
65
- return {
66
- choices,
67
- shuffle,
68
- maxChoices,
69
- minChoices,
70
- prompt,
71
- ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
72
- ...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
73
- ...(minSelectionsMessage ? { minSelectionsMessage } : {}),
74
- };
75
- },
76
-
77
- validate(data) {
78
- const errors: string[] = [];
79
- const warnings: string[] = [];
80
-
81
- // Validate choices exist
82
- if (!data.choices || data.choices.length === 0) {
83
- errors.push('choiceInteraction must have at least one choice');
84
- }
85
-
86
- // Validate choice identifiers
87
- if (data.choices) {
88
- const identifiers = new Set<string>();
89
- for (const choice of data.choices) {
90
- if (!choice.identifier) {
91
- errors.push('All choices must have an identifier');
92
- } else if (identifiers.has(choice.identifier)) {
93
- errors.push(`Duplicate choice identifier: ${choice.identifier}`);
94
- } else {
95
- identifiers.add(choice.identifier);
96
- }
97
- }
98
- }
99
-
100
- // Validate maxChoices
101
- if (data.maxChoices < 0) {
102
- errors.push('maxChoices must be non-negative');
103
- }
104
-
105
- if (data.maxChoices === 0) {
106
- warnings.push('maxChoices=0 means unlimited selections');
107
- }
108
-
109
- if (data.maxChoices > data.choices.length) {
110
- warnings.push(
111
- `maxChoices (${data.maxChoices}) is greater than the number of choices (${data.choices.length})`
112
- );
113
- }
114
-
115
- return {
116
- valid: errors.length === 0,
117
- errors: errors.length > 0 ? errors : undefined,
118
- warnings: warnings.length > 0 ? warnings : undefined,
119
- };
120
- },
121
- };
@@ -1,2 +0,0 @@
1
- export * from './extractor.js';
2
- export type { ChoiceInteractionData } from './types.js';
@@ -1 +0,0 @@
1
- export type { ChoiceInteractionData } from '../shared/types.js';
@@ -1,72 +0,0 @@
1
- /**
2
- * Standard QTI customInteraction extractor
3
- *
4
- * Extracts data from customInteraction elements (custom/portable interactions)
5
- */
6
-
7
- import type { ElementExtractor } from '../../extraction/types.js';
8
-
9
- /**
10
- * Custom interaction data extracted from customInteraction elements
11
- */
12
- export interface CustomData {
13
- xml: string;
14
- rawAttributes: Record<string, string>;
15
- prompt: string | null;
16
- }
17
-
18
- /**
19
- * Standard QTI custom interaction extractor
20
- * Handles customInteraction elements (vendor-specific or portable custom interactions)
21
- */
22
- export const standardCustomExtractor: ElementExtractor<CustomData> = {
23
- id: 'qti:custom-interaction',
24
- name: 'QTI Standard Custom Interaction',
25
- priority: 10,
26
- elementTypes: ['customInteraction'],
27
- description: 'Extracts standard QTI customInteraction (custom/portable interactions)',
28
-
29
- canHandle(element, _context) {
30
- // All customInteraction elements are handled by this extractor
31
- return element.rawTagName === 'customInteraction';
32
- },
33
-
34
- extract(element, context) {
35
- const { utils } = context;
36
-
37
- // Capture the raw XML for the custom interaction
38
- const xml = element.outerHTML || element.toString();
39
-
40
- // Extract all attributes
41
- const rawAttributes: Record<string, string> = {};
42
- if (element.attributes) {
43
- for (const [key, value] of Object.entries(element.attributes)) {
44
- rawAttributes[key] = String(value);
45
- }
46
- }
47
-
48
- // Extract prompt (optional)
49
- const promptElements = utils.getChildrenByTag(element, 'prompt');
50
- const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
51
-
52
- return {
53
- xml,
54
- rawAttributes,
55
- prompt,
56
- };
57
- },
58
-
59
- validate(_data) {
60
- const warnings: string[] = [];
61
-
62
- // Warn if no XML content
63
- if (!_data.xml || _data.xml.trim() === '') {
64
- warnings.push('customInteraction has no XML content');
65
- }
66
-
67
- return {
68
- valid: true,
69
- warnings: warnings.length > 0 ? warnings : undefined,
70
- };
71
- },
72
- };
@@ -1,2 +0,0 @@
1
- export * from './extractor.js';
2
- export type { CustomInteractionData } from './types.js';
@@ -1 +0,0 @@
1
- export type { CustomInteractionData } from '../shared/types.js';
@@ -1,113 +0,0 @@
1
- /**
2
- * Standard QTI drawingInteraction extractor
3
- *
4
- * Extracts data from drawingInteraction elements (drawing on canvas)
5
- */
6
-
7
- import type { ElementExtractor } from '../../extraction/types.js';
8
-
9
- /**
10
- * Image data for drawing interaction
11
- */
12
- export interface ImageData {
13
- type: 'image' | 'svg';
14
- src?: string;
15
- content?: string;
16
- width?: string;
17
- height?: string;
18
- }
19
-
20
- /**
21
- * Drawing data extracted from drawingInteraction elements
22
- */
23
- export interface DrawingData {
24
- imageData: ImageData | null;
25
- rawAttributes: Record<string, string>;
26
- prompt: string | null;
27
- }
28
-
29
- /**
30
- * Standard QTI drawing interaction extractor
31
- * Handles drawingInteraction elements (drawing on a canvas)
32
- */
33
- export const standardDrawingExtractor: ElementExtractor<DrawingData> = {
34
- id: 'qti:drawing-interaction',
35
- name: 'QTI Standard Drawing Interaction',
36
- priority: 10,
37
- elementTypes: ['drawingInteraction'],
38
- description: 'Extracts standard QTI drawingInteraction (drawing on canvas)',
39
-
40
- canHandle(element, _context) {
41
- // All drawingInteraction elements are standard
42
- return element.rawTagName === 'drawingInteraction';
43
- },
44
-
45
- extract(element, context) {
46
- const { utils } = context;
47
-
48
- // Extract background image data from object element (optional)
49
- const objectElements = utils.getChildrenByTag(element, 'object');
50
- let imageData: ImageData | null = null;
51
-
52
- if (objectElements.length > 0) {
53
- const objectElement = objectElements[0];
54
- const type = utils.getAttribute(objectElement, 'type', '');
55
- const data = utils.getAttribute(objectElement, 'data', '');
56
- const width = utils.getAttribute(objectElement, 'width', '');
57
- const height = utils.getAttribute(objectElement, 'height', '');
58
-
59
- if (type.startsWith('image/svg')) {
60
- // Extract inline SVG content
61
- const content = utils.getHtmlContent(objectElement);
62
- imageData = {
63
- type: 'svg',
64
- content,
65
- ...(width ? { width } : {}),
66
- ...(height ? { height } : {}),
67
- };
68
- } else if (data) {
69
- // External image reference
70
- imageData = {
71
- type: 'image',
72
- src: data,
73
- ...(width ? { width } : {}),
74
- ...(height ? { height } : {}),
75
- };
76
- }
77
- }
78
-
79
- // Extract all attributes
80
- const rawAttributes: Record<string, string> = {};
81
- if (element.attributes) {
82
- for (const [key, value] of Object.entries(element.attributes)) {
83
- rawAttributes[key] = String(value);
84
- }
85
- }
86
-
87
- // Extract prompt (optional)
88
- const promptElements = utils.getChildrenByTag(element, 'prompt');
89
- const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
90
-
91
- return {
92
- imageData,
93
- rawAttributes,
94
- prompt,
95
- };
96
- },
97
-
98
- validate(data) {
99
- const warnings: string[] = [];
100
-
101
- // Warn if no background image
102
- if (!data.imageData) {
103
- warnings.push(
104
- 'drawingInteraction has no background image - students will draw on a blank canvas'
105
- );
106
- }
107
-
108
- return {
109
- valid: true,
110
- warnings: warnings.length > 0 ? warnings : undefined,
111
- };
112
- },
113
- };
@@ -1,2 +0,0 @@
1
- export * from './extractor.js';
2
- export type { DrawingInteractionData } from './types.js';
@@ -1 +0,0 @@
1
- export type { DrawingInteractionData } from '../shared/types.js';
@@ -1,74 +0,0 @@
1
- /**
2
- * Standard QTI endAttemptInteraction extractor
3
- *
4
- * Extracts data from endAttemptInteraction elements (end attempt button)
5
- */
6
-
7
- import type { ElementExtractor } from '../../extraction/types.js';
8
-
9
- /**
10
- * End attempt data extracted from endAttemptInteraction elements
11
- */
12
- export interface EndAttemptData {
13
- title?: string;
14
- countAttempt?: boolean;
15
- prompt: string | null;
16
- }
17
-
18
- /**
19
- * Standard QTI end attempt interaction extractor
20
- * Handles endAttemptInteraction elements (button to end the attempt)
21
- */
22
- export const standardEndAttemptExtractor: ElementExtractor<EndAttemptData> = {
23
- id: 'qti:end-attempt-interaction',
24
- name: 'QTI Standard End Attempt Interaction',
25
- priority: 10,
26
- elementTypes: ['endAttemptInteraction'],
27
- description: 'Extracts standard QTI endAttemptInteraction (end attempt button)',
28
-
29
- canHandle(element, _context) {
30
- // All endAttemptInteraction elements are standard
31
- return element.rawTagName === 'endAttemptInteraction';
32
- },
33
-
34
- extract(element, context) {
35
- const { utils } = context;
36
-
37
- // Extract attributes with defaults
38
- const title = utils.getAttribute(element, 'title', 'End Attempt');
39
- const countAttempt = element.hasAttribute('countAttempt')
40
- ? utils.getBooleanAttribute(element, 'countAttempt')
41
- : true;
42
-
43
- // Extract prompt (optional)
44
- const promptElements = utils.getChildrenByTag(element, 'prompt');
45
- const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
46
-
47
- return {
48
- title,
49
- countAttempt,
50
- prompt,
51
- };
52
- },
53
-
54
- validate(data) {
55
- const errors: string[] = [];
56
- const warnings: string[] = [];
57
-
58
- // Validate title is not empty
59
- if (!data.title || data.title.trim() === '') {
60
- errors.push('endAttemptInteraction must have a title');
61
- }
62
-
63
- // Warn if countAttempt is false (uncommon usage)
64
- if (data.countAttempt === false) {
65
- warnings.push('endAttemptInteraction has countAttempt=false - make sure this is intentional');
66
- }
67
-
68
- return {
69
- valid: errors.length === 0,
70
- errors: errors.length > 0 ? errors : undefined,
71
- warnings: warnings.length > 0 ? warnings : undefined,
72
- };
73
- },
74
- };
@@ -1,2 +0,0 @@
1
- export * from './extractor.js';
2
- export type { EndAttemptInteractionData } from './types.js';
@@ -1 +0,0 @@
1
- export type { EndAttemptInteractionData } from '../shared/types.js';
@@ -1,92 +0,0 @@
1
- /**
2
- * Standard QTI extendedTextInteraction extractor
3
- *
4
- * Extracts data from extendedTextInteraction elements (multi-line text input)
5
- */
6
-
7
- import type { ElementExtractor } from '../../extraction/types.js';
8
-
9
- /**
10
- * Extended text data extracted from extendedTextInteraction elements
11
- */
12
- export interface ExtendedTextData {
13
- expectedLines: number;
14
- expectedLength: number;
15
- prompt: string | null;
16
- placeholderText: string;
17
- format: string;
18
- }
19
-
20
- /**
21
- * Standard QTI extended text interaction extractor
22
- * Handles extendedTextInteraction elements (multi-line text input)
23
- */
24
- export const standardExtendedTextExtractor: ElementExtractor<ExtendedTextData> = {
25
- id: 'qti:extended-text-interaction',
26
- name: 'QTI Standard Extended Text Interaction',
27
- priority: 10,
28
- elementTypes: ['extendedTextInteraction'],
29
- description: 'Extracts standard QTI extendedTextInteraction (multi-line text input)',
30
-
31
- canHandle(element, _context) {
32
- // All extendedTextInteraction elements are standard (both QTI 2.x and 3.0)
33
- return (
34
- element.rawTagName === 'extendedTextInteraction' ||
35
- element.rawTagName === 'qti-extended-text-interaction'
36
- );
37
- },
38
-
39
- extract(element, context) {
40
- const { utils } = context;
41
-
42
- // Extract attributes
43
- const expectedLines = utils.getNumberAttribute(element, 'expectedLines', 3);
44
- const expectedLength = utils.getNumberAttribute(element, 'expectedLength', 200);
45
- const placeholderText = utils.getAttribute(element, 'placeholderText', '');
46
- const format = utils.getAttribute(element, 'format', 'plain');
47
- const patternMask = utils.getAttribute(element, 'patternMask', '') || null;
48
- const patternMaskMessage = utils.getAttribute(element, 'patternMaskMessage', '') || null;
49
- const interactionClasses = utils.getClasses(element);
50
- const prompt = utils.getPrompt(element);
51
-
52
- return {
53
- expectedLines,
54
- expectedLength,
55
- prompt,
56
- placeholderText,
57
- format,
58
- ...(patternMask ? { patternMask } : {}),
59
- ...(patternMaskMessage ? { patternMaskMessage } : {}),
60
- ...(interactionClasses.length > 0 ? { interactionClasses } : {}),
61
- };
62
- },
63
-
64
- validate(data) {
65
- const errors: string[] = [];
66
- const warnings: string[] = [];
67
-
68
- // Validate expectedLines
69
- if (data.expectedLines < 1) {
70
- errors.push('expectedLines must be at least 1');
71
- }
72
-
73
- // Validate expectedLength
74
- if (data.expectedLength < 1) {
75
- errors.push('expectedLength must be positive');
76
- }
77
-
78
- // Validate format
79
- const validFormats = ['plain', 'preFormatted', 'xhtml'];
80
- if (!validFormats.includes(data.format)) {
81
- warnings.push(
82
- `Unrecognized format "${data.format}" - expected plain, preFormatted, or xhtml`
83
- );
84
- }
85
-
86
- return {
87
- valid: errors.length === 0,
88
- errors: errors.length > 0 ? errors : undefined,
89
- warnings: warnings.length > 0 ? warnings : undefined,
90
- };
91
- },
92
- };
@@ -1,2 +0,0 @@
1
- export * from './extractor.js';
2
- export type { ExtendedTextInteractionData } from './types.js';
@@ -1 +0,0 @@
1
- export type { ExtendedTextInteractionData } from '../shared/types.js';