@pie-qti/item-player 0.1.18 → 0.1.20
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 +137 -427
- package/dist/catalog/applyGlossaryTriggers.d.ts +2 -1
- package/dist/catalog/applyGlossaryTriggers.js +4 -2
- package/dist/catalog/applyGlossaryTriggers.js.map +1 -1
- package/dist/components/utils/stimulusRender.d.ts +1 -2
- package/dist/components/utils/stimulusRender.js +2 -5
- package/dist/components/utils/stimulusRender.js.map +1 -1
- package/dist/core/AssessmentItemDefinition.d.ts +69 -0
- package/dist/core/AssessmentItemDefinition.js +149 -0
- package/dist/core/AssessmentItemDefinition.js.map +1 -0
- package/dist/core/ComponentRegistry.d.ts +11 -5
- package/dist/core/ComponentRegistry.js +44 -17
- package/dist/core/ComponentRegistry.js.map +1 -1
- package/dist/core/ItemSession.d.ts +58 -0
- package/dist/core/ItemSession.js +286 -0
- package/dist/core/ItemSession.js.map +1 -0
- package/dist/core/Player.d.ts +9 -8
- package/dist/core/Player.js +182 -163
- package/dist/core/Player.js.map +1 -1
- package/dist/core/sanitizer.js +33 -10
- package/dist/core/sanitizer.js.map +1 -1
- package/dist/document/AssessmentItemDocument.d.ts +32 -10
- package/dist/document/AssessmentItemDocument.js +80 -23
- package/dist/document/AssessmentItemDocument.js.map +1 -1
- package/dist/{element-class-C8OTgYHE.js → element-class-CILJ4Ls7.js} +3583 -2779
- package/dist/element-class-CILJ4Ls7.js.map +1 -0
- package/dist/element-class.d.ts +17 -13
- package/dist/element-class.js +1 -1
- package/dist/element.js +1 -1
- package/dist/extraction/ExtractionRegistry.d.ts +34 -11
- package/dist/extraction/ExtractionRegistry.js +122 -19
- package/dist/extraction/ExtractionRegistry.js.map +1 -1
- package/dist/extraction/createContext.d.ts +5 -6
- package/dist/extraction/createContext.js +2 -2
- package/dist/extraction/createContext.js.map +1 -1
- package/dist/extraction/deliveryTypes.d.ts +26 -0
- package/dist/extraction/deliveryTypes.js +7 -0
- package/dist/extraction/deliveryTypes.js.map +1 -0
- package/dist/extraction/index.d.ts +3 -3
- package/dist/extraction/index.js +1 -2
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/interactionExtractionPipeline.d.ts +4 -4
- package/dist/extraction/interactionExtractionPipeline.js +27 -10
- package/dist/extraction/interactionExtractionPipeline.js.map +1 -1
- package/dist/extraction/interactionSecurity.d.ts +11 -2
- package/dist/extraction/interactionSecurity.js +105 -40
- package/dist/extraction/interactionSecurity.js.map +1 -1
- package/dist/extraction/types.d.ts +44 -7
- package/dist/extraction/types.js.map +1 -1
- package/dist/extraction/utils.js +4 -16
- package/dist/extraction/utils.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/interactions/associate/extractor.js +1 -1
- package/dist/interactions/associate/extractor.js.map +1 -1
- package/dist/interactions/drawing/extractor.js +5 -4
- package/dist/interactions/drawing/extractor.js.map +1 -1
- package/dist/interactions/end-attempt/extractor.js +2 -2
- package/dist/interactions/end-attempt/extractor.js.map +1 -1
- package/dist/interactions/gap-match/extractor.js +4 -3
- package/dist/interactions/gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-associate/extractor.js +5 -4
- package/dist/interactions/graphic-associate/extractor.js.map +1 -1
- package/dist/interactions/graphic-gap-match/extractor.js +20 -17
- package/dist/interactions/graphic-gap-match/extractor.js.map +1 -1
- package/dist/interactions/graphic-order/extractor.js +5 -4
- package/dist/interactions/graphic-order/extractor.js.map +1 -1
- package/dist/interactions/hotspot/extractor.js +11 -10
- package/dist/interactions/hotspot/extractor.js.map +1 -1
- package/dist/interactions/inline/render-plan.d.ts +3 -5
- package/dist/interactions/inline/render-plan.js.map +1 -1
- package/dist/interactions/media/extractor.js +2 -2
- package/dist/interactions/media/extractor.js.map +1 -1
- package/dist/interactions/modules.d.ts +11 -91
- package/dist/interactions/modules.js +185 -45
- package/dist/interactions/modules.js.map +1 -1
- package/dist/interactions/portable-custom/extractor.d.ts +1 -1
- package/dist/interactions/portable-custom/extractor.js +1 -1
- package/dist/interactions/portable-custom/extractor.js.map +1 -1
- package/dist/interactions/position-object/extractor.js +3 -2
- package/dist/interactions/position-object/extractor.js.map +1 -1
- package/dist/interactions/select-point/extractor.js +7 -6
- package/dist/interactions/select-point/extractor.js.map +1 -1
- package/dist/interactions/shared/types.d.ts +59 -70
- package/dist/interactions/shared/types.js.map +1 -1
- package/dist/interactions/slider/extractor.js +2 -2
- package/dist/interactions/slider/extractor.js.map +1 -1
- package/dist/interactions/upload/extractor.js +2 -2
- package/dist/interactions/upload/extractor.js.map +1 -1
- package/dist/pci/types.d.ts +2 -3
- package/dist/pci/types.js.map +1 -1
- package/dist/presentation/itemPresentationPlan.d.ts +71 -38
- package/dist/presentation/itemPresentationPlan.js +78 -34
- package/dist/presentation/itemPresentationPlan.js.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/styleValues.d.ts +20 -0
- package/dist/security/styleValues.js +49 -0
- package/dist/security/styleValues.js.map +1 -0
- package/dist/server.d.ts +188 -9
- package/dist/server.js +32 -7
- package/dist/server.js.map +1 -1
- package/dist/types/index.d.ts +1 -110
- package/dist/types/index.js.map +1 -1
- package/dist/web-components/QTIInteractionBase.d.ts +2 -2
- package/dist/web-components/QTIInteractionBase.js.map +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +3 -3
- package/dist/web-components/QTIInteractionElement.js.map +1 -1
- package/package.json +11 -11
- package/dist/core/Plugin.d.ts +0 -104
- package/dist/core/Plugin.js +0 -8
- package/dist/core/Plugin.js.map +0 -1
- package/dist/core/PluginManager.d.ts +0 -55
- package/dist/core/PluginManager.js +0 -148
- package/dist/core/PluginManager.js.map +0 -1
- package/dist/element-class-C8OTgYHE.js.map +0 -1
- package/dist/interactions/associate/index.d.ts +0 -2
- package/dist/interactions/associate/index.js +0 -2
- package/dist/interactions/associate/index.js.map +0 -1
- package/dist/interactions/associate/types.d.ts +0 -1
- package/dist/interactions/associate/types.js +0 -2
- package/dist/interactions/associate/types.js.map +0 -1
- package/dist/interactions/choice/index.d.ts +0 -2
- package/dist/interactions/choice/index.js +0 -2
- package/dist/interactions/choice/index.js.map +0 -1
- package/dist/interactions/choice/types.d.ts +0 -1
- package/dist/interactions/choice/types.js +0 -2
- package/dist/interactions/choice/types.js.map +0 -1
- package/dist/interactions/custom/index.d.ts +0 -2
- package/dist/interactions/custom/index.js +0 -2
- package/dist/interactions/custom/index.js.map +0 -1
- package/dist/interactions/custom/types.d.ts +0 -1
- package/dist/interactions/custom/types.js +0 -2
- package/dist/interactions/custom/types.js.map +0 -1
- package/dist/interactions/drawing/index.d.ts +0 -2
- package/dist/interactions/drawing/index.js +0 -2
- package/dist/interactions/drawing/index.js.map +0 -1
- package/dist/interactions/drawing/types.d.ts +0 -1
- package/dist/interactions/drawing/types.js +0 -2
- package/dist/interactions/drawing/types.js.map +0 -1
- package/dist/interactions/end-attempt/index.d.ts +0 -2
- package/dist/interactions/end-attempt/index.js +0 -2
- package/dist/interactions/end-attempt/index.js.map +0 -1
- package/dist/interactions/end-attempt/types.d.ts +0 -1
- package/dist/interactions/end-attempt/types.js +0 -2
- package/dist/interactions/end-attempt/types.js.map +0 -1
- package/dist/interactions/extended-text/index.d.ts +0 -3
- package/dist/interactions/extended-text/index.js +0 -3
- package/dist/interactions/extended-text/index.js.map +0 -1
- package/dist/interactions/extended-text/types.d.ts +0 -1
- package/dist/interactions/extended-text/types.js +0 -2
- package/dist/interactions/extended-text/types.js.map +0 -1
- package/dist/interactions/gap-match/index.d.ts +0 -2
- package/dist/interactions/gap-match/index.js +0 -2
- package/dist/interactions/gap-match/index.js.map +0 -1
- package/dist/interactions/gap-match/types.d.ts +0 -1
- package/dist/interactions/gap-match/types.js +0 -2
- package/dist/interactions/gap-match/types.js.map +0 -1
- package/dist/interactions/graphic-associate/index.d.ts +0 -2
- package/dist/interactions/graphic-associate/index.js +0 -2
- package/dist/interactions/graphic-associate/index.js.map +0 -1
- package/dist/interactions/graphic-associate/types.d.ts +0 -1
- package/dist/interactions/graphic-associate/types.js +0 -2
- package/dist/interactions/graphic-associate/types.js.map +0 -1
- package/dist/interactions/graphic-gap-match/index.d.ts +0 -2
- package/dist/interactions/graphic-gap-match/index.js +0 -2
- package/dist/interactions/graphic-gap-match/index.js.map +0 -1
- package/dist/interactions/graphic-gap-match/types.d.ts +0 -1
- package/dist/interactions/graphic-gap-match/types.js +0 -2
- package/dist/interactions/graphic-gap-match/types.js.map +0 -1
- package/dist/interactions/graphic-order/index.d.ts +0 -2
- package/dist/interactions/graphic-order/index.js +0 -2
- package/dist/interactions/graphic-order/index.js.map +0 -1
- package/dist/interactions/graphic-order/types.d.ts +0 -1
- package/dist/interactions/graphic-order/types.js +0 -2
- package/dist/interactions/graphic-order/types.js.map +0 -1
- package/dist/interactions/hotspot/index.d.ts +0 -2
- package/dist/interactions/hotspot/index.js +0 -2
- package/dist/interactions/hotspot/index.js.map +0 -1
- package/dist/interactions/hotspot/types.d.ts +0 -1
- package/dist/interactions/hotspot/types.js +0 -2
- package/dist/interactions/hotspot/types.js.map +0 -1
- package/dist/interactions/hottext/index.d.ts +0 -2
- package/dist/interactions/hottext/index.js +0 -2
- package/dist/interactions/hottext/index.js.map +0 -1
- package/dist/interactions/hottext/types.d.ts +0 -1
- package/dist/interactions/hottext/types.js +0 -2
- package/dist/interactions/hottext/types.js.map +0 -1
- package/dist/interactions/index.d.ts +0 -32
- package/dist/interactions/index.js +0 -31
- package/dist/interactions/index.js.map +0 -1
- package/dist/interactions/inline/index.d.ts +0 -1
- package/dist/interactions/inline/index.js +0 -2
- package/dist/interactions/inline/index.js.map +0 -1
- package/dist/interactions/inline-choice/index.d.ts +0 -2
- package/dist/interactions/inline-choice/index.js +0 -2
- package/dist/interactions/inline-choice/index.js.map +0 -1
- package/dist/interactions/inline-choice/types.d.ts +0 -1
- package/dist/interactions/inline-choice/types.js +0 -2
- package/dist/interactions/inline-choice/types.js.map +0 -1
- package/dist/interactions/match/index.d.ts +0 -2
- package/dist/interactions/match/index.js +0 -2
- package/dist/interactions/match/index.js.map +0 -1
- package/dist/interactions/match/types.d.ts +0 -1
- package/dist/interactions/match/types.js +0 -2
- package/dist/interactions/match/types.js.map +0 -1
- package/dist/interactions/media/index.d.ts +0 -2
- package/dist/interactions/media/index.js +0 -2
- package/dist/interactions/media/index.js.map +0 -1
- package/dist/interactions/media/types.d.ts +0 -1
- package/dist/interactions/media/types.js +0 -2
- package/dist/interactions/media/types.js.map +0 -1
- package/dist/interactions/order/index.d.ts +0 -2
- package/dist/interactions/order/index.js +0 -2
- package/dist/interactions/order/index.js.map +0 -1
- package/dist/interactions/order/types.d.ts +0 -1
- package/dist/interactions/order/types.js +0 -2
- package/dist/interactions/order/types.js.map +0 -1
- package/dist/interactions/portable-custom/index.d.ts +0 -2
- package/dist/interactions/portable-custom/index.js +0 -2
- package/dist/interactions/portable-custom/index.js.map +0 -1
- package/dist/interactions/portable-custom/types.d.ts +0 -1
- package/dist/interactions/portable-custom/types.js +0 -2
- package/dist/interactions/portable-custom/types.js.map +0 -1
- package/dist/interactions/position-object/index.d.ts +0 -2
- package/dist/interactions/position-object/index.js +0 -2
- package/dist/interactions/position-object/index.js.map +0 -1
- package/dist/interactions/position-object/types.d.ts +0 -1
- package/dist/interactions/position-object/types.js +0 -2
- package/dist/interactions/position-object/types.js.map +0 -1
- package/dist/interactions/select-point/index.d.ts +0 -2
- package/dist/interactions/select-point/index.js +0 -2
- package/dist/interactions/select-point/index.js.map +0 -1
- package/dist/interactions/select-point/types.d.ts +0 -1
- package/dist/interactions/select-point/types.js +0 -2
- package/dist/interactions/select-point/types.js.map +0 -1
- package/dist/interactions/shared/index.d.ts +0 -1
- package/dist/interactions/shared/index.js +0 -2
- package/dist/interactions/shared/index.js.map +0 -1
- package/dist/interactions/slider/index.d.ts +0 -2
- package/dist/interactions/slider/index.js +0 -2
- package/dist/interactions/slider/index.js.map +0 -1
- package/dist/interactions/slider/types.d.ts +0 -1
- package/dist/interactions/slider/types.js +0 -2
- package/dist/interactions/slider/types.js.map +0 -1
- package/dist/interactions/text-entry/index.d.ts +0 -2
- package/dist/interactions/text-entry/index.js +0 -2
- package/dist/interactions/text-entry/index.js.map +0 -1
- package/dist/interactions/text-entry/types.d.ts +0 -1
- package/dist/interactions/text-entry/types.js +0 -2
- package/dist/interactions/text-entry/types.js.map +0 -1
- package/dist/interactions/upload/index.d.ts +0 -2
- package/dist/interactions/upload/index.js +0 -2
- package/dist/interactions/upload/index.js.map +0 -1
- package/dist/interactions/upload/types.d.ts +0 -1
- package/dist/interactions/upload/types.js +0 -2
- package/dist/interactions/upload/types.js.map +0 -1
|
@@ -1,105 +1,25 @@
|
|
|
1
1
|
import type { ElementExtractor } from '../extraction/types.js';
|
|
2
|
+
import { type InteractionDeliveryField } from '../extraction/deliveryTypes.js';
|
|
2
3
|
import type { InteractionDataMap } from './shared/types.js';
|
|
3
4
|
export type StandardInteractionType = keyof InteractionDataMap;
|
|
4
5
|
export type InteractionPlacement = 'block' | 'inline';
|
|
5
6
|
export interface StandardInteractionModule {
|
|
6
7
|
type: StandardInteractionType;
|
|
7
|
-
extractor: ElementExtractor
|
|
8
|
+
extractor: ElementExtractor<any, string>;
|
|
8
9
|
placement: InteractionPlacement;
|
|
10
|
+
/** Render-sink fields owned by this InteractionModule. */
|
|
11
|
+
delivery: readonly InteractionDeliveryField[];
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly extractor: ElementExtractor<import("./index.js").TextEntryData, import("../index.js").ExtractionContext>;
|
|
17
|
-
readonly placement: "inline";
|
|
18
|
-
}, {
|
|
19
|
-
readonly type: "extendedTextInteraction";
|
|
20
|
-
readonly extractor: ElementExtractor<import("./index.js").ExtendedTextData, import("../index.js").ExtractionContext>;
|
|
21
|
-
readonly placement: "block";
|
|
22
|
-
}, {
|
|
23
|
-
readonly type: "inlineChoiceInteraction";
|
|
24
|
-
readonly extractor: ElementExtractor<import("./index.js").InlineChoiceData, import("../index.js").ExtractionContext>;
|
|
25
|
-
readonly placement: "inline";
|
|
26
|
-
}, {
|
|
27
|
-
readonly type: "orderInteraction";
|
|
28
|
-
readonly extractor: ElementExtractor<import("./index.js").OrderData, import("../index.js").ExtractionContext>;
|
|
29
|
-
readonly placement: "block";
|
|
30
|
-
}, {
|
|
31
|
-
readonly type: "matchInteraction";
|
|
32
|
-
readonly extractor: ElementExtractor<import("./index.js").MatchData, import("../index.js").ExtractionContext>;
|
|
33
|
-
readonly placement: "block";
|
|
34
|
-
}, {
|
|
35
|
-
readonly type: "associateInteraction";
|
|
36
|
-
readonly extractor: ElementExtractor<import("./index.js").AssociateData, import("../index.js").ExtractionContext>;
|
|
37
|
-
readonly placement: "block";
|
|
38
|
-
}, {
|
|
39
|
-
readonly type: "gapMatchInteraction";
|
|
40
|
-
readonly extractor: ElementExtractor<import("./index.js").GapMatchData, import("../index.js").ExtractionContext>;
|
|
41
|
-
readonly placement: "block";
|
|
42
|
-
}, {
|
|
43
|
-
readonly type: "sliderInteraction";
|
|
44
|
-
readonly extractor: ElementExtractor<import("./index.js").SliderData, import("../index.js").ExtractionContext>;
|
|
45
|
-
readonly placement: "block";
|
|
46
|
-
}, {
|
|
47
|
-
readonly type: "hotspotInteraction";
|
|
48
|
-
readonly extractor: ElementExtractor<import("./index.js").HotspotData, import("../index.js").ExtractionContext>;
|
|
49
|
-
readonly placement: "block";
|
|
50
|
-
}, {
|
|
51
|
-
readonly type: "graphicGapMatchInteraction";
|
|
52
|
-
readonly extractor: ElementExtractor<import("./index.js").GraphicGapMatchData, import("../index.js").ExtractionContext>;
|
|
53
|
-
readonly placement: "block";
|
|
54
|
-
}, {
|
|
55
|
-
readonly type: "uploadInteraction";
|
|
56
|
-
readonly extractor: ElementExtractor<import("./index.js").UploadData, import("../index.js").ExtractionContext>;
|
|
57
|
-
readonly placement: "block";
|
|
58
|
-
}, {
|
|
59
|
-
readonly type: "drawingInteraction";
|
|
60
|
-
readonly extractor: ElementExtractor<import("./index.js").DrawingData, import("../index.js").ExtractionContext>;
|
|
61
|
-
readonly placement: "block";
|
|
62
|
-
}, {
|
|
63
|
-
readonly type: "customInteraction";
|
|
64
|
-
readonly extractor: ElementExtractor<import("./index.js").CustomData, import("../index.js").ExtractionContext>;
|
|
65
|
-
readonly placement: "block";
|
|
66
|
-
}, {
|
|
67
|
-
readonly type: "portableCustomInteraction";
|
|
68
|
-
readonly extractor: ElementExtractor<import("../index.js").ExtractedPci, import("../index.js").ExtractionContext>;
|
|
69
|
-
readonly placement: "block";
|
|
70
|
-
}, {
|
|
71
|
-
readonly type: "mediaInteraction";
|
|
72
|
-
readonly extractor: ElementExtractor<import("./index.js").MediaData, import("../index.js").ExtractionContext>;
|
|
73
|
-
readonly placement: "block";
|
|
74
|
-
}, {
|
|
75
|
-
readonly type: "hottextInteraction";
|
|
76
|
-
readonly extractor: ElementExtractor<import("./index.js").HottextData, import("../index.js").ExtractionContext>;
|
|
77
|
-
readonly placement: "block";
|
|
78
|
-
}, {
|
|
79
|
-
readonly type: "selectPointInteraction";
|
|
80
|
-
readonly extractor: ElementExtractor<import("./index.js").SelectPointData, import("../index.js").ExtractionContext>;
|
|
81
|
-
readonly placement: "block";
|
|
82
|
-
}, {
|
|
83
|
-
readonly type: "graphicOrderInteraction";
|
|
84
|
-
readonly extractor: ElementExtractor<import("./index.js").GraphicOrderData, import("../index.js").ExtractionContext>;
|
|
85
|
-
readonly placement: "block";
|
|
86
|
-
}, {
|
|
87
|
-
readonly type: "graphicAssociateInteraction";
|
|
88
|
-
readonly extractor: ElementExtractor<import("./index.js").GraphicAssociateData, import("../index.js").ExtractionContext>;
|
|
89
|
-
readonly placement: "block";
|
|
90
|
-
}, {
|
|
91
|
-
readonly type: "positionObjectInteraction";
|
|
92
|
-
readonly extractor: ElementExtractor<import("./index.js").PositionObjectData, import("../index.js").ExtractionContext>;
|
|
93
|
-
readonly placement: "block";
|
|
94
|
-
}, {
|
|
95
|
-
readonly type: "endAttemptInteraction";
|
|
96
|
-
readonly extractor: ElementExtractor<import("./index.js").EndAttemptData, import("../index.js").ExtractionContext>;
|
|
97
|
-
readonly placement: "block";
|
|
98
|
-
}];
|
|
13
|
+
/**
|
|
14
|
+
* Immutable process-wide inventory. Definitions still snapshot its delivery
|
|
15
|
+
* fields into their own sealed registry, so session behavior does not depend on
|
|
16
|
+
* later access to this exported catalog.
|
|
17
|
+
*/
|
|
18
|
+
export declare const STANDARD_INTERACTION_MODULES: readonly StandardInteractionModule[];
|
|
99
19
|
export declare function getStandardInteractionModules(): readonly StandardInteractionModule[];
|
|
100
20
|
export declare function getStandardBlockInteractionModules(): readonly StandardInteractionModule[];
|
|
101
21
|
export declare function getStandardInlineInteractionModules(): readonly StandardInteractionModule[];
|
|
102
|
-
export declare function getStandardInteractionExtractors(): readonly ElementExtractor[];
|
|
22
|
+
export declare function getStandardInteractionExtractors(): readonly ElementExtractor<any, string>[];
|
|
103
23
|
export declare function getStandardInteractionElementTypes(): string[];
|
|
104
24
|
export declare function normalizeInteractionTypeFromTagName(tagName: string): string;
|
|
105
25
|
export declare function getStandardInteractionModule(type: string): StandardInteractionModule | null;
|
|
@@ -1,49 +1,180 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{ type: 'orderInteraction', extractor: standardOrderExtractor, placement: 'block' },
|
|
29
|
-
{ type: 'matchInteraction', extractor: standardMatchExtractor, placement: 'block' },
|
|
30
|
-
{ type: 'associateInteraction', extractor: standardAssociateExtractor, placement: 'block' },
|
|
31
|
-
{ type: 'gapMatchInteraction', extractor: standardGapMatchExtractor, placement: 'block' },
|
|
32
|
-
{ type: 'sliderInteraction', extractor: standardSliderExtractor, placement: 'block' },
|
|
33
|
-
{ type: 'hotspotInteraction', extractor: standardHotspotExtractor, placement: 'block' },
|
|
34
|
-
{ type: 'graphicGapMatchInteraction', extractor: standardGraphicGapMatchExtractor, placement: 'block' },
|
|
35
|
-
{ type: 'uploadInteraction', extractor: standardUploadExtractor, placement: 'block' },
|
|
36
|
-
{ type: 'drawingInteraction', extractor: standardDrawingExtractor, placement: 'block' },
|
|
37
|
-
{ type: 'customInteraction', extractor: standardCustomExtractor, placement: 'block' },
|
|
38
|
-
{ type: 'portableCustomInteraction', extractor: portableCustomExtractor, placement: 'block' },
|
|
39
|
-
{ type: 'mediaInteraction', extractor: standardMediaExtractor, placement: 'block' },
|
|
40
|
-
{ type: 'hottextInteraction', extractor: standardHottextExtractor, placement: 'block' },
|
|
41
|
-
{ type: 'selectPointInteraction', extractor: standardSelectPointExtractor, placement: 'block' },
|
|
42
|
-
{ type: 'graphicOrderInteraction', extractor: standardGraphicOrderExtractor, placement: 'block' },
|
|
43
|
-
{ type: 'graphicAssociateInteraction', extractor: standardGraphicAssociateExtractor, placement: 'block' },
|
|
44
|
-
{ type: 'positionObjectInteraction', extractor: standardPositionObjectExtractor, placement: 'block' },
|
|
45
|
-
{ type: 'endAttemptInteraction', extractor: standardEndAttemptExtractor, placement: 'block' },
|
|
1
|
+
import { htmlField, urlField, } from '../extraction/deliveryTypes.js';
|
|
2
|
+
import { standardAssociateExtractor } from './associate/extractor.js';
|
|
3
|
+
import { standardChoiceExtractor } from './choice/extractor.js';
|
|
4
|
+
import { standardCustomExtractor } from './custom/extractor.js';
|
|
5
|
+
import { standardDrawingExtractor } from './drawing/extractor.js';
|
|
6
|
+
import { standardEndAttemptExtractor } from './end-attempt/extractor.js';
|
|
7
|
+
import { standardExtendedTextExtractor } from './extended-text/extractor.js';
|
|
8
|
+
import { standardGapMatchExtractor } from './gap-match/extractor.js';
|
|
9
|
+
import { standardGraphicAssociateExtractor } from './graphic-associate/extractor.js';
|
|
10
|
+
import { standardGraphicGapMatchExtractor } from './graphic-gap-match/extractor.js';
|
|
11
|
+
import { standardGraphicOrderExtractor } from './graphic-order/extractor.js';
|
|
12
|
+
import { standardHotspotExtractor } from './hotspot/extractor.js';
|
|
13
|
+
import { standardHottextExtractor } from './hottext/extractor.js';
|
|
14
|
+
import { standardInlineChoiceExtractor } from './inline-choice/extractor.js';
|
|
15
|
+
import { standardMatchExtractor } from './match/extractor.js';
|
|
16
|
+
import { standardMediaExtractor } from './media/extractor.js';
|
|
17
|
+
import { standardOrderExtractor } from './order/extractor.js';
|
|
18
|
+
import { standardPositionObjectExtractor } from './position-object/extractor.js';
|
|
19
|
+
import { portableCustomExtractor } from './portable-custom/extractor.js';
|
|
20
|
+
import { standardSelectPointExtractor } from './select-point/extractor.js';
|
|
21
|
+
import { standardSliderExtractor } from './slider/extractor.js';
|
|
22
|
+
import { standardTextEntryExtractor } from './text-entry/extractor.js';
|
|
23
|
+
import { standardUploadExtractor } from './upload/extractor.js';
|
|
24
|
+
const prompt = htmlField('prompt');
|
|
25
|
+
const image = [
|
|
26
|
+
htmlField('imageData', 'content'),
|
|
27
|
+
urlField('img', 'imageData', 'src'),
|
|
46
28
|
];
|
|
29
|
+
const STANDARD_INTERACTION_MODULE_DEFINITIONS = [
|
|
30
|
+
{
|
|
31
|
+
type: 'choiceInteraction',
|
|
32
|
+
extractor: standardChoiceExtractor,
|
|
33
|
+
placement: 'block',
|
|
34
|
+
delivery: [prompt, htmlField('choices', '*', 'text')],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'textEntryInteraction',
|
|
38
|
+
extractor: standardTextEntryExtractor,
|
|
39
|
+
placement: 'inline',
|
|
40
|
+
delivery: [],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'extendedTextInteraction',
|
|
44
|
+
extractor: standardExtendedTextExtractor,
|
|
45
|
+
placement: 'block',
|
|
46
|
+
delivery: [prompt],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'inlineChoiceInteraction',
|
|
50
|
+
extractor: standardInlineChoiceExtractor,
|
|
51
|
+
placement: 'inline',
|
|
52
|
+
delivery: [],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'orderInteraction',
|
|
56
|
+
extractor: standardOrderExtractor,
|
|
57
|
+
placement: 'block',
|
|
58
|
+
delivery: [prompt, htmlField('choices', '*', 'text')],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'matchInteraction',
|
|
62
|
+
extractor: standardMatchExtractor,
|
|
63
|
+
placement: 'block',
|
|
64
|
+
delivery: [
|
|
65
|
+
prompt,
|
|
66
|
+
htmlField('sourceSet', '*', 'text'),
|
|
67
|
+
htmlField('targetSet', '*', 'text'),
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'associateInteraction',
|
|
72
|
+
extractor: standardAssociateExtractor,
|
|
73
|
+
placement: 'block',
|
|
74
|
+
delivery: [prompt, htmlField('choices', '*', 'text')],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'gapMatchInteraction',
|
|
78
|
+
extractor: standardGapMatchExtractor,
|
|
79
|
+
placement: 'block',
|
|
80
|
+
delivery: [prompt, htmlField('promptText')],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'sliderInteraction',
|
|
84
|
+
extractor: standardSliderExtractor,
|
|
85
|
+
placement: 'block',
|
|
86
|
+
delivery: [prompt],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'hotspotInteraction',
|
|
90
|
+
extractor: standardHotspotExtractor,
|
|
91
|
+
placement: 'block',
|
|
92
|
+
delivery: [prompt, ...image],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'graphicGapMatchInteraction',
|
|
96
|
+
extractor: standardGraphicGapMatchExtractor,
|
|
97
|
+
placement: 'block',
|
|
98
|
+
delivery: [prompt, ...image, urlField('img', 'gapImages', '*', 'src')],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'uploadInteraction',
|
|
102
|
+
extractor: standardUploadExtractor,
|
|
103
|
+
placement: 'block',
|
|
104
|
+
delivery: [prompt],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'drawingInteraction',
|
|
108
|
+
extractor: standardDrawingExtractor,
|
|
109
|
+
placement: 'block',
|
|
110
|
+
delivery: [prompt, ...image],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'customInteraction',
|
|
114
|
+
extractor: standardCustomExtractor,
|
|
115
|
+
placement: 'block',
|
|
116
|
+
delivery: [prompt],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: 'portableCustomInteraction',
|
|
120
|
+
extractor: portableCustomExtractor,
|
|
121
|
+
placement: 'block',
|
|
122
|
+
delivery: [htmlField('markup')],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: 'mediaInteraction',
|
|
126
|
+
extractor: standardMediaExtractor,
|
|
127
|
+
placement: 'block',
|
|
128
|
+
delivery: [prompt, urlField('media-or-object', 'mediaElement', 'src')],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: 'hottextInteraction',
|
|
132
|
+
extractor: standardHottextExtractor,
|
|
133
|
+
placement: 'block',
|
|
134
|
+
delivery: [prompt, htmlField('contentHtml')],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'selectPointInteraction',
|
|
138
|
+
extractor: standardSelectPointExtractor,
|
|
139
|
+
placement: 'block',
|
|
140
|
+
delivery: [prompt, ...image],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'graphicOrderInteraction',
|
|
144
|
+
extractor: standardGraphicOrderExtractor,
|
|
145
|
+
placement: 'block',
|
|
146
|
+
delivery: [prompt, ...image],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'graphicAssociateInteraction',
|
|
150
|
+
extractor: standardGraphicAssociateExtractor,
|
|
151
|
+
placement: 'block',
|
|
152
|
+
delivery: [prompt, ...image],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: 'positionObjectInteraction',
|
|
156
|
+
extractor: standardPositionObjectExtractor,
|
|
157
|
+
placement: 'block',
|
|
158
|
+
delivery: [
|
|
159
|
+
prompt,
|
|
160
|
+
...image,
|
|
161
|
+
htmlField('positionObjectStages', '*', 'objectData', 'content'),
|
|
162
|
+
urlField('img', 'positionObjectStages', '*', 'objectData', 'src'),
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
type: 'endAttemptInteraction',
|
|
167
|
+
extractor: standardEndAttemptExtractor,
|
|
168
|
+
placement: 'block',
|
|
169
|
+
delivery: [prompt],
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
/**
|
|
173
|
+
* Immutable process-wide inventory. Definitions still snapshot its delivery
|
|
174
|
+
* fields into their own sealed registry, so session behavior does not depend on
|
|
175
|
+
* later access to this exported catalog.
|
|
176
|
+
*/
|
|
177
|
+
export const STANDARD_INTERACTION_MODULES = freezeStandardInteractionModules(STANDARD_INTERACTION_MODULE_DEFINITIONS);
|
|
47
178
|
export function getStandardInteractionModules() {
|
|
48
179
|
return STANDARD_INTERACTION_MODULES;
|
|
49
180
|
}
|
|
@@ -86,4 +217,13 @@ export function isStandardBlockInteractionType(type) {
|
|
|
86
217
|
export function isStandardInlineInteractionTagName(tagName) {
|
|
87
218
|
return isStandardInlineInteractionType(normalizeInteractionTypeFromTagName(tagName));
|
|
88
219
|
}
|
|
220
|
+
function freezeStandardInteractionModules(modules) {
|
|
221
|
+
return Object.freeze(modules.map((module) => Object.freeze({
|
|
222
|
+
...module,
|
|
223
|
+
delivery: Object.freeze(module.delivery.map((field) => Object.freeze({
|
|
224
|
+
...field,
|
|
225
|
+
path: Object.freeze([...field.path]),
|
|
226
|
+
}))),
|
|
227
|
+
})));
|
|
228
|
+
}
|
|
89
229
|
//# sourceMappingURL=modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/interactions/modules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,+BAA+B,EAA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AAI,OAAO,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,IAAY;IACxD,MAAM,cAAc,GAAG,mCAAmC,CAAC,IAAI,CAAC,CAAC;IACjE,OAAO,4BAA4B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC;AAC9F,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,IAAY;IAC3D,OAAO,4BAA4B,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,QAAQ,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,IAAY;IAC1D,OAAO,4BAA4B,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,kCAAkC,CAAC,OAAe;IACjE,OAAO,+BAA+B,CAAC,mCAAmC,CAAC,OAAO,CAAC,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import type { ElementExtractor } from '../extraction/types.js';\nimport type { InteractionDataMap } from './shared/types.js';\nimport { standardAssociateExtractor } from './associate/index.js';\nimport { standardChoiceExtractor } from './choice/index.js';\nimport { standardCustomExtractor } from './custom/index.js';\nimport { standardDrawingExtractor } from './drawing/index.js';\nimport { standardEndAttemptExtractor } from './end-attempt/index.js';\nimport { standardExtendedTextExtractor } from './extended-text/index.js';\nimport { standardGapMatchExtractor } from './gap-match/index.js';\nimport { standardGraphicAssociateExtractor } from './graphic-associate/index.js';\nimport { standardGraphicGapMatchExtractor } from './graphic-gap-match/index.js';\nimport { standardGraphicOrderExtractor } from './graphic-order/index.js';\nimport { standardHotspotExtractor } from './hotspot/index.js';\nimport { standardHottextExtractor } from './hottext/index.js';\nimport { standardInlineChoiceExtractor } from './inline-choice/index.js';\nimport { standardMatchExtractor } from './match/index.js';\nimport { standardMediaExtractor } from './media/index.js';\nimport { standardOrderExtractor } from './order/index.js';\nimport { standardPositionObjectExtractor } from './position-object/index.js';\nimport { portableCustomExtractor } from './portable-custom/index.js';\nimport { standardSelectPointExtractor } from './select-point/index.js';\nimport { standardSliderExtractor } from './slider/index.js';\nimport { standardTextEntryExtractor } from './text-entry/index.js';\nimport { standardUploadExtractor } from './upload/index.js';\n\nexport type StandardInteractionType = keyof InteractionDataMap;\nexport type InteractionPlacement = 'block' | 'inline';\n\nexport interface StandardInteractionModule {\n\ttype: StandardInteractionType;\n\textractor: ElementExtractor;\n\tplacement: InteractionPlacement;\n}\n\nexport const STANDARD_INTERACTION_MODULES = [\n\t{ type: 'choiceInteraction', extractor: standardChoiceExtractor, placement: 'block' },\n\t{ type: 'textEntryInteraction', extractor: standardTextEntryExtractor, placement: 'inline' },\n\t{ type: 'extendedTextInteraction', extractor: standardExtendedTextExtractor, placement: 'block' },\n\t{ type: 'inlineChoiceInteraction', extractor: standardInlineChoiceExtractor, placement: 'inline' },\n\t{ type: 'orderInteraction', extractor: standardOrderExtractor, placement: 'block' },\n\t{ type: 'matchInteraction', extractor: standardMatchExtractor, placement: 'block' },\n\t{ type: 'associateInteraction', extractor: standardAssociateExtractor, placement: 'block' },\n\t{ type: 'gapMatchInteraction', extractor: standardGapMatchExtractor, placement: 'block' },\n\t{ type: 'sliderInteraction', extractor: standardSliderExtractor, placement: 'block' },\n\t{ type: 'hotspotInteraction', extractor: standardHotspotExtractor, placement: 'block' },\n\t{ type: 'graphicGapMatchInteraction', extractor: standardGraphicGapMatchExtractor, placement: 'block' },\n\t{ type: 'uploadInteraction', extractor: standardUploadExtractor, placement: 'block' },\n\t{ type: 'drawingInteraction', extractor: standardDrawingExtractor, placement: 'block' },\n\t{ type: 'customInteraction', extractor: standardCustomExtractor, placement: 'block' },\n\t{ type: 'portableCustomInteraction', extractor: portableCustomExtractor, placement: 'block' },\n\t{ type: 'mediaInteraction', extractor: standardMediaExtractor, placement: 'block' },\n\t{ type: 'hottextInteraction', extractor: standardHottextExtractor, placement: 'block' },\n\t{ type: 'selectPointInteraction', extractor: standardSelectPointExtractor, placement: 'block' },\n\t{ type: 'graphicOrderInteraction', extractor: standardGraphicOrderExtractor, placement: 'block' },\n\t{ type: 'graphicAssociateInteraction', extractor: standardGraphicAssociateExtractor, placement: 'block' },\n\t{ type: 'positionObjectInteraction', extractor: standardPositionObjectExtractor, placement: 'block' },\n\t{ type: 'endAttemptInteraction', extractor: standardEndAttemptExtractor, placement: 'block' },\n] as const satisfies readonly StandardInteractionModule[];\n\nexport function getStandardInteractionModules(): readonly StandardInteractionModule[] {\n\treturn STANDARD_INTERACTION_MODULES;\n}\n\nexport function getStandardBlockInteractionModules(): readonly StandardInteractionModule[] {\n\treturn STANDARD_INTERACTION_MODULES.filter((module) => module.placement === 'block');\n}\n\nexport function getStandardInlineInteractionModules(): readonly StandardInteractionModule[] {\n\treturn STANDARD_INTERACTION_MODULES.filter((module) => module.placement === 'inline');\n}\n\nexport function getStandardInteractionExtractors(): readonly ElementExtractor[] {\n\treturn STANDARD_INTERACTION_MODULES.map((module) => module.extractor);\n}\n\nexport function getStandardInteractionElementTypes(): string[] {\n\tconst elementTypes = new Set<string>();\n\tfor (const module of STANDARD_INTERACTION_MODULES) {\n\t\tfor (const elementType of module.extractor.elementTypes) {\n\t\t\telementTypes.add(elementType);\n\t\t}\n\t}\n\treturn [...elementTypes];\n}\n\nconst STANDARD_TYPE_BY_LOWERCASE = new Map(\n\tSTANDARD_INTERACTION_MODULES.map((module) => [module.type.toLowerCase(), module.type])\n);\n\nexport function normalizeInteractionTypeFromTagName(tagName: string): string {\n\tconst lowerTagName = tagName.toLowerCase();\n\tif (lowerTagName.startsWith('qti-')) {\n\t\treturn lowerTagName.slice(4).replace(/-([a-z])/g, (_match, letter: string) => letter.toUpperCase());\n\t}\n\treturn STANDARD_TYPE_BY_LOWERCASE.get(lowerTagName) ?? tagName;\n}\n\nexport function getStandardInteractionModule(type: string): StandardInteractionModule | null {\n\tconst normalizedType = normalizeInteractionTypeFromTagName(type);\n\treturn STANDARD_INTERACTION_MODULES.find((module) => module.type === normalizedType) ?? null;\n}\n\nexport function isStandardInlineInteractionType(type: string): type is 'textEntryInteraction' | 'inlineChoiceInteraction' {\n\treturn getStandardInteractionModule(type)?.placement === 'inline';\n}\n\nexport function isStandardBlockInteractionType(type: string): boolean {\n\treturn getStandardInteractionModule(type)?.placement === 'block';\n}\n\nexport function isStandardInlineInteractionTagName(tagName: string): boolean {\n\treturn isStandardInlineInteractionType(normalizeInteractionTypeFromTagName(tagName));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/interactions/modules.ts"],"names":[],"mappings":"AACA,OAAO,EACN,SAAS,EAET,QAAQ,GACR,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AA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CAAC;AAED,SAAS,gCAAgC,CACxC,OAA6C;IAE7C,OAAO,MAAM,CAAC,MAAM,CACnB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACtB,MAAM,CAAC,MAAM,CAAC;QACb,GAAG,MAAM;QACT,QAAQ,EAAE,MAAM,CAAC,MAAM,CACtB,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7B,MAAM,CAAC,MAAM,CAAC;YACb,GAAG,KAAK;YACR,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;SACpC,CAAC,CACF,CACD;KACD,CAAC,CACF,CACD,CAAC;AACH,CAAC","sourcesContent":["import type { ElementExtractor } from '../extraction/types.js';\nimport {\n\thtmlField,\n\ttype InteractionDeliveryField,\n\turlField,\n} from '../extraction/deliveryTypes.js';\nimport type { InteractionDataMap } from './shared/types.js';\nimport { standardAssociateExtractor } from './associate/extractor.js';\nimport { standardChoiceExtractor } from './choice/extractor.js';\nimport { standardCustomExtractor } from './custom/extractor.js';\nimport { standardDrawingExtractor } from './drawing/extractor.js';\nimport { standardEndAttemptExtractor } from './end-attempt/extractor.js';\nimport { standardExtendedTextExtractor } from './extended-text/extractor.js';\nimport { standardGapMatchExtractor } from './gap-match/extractor.js';\nimport { standardGraphicAssociateExtractor } from './graphic-associate/extractor.js';\nimport { standardGraphicGapMatchExtractor } from './graphic-gap-match/extractor.js';\nimport { standardGraphicOrderExtractor } from './graphic-order/extractor.js';\nimport { standardHotspotExtractor } from './hotspot/extractor.js';\nimport { standardHottextExtractor } from './hottext/extractor.js';\nimport { standardInlineChoiceExtractor } from './inline-choice/extractor.js';\nimport { standardMatchExtractor } from './match/extractor.js';\nimport { standardMediaExtractor } from './media/extractor.js';\nimport { standardOrderExtractor } from './order/extractor.js';\nimport { standardPositionObjectExtractor } from './position-object/extractor.js';\nimport { portableCustomExtractor } from './portable-custom/extractor.js';\nimport { standardSelectPointExtractor } from './select-point/extractor.js';\nimport { standardSliderExtractor } from './slider/extractor.js';\nimport { standardTextEntryExtractor } from './text-entry/extractor.js';\nimport { standardUploadExtractor } from './upload/extractor.js';\n\nexport type StandardInteractionType = keyof InteractionDataMap;\nexport type InteractionPlacement = 'block' | 'inline';\n\nexport interface StandardInteractionModule {\n\ttype: StandardInteractionType;\n\textractor: ElementExtractor<any, string>;\n\tplacement: InteractionPlacement;\n\t/** Render-sink fields owned by this InteractionModule. */\n\tdelivery: readonly InteractionDeliveryField[];\n}\n\nconst prompt = htmlField('prompt');\nconst image = [\n\thtmlField('imageData', 'content'),\n\turlField('img', 'imageData', 'src'),\n] as const;\n\nconst STANDARD_INTERACTION_MODULE_DEFINITIONS = [\n\t{\n\t\ttype: 'choiceInteraction',\n\t\textractor: standardChoiceExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, htmlField('choices', '*', 'text')],\n\t},\n\t{\n\t\ttype: 'textEntryInteraction',\n\t\textractor: standardTextEntryExtractor,\n\t\tplacement: 'inline',\n\t\tdelivery: [],\n\t},\n\t{\n\t\ttype: 'extendedTextInteraction',\n\t\textractor: standardExtendedTextExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt],\n\t},\n\t{\n\t\ttype: 'inlineChoiceInteraction',\n\t\textractor: standardInlineChoiceExtractor,\n\t\tplacement: 'inline',\n\t\tdelivery: [],\n\t},\n\t{\n\t\ttype: 'orderInteraction',\n\t\textractor: standardOrderExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, htmlField('choices', '*', 'text')],\n\t},\n\t{\n\t\ttype: 'matchInteraction',\n\t\textractor: standardMatchExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [\n\t\t\tprompt,\n\t\t\thtmlField('sourceSet', '*', 'text'),\n\t\t\thtmlField('targetSet', '*', 'text'),\n\t\t],\n\t},\n\t{\n\t\ttype: 'associateInteraction',\n\t\textractor: standardAssociateExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, htmlField('choices', '*', 'text')],\n\t},\n\t{\n\t\ttype: 'gapMatchInteraction',\n\t\textractor: standardGapMatchExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, htmlField('promptText')],\n\t},\n\t{\n\t\ttype: 'sliderInteraction',\n\t\textractor: standardSliderExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt],\n\t},\n\t{\n\t\ttype: 'hotspotInteraction',\n\t\textractor: standardHotspotExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, ...image],\n\t},\n\t{\n\t\ttype: 'graphicGapMatchInteraction',\n\t\textractor: standardGraphicGapMatchExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, ...image, urlField('img', 'gapImages', '*', 'src')],\n\t},\n\t{\n\t\ttype: 'uploadInteraction',\n\t\textractor: standardUploadExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt],\n\t},\n\t{\n\t\ttype: 'drawingInteraction',\n\t\textractor: standardDrawingExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, ...image],\n\t},\n\t{\n\t\ttype: 'customInteraction',\n\t\textractor: standardCustomExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt],\n\t},\n\t{\n\t\ttype: 'portableCustomInteraction',\n\t\textractor: portableCustomExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [htmlField('markup')],\n\t},\n\t{\n\t\ttype: 'mediaInteraction',\n\t\textractor: standardMediaExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, urlField('media-or-object', 'mediaElement', 'src')],\n\t},\n\t{\n\t\ttype: 'hottextInteraction',\n\t\textractor: standardHottextExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, htmlField('contentHtml')],\n\t},\n\t{\n\t\ttype: 'selectPointInteraction',\n\t\textractor: standardSelectPointExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, ...image],\n\t},\n\t{\n\t\ttype: 'graphicOrderInteraction',\n\t\textractor: standardGraphicOrderExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, ...image],\n\t},\n\t{\n\t\ttype: 'graphicAssociateInteraction',\n\t\textractor: standardGraphicAssociateExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt, ...image],\n\t},\n\t{\n\t\ttype: 'positionObjectInteraction',\n\t\textractor: standardPositionObjectExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [\n\t\t\tprompt,\n\t\t\t...image,\n\t\t\thtmlField('positionObjectStages', '*', 'objectData', 'content'),\n\t\t\turlField('img', 'positionObjectStages', '*', 'objectData', 'src'),\n\t\t],\n\t},\n\t{\n\t\ttype: 'endAttemptInteraction',\n\t\textractor: standardEndAttemptExtractor,\n\t\tplacement: 'block',\n\t\tdelivery: [prompt],\n\t},\n] as const satisfies readonly StandardInteractionModule[];\n\n/**\n * Immutable process-wide inventory. Definitions still snapshot its delivery\n * fields into their own sealed registry, so session behavior does not depend on\n * later access to this exported catalog.\n */\nexport const STANDARD_INTERACTION_MODULES = freezeStandardInteractionModules(\n\tSTANDARD_INTERACTION_MODULE_DEFINITIONS,\n);\n\nexport function getStandardInteractionModules(): readonly StandardInteractionModule[] {\n\treturn STANDARD_INTERACTION_MODULES;\n}\n\nexport function getStandardBlockInteractionModules(): readonly StandardInteractionModule[] {\n\treturn STANDARD_INTERACTION_MODULES.filter((module) => module.placement === 'block');\n}\n\nexport function getStandardInlineInteractionModules(): readonly StandardInteractionModule[] {\n\treturn STANDARD_INTERACTION_MODULES.filter((module) => module.placement === 'inline');\n}\n\nexport function getStandardInteractionExtractors(): readonly ElementExtractor<any, string>[] {\n\treturn STANDARD_INTERACTION_MODULES.map((module) => module.extractor);\n}\n\nexport function getStandardInteractionElementTypes(): string[] {\n\tconst elementTypes = new Set<string>();\n\tfor (const module of STANDARD_INTERACTION_MODULES) {\n\t\tfor (const elementType of module.extractor.elementTypes) {\n\t\t\telementTypes.add(elementType);\n\t\t}\n\t}\n\treturn [...elementTypes];\n}\n\nconst STANDARD_TYPE_BY_LOWERCASE = new Map(\n\tSTANDARD_INTERACTION_MODULES.map((module) => [module.type.toLowerCase(), module.type])\n);\n\nexport function normalizeInteractionTypeFromTagName(tagName: string): string {\n\tconst lowerTagName = tagName.toLowerCase();\n\tif (lowerTagName.startsWith('qti-')) {\n\t\treturn lowerTagName.slice(4).replace(/-([a-z])/g, (_match, letter: string) => letter.toUpperCase());\n\t}\n\treturn STANDARD_TYPE_BY_LOWERCASE.get(lowerTagName) ?? tagName;\n}\n\nexport function getStandardInteractionModule(type: string): StandardInteractionModule | null {\n\tconst normalizedType = normalizeInteractionTypeFromTagName(type);\n\treturn STANDARD_INTERACTION_MODULES.find((module) => module.type === normalizedType) ?? null;\n}\n\nexport function isStandardInlineInteractionType(type: string): type is 'textEntryInteraction' | 'inlineChoiceInteraction' {\n\treturn getStandardInteractionModule(type)?.placement === 'inline';\n}\n\nexport function isStandardBlockInteractionType(type: string): boolean {\n\treturn getStandardInteractionModule(type)?.placement === 'block';\n}\n\nexport function isStandardInlineInteractionTagName(tagName: string): boolean {\n\treturn isStandardInlineInteractionType(normalizeInteractionTypeFromTagName(tagName));\n}\n\nfunction freezeStandardInteractionModules(\n\tmodules: readonly StandardInteractionModule[],\n): readonly StandardInteractionModule[] {\n\treturn Object.freeze(\n\t\tmodules.map((module) =>\n\t\t\tObject.freeze({\n\t\t\t\t...module,\n\t\t\t\tdelivery: Object.freeze(\n\t\t\t\t\tmodule.delivery.map((field) =>\n\t\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\t\t...field,\n\t\t\t\t\t\t\tpath: Object.freeze([...field.path]),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t);\n}\n"]}
|
|
@@ -11,4 +11,4 @@ import type { ExtractedPci } from '../../pci/types.js';
|
|
|
11
11
|
* Priority 20 > standardCustomExtractor priority 10, so this runs first when
|
|
12
12
|
* both would match the same element.
|
|
13
13
|
*/
|
|
14
|
-
export declare const portableCustomExtractor: ElementExtractor<ExtractedPci>;
|
|
14
|
+
export declare const portableCustomExtractor: ElementExtractor<ExtractedPci, 'portableCustomInteraction'>;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
export const portableCustomExtractor = {
|
|
13
13
|
id: 'qti:portable-custom-interaction',
|
|
14
14
|
name: 'QTI Portable Custom Interaction',
|
|
15
|
+
outputType: 'portableCustomInteraction',
|
|
15
16
|
priority: 20,
|
|
16
17
|
elementTypes: [
|
|
17
18
|
'customInteraction',
|
|
@@ -88,7 +89,6 @@ export const portableCustomExtractor = {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
return {
|
|
91
|
-
type: 'portableCustomInteraction',
|
|
92
92
|
responseIdentifier,
|
|
93
93
|
customInteractionTypeIdentifier,
|
|
94
94
|
primaryPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/portable-custom/extractor.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAmC;IACtE,EAAE,EAAE,iCAAiC;IACrC,IAAI,EAAE,iCAAiC;IACvC,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE;QACb,mBAAmB;QACnB,2BAA2B;QAC3B,iCAAiC;KACjC;IACD,WAAW,EAAE,mFAAmF;IAEhG,SAAS,CAAC,OAAO,EAAE,QAAQ;QAC1B,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QAClC,OAAO,CACN,GAAG,KAAK,2BAA2B;YACnC,GAAG,KAAK,iCAAiC;YACzC,CAAC,GAAG,KAAK,mBAAmB,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC,2BAA2B,CAAC,CAAC,KAAK,IAAI,CAAC,CAChG,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAA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AAK,CAAC,OAAO,CAAC,CAAC;IACf,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import type { ElementExtractor } from '../../extraction/types.js';\nimport type { ExtractedPci } from '../../pci/types.js';\n\n/**\n * Extractor for <qti-portable-custom-interaction> (QTI 3.0) and the\n * namespaced <pci:portableCustomInteraction> payload inside a QTI 2.x\n * <customInteraction> wrapper.\n *\n * Extracts the module paths, markup, and config properties needed by PciHost\n * to load and initialize the PCI JavaScript module.\n *\n * Priority 20 > standardCustomExtractor priority 10, so this runs first when\n * both would match the same element.\n */\nexport const portableCustomExtractor: ElementExtractor<ExtractedPci> = {\n\tid: 'qti:portable-custom-interaction',\n\tname: 'QTI Portable Custom Interaction',\n\tpriority: 20,\n\telementTypes: [\n\t\t'customInteraction',\n\t\t'portableCustomInteraction',\n\t\t'qti-portable-custom-interaction',\n\t],\n\tdescription: 'Extracts QTI 2.x/3.0 portable custom interaction module paths, markup, and config',\n\n\tcanHandle(element, _context) {\n\t\tconst tag = localTagName(element);\n\t\treturn (\n\t\t\ttag === 'portablecustominteraction' ||\n\t\t\ttag === 'qti-portable-custom-interaction' ||\n\t\t\t(tag === 'custominteraction' && findDescendant(element, ['portablecustominteraction']) !== null)\n\t\t);\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\t\tconst outerTag = localTagName(element);\n\t\tconst pciElement =\n\t\t\touterTag === 'custominteraction'\n\t\t\t\t? findDescendant(element, ['portablecustominteraction'])\n\t\t\t\t: element;\n\n\t\tif (!pciElement) {\n\t\t\tthrow new Error('customInteraction does not contain a portableCustomInteraction payload');\n\t\t}\n\n\t\tconst responseIdentifier =\n\t\t\tutils.getAttribute(element, 'responseIdentifier') ||\n\t\t\tutils.getAttribute(element, 'response-identifier') ||\n\t\t\tcontext.responseId ||\n\t\t\t'';\n\n\t\tconst customInteractionTypeIdentifier =\n\t\t\tutils.getAttribute(pciElement, 'customInteractionTypeIdentifier') ||\n\t\t\tutils.getAttribute(pciElement, 'custom-interaction-type-identifier') ||\n\t\t\tutils.getAttribute(pciElement, 'customInteractionIdentifierType') ||\n\t\t\tutils.getAttribute(pciElement, 'custom-interaction-identifier-type') ||\n\t\t\t'';\n\n\t\t// --- Module paths from <qti-interaction-modules>/<qti-interaction-module> ---\n\t\t// These element names ARE in the standard QTI 3.0 element mapper so utils.querySelector works.\n\t\tlet primaryPath = '';\n\t\tlet fallbackPath: string | undefined;\n\n\t\tconst modulesEl = findDescendant(pciElement, ['interactionmodules', 'qti-interaction-modules']);\n\n\t\tif (modulesEl) {\n\t\t\tconst moduleEl = findDescendant(modulesEl, ['interactionmodule', 'qti-interaction-module']);\n\n\t\t\tif (moduleEl) {\n\t\t\t\tprimaryPath =\n\t\t\t\t\tutils.getAttribute(moduleEl, 'primaryPath') ||\n\t\t\t\t\tutils.getAttribute(moduleEl, 'primary-path') || '';\n\t\t\t\tconst fb =\n\t\t\t\t\tutils.getAttribute(moduleEl, 'fallbackPath') ||\n\t\t\t\t\tutils.getAttribute(moduleEl, 'fallback-path') || '';\n\t\t\t\tif (fb) fallbackPath = fb;\n\t\t\t}\n\t\t}\n\n\t\t// QTI 2.x PCI v1.0 embeds one or more script hooks in <pci:instance>.\n\t\t// The first external script identifies the resource a host resolver must map.\n\t\tconst instanceEl = findDescendant(pciElement, ['instance']);\n\t\tif (!primaryPath && instanceEl) {\n\t\t\tconst externalScript = findDescendants(instanceEl, ['script']).find((script) =>\n\t\t\t\tBoolean(utils.getAttribute(script, 'src'))\n\t\t\t);\n\t\t\tprimaryPath = externalScript ? utils.getAttribute(externalScript, 'src') : '';\n\t\t}\n\n\t\t// --- Markup from <qti-interaction-markup> ---\n\t\tconst markupEl = findDescendant(pciElement, ['interactionmarkup', 'qti-interaction-markup']);\n\n\t\t// sanitizeHtml removes script hooks from the QTI 2.x instance while preserving\n\t\t// the authored DOM scaffold that the resolved module initializes.\n\t\tconst markupSource = markupEl ?? instanceEl;\n\t\tconst markup = markupSource ? utils.getHtmlContent(markupSource) : '';\n\n\t\t// --- Config from <qti-pci-properties>/<qti-pci-property> ---\n\t\t// qti-pci-properties is NOT in the standard QTI 3.0 element mapper, so we use the\n\t\t// native node-html-parser querySelector (available as element.querySelector on the raw element).\n\t\tconst config: Record<string, string> = {};\n\n\t\tconst propsEl = findDescendant(pciElement, ['pciproperties', 'qti-pci-properties']);\n\n\t\tif (propsEl) {\n\t\t\tconst propEls = findDescendants(propsEl, ['pciproperty', 'qti-pci-property']);\n\t\t\tfor (const propEl of propEls) {\n\t\t\t\tconst key = utils.getAttribute(propEl, 'key') || utils.getAttribute(propEl, 'name') || '';\n\t\t\t\tconst value = utils.getAttribute(propEl, 'value') || (propEl.textContent ?? '').trim() || '';\n\t\t\t\tif (key) config[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\ttype: 'portableCustomInteraction',\n\t\t\tresponseIdentifier,\n\t\t\tcustomInteractionTypeIdentifier,\n\t\t\tprimaryPath,\n\t\t\tfallbackPath,\n\t\t\tmarkup,\n\t\t\tconfig,\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\tif (!data.responseIdentifier) {\n\t\t\terrors.push('portableCustomInteraction is missing responseIdentifier');\n\t\t}\n\t\tif (!data.customInteractionTypeIdentifier) {\n\t\t\twarnings.push('portableCustomInteraction is missing customInteractionTypeIdentifier');\n\t\t}\n\t\tif (!data.primaryPath) {\n\t\t\terrors.push('portableCustomInteraction has no primaryPath in qti-interaction-modules');\n\t\t}\n\n\t\treturn { valid: errors.length === 0, errors: errors.length ? errors : undefined, warnings: warnings.length ? warnings : undefined };\n\t},\n};\n\ntype ExtractableElement = Parameters<typeof portableCustomExtractor.canHandle>[0];\n\nfunction localTagName(element: ExtractableElement): string {\n\tconst raw = element.rawTagName?.toLowerCase() ?? '';\n\treturn raw.includes(':') ? raw.slice(raw.lastIndexOf(':') + 1) : raw;\n}\n\nfunction findDescendant(\n\telement: ExtractableElement,\n\tlocalNames: readonly string[]\n): ExtractableElement | null {\n\treturn findDescendants(element, localNames)[0] ?? null;\n}\n\nfunction findDescendants(\n\telement: ExtractableElement,\n\tlocalNames: readonly string[]\n): ExtractableElement[] {\n\tconst expected = new Set(localNames.map((name) => name.toLowerCase()));\n\tconst matches: ExtractableElement[] = [];\n\tconst visit = (parent: ExtractableElement) => {\n\t\tfor (const child of parent.childNodes ?? []) {\n\t\t\tconst candidate = child as ExtractableElement;\n\t\t\tif (!candidate.rawTagName) continue;\n\t\t\tif (expected.has(localTagName(candidate))) matches.push(candidate);\n\t\t\tvisit(candidate);\n\t\t}\n\t};\n\tvisit(element);\n\treturn matches;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/portable-custom/extractor.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAGhC;IACH,EAAE,EAAE,iCAAiC;IACrC,IAAI,EAAE,iCAAiC;IACvC,UAAU,EAAE,2BAA2B;IACvC,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE;QACb,mBAAmB;QACnB,2BAA2B;QAC3B,iCAAiC;KACjC;IACD,WAAW,EAAE,mFAAmF;IAEhG,SAAS,CAAC,OAAO,EAAE,QAAQ;QAC1B,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QAClC,OAAO,CACN,GAAG,KAAK,2BAA2B;YACnC,GAAG,KAAK,iCAAiC;YACzC,CAAC,GAAG,KAAK,mBAAmB,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC,2BAA2B,CAAC,CAAC,KAAK,IAAI,CAAC,CAChG,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1B,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,UAAU,GACf,QAAQ,KAAK,mBAAmB;Y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AAC;CACD,CAAC;AAIF,SAAS,YAAY,CAAC,OAA2B;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACpD,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACtE,CAAC;AAED,SAAS,cAAc,CACtB,OAA2B,EAC3B,UAA6B;IAE7B,OAAO,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACxD,CAAC;AAED,SAAS,eAAe,CACvB,OAA2B,EAC3B,UAA6B;IAE7B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACvE,MAAM,OAAO,GAAyB,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,CAAC,MAA0B,EAAE,EAAE;QAC5C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YAC7C,MAAM,SAAS,GAAG,KAA2B,CAAC;YAC9C,IAAI,CAAC,SAAS,CAAC,UAAU;gBAAE,SAAS;YACpC,IAAI,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACnE,KAAK,CAAC,SAAS,CAAC,CAAC;QAClB,CAAC;IACF,CAAC,CAAC;IACF,KAAK,CAAC,OAAO,CAAC,CAAC;IACf,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import type { ElementExtractor } from '../../extraction/types.js';\nimport type { ExtractedPci } from '../../pci/types.js';\n\n/**\n * Extractor for <qti-portable-custom-interaction> (QTI 3.0) and the\n * namespaced <pci:portableCustomInteraction> payload inside a QTI 2.x\n * <customInteraction> wrapper.\n *\n * Extracts the module paths, markup, and config properties needed by PciHost\n * to load and initialize the PCI JavaScript module.\n *\n * Priority 20 > standardCustomExtractor priority 10, so this runs first when\n * both would match the same element.\n */\nexport const portableCustomExtractor: ElementExtractor<\n\tExtractedPci,\n\t'portableCustomInteraction'\n> = {\n\tid: 'qti:portable-custom-interaction',\n\tname: 'QTI Portable Custom Interaction',\n\toutputType: 'portableCustomInteraction',\n\tpriority: 20,\n\telementTypes: [\n\t\t'customInteraction',\n\t\t'portableCustomInteraction',\n\t\t'qti-portable-custom-interaction',\n\t],\n\tdescription: 'Extracts QTI 2.x/3.0 portable custom interaction module paths, markup, and config',\n\n\tcanHandle(element, _context) {\n\t\tconst tag = localTagName(element);\n\t\treturn (\n\t\t\ttag === 'portablecustominteraction' ||\n\t\t\ttag === 'qti-portable-custom-interaction' ||\n\t\t\t(tag === 'custominteraction' && findDescendant(element, ['portablecustominteraction']) !== null)\n\t\t);\n\t},\n\n\textract(element, context) {\n\t\tconst { utils } = context;\n\t\tconst outerTag = localTagName(element);\n\t\tconst pciElement =\n\t\t\touterTag === 'custominteraction'\n\t\t\t\t? findDescendant(element, ['portablecustominteraction'])\n\t\t\t\t: element;\n\n\t\tif (!pciElement) {\n\t\t\tthrow new Error('customInteraction does not contain a portableCustomInteraction payload');\n\t\t}\n\n\t\tconst responseIdentifier =\n\t\t\tutils.getAttribute(element, 'responseIdentifier') ||\n\t\t\tutils.getAttribute(element, 'response-identifier') ||\n\t\t\tcontext.responseId ||\n\t\t\t'';\n\n\t\tconst customInteractionTypeIdentifier =\n\t\t\tutils.getAttribute(pciElement, 'customInteractionTypeIdentifier') ||\n\t\t\tutils.getAttribute(pciElement, 'custom-interaction-type-identifier') ||\n\t\t\tutils.getAttribute(pciElement, 'customInteractionIdentifierType') ||\n\t\t\tutils.getAttribute(pciElement, 'custom-interaction-identifier-type') ||\n\t\t\t'';\n\n\t\t// --- Module paths from <qti-interaction-modules>/<qti-interaction-module> ---\n\t\t// These element names ARE in the standard QTI 3.0 element mapper so utils.querySelector works.\n\t\tlet primaryPath = '';\n\t\tlet fallbackPath: string | undefined;\n\n\t\tconst modulesEl = findDescendant(pciElement, ['interactionmodules', 'qti-interaction-modules']);\n\n\t\tif (modulesEl) {\n\t\t\tconst moduleEl = findDescendant(modulesEl, ['interactionmodule', 'qti-interaction-module']);\n\n\t\t\tif (moduleEl) {\n\t\t\t\tprimaryPath =\n\t\t\t\t\tutils.getAttribute(moduleEl, 'primaryPath') ||\n\t\t\t\t\tutils.getAttribute(moduleEl, 'primary-path') || '';\n\t\t\t\tconst fb =\n\t\t\t\t\tutils.getAttribute(moduleEl, 'fallbackPath') ||\n\t\t\t\t\tutils.getAttribute(moduleEl, 'fallback-path') || '';\n\t\t\t\tif (fb) fallbackPath = fb;\n\t\t\t}\n\t\t}\n\n\t\t// QTI 2.x PCI v1.0 embeds one or more script hooks in <pci:instance>.\n\t\t// The first external script identifies the resource a host resolver must map.\n\t\tconst instanceEl = findDescendant(pciElement, ['instance']);\n\t\tif (!primaryPath && instanceEl) {\n\t\t\tconst externalScript = findDescendants(instanceEl, ['script']).find((script) =>\n\t\t\t\tBoolean(utils.getAttribute(script, 'src'))\n\t\t\t);\n\t\t\tprimaryPath = externalScript ? utils.getAttribute(externalScript, 'src') : '';\n\t\t}\n\n\t\t// --- Markup from <qti-interaction-markup> ---\n\t\tconst markupEl = findDescendant(pciElement, ['interactionmarkup', 'qti-interaction-markup']);\n\n\t\t// sanitizeHtml removes script hooks from the QTI 2.x instance while preserving\n\t\t// the authored DOM scaffold that the resolved module initializes.\n\t\tconst markupSource = markupEl ?? instanceEl;\n\t\tconst markup = markupSource ? utils.getHtmlContent(markupSource) : '';\n\n\t\t// --- Config from <qti-pci-properties>/<qti-pci-property> ---\n\t\t// qti-pci-properties is NOT in the standard QTI 3.0 element mapper, so we use the\n\t\t// native node-html-parser querySelector (available as element.querySelector on the raw element).\n\t\tconst config: Record<string, string> = {};\n\n\t\tconst propsEl = findDescendant(pciElement, ['pciproperties', 'qti-pci-properties']);\n\n\t\tif (propsEl) {\n\t\t\tconst propEls = findDescendants(propsEl, ['pciproperty', 'qti-pci-property']);\n\t\t\tfor (const propEl of propEls) {\n\t\t\t\tconst key = utils.getAttribute(propEl, 'key') || utils.getAttribute(propEl, 'name') || '';\n\t\t\t\tconst value = utils.getAttribute(propEl, 'value') || (propEl.textContent ?? '').trim() || '';\n\t\t\t\tif (key) config[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tresponseIdentifier,\n\t\t\tcustomInteractionTypeIdentifier,\n\t\t\tprimaryPath,\n\t\t\tfallbackPath,\n\t\t\tmarkup,\n\t\t\tconfig,\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\tif (!data.responseIdentifier) {\n\t\t\terrors.push('portableCustomInteraction is missing responseIdentifier');\n\t\t}\n\t\tif (!data.customInteractionTypeIdentifier) {\n\t\t\twarnings.push('portableCustomInteraction is missing customInteractionTypeIdentifier');\n\t\t}\n\t\tif (!data.primaryPath) {\n\t\t\terrors.push('portableCustomInteraction has no primaryPath in qti-interaction-modules');\n\t\t}\n\n\t\treturn { valid: errors.length === 0, errors: errors.length ? errors : undefined, warnings: warnings.length ? warnings : undefined };\n\t},\n};\n\ntype ExtractableElement = Parameters<typeof portableCustomExtractor.canHandle>[0];\n\nfunction localTagName(element: ExtractableElement): string {\n\tconst raw = element.rawTagName?.toLowerCase() ?? '';\n\treturn raw.includes(':') ? raw.slice(raw.lastIndexOf(':') + 1) : raw;\n}\n\nfunction findDescendant(\n\telement: ExtractableElement,\n\tlocalNames: readonly string[]\n): ExtractableElement | null {\n\treturn findDescendants(element, localNames)[0] ?? null;\n}\n\nfunction findDescendants(\n\telement: ExtractableElement,\n\tlocalNames: readonly string[]\n): ExtractableElement[] {\n\tconst expected = new Set(localNames.map((name) => name.toLowerCase()));\n\tconst matches: ExtractableElement[] = [];\n\tconst visit = (parent: ExtractableElement) => {\n\t\tfor (const child of parent.childNodes ?? []) {\n\t\t\tconst candidate = child as ExtractableElement;\n\t\t\tif (!candidate.rawTagName) continue;\n\t\t\tif (expected.has(localTagName(candidate))) matches.push(candidate);\n\t\t\tvisit(candidate);\n\t\t}\n\t};\n\tvisit(element);\n\treturn matches;\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { normalizePixelDimension } from '../../security/styleValues.js';
|
|
1
2
|
function imageDataFromObject(objectElement, utils, defaultWidth, defaultHeight) {
|
|
2
3
|
if (!objectElement)
|
|
3
4
|
return null;
|
|
4
5
|
const type = utils.getAttribute(objectElement, 'type', '');
|
|
5
6
|
const data = utils.getAttribute(objectElement, 'data', '');
|
|
6
|
-
const width = utils.getAttribute(objectElement, 'width', defaultWidth);
|
|
7
|
-
const height = utils.getAttribute(objectElement, 'height', defaultHeight);
|
|
7
|
+
const width = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''), defaultWidth);
|
|
8
|
+
const height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''), defaultHeight);
|
|
8
9
|
const content = utils.getHtmlContent(objectElement);
|
|
9
10
|
if (type.startsWith('image/svg') && /<svg[\s>]/i.test(content)) {
|
|
10
11
|
return { type: 'svg', content, width, height };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/position-object/extractor.ts"],"names":[],"mappings":"AA+
|
|
1
|
+
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../../src/interactions/position-object/extractor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AA+BxE,SAAS,mBAAmB,CAC3B,aAAqC,EACrC,KAA8E,EAC9E,YAAoB,EACpB,aAAqB;IAErB,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI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AAE,CAAC;YAC/E,MAAM,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC;YACtC,QAAQ,CAAC,IAAI,CACZ,mFAAmF;gBAClF,aAAa,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,aAAa,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,aAAa,EAAE,CAC/F,CAAC;QACH,CAAC;QAED,OAAO;YACN,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAC9C,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;SACpD,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["import type { ElementExtractor } from '../../extraction/types.js';\nimport { normalizePixelDimension } from '../../security/styleValues.js';\nimport type { QTIElement } from '../shared/types.js';\n\nexport interface ImageData {\n\ttype: 'image' | 'svg';\n\tsrc?: string;\n\tcontent?: string;\n\twidth?: string;\n\theight?: string;\n}\n\nexport interface PositionObjectData {\n\timageData: ImageData | null;\n\t/**\n\t * Compatibility shape consumed by the existing renderer. Each extracted\n\t * interaction contributes its one draggable object here; the actual QTI\n\t * positionObjectStage is the interaction's parent and supplies imageData.\n\t */\n\tpositionObjectStages: Array<{\n\t\tidentifier: string;\n\t\tlabel: string;\n\t\tmatchMax: number;\n\t\tobjectData: ImageData | null;\n\t\tclasses?: string[];\n\t}>;\n\tcenterPoint: boolean;\n\tmaxChoices: number;\n\tminChoices: number;\n\tprompt: string | null;\n}\n\nfunction imageDataFromObject(\n\tobjectElement: QTIElement | undefined,\n\tutils: Parameters<ElementExtractor<PositionObjectData>['extract']>[1]['utils'],\n\tdefaultWidth: string,\n\tdefaultHeight: string,\n): ImageData | null {\n\tif (!objectElement) return null;\n\n\tconst type = utils.getAttribute(objectElement, 'type', '');\n\tconst data = utils.getAttribute(objectElement, 'data', '');\n\tconst width = normalizePixelDimension(\n\t\tutils.getAttribute(objectElement, 'width', ''),\n\t\tdefaultWidth,\n\t);\n\tconst height = normalizePixelDimension(\n\t\tutils.getAttribute(objectElement, 'height', ''),\n\t\tdefaultHeight,\n\t);\n\tconst content = utils.getHtmlContent(objectElement);\n\n\tif (type.startsWith('image/svg') && /<svg[\\s>]/i.test(content)) {\n\t\treturn { type: 'svg', content, width, height };\n\t}\n\n\treturn { type: 'image', src: data, width, height };\n}\n\nexport const standardPositionObjectExtractor: ElementExtractor<PositionObjectData> = {\n\tid: 'qti:position-object-interaction',\n\tname: 'QTI Standard Position Object Interaction',\n\tpriority: 10,\n\telementTypes: ['positionObjectInteraction'],\n\tdescription: 'Extracts a positionObjectInteraction from its parent positionObjectStage',\n\n\tcanHandle(element) {\n\t\tconst tagName = element.rawTagName?.toLowerCase();\n\t\treturn tagName === 'positionobjectinteraction' || tagName === 'qti-position-object-interaction';\n\t},\n\n\textract(element, context) {\n\t\tconst { utils, responseId } = context;\n\t\tconst parent = element.parentNode as QTIElement | undefined;\n\t\tconst parentTagName = parent?.rawTagName?.toLowerCase();\n\t\tconst isPositionObjectStage =\n\t\t\tparentTagName === 'positionobjectstage' || parentTagName === 'qti-position-object-stage';\n\t\tconst stage = parent && isPositionObjectStage && utils.getChildrenByTag(parent, 'positionObjectInteraction').includes(element)\n\t\t\t? parent\n\t\t\t: undefined;\n\n\t\tconst backgroundObject = stage ? utils.getChildrenByTag(stage, 'object')[0] : undefined;\n\t\tconst draggableObject = utils.getChildrenByTag(element, 'object')[0];\n\t\tconst imageData = imageDataFromObject(backgroundObject, utils, '500', '300');\n\t\tconst objectData = imageDataFromObject(draggableObject, utils, '50', '50');\n\t\tconst maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);\n\t\tconst minChoices = utils.getNumberAttribute(element, 'minChoices', 0);\n\t\tconst label = utils.getTextContent(draggableObject).trim() || responseId;\n\t\tconst classes = utils.getClasses(element);\n\t\tconst prompt = utils.getPrompt(element);\n\n\t\treturn {\n\t\t\timageData,\n\t\t\tpositionObjectStages: [\n\t\t\t\t{\n\t\t\t\t\tidentifier: responseId,\n\t\t\t\t\tlabel,\n\t\t\t\t\tmatchMax: maxChoices,\n\t\t\t\t\tobjectData,\n\t\t\t\t\t...(classes.length > 0 ? { classes } : {}),\n\t\t\t\t},\n\t\t\t],\n\t\t\t// The renderer currently represents the QTI default (the object's centre)\n\t\t\t// as a boolean. Explicit centre coordinates remain a follow-up API change.\n\t\t\tcenterPoint: true,\n\t\t\tmaxChoices,\n\t\t\tminChoices,\n\t\t\tprompt,\n\t\t};\n\t},\n\n\tvalidate(data) {\n\t\tconst errors: string[] = [];\n\t\tconst warnings: string[] = [];\n\n\t\tif (!data.imageData) {\n\t\t\terrors.push('positionObjectInteraction must have a parent positionObjectStage with a background object');\n\t\t} else if (data.imageData.type === 'image' && !data.imageData.src) {\n\t\t\terrors.push('positionObjectStage background object must have a data URL');\n\t\t} else if (data.imageData.type === 'svg' && !data.imageData.content) {\n\t\t\terrors.push('positionObjectStage background object must have SVG content');\n\t\t}\n\n\t\tconst draggable = data.positionObjectStages[0];\n\t\tif (!draggable?.objectData) {\n\t\t\terrors.push('positionObjectInteraction must contain one draggable object');\n\t\t} else if (draggable.objectData.type === 'image' && !draggable.objectData.src) {\n\t\t\terrors.push('positionObjectInteraction draggable object must have a data URL');\n\t\t}\n\n\t\tif (data.maxChoices < 0) errors.push('maxChoices must be non-negative');\n\t\tif (data.minChoices < 0) errors.push('minChoices must be non-negative');\n\t\tif (data.maxChoices > 0 && data.minChoices > data.maxChoices) {\n\t\t\terrors.push('minChoices cannot exceed maxChoices');\n\t\t}\n\n\t\tif (data.imageData?.type === 'image') {\n\t\t\twarnings.push(\n\t\t\t\t'Ensure the declared positionObjectStage width/height match the image dimensions. ' +\n\t\t\t\t\t`Declared: ${data.imageData.width || 'unspecified'}×${data.imageData.height || 'unspecified'}`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: errors.length === 0,\n\t\t\terrors: errors.length > 0 ? errors : undefined,\n\t\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\t};\n\t},\n};\n"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Extracts data from selectPointInteraction elements (click point on image)
|
|
5
5
|
*/
|
|
6
|
+
import { normalizePixelDimension } from '../../security/styleValues.js';
|
|
6
7
|
/**
|
|
7
8
|
* Standard QTI select point interaction extractor
|
|
8
9
|
* Handles selectPointInteraction elements (clicking points on an image)
|
|
@@ -13,9 +14,9 @@ export const standardSelectPointExtractor = {
|
|
|
13
14
|
priority: 10,
|
|
14
15
|
elementTypes: ['selectPointInteraction'],
|
|
15
16
|
description: 'Extracts standard QTI selectPointInteraction (click point on image)',
|
|
16
|
-
canHandle(element,
|
|
17
|
+
canHandle(element, context) {
|
|
17
18
|
// All selectPointInteraction elements are standard
|
|
18
|
-
return element
|
|
19
|
+
return context.utils.matchesTag(element, 'selectPointInteraction');
|
|
19
20
|
},
|
|
20
21
|
extract(element, context) {
|
|
21
22
|
const { utils } = context;
|
|
@@ -27,8 +28,8 @@ export const standardSelectPointExtractor = {
|
|
|
27
28
|
const objectElement = objectElements[0];
|
|
28
29
|
const type = utils.getAttribute(objectElement, 'type', '');
|
|
29
30
|
const data = utils.getAttribute(objectElement, 'data', '');
|
|
30
|
-
const width = utils.getAttribute(objectElement, 'width', '500');
|
|
31
|
-
const height = utils.getAttribute(objectElement, 'height', '300');
|
|
31
|
+
const width = normalizePixelDimension(utils.getAttribute(objectElement, 'width', ''), '500');
|
|
32
|
+
const height = normalizePixelDimension(utils.getAttribute(objectElement, 'height', ''), '300');
|
|
32
33
|
if (type.startsWith('image/svg')) {
|
|
33
34
|
// Extract inline SVG content - get full content including <svg> tag
|
|
34
35
|
const content = utils.getHtmlContent(objectElement);
|
|
@@ -53,8 +54,8 @@ export const standardSelectPointExtractor = {
|
|
|
53
54
|
// Handle img element as fallback
|
|
54
55
|
const imgElement = imgElements[0];
|
|
55
56
|
const src = utils.getAttribute(imgElement, 'src', '');
|
|
56
|
-
const width = utils.getAttribute(imgElement, 'width', '500');
|
|
57
|
-
const height = utils.getAttribute(imgElement, 'height', '300');
|
|
57
|
+
const width = normalizePixelDimension(utils.getAttribute(imgElement, 'width', ''), '500');
|
|
58
|
+
const height = normalizePixelDimension(utils.getAttribute(imgElement, 'height', ''), '300');
|
|
58
59
|
imageData = {
|
|
59
60
|
type: 'image',
|
|
60
61
|
src,
|