@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
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { AttributeNameMapper, ElementNameMapper } from '@pie-qti/qti-common';
|
|
2
|
+
import {
|
|
3
|
+
childElements,
|
|
4
|
+
findAssessmentItem,
|
|
5
|
+
findDescendants,
|
|
6
|
+
findFirstDescendant,
|
|
7
|
+
parseXml,
|
|
8
|
+
serializeXml,
|
|
9
|
+
} from '@pie-qti/qti-processing';
|
|
10
|
+
import { parse } from 'node-html-parser';
|
|
11
|
+
import { enforceItemXmlLimits } from '../core/parsingLimits.js';
|
|
12
|
+
import { normalizeInteractionTypeFromTagName } from '../interactions/modules.js';
|
|
13
|
+
import type { PlayerSecurityConfig } from '../types/index.js';
|
|
14
|
+
import type { QTIElement } from '../types/interactions.js';
|
|
15
|
+
|
|
16
|
+
export type ProcessingKind = 'template' | 'response' | 'outcome';
|
|
17
|
+
|
|
18
|
+
export interface DiscoveredInteractionElement {
|
|
19
|
+
element: QTIElement;
|
|
20
|
+
contextRoot: QTIElement;
|
|
21
|
+
responseIdentifier: string;
|
|
22
|
+
normalizedType: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AssessmentItemDocumentInput {
|
|
26
|
+
itemXml: string;
|
|
27
|
+
elementNameMapper: ElementNameMapper;
|
|
28
|
+
attributeNameMapper: AttributeNameMapper;
|
|
29
|
+
security?: PlayerSecurityConfig;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class AssessmentItemDocument {
|
|
33
|
+
private readonly itemXml: string;
|
|
34
|
+
private readonly security?: PlayerSecurityConfig;
|
|
35
|
+
readonly elementNameMapper: ElementNameMapper;
|
|
36
|
+
readonly attributeNameMapper: AttributeNameMapper;
|
|
37
|
+
private readonly xmlDocument: Document;
|
|
38
|
+
private readonly assessmentItem: Element;
|
|
39
|
+
private extractionDocument: QTIElement | null = null;
|
|
40
|
+
private extractionRoot: QTIElement | null = null;
|
|
41
|
+
|
|
42
|
+
constructor({
|
|
43
|
+
itemXml,
|
|
44
|
+
elementNameMapper,
|
|
45
|
+
attributeNameMapper,
|
|
46
|
+
security,
|
|
47
|
+
}: AssessmentItemDocumentInput) {
|
|
48
|
+
this.itemXml = itemXml;
|
|
49
|
+
this.security = security;
|
|
50
|
+
this.elementNameMapper = elementNameMapper;
|
|
51
|
+
this.attributeNameMapper = attributeNameMapper;
|
|
52
|
+
|
|
53
|
+
enforceItemXmlLimits(this.itemXml, this.security);
|
|
54
|
+
this.xmlDocument = parseXml(this.itemXml);
|
|
55
|
+
this.assessmentItem = findAssessmentItem(this.xmlDocument);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getAssessmentItem(): Element {
|
|
59
|
+
return this.assessmentItem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getProcessingElement(kind: ProcessingKind): Element | null {
|
|
63
|
+
const tagName =
|
|
64
|
+
kind === 'template'
|
|
65
|
+
? 'templateprocessing'
|
|
66
|
+
: kind === 'response'
|
|
67
|
+
? 'responseprocessing'
|
|
68
|
+
: 'outcomeprocessing';
|
|
69
|
+
return findFirstDescendant(this.assessmentItem, this.elementNameMapper.toNative(tagName));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
serializeItemBodyChildren(): string {
|
|
73
|
+
const itemBody = findFirstDescendant(
|
|
74
|
+
this.assessmentItem,
|
|
75
|
+
this.elementNameMapper.toNative('itembody')
|
|
76
|
+
);
|
|
77
|
+
if (!itemBody) return '';
|
|
78
|
+
return this.serializeChildren(itemBody);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
findRubricElements(): Element[] {
|
|
82
|
+
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative('rubricblock'));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
findModalFeedbackElements(): Element[] {
|
|
86
|
+
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative('modalfeedback'));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
findDeclarationElements(kind: 'response' | 'outcome' | 'template'): Element[] {
|
|
90
|
+
const tagName =
|
|
91
|
+
kind === 'response'
|
|
92
|
+
? 'responsedeclaration'
|
|
93
|
+
: kind === 'outcome'
|
|
94
|
+
? 'outcomedeclaration'
|
|
95
|
+
: 'templatedeclaration';
|
|
96
|
+
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative(tagName));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getAssessmentItemAttribute(name: string): string | null {
|
|
100
|
+
return this.assessmentItem.getAttribute(this.attributeNameMapper.toNative(name));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
serializeChildren(element: Element): string {
|
|
104
|
+
return childElements(element).map((child) => serializeXml(child)).join('');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
findExtractionElements(elementTypes: Iterable<string>): DiscoveredInteractionElement[] {
|
|
108
|
+
const root = this.getExtractionRoot();
|
|
109
|
+
if (!root) return [];
|
|
110
|
+
|
|
111
|
+
const canonicalTypes = new Set(
|
|
112
|
+
[...elementTypes].map((elementType) => this.elementNameMapper.toCanonical(elementType))
|
|
113
|
+
);
|
|
114
|
+
const elements: DiscoveredInteractionElement[] = [];
|
|
115
|
+
|
|
116
|
+
this.walkExtractionChildren(root, (element) => {
|
|
117
|
+
const rawTagName = element.rawTagName;
|
|
118
|
+
if (!rawTagName) return;
|
|
119
|
+
if (!canonicalTypes.has(this.elementNameMapper.toCanonical(rawTagName))) return;
|
|
120
|
+
|
|
121
|
+
const responseIdentifier = this.getExtractionResponseIdentifier(element);
|
|
122
|
+
if (!responseIdentifier) return;
|
|
123
|
+
|
|
124
|
+
elements.push({
|
|
125
|
+
element,
|
|
126
|
+
contextRoot: root,
|
|
127
|
+
responseIdentifier,
|
|
128
|
+
normalizedType: normalizeInteractionTypeFromTagName(rawTagName),
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return elements;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private getExtractionRoot(): QTIElement | null {
|
|
136
|
+
if (this.extractionRoot) return this.extractionRoot;
|
|
137
|
+
|
|
138
|
+
const docRoot = this.getExtractionDocument();
|
|
139
|
+
const itemBodyTag = this.elementNameMapper.toNative('itembody').toLowerCase();
|
|
140
|
+
this.extractionRoot = (docRoot.querySelector?.(itemBodyTag) as QTIElement | null) ?? null;
|
|
141
|
+
return this.extractionRoot;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private getExtractionDocument(): QTIElement {
|
|
145
|
+
if (!this.extractionDocument) {
|
|
146
|
+
enforceItemXmlLimits(this.itemXml, this.security);
|
|
147
|
+
this.extractionDocument = parse(this.itemXml, {
|
|
148
|
+
lowerCaseTagName: false,
|
|
149
|
+
comment: false,
|
|
150
|
+
}) as unknown as QTIElement;
|
|
151
|
+
}
|
|
152
|
+
return this.extractionDocument;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private walkExtractionChildren(root: QTIElement, visit: (element: QTIElement) => void): void {
|
|
156
|
+
for (const child of root.childNodes ?? []) {
|
|
157
|
+
const element = child as QTIElement;
|
|
158
|
+
if (!element.rawTagName) continue;
|
|
159
|
+
visit(element);
|
|
160
|
+
this.walkExtractionChildren(element, visit);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private getExtractionResponseIdentifier(element: QTIElement): string {
|
|
165
|
+
const nativeName = this.attributeNameMapper.toNative('responseIdentifier');
|
|
166
|
+
return (
|
|
167
|
+
element.getAttribute?.('responseIdentifier') ||
|
|
168
|
+
element.getAttribute?.(nativeName) ||
|
|
169
|
+
element.getAttribute?.('response-identifier') ||
|
|
170
|
+
element.getAttribute?.('responseidentifier') ||
|
|
171
|
+
''
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function parseAssessmentItemDocument(input: AssessmentItemDocumentInput): AssessmentItemDocument {
|
|
177
|
+
return new AssessmentItemDocument(input);
|
|
178
|
+
}
|
|
@@ -1,133 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI associateInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from associateInteraction elements (associating items)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Associate data extracted from associateInteraction elements
|
|
11
|
-
*/
|
|
12
|
-
export interface AssociateData {
|
|
13
|
-
choices: Array<{
|
|
14
|
-
identifier: string;
|
|
15
|
-
text: string;
|
|
16
|
-
matchMax: number;
|
|
17
|
-
matchMin?: number;
|
|
18
|
-
matchGroup?: string[];
|
|
19
|
-
classes?: string[];
|
|
20
|
-
}>;
|
|
21
|
-
shuffle: boolean;
|
|
22
|
-
maxAssociations: number;
|
|
23
|
-
minAssociations?: number;
|
|
24
|
-
prompt: string | null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Standard QTI associate interaction extractor
|
|
29
|
-
* Handles associateInteraction elements (creating associations between items)
|
|
30
|
-
*/
|
|
31
|
-
export const standardAssociateExtractor: ElementExtractor<AssociateData> = {
|
|
32
|
-
id: 'qti:associate-interaction',
|
|
33
|
-
name: 'QTI Standard Associate Interaction',
|
|
34
|
-
priority: 10,
|
|
35
|
-
elementTypes: ['associateInteraction'],
|
|
36
|
-
description: 'Extracts standard QTI associateInteraction (associating items)',
|
|
37
|
-
|
|
38
|
-
canHandle(element, context) {
|
|
39
|
-
// All associateInteraction elements with simpleAssociableChoice are standard
|
|
40
|
-
return (
|
|
41
|
-
element.rawTagName === 'associateInteraction' &&
|
|
42
|
-
context.utils.hasChildWithTag(element, 'simpleAssociableChoice')
|
|
43
|
-
);
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
extract(element, context) {
|
|
47
|
-
const { utils } = context;
|
|
48
|
-
|
|
49
|
-
// Extract simpleAssociableChoice children
|
|
50
|
-
const choiceElements = utils.getChildrenByTag(element, 'simpleAssociableChoice');
|
|
51
|
-
const choices = choiceElements.map((choice) => {
|
|
52
|
-
const classes = utils.getClasses(choice);
|
|
53
|
-
const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
|
|
54
|
-
const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
|
|
55
|
-
const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
|
|
56
|
-
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
60
|
-
text: utils.getHtmlContent(choice),
|
|
61
|
-
matchMax,
|
|
62
|
-
...(matchMin > 0 ? { matchMin } : {}),
|
|
63
|
-
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
64
|
-
...(classes.length > 0 ? { classes } : {}),
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Extract attributes with proper defaults
|
|
69
|
-
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
70
|
-
const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 0);
|
|
71
|
-
const minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);
|
|
72
|
-
|
|
73
|
-
// Extract prompt (optional)
|
|
74
|
-
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
75
|
-
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
choices,
|
|
79
|
-
shuffle,
|
|
80
|
-
maxAssociations,
|
|
81
|
-
...(minAssociations > 0 ? { minAssociations } : {}),
|
|
82
|
-
prompt,
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
validate(data) {
|
|
87
|
-
const errors: string[] = [];
|
|
88
|
-
|
|
89
|
-
// Validate choices exist
|
|
90
|
-
if (!data.choices || data.choices.length < 2) {
|
|
91
|
-
errors.push('associateInteraction must have at least 2 choices');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Validate choice identifiers
|
|
95
|
-
if (data.choices) {
|
|
96
|
-
const identifiers = new Set<string>();
|
|
97
|
-
for (const choice of data.choices) {
|
|
98
|
-
if (!choice.identifier) {
|
|
99
|
-
errors.push('All choices must have an identifier');
|
|
100
|
-
} else if (identifiers.has(choice.identifier)) {
|
|
101
|
-
errors.push(`Duplicate choice identifier: ${choice.identifier}`);
|
|
102
|
-
} else {
|
|
103
|
-
identifiers.add(choice.identifier);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Validate matchMax
|
|
107
|
-
if (choice.matchMax < 0) {
|
|
108
|
-
errors.push(`matchMax must be non-negative for choice ${choice.identifier}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Validate matchMin
|
|
112
|
-
if (choice.matchMin !== undefined && choice.matchMin < 0) {
|
|
113
|
-
errors.push(`matchMin must be non-negative for choice ${choice.identifier}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Validate maxAssociations
|
|
119
|
-
if (data.maxAssociations < 0) {
|
|
120
|
-
errors.push('maxAssociations must be non-negative');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Validate minAssociations
|
|
124
|
-
if (data.minAssociations !== undefined && data.minAssociations < 0) {
|
|
125
|
-
errors.push('minAssociations must be non-negative');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
valid: errors.length === 0,
|
|
130
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
};
|
|
1
|
+
export * from '../../interactions/associate/extractor.js';
|
|
@@ -1,121 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI choiceInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from choiceInteraction elements with simpleChoice children
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ChoiceInteractionData } from '../../types/interactions.js';
|
|
8
|
-
import type { ElementExtractor, ExtractionContext } from '../types.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Choice data extracted from simpleChoice elements
|
|
12
|
-
*/
|
|
13
|
-
export interface ChoiceData {
|
|
14
|
-
choices: Array<{ identifier: string; text: string; fixed?: boolean; classes?: string[] }>;
|
|
15
|
-
shuffle: boolean;
|
|
16
|
-
maxChoices: number;
|
|
17
|
-
minChoices: number;
|
|
18
|
-
prompt: string | null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Standard QTI choice interaction extractor
|
|
23
|
-
* Handles choiceInteraction elements with simpleChoice children
|
|
24
|
-
*/
|
|
25
|
-
export const standardChoiceExtractor: ElementExtractor<ChoiceData> = {
|
|
26
|
-
id: 'qti:choice-interaction',
|
|
27
|
-
name: 'QTI Standard Choice Interaction',
|
|
28
|
-
priority: 10,
|
|
29
|
-
elementTypes: ['choiceInteraction'],
|
|
30
|
-
description: 'Extracts standard QTI choiceInteraction with simpleChoice elements',
|
|
31
|
-
|
|
32
|
-
canHandle(element, context) {
|
|
33
|
-
// Standard QTI choice interactions have simpleChoice children
|
|
34
|
-
return context.utils.hasChildWithTag(element, 'simpleChoice');
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
extract(element, context) {
|
|
38
|
-
const { utils } = context;
|
|
39
|
-
|
|
40
|
-
// Extract choices
|
|
41
|
-
const simpleChoices = utils.getChildrenByTag(element, 'simpleChoice');
|
|
42
|
-
const choices = simpleChoices.map((choice) => {
|
|
43
|
-
const classes = utils.getClasses(choice);
|
|
44
|
-
const fixed = utils.getBooleanAttribute(choice, 'fixed');
|
|
45
|
-
return {
|
|
46
|
-
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
47
|
-
text: utils.getHtmlContent(choice),
|
|
48
|
-
...(fixed ? { fixed } : {}),
|
|
49
|
-
...(classes.length > 0 ? { classes } : {}),
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Extract prompt
|
|
54
|
-
const promptElement = utils.querySelector(element, 'prompt');
|
|
55
|
-
const prompt = promptElement ? utils.getHtmlContent(promptElement) : null;
|
|
56
|
-
|
|
57
|
-
// Extract attributes
|
|
58
|
-
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
59
|
-
const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);
|
|
60
|
-
const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
|
|
61
|
-
const interactionClasses = utils.getClasses(element);
|
|
62
|
-
const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
|
|
63
|
-
const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
choices,
|
|
67
|
-
shuffle,
|
|
68
|
-
maxChoices,
|
|
69
|
-
minChoices,
|
|
70
|
-
prompt,
|
|
71
|
-
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
72
|
-
...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
|
|
73
|
-
...(minSelectionsMessage ? { minSelectionsMessage } : {}),
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
validate(data) {
|
|
78
|
-
const errors: string[] = [];
|
|
79
|
-
const warnings: string[] = [];
|
|
80
|
-
|
|
81
|
-
// Validate choices exist
|
|
82
|
-
if (!data.choices || data.choices.length === 0) {
|
|
83
|
-
errors.push('choiceInteraction must have at least one choice');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Validate choice identifiers
|
|
87
|
-
if (data.choices) {
|
|
88
|
-
const identifiers = new Set<string>();
|
|
89
|
-
for (const choice of data.choices) {
|
|
90
|
-
if (!choice.identifier) {
|
|
91
|
-
errors.push('All choices must have an identifier');
|
|
92
|
-
} else if (identifiers.has(choice.identifier)) {
|
|
93
|
-
errors.push(`Duplicate choice identifier: ${choice.identifier}`);
|
|
94
|
-
} else {
|
|
95
|
-
identifiers.add(choice.identifier);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Validate maxChoices
|
|
101
|
-
if (data.maxChoices < 0) {
|
|
102
|
-
errors.push('maxChoices must be non-negative');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (data.maxChoices === 0) {
|
|
106
|
-
warnings.push('maxChoices=0 means unlimited selections');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (data.maxChoices > data.choices.length) {
|
|
110
|
-
warnings.push(
|
|
111
|
-
`maxChoices (${data.maxChoices}) is greater than the number of choices (${data.choices.length})`
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
valid: errors.length === 0,
|
|
117
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
118
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
};
|
|
1
|
+
export * from '../../interactions/choice/extractor.js';
|
|
@@ -1,72 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI customInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from customInteraction elements (custom/portable interactions)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Custom interaction data extracted from customInteraction elements
|
|
11
|
-
*/
|
|
12
|
-
export interface CustomData {
|
|
13
|
-
xml: string;
|
|
14
|
-
rawAttributes: Record<string, string>;
|
|
15
|
-
prompt: string | null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Standard QTI custom interaction extractor
|
|
20
|
-
* Handles customInteraction elements (vendor-specific or portable custom interactions)
|
|
21
|
-
*/
|
|
22
|
-
export const standardCustomExtractor: ElementExtractor<CustomData> = {
|
|
23
|
-
id: 'qti:custom-interaction',
|
|
24
|
-
name: 'QTI Standard Custom Interaction',
|
|
25
|
-
priority: 10,
|
|
26
|
-
elementTypes: ['customInteraction'],
|
|
27
|
-
description: 'Extracts standard QTI customInteraction (custom/portable interactions)',
|
|
28
|
-
|
|
29
|
-
canHandle(element, _context) {
|
|
30
|
-
// All customInteraction elements are handled by this extractor
|
|
31
|
-
return element.rawTagName === 'customInteraction';
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
extract(element, context) {
|
|
35
|
-
const { utils } = context;
|
|
36
|
-
|
|
37
|
-
// Capture the raw XML for the custom interaction
|
|
38
|
-
const xml = element.outerHTML || element.toString();
|
|
39
|
-
|
|
40
|
-
// Extract all attributes
|
|
41
|
-
const rawAttributes: Record<string, string> = {};
|
|
42
|
-
if (element.attributes) {
|
|
43
|
-
for (const [key, value] of Object.entries(element.attributes)) {
|
|
44
|
-
rawAttributes[key] = String(value);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Extract prompt (optional)
|
|
49
|
-
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
50
|
-
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
xml,
|
|
54
|
-
rawAttributes,
|
|
55
|
-
prompt,
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
validate(_data) {
|
|
60
|
-
const warnings: string[] = [];
|
|
61
|
-
|
|
62
|
-
// Warn if no XML content
|
|
63
|
-
if (!_data.xml || _data.xml.trim() === '') {
|
|
64
|
-
warnings.push('customInteraction has no XML content');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
valid: true,
|
|
69
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
};
|
|
1
|
+
export * from '../../interactions/custom/extractor.js';
|
|
@@ -1,113 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI drawingInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from drawingInteraction elements (drawing on canvas)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Image data for drawing interaction
|
|
11
|
-
*/
|
|
12
|
-
export interface ImageData {
|
|
13
|
-
type: 'image' | 'svg';
|
|
14
|
-
src?: string;
|
|
15
|
-
content?: string;
|
|
16
|
-
width?: string;
|
|
17
|
-
height?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Drawing data extracted from drawingInteraction elements
|
|
22
|
-
*/
|
|
23
|
-
export interface DrawingData {
|
|
24
|
-
imageData: ImageData | null;
|
|
25
|
-
rawAttributes: Record<string, string>;
|
|
26
|
-
prompt: string | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Standard QTI drawing interaction extractor
|
|
31
|
-
* Handles drawingInteraction elements (drawing on a canvas)
|
|
32
|
-
*/
|
|
33
|
-
export const standardDrawingExtractor: ElementExtractor<DrawingData> = {
|
|
34
|
-
id: 'qti:drawing-interaction',
|
|
35
|
-
name: 'QTI Standard Drawing Interaction',
|
|
36
|
-
priority: 10,
|
|
37
|
-
elementTypes: ['drawingInteraction'],
|
|
38
|
-
description: 'Extracts standard QTI drawingInteraction (drawing on canvas)',
|
|
39
|
-
|
|
40
|
-
canHandle(element, _context) {
|
|
41
|
-
// All drawingInteraction elements are standard
|
|
42
|
-
return element.rawTagName === 'drawingInteraction';
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
extract(element, context) {
|
|
46
|
-
const { utils } = context;
|
|
47
|
-
|
|
48
|
-
// Extract background image data from object element (optional)
|
|
49
|
-
const objectElements = utils.getChildrenByTag(element, 'object');
|
|
50
|
-
let imageData: ImageData | null = null;
|
|
51
|
-
|
|
52
|
-
if (objectElements.length > 0) {
|
|
53
|
-
const objectElement = objectElements[0];
|
|
54
|
-
const type = utils.getAttribute(objectElement, 'type', '');
|
|
55
|
-
const data = utils.getAttribute(objectElement, 'data', '');
|
|
56
|
-
const width = utils.getAttribute(objectElement, 'width', '');
|
|
57
|
-
const height = utils.getAttribute(objectElement, 'height', '');
|
|
58
|
-
|
|
59
|
-
if (type.startsWith('image/svg')) {
|
|
60
|
-
// Extract inline SVG content
|
|
61
|
-
const content = utils.getHtmlContent(objectElement);
|
|
62
|
-
imageData = {
|
|
63
|
-
type: 'svg',
|
|
64
|
-
content,
|
|
65
|
-
...(width ? { width } : {}),
|
|
66
|
-
...(height ? { height } : {}),
|
|
67
|
-
};
|
|
68
|
-
} else if (data) {
|
|
69
|
-
// External image reference
|
|
70
|
-
imageData = {
|
|
71
|
-
type: 'image',
|
|
72
|
-
src: data,
|
|
73
|
-
...(width ? { width } : {}),
|
|
74
|
-
...(height ? { height } : {}),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Extract all attributes
|
|
80
|
-
const rawAttributes: Record<string, string> = {};
|
|
81
|
-
if (element.attributes) {
|
|
82
|
-
for (const [key, value] of Object.entries(element.attributes)) {
|
|
83
|
-
rawAttributes[key] = String(value);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Extract prompt (optional)
|
|
88
|
-
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
89
|
-
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
imageData,
|
|
93
|
-
rawAttributes,
|
|
94
|
-
prompt,
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
validate(data) {
|
|
99
|
-
const warnings: string[] = [];
|
|
100
|
-
|
|
101
|
-
// Warn if no background image
|
|
102
|
-
if (!data.imageData) {
|
|
103
|
-
warnings.push(
|
|
104
|
-
'drawingInteraction has no background image - students will draw on a blank canvas'
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
valid: true,
|
|
110
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
};
|
|
1
|
+
export * from '../../interactions/drawing/extractor.js';
|
|
@@ -1,74 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Standard QTI endAttemptInteraction extractor
|
|
3
|
-
*
|
|
4
|
-
* Extracts data from endAttemptInteraction elements (end attempt button)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ElementExtractor } from '../types.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* End attempt data extracted from endAttemptInteraction elements
|
|
11
|
-
*/
|
|
12
|
-
export interface EndAttemptData {
|
|
13
|
-
title?: string;
|
|
14
|
-
countAttempt?: boolean;
|
|
15
|
-
prompt: string | null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Standard QTI end attempt interaction extractor
|
|
20
|
-
* Handles endAttemptInteraction elements (button to end the attempt)
|
|
21
|
-
*/
|
|
22
|
-
export const standardEndAttemptExtractor: ElementExtractor<EndAttemptData> = {
|
|
23
|
-
id: 'qti:end-attempt-interaction',
|
|
24
|
-
name: 'QTI Standard End Attempt Interaction',
|
|
25
|
-
priority: 10,
|
|
26
|
-
elementTypes: ['endAttemptInteraction'],
|
|
27
|
-
description: 'Extracts standard QTI endAttemptInteraction (end attempt button)',
|
|
28
|
-
|
|
29
|
-
canHandle(element, _context) {
|
|
30
|
-
// All endAttemptInteraction elements are standard
|
|
31
|
-
return element.rawTagName === 'endAttemptInteraction';
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
extract(element, context) {
|
|
35
|
-
const { utils } = context;
|
|
36
|
-
|
|
37
|
-
// Extract attributes with defaults
|
|
38
|
-
const title = utils.getAttribute(element, 'title', 'End Attempt');
|
|
39
|
-
const countAttempt = element.hasAttribute('countAttempt')
|
|
40
|
-
? utils.getBooleanAttribute(element, 'countAttempt')
|
|
41
|
-
: true;
|
|
42
|
-
|
|
43
|
-
// Extract prompt (optional)
|
|
44
|
-
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
45
|
-
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
title,
|
|
49
|
-
countAttempt,
|
|
50
|
-
prompt,
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
validate(data) {
|
|
55
|
-
const errors: string[] = [];
|
|
56
|
-
const warnings: string[] = [];
|
|
57
|
-
|
|
58
|
-
// Validate title is not empty
|
|
59
|
-
if (!data.title || data.title.trim() === '') {
|
|
60
|
-
errors.push('endAttemptInteraction must have a title');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Warn if countAttempt is false (uncommon usage)
|
|
64
|
-
if (data.countAttempt === false) {
|
|
65
|
-
warnings.push('endAttemptInteraction has countAttempt=false - make sure this is intentional');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
valid: errors.length === 0,
|
|
70
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
71
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
};
|
|
1
|
+
export * from '../../interactions/end-attempt/extractor.js';
|