@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.
- package/README.md +17 -0
- package/dist/catalog/applyGlossaryTriggers.d.ts +13 -2
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
- package/dist/catalog/glossaryAction.d.ts +4 -2
- package/dist/catalog/glossaryAction.d.ts.map +1 -1
- package/dist/components/utils/index.d.ts +1 -2
- package/dist/components/utils/index.d.ts.map +1 -1
- package/dist/components/utils/index.js +1 -2
- package/dist/core/ComponentRegistry.d.ts +10 -1
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +42 -1
- package/dist/core/Player.d.ts +10 -2
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +54 -46
- package/dist/document/AssessmentItemDocument.d.ts +1 -1
- package/dist/element.d.ts +15 -0
- package/dist/element.js +1921 -1785
- package/dist/element.js.map +1 -1
- package/dist/extraction/ExtractionRegistry.d.ts +1 -1
- package/dist/extraction/createContext.d.ts +1 -1
- package/dist/extraction/index.d.ts +2 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +1 -1
- package/dist/extraction/interactionExtractionPipeline.d.ts +1 -1
- package/dist/extraction/interactionSecurity.d.ts +1 -1
- package/dist/extraction/types.d.ts +1 -1
- package/dist/presentation/itemPresentationPlan.d.ts +54 -0
- package/dist/presentation/itemPresentationPlan.d.ts.map +1 -0
- package/dist/presentation/itemPresentationPlan.js +98 -0
- package/dist/types/index.d.ts +17 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -3
- package/dist/web-components/QTIInteractionBase.d.ts +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +1 -1
- package/package.json +10 -12
- package/src/__tests__/catalog.test.ts +0 -267
- package/src/__tests__/fixtures/pci/echo-pci.js +0 -49
- package/src/__tests__/pci.test.ts +0 -353
- package/src/__tests__/qti3-attribute-extraction.test.ts +0 -174
- package/src/__tests__/qti3-debug.test.ts +0 -140
- package/src/__tests__/qti3-extraction.test.ts +0 -309
- package/src/catalog/applyGlossaryTriggers.ts +0 -372
- package/src/catalog/catalogExtractor.ts +0 -130
- package/src/catalog/catalogLookup.ts +0 -53
- package/src/catalog/glossaryAction.ts +0 -38
- package/src/catalog/types.ts +0 -37
- package/src/components/ItemBody.svelte +0 -363
- package/src/components/ItemPlayer.svelte +0 -163
- package/src/components/ModalFeedbackDisplay.svelte +0 -97
- package/src/components/actions/typesetAction.ts +0 -74
- package/src/components/index.ts +0 -22
- package/src/components/utils/assignProps.ts +0 -2
- package/src/components/utils/feedbackUtils.ts +0 -140
- package/src/components/utils/index.ts +0 -13
- package/src/components/utils/stimulusRender.ts +0 -93
- package/src/components/utils/stylesheetRender.ts +0 -58
- package/src/core/ComponentRegistry.ts +0 -248
- package/src/core/Player.ts +0 -1618
- package/src/core/Plugin.ts +0 -123
- package/src/core/PluginManager.ts +0 -182
- package/src/core/constants.ts +0 -117
- package/src/core/declarations.ts +0 -171
- package/src/core/parsingLimits.ts +0 -62
- package/src/core/random.ts +0 -24
- package/src/core/rolePolicy.ts +0 -34
- package/src/core/sanitizer.ts +0 -305
- package/src/core/trustedTypes.ts +0 -63
- package/src/core/urlPolicy.ts +0 -98
- package/src/document/AssessmentItemDocument.ts +0 -247
- package/src/element.ts +0 -128
- package/src/extensions/MathLiveEditor.ts +0 -313
- package/src/extraction/ExtractionRegistry.ts +0 -335
- package/src/extraction/createContext.ts +0 -52
- package/src/extraction/extractors/associateExtractor.ts +0 -1
- package/src/extraction/extractors/choiceExtractor.ts +0 -1
- package/src/extraction/extractors/conformance-qti3-advanced.test.ts +0 -239
- package/src/extraction/extractors/conformance-qti3-basic.test.ts +0 -82
- package/src/extraction/extractors/conformance.test.ts +0 -208
- package/src/extraction/extractors/customExtractor.ts +0 -1
- package/src/extraction/extractors/drawingExtractor.ts +0 -1
- package/src/extraction/extractors/endAttemptExtractor.ts +0 -1
- package/src/extraction/extractors/extendedTextExtractor.ts +0 -1
- package/src/extraction/extractors/gapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicAssociateExtractor.ts +0 -1
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicOrderExtractor.ts +0 -1
- package/src/extraction/extractors/hotspotExtractor.ts +0 -1
- package/src/extraction/extractors/hottextExtractor.ts +0 -1
- package/src/extraction/extractors/index.ts +0 -9
- package/src/extraction/extractors/inlineChoiceExtractor.ts +0 -1
- package/src/extraction/extractors/matchExtractor.ts +0 -1
- package/src/extraction/extractors/mediaExtractor.ts +0 -1
- package/src/extraction/extractors/orderExtractor.ts +0 -1
- package/src/extraction/extractors/portableCustomExtractor.ts +0 -1
- package/src/extraction/extractors/positionObjectExtractor.ts +0 -1
- package/src/extraction/extractors/selectPointExtractor.ts +0 -1
- package/src/extraction/extractors/sliderExtractor.ts +0 -1
- package/src/extraction/extractors/textEntryExtractor.ts +0 -1
- package/src/extraction/extractors/uploadExtractor.ts +0 -1
- package/src/extraction/index.ts +0 -108
- package/src/extraction/interactionExtractionPipeline.ts +0 -70
- package/src/extraction/interactionSecurity.ts +0 -60
- package/src/extraction/types.ts +0 -246
- package/src/extraction/utils.ts +0 -243
- package/src/iframe/IFramePlayerHost.ts +0 -265
- package/src/iframe/index.ts +0 -11
- package/src/iframe/protocol.ts +0 -137
- package/src/index.ts +0 -101
- package/src/interactions/associate/extractor.ts +0 -133
- package/src/interactions/associate/index.ts +0 -2
- package/src/interactions/associate/types.ts +0 -1
- package/src/interactions/choice/extractor.ts +0 -121
- package/src/interactions/choice/index.ts +0 -2
- package/src/interactions/choice/types.ts +0 -1
- package/src/interactions/custom/extractor.ts +0 -72
- package/src/interactions/custom/index.ts +0 -2
- package/src/interactions/custom/types.ts +0 -1
- package/src/interactions/drawing/extractor.ts +0 -113
- package/src/interactions/drawing/index.ts +0 -2
- package/src/interactions/drawing/types.ts +0 -1
- package/src/interactions/end-attempt/extractor.ts +0 -74
- package/src/interactions/end-attempt/index.ts +0 -2
- package/src/interactions/end-attempt/types.ts +0 -1
- package/src/interactions/extended-text/extractor.ts +0 -92
- package/src/interactions/extended-text/index.ts +0 -2
- package/src/interactions/extended-text/types.ts +0 -1
- package/src/interactions/gap-match/extractor.ts +0 -193
- package/src/interactions/gap-match/index.ts +0 -2
- package/src/interactions/gap-match/types.ts +0 -1
- package/src/interactions/graphic-associate/extractor.ts +0 -192
- package/src/interactions/graphic-associate/index.ts +0 -2
- package/src/interactions/graphic-associate/types.ts +0 -1
- package/src/interactions/graphic-gap-match/extractor.ts +0 -257
- package/src/interactions/graphic-gap-match/index.ts +0 -2
- package/src/interactions/graphic-gap-match/types.ts +0 -1
- package/src/interactions/graphic-order/extractor.ts +0 -162
- package/src/interactions/graphic-order/index.ts +0 -2
- package/src/interactions/graphic-order/types.ts +0 -1
- package/src/interactions/hotspot/extractor.ts +0 -208
- package/src/interactions/hotspot/index.ts +0 -2
- package/src/interactions/hotspot/types.ts +0 -1
- package/src/interactions/hottext/extractor.ts +0 -163
- package/src/interactions/hottext/index.ts +0 -2
- package/src/interactions/hottext/types.ts +0 -1
- package/src/interactions/index.ts +0 -52
- package/src/interactions/inline/index.ts +0 -1
- package/src/interactions/inline/render-plan.ts +0 -105
- package/src/interactions/inline-choice/InlineChoice.svelte +0 -57
- package/src/interactions/inline-choice/extractor.ts +0 -105
- package/src/interactions/inline-choice/index.ts +0 -2
- package/src/interactions/inline-choice/types.ts +0 -1
- package/src/interactions/match/extractor.ts +0 -187
- package/src/interactions/match/index.ts +0 -2
- package/src/interactions/match/types.ts +0 -1
- package/src/interactions/media/extractor.ts +0 -168
- package/src/interactions/media/index.ts +0 -2
- package/src/interactions/media/types.ts +0 -1
- package/src/interactions/modules.ts +0 -111
- package/src/interactions/order/extractor.ts +0 -120
- package/src/interactions/order/index.ts +0 -2
- package/src/interactions/order/types.ts +0 -1
- package/src/interactions/portable-custom/extractor.ts +0 -122
- package/src/interactions/portable-custom/index.ts +0 -2
- package/src/interactions/portable-custom/types.ts +0 -1
- package/src/interactions/position-object/extractor.ts +0 -243
- package/src/interactions/position-object/index.ts +0 -2
- package/src/interactions/position-object/types.ts +0 -1
- package/src/interactions/select-point/extractor.ts +0 -143
- package/src/interactions/select-point/index.ts +0 -2
- package/src/interactions/select-point/types.ts +0 -1
- package/src/interactions/shared/index.ts +0 -1
- package/src/interactions/shared/types.ts +0 -430
- package/src/interactions/slider/extractor.ts +0 -102
- package/src/interactions/slider/index.ts +0 -2
- package/src/interactions/slider/types.ts +0 -1
- package/src/interactions/text-entry/InlineTextEntry.svelte +0 -75
- package/src/interactions/text-entry/extractor.ts +0 -79
- package/src/interactions/text-entry/index.ts +0 -2
- package/src/interactions/text-entry/types.ts +0 -1
- package/src/interactions/upload/extractor.ts +0 -81
- package/src/interactions/upload/index.ts +0 -2
- package/src/interactions/upload/types.ts +0 -1
- package/src/pci/PciHost.ts +0 -138
- package/src/pci/types.ts +0 -70
- package/src/pnp/applyPnp.ts +0 -29
- package/src/pnp/parsePnpXml.ts +0 -215
- package/src/pnp/types.ts +0 -75
- package/src/server.ts +0 -14
- package/src/types/index.ts +0 -388
- package/src/types/interactions.ts +0 -8
- package/src/types/responseValidation.ts +0 -29
- package/src/types/xmldom.d.ts +0 -12
- package/src/utils/PerformanceMonitor.ts +0 -335
- package/src/utils/drawingUtils.ts +0 -73
- package/src/utils/responseUtils.ts +0 -51
- package/src/utils/touchDragHelper.ts +0 -1
- package/src/web-components/QTIInteractionBase.ts +0 -303
- package/src/web-components/QTIInteractionElement.ts +0 -125
- package/src/web-components/index.ts +0 -22
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type { ElementExtractor } from '../extraction/types.js';
|
|
2
|
-
import type { InteractionDataMap } from './shared/types.js';
|
|
3
|
-
import { standardAssociateExtractor } from './associate/index.js';
|
|
4
|
-
import { standardChoiceExtractor } from './choice/index.js';
|
|
5
|
-
import { standardCustomExtractor } from './custom/index.js';
|
|
6
|
-
import { standardDrawingExtractor } from './drawing/index.js';
|
|
7
|
-
import { standardEndAttemptExtractor } from './end-attempt/index.js';
|
|
8
|
-
import { standardExtendedTextExtractor } from './extended-text/index.js';
|
|
9
|
-
import { standardGapMatchExtractor } from './gap-match/index.js';
|
|
10
|
-
import { standardGraphicAssociateExtractor } from './graphic-associate/index.js';
|
|
11
|
-
import { standardGraphicGapMatchExtractor } from './graphic-gap-match/index.js';
|
|
12
|
-
import { standardGraphicOrderExtractor } from './graphic-order/index.js';
|
|
13
|
-
import { standardHotspotExtractor } from './hotspot/index.js';
|
|
14
|
-
import { standardHottextExtractor } from './hottext/index.js';
|
|
15
|
-
import { standardInlineChoiceExtractor } from './inline-choice/index.js';
|
|
16
|
-
import { standardMatchExtractor } from './match/index.js';
|
|
17
|
-
import { standardMediaExtractor } from './media/index.js';
|
|
18
|
-
import { standardOrderExtractor } from './order/index.js';
|
|
19
|
-
import { standardPositionObjectExtractor } from './position-object/index.js';
|
|
20
|
-
import { standardSelectPointExtractor } from './select-point/index.js';
|
|
21
|
-
import { standardSliderExtractor } from './slider/index.js';
|
|
22
|
-
import { standardTextEntryExtractor } from './text-entry/index.js';
|
|
23
|
-
import { standardUploadExtractor } from './upload/index.js';
|
|
24
|
-
|
|
25
|
-
export type StandardInteractionType = keyof InteractionDataMap;
|
|
26
|
-
export type InteractionPlacement = 'block' | 'inline';
|
|
27
|
-
|
|
28
|
-
export interface StandardInteractionModule {
|
|
29
|
-
type: StandardInteractionType;
|
|
30
|
-
extractor: ElementExtractor;
|
|
31
|
-
placement: InteractionPlacement;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const STANDARD_INTERACTION_MODULES = [
|
|
35
|
-
{ type: 'choiceInteraction', extractor: standardChoiceExtractor, placement: 'block' },
|
|
36
|
-
{ type: 'textEntryInteraction', extractor: standardTextEntryExtractor, placement: 'inline' },
|
|
37
|
-
{ type: 'extendedTextInteraction', extractor: standardExtendedTextExtractor, placement: 'block' },
|
|
38
|
-
{ type: 'inlineChoiceInteraction', extractor: standardInlineChoiceExtractor, placement: 'inline' },
|
|
39
|
-
{ type: 'orderInteraction', extractor: standardOrderExtractor, placement: 'block' },
|
|
40
|
-
{ type: 'matchInteraction', extractor: standardMatchExtractor, placement: 'block' },
|
|
41
|
-
{ type: 'associateInteraction', extractor: standardAssociateExtractor, placement: 'block' },
|
|
42
|
-
{ type: 'gapMatchInteraction', extractor: standardGapMatchExtractor, placement: 'block' },
|
|
43
|
-
{ type: 'sliderInteraction', extractor: standardSliderExtractor, placement: 'block' },
|
|
44
|
-
{ type: 'hotspotInteraction', extractor: standardHotspotExtractor, placement: 'block' },
|
|
45
|
-
{ type: 'graphicGapMatchInteraction', extractor: standardGraphicGapMatchExtractor, placement: 'block' },
|
|
46
|
-
{ type: 'uploadInteraction', extractor: standardUploadExtractor, placement: 'block' },
|
|
47
|
-
{ type: 'drawingInteraction', extractor: standardDrawingExtractor, placement: 'block' },
|
|
48
|
-
{ type: 'customInteraction', extractor: standardCustomExtractor, placement: 'block' },
|
|
49
|
-
{ type: 'mediaInteraction', extractor: standardMediaExtractor, placement: 'block' },
|
|
50
|
-
{ type: 'hottextInteraction', extractor: standardHottextExtractor, placement: 'block' },
|
|
51
|
-
{ type: 'selectPointInteraction', extractor: standardSelectPointExtractor, placement: 'block' },
|
|
52
|
-
{ type: 'graphicOrderInteraction', extractor: standardGraphicOrderExtractor, placement: 'block' },
|
|
53
|
-
{ type: 'graphicAssociateInteraction', extractor: standardGraphicAssociateExtractor, placement: 'block' },
|
|
54
|
-
{ type: 'positionObjectInteraction', extractor: standardPositionObjectExtractor, placement: 'block' },
|
|
55
|
-
{ type: 'endAttemptInteraction', extractor: standardEndAttemptExtractor, placement: 'block' },
|
|
56
|
-
] as const satisfies readonly StandardInteractionModule[];
|
|
57
|
-
|
|
58
|
-
export function getStandardInteractionModules(): readonly StandardInteractionModule[] {
|
|
59
|
-
return STANDARD_INTERACTION_MODULES;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function getStandardBlockInteractionModules(): readonly StandardInteractionModule[] {
|
|
63
|
-
return STANDARD_INTERACTION_MODULES.filter((module) => module.placement === 'block');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function getStandardInlineInteractionModules(): readonly StandardInteractionModule[] {
|
|
67
|
-
return STANDARD_INTERACTION_MODULES.filter((module) => module.placement === 'inline');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function getStandardInteractionExtractors(): readonly ElementExtractor[] {
|
|
71
|
-
return STANDARD_INTERACTION_MODULES.map((module) => module.extractor);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function getStandardInteractionElementTypes(): string[] {
|
|
75
|
-
const elementTypes = new Set<string>();
|
|
76
|
-
for (const module of STANDARD_INTERACTION_MODULES) {
|
|
77
|
-
for (const elementType of module.extractor.elementTypes) {
|
|
78
|
-
elementTypes.add(elementType);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return [...elementTypes];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const STANDARD_TYPE_BY_LOWERCASE = new Map(
|
|
85
|
-
STANDARD_INTERACTION_MODULES.map((module) => [module.type.toLowerCase(), module.type])
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
export function normalizeInteractionTypeFromTagName(tagName: string): string {
|
|
89
|
-
const lowerTagName = tagName.toLowerCase();
|
|
90
|
-
if (lowerTagName.startsWith('qti-')) {
|
|
91
|
-
return lowerTagName.slice(4).replace(/-([a-z])/g, (_match, letter: string) => letter.toUpperCase());
|
|
92
|
-
}
|
|
93
|
-
return STANDARD_TYPE_BY_LOWERCASE.get(lowerTagName) ?? tagName;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function getStandardInteractionModule(type: string): StandardInteractionModule | null {
|
|
97
|
-
const normalizedType = normalizeInteractionTypeFromTagName(type);
|
|
98
|
-
return STANDARD_INTERACTION_MODULES.find((module) => module.type === normalizedType) ?? null;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function isStandardInlineInteractionType(type: string): type is 'textEntryInteraction' | 'inlineChoiceInteraction' {
|
|
102
|
-
return getStandardInteractionModule(type)?.placement === 'inline';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function isStandardBlockInteractionType(type: string): boolean {
|
|
106
|
-
return getStandardInteractionModule(type)?.placement === 'block';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function isStandardInlineInteractionTagName(tagName: string): boolean {
|
|
110
|
-
return isStandardInlineInteractionType(normalizeInteractionTypeFromTagName(tagName));
|
|
111
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standard QTI orderInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from orderInteraction elements (ordering/ranking tasks)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../../extraction/types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Order data extracted from orderInteraction elements
|
|
11
|
-
*/
|
|
12
|
-
export interface OrderData {
|
|
13
|
-
choices: Array<{ identifier: string; text: string; fixed?: boolean; classes?: string[] }>;
|
|
14
|
-
shuffle: boolean;
|
|
15
|
-
minChoices: number;
|
|
16
|
-
maxChoices: number;
|
|
17
|
-
orientation?: string;
|
|
18
|
-
prompt: string | null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Standard QTI order interaction extractor
|
|
23
|
-
* Handles orderInteraction elements with simpleChoice children
|
|
24
|
-
*/
|
|
25
|
-
export const standardOrderExtractor: ElementExtractor<OrderData> = {
|
|
26
|
-
id: 'qti:order-interaction',
|
|
27
|
-
name: 'QTI Standard Order Interaction',
|
|
28
|
-
priority: 10,
|
|
29
|
-
elementTypes: ['orderInteraction'],
|
|
30
|
-
description: 'Extracts standard QTI orderInteraction (ordering/ranking tasks)',
|
|
31
|
-
|
|
32
|
-
canHandle(element, context) {
|
|
33
|
-
// Standard QTI order 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
|
-
|
|
46
|
-
return {
|
|
47
|
-
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
48
|
-
text: utils.getHtmlContent(choice),
|
|
49
|
-
...(fixed ? { fixed } : {}),
|
|
50
|
-
...(classes.length > 0 ? { classes } : {}),
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Extract prompt
|
|
55
|
-
const promptElement = utils.querySelector(element, 'prompt');
|
|
56
|
-
const prompt = promptElement ? utils.getHtmlContent(promptElement) : null;
|
|
57
|
-
|
|
58
|
-
// Extract attributes
|
|
59
|
-
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
60
|
-
const orientation = utils.getAttribute(element, 'orientation', 'vertical');
|
|
61
|
-
const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
|
|
62
|
-
const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 0);
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
choices,
|
|
66
|
-
shuffle,
|
|
67
|
-
orientation,
|
|
68
|
-
minChoices,
|
|
69
|
-
maxChoices,
|
|
70
|
-
prompt,
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
validate(data) {
|
|
75
|
-
const errors: string[] = [];
|
|
76
|
-
const warnings: string[] = [];
|
|
77
|
-
|
|
78
|
-
// Validate choices exist
|
|
79
|
-
if (!data.choices || data.choices.length < 2) {
|
|
80
|
-
errors.push('orderInteraction must have at least 2 choices');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Warn if too many choices (difficult to order)
|
|
84
|
-
if (data.choices && data.choices.length > 10) {
|
|
85
|
-
warnings.push(
|
|
86
|
-
`orderInteraction has ${data.choices.length} choices - this may be difficult for users to order`
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Validate choice identifiers
|
|
91
|
-
if (data.choices) {
|
|
92
|
-
const identifiers = new Set<string>();
|
|
93
|
-
for (const choice of data.choices) {
|
|
94
|
-
if (!choice.identifier) {
|
|
95
|
-
errors.push('All choices must have an identifier');
|
|
96
|
-
} else if (identifiers.has(choice.identifier)) {
|
|
97
|
-
errors.push(`Duplicate choice identifier: ${choice.identifier}`);
|
|
98
|
-
} else {
|
|
99
|
-
identifiers.add(choice.identifier);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Validate orientation (only if provided)
|
|
105
|
-
if (data.orientation) {
|
|
106
|
-
const validOrientations = ['vertical', 'horizontal'];
|
|
107
|
-
if (!validOrientations.includes(data.orientation)) {
|
|
108
|
-
warnings.push(
|
|
109
|
-
`orientation '${data.orientation}' is not standard (expected: ${validOrientations.join(', ')})`
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
valid: errors.length === 0,
|
|
116
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
117
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { OrderInteractionData } from '../shared/types.js';
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { ElementExtractor } from '../../extraction/types.js';
|
|
2
|
-
import type { ExtractedPci } from '../../pci/types.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Extractor for <qti-portable-custom-interaction> (QTI 3.0) and
|
|
6
|
-
* <portableCustomInteraction> (QTI 2.x vendor extension).
|
|
7
|
-
*
|
|
8
|
-
* Extracts the module paths, markup, and config properties needed by PciHost
|
|
9
|
-
* to load and initialize the PCI JavaScript module.
|
|
10
|
-
*
|
|
11
|
-
* Priority 20 > standardCustomExtractor priority 10, so this runs first when
|
|
12
|
-
* both would match the same element.
|
|
13
|
-
*/
|
|
14
|
-
export const portableCustomExtractor: ElementExtractor<ExtractedPci> = {
|
|
15
|
-
id: 'qti:portable-custom-interaction',
|
|
16
|
-
name: 'QTI Portable Custom Interaction',
|
|
17
|
-
priority: 20,
|
|
18
|
-
elementTypes: [
|
|
19
|
-
'portableCustomInteraction',
|
|
20
|
-
'qti-portable-custom-interaction',
|
|
21
|
-
],
|
|
22
|
-
description: 'Extracts QTI 3.0 portable custom interaction module paths, markup, and config',
|
|
23
|
-
|
|
24
|
-
canHandle(element, _context) {
|
|
25
|
-
const tag = element.rawTagName?.toLowerCase() ?? '';
|
|
26
|
-
return (
|
|
27
|
-
tag === 'qti-portable-custom-interaction' ||
|
|
28
|
-
tag === 'portablecustominteraction'
|
|
29
|
-
);
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
extract(element, context) {
|
|
33
|
-
const { utils } = context;
|
|
34
|
-
|
|
35
|
-
const responseIdentifier = utils.getAttribute(element, 'responseIdentifier') ||
|
|
36
|
-
utils.getAttribute(element, 'response-identifier') || '';
|
|
37
|
-
|
|
38
|
-
const customInteractionTypeIdentifier =
|
|
39
|
-
utils.getAttribute(element, 'customInteractionTypeIdentifier') ||
|
|
40
|
-
utils.getAttribute(element, 'custom-interaction-type-identifier') || '';
|
|
41
|
-
|
|
42
|
-
// --- Module paths from <qti-interaction-modules>/<qti-interaction-module> ---
|
|
43
|
-
// These element names ARE in the standard QTI 3.0 element mapper so utils.querySelector works.
|
|
44
|
-
let primaryPath = '';
|
|
45
|
-
let fallbackPath: string | undefined;
|
|
46
|
-
|
|
47
|
-
const modulesEl =
|
|
48
|
-
utils.querySelector(element, 'qti-interaction-modules') ??
|
|
49
|
-
utils.querySelector(element, 'interactionmodules');
|
|
50
|
-
|
|
51
|
-
if (modulesEl) {
|
|
52
|
-
const moduleEl =
|
|
53
|
-
utils.querySelector(modulesEl, 'qti-interaction-module') ??
|
|
54
|
-
utils.querySelector(modulesEl, 'interactionmodule');
|
|
55
|
-
|
|
56
|
-
if (moduleEl) {
|
|
57
|
-
primaryPath =
|
|
58
|
-
utils.getAttribute(moduleEl, 'primaryPath') ||
|
|
59
|
-
utils.getAttribute(moduleEl, 'primary-path') || '';
|
|
60
|
-
const fb =
|
|
61
|
-
utils.getAttribute(moduleEl, 'fallbackPath') ||
|
|
62
|
-
utils.getAttribute(moduleEl, 'fallback-path') || '';
|
|
63
|
-
if (fb) fallbackPath = fb;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// --- Markup from <qti-interaction-markup> ---
|
|
68
|
-
const markupEl =
|
|
69
|
-
utils.querySelector(element, 'qti-interaction-markup') ??
|
|
70
|
-
utils.querySelector(element, 'interactionmarkup');
|
|
71
|
-
|
|
72
|
-
const markup = markupEl ? utils.getHtmlContent(markupEl) : '';
|
|
73
|
-
|
|
74
|
-
// --- Config from <qti-pci-properties>/<qti-pci-property> ---
|
|
75
|
-
// qti-pci-properties is NOT in the standard QTI 3.0 element mapper, so we use the
|
|
76
|
-
// native node-html-parser querySelector (available as element.querySelector on the raw element).
|
|
77
|
-
const config: Record<string, string> = {};
|
|
78
|
-
|
|
79
|
-
const rawEl = element as any;
|
|
80
|
-
const propsEl =
|
|
81
|
-
rawEl.querySelector?.('qti-pci-properties') ??
|
|
82
|
-
rawEl.querySelector?.('pciproperties');
|
|
83
|
-
|
|
84
|
-
if (propsEl) {
|
|
85
|
-
const propEls: any[] = [
|
|
86
|
-
...(propsEl.querySelectorAll?.('qti-pci-property') ?? []),
|
|
87
|
-
...(propsEl.querySelectorAll?.('pciproperty') ?? []),
|
|
88
|
-
];
|
|
89
|
-
for (const propEl of propEls) {
|
|
90
|
-
const key = propEl.getAttribute?.('key') || propEl.getAttribute?.('name') || '';
|
|
91
|
-
const value = propEl.getAttribute?.('value') || (propEl.textContent ?? '').trim() || '';
|
|
92
|
-
if (key) config[key] = value;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
responseIdentifier,
|
|
98
|
-
customInteractionTypeIdentifier,
|
|
99
|
-
primaryPath,
|
|
100
|
-
fallbackPath,
|
|
101
|
-
markup,
|
|
102
|
-
config,
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
validate(data) {
|
|
107
|
-
const errors: string[] = [];
|
|
108
|
-
const warnings: string[] = [];
|
|
109
|
-
|
|
110
|
-
if (!data.responseIdentifier) {
|
|
111
|
-
errors.push('portableCustomInteraction is missing responseIdentifier');
|
|
112
|
-
}
|
|
113
|
-
if (!data.customInteractionTypeIdentifier) {
|
|
114
|
-
warnings.push('portableCustomInteraction is missing customInteractionTypeIdentifier');
|
|
115
|
-
}
|
|
116
|
-
if (!data.primaryPath) {
|
|
117
|
-
errors.push('portableCustomInteraction has no primaryPath in qti-interaction-modules');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return { valid: errors.length === 0, errors: errors.length ? errors : undefined, warnings: warnings.length ? warnings : undefined };
|
|
121
|
-
},
|
|
122
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { CustomInteractionData } from '../shared/types.js';
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standard QTI positionObjectInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from positionObjectInteraction elements (drag objects to positions)
|
|
5
|
-
*
|
|
6
|
-
* ⚠️ IMPORTANT: QTI 2.2 positionObjectInteraction Limitations
|
|
7
|
-
*
|
|
8
|
-
* This interaction has severe limitations that make it impractical for most educational scenarios:
|
|
9
|
-
*
|
|
10
|
-
* 1. Response format is baseType="point" - only stores coordinates ["158 168"]
|
|
11
|
-
* 2. NO way to track which specific object was placed where
|
|
12
|
-
* 3. Designed ONLY for placing multiple copies of the SAME object (e.g., airport icons)
|
|
13
|
-
* 4. Cannot support "place labeled objects on map" use cases
|
|
14
|
-
*
|
|
15
|
-
* The official QTI 2.2 spec example shows:
|
|
16
|
-
* - ONE positionObjectStage (container) with background image
|
|
17
|
-
* - ONE positionObjectInteraction with ONE draggable object
|
|
18
|
-
* - maxChoices determines how many times the object can be placed
|
|
19
|
-
* - Scoring uses areaMapping to check if ANY placement hits target zones
|
|
20
|
-
*
|
|
21
|
-
* This extractor supports a NON-STANDARD extension with multiple positionObjectStage
|
|
22
|
-
* elements (each with identifiers), but the response format cannot preserve object identity.
|
|
23
|
-
* For labeled-object placement, use graphicGapMatchInteraction instead.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import type { ElementExtractor } from '../../extraction/types.js';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Image data for position object interaction
|
|
30
|
-
*/
|
|
31
|
-
export interface ImageData {
|
|
32
|
-
type: 'image' | 'svg';
|
|
33
|
-
src?: string;
|
|
34
|
-
content?: string;
|
|
35
|
-
width?: string;
|
|
36
|
-
height?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Position object data extracted from positionObjectInteraction elements
|
|
41
|
-
*/
|
|
42
|
-
export interface PositionObjectData {
|
|
43
|
-
imageData: ImageData | null;
|
|
44
|
-
positionObjectStages: Array<{
|
|
45
|
-
identifier: string;
|
|
46
|
-
label: string;
|
|
47
|
-
matchMax: number;
|
|
48
|
-
matchMin?: number;
|
|
49
|
-
objectData: ImageData | null;
|
|
50
|
-
classes?: string[];
|
|
51
|
-
}>;
|
|
52
|
-
centerPoint: boolean;
|
|
53
|
-
maxChoices: number;
|
|
54
|
-
minChoices: number;
|
|
55
|
-
prompt: string | null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Standard QTI position object interaction extractor
|
|
60
|
-
* Handles positionObjectInteraction elements (dragging an object to a position)
|
|
61
|
-
*/
|
|
62
|
-
export const standardPositionObjectExtractor: ElementExtractor<PositionObjectData> = {
|
|
63
|
-
id: 'qti:position-object-interaction',
|
|
64
|
-
name: 'QTI Standard Position Object Interaction',
|
|
65
|
-
priority: 10,
|
|
66
|
-
elementTypes: ['positionObjectInteraction'],
|
|
67
|
-
description: 'Extracts standard QTI positionObjectInteraction (drag object to position)',
|
|
68
|
-
|
|
69
|
-
canHandle(element, _context) {
|
|
70
|
-
// All positionObjectInteraction elements are standard
|
|
71
|
-
return element.rawTagName === 'positionObjectInteraction';
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
extract(element, context) {
|
|
75
|
-
const { utils } = context;
|
|
76
|
-
|
|
77
|
-
// Extract background image data from object element (direct child)
|
|
78
|
-
const objectElements = utils.getChildrenByTag(element, 'object');
|
|
79
|
-
let imageData: ImageData | null = null;
|
|
80
|
-
|
|
81
|
-
if (objectElements.length > 0) {
|
|
82
|
-
const objectElement = objectElements[0];
|
|
83
|
-
const type = utils.getAttribute(objectElement, 'type', '');
|
|
84
|
-
const data = utils.getAttribute(objectElement, 'data', '');
|
|
85
|
-
const width = utils.getAttribute(objectElement, 'width', '500');
|
|
86
|
-
const height = utils.getAttribute(objectElement, 'height', '300');
|
|
87
|
-
|
|
88
|
-
if (type.startsWith('image/svg')) {
|
|
89
|
-
// Extract inline SVG content - get full content including <svg> tag
|
|
90
|
-
const content = utils.getHtmlContent(objectElement);
|
|
91
|
-
imageData = {
|
|
92
|
-
type: 'svg',
|
|
93
|
-
content,
|
|
94
|
-
width,
|
|
95
|
-
height,
|
|
96
|
-
};
|
|
97
|
-
} else {
|
|
98
|
-
// External image reference
|
|
99
|
-
imageData = {
|
|
100
|
-
type: 'image',
|
|
101
|
-
src: data,
|
|
102
|
-
width,
|
|
103
|
-
height,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Extract positionObjectStage children
|
|
109
|
-
const stageElements = utils.getChildrenByTag(element, 'positionObjectStage');
|
|
110
|
-
const positionObjectStages = stageElements.map((stage) => {
|
|
111
|
-
const classes = utils.getClasses(stage);
|
|
112
|
-
const identifier = utils.getAttribute(stage, 'identifier', '');
|
|
113
|
-
const matchMax = utils.getNumberAttribute(stage, 'matchMax', 1);
|
|
114
|
-
const matchMin = utils.getNumberAttribute(stage, 'matchMin', 0);
|
|
115
|
-
|
|
116
|
-
// Get text content as label, use identifier as fallback
|
|
117
|
-
const textContent = utils.getTextContent(stage).trim();
|
|
118
|
-
const label = textContent || identifier;
|
|
119
|
-
|
|
120
|
-
// Extract object data from nested object element
|
|
121
|
-
const stageObjectElements = utils.getChildrenByTag(stage, 'object');
|
|
122
|
-
let objectData: ImageData | null = null;
|
|
123
|
-
|
|
124
|
-
if (stageObjectElements.length > 0) {
|
|
125
|
-
const objElement = stageObjectElements[0];
|
|
126
|
-
const objType = utils.getAttribute(objElement, 'type', '');
|
|
127
|
-
const objData = utils.getAttribute(objElement, 'data', '');
|
|
128
|
-
const objWidth = utils.getAttribute(objElement, 'width', '50');
|
|
129
|
-
const objHeight = utils.getAttribute(objElement, 'height', '50');
|
|
130
|
-
|
|
131
|
-
if (objType.startsWith('image/svg')) {
|
|
132
|
-
// Extract inline SVG content
|
|
133
|
-
const content = utils.getHtmlContent(objElement);
|
|
134
|
-
objectData = {
|
|
135
|
-
type: 'svg',
|
|
136
|
-
content,
|
|
137
|
-
width: objWidth,
|
|
138
|
-
height: objHeight,
|
|
139
|
-
};
|
|
140
|
-
} else {
|
|
141
|
-
// External image reference
|
|
142
|
-
objectData = {
|
|
143
|
-
type: 'image',
|
|
144
|
-
src: objData,
|
|
145
|
-
width: objWidth,
|
|
146
|
-
height: objHeight,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
identifier,
|
|
153
|
-
label,
|
|
154
|
-
matchMax,
|
|
155
|
-
...(matchMin > 0 ? { matchMin } : {}),
|
|
156
|
-
objectData,
|
|
157
|
-
...(classes.length > 0 ? { classes } : {}),
|
|
158
|
-
};
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Extract attributes
|
|
162
|
-
// centerPoint defaults to true when not specified
|
|
163
|
-
const centerPoint = utils.getBooleanAttribute(element, 'centerPoint', true);
|
|
164
|
-
const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 0);
|
|
165
|
-
const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
|
|
166
|
-
|
|
167
|
-
// Extract prompt (optional)
|
|
168
|
-
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
169
|
-
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
imageData,
|
|
173
|
-
positionObjectStages,
|
|
174
|
-
centerPoint,
|
|
175
|
-
maxChoices,
|
|
176
|
-
minChoices,
|
|
177
|
-
prompt,
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
validate(data) {
|
|
182
|
-
const errors: string[] = [];
|
|
183
|
-
const warnings: string[] = [];
|
|
184
|
-
|
|
185
|
-
// Validate image data
|
|
186
|
-
if (!data.imageData) {
|
|
187
|
-
warnings.push('positionObjectInteraction has no background image');
|
|
188
|
-
} else if (data.imageData.type === 'image' && !data.imageData.src) {
|
|
189
|
-
errors.push('positionObjectInteraction must have an image URL');
|
|
190
|
-
} else if (data.imageData.type === 'svg' && !data.imageData.content) {
|
|
191
|
-
errors.push('positionObjectInteraction must have SVG content');
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Warn about dimension consistency (cannot verify actual file dimensions at extraction time)
|
|
195
|
-
if (data.imageData && data.imageData.type === 'image') {
|
|
196
|
-
warnings.push(
|
|
197
|
-
'IMPORTANT: Ensure declared width/height match actual image file dimensions. ' +
|
|
198
|
-
'Mismatched dimensions cause coordinate system errors in mapResponsePoint scoring. ' +
|
|
199
|
-
`Declared: ${data.imageData.width || 'unspecified'}×${data.imageData.height || 'unspecified'}`
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Validate positionObjectStages exist
|
|
204
|
-
if (!data.positionObjectStages || data.positionObjectStages.length === 0) {
|
|
205
|
-
errors.push('positionObjectInteraction must have at least one positionObjectStage');
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Validate positionObjectStage identifiers
|
|
209
|
-
if (data.positionObjectStages) {
|
|
210
|
-
const identifiers = new Set<string>();
|
|
211
|
-
for (const stage of data.positionObjectStages) {
|
|
212
|
-
if (!stage.identifier) {
|
|
213
|
-
errors.push('All positionObjectStages must have an identifier');
|
|
214
|
-
} else if (identifiers.has(stage.identifier)) {
|
|
215
|
-
errors.push(`Duplicate positionObjectStage identifier: ${stage.identifier}`);
|
|
216
|
-
} else {
|
|
217
|
-
identifiers.add(stage.identifier);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Validate maxChoices
|
|
223
|
-
if (data.maxChoices < 0) {
|
|
224
|
-
errors.push('maxChoices must be non-negative');
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Validate minChoices
|
|
228
|
-
if (data.minChoices < 0) {
|
|
229
|
-
errors.push('minChoices must be non-negative');
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Validate minChoices <= maxChoices
|
|
233
|
-
if (data.maxChoices > 0 && data.minChoices > data.maxChoices) {
|
|
234
|
-
errors.push('minChoices cannot exceed maxChoices');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return {
|
|
238
|
-
valid: errors.length === 0,
|
|
239
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
240
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
241
|
-
};
|
|
242
|
-
},
|
|
243
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { PositionObjectInteractionData, PositionObjectStage } from '../shared/types.js';
|