@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
|
@@ -18,16 +18,18 @@ export interface ComponentConfig<TData extends InteractionData = InteractionData
|
|
|
18
18
|
* - 50: Moderately specific custom renderers
|
|
19
19
|
* - 10: Generic custom renderers
|
|
20
20
|
* - 0: Default fallback renderers
|
|
21
|
+
* Default: 0
|
|
21
22
|
*/
|
|
22
|
-
priority
|
|
23
|
+
priority?: number;
|
|
23
24
|
/** Optional description for debugging/error messages */
|
|
24
25
|
description?: string;
|
|
25
26
|
/**
|
|
26
27
|
* Predicate to determine if this component can handle the interaction
|
|
27
28
|
* Evaluated in priority order (highest first)
|
|
28
29
|
* @returns true if this component should be used
|
|
30
|
+
* Default: always true
|
|
29
31
|
*/
|
|
30
|
-
canHandle
|
|
32
|
+
canHandle?: (data: TData) => boolean;
|
|
31
33
|
/**
|
|
32
34
|
* Web component tag name (must contain a hyphen per web component spec)
|
|
33
35
|
* e.g., 'qti-choice-interaction', 'custom-rating-choice'
|
|
@@ -71,12 +73,11 @@ export declare class ComponentRegistry {
|
|
|
71
73
|
* // Default choice component
|
|
72
74
|
* registry.register('choiceInteraction', {
|
|
73
75
|
* name: 'standard-choice',
|
|
74
|
-
* priority: 0,
|
|
75
|
-
* canHandle: () => true,
|
|
76
76
|
* tagName: 'qti-choice-interaction'
|
|
77
77
|
* });
|
|
78
78
|
*/
|
|
79
79
|
register<TData extends InteractionData>(type: string, config: ComponentConfig<TData>): void;
|
|
80
|
+
private createRegisteredComponent;
|
|
80
81
|
/**
|
|
81
82
|
* Get a web component tag name for an interaction type
|
|
82
83
|
* Evaluates canHandle predicates in priority order
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../src/core/ComponentRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,SAAS,eAAe,GAAG,eAAe;IAC/E,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IAEb
|
|
1
|
+
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../src/core/ComponentRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,SAAS,eAAe,GAAG,eAAe;IAC/E,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IAErC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAE1C;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAYD;;GAEG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,UAAU,CAA4C;IAC9D,OAAO,CAAC,eAAe,CAAqB;IAE5C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,KAAK,SAAS,eAAe,EACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,GAC5B,IAAI;IA+BP,OAAO,CAAC,yBAAyB;IAYjC;;;;;;;OAOG;IACH,UAAU,CAAC,KAAK,SAAS,eAAe,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM;IAwC9D;;;OAGG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAInC;;;;;;;OAOG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAK9C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAEhB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC5C"}
|
|
@@ -34,8 +34,6 @@ export class ComponentRegistry {
|
|
|
34
34
|
* // Default choice component
|
|
35
35
|
* registry.register('choiceInteraction', {
|
|
36
36
|
* name: 'standard-choice',
|
|
37
|
-
* priority: 0,
|
|
38
|
-
* canHandle: () => true,
|
|
39
37
|
* tagName: 'qti-choice-interaction'
|
|
40
38
|
* });
|
|
41
39
|
*/
|
|
@@ -60,10 +58,19 @@ export class ComponentRegistry {
|
|
|
60
58
|
components = [];
|
|
61
59
|
this.components.set(type, components);
|
|
62
60
|
}
|
|
63
|
-
// Add component and sort by priority (highest first)
|
|
64
|
-
components.push(
|
|
61
|
+
// Add normalized component and sort by priority (highest first)
|
|
62
|
+
components.push(this.createRegisteredComponent(config));
|
|
65
63
|
components.sort((a, b) => b.config.priority - a.config.priority);
|
|
66
64
|
}
|
|
65
|
+
createRegisteredComponent(config) {
|
|
66
|
+
return {
|
|
67
|
+
config: {
|
|
68
|
+
...config,
|
|
69
|
+
priority: config.priority ?? 0,
|
|
70
|
+
canHandle: config.canHandle ?? (() => true),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
67
74
|
/**
|
|
68
75
|
* Get a web component tag name for an interaction type
|
|
69
76
|
* Evaluates canHandle predicates in priority order
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemRenderer.d.ts","sourceRoot":"","sources":["../../src/core/ItemRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ItemRenderer.d.ts","sourceRoot":"","sources":["../../src/core/ItemRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IAEf,oDAAoD;IACpD,SAAS,EAAE,WAAW,CAAC;IAEvB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,yEAAyE;IACzE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAEzC,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5D;AAED;;GAEG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAC,CAAiC;IACjD,OAAO,CAAC,gBAAgB,CAA2C;IAGnE,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,cAAc,CAId;IAGR,OAAO,CAAC,kBAAkB,CAAuB;gBAErC,MAAM,EAAE,kBAAkB;IAatC;;OAEG;IACI,MAAM,IAAI,IAAI;IA+DrB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAiChC;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IASjC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA0DhC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAYzD;;OAEG;IACI,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAS3C;;OAEG;IACI,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAI1C;;OAEG;IACH,OAAO,CAAC,OAAO;IAcf;;OAEG;IACI,OAAO,IAAI,IAAI;CAItB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAE3E"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { htmlToString, toTrustedHtml } from './trustedTypes.js';
|
|
9
9
|
import { applyGlossaryTriggers } from '../catalog/applyGlossaryTriggers.js';
|
|
10
|
+
import { createInlinePlaceholderHtml, isInlineInteractionType } from '../interactions/inline/render-plan.js';
|
|
10
11
|
/**
|
|
11
12
|
* ItemRenderer class manages the rendering of QTI items using web components
|
|
12
13
|
*/
|
|
@@ -39,7 +40,7 @@ export class ItemRenderer {
|
|
|
39
40
|
// Get and process interactions using the player's configured ExtractionRegistry
|
|
40
41
|
const interactions = this.player.getInteractionData();
|
|
41
42
|
// Filter block vs inline interactions
|
|
42
|
-
const blockInteractions = interactions.filter((
|
|
43
|
+
const blockInteractions = interactions.filter((interaction) => !isInlineInteractionType(interaction.type));
|
|
43
44
|
// Get item body HTML with interactions removed
|
|
44
45
|
const itemBodyHtml = this.getProcessedItemBodyHtml();
|
|
45
46
|
// Create prose container for body HTML
|
|
@@ -114,23 +115,9 @@ export class ItemRenderer {
|
|
|
114
115
|
* Replaces QTI XML tags with web component placeholders
|
|
115
116
|
*/
|
|
116
117
|
processInlineInteractions(html, interactions) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (interaction) {
|
|
121
|
-
return `<span data-inline-interaction="${responseId}" data-type="textEntry"></span>`;
|
|
122
|
-
}
|
|
123
|
-
return match;
|
|
124
|
-
});
|
|
125
|
-
// Replace inlineChoice with placeholder
|
|
126
|
-
html = html.replace(/<inlineChoiceInteraction[^>]*responseIdentifier="([^"]+)"[^>]*>[\s\S]*?<\/inlineChoiceInteraction>/gi, (match, responseId) => {
|
|
127
|
-
const interaction = interactions.find((i) => i.responseId === responseId && i.type === 'inlineChoiceInteraction');
|
|
128
|
-
if (interaction) {
|
|
129
|
-
return `<span data-inline-interaction="${responseId}" data-type="inlineChoice"></span>`;
|
|
130
|
-
}
|
|
131
|
-
return match;
|
|
132
|
-
});
|
|
133
|
-
return html;
|
|
118
|
+
return createInlinePlaceholderHtml(html, interactions)
|
|
119
|
+
.replace(/\[TEXTENTRY:([^\]]+)\]/g, '<span data-inline-interaction="$1" data-type="textEntry"></span>')
|
|
120
|
+
.replace(/\[INLINECHOICE:([^\]]+)\]/g, '<span data-inline-interaction="$1" data-type="inlineChoice"></span>');
|
|
134
121
|
}
|
|
135
122
|
/**
|
|
136
123
|
* Create a web component element for an interaction
|
package/dist/core/Player.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class Player {
|
|
|
11
11
|
private role;
|
|
12
12
|
private config;
|
|
13
13
|
private itemXml;
|
|
14
|
-
private
|
|
14
|
+
private itemDocument;
|
|
15
15
|
private assessmentItem;
|
|
16
16
|
private decls;
|
|
17
17
|
private ctx;
|
|
@@ -51,7 +51,7 @@ export declare class Player {
|
|
|
51
51
|
getCatalogEntry(idref: string, usage: string, lang?: string): string | null;
|
|
52
52
|
/**
|
|
53
53
|
* Create a PciHost for an extracted PCI and register it for response tracking.
|
|
54
|
-
* The caller
|
|
54
|
+
* The caller is responsible for calling host.load() and
|
|
55
55
|
* host.initialize(domNode) once the DOM element is available.
|
|
56
56
|
*/
|
|
57
57
|
createPciHost(data: ExtractedPci): PciHost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../../src/core/Player.ts"],"names":[],"mappings":"AAAA,OAAO,EAWN,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../../src/core/Player.ts"],"names":[],"mappings":"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"}
|
package/dist/core/Player.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { buildOutcomeProcessingAst, buildResponseProcessingAst, buildTemplateProcessingAst, childElements, coerceBaseValue, DeclarationContext, evalExpr, execProgram,
|
|
1
|
+
import { buildOutcomeProcessingAst, buildResponseProcessingAst, buildTemplateProcessingAst, childElements, coerceBaseValue, DeclarationContext, evalExpr, execProgram, findDescendants, findFirstDescendant, getAttr, OperatorRegistry, qtiNull, qtiValue, toBoolean, toNumber, toStringValue, } from '@pie-qti/qti-processing';
|
|
2
2
|
import { Qti2xElementNameMapper, Qti2xAttributeNameMapper, Qti3ElementNameMapper, Qti3AttributeNameMapper, detectQtiVersion, } from '@pie-qti/qti-common';
|
|
3
|
-
import {
|
|
3
|
+
import { parseAssessmentItemDocument } from '../document/AssessmentItemDocument.js';
|
|
4
4
|
import { createExtractionRegistry } from '../extraction/ExtractionRegistry.js';
|
|
5
|
-
import {
|
|
5
|
+
import { extractInteractionData } from '../extraction/interactionExtractionPipeline.js';
|
|
6
|
+
import { getStandardInteractionExtractors } from '../interactions/modules.js';
|
|
6
7
|
import { createComponentRegistry } from './ComponentRegistry.js';
|
|
7
|
-
import { enforceItemXmlLimits } from './parsingLimits.js';
|
|
8
8
|
import { createSeededRng } from './random.js';
|
|
9
9
|
import { sanitizeHtml } from './sanitizer.js';
|
|
10
10
|
import { toTrustedHtml } from './trustedTypes.js';
|
|
11
|
-
import { sanitizeResourceUrl } from './urlPolicy.js';
|
|
12
11
|
import { applyPnpToRoot } from '../pnp/applyPnp.js';
|
|
13
12
|
import { extractCatalogFromItemXml, mergeCatalogs } from '../catalog/catalogExtractor.js';
|
|
14
13
|
import { getCatalogEntry } from '../catalog/catalogLookup.js';
|
|
@@ -46,12 +45,21 @@ export class Player {
|
|
|
46
45
|
}
|
|
47
46
|
else {
|
|
48
47
|
this.mapper = config.elementNameMapper;
|
|
48
|
+
if (!config.attributeNameMapper) {
|
|
49
|
+
config.attributeNameMapper =
|
|
50
|
+
this.mapper.version === '3.0'
|
|
51
|
+
? new Qti3AttributeNameMapper()
|
|
52
|
+
: new Qti2xAttributeNameMapper();
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
this.itemDocument = parseAssessmentItemDocument({
|
|
56
|
+
itemXml: this.itemXml,
|
|
57
|
+
elementNameMapper: this.mapper,
|
|
58
|
+
attributeNameMapper: config.attributeNameMapper,
|
|
59
|
+
security: this.config.security,
|
|
60
|
+
});
|
|
61
|
+
this.assessmentItem = this.itemDocument.getAssessmentItem();
|
|
62
|
+
this.decls = this.buildDeclarations();
|
|
55
63
|
this.ensureBuiltinDeclarations(this.decls);
|
|
56
64
|
this.ctx = new DeclarationContext(this.decls);
|
|
57
65
|
this.ops = new OperatorRegistry();
|
|
@@ -65,8 +73,8 @@ export class Player {
|
|
|
65
73
|
this.componentRegistry = config.componentRegistry ?? createComponentRegistry();
|
|
66
74
|
// I18n provider (defaults to a simple fallback if not provided)
|
|
67
75
|
this.i18nProvider = config.i18nProvider ?? this.createDefaultI18nProvider();
|
|
68
|
-
// Register standard extractors (idempotent per-registry instance)
|
|
69
|
-
for (const ex of
|
|
76
|
+
// Register standard interaction extractors (idempotent per-registry instance)
|
|
77
|
+
for (const ex of getStandardInteractionExtractors()) {
|
|
70
78
|
try {
|
|
71
79
|
this.extractionRegistry.register(ex);
|
|
72
80
|
}
|
|
@@ -85,20 +93,20 @@ export class Player {
|
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
// Build ASTs once.
|
|
88
|
-
const templateProcessing =
|
|
96
|
+
const templateProcessing = this.itemDocument.getProcessingElement('template');
|
|
89
97
|
if (templateProcessing) {
|
|
90
98
|
this.templateProcessingProgram = buildTemplateProcessingAst(templateProcessing, {
|
|
91
99
|
elementNameMapper: this.mapper,
|
|
92
100
|
});
|
|
93
101
|
this.execTemplateProcessing();
|
|
94
102
|
}
|
|
95
|
-
const responseProcessing =
|
|
103
|
+
const responseProcessing = this.itemDocument.getProcessingElement('response');
|
|
96
104
|
if (responseProcessing) {
|
|
97
105
|
this.responseProcessingProgram = buildResponseProcessingAst(responseProcessing, {
|
|
98
106
|
elementNameMapper: this.mapper,
|
|
99
107
|
});
|
|
100
108
|
}
|
|
101
|
-
const outcomeProcessing =
|
|
109
|
+
const outcomeProcessing = this.itemDocument.getProcessingElement('outcome');
|
|
102
110
|
if (outcomeProcessing) {
|
|
103
111
|
this.outcomeProcessingProgram = buildOutcomeProcessingAst(outcomeProcessing, {
|
|
104
112
|
elementNameMapper: this.mapper,
|
|
@@ -170,7 +178,7 @@ export class Player {
|
|
|
170
178
|
}
|
|
171
179
|
/**
|
|
172
180
|
* Create a PciHost for an extracted PCI and register it for response tracking.
|
|
173
|
-
* The caller
|
|
181
|
+
* The caller is responsible for calling host.load() and
|
|
174
182
|
* host.initialize(domNode) once the DOM element is available.
|
|
175
183
|
*/
|
|
176
184
|
createPciHost(data) {
|
|
@@ -241,7 +249,7 @@ export class Player {
|
|
|
241
249
|
// This prevents stale outcomes when response/outcome processing doesn't set every variable.
|
|
242
250
|
this.resetOutcomesToDefault();
|
|
243
251
|
// Execute response processing if present
|
|
244
|
-
const rpEl =
|
|
252
|
+
const rpEl = this.itemDocument.getProcessingElement('response');
|
|
245
253
|
if (rpEl) {
|
|
246
254
|
// If responseProcessing has explicit statements, run the compiled program.
|
|
247
255
|
// Otherwise, fall back to template-based processing (responseProcessing@template).
|
|
@@ -387,11 +395,9 @@ export class Player {
|
|
|
387
395
|
}
|
|
388
396
|
}
|
|
389
397
|
getItemBodyHtml() {
|
|
390
|
-
const
|
|
391
|
-
if (!
|
|
398
|
+
const inner = this.itemDocument.serializeItemBodyChildren();
|
|
399
|
+
if (!inner)
|
|
392
400
|
return '';
|
|
393
|
-
// Serialize children rather than the container tag itself.
|
|
394
|
-
const inner = childElements(itemBody).map((c) => serializeXml(c)).join('');
|
|
395
401
|
const printed = this.renderPrintedVariables(inner);
|
|
396
402
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
397
403
|
return toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -404,7 +410,7 @@ export class Player {
|
|
|
404
410
|
*/
|
|
405
411
|
getRubrics() {
|
|
406
412
|
const role = this.role;
|
|
407
|
-
const rubricEls =
|
|
413
|
+
const rubricEls = this.itemDocument.findRubricElements();
|
|
408
414
|
if (rubricEls.length === 0)
|
|
409
415
|
return [];
|
|
410
416
|
const blocks = [];
|
|
@@ -414,8 +420,7 @@ export class Player {
|
|
|
414
420
|
// If view is specified, show only when it includes the current role.
|
|
415
421
|
if (view.length > 0 && role && !view.includes(role))
|
|
416
422
|
continue;
|
|
417
|
-
|
|
418
|
-
const contentRaw = childElements(el).map((c) => serializeXml(c)).join('') || (el.textContent || '');
|
|
423
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
419
424
|
const printed = this.renderPrintedVariables(contentRaw);
|
|
420
425
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
421
426
|
const html = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -433,118 +438,12 @@ export class Player {
|
|
|
433
438
|
* Canonical interaction API (new): extracted, typed interaction data.
|
|
434
439
|
*/
|
|
435
440
|
getInteractionData() {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
const docRoot = parse(this.itemXml, { lowerCaseTagName: false, comment: false });
|
|
443
|
-
// node-html-parser's CSS selectors match lowercase tag names.
|
|
444
|
-
// Search for itemBody in the native form for this QTI version (itembody for 2.x, qti-item-body for 3.0)
|
|
445
|
-
const itemBodyTag = this.mapper.toNative('itembody').toLowerCase();
|
|
446
|
-
const parsedItemBody = docRoot.querySelector?.(itemBodyTag) ?? null;
|
|
447
|
-
const root = parsedItemBody ?? docRoot;
|
|
448
|
-
const declMap = new Map();
|
|
449
|
-
for (const d of Object.values(this.decls)) {
|
|
450
|
-
declMap.set(d.identifier, {
|
|
451
|
-
identifier: d.identifier,
|
|
452
|
-
cardinality: d.cardinality,
|
|
453
|
-
baseType: d.baseType,
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
// Discover all elements that match any standard extractor elementType.
|
|
457
|
-
// Extractors specify element types in QTI 2.x form (e.g., 'choiceInteraction').
|
|
458
|
-
// We use the mapper to convert to the appropriate form for this QTI version
|
|
459
|
-
// (e.g., 'choiceInteraction' for QTI 2.x, 'qti-choice-interaction' for QTI 3.0).
|
|
460
|
-
const tagSet = new Set();
|
|
461
|
-
for (const ex of ALL_STANDARD_EXTRACTORS) {
|
|
462
|
-
for (const t of ex.elementTypes ?? []) {
|
|
463
|
-
// Convert to canonical form (lowercase), then to native form using mapper
|
|
464
|
-
const canonical = t.toLowerCase();
|
|
465
|
-
const native = this.mapper.toNative(canonical);
|
|
466
|
-
tagSet.add(native.toLowerCase());
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
const elements = [];
|
|
470
|
-
for (const tag of tagSet) {
|
|
471
|
-
try {
|
|
472
|
-
elements.push(...root.querySelectorAll(tag));
|
|
473
|
-
}
|
|
474
|
-
catch {
|
|
475
|
-
// ignore selector errors
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
const interactions = [];
|
|
479
|
-
for (const el of elements) {
|
|
480
|
-
// Try both QTI 2.x (responseIdentifier) and QTI 3.0 (response-identifier) attribute names
|
|
481
|
-
const responseId = el.getAttribute?.('responseIdentifier') ||
|
|
482
|
-
el.getAttribute?.('response-identifier') ||
|
|
483
|
-
el.getAttribute?.('responseidentifier') ||
|
|
484
|
-
'';
|
|
485
|
-
if (!responseId)
|
|
486
|
-
continue;
|
|
487
|
-
const ctx = createExtractionContext(el, responseId, root, declMap, this.config);
|
|
488
|
-
const res = this.extractionRegistry.extract(el, ctx);
|
|
489
|
-
if (!res.success)
|
|
490
|
-
continue;
|
|
491
|
-
// Normalize raw tag to QTI 2.x camelCase for ComponentRegistry compatibility.
|
|
492
|
-
// QTI 3.0 elements use kebab-case with 'qti-' prefix:
|
|
493
|
-
// 'qti-choice-interaction' → 'choiceInteraction'
|
|
494
|
-
const rawTag = el.rawTagName;
|
|
495
|
-
const normalizedType = rawTag.startsWith('qti-')
|
|
496
|
-
? rawTag.slice(4).replace(/-([a-z])/g, (_, c) => c.toUpperCase())
|
|
497
|
-
: rawTag;
|
|
498
|
-
interactions.push({
|
|
499
|
-
type: normalizedType,
|
|
500
|
-
responseId,
|
|
501
|
-
...res.data,
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
// Apply URL policy + embed allowances to standard extracted URL fields.
|
|
505
|
-
const policy = this.config.security?.urlPolicy;
|
|
506
|
-
const allowObjectEmbeds = this.config.security?.allowObjectEmbeds === true;
|
|
507
|
-
const ttPolicyName = this.config.security?.trustedTypesPolicyName;
|
|
508
|
-
for (const i of interactions) {
|
|
509
|
-
// Wrap known HTML injection fields in TrustedHTML (when enabled).
|
|
510
|
-
// Important: do NOT wrap fields that are rendered as plain text in our Svelte components
|
|
511
|
-
// (e.g. prompt) to avoid "[object Object]" rendering.
|
|
512
|
-
if (i.type === 'choiceInteraction' && Array.isArray(i.choices)) {
|
|
513
|
-
for (const c of i.choices) {
|
|
514
|
-
if (typeof c?.text === 'string')
|
|
515
|
-
c.text = toTrustedHtml(c.text, ttPolicyName);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
// Shared ImageData shape
|
|
519
|
-
if (i.imageData?.src) {
|
|
520
|
-
i.imageData.src = sanitizeResourceUrl(i.imageData.src, policy, 'img') ?? '';
|
|
521
|
-
}
|
|
522
|
-
if (i.imageData?.content && typeof i.imageData.content === 'string') {
|
|
523
|
-
i.imageData.content = toTrustedHtml(i.imageData.content, ttPolicyName);
|
|
524
|
-
}
|
|
525
|
-
// positionObject stages
|
|
526
|
-
if (Array.isArray(i.positionObjectStages)) {
|
|
527
|
-
for (const st of i.positionObjectStages) {
|
|
528
|
-
if (st?.objectData?.src) {
|
|
529
|
-
st.objectData.src = sanitizeResourceUrl(st.objectData.src, policy, 'img') ?? '';
|
|
530
|
-
}
|
|
531
|
-
if (st?.objectData?.content && typeof st.objectData.content === 'string') {
|
|
532
|
-
st.objectData.content = toTrustedHtml(st.objectData.content, ttPolicyName);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
// mediaInteraction
|
|
537
|
-
if (i.type === 'mediaInteraction' && i.mediaElement?.src) {
|
|
538
|
-
const kind = i.mediaElement.type === 'object' ? 'object' : 'media';
|
|
539
|
-
i.mediaElement.src = sanitizeResourceUrl(i.mediaElement.src, policy, kind) ?? '';
|
|
540
|
-
i.allowObjectEmbeds = allowObjectEmbeds;
|
|
541
|
-
}
|
|
542
|
-
// hottextInteraction content is injected via {@html}
|
|
543
|
-
if (i.type === 'hottextInteraction' && typeof i.contentHtml === 'string') {
|
|
544
|
-
i.contentHtml = toTrustedHtml(i.contentHtml, ttPolicyName);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return interactions;
|
|
441
|
+
return extractInteractionData({
|
|
442
|
+
document: this.itemDocument,
|
|
443
|
+
extractionRegistry: this.extractionRegistry,
|
|
444
|
+
declarations: this.decls,
|
|
445
|
+
config: this.config,
|
|
446
|
+
});
|
|
548
447
|
}
|
|
549
448
|
/**
|
|
550
449
|
* Convenience API (used by tests/bench): returns a minimal interaction list with QTI-ish field names.
|
|
@@ -571,7 +470,7 @@ export class Player {
|
|
|
571
470
|
return this.getResponseInteractions().map((i) => i.responseIdentifier);
|
|
572
471
|
}
|
|
573
472
|
isAdaptive() {
|
|
574
|
-
return (
|
|
473
|
+
return (this.itemDocument.getAssessmentItemAttribute('adaptive') || '').toLowerCase() === 'true';
|
|
575
474
|
}
|
|
576
475
|
getNumAttempts() {
|
|
577
476
|
return Math.max(0, Math.floor(toNumber(this.ctx.getValue('numAttempts')) || 0));
|
|
@@ -906,7 +805,7 @@ export class Player {
|
|
|
906
805
|
// ----------------------------------------------------------------------------
|
|
907
806
|
// Declarations
|
|
908
807
|
// ----------------------------------------------------------------------------
|
|
909
|
-
buildDeclarations(
|
|
808
|
+
buildDeclarations() {
|
|
910
809
|
const decls = {};
|
|
911
810
|
const addDecl = (kind, el) => {
|
|
912
811
|
const identifier = this.getAttrMapped(el, 'identifier');
|
|
@@ -956,11 +855,11 @@ export class Player {
|
|
|
956
855
|
}
|
|
957
856
|
}
|
|
958
857
|
};
|
|
959
|
-
for (const el of
|
|
858
|
+
for (const el of this.itemDocument.findDeclarationElements('response'))
|
|
960
859
|
addDecl('response', el);
|
|
961
|
-
for (const el of
|
|
860
|
+
for (const el of this.itemDocument.findDeclarationElements('outcome'))
|
|
962
861
|
addDecl('outcome', el);
|
|
963
|
-
for (const el of
|
|
862
|
+
for (const el of this.itemDocument.findDeclarationElements('template'))
|
|
964
863
|
addDecl('template', el);
|
|
965
864
|
return decls;
|
|
966
865
|
}
|
|
@@ -1204,14 +1103,14 @@ export class Player {
|
|
|
1204
1103
|
return out;
|
|
1205
1104
|
}
|
|
1206
1105
|
getModalFeedback(outcomes) {
|
|
1207
|
-
const feedbackEls =
|
|
1106
|
+
const feedbackEls = this.itemDocument.findModalFeedbackElements();
|
|
1208
1107
|
const active = [];
|
|
1209
1108
|
for (const el of feedbackEls) {
|
|
1210
|
-
const identifier =
|
|
1211
|
-
const outcomeIdentifier =
|
|
1212
|
-
const showHide = (
|
|
1213
|
-
const title =
|
|
1214
|
-
const contentRaw =
|
|
1109
|
+
const identifier = this.getAttrMapped(el, 'identifier') || '';
|
|
1110
|
+
const outcomeIdentifier = this.getAttrMapped(el, 'outcomeIdentifier') || '';
|
|
1111
|
+
const showHide = (this.getAttrMapped(el, 'showHide') || 'show');
|
|
1112
|
+
const title = this.getAttrMapped(el, 'title') || undefined;
|
|
1113
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
1215
1114
|
const sanitized = sanitizeHtml(contentRaw, { security: this.config.security });
|
|
1216
1115
|
const content = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
1217
1116
|
const outcomeValue = outcomes[outcomeIdentifier];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AttributeNameMapper, ElementNameMapper } from '@pie-qti/qti-common';
|
|
2
|
+
import type { PlayerSecurityConfig } from '../types/index.js';
|
|
3
|
+
import type { QTIElement } from '../types/interactions.js';
|
|
4
|
+
export type ProcessingKind = 'template' | 'response' | 'outcome';
|
|
5
|
+
export interface DiscoveredInteractionElement {
|
|
6
|
+
element: QTIElement;
|
|
7
|
+
contextRoot: QTIElement;
|
|
8
|
+
responseIdentifier: string;
|
|
9
|
+
normalizedType: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AssessmentItemDocumentInput {
|
|
12
|
+
itemXml: string;
|
|
13
|
+
elementNameMapper: ElementNameMapper;
|
|
14
|
+
attributeNameMapper: AttributeNameMapper;
|
|
15
|
+
security?: PlayerSecurityConfig;
|
|
16
|
+
}
|
|
17
|
+
export declare class AssessmentItemDocument {
|
|
18
|
+
private readonly itemXml;
|
|
19
|
+
private readonly security?;
|
|
20
|
+
readonly elementNameMapper: ElementNameMapper;
|
|
21
|
+
readonly attributeNameMapper: AttributeNameMapper;
|
|
22
|
+
private readonly xmlDocument;
|
|
23
|
+
private readonly assessmentItem;
|
|
24
|
+
private extractionDocument;
|
|
25
|
+
private extractionRoot;
|
|
26
|
+
constructor({ itemXml, elementNameMapper, attributeNameMapper, security, }: AssessmentItemDocumentInput);
|
|
27
|
+
getAssessmentItem(): Element;
|
|
28
|
+
getProcessingElement(kind: ProcessingKind): Element | null;
|
|
29
|
+
serializeItemBodyChildren(): string;
|
|
30
|
+
findRubricElements(): Element[];
|
|
31
|
+
findModalFeedbackElements(): Element[];
|
|
32
|
+
findDeclarationElements(kind: 'response' | 'outcome' | 'template'): Element[];
|
|
33
|
+
getAssessmentItemAttribute(name: string): string | null;
|
|
34
|
+
serializeChildren(element: Element): string;
|
|
35
|
+
findExtractionElements(elementTypes: Iterable<string>): DiscoveredInteractionElement[];
|
|
36
|
+
private getExtractionRoot;
|
|
37
|
+
private getExtractionDocument;
|
|
38
|
+
private walkExtractionChildren;
|
|
39
|
+
private getExtractionResponseIdentifier;
|
|
40
|
+
}
|
|
41
|
+
export declare function parseAssessmentItemDocument(input: AssessmentItemDocumentInput): AssessmentItemDocument;
|
|
42
|
+
//# sourceMappingURL=AssessmentItemDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssessmentItemDocument.d.ts","sourceRoot":"","sources":["../../src/document/AssessmentItemDocument.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAYlF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,4BAA4B;IAC5C,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,2BAA2B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED,qBAAa,sBAAsB;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAuB;IACjD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAW;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IACzC,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,cAAc,CAA2B;gBAErC,EACX,OAAO,EACP,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,GACR,EAAE,2BAA2B;IAW9B,iBAAiB,IAAI,OAAO;IAI5B,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAU1D,yBAAyB,IAAI,MAAM;IASnC,kBAAkB,IAAI,OAAO,EAAE;IAI/B,yBAAyB,IAAI,OAAO,EAAE;IAItC,uBAAuB,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,EAAE;IAU7E,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIvD,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAI3C,sBAAsB,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,4BAA4B,EAAE;IA4BtF,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,+BAA+B;CAUvC;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,2BAA2B,GAAG,sBAAsB,CAEtG"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { childElements, findAssessmentItem, findDescendants, findFirstDescendant, parseXml, serializeXml, } from '@pie-qti/qti-processing';
|
|
2
|
+
import { parse } from 'node-html-parser';
|
|
3
|
+
import { enforceItemXmlLimits } from '../core/parsingLimits.js';
|
|
4
|
+
import { normalizeInteractionTypeFromTagName } from '../interactions/modules.js';
|
|
5
|
+
export class AssessmentItemDocument {
|
|
6
|
+
constructor({ itemXml, elementNameMapper, attributeNameMapper, security, }) {
|
|
7
|
+
this.extractionDocument = null;
|
|
8
|
+
this.extractionRoot = null;
|
|
9
|
+
this.itemXml = itemXml;
|
|
10
|
+
this.security = security;
|
|
11
|
+
this.elementNameMapper = elementNameMapper;
|
|
12
|
+
this.attributeNameMapper = attributeNameMapper;
|
|
13
|
+
enforceItemXmlLimits(this.itemXml, this.security);
|
|
14
|
+
this.xmlDocument = parseXml(this.itemXml);
|
|
15
|
+
this.assessmentItem = findAssessmentItem(this.xmlDocument);
|
|
16
|
+
}
|
|
17
|
+
getAssessmentItem() {
|
|
18
|
+
return this.assessmentItem;
|
|
19
|
+
}
|
|
20
|
+
getProcessingElement(kind) {
|
|
21
|
+
const tagName = kind === 'template'
|
|
22
|
+
? 'templateprocessing'
|
|
23
|
+
: kind === 'response'
|
|
24
|
+
? 'responseprocessing'
|
|
25
|
+
: 'outcomeprocessing';
|
|
26
|
+
return findFirstDescendant(this.assessmentItem, this.elementNameMapper.toNative(tagName));
|
|
27
|
+
}
|
|
28
|
+
serializeItemBodyChildren() {
|
|
29
|
+
const itemBody = findFirstDescendant(this.assessmentItem, this.elementNameMapper.toNative('itembody'));
|
|
30
|
+
if (!itemBody)
|
|
31
|
+
return '';
|
|
32
|
+
return this.serializeChildren(itemBody);
|
|
33
|
+
}
|
|
34
|
+
findRubricElements() {
|
|
35
|
+
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative('rubricblock'));
|
|
36
|
+
}
|
|
37
|
+
findModalFeedbackElements() {
|
|
38
|
+
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative('modalfeedback'));
|
|
39
|
+
}
|
|
40
|
+
findDeclarationElements(kind) {
|
|
41
|
+
const tagName = kind === 'response'
|
|
42
|
+
? 'responsedeclaration'
|
|
43
|
+
: kind === 'outcome'
|
|
44
|
+
? 'outcomedeclaration'
|
|
45
|
+
: 'templatedeclaration';
|
|
46
|
+
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative(tagName));
|
|
47
|
+
}
|
|
48
|
+
getAssessmentItemAttribute(name) {
|
|
49
|
+
return this.assessmentItem.getAttribute(this.attributeNameMapper.toNative(name));
|
|
50
|
+
}
|
|
51
|
+
serializeChildren(element) {
|
|
52
|
+
return childElements(element).map((child) => serializeXml(child)).join('');
|
|
53
|
+
}
|
|
54
|
+
findExtractionElements(elementTypes) {
|
|
55
|
+
const root = this.getExtractionRoot();
|
|
56
|
+
if (!root)
|
|
57
|
+
return [];
|
|
58
|
+
const canonicalTypes = new Set([...elementTypes].map((elementType) => this.elementNameMapper.toCanonical(elementType)));
|
|
59
|
+
const elements = [];
|
|
60
|
+
this.walkExtractionChildren(root, (element) => {
|
|
61
|
+
const rawTagName = element.rawTagName;
|
|
62
|
+
if (!rawTagName)
|
|
63
|
+
return;
|
|
64
|
+
if (!canonicalTypes.has(this.elementNameMapper.toCanonical(rawTagName)))
|
|
65
|
+
return;
|
|
66
|
+
const responseIdentifier = this.getExtractionResponseIdentifier(element);
|
|
67
|
+
if (!responseIdentifier)
|
|
68
|
+
return;
|
|
69
|
+
elements.push({
|
|
70
|
+
element,
|
|
71
|
+
contextRoot: root,
|
|
72
|
+
responseIdentifier,
|
|
73
|
+
normalizedType: normalizeInteractionTypeFromTagName(rawTagName),
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return elements;
|
|
77
|
+
}
|
|
78
|
+
getExtractionRoot() {
|
|
79
|
+
if (this.extractionRoot)
|
|
80
|
+
return this.extractionRoot;
|
|
81
|
+
const docRoot = this.getExtractionDocument();
|
|
82
|
+
const itemBodyTag = this.elementNameMapper.toNative('itembody').toLowerCase();
|
|
83
|
+
this.extractionRoot = docRoot.querySelector?.(itemBodyTag) ?? null;
|
|
84
|
+
return this.extractionRoot;
|
|
85
|
+
}
|
|
86
|
+
getExtractionDocument() {
|
|
87
|
+
if (!this.extractionDocument) {
|
|
88
|
+
enforceItemXmlLimits(this.itemXml, this.security);
|
|
89
|
+
this.extractionDocument = parse(this.itemXml, {
|
|
90
|
+
lowerCaseTagName: false,
|
|
91
|
+
comment: false,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return this.extractionDocument;
|
|
95
|
+
}
|
|
96
|
+
walkExtractionChildren(root, visit) {
|
|
97
|
+
for (const child of root.childNodes ?? []) {
|
|
98
|
+
const element = child;
|
|
99
|
+
if (!element.rawTagName)
|
|
100
|
+
continue;
|
|
101
|
+
visit(element);
|
|
102
|
+
this.walkExtractionChildren(element, visit);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
getExtractionResponseIdentifier(element) {
|
|
106
|
+
const nativeName = this.attributeNameMapper.toNative('responseIdentifier');
|
|
107
|
+
return (element.getAttribute?.('responseIdentifier') ||
|
|
108
|
+
element.getAttribute?.(nativeName) ||
|
|
109
|
+
element.getAttribute?.('response-identifier') ||
|
|
110
|
+
element.getAttribute?.('responseidentifier') ||
|
|
111
|
+
'');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export function parseAssessmentItemDocument(input) {
|
|
115
|
+
return new AssessmentItemDocument(input);
|
|
116
|
+
}
|