@pie-qti/item-player 0.1.5 → 0.1.6
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/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 +2 -2
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +46 -147
- 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 +2515 -2294
- 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 +1 -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/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/components/ItemBody.svelte +35 -173
- package/src/components/ItemPlayer.svelte +9 -5
- package/src/components/ModalFeedbackDisplay.svelte +15 -5
- package/src/core/ComponentRegistry.ts +22 -7
- package/src/core/Player.ts +48 -163
- 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 +2 -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/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/core/ItemRenderer.ts +0 -371
package/src/core/Player.ts
CHANGED
|
@@ -12,17 +12,14 @@ import {
|
|
|
12
12
|
type DeclarationMap,
|
|
13
13
|
evalExpr,
|
|
14
14
|
execProgram,
|
|
15
|
-
findAssessmentItem,
|
|
16
15
|
findDescendants,
|
|
17
16
|
findFirstDescendant,
|
|
18
17
|
getAttr,
|
|
19
18
|
OperatorRegistry,
|
|
20
19
|
type ProcessingProgram,
|
|
21
|
-
parseXml,
|
|
22
20
|
type QtiValue,
|
|
23
21
|
qtiNull,
|
|
24
22
|
qtiValue,
|
|
25
|
-
serializeXml,
|
|
26
23
|
toBoolean,
|
|
27
24
|
toNumber,
|
|
28
25
|
toStringValue,
|
|
@@ -35,11 +32,12 @@ import {
|
|
|
35
32
|
Qti3AttributeNameMapper,
|
|
36
33
|
detectQtiVersion,
|
|
37
34
|
} from '@pie-qti/qti-common';
|
|
38
|
-
import {
|
|
35
|
+
import type { AssessmentItemDocument } from '../document/AssessmentItemDocument.js';
|
|
36
|
+
import { parseAssessmentItemDocument } from '../document/AssessmentItemDocument.js';
|
|
39
37
|
import type { ExtractionRegistry } from '../extraction/ExtractionRegistry.js';
|
|
40
38
|
import { createExtractionRegistry } from '../extraction/ExtractionRegistry.js';
|
|
41
|
-
import {
|
|
42
|
-
import
|
|
39
|
+
import { extractInteractionData } from '../extraction/interactionExtractionPipeline.js';
|
|
40
|
+
import { getStandardInteractionExtractors } from '../interactions/modules.js';
|
|
43
41
|
import type {
|
|
44
42
|
AdaptiveAttemptResult,
|
|
45
43
|
CompletionStatus,
|
|
@@ -52,15 +50,13 @@ import type {
|
|
|
52
50
|
RubricBlock,
|
|
53
51
|
ScoringResult,
|
|
54
52
|
} from '../types/index.js';
|
|
55
|
-
import type { InteractionData
|
|
53
|
+
import type { InteractionData } from '../types/interactions.js';
|
|
56
54
|
import type { ResponseValidationResult } from '../types/responseValidation.js';
|
|
57
55
|
import type { ComponentRegistry } from './ComponentRegistry.js';
|
|
58
56
|
import { createComponentRegistry } from './ComponentRegistry.js';
|
|
59
|
-
import { enforceItemXmlLimits } from './parsingLimits.js';
|
|
60
57
|
import { createSeededRng } from './random.js';
|
|
61
58
|
import { sanitizeHtml } from './sanitizer.js';
|
|
62
59
|
import { toTrustedHtml } from './trustedTypes.js';
|
|
63
|
-
import { sanitizeResourceUrl } from './urlPolicy.js';
|
|
64
60
|
import type { PnpProfile } from '../pnp/types.js';
|
|
65
61
|
import { applyPnpToRoot } from '../pnp/applyPnp.js';
|
|
66
62
|
import type { CatalogIndex } from '../catalog/types.js';
|
|
@@ -75,7 +71,7 @@ export class Player {
|
|
|
75
71
|
private role: QTIRole;
|
|
76
72
|
private config: PlayerConfig;
|
|
77
73
|
private itemXml: string;
|
|
78
|
-
private
|
|
74
|
+
private itemDocument: AssessmentItemDocument;
|
|
79
75
|
private assessmentItem: Element;
|
|
80
76
|
private decls: DeclarationMap;
|
|
81
77
|
private ctx: DeclarationContext;
|
|
@@ -120,15 +116,23 @@ export class Player {
|
|
|
120
116
|
}
|
|
121
117
|
} else {
|
|
122
118
|
this.mapper = config.elementNameMapper as ElementNameMapper;
|
|
119
|
+
if (!config.attributeNameMapper) {
|
|
120
|
+
(config as any).attributeNameMapper =
|
|
121
|
+
this.mapper.version === '3.0'
|
|
122
|
+
? new Qti3AttributeNameMapper()
|
|
123
|
+
: new Qti2xAttributeNameMapper();
|
|
124
|
+
}
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
this.itemDocument = parseAssessmentItemDocument({
|
|
128
|
+
itemXml: this.itemXml,
|
|
129
|
+
elementNameMapper: this.mapper,
|
|
130
|
+
attributeNameMapper: config.attributeNameMapper as AttributeNameMapper,
|
|
131
|
+
security: this.config.security,
|
|
132
|
+
});
|
|
133
|
+
this.assessmentItem = this.itemDocument.getAssessmentItem();
|
|
130
134
|
|
|
131
|
-
this.decls = this.buildDeclarations(
|
|
135
|
+
this.decls = this.buildDeclarations();
|
|
132
136
|
this.ensureBuiltinDeclarations(this.decls);
|
|
133
137
|
this.ctx = new DeclarationContext(this.decls);
|
|
134
138
|
this.ops = new OperatorRegistry();
|
|
@@ -146,8 +150,8 @@ export class Player {
|
|
|
146
150
|
// I18n provider (defaults to a simple fallback if not provided)
|
|
147
151
|
this.i18nProvider = config.i18nProvider ?? this.createDefaultI18nProvider();
|
|
148
152
|
|
|
149
|
-
// Register standard extractors (idempotent per-registry instance)
|
|
150
|
-
for (const ex of
|
|
153
|
+
// Register standard interaction extractors (idempotent per-registry instance)
|
|
154
|
+
for (const ex of getStandardInteractionExtractors()) {
|
|
151
155
|
try {
|
|
152
156
|
this.extractionRegistry.register(ex as any);
|
|
153
157
|
} catch {
|
|
@@ -166,7 +170,7 @@ export class Player {
|
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
// Build ASTs once.
|
|
169
|
-
const templateProcessing =
|
|
173
|
+
const templateProcessing = this.itemDocument.getProcessingElement('template');
|
|
170
174
|
if (templateProcessing) {
|
|
171
175
|
this.templateProcessingProgram = buildTemplateProcessingAst(templateProcessing, {
|
|
172
176
|
elementNameMapper: this.mapper,
|
|
@@ -174,14 +178,14 @@ export class Player {
|
|
|
174
178
|
this.execTemplateProcessing();
|
|
175
179
|
}
|
|
176
180
|
|
|
177
|
-
const responseProcessing =
|
|
181
|
+
const responseProcessing = this.itemDocument.getProcessingElement('response');
|
|
178
182
|
if (responseProcessing) {
|
|
179
183
|
this.responseProcessingProgram = buildResponseProcessingAst(responseProcessing, {
|
|
180
184
|
elementNameMapper: this.mapper,
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
187
|
|
|
184
|
-
const outcomeProcessing =
|
|
188
|
+
const outcomeProcessing = this.itemDocument.getProcessingElement('outcome');
|
|
185
189
|
if (outcomeProcessing) {
|
|
186
190
|
this.outcomeProcessingProgram = buildOutcomeProcessingAst(outcomeProcessing, {
|
|
187
191
|
elementNameMapper: this.mapper,
|
|
@@ -264,7 +268,7 @@ export class Player {
|
|
|
264
268
|
|
|
265
269
|
/**
|
|
266
270
|
* Create a PciHost for an extracted PCI and register it for response tracking.
|
|
267
|
-
* The caller
|
|
271
|
+
* The caller is responsible for calling host.load() and
|
|
268
272
|
* host.initialize(domNode) once the DOM element is available.
|
|
269
273
|
*/
|
|
270
274
|
public createPciHost(data: ExtractedPci): PciHost {
|
|
@@ -341,7 +345,7 @@ export class Player {
|
|
|
341
345
|
this.resetOutcomesToDefault();
|
|
342
346
|
|
|
343
347
|
// Execute response processing if present
|
|
344
|
-
const rpEl =
|
|
348
|
+
const rpEl = this.itemDocument.getProcessingElement('response');
|
|
345
349
|
if (rpEl) {
|
|
346
350
|
// If responseProcessing has explicit statements, run the compiled program.
|
|
347
351
|
// Otherwise, fall back to template-based processing (responseProcessing@template).
|
|
@@ -492,11 +496,9 @@ export class Player {
|
|
|
492
496
|
}
|
|
493
497
|
|
|
494
498
|
public getItemBodyHtml(): HtmlContent {
|
|
495
|
-
const
|
|
496
|
-
if (!
|
|
499
|
+
const inner = this.itemDocument.serializeItemBodyChildren();
|
|
500
|
+
if (!inner) return '';
|
|
497
501
|
|
|
498
|
-
// Serialize children rather than the container tag itself.
|
|
499
|
-
const inner = childElements(itemBody).map((c) => serializeXml(c)).join('');
|
|
500
502
|
const printed = this.renderPrintedVariables(inner);
|
|
501
503
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
502
504
|
return toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -510,7 +512,7 @@ export class Player {
|
|
|
510
512
|
*/
|
|
511
513
|
public getRubrics(): RubricBlock[] {
|
|
512
514
|
const role = this.role;
|
|
513
|
-
const rubricEls =
|
|
515
|
+
const rubricEls = this.itemDocument.findRubricElements();
|
|
514
516
|
if (rubricEls.length === 0) return [];
|
|
515
517
|
|
|
516
518
|
const blocks: RubricBlock[] = [];
|
|
@@ -521,8 +523,7 @@ export class Player {
|
|
|
521
523
|
// If view is specified, show only when it includes the current role.
|
|
522
524
|
if (view.length > 0 && role && !view.includes(role)) continue;
|
|
523
525
|
|
|
524
|
-
|
|
525
|
-
const contentRaw = childElements(el).map((c) => serializeXml(c)).join('') || (el.textContent || '');
|
|
526
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
526
527
|
const printed = this.renderPrintedVariables(contentRaw);
|
|
527
528
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
528
529
|
const html = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -545,128 +546,12 @@ export class Player {
|
|
|
545
546
|
* Canonical interaction API (new): extracted, typed interaction data.
|
|
546
547
|
*/
|
|
547
548
|
public getInteractionData(): InteractionData[] {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const docRoot = parse(this.itemXml, { lowerCaseTagName: false, comment: false }) as any as QTIElement;
|
|
555
|
-
// node-html-parser's CSS selectors match lowercase tag names.
|
|
556
|
-
// Search for itemBody in the native form for this QTI version (itembody for 2.x, qti-item-body for 3.0)
|
|
557
|
-
const itemBodyTag = this.mapper.toNative('itembody').toLowerCase();
|
|
558
|
-
const parsedItemBody = (docRoot.querySelector?.(itemBodyTag) as any as QTIElement | null) ?? null;
|
|
559
|
-
const root = parsedItemBody ?? docRoot;
|
|
560
|
-
|
|
561
|
-
const declMap = new Map<string, ExtractionVariableDeclaration>();
|
|
562
|
-
for (const d of Object.values(this.decls)) {
|
|
563
|
-
declMap.set(d.identifier, {
|
|
564
|
-
identifier: d.identifier,
|
|
565
|
-
cardinality: d.cardinality as any,
|
|
566
|
-
baseType: d.baseType,
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// Discover all elements that match any standard extractor elementType.
|
|
571
|
-
// Extractors specify element types in QTI 2.x form (e.g., 'choiceInteraction').
|
|
572
|
-
// We use the mapper to convert to the appropriate form for this QTI version
|
|
573
|
-
// (e.g., 'choiceInteraction' for QTI 2.x, 'qti-choice-interaction' for QTI 3.0).
|
|
574
|
-
const tagSet = new Set<string>();
|
|
575
|
-
for (const ex of ALL_STANDARD_EXTRACTORS) {
|
|
576
|
-
for (const t of ex.elementTypes ?? []) {
|
|
577
|
-
// Convert to canonical form (lowercase), then to native form using mapper
|
|
578
|
-
const canonical = t.toLowerCase();
|
|
579
|
-
const native = this.mapper.toNative(canonical);
|
|
580
|
-
tagSet.add(native.toLowerCase());
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
const elements: QTIElement[] = [];
|
|
585
|
-
for (const tag of tagSet) {
|
|
586
|
-
try {
|
|
587
|
-
elements.push(...(root.querySelectorAll(tag) as any));
|
|
588
|
-
} catch {
|
|
589
|
-
// ignore selector errors
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
const interactions: InteractionData[] = [];
|
|
594
|
-
for (const el of elements) {
|
|
595
|
-
// Try both QTI 2.x (responseIdentifier) and QTI 3.0 (response-identifier) attribute names
|
|
596
|
-
const responseId = el.getAttribute?.('responseIdentifier') ||
|
|
597
|
-
el.getAttribute?.('response-identifier') ||
|
|
598
|
-
el.getAttribute?.('responseidentifier') ||
|
|
599
|
-
'';
|
|
600
|
-
if (!responseId) continue;
|
|
601
|
-
|
|
602
|
-
const ctx = createExtractionContext(el, responseId, root, declMap, this.config);
|
|
603
|
-
const res = this.extractionRegistry.extract<any>(el, ctx);
|
|
604
|
-
if (!res.success) continue;
|
|
605
|
-
|
|
606
|
-
// Normalize raw tag to QTI 2.x camelCase for ComponentRegistry compatibility.
|
|
607
|
-
// QTI 3.0 elements use kebab-case with 'qti-' prefix:
|
|
608
|
-
// 'qti-choice-interaction' → 'choiceInteraction'
|
|
609
|
-
const rawTag = el.rawTagName;
|
|
610
|
-
const normalizedType = rawTag.startsWith('qti-')
|
|
611
|
-
? rawTag.slice(4).replace(/-([a-z])/g, (_: string, c: string) => c.toUpperCase())
|
|
612
|
-
: rawTag;
|
|
613
|
-
|
|
614
|
-
interactions.push({
|
|
615
|
-
type: normalizedType as any,
|
|
616
|
-
responseId,
|
|
617
|
-
...res.data,
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// Apply URL policy + embed allowances to standard extracted URL fields.
|
|
622
|
-
const policy = this.config.security?.urlPolicy;
|
|
623
|
-
const allowObjectEmbeds = this.config.security?.allowObjectEmbeds === true;
|
|
624
|
-
const ttPolicyName = this.config.security?.trustedTypesPolicyName;
|
|
625
|
-
|
|
626
|
-
for (const i of interactions as any[]) {
|
|
627
|
-
// Wrap known HTML injection fields in TrustedHTML (when enabled).
|
|
628
|
-
// Important: do NOT wrap fields that are rendered as plain text in our Svelte components
|
|
629
|
-
// (e.g. prompt) to avoid "[object Object]" rendering.
|
|
630
|
-
if (i.type === 'choiceInteraction' && Array.isArray(i.choices)) {
|
|
631
|
-
for (const c of i.choices) {
|
|
632
|
-
if (typeof c?.text === 'string') c.text = toTrustedHtml(c.text, ttPolicyName);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// Shared ImageData shape
|
|
637
|
-
if (i.imageData?.src) {
|
|
638
|
-
i.imageData.src = sanitizeResourceUrl(i.imageData.src, policy, 'img') ?? '';
|
|
639
|
-
}
|
|
640
|
-
if (i.imageData?.content && typeof i.imageData.content === 'string') {
|
|
641
|
-
i.imageData.content = toTrustedHtml(i.imageData.content, ttPolicyName);
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// positionObject stages
|
|
645
|
-
if (Array.isArray(i.positionObjectStages)) {
|
|
646
|
-
for (const st of i.positionObjectStages) {
|
|
647
|
-
if (st?.objectData?.src) {
|
|
648
|
-
st.objectData.src = sanitizeResourceUrl(st.objectData.src, policy, 'img') ?? '';
|
|
649
|
-
}
|
|
650
|
-
if (st?.objectData?.content && typeof st.objectData.content === 'string') {
|
|
651
|
-
st.objectData.content = toTrustedHtml(st.objectData.content, ttPolicyName);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
// mediaInteraction
|
|
657
|
-
if (i.type === 'mediaInteraction' && i.mediaElement?.src) {
|
|
658
|
-
const kind = i.mediaElement.type === 'object' ? 'object' : 'media';
|
|
659
|
-
i.mediaElement.src = sanitizeResourceUrl(i.mediaElement.src, policy, kind) ?? '';
|
|
660
|
-
i.allowObjectEmbeds = allowObjectEmbeds;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
// hottextInteraction content is injected via {@html}
|
|
664
|
-
if (i.type === 'hottextInteraction' && typeof i.contentHtml === 'string') {
|
|
665
|
-
i.contentHtml = toTrustedHtml(i.contentHtml, ttPolicyName);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
return interactions;
|
|
549
|
+
return extractInteractionData({
|
|
550
|
+
document: this.itemDocument,
|
|
551
|
+
extractionRegistry: this.extractionRegistry,
|
|
552
|
+
declarations: this.decls,
|
|
553
|
+
config: this.config,
|
|
554
|
+
});
|
|
670
555
|
}
|
|
671
556
|
|
|
672
557
|
/**
|
|
@@ -698,7 +583,7 @@ export class Player {
|
|
|
698
583
|
}
|
|
699
584
|
|
|
700
585
|
public isAdaptive(): boolean {
|
|
701
|
-
return (
|
|
586
|
+
return (this.itemDocument.getAssessmentItemAttribute('adaptive') || '').toLowerCase() === 'true';
|
|
702
587
|
}
|
|
703
588
|
|
|
704
589
|
public getNumAttempts(): number {
|
|
@@ -1065,7 +950,7 @@ export class Player {
|
|
|
1065
950
|
// Declarations
|
|
1066
951
|
// ----------------------------------------------------------------------------
|
|
1067
952
|
|
|
1068
|
-
private buildDeclarations(
|
|
953
|
+
private buildDeclarations(): DeclarationMap {
|
|
1069
954
|
const decls: DeclarationMap = {};
|
|
1070
955
|
|
|
1071
956
|
const addDecl = (kind: DeclKind, el: Element) => {
|
|
@@ -1119,9 +1004,9 @@ export class Player {
|
|
|
1119
1004
|
}
|
|
1120
1005
|
};
|
|
1121
1006
|
|
|
1122
|
-
for (const el of
|
|
1123
|
-
for (const el of
|
|
1124
|
-
for (const el of
|
|
1007
|
+
for (const el of this.itemDocument.findDeclarationElements('response')) addDecl('response', el);
|
|
1008
|
+
for (const el of this.itemDocument.findDeclarationElements('outcome')) addDecl('outcome', el);
|
|
1009
|
+
for (const el of this.itemDocument.findDeclarationElements('template')) addDecl('template', el);
|
|
1125
1010
|
|
|
1126
1011
|
return decls;
|
|
1127
1012
|
}
|
|
@@ -1390,16 +1275,16 @@ export class Player {
|
|
|
1390
1275
|
}
|
|
1391
1276
|
|
|
1392
1277
|
private getModalFeedback(outcomes: Record<string, any>): ModalFeedback[] {
|
|
1393
|
-
const feedbackEls =
|
|
1278
|
+
const feedbackEls = this.itemDocument.findModalFeedbackElements();
|
|
1394
1279
|
const active: ModalFeedback[] = [];
|
|
1395
1280
|
|
|
1396
1281
|
for (const el of feedbackEls) {
|
|
1397
|
-
const identifier =
|
|
1398
|
-
const outcomeIdentifier =
|
|
1399
|
-
const showHide = (
|
|
1400
|
-
const title =
|
|
1282
|
+
const identifier = this.getAttrMapped(el, 'identifier') || '';
|
|
1283
|
+
const outcomeIdentifier = this.getAttrMapped(el, 'outcomeIdentifier') || '';
|
|
1284
|
+
const showHide = (this.getAttrMapped(el, 'showHide') || 'show') as 'show' | 'hide';
|
|
1285
|
+
const title = this.getAttrMapped(el, 'title') || undefined;
|
|
1401
1286
|
|
|
1402
|
-
const contentRaw =
|
|
1287
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
1403
1288
|
const sanitized = sanitizeHtml(contentRaw, { security: this.config.security });
|
|
1404
1289
|
const content = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
1405
1290
|
|
|
@@ -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';
|