@pie-qti/item-player 0.1.5 → 0.1.7
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/dist/catalog/applyGlossaryTriggers.d.ts +2 -1
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
- package/dist/catalog/applyGlossaryTriggers.js +145 -30
- package/dist/catalog/glossaryAction.d.ts.map +1 -1
- package/dist/catalog/glossaryAction.js +14 -4
- package/dist/components/utils/stimulusRender.d.ts +17 -0
- package/dist/components/utils/stimulusRender.d.ts.map +1 -0
- package/dist/components/utils/stimulusRender.js +70 -0
- package/dist/components/utils/stylesheetRender.d.ts +4 -0
- package/dist/components/utils/stylesheetRender.d.ts.map +1 -0
- package/dist/components/utils/stylesheetRender.js +57 -0
- package/dist/core/ComponentRegistry.d.ts +5 -4
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +11 -4
- package/dist/core/ItemRenderer.d.ts.map +1 -1
- package/dist/core/ItemRenderer.js +5 -18
- package/dist/core/Player.d.ts +39 -4
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +364 -193
- package/dist/document/AssessmentItemDocument.d.ts +42 -0
- package/dist/document/AssessmentItemDocument.d.ts.map +1 -0
- package/dist/document/AssessmentItemDocument.js +116 -0
- package/dist/element.js +3318 -2733
- package/dist/element.js.map +1 -1
- package/dist/extraction/extractors/associateExtractor.d.ts +1 -28
- package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/associateExtractor.js +1 -97
- package/dist/extraction/extractors/choiceExtractor.d.ts +1 -26
- package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/choiceExtractor.js +1 -93
- package/dist/extraction/extractors/customExtractor.d.ts +1 -19
- package/dist/extraction/extractors/customExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/customExtractor.js +1 -51
- package/dist/extraction/extractors/drawingExtractor.d.ts +1 -29
- package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/drawingExtractor.js +1 -78
- package/dist/extraction/extractors/endAttemptExtractor.d.ts +1 -19
- package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/endAttemptExtractor.js +1 -53
- package/dist/extraction/extractors/extendedTextExtractor.d.ts +1 -20
- package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/extendedTextExtractor.js +1 -63
- package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -28
- package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/gapMatchExtractor.js +1 -155
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -40
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicAssociateExtractor.js +1 -143
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +1 -52
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicGapMatchExtractor.js +1 -205
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts +1 -36
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicOrderExtractor.js +1 -121
- package/dist/extraction/extractors/hotspotExtractor.d.ts +1 -37
- package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/hotspotExtractor.js +1 -159
- package/dist/extraction/extractors/hottextExtractor.d.ts +1 -25
- package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/hottextExtractor.js +1 -128
- package/dist/extraction/extractors/index.d.ts +5 -59
- package/dist/extraction/extractors/index.d.ts.map +1 -1
- package/dist/extraction/extractors/index.js +5 -85
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +1 -24
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/inlineChoiceExtractor.js +1 -80
- package/dist/extraction/extractors/matchExtractor.d.ts +1 -36
- package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/matchExtractor.js +1 -160
- package/dist/extraction/extractors/mediaExtractor.d.ts +1 -32
- package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/mediaExtractor.js +1 -125
- package/dist/extraction/extractors/orderExtractor.d.ts +1 -27
- package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/orderExtractor.js +1 -90
- package/dist/extraction/extractors/portableCustomExtractor.d.ts +1 -13
- package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/portableCustomExtractor.js +1 -96
- package/dist/extraction/extractors/positionObjectExtractor.d.ts +1 -58
- package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/positionObjectExtractor.js +1 -191
- package/dist/extraction/extractors/selectPointExtractor.d.ts +1 -30
- package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/selectPointExtractor.js +1 -109
- package/dist/extraction/extractors/sliderExtractor.d.ts +1 -23
- package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/sliderExtractor.js +1 -73
- package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -20
- package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/textEntryExtractor.js +1 -54
- package/dist/extraction/extractors/uploadExtractor.d.ts +1 -19
- package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/uploadExtractor.js +1 -59
- package/dist/extraction/index.d.ts +1 -1
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +2 -2
- package/dist/extraction/interactionExtractionPipeline.d.ts +13 -0
- package/dist/extraction/interactionExtractionPipeline.d.ts.map +1 -0
- package/dist/extraction/interactionExtractionPipeline.js +39 -0
- package/dist/extraction/interactionSecurity.d.ts +4 -0
- package/dist/extraction/interactionSecurity.d.ts.map +1 -0
- package/dist/extraction/interactionSecurity.js +48 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/interactions/associate/extractor.d.ts +29 -0
- package/dist/interactions/associate/extractor.d.ts.map +1 -0
- package/dist/interactions/associate/extractor.js +97 -0
- package/dist/interactions/associate/index.d.ts +3 -0
- package/dist/interactions/associate/index.d.ts.map +1 -0
- package/dist/interactions/associate/index.js +1 -0
- package/dist/interactions/associate/types.d.ts +2 -0
- package/dist/interactions/associate/types.d.ts.map +1 -0
- package/dist/interactions/associate/types.js +1 -0
- package/dist/interactions/choice/extractor.d.ts +27 -0
- package/dist/interactions/choice/extractor.d.ts.map +1 -0
- package/dist/interactions/choice/extractor.js +93 -0
- package/dist/interactions/choice/index.d.ts +3 -0
- package/dist/interactions/choice/index.d.ts.map +1 -0
- package/dist/interactions/choice/index.js +1 -0
- package/dist/interactions/choice/types.d.ts +2 -0
- package/dist/interactions/choice/types.d.ts.map +1 -0
- package/dist/interactions/choice/types.js +1 -0
- package/dist/interactions/custom/extractor.d.ts +20 -0
- package/dist/interactions/custom/extractor.d.ts.map +1 -0
- package/dist/interactions/custom/extractor.js +51 -0
- package/dist/interactions/custom/index.d.ts +3 -0
- package/dist/interactions/custom/index.d.ts.map +1 -0
- package/dist/interactions/custom/index.js +1 -0
- package/dist/interactions/custom/types.d.ts +2 -0
- package/dist/interactions/custom/types.d.ts.map +1 -0
- package/dist/interactions/custom/types.js +1 -0
- package/dist/interactions/drawing/extractor.d.ts +30 -0
- package/dist/interactions/drawing/extractor.d.ts.map +1 -0
- package/dist/interactions/drawing/extractor.js +78 -0
- package/dist/interactions/drawing/index.d.ts +3 -0
- package/dist/interactions/drawing/index.d.ts.map +1 -0
- package/dist/interactions/drawing/index.js +1 -0
- package/dist/interactions/drawing/types.d.ts +2 -0
- package/dist/interactions/drawing/types.d.ts.map +1 -0
- package/dist/interactions/drawing/types.js +1 -0
- package/dist/interactions/end-attempt/extractor.d.ts +20 -0
- package/dist/interactions/end-attempt/extractor.d.ts.map +1 -0
- package/dist/interactions/end-attempt/extractor.js +53 -0
- package/dist/interactions/end-attempt/index.d.ts +3 -0
- package/dist/interactions/end-attempt/index.d.ts.map +1 -0
- package/dist/interactions/end-attempt/index.js +1 -0
- package/dist/interactions/end-attempt/types.d.ts +2 -0
- package/dist/interactions/end-attempt/types.d.ts.map +1 -0
- package/dist/interactions/end-attempt/types.js +1 -0
- package/dist/interactions/extended-text/extractor.d.ts +21 -0
- package/dist/interactions/extended-text/extractor.d.ts.map +1 -0
- package/dist/interactions/extended-text/extractor.js +63 -0
- package/dist/interactions/extended-text/index.d.ts +3 -0
- package/dist/interactions/extended-text/index.d.ts.map +1 -0
- package/dist/interactions/extended-text/index.js +1 -0
- package/dist/interactions/extended-text/types.d.ts +2 -0
- package/dist/interactions/extended-text/types.d.ts.map +1 -0
- package/dist/interactions/extended-text/types.js +1 -0
- package/dist/interactions/gap-match/extractor.d.ts +29 -0
- package/dist/interactions/gap-match/extractor.d.ts.map +1 -0
- package/dist/interactions/gap-match/extractor.js +155 -0
- package/dist/interactions/gap-match/index.d.ts +3 -0
- package/dist/interactions/gap-match/index.d.ts.map +1 -0
- package/dist/interactions/gap-match/index.js +1 -0
- package/dist/interactions/gap-match/types.d.ts +2 -0
- package/dist/interactions/gap-match/types.d.ts.map +1 -0
- package/dist/interactions/gap-match/types.js +1 -0
- package/dist/interactions/graphic-associate/extractor.d.ts +41 -0
- package/dist/interactions/graphic-associate/extractor.d.ts.map +1 -0
- package/dist/interactions/graphic-associate/extractor.js +143 -0
- package/dist/interactions/graphic-associate/index.d.ts +3 -0
- package/dist/interactions/graphic-associate/index.d.ts.map +1 -0
- package/dist/interactions/graphic-associate/index.js +1 -0
- package/dist/interactions/graphic-associate/types.d.ts +2 -0
- package/dist/interactions/graphic-associate/types.d.ts.map +1 -0
- package/dist/interactions/graphic-associate/types.js +1 -0
- package/dist/interactions/graphic-gap-match/extractor.d.ts +53 -0
- package/dist/interactions/graphic-gap-match/extractor.d.ts.map +1 -0
- package/dist/interactions/graphic-gap-match/extractor.js +205 -0
- package/dist/interactions/graphic-gap-match/index.d.ts +3 -0
- package/dist/interactions/graphic-gap-match/index.d.ts.map +1 -0
- package/dist/interactions/graphic-gap-match/index.js +1 -0
- package/dist/interactions/graphic-gap-match/types.d.ts +2 -0
- package/dist/interactions/graphic-gap-match/types.d.ts.map +1 -0
- package/dist/interactions/graphic-gap-match/types.js +1 -0
- package/dist/interactions/graphic-order/extractor.d.ts +37 -0
- package/dist/interactions/graphic-order/extractor.d.ts.map +1 -0
- package/dist/interactions/graphic-order/extractor.js +121 -0
- package/dist/interactions/graphic-order/index.d.ts +3 -0
- package/dist/interactions/graphic-order/index.d.ts.map +1 -0
- package/dist/interactions/graphic-order/index.js +1 -0
- package/dist/interactions/graphic-order/types.d.ts +2 -0
- package/dist/interactions/graphic-order/types.d.ts.map +1 -0
- package/dist/interactions/graphic-order/types.js +1 -0
- package/dist/interactions/hotspot/extractor.d.ts +38 -0
- package/dist/interactions/hotspot/extractor.d.ts.map +1 -0
- package/dist/interactions/hotspot/extractor.js +159 -0
- package/dist/interactions/hotspot/index.d.ts +3 -0
- package/dist/interactions/hotspot/index.d.ts.map +1 -0
- package/dist/interactions/hotspot/index.js +1 -0
- package/dist/interactions/hotspot/types.d.ts +2 -0
- package/dist/interactions/hotspot/types.d.ts.map +1 -0
- package/dist/interactions/hotspot/types.js +1 -0
- package/dist/interactions/hottext/extractor.d.ts +26 -0
- package/dist/interactions/hottext/extractor.d.ts.map +1 -0
- package/dist/interactions/hottext/extractor.js +128 -0
- package/dist/interactions/hottext/index.d.ts +3 -0
- package/dist/interactions/hottext/index.d.ts.map +1 -0
- package/dist/interactions/hottext/index.js +1 -0
- package/dist/interactions/hottext/types.d.ts +2 -0
- package/dist/interactions/hottext/types.d.ts.map +1 -0
- package/dist/interactions/hottext/types.js +1 -0
- package/dist/interactions/index.d.ts +33 -0
- package/dist/interactions/index.d.ts.map +1 -0
- package/dist/interactions/index.js +30 -0
- package/dist/interactions/inline/index.d.ts +2 -0
- package/dist/interactions/inline/index.d.ts.map +1 -0
- package/dist/interactions/inline/index.js +1 -0
- package/dist/interactions/inline/render-plan.d.ts +19 -0
- package/dist/interactions/inline/render-plan.d.ts.map +1 -0
- package/dist/interactions/inline/render-plan.js +59 -0
- package/dist/interactions/inline-choice/extractor.d.ts +25 -0
- package/dist/interactions/inline-choice/extractor.d.ts.map +1 -0
- package/dist/interactions/inline-choice/extractor.js +80 -0
- package/dist/interactions/inline-choice/index.d.ts +3 -0
- package/dist/interactions/inline-choice/index.d.ts.map +1 -0
- package/dist/interactions/inline-choice/index.js +1 -0
- package/dist/interactions/inline-choice/types.d.ts +2 -0
- package/dist/interactions/inline-choice/types.d.ts.map +1 -0
- package/dist/interactions/inline-choice/types.js +1 -0
- package/dist/interactions/match/extractor.d.ts +37 -0
- package/dist/interactions/match/extractor.d.ts.map +1 -0
- package/dist/interactions/match/extractor.js +160 -0
- package/dist/interactions/match/index.d.ts +3 -0
- package/dist/interactions/match/index.d.ts.map +1 -0
- package/dist/interactions/match/index.js +1 -0
- package/dist/interactions/match/types.d.ts +2 -0
- package/dist/interactions/match/types.d.ts.map +1 -0
- package/dist/interactions/match/types.js +1 -0
- package/dist/interactions/media/extractor.d.ts +33 -0
- package/dist/interactions/media/extractor.d.ts.map +1 -0
- package/dist/interactions/media/extractor.js +125 -0
- package/dist/interactions/media/index.d.ts +3 -0
- package/dist/interactions/media/index.d.ts.map +1 -0
- package/dist/interactions/media/index.js +1 -0
- package/dist/interactions/media/types.d.ts +2 -0
- package/dist/interactions/media/types.d.ts.map +1 -0
- package/dist/interactions/media/types.js +1 -0
- package/dist/interactions/modules.d.ts +105 -0
- package/dist/interactions/modules.d.ts.map +1 -0
- package/dist/interactions/modules.js +86 -0
- package/dist/interactions/order/extractor.d.ts +28 -0
- package/dist/interactions/order/extractor.d.ts.map +1 -0
- package/dist/interactions/order/extractor.js +90 -0
- package/dist/interactions/order/index.d.ts +3 -0
- package/dist/interactions/order/index.d.ts.map +1 -0
- package/dist/interactions/order/index.js +1 -0
- package/dist/interactions/order/types.d.ts +2 -0
- package/dist/interactions/order/types.d.ts.map +1 -0
- package/dist/interactions/order/types.js +1 -0
- package/dist/interactions/portable-custom/extractor.d.ts +14 -0
- package/dist/interactions/portable-custom/extractor.d.ts.map +1 -0
- package/dist/interactions/portable-custom/extractor.js +96 -0
- package/dist/interactions/portable-custom/index.d.ts +3 -0
- package/dist/interactions/portable-custom/index.d.ts.map +1 -0
- package/dist/interactions/portable-custom/index.js +1 -0
- package/dist/interactions/portable-custom/types.d.ts +2 -0
- package/dist/interactions/portable-custom/types.d.ts.map +1 -0
- package/dist/interactions/portable-custom/types.js +1 -0
- package/dist/interactions/position-object/extractor.d.ts +59 -0
- package/dist/interactions/position-object/extractor.d.ts.map +1 -0
- package/dist/interactions/position-object/extractor.js +191 -0
- package/dist/interactions/position-object/index.d.ts +3 -0
- package/dist/interactions/position-object/index.d.ts.map +1 -0
- package/dist/interactions/position-object/index.js +1 -0
- package/dist/interactions/position-object/types.d.ts +2 -0
- package/dist/interactions/position-object/types.d.ts.map +1 -0
- package/dist/interactions/position-object/types.js +1 -0
- package/dist/interactions/select-point/extractor.d.ts +31 -0
- package/dist/interactions/select-point/extractor.d.ts.map +1 -0
- package/dist/interactions/select-point/extractor.js +109 -0
- package/dist/interactions/select-point/index.d.ts +3 -0
- package/dist/interactions/select-point/index.d.ts.map +1 -0
- package/dist/interactions/select-point/index.js +1 -0
- package/dist/interactions/select-point/types.d.ts +2 -0
- package/dist/interactions/select-point/types.d.ts.map +1 -0
- package/dist/interactions/select-point/types.js +1 -0
- package/dist/interactions/shared/index.d.ts +2 -0
- package/dist/interactions/shared/index.d.ts.map +1 -0
- package/dist/interactions/shared/index.js +1 -0
- package/dist/interactions/shared/types.d.ts +412 -0
- package/dist/interactions/shared/types.d.ts.map +1 -0
- package/dist/interactions/shared/types.js +7 -0
- package/dist/interactions/slider/extractor.d.ts +24 -0
- package/dist/interactions/slider/extractor.d.ts.map +1 -0
- package/dist/interactions/slider/extractor.js +73 -0
- package/dist/interactions/slider/index.d.ts +3 -0
- package/dist/interactions/slider/index.d.ts.map +1 -0
- package/dist/interactions/slider/index.js +1 -0
- package/dist/interactions/slider/types.d.ts +2 -0
- package/dist/interactions/slider/types.d.ts.map +1 -0
- package/dist/interactions/slider/types.js +1 -0
- package/dist/interactions/text-entry/extractor.d.ts +21 -0
- package/dist/interactions/text-entry/extractor.d.ts.map +1 -0
- package/dist/interactions/text-entry/extractor.js +54 -0
- package/dist/interactions/text-entry/index.d.ts +3 -0
- package/dist/interactions/text-entry/index.d.ts.map +1 -0
- package/dist/interactions/text-entry/index.js +1 -0
- package/dist/interactions/text-entry/types.d.ts +2 -0
- package/dist/interactions/text-entry/types.d.ts.map +1 -0
- package/dist/interactions/text-entry/types.js +1 -0
- package/dist/interactions/upload/extractor.d.ts +20 -0
- package/dist/interactions/upload/extractor.d.ts.map +1 -0
- package/dist/interactions/upload/extractor.js +59 -0
- package/dist/interactions/upload/index.d.ts +3 -0
- package/dist/interactions/upload/index.d.ts.map +1 -0
- package/dist/interactions/upload/index.js +1 -0
- package/dist/interactions/upload/types.d.ts +2 -0
- package/dist/interactions/upload/types.d.ts.map +1 -0
- package/dist/interactions/upload/types.js +1 -0
- package/dist/pnp/applyPnp.d.ts.map +1 -1
- package/dist/pnp/applyPnp.js +9 -2
- package/dist/pnp/parsePnpXml.d.ts.map +1 -1
- package/dist/pnp/parsePnpXml.js +91 -3
- package/dist/pnp/types.d.ts +24 -1
- package/dist/pnp/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +47 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interactions.d.ts +4 -408
- package/dist/types/interactions.d.ts.map +1 -1
- package/dist/types/interactions.js +3 -3
- package/dist/web-components/QTIInteractionBase.d.ts +5 -5
- package/dist/web-components/QTIInteractionBase.d.ts.map +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +11 -8
- package/dist/web-components/QTIInteractionElement.d.ts.map +1 -1
- package/dist/web-components/index.d.ts +1 -1
- package/dist/web-components/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/catalog/applyGlossaryTriggers.ts +174 -34
- package/src/catalog/glossaryAction.ts +14 -4
- package/src/components/ItemBody.svelte +71 -200
- package/src/components/ItemPlayer.svelte +9 -5
- package/src/components/ModalFeedbackDisplay.svelte +15 -5
- package/src/components/utils/stimulusRender.ts +93 -0
- package/src/components/utils/stylesheetRender.ts +58 -0
- package/src/core/ComponentRegistry.ts +22 -7
- package/src/core/Player.ts +401 -209
- package/src/document/AssessmentItemDocument.ts +178 -0
- package/src/extraction/extractors/associateExtractor.ts +1 -133
- package/src/extraction/extractors/choiceExtractor.ts +1 -121
- package/src/extraction/extractors/customExtractor.ts +1 -72
- package/src/extraction/extractors/drawingExtractor.ts +1 -113
- package/src/extraction/extractors/endAttemptExtractor.ts +1 -74
- package/src/extraction/extractors/extendedTextExtractor.ts +1 -89
- package/src/extraction/extractors/gapMatchExtractor.ts +1 -193
- package/src/extraction/extractors/graphicAssociateExtractor.ts +1 -192
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +1 -257
- package/src/extraction/extractors/graphicOrderExtractor.ts +1 -162
- package/src/extraction/extractors/hotspotExtractor.ts +1 -208
- package/src/extraction/extractors/hottextExtractor.ts +1 -163
- package/src/extraction/extractors/index.ts +5 -111
- package/src/extraction/extractors/inlineChoiceExtractor.ts +1 -105
- package/src/extraction/extractors/matchExtractor.ts +1 -187
- package/src/extraction/extractors/mediaExtractor.ts +1 -168
- package/src/extraction/extractors/orderExtractor.ts +1 -120
- package/src/extraction/extractors/portableCustomExtractor.ts +1 -122
- package/src/extraction/extractors/positionObjectExtractor.ts +1 -243
- package/src/extraction/extractors/selectPointExtractor.ts +1 -143
- package/src/extraction/extractors/sliderExtractor.ts +1 -102
- package/src/extraction/extractors/textEntryExtractor.ts +1 -79
- package/src/extraction/extractors/uploadExtractor.ts +1 -81
- package/src/extraction/index.ts +1 -2
- package/src/extraction/interactionExtractionPipeline.ts +70 -0
- package/src/extraction/interactionSecurity.ts +60 -0
- package/src/index.ts +3 -7
- package/src/interactions/associate/extractor.ts +133 -0
- package/src/interactions/associate/index.ts +2 -0
- package/src/interactions/associate/types.ts +1 -0
- package/src/interactions/choice/extractor.ts +121 -0
- package/src/interactions/choice/index.ts +2 -0
- package/src/interactions/choice/types.ts +1 -0
- package/src/interactions/custom/extractor.ts +72 -0
- package/src/interactions/custom/index.ts +2 -0
- package/src/interactions/custom/types.ts +1 -0
- package/src/interactions/drawing/extractor.ts +113 -0
- package/src/interactions/drawing/index.ts +2 -0
- package/src/interactions/drawing/types.ts +1 -0
- package/src/interactions/end-attempt/extractor.ts +74 -0
- package/src/interactions/end-attempt/index.ts +2 -0
- package/src/interactions/end-attempt/types.ts +1 -0
- package/src/interactions/extended-text/extractor.ts +89 -0
- package/src/interactions/extended-text/index.ts +2 -0
- package/src/interactions/extended-text/types.ts +1 -0
- package/src/interactions/gap-match/extractor.ts +193 -0
- package/src/interactions/gap-match/index.ts +2 -0
- package/src/interactions/gap-match/types.ts +1 -0
- package/src/interactions/graphic-associate/extractor.ts +192 -0
- package/src/interactions/graphic-associate/index.ts +2 -0
- package/src/interactions/graphic-associate/types.ts +1 -0
- package/src/interactions/graphic-gap-match/extractor.ts +257 -0
- package/src/interactions/graphic-gap-match/index.ts +2 -0
- package/src/interactions/graphic-gap-match/types.ts +1 -0
- package/src/interactions/graphic-order/extractor.ts +162 -0
- package/src/interactions/graphic-order/index.ts +2 -0
- package/src/interactions/graphic-order/types.ts +1 -0
- package/src/interactions/hotspot/extractor.ts +208 -0
- package/src/interactions/hotspot/index.ts +2 -0
- package/src/interactions/hotspot/types.ts +1 -0
- package/src/interactions/hottext/extractor.ts +163 -0
- package/src/interactions/hottext/index.ts +2 -0
- package/src/interactions/hottext/types.ts +1 -0
- package/src/interactions/index.ts +52 -0
- package/src/interactions/inline/index.ts +1 -0
- package/src/interactions/inline/render-plan.ts +105 -0
- package/src/interactions/inline-choice/InlineChoice.svelte +57 -0
- package/src/interactions/inline-choice/extractor.ts +105 -0
- package/src/interactions/inline-choice/index.ts +2 -0
- package/src/interactions/inline-choice/types.ts +1 -0
- package/src/interactions/match/extractor.ts +187 -0
- package/src/interactions/match/index.ts +2 -0
- package/src/interactions/match/types.ts +1 -0
- package/src/interactions/media/extractor.ts +168 -0
- package/src/interactions/media/index.ts +2 -0
- package/src/interactions/media/types.ts +1 -0
- package/src/interactions/modules.ts +111 -0
- package/src/interactions/order/extractor.ts +120 -0
- package/src/interactions/order/index.ts +2 -0
- package/src/interactions/order/types.ts +1 -0
- package/src/interactions/portable-custom/extractor.ts +122 -0
- package/src/interactions/portable-custom/index.ts +2 -0
- package/src/interactions/portable-custom/types.ts +1 -0
- package/src/interactions/position-object/extractor.ts +243 -0
- package/src/interactions/position-object/index.ts +2 -0
- package/src/interactions/position-object/types.ts +1 -0
- package/src/interactions/select-point/extractor.ts +143 -0
- package/src/interactions/select-point/index.ts +2 -0
- package/src/interactions/select-point/types.ts +1 -0
- package/src/interactions/shared/index.ts +1 -0
- package/src/interactions/shared/types.ts +429 -0
- package/src/interactions/slider/extractor.ts +102 -0
- package/src/interactions/slider/index.ts +2 -0
- package/src/interactions/slider/types.ts +1 -0
- package/src/interactions/text-entry/InlineTextEntry.svelte +75 -0
- package/src/interactions/text-entry/extractor.ts +79 -0
- package/src/interactions/text-entry/index.ts +2 -0
- package/src/interactions/text-entry/types.ts +1 -0
- package/src/interactions/upload/extractor.ts +81 -0
- package/src/interactions/upload/index.ts +2 -0
- package/src/interactions/upload/types.ts +1 -0
- package/src/pnp/applyPnp.ts +8 -2
- package/src/pnp/parsePnpXml.ts +102 -5
- package/src/pnp/types.ts +43 -1
- package/src/types/index.ts +53 -0
- package/src/types/interactions.ts +4 -425
- package/src/web-components/QTIInteractionBase.ts +6 -5
- package/src/web-components/QTIInteractionElement.ts +15 -8
- package/src/web-components/index.ts +1 -0
- package/src/__tests__/glossaryTriggers.test.ts +0 -411
- package/src/__tests__/pnp.test.ts +0 -250
- package/src/core/ItemRenderer.ts +0 -371
|
@@ -1,89 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI extendedTextInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from extendedTextInteraction elements (multi-line text input)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Extended text data extracted from extendedTextInteraction elements
|
|
11
|
-
*/
|
|
12
|
-
export interface ExtendedTextData {
|
|
13
|
-
expectedLines: number;
|
|
14
|
-
expectedLength: number;
|
|
15
|
-
placeholderText: string;
|
|
16
|
-
format: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Standard QTI extended text interaction extractor
|
|
21
|
-
* Handles extendedTextInteraction elements (multi-line text input)
|
|
22
|
-
*/
|
|
23
|
-
export const standardExtendedTextExtractor: ElementExtractor<ExtendedTextData> = {
|
|
24
|
-
id: 'qti:extended-text-interaction',
|
|
25
|
-
name: 'QTI Standard Extended Text Interaction',
|
|
26
|
-
priority: 10,
|
|
27
|
-
elementTypes: ['extendedTextInteraction'],
|
|
28
|
-
description: 'Extracts standard QTI extendedTextInteraction (multi-line text input)',
|
|
29
|
-
|
|
30
|
-
canHandle(element, _context) {
|
|
31
|
-
// All extendedTextInteraction elements are standard (both QTI 2.x and 3.0)
|
|
32
|
-
return (
|
|
33
|
-
element.rawTagName === 'extendedTextInteraction' ||
|
|
34
|
-
element.rawTagName === 'qti-extended-text-interaction'
|
|
35
|
-
);
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
extract(element, context) {
|
|
39
|
-
const { utils } = context;
|
|
40
|
-
|
|
41
|
-
// Extract attributes
|
|
42
|
-
const expectedLines = utils.getNumberAttribute(element, 'expectedLines', 3);
|
|
43
|
-
const expectedLength = utils.getNumberAttribute(element, 'expectedLength', 200);
|
|
44
|
-
const placeholderText = utils.getAttribute(element, 'placeholderText', '');
|
|
45
|
-
const format = utils.getAttribute(element, 'format', 'plain');
|
|
46
|
-
const patternMask = utils.getAttribute(element, 'patternMask', '') || null;
|
|
47
|
-
const patternMaskMessage = utils.getAttribute(element, 'patternMaskMessage', '') || null;
|
|
48
|
-
const interactionClasses = utils.getClasses(element);
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
expectedLines,
|
|
52
|
-
expectedLength,
|
|
53
|
-
placeholderText,
|
|
54
|
-
format,
|
|
55
|
-
...(patternMask ? { patternMask } : {}),
|
|
56
|
-
...(patternMaskMessage ? { patternMaskMessage } : {}),
|
|
57
|
-
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
validate(data) {
|
|
62
|
-
const errors: string[] = [];
|
|
63
|
-
const warnings: string[] = [];
|
|
64
|
-
|
|
65
|
-
// Validate expectedLines
|
|
66
|
-
if (data.expectedLines < 1) {
|
|
67
|
-
errors.push('expectedLines must be at least 1');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Validate expectedLength
|
|
71
|
-
if (data.expectedLength < 1) {
|
|
72
|
-
errors.push('expectedLength must be positive');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Validate format
|
|
76
|
-
const validFormats = ['plain', 'preFormatted', 'xhtml'];
|
|
77
|
-
if (!validFormats.includes(data.format)) {
|
|
78
|
-
warnings.push(
|
|
79
|
-
`Unrecognized format "${data.format}" - expected plain, preFormatted, or xhtml`
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
valid: errors.length === 0,
|
|
85
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
86
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
|
-
};
|
|
1
|
+
export * from '../../interactions/extended-text/extractor.js';
|
|
@@ -1,193 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI gapMatchInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from gapMatchInteraction elements (drag words into gaps)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Gap match data extracted from gapMatchInteraction elements
|
|
11
|
-
*/
|
|
12
|
-
export interface GapMatchData {
|
|
13
|
-
gapTexts: Array<{
|
|
14
|
-
identifier: string;
|
|
15
|
-
text: string;
|
|
16
|
-
matchMax: number;
|
|
17
|
-
matchMin?: number;
|
|
18
|
-
matchGroup?: string[];
|
|
19
|
-
classes?: string[];
|
|
20
|
-
}>;
|
|
21
|
-
gaps: string[];
|
|
22
|
-
shuffle: boolean;
|
|
23
|
-
prompt: string | null;
|
|
24
|
-
promptText: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Standard QTI gap match interaction extractor
|
|
29
|
-
* Handles gapMatchInteraction elements (drag words into gaps in text)
|
|
30
|
-
*/
|
|
31
|
-
export const standardGapMatchExtractor: ElementExtractor<GapMatchData> = {
|
|
32
|
-
id: 'qti:gap-match-interaction',
|
|
33
|
-
name: 'QTI Standard Gap Match Interaction',
|
|
34
|
-
priority: 10,
|
|
35
|
-
elementTypes: ['gapMatchInteraction'],
|
|
36
|
-
description: 'Extracts standard QTI gapMatchInteraction (drag words into gaps)',
|
|
37
|
-
|
|
38
|
-
canHandle(element, _context) {
|
|
39
|
-
// All gapMatchInteraction elements are standard
|
|
40
|
-
return element.rawTagName === 'gapMatchInteraction';
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
extract(element, context) {
|
|
44
|
-
const { utils } = context;
|
|
45
|
-
|
|
46
|
-
// Extract gapText children (draggable items)
|
|
47
|
-
const gapTextElements = utils.getChildrenByTag(element, 'gapText');
|
|
48
|
-
const gapTexts = gapTextElements.map((gapText) => {
|
|
49
|
-
const classes = utils.getClasses(gapText);
|
|
50
|
-
const matchMax = utils.getNumberAttribute(gapText, 'matchMax', 1);
|
|
51
|
-
const matchMin = utils.getNumberAttribute(gapText, 'matchMin', 0);
|
|
52
|
-
const matchGroupRaw = utils.getAttribute(gapText, 'matchGroup', '');
|
|
53
|
-
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
identifier: utils.getAttribute(gapText, 'identifier', ''),
|
|
57
|
-
text: utils.getTextContent(gapText),
|
|
58
|
-
matchMax,
|
|
59
|
-
...(matchMin > 0 ? { matchMin } : {}),
|
|
60
|
-
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
61
|
-
...(classes.length > 0 ? { classes } : {}),
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Extract prompt (optional) and process gap placeholders.
|
|
66
|
-
// NOTE: Many QTI items place `<gap>` elements in the interaction content (e.g. a `<p>`/`<blockquote>`)
|
|
67
|
-
// rather than inside a `<prompt>` element. Support both patterns.
|
|
68
|
-
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
69
|
-
let prompt: string | null = null;
|
|
70
|
-
let promptText = '';
|
|
71
|
-
const gaps: string[] = [];
|
|
72
|
-
|
|
73
|
-
if (promptElements.length > 0) {
|
|
74
|
-
const promptElement = promptElements[0];
|
|
75
|
-
prompt = utils.getHtmlContent(promptElement);
|
|
76
|
-
|
|
77
|
-
// Get the raw HTML content and extract gaps
|
|
78
|
-
const promptHtml = promptElement.outerHTML || promptElement.toString();
|
|
79
|
-
|
|
80
|
-
// Extract gap elements from prompt children
|
|
81
|
-
const gapElements = utils.getChildrenByTag(promptElement, 'gap');
|
|
82
|
-
for (const gap of gapElements) {
|
|
83
|
-
gaps.push(utils.getAttribute(gap, 'identifier', ''));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Replace gap elements with placeholders in the text
|
|
87
|
-
promptText = promptHtml
|
|
88
|
-
.replace(/<qti-prompt[^>]*>|<prompt[^>]*>/, '')
|
|
89
|
-
.replace(/<\/qti-prompt>|<\/prompt>/, '')
|
|
90
|
-
.replace(/<(?:qti-)?gap\s+identifier="([^"]+)"[^>]*>/g, '[GAP:$1]')
|
|
91
|
-
.replace(/<(?:qti-)?gap\s+identifier='([^']+)'[^>]*>/g, '[GAP:$1]')
|
|
92
|
-
.replace(/<\/(?:qti-)?gap>/g, '')
|
|
93
|
-
.trim();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// If gaps were not found inside a <prompt>, search the full interaction body.
|
|
97
|
-
// This handles items where <gap> elements appear in <p>/<blockquote> siblings of <prompt>.
|
|
98
|
-
if (gaps.length === 0) {
|
|
99
|
-
const interactionHtml = element.outerHTML || element.toString();
|
|
100
|
-
const gapIdMatches = Array.from(
|
|
101
|
-
interactionHtml.matchAll(/<(?:qti-)?gap\s+identifier=(?:"([^"]+)"|'([^']+)')[^>]*\/?>/gi)
|
|
102
|
-
);
|
|
103
|
-
for (const m of gapIdMatches) {
|
|
104
|
-
const id = (m[1] || m[2] || '').trim();
|
|
105
|
-
if (id) gaps.push(id);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (!promptText) {
|
|
109
|
-
// No prompt element either: build promptText from full interaction content.
|
|
110
|
-
const interactionHtml2 = element.outerHTML || element.toString();
|
|
111
|
-
promptText = interactionHtml2
|
|
112
|
-
.replace(/<(?:qti-)?gap-match-interaction[^>]*>|<gapMatchInteraction[^>]*>/, '')
|
|
113
|
-
.replace(/<\/(?:qti-)?gap-match-interaction>|<\/gapMatchInteraction>/, '')
|
|
114
|
-
.replace(/<(?:qti-)?gap-text[\s\S]*?<\/(?:qti-)?gap-text>|<gapText[\s\S]*?<\/gapText>/g, '')
|
|
115
|
-
.replace(/<(?:qti-)?gap\s+identifier="([^"]+)"[^>]*\/?>/g, '[GAP:$1]')
|
|
116
|
-
.replace(/<(?:qti-)?gap\s+identifier='([^']+)'[^>]*\/?>/g, '[GAP:$1]')
|
|
117
|
-
.replace(/<\/(?:qti-)?gap>/g, '')
|
|
118
|
-
.trim();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Extract attributes
|
|
123
|
-
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
124
|
-
const interactionClasses = utils.getClasses(element);
|
|
125
|
-
const choicesContainerWidth = utils.getAttribute(element, 'data-choices-container-width', '') || null;
|
|
126
|
-
const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
|
|
127
|
-
const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
gapTexts,
|
|
131
|
-
gaps,
|
|
132
|
-
shuffle,
|
|
133
|
-
prompt,
|
|
134
|
-
promptText,
|
|
135
|
-
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
136
|
-
...(choicesContainerWidth ? { choicesContainerWidth } : {}),
|
|
137
|
-
...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
|
|
138
|
-
...(minSelectionsMessage ? { minSelectionsMessage } : {}),
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
validate(data) {
|
|
143
|
-
const errors: string[] = [];
|
|
144
|
-
|
|
145
|
-
// Validate gapTexts exist
|
|
146
|
-
if (!data.gapTexts || data.gapTexts.length === 0) {
|
|
147
|
-
errors.push('gapMatchInteraction must have at least one gapText');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Validate gaps exist
|
|
151
|
-
if (!data.gaps || data.gaps.length === 0) {
|
|
152
|
-
errors.push('gapMatchInteraction must have at least one gap in the prompt');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Validate gapText identifiers
|
|
156
|
-
if (data.gapTexts) {
|
|
157
|
-
const identifiers = new Set<string>();
|
|
158
|
-
for (const gapText of data.gapTexts) {
|
|
159
|
-
if (!gapText.identifier) {
|
|
160
|
-
errors.push('All gapTexts must have an identifier');
|
|
161
|
-
} else if (identifiers.has(gapText.identifier)) {
|
|
162
|
-
errors.push(`Duplicate gapText identifier: ${gapText.identifier}`);
|
|
163
|
-
} else {
|
|
164
|
-
identifiers.add(gapText.identifier);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Validate matchMax
|
|
168
|
-
if (gapText.matchMax < 0) {
|
|
169
|
-
errors.push(`matchMax must be non-negative for gapText ${gapText.identifier}`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Validate gap identifiers
|
|
175
|
-
if (data.gaps) {
|
|
176
|
-
const identifiers = new Set<string>();
|
|
177
|
-
for (const gap of data.gaps) {
|
|
178
|
-
if (!gap) {
|
|
179
|
-
errors.push('All gaps must have an identifier');
|
|
180
|
-
} else if (identifiers.has(gap)) {
|
|
181
|
-
errors.push(`Duplicate gap identifier: ${gap}`);
|
|
182
|
-
} else {
|
|
183
|
-
identifiers.add(gap);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
valid: errors.length === 0,
|
|
190
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
191
|
-
};
|
|
192
|
-
},
|
|
193
|
-
};
|
|
1
|
+
export * from '../../interactions/gap-match/extractor.js';
|
|
@@ -1,192 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI graphicAssociateInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from graphicAssociateInteraction elements (associate items on image)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Image data for graphic associate interaction
|
|
11
|
-
*/
|
|
12
|
-
export interface ImageData {
|
|
13
|
-
type: 'image' | 'svg';
|
|
14
|
-
src?: string;
|
|
15
|
-
content?: string;
|
|
16
|
-
width?: string;
|
|
17
|
-
height?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Graphic associate data extracted from graphicAssociateInteraction elements
|
|
22
|
-
*/
|
|
23
|
-
export interface GraphicAssociateData {
|
|
24
|
-
imageData: ImageData | null;
|
|
25
|
-
associableHotspots: Array<{
|
|
26
|
-
identifier: string;
|
|
27
|
-
label: string;
|
|
28
|
-
shape: string;
|
|
29
|
-
coords: string;
|
|
30
|
-
matchMax: number;
|
|
31
|
-
matchMin?: number;
|
|
32
|
-
matchGroup?: string[];
|
|
33
|
-
classes?: string[];
|
|
34
|
-
}>;
|
|
35
|
-
maxAssociations: number;
|
|
36
|
-
minAssociations: number;
|
|
37
|
-
prompt: string | null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Standard QTI graphic associate interaction extractor
|
|
42
|
-
* Handles graphicAssociateInteraction elements (creating associations between hotspots)
|
|
43
|
-
*/
|
|
44
|
-
export const standardGraphicAssociateExtractor: ElementExtractor<GraphicAssociateData> = {
|
|
45
|
-
id: 'qti:graphic-associate-interaction',
|
|
46
|
-
name: 'QTI Standard Graphic Associate Interaction',
|
|
47
|
-
priority: 10,
|
|
48
|
-
elementTypes: ['graphicAssociateInteraction'],
|
|
49
|
-
description: 'Extracts standard QTI graphicAssociateInteraction (associate items on image)',
|
|
50
|
-
|
|
51
|
-
canHandle(element, _context) {
|
|
52
|
-
// All graphicAssociateInteraction elements are standard
|
|
53
|
-
return element.rawTagName === 'graphicAssociateInteraction';
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
extract(element, context) {
|
|
57
|
-
const { utils } = context;
|
|
58
|
-
|
|
59
|
-
// Extract image data from object element
|
|
60
|
-
const objectElements = utils.getChildrenByTag(element, 'object');
|
|
61
|
-
let imageData: ImageData | null = null;
|
|
62
|
-
|
|
63
|
-
if (objectElements.length > 0) {
|
|
64
|
-
const objectElement = objectElements[0];
|
|
65
|
-
const type = utils.getAttribute(objectElement, 'type', '');
|
|
66
|
-
const data = utils.getAttribute(objectElement, 'data', '');
|
|
67
|
-
const width = utils.getAttribute(objectElement, 'width', '500');
|
|
68
|
-
const height = utils.getAttribute(objectElement, 'height', '300');
|
|
69
|
-
|
|
70
|
-
if (type.startsWith('image/svg')) {
|
|
71
|
-
// Extract inline SVG content - get full content including <svg> tag
|
|
72
|
-
const content = utils.getHtmlContent(objectElement);
|
|
73
|
-
imageData = {
|
|
74
|
-
type: 'svg',
|
|
75
|
-
content,
|
|
76
|
-
width,
|
|
77
|
-
height,
|
|
78
|
-
};
|
|
79
|
-
} else {
|
|
80
|
-
// External image reference
|
|
81
|
-
imageData = {
|
|
82
|
-
type: 'image',
|
|
83
|
-
src: data,
|
|
84
|
-
width,
|
|
85
|
-
height,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Extract associableHotspot children
|
|
91
|
-
const hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');
|
|
92
|
-
const associableHotspots = hotspotElements.map((hotspot) => {
|
|
93
|
-
const classes = utils.getClasses(hotspot);
|
|
94
|
-
const identifier = utils.getAttribute(hotspot, 'identifier', '');
|
|
95
|
-
const shape = utils.getAttribute(hotspot, 'shape', 'rect');
|
|
96
|
-
const coords = utils.getAttribute(hotspot, 'coords', '0,0,50,50');
|
|
97
|
-
const matchMax = utils.getNumberAttribute(hotspot, 'matchMax', 1);
|
|
98
|
-
const matchMin = utils.getNumberAttribute(hotspot, 'matchMin', 0);
|
|
99
|
-
const matchGroupRaw = utils.getAttribute(hotspot, 'matchGroup', '');
|
|
100
|
-
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
101
|
-
|
|
102
|
-
// Get text content as label, use identifier as fallback
|
|
103
|
-
const textContent = utils.getTextContent(hotspot).trim();
|
|
104
|
-
const label = textContent || identifier;
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
identifier,
|
|
108
|
-
label,
|
|
109
|
-
shape,
|
|
110
|
-
coords,
|
|
111
|
-
matchMax,
|
|
112
|
-
...(matchMin > 0 ? { matchMin } : {}),
|
|
113
|
-
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
114
|
-
...(classes.length > 0 ? { classes } : {}),
|
|
115
|
-
};
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// Extract attributes with proper defaults
|
|
119
|
-
const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 1);
|
|
120
|
-
const minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);
|
|
121
|
-
|
|
122
|
-
// Extract prompt (optional)
|
|
123
|
-
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
124
|
-
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
imageData,
|
|
128
|
-
associableHotspots,
|
|
129
|
-
maxAssociations,
|
|
130
|
-
minAssociations,
|
|
131
|
-
prompt,
|
|
132
|
-
};
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
validate(data) {
|
|
136
|
-
const errors: string[] = [];
|
|
137
|
-
const warnings: string[] = [];
|
|
138
|
-
|
|
139
|
-
// Validate image data
|
|
140
|
-
if (!data.imageData) {
|
|
141
|
-
warnings.push('graphicAssociateInteraction has no image data');
|
|
142
|
-
} else if (data.imageData.type === 'image' && !data.imageData.src) {
|
|
143
|
-
errors.push('graphicAssociateInteraction must have an image URL');
|
|
144
|
-
} else if (data.imageData.type === 'svg' && !data.imageData.content) {
|
|
145
|
-
errors.push('graphicAssociateInteraction must have SVG content');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Validate hotspots exist
|
|
149
|
-
if (!data.associableHotspots || data.associableHotspots.length < 2) {
|
|
150
|
-
errors.push('graphicAssociateInteraction must have at least 2 hotspots');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Validate hotspot identifiers and coords
|
|
154
|
-
if (data.associableHotspots && data.associableHotspots.length > 0) {
|
|
155
|
-
const identifiers = new Set<string>();
|
|
156
|
-
for (const hotspot of data.associableHotspots) {
|
|
157
|
-
if (!hotspot.identifier) {
|
|
158
|
-
errors.push('All hotspots must have an identifier');
|
|
159
|
-
} else if (identifiers.has(hotspot.identifier)) {
|
|
160
|
-
errors.push(`Duplicate hotspot identifier: ${hotspot.identifier}`);
|
|
161
|
-
} else {
|
|
162
|
-
identifiers.add(hotspot.identifier);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (!hotspot.coords) {
|
|
166
|
-
errors.push(`Hotspot ${hotspot.identifier} must have coords`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Validate matchMax
|
|
170
|
-
if (hotspot.matchMax < 0) {
|
|
171
|
-
errors.push(`matchMax must be non-negative for hotspot ${hotspot.identifier}`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Validate maxAssociations
|
|
177
|
-
if (data.maxAssociations < 0) {
|
|
178
|
-
errors.push('maxAssociations must be non-negative');
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Validate minAssociations
|
|
182
|
-
if (data.minAssociations < 0) {
|
|
183
|
-
errors.push('minAssociations must be non-negative');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
valid: errors.length === 0,
|
|
188
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
189
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
190
|
-
};
|
|
191
|
-
},
|
|
192
|
-
};
|
|
1
|
+
export * from '../../interactions/graphic-associate/extractor.js';
|