@pie-qti/item-player 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/applyGlossaryTriggers.d.ts +2 -1
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
- package/dist/catalog/applyGlossaryTriggers.js +145 -30
- package/dist/catalog/glossaryAction.d.ts.map +1 -1
- package/dist/catalog/glossaryAction.js +14 -4
- package/dist/components/utils/stimulusRender.d.ts +17 -0
- package/dist/components/utils/stimulusRender.d.ts.map +1 -0
- package/dist/components/utils/stimulusRender.js +70 -0
- package/dist/components/utils/stylesheetRender.d.ts +4 -0
- package/dist/components/utils/stylesheetRender.d.ts.map +1 -0
- package/dist/components/utils/stylesheetRender.js +57 -0
- package/dist/core/ComponentRegistry.d.ts +5 -4
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +11 -4
- package/dist/core/ItemRenderer.d.ts.map +1 -1
- package/dist/core/ItemRenderer.js +5 -18
- package/dist/core/Player.d.ts +39 -4
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +364 -193
- package/dist/document/AssessmentItemDocument.d.ts +42 -0
- package/dist/document/AssessmentItemDocument.d.ts.map +1 -0
- package/dist/document/AssessmentItemDocument.js +116 -0
- package/dist/element.js +3318 -2733
- package/dist/element.js.map +1 -1
- package/dist/extraction/extractors/associateExtractor.d.ts +1 -28
- package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/associateExtractor.js +1 -97
- package/dist/extraction/extractors/choiceExtractor.d.ts +1 -26
- package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/choiceExtractor.js +1 -93
- package/dist/extraction/extractors/customExtractor.d.ts +1 -19
- package/dist/extraction/extractors/customExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/customExtractor.js +1 -51
- package/dist/extraction/extractors/drawingExtractor.d.ts +1 -29
- package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/drawingExtractor.js +1 -78
- package/dist/extraction/extractors/endAttemptExtractor.d.ts +1 -19
- package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/endAttemptExtractor.js +1 -53
- package/dist/extraction/extractors/extendedTextExtractor.d.ts +1 -20
- package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/extendedTextExtractor.js +1 -63
- package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -28
- package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/gapMatchExtractor.js +1 -155
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -40
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicAssociateExtractor.js +1 -143
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +1 -52
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicGapMatchExtractor.js +1 -205
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts +1 -36
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicOrderExtractor.js +1 -121
- package/dist/extraction/extractors/hotspotExtractor.d.ts +1 -37
- package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/hotspotExtractor.js +1 -159
- package/dist/extraction/extractors/hottextExtractor.d.ts +1 -25
- package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/hottextExtractor.js +1 -128
- package/dist/extraction/extractors/index.d.ts +5 -59
- package/dist/extraction/extractors/index.d.ts.map +1 -1
- package/dist/extraction/extractors/index.js +5 -85
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +1 -24
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/inlineChoiceExtractor.js +1 -80
- package/dist/extraction/extractors/matchExtractor.d.ts +1 -36
- package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/matchExtractor.js +1 -160
- package/dist/extraction/extractors/mediaExtractor.d.ts +1 -32
- package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/mediaExtractor.js +1 -125
- package/dist/extraction/extractors/orderExtractor.d.ts +1 -27
- package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/orderExtractor.js +1 -90
- package/dist/extraction/extractors/portableCustomExtractor.d.ts +1 -13
- package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/portableCustomExtractor.js +1 -96
- package/dist/extraction/extractors/positionObjectExtractor.d.ts +1 -58
- package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/positionObjectExtractor.js +1 -191
- package/dist/extraction/extractors/selectPointExtractor.d.ts +1 -30
- package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/selectPointExtractor.js +1 -109
- package/dist/extraction/extractors/sliderExtractor.d.ts +1 -23
- package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/sliderExtractor.js +1 -73
- package/dist/extraction/extractors/textEntryExtractor.d.ts +1 -20
- package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/textEntryExtractor.js +1 -54
- package/dist/extraction/extractors/uploadExtractor.d.ts +1 -19
- package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/uploadExtractor.js +1 -59
- package/dist/extraction/index.d.ts +1 -1
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +2 -2
- package/dist/extraction/interactionExtractionPipeline.d.ts +13 -0
- package/dist/extraction/interactionExtractionPipeline.d.ts.map +1 -0
- package/dist/extraction/interactionExtractionPipeline.js +39 -0
- package/dist/extraction/interactionSecurity.d.ts +4 -0
- package/dist/extraction/interactionSecurity.d.ts.map +1 -0
- package/dist/extraction/interactionSecurity.js +48 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/interactions/associate/extractor.d.ts +29 -0
- package/dist/interactions/associate/extractor.d.ts.map +1 -0
- package/dist/interactions/associate/extractor.js +97 -0
- package/dist/interactions/associate/index.d.ts +3 -0
- package/dist/interactions/associate/index.d.ts.map +1 -0
- package/dist/interactions/associate/index.js +1 -0
- package/dist/interactions/associate/types.d.ts +2 -0
- package/dist/interactions/associate/types.d.ts.map +1 -0
- package/dist/interactions/associate/types.js +1 -0
- package/dist/interactions/choice/extractor.d.ts +27 -0
- package/dist/interactions/choice/extractor.d.ts.map +1 -0
- package/dist/interactions/choice/extractor.js +93 -0
- package/dist/interactions/choice/index.d.ts +3 -0
- package/dist/interactions/choice/index.d.ts.map +1 -0
- package/dist/interactions/choice/index.js +1 -0
- package/dist/interactions/choice/types.d.ts +2 -0
- package/dist/interactions/choice/types.d.ts.map +1 -0
- package/dist/interactions/choice/types.js +1 -0
- package/dist/interactions/custom/extractor.d.ts +20 -0
- package/dist/interactions/custom/extractor.d.ts.map +1 -0
- package/dist/interactions/custom/extractor.js +51 -0
- package/dist/interactions/custom/index.d.ts +3 -0
- package/dist/interactions/custom/index.d.ts.map +1 -0
- package/dist/interactions/custom/index.js +1 -0
- package/dist/interactions/custom/types.d.ts +2 -0
- package/dist/interactions/custom/types.d.ts.map +1 -0
- package/dist/interactions/custom/types.js +1 -0
- package/dist/interactions/drawing/extractor.d.ts +30 -0
- package/dist/interactions/drawing/extractor.d.ts.map +1 -0
- package/dist/interactions/drawing/extractor.js +78 -0
- package/dist/interactions/drawing/index.d.ts +3 -0
- package/dist/interactions/drawing/index.d.ts.map +1 -0
- package/dist/interactions/drawing/index.js +1 -0
- package/dist/interactions/drawing/types.d.ts +2 -0
- package/dist/interactions/drawing/types.d.ts.map +1 -0
- package/dist/interactions/drawing/types.js +1 -0
- package/dist/interactions/end-attempt/extractor.d.ts +20 -0
- package/dist/interactions/end-attempt/extractor.d.ts.map +1 -0
- package/dist/interactions/end-attempt/extractor.js +53 -0
- package/dist/interactions/end-attempt/index.d.ts +3 -0
- package/dist/interactions/end-attempt/index.d.ts.map +1 -0
- package/dist/interactions/end-attempt/index.js +1 -0
- package/dist/interactions/end-attempt/types.d.ts +2 -0
- package/dist/interactions/end-attempt/types.d.ts.map +1 -0
- package/dist/interactions/end-attempt/types.js +1 -0
- package/dist/interactions/extended-text/extractor.d.ts +21 -0
- package/dist/interactions/extended-text/extractor.d.ts.map +1 -0
- package/dist/interactions/extended-text/extractor.js +63 -0
- package/dist/interactions/extended-text/index.d.ts +3 -0
- package/dist/interactions/extended-text/index.d.ts.map +1 -0
- package/dist/interactions/extended-text/index.js +1 -0
- package/dist/interactions/extended-text/types.d.ts +2 -0
- package/dist/interactions/extended-text/types.d.ts.map +1 -0
- package/dist/interactions/extended-text/types.js +1 -0
- package/dist/interactions/gap-match/extractor.d.ts +29 -0
- package/dist/interactions/gap-match/extractor.d.ts.map +1 -0
- package/dist/interactions/gap-match/extractor.js +155 -0
- package/dist/interactions/gap-match/index.d.ts +3 -0
- package/dist/interactions/gap-match/index.d.ts.map +1 -0
- package/dist/interactions/gap-match/index.js +1 -0
- package/dist/interactions/gap-match/types.d.ts +2 -0
- package/dist/interactions/gap-match/types.d.ts.map +1 -0
- package/dist/interactions/gap-match/types.js +1 -0
- package/dist/interactions/graphic-associate/extractor.d.ts +41 -0
- package/dist/interactions/graphic-associate/extractor.d.ts.map +1 -0
- package/dist/interactions/graphic-associate/extractor.js +143 -0
- package/dist/interactions/graphic-associate/index.d.ts +3 -0
- package/dist/interactions/graphic-associate/index.d.ts.map +1 -0
- package/dist/interactions/graphic-associate/index.js +1 -0
- package/dist/interactions/graphic-associate/types.d.ts +2 -0
- package/dist/interactions/graphic-associate/types.d.ts.map +1 -0
- package/dist/interactions/graphic-associate/types.js +1 -0
- package/dist/interactions/graphic-gap-match/extractor.d.ts +53 -0
- package/dist/interactions/graphic-gap-match/extractor.d.ts.map +1 -0
- package/dist/interactions/graphic-gap-match/extractor.js +205 -0
- package/dist/interactions/graphic-gap-match/index.d.ts +3 -0
- package/dist/interactions/graphic-gap-match/index.d.ts.map +1 -0
- package/dist/interactions/graphic-gap-match/index.js +1 -0
- package/dist/interactions/graphic-gap-match/types.d.ts +2 -0
- package/dist/interactions/graphic-gap-match/types.d.ts.map +1 -0
- package/dist/interactions/graphic-gap-match/types.js +1 -0
- package/dist/interactions/graphic-order/extractor.d.ts +37 -0
- package/dist/interactions/graphic-order/extractor.d.ts.map +1 -0
- package/dist/interactions/graphic-order/extractor.js +121 -0
- package/dist/interactions/graphic-order/index.d.ts +3 -0
- package/dist/interactions/graphic-order/index.d.ts.map +1 -0
- package/dist/interactions/graphic-order/index.js +1 -0
- package/dist/interactions/graphic-order/types.d.ts +2 -0
- package/dist/interactions/graphic-order/types.d.ts.map +1 -0
- package/dist/interactions/graphic-order/types.js +1 -0
- package/dist/interactions/hotspot/extractor.d.ts +38 -0
- package/dist/interactions/hotspot/extractor.d.ts.map +1 -0
- package/dist/interactions/hotspot/extractor.js +159 -0
- package/dist/interactions/hotspot/index.d.ts +3 -0
- package/dist/interactions/hotspot/index.d.ts.map +1 -0
- package/dist/interactions/hotspot/index.js +1 -0
- package/dist/interactions/hotspot/types.d.ts +2 -0
- package/dist/interactions/hotspot/types.d.ts.map +1 -0
- package/dist/interactions/hotspot/types.js +1 -0
- package/dist/interactions/hottext/extractor.d.ts +26 -0
- package/dist/interactions/hottext/extractor.d.ts.map +1 -0
- package/dist/interactions/hottext/extractor.js +128 -0
- package/dist/interactions/hottext/index.d.ts +3 -0
- package/dist/interactions/hottext/index.d.ts.map +1 -0
- package/dist/interactions/hottext/index.js +1 -0
- package/dist/interactions/hottext/types.d.ts +2 -0
- package/dist/interactions/hottext/types.d.ts.map +1 -0
- package/dist/interactions/hottext/types.js +1 -0
- package/dist/interactions/index.d.ts +33 -0
- package/dist/interactions/index.d.ts.map +1 -0
- package/dist/interactions/index.js +30 -0
- package/dist/interactions/inline/index.d.ts +2 -0
- package/dist/interactions/inline/index.d.ts.map +1 -0
- package/dist/interactions/inline/index.js +1 -0
- package/dist/interactions/inline/render-plan.d.ts +19 -0
- package/dist/interactions/inline/render-plan.d.ts.map +1 -0
- package/dist/interactions/inline/render-plan.js +59 -0
- package/dist/interactions/inline-choice/extractor.d.ts +25 -0
- package/dist/interactions/inline-choice/extractor.d.ts.map +1 -0
- package/dist/interactions/inline-choice/extractor.js +80 -0
- package/dist/interactions/inline-choice/index.d.ts +3 -0
- package/dist/interactions/inline-choice/index.d.ts.map +1 -0
- package/dist/interactions/inline-choice/index.js +1 -0
- package/dist/interactions/inline-choice/types.d.ts +2 -0
- package/dist/interactions/inline-choice/types.d.ts.map +1 -0
- package/dist/interactions/inline-choice/types.js +1 -0
- package/dist/interactions/match/extractor.d.ts +37 -0
- package/dist/interactions/match/extractor.d.ts.map +1 -0
- package/dist/interactions/match/extractor.js +160 -0
- package/dist/interactions/match/index.d.ts +3 -0
- package/dist/interactions/match/index.d.ts.map +1 -0
- package/dist/interactions/match/index.js +1 -0
- package/dist/interactions/match/types.d.ts +2 -0
- package/dist/interactions/match/types.d.ts.map +1 -0
- package/dist/interactions/match/types.js +1 -0
- package/dist/interactions/media/extractor.d.ts +33 -0
- package/dist/interactions/media/extractor.d.ts.map +1 -0
- package/dist/interactions/media/extractor.js +125 -0
- package/dist/interactions/media/index.d.ts +3 -0
- package/dist/interactions/media/index.d.ts.map +1 -0
- package/dist/interactions/media/index.js +1 -0
- package/dist/interactions/media/types.d.ts +2 -0
- package/dist/interactions/media/types.d.ts.map +1 -0
- package/dist/interactions/media/types.js +1 -0
- package/dist/interactions/modules.d.ts +105 -0
- package/dist/interactions/modules.d.ts.map +1 -0
- package/dist/interactions/modules.js +86 -0
- package/dist/interactions/order/extractor.d.ts +28 -0
- package/dist/interactions/order/extractor.d.ts.map +1 -0
- package/dist/interactions/order/extractor.js +90 -0
- package/dist/interactions/order/index.d.ts +3 -0
- package/dist/interactions/order/index.d.ts.map +1 -0
- package/dist/interactions/order/index.js +1 -0
- package/dist/interactions/order/types.d.ts +2 -0
- package/dist/interactions/order/types.d.ts.map +1 -0
- package/dist/interactions/order/types.js +1 -0
- package/dist/interactions/portable-custom/extractor.d.ts +14 -0
- package/dist/interactions/portable-custom/extractor.d.ts.map +1 -0
- package/dist/interactions/portable-custom/extractor.js +96 -0
- package/dist/interactions/portable-custom/index.d.ts +3 -0
- package/dist/interactions/portable-custom/index.d.ts.map +1 -0
- package/dist/interactions/portable-custom/index.js +1 -0
- package/dist/interactions/portable-custom/types.d.ts +2 -0
- package/dist/interactions/portable-custom/types.d.ts.map +1 -0
- package/dist/interactions/portable-custom/types.js +1 -0
- package/dist/interactions/position-object/extractor.d.ts +59 -0
- package/dist/interactions/position-object/extractor.d.ts.map +1 -0
- package/dist/interactions/position-object/extractor.js +191 -0
- package/dist/interactions/position-object/index.d.ts +3 -0
- package/dist/interactions/position-object/index.d.ts.map +1 -0
- package/dist/interactions/position-object/index.js +1 -0
- package/dist/interactions/position-object/types.d.ts +2 -0
- package/dist/interactions/position-object/types.d.ts.map +1 -0
- package/dist/interactions/position-object/types.js +1 -0
- package/dist/interactions/select-point/extractor.d.ts +31 -0
- package/dist/interactions/select-point/extractor.d.ts.map +1 -0
- package/dist/interactions/select-point/extractor.js +109 -0
- package/dist/interactions/select-point/index.d.ts +3 -0
- package/dist/interactions/select-point/index.d.ts.map +1 -0
- package/dist/interactions/select-point/index.js +1 -0
- package/dist/interactions/select-point/types.d.ts +2 -0
- package/dist/interactions/select-point/types.d.ts.map +1 -0
- package/dist/interactions/select-point/types.js +1 -0
- package/dist/interactions/shared/index.d.ts +2 -0
- package/dist/interactions/shared/index.d.ts.map +1 -0
- package/dist/interactions/shared/index.js +1 -0
- package/dist/interactions/shared/types.d.ts +412 -0
- package/dist/interactions/shared/types.d.ts.map +1 -0
- package/dist/interactions/shared/types.js +7 -0
- package/dist/interactions/slider/extractor.d.ts +24 -0
- package/dist/interactions/slider/extractor.d.ts.map +1 -0
- package/dist/interactions/slider/extractor.js +73 -0
- package/dist/interactions/slider/index.d.ts +3 -0
- package/dist/interactions/slider/index.d.ts.map +1 -0
- package/dist/interactions/slider/index.js +1 -0
- package/dist/interactions/slider/types.d.ts +2 -0
- package/dist/interactions/slider/types.d.ts.map +1 -0
- package/dist/interactions/slider/types.js +1 -0
- package/dist/interactions/text-entry/extractor.d.ts +21 -0
- package/dist/interactions/text-entry/extractor.d.ts.map +1 -0
- package/dist/interactions/text-entry/extractor.js +54 -0
- package/dist/interactions/text-entry/index.d.ts +3 -0
- package/dist/interactions/text-entry/index.d.ts.map +1 -0
- package/dist/interactions/text-entry/index.js +1 -0
- package/dist/interactions/text-entry/types.d.ts +2 -0
- package/dist/interactions/text-entry/types.d.ts.map +1 -0
- package/dist/interactions/text-entry/types.js +1 -0
- package/dist/interactions/upload/extractor.d.ts +20 -0
- package/dist/interactions/upload/extractor.d.ts.map +1 -0
- package/dist/interactions/upload/extractor.js +59 -0
- package/dist/interactions/upload/index.d.ts +3 -0
- package/dist/interactions/upload/index.d.ts.map +1 -0
- package/dist/interactions/upload/index.js +1 -0
- package/dist/interactions/upload/types.d.ts +2 -0
- package/dist/interactions/upload/types.d.ts.map +1 -0
- package/dist/interactions/upload/types.js +1 -0
- package/dist/pnp/applyPnp.d.ts.map +1 -1
- package/dist/pnp/applyPnp.js +9 -2
- package/dist/pnp/parsePnpXml.d.ts.map +1 -1
- package/dist/pnp/parsePnpXml.js +91 -3
- package/dist/pnp/types.d.ts +24 -1
- package/dist/pnp/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +47 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interactions.d.ts +4 -408
- package/dist/types/interactions.d.ts.map +1 -1
- package/dist/types/interactions.js +3 -3
- package/dist/web-components/QTIInteractionBase.d.ts +5 -5
- package/dist/web-components/QTIInteractionBase.d.ts.map +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +11 -8
- package/dist/web-components/QTIInteractionElement.d.ts.map +1 -1
- package/dist/web-components/index.d.ts +1 -1
- package/dist/web-components/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/catalog/applyGlossaryTriggers.ts +174 -34
- package/src/catalog/glossaryAction.ts +14 -4
- package/src/components/ItemBody.svelte +71 -200
- package/src/components/ItemPlayer.svelte +9 -5
- package/src/components/ModalFeedbackDisplay.svelte +15 -5
- package/src/components/utils/stimulusRender.ts +93 -0
- package/src/components/utils/stylesheetRender.ts +58 -0
- package/src/core/ComponentRegistry.ts +22 -7
- package/src/core/Player.ts +401 -209
- package/src/document/AssessmentItemDocument.ts +178 -0
- package/src/extraction/extractors/associateExtractor.ts +1 -133
- package/src/extraction/extractors/choiceExtractor.ts +1 -121
- package/src/extraction/extractors/customExtractor.ts +1 -72
- package/src/extraction/extractors/drawingExtractor.ts +1 -113
- package/src/extraction/extractors/endAttemptExtractor.ts +1 -74
- package/src/extraction/extractors/extendedTextExtractor.ts +1 -89
- package/src/extraction/extractors/gapMatchExtractor.ts +1 -193
- package/src/extraction/extractors/graphicAssociateExtractor.ts +1 -192
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +1 -257
- package/src/extraction/extractors/graphicOrderExtractor.ts +1 -162
- package/src/extraction/extractors/hotspotExtractor.ts +1 -208
- package/src/extraction/extractors/hottextExtractor.ts +1 -163
- package/src/extraction/extractors/index.ts +5 -111
- package/src/extraction/extractors/inlineChoiceExtractor.ts +1 -105
- package/src/extraction/extractors/matchExtractor.ts +1 -187
- package/src/extraction/extractors/mediaExtractor.ts +1 -168
- package/src/extraction/extractors/orderExtractor.ts +1 -120
- package/src/extraction/extractors/portableCustomExtractor.ts +1 -122
- package/src/extraction/extractors/positionObjectExtractor.ts +1 -243
- package/src/extraction/extractors/selectPointExtractor.ts +1 -143
- package/src/extraction/extractors/sliderExtractor.ts +1 -102
- package/src/extraction/extractors/textEntryExtractor.ts +1 -79
- package/src/extraction/extractors/uploadExtractor.ts +1 -81
- package/src/extraction/index.ts +1 -2
- package/src/extraction/interactionExtractionPipeline.ts +70 -0
- package/src/extraction/interactionSecurity.ts +60 -0
- package/src/index.ts +3 -7
- package/src/interactions/associate/extractor.ts +133 -0
- package/src/interactions/associate/index.ts +2 -0
- package/src/interactions/associate/types.ts +1 -0
- package/src/interactions/choice/extractor.ts +121 -0
- package/src/interactions/choice/index.ts +2 -0
- package/src/interactions/choice/types.ts +1 -0
- package/src/interactions/custom/extractor.ts +72 -0
- package/src/interactions/custom/index.ts +2 -0
- package/src/interactions/custom/types.ts +1 -0
- package/src/interactions/drawing/extractor.ts +113 -0
- package/src/interactions/drawing/index.ts +2 -0
- package/src/interactions/drawing/types.ts +1 -0
- package/src/interactions/end-attempt/extractor.ts +74 -0
- package/src/interactions/end-attempt/index.ts +2 -0
- package/src/interactions/end-attempt/types.ts +1 -0
- package/src/interactions/extended-text/extractor.ts +89 -0
- package/src/interactions/extended-text/index.ts +2 -0
- package/src/interactions/extended-text/types.ts +1 -0
- package/src/interactions/gap-match/extractor.ts +193 -0
- package/src/interactions/gap-match/index.ts +2 -0
- package/src/interactions/gap-match/types.ts +1 -0
- package/src/interactions/graphic-associate/extractor.ts +192 -0
- package/src/interactions/graphic-associate/index.ts +2 -0
- package/src/interactions/graphic-associate/types.ts +1 -0
- package/src/interactions/graphic-gap-match/extractor.ts +257 -0
- package/src/interactions/graphic-gap-match/index.ts +2 -0
- package/src/interactions/graphic-gap-match/types.ts +1 -0
- package/src/interactions/graphic-order/extractor.ts +162 -0
- package/src/interactions/graphic-order/index.ts +2 -0
- package/src/interactions/graphic-order/types.ts +1 -0
- package/src/interactions/hotspot/extractor.ts +208 -0
- package/src/interactions/hotspot/index.ts +2 -0
- package/src/interactions/hotspot/types.ts +1 -0
- package/src/interactions/hottext/extractor.ts +163 -0
- package/src/interactions/hottext/index.ts +2 -0
- package/src/interactions/hottext/types.ts +1 -0
- package/src/interactions/index.ts +52 -0
- package/src/interactions/inline/index.ts +1 -0
- package/src/interactions/inline/render-plan.ts +105 -0
- package/src/interactions/inline-choice/InlineChoice.svelte +57 -0
- package/src/interactions/inline-choice/extractor.ts +105 -0
- package/src/interactions/inline-choice/index.ts +2 -0
- package/src/interactions/inline-choice/types.ts +1 -0
- package/src/interactions/match/extractor.ts +187 -0
- package/src/interactions/match/index.ts +2 -0
- package/src/interactions/match/types.ts +1 -0
- package/src/interactions/media/extractor.ts +168 -0
- package/src/interactions/media/index.ts +2 -0
- package/src/interactions/media/types.ts +1 -0
- package/src/interactions/modules.ts +111 -0
- package/src/interactions/order/extractor.ts +120 -0
- package/src/interactions/order/index.ts +2 -0
- package/src/interactions/order/types.ts +1 -0
- package/src/interactions/portable-custom/extractor.ts +122 -0
- package/src/interactions/portable-custom/index.ts +2 -0
- package/src/interactions/portable-custom/types.ts +1 -0
- package/src/interactions/position-object/extractor.ts +243 -0
- package/src/interactions/position-object/index.ts +2 -0
- package/src/interactions/position-object/types.ts +1 -0
- package/src/interactions/select-point/extractor.ts +143 -0
- package/src/interactions/select-point/index.ts +2 -0
- package/src/interactions/select-point/types.ts +1 -0
- package/src/interactions/shared/index.ts +1 -0
- package/src/interactions/shared/types.ts +429 -0
- package/src/interactions/slider/extractor.ts +102 -0
- package/src/interactions/slider/index.ts +2 -0
- package/src/interactions/slider/types.ts +1 -0
- package/src/interactions/text-entry/InlineTextEntry.svelte +75 -0
- package/src/interactions/text-entry/extractor.ts +79 -0
- package/src/interactions/text-entry/index.ts +2 -0
- package/src/interactions/text-entry/types.ts +1 -0
- package/src/interactions/upload/extractor.ts +81 -0
- package/src/interactions/upload/index.ts +2 -0
- package/src/interactions/upload/types.ts +1 -0
- package/src/pnp/applyPnp.ts +8 -2
- package/src/pnp/parsePnpXml.ts +102 -5
- package/src/pnp/types.ts +43 -1
- package/src/types/index.ts +53 -0
- package/src/types/interactions.ts +4 -425
- package/src/web-components/QTIInteractionBase.ts +6 -5
- package/src/web-components/QTIInteractionElement.ts +15 -8
- package/src/web-components/index.ts +1 -0
- package/src/__tests__/glossaryTriggers.test.ts +0 -411
- package/src/__tests__/pnp.test.ts +0 -250
- package/src/core/ItemRenderer.ts +0 -371
|
@@ -1,26 +1,46 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
let nextItemBodyScopeId = 0;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
1
5
|
<script lang="ts">
|
|
2
6
|
import type { InteractionData } from '../types';
|
|
3
7
|
import type { Player } from '../core/Player';
|
|
8
|
+
import type { InteractionResponseValue, QTIChangeEventDetail } from '../web-components';
|
|
4
9
|
import type { I18nProvider } from '@pie-qti/i18n';
|
|
5
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
normalizeHeuristicsConfig,
|
|
12
|
+
type QtiHeuristicsConfig,
|
|
13
|
+
type ResolvedItemDeliveryContext
|
|
14
|
+
} from '@pie-qti/ims-cp-core';
|
|
6
15
|
import { processFeedbackInline } from './utils/feedbackUtils';
|
|
7
16
|
import { typesetAction } from './actions/typesetAction';
|
|
8
17
|
import { glossaryAction } from '../catalog/glossaryAction';
|
|
9
18
|
import { assignProps } from './utils/assignProps';
|
|
19
|
+
import { buildScopedStylesheetCss } from './utils/stylesheetRender';
|
|
20
|
+
import { buildEffectiveStimulusContent, injectStimulusContent } from './utils/stimulusRender';
|
|
10
21
|
import { getRoleCapabilities } from '../core/rolePolicy';
|
|
22
|
+
import InlineChoice from '../interactions/inline-choice/InlineChoice.svelte';
|
|
23
|
+
import InlineTextEntry from '../interactions/text-entry/InlineTextEntry.svelte';
|
|
24
|
+
import { createInlineRenderPlan, isInlineInteractionTagName, isInlineInteractionType } from '../interactions/inline/render-plan';
|
|
25
|
+
|
|
26
|
+
type ItemResponseValue = InteractionResponseValue | null;
|
|
27
|
+
type ItemResponseMap = Record<string, ItemResponseValue>;
|
|
28
|
+
type QtiChangeDomEvent = CustomEvent<QTIChangeEventDetail<ItemResponseValue>>;
|
|
11
29
|
|
|
12
30
|
interface Props {
|
|
13
31
|
player: Player;
|
|
14
|
-
responses?:
|
|
32
|
+
responses?: ItemResponseMap;
|
|
15
33
|
disabled?: boolean;
|
|
16
34
|
role?: 'candidate' | 'scorer' | 'author' | 'tutor' | 'proctor' | 'testConstructor';
|
|
17
35
|
i18n?: I18nProvider;
|
|
18
36
|
typeset?: (element: HTMLElement) => void;
|
|
19
|
-
onResponseChange?: (responseId: string, value:
|
|
37
|
+
onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
|
|
20
38
|
outcomeValues?: Record<string, any>; // Needed for feedbackInline visibility
|
|
21
39
|
heuristicsConfig?: QtiHeuristicsConfig; // Optional heuristics configuration
|
|
22
40
|
/** QTI 3.0 shared stimulus content: map of stimulus identifier → HTML string */
|
|
23
41
|
stimulusContent?: Record<string, string>;
|
|
42
|
+
/** Package/assessment-resolved QTI 3 delivery context. */
|
|
43
|
+
deliveryContext?: ResolvedItemDeliveryContext;
|
|
24
44
|
}
|
|
25
45
|
|
|
26
46
|
let {
|
|
@@ -34,7 +54,10 @@
|
|
|
34
54
|
outcomeValues = {},
|
|
35
55
|
heuristicsConfig,
|
|
36
56
|
stimulusContent = {},
|
|
57
|
+
deliveryContext,
|
|
37
58
|
}: Props = $props();
|
|
59
|
+
const itemBodyScope = `qti-item-body-${++nextItemBodyScopeId}`;
|
|
60
|
+
const itemBodyScopeSelector = `[data-qti-item-body-scope="${itemBodyScope}"]`;
|
|
38
61
|
|
|
39
62
|
// Normalize heuristics configuration with defaults
|
|
40
63
|
const heuristics = $derived(normalizeHeuristicsConfig(heuristicsConfig));
|
|
@@ -58,8 +81,7 @@
|
|
|
58
81
|
interactions
|
|
59
82
|
.filter(
|
|
60
83
|
(interaction) =>
|
|
61
|
-
interaction.type
|
|
62
|
-
interaction.type !== 'inlineChoiceInteraction'
|
|
84
|
+
!isInlineInteractionType(interaction.type)
|
|
63
85
|
)
|
|
64
86
|
.map((interaction) => {
|
|
65
87
|
try {
|
|
@@ -82,58 +104,19 @@
|
|
|
82
104
|
// Inline interactions are replaced with placeholders
|
|
83
105
|
const itemBodyHtml = $derived.by(() => {
|
|
84
106
|
let html = player.getItemBodyHtml();
|
|
107
|
+
const resolvedDeliveryContext = deliveryContext ?? player.getDeliveryContext();
|
|
108
|
+
const stylesheetCss = buildScopedStylesheetCss(resolvedDeliveryContext, itemBodyScopeSelector);
|
|
109
|
+
const effectiveStimulusContent = buildEffectiveStimulusContent(
|
|
110
|
+
resolvedDeliveryContext,
|
|
111
|
+
stimulusContent,
|
|
112
|
+
(content) => player.sanitizeHtmlContent(content)
|
|
113
|
+
);
|
|
85
114
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const docked = new Set<string>();
|
|
90
|
-
// Replace docking divs: <div ... data-stimulus-idref="ID" ...></div>
|
|
91
|
-
html = html.replace(
|
|
92
|
-
/<div([^>]*)\bdata-stimulus-idref="([^"]+)"([^>]*)>\s*<\/div>/gi,
|
|
93
|
-
(match, before, identifier, after) => {
|
|
94
|
-
const content = stimulusContent[identifier];
|
|
95
|
-
if (content) {
|
|
96
|
-
docked.add(identifier);
|
|
97
|
-
// Preserve any other attributes on the docking div
|
|
98
|
-
return `<div${before} data-stimulus-idref="${identifier}"${after} class="qti-stimulus-dock">${content}</div>`;
|
|
99
|
-
}
|
|
100
|
-
return match; // no content found — leave as-is
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
// Prepend any stimuli that had no docking div
|
|
104
|
-
const undocked = Object.entries(stimulusContent)
|
|
105
|
-
.filter(([id]) => !docked.has(id))
|
|
106
|
-
.map(([, content]) => `<div class="qti-stimulus-block">${content}</div>`)
|
|
107
|
-
.join('');
|
|
108
|
-
if (undocked) {
|
|
109
|
-
html = undocked + html;
|
|
110
|
-
}
|
|
115
|
+
html = injectStimulusContent(html, effectiveStimulusContent);
|
|
116
|
+
if (stylesheetCss) {
|
|
117
|
+
html = `<style data-qti-stylesheets="resolved">${stylesheetCss}</style>${html}`;
|
|
111
118
|
}
|
|
112
119
|
|
|
113
|
-
// Replace inline interactions with placeholders (they need to be rendered in-flow).
|
|
114
|
-
// Handles both QTI 2.x camelCase and QTI 3.0 kebab-case element names.
|
|
115
|
-
html = html
|
|
116
|
-
// QTI 2.x: <textEntryInteraction responseIdentifier="..." />
|
|
117
|
-
.replace(
|
|
118
|
-
/<textEntryInteraction[^>]*responseIdentifier="([^"]+)"[^>]*?(?:\/>|><\/textEntryInteraction>)/gi,
|
|
119
|
-
'[TEXTENTRY:$1]'
|
|
120
|
-
)
|
|
121
|
-
// QTI 3.0: <qti-text-entry-interaction response-identifier="..." />
|
|
122
|
-
.replace(
|
|
123
|
-
/<qti-text-entry-interaction[^>]*response-identifier="([^"]+)"[^>]*?(?:\/>|><\/qti-text-entry-interaction>)/gi,
|
|
124
|
-
'[TEXTENTRY:$1]'
|
|
125
|
-
)
|
|
126
|
-
// QTI 2.x: <inlineChoiceInteraction responseIdentifier="...">...</inlineChoiceInteraction>
|
|
127
|
-
.replace(
|
|
128
|
-
/<inlineChoiceInteraction[^>]*responseIdentifier="([^"]+)"[^>]*>[\s\S]*?<\/inlineChoiceInteraction>/gi,
|
|
129
|
-
'[INLINECHOICE:$1]'
|
|
130
|
-
)
|
|
131
|
-
// QTI 3.0: <qti-inline-choice-interaction response-identifier="...">...</qti-inline-choice-interaction>
|
|
132
|
-
.replace(
|
|
133
|
-
/<qti-inline-choice-interaction[^>]*response-identifier="([^"]+)"[^>]*>[\s\S]*?<\/qti-inline-choice-interaction>/gi,
|
|
134
|
-
'[INLINECHOICE:$1]'
|
|
135
|
-
);
|
|
136
|
-
|
|
137
120
|
// Process feedbackInline elements - conditionally show/hide based on outcome values
|
|
138
121
|
html = processFeedbackInline(html, {
|
|
139
122
|
outcomeValues,
|
|
@@ -147,9 +130,8 @@
|
|
|
147
130
|
/<(\w+Interaction|qti-[\w-]+-interaction)(\s[^>]*)?>[\s\S]*?<\/\1>/gi,
|
|
148
131
|
(match, tagName) => {
|
|
149
132
|
const lower = tagName.toLowerCase();
|
|
150
|
-
//
|
|
151
|
-
if (lower
|
|
152
|
-
lower === 'qti-text-entry-interaction' || lower === 'qti-inline-choice-interaction') {
|
|
133
|
+
// Inline interactions are rendered in-flow by the inline render plan.
|
|
134
|
+
if (isInlineInteractionTagName(lower)) {
|
|
153
135
|
return match;
|
|
154
136
|
}
|
|
155
137
|
// Wrap block interactions with a hidden span
|
|
@@ -160,95 +142,19 @@
|
|
|
160
142
|
return html;
|
|
161
143
|
});
|
|
162
144
|
|
|
163
|
-
|
|
164
|
-
// around component props inference in runes mode.
|
|
165
|
-
interface ParsedSegment {
|
|
166
|
-
type: 'html' | 'textEntry' | 'inlineChoice';
|
|
167
|
-
content?: string;
|
|
168
|
-
interaction?: any;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const inlineSegments = $derived.by(() => {
|
|
172
|
-
const html = itemBodyHtml;
|
|
173
|
-
const result: ParsedSegment[] = [];
|
|
174
|
-
|
|
175
|
-
let lastIndex = 0;
|
|
176
|
-
let match: RegExpExecArray | null;
|
|
177
|
-
|
|
178
|
-
// Find placeholders in order.
|
|
179
|
-
const combinedPattern = /\[TEXTENTRY:([^\]]+)\]|\[INLINECHOICE:([^\]]+)\]/g;
|
|
180
|
-
|
|
181
|
-
while ((match = combinedPattern.exec(html)) !== null) {
|
|
182
|
-
if (match.index > lastIndex) {
|
|
183
|
-
result.push({ type: 'html', content: html.substring(lastIndex, match.index) });
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (match[0].startsWith('[TEXTENTRY:')) {
|
|
187
|
-
const responseId = match[1];
|
|
188
|
-
const interaction = (interactions as any[]).find((i) => i.responseId === responseId);
|
|
189
|
-
if (interaction) result.push({ type: 'textEntry', interaction });
|
|
190
|
-
} else if (match[0].startsWith('[INLINECHOICE:')) {
|
|
191
|
-
const responseId = match[2];
|
|
192
|
-
const interaction = (interactions as any[]).find((i) => i.responseId === responseId);
|
|
193
|
-
if (interaction) result.push({ type: 'inlineChoice', interaction });
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
lastIndex = match.index + match[0].length;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (lastIndex < html.length) {
|
|
200
|
-
result.push({ type: 'html', content: html.substring(lastIndex) });
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (result.length === 0) {
|
|
204
|
-
result.push({ type: 'html', content: html });
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return result;
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
function handleResponseChange(responseId: string, value: any) {
|
|
211
|
-
onResponseChange(responseId, value);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
let textEntryErrors = $state<Map<string, string>>(new Map());
|
|
145
|
+
const inlineSegments = $derived(createInlineRenderPlan(itemBodyHtml, interactions));
|
|
215
146
|
|
|
216
|
-
function
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
handleResponseChange(responseId, value);
|
|
220
|
-
if (input?.validity.valid) {
|
|
221
|
-
const m = new Map(textEntryErrors);
|
|
222
|
-
m.delete(responseId);
|
|
223
|
-
textEntryErrors = m;
|
|
224
|
-
}
|
|
147
|
+
function getStringResponse(responseId: string): string {
|
|
148
|
+
const response = responses[responseId];
|
|
149
|
+
return typeof response === 'string' ? response : '';
|
|
225
150
|
}
|
|
226
151
|
|
|
227
|
-
function
|
|
228
|
-
|
|
229
|
-
const msg = customMessage
|
|
230
|
-
?? i18n?.t('interactions.textEntry.patternError', 'Please match the required format')
|
|
231
|
-
?? 'Please match the required format';
|
|
232
|
-
textEntryErrors = new Map(textEntryErrors).set(responseId, msg);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function handleTextEntryBlur(e: Event) {
|
|
236
|
-
(e.currentTarget as HTMLInputElement | null)?.checkValidity();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function handleInlineChoiceChange(responseId: string, e: Event) {
|
|
240
|
-
const value = (e.currentTarget as HTMLSelectElement | null)?.value ?? '';
|
|
241
|
-
handleResponseChange(responseId, value);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Helper to find correct choice for inline choice interactions
|
|
245
|
-
function findCorrectChoice(choices: any[], correctAnswer: string | null): any {
|
|
246
|
-
if (!correctAnswer) return null;
|
|
247
|
-
return choices.find((c: any) => c.identifier === correctAnswer) || null;
|
|
152
|
+
function handleResponseChange(responseId: string, value: ItemResponseValue) {
|
|
153
|
+
onResponseChange(responseId, value);
|
|
248
154
|
}
|
|
249
155
|
|
|
250
156
|
// Handle qti:change events from web components
|
|
251
|
-
function handleQtiChange(event:
|
|
157
|
+
function handleQtiChange(event: QtiChangeDomEvent) {
|
|
252
158
|
const { responseId, value } = event.detail;
|
|
253
159
|
handleResponseChange(responseId, value);
|
|
254
160
|
}
|
|
@@ -258,7 +164,8 @@
|
|
|
258
164
|
let rootEl: HTMLDivElement | null = $state(null);
|
|
259
165
|
$effect(() => {
|
|
260
166
|
if (!rootEl) return;
|
|
261
|
-
|
|
167
|
+
player.applyPnp(rootEl);
|
|
168
|
+
const handler = (e: Event) => handleQtiChange(e as QtiChangeDomEvent);
|
|
262
169
|
const el = rootEl; // Capture reference for cleanup
|
|
263
170
|
el.addEventListener('qti-change', handler as EventListener);
|
|
264
171
|
return () => {
|
|
@@ -309,7 +216,13 @@
|
|
|
309
216
|
}
|
|
310
217
|
</script>
|
|
311
218
|
|
|
312
|
-
<div
|
|
219
|
+
<div
|
|
220
|
+
bind:this={rootEl}
|
|
221
|
+
class="qti-item-body"
|
|
222
|
+
data-qti-item-body-scope={itemBodyScope}
|
|
223
|
+
use:typesetAction={{ typeset }}
|
|
224
|
+
use:glossaryAction={{ player }}
|
|
225
|
+
>
|
|
313
226
|
<!-- Item body with inline interactions -->
|
|
314
227
|
<div class="prose max-w-none mb-4">
|
|
315
228
|
<div class="inline-interaction-container">
|
|
@@ -318,68 +231,24 @@
|
|
|
318
231
|
{@html segment.content}
|
|
319
232
|
{:else if segment.type === 'textEntry'}
|
|
320
233
|
{@const correctAnswer = roleCapabilities.canViewCorrectResponses ? (correctResponses[segment.interaction.responseId] ?? null) : null}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
type="text"
|
|
326
|
-
class={['input input-bordered input-sm inline-input', inputWidthClass ?? '', extraClasses].filter(Boolean).join(' ')}
|
|
327
|
-
class:border-success={correctAnswer !== null}
|
|
328
|
-
class:bg-success={correctAnswer !== null}
|
|
329
|
-
class:bg-opacity-10={correctAnswer !== null}
|
|
330
|
-
style={inputWidthClass ? 'min-width: 100px; display: inline-block; margin: 0 4px;' : `width: ${segment.interaction.expectedLength * 8}px; min-width: 100px; display: inline-block; margin: 0 4px;`}
|
|
331
|
-
placeholder={segment.interaction.placeholderText || '...'}
|
|
332
|
-
pattern={segment.interaction.patternMask || undefined}
|
|
333
|
-
title={segment.interaction.patternMask ? `Format: ${segment.interaction.patternMask}` : undefined}
|
|
334
|
-
data-format={segment.interaction.format || undefined}
|
|
335
|
-
aria-label={`Text entry ${segment.interaction.responseId}${correctAnswer ? '. Correct answer: ' + correctAnswer : ''}`}
|
|
336
|
-
aria-invalid={textEntryErrors.has(segment.interaction.responseId) ? 'true' : undefined}
|
|
337
|
-
aria-describedby={textEntryErrors.has(segment.interaction.responseId) ? `${segment.interaction.responseId}-error` : undefined}
|
|
338
|
-
value={displayValue}
|
|
339
|
-
oninput={(e) => handleTextEntryInput(segment.interaction.responseId, e)}
|
|
340
|
-
oninvalid={(e) => handleTextEntryInvalid(segment.interaction.responseId, e, segment.interaction.patternMaskMessage)}
|
|
341
|
-
onblur={handleTextEntryBlur}
|
|
234
|
+
<InlineTextEntry
|
|
235
|
+
interaction={segment.interaction}
|
|
236
|
+
response={getStringResponse(segment.interaction.responseId)}
|
|
237
|
+
correctAnswer={roleCapabilities.canViewCorrectResponses ? correctAnswer : null}
|
|
342
238
|
disabled={effectiveDisabled}
|
|
239
|
+
{i18n}
|
|
240
|
+
onResponseChange={handleResponseChange}
|
|
343
241
|
/>
|
|
344
|
-
{#if textEntryErrors.has(segment.interaction.responseId)}
|
|
345
|
-
<span
|
|
346
|
-
id="{segment.interaction.responseId}-error"
|
|
347
|
-
role="alert"
|
|
348
|
-
class="qti-text-entry-error text-error text-xs"
|
|
349
|
-
style="display: block;"
|
|
350
|
-
>{textEntryErrors.get(segment.interaction.responseId)}</span>
|
|
351
|
-
{/if}
|
|
352
242
|
{:else if segment.type === 'inlineChoice'}
|
|
353
243
|
{@const correctAnswer = roleCapabilities.canViewCorrectResponses ? (correctResponses[segment.interaction.responseId] ?? null) : null}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
class:bg-opacity-10={correctAnswer !== null}
|
|
363
|
-
style="display: inline-block; margin: 0 4px; width: auto; min-width: 120px;"
|
|
364
|
-
aria-label={`Inline choice ${segment.interaction.responseId}${correctAnswer && correctChoice ? '. Correct answer: ' + (correctChoice as any).text : ''}`}
|
|
365
|
-
value={displayValue}
|
|
366
|
-
onchange={(e) => handleInlineChoiceChange(segment.interaction.responseId, e)}
|
|
367
|
-
disabled={effectiveDisabled}
|
|
368
|
-
>
|
|
369
|
-
<option value="">{segment.interaction.label ?? i18n?.t('interactions.inline.selectPlaceholder', 'Select...')}</option>
|
|
370
|
-
{#each segment.interaction.choices as choice}
|
|
371
|
-
{@const isCorrect = correctAnswer === choice.identifier}
|
|
372
|
-
<option value={choice.identifier}>
|
|
373
|
-
{choice.text}{isCorrect ? ' ✓' : ''}
|
|
374
|
-
</option>
|
|
375
|
-
{/each}
|
|
376
|
-
</select>
|
|
377
|
-
{#if correctAnswer !== null && correctChoice}
|
|
378
|
-
<span class="badge badge-success badge-sm" style="position: absolute; top: -1.5rem; left: 0; white-space: nowrap; font-size: 0.7rem;">
|
|
379
|
-
{i18n?.t('interactions.choice.correct', 'Correct') ?? 'Correct'}: {(correctChoice as any).text}
|
|
380
|
-
</span>
|
|
381
|
-
{/if}
|
|
382
|
-
</span>
|
|
244
|
+
<InlineChoice
|
|
245
|
+
interaction={segment.interaction}
|
|
246
|
+
response={getStringResponse(segment.interaction.responseId)}
|
|
247
|
+
correctAnswer={roleCapabilities.canViewCorrectResponses ? correctAnswer : null}
|
|
248
|
+
disabled={effectiveDisabled}
|
|
249
|
+
{i18n}
|
|
250
|
+
onResponseChange={handleResponseChange}
|
|
251
|
+
/>
|
|
383
252
|
{/if}
|
|
384
253
|
{/each}
|
|
385
254
|
</div>
|
|
@@ -396,6 +265,8 @@
|
|
|
396
265
|
interaction,
|
|
397
266
|
response: responses[interaction.responseId] ?? null,
|
|
398
267
|
correctResponse: roleCapabilities.canViewCorrectResponses ? correctRespForInteraction : null,
|
|
268
|
+
pnp: player.getPnp(),
|
|
269
|
+
eliminationTool: player.getPnp()?.cognitive?.eliminationTool === true,
|
|
399
270
|
disabled: effectiveDisabled,
|
|
400
271
|
// Avoid invalid ARIA role values on custom-element hosts.
|
|
401
272
|
// Components default to candidate when role is omitted.
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Player } from '../core/Player';
|
|
3
|
-
import type { AdaptiveAttemptResult, ModalFeedback, PlayerSecurityConfig, QTIRole } from '../types';
|
|
3
|
+
import type { AdaptiveAttemptResult, ModalFeedback, PlayerSecurityConfig, QTIRole, ScoringResult } from '../types';
|
|
4
|
+
import type { InteractionResponseValue } from '../web-components';
|
|
4
5
|
import type { I18nProvider } from '@pie-qti/i18n';
|
|
5
6
|
import { typesetMathInElement } from '@pie-qti/typeset-katex';
|
|
6
7
|
import ItemBody from './ItemBody.svelte';
|
|
7
8
|
import ModalFeedbackDisplay from './ModalFeedbackDisplay.svelte';
|
|
8
9
|
|
|
10
|
+
type ItemResponseValue = InteractionResponseValue | null;
|
|
11
|
+
type ItemResponseMap = Record<string, ItemResponseValue>;
|
|
12
|
+
|
|
9
13
|
interface Props {
|
|
10
14
|
itemXml: string;
|
|
11
15
|
role?: QTIRole;
|
|
@@ -14,8 +18,8 @@
|
|
|
14
18
|
disabled?: boolean;
|
|
15
19
|
typeset?: (element: HTMLElement) => void;
|
|
16
20
|
i18n?: I18nProvider;
|
|
17
|
-
onResponseChange?: (responseId: string, value:
|
|
18
|
-
onSubmit?: (responses:
|
|
21
|
+
onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
|
|
22
|
+
onSubmit?: (responses: ItemResponseMap, scoringResult: ScoringResult) => void;
|
|
19
23
|
/** Called when adaptive item completes (all attempts exhausted) */
|
|
20
24
|
onComplete?: (finalResult: AdaptiveAttemptResult) => void;
|
|
21
25
|
}
|
|
@@ -37,7 +41,7 @@
|
|
|
37
41
|
|
|
38
42
|
// Create player instance
|
|
39
43
|
let player = $state<Player | null>(null);
|
|
40
|
-
let responses = $state<
|
|
44
|
+
let responses = $state<ItemResponseMap>({});
|
|
41
45
|
let error = $state<string | null>(null);
|
|
42
46
|
let modalFeedback = $state<ModalFeedback[]>([]);
|
|
43
47
|
let outcomeValues = $state<Record<string, any>>({});
|
|
@@ -63,7 +67,7 @@
|
|
|
63
67
|
}
|
|
64
68
|
});
|
|
65
69
|
|
|
66
|
-
function handleResponseChange(responseId: string, value:
|
|
70
|
+
function handleResponseChange(responseId: string, value: ItemResponseValue) {
|
|
67
71
|
responses = { ...responses, [responseId]: value };
|
|
68
72
|
onResponseChange?.(responseId, value);
|
|
69
73
|
}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
// Show modal if there's feedback
|
|
16
16
|
const hasActiveFeedback = $derived(feedback.length > 0);
|
|
17
|
+
const modalTitleId = 'item-player-modal-feedback-title';
|
|
18
|
+
const firstTitle = $derived(feedback.find((item) => item.title)?.title);
|
|
17
19
|
|
|
18
20
|
function handleClose() {
|
|
19
21
|
onClose?.();
|
|
@@ -29,13 +31,21 @@
|
|
|
29
31
|
|
|
30
32
|
{#if hasActiveFeedback}
|
|
31
33
|
<!-- DaisyUI Modal -->
|
|
32
|
-
<dialog
|
|
34
|
+
<dialog
|
|
35
|
+
open
|
|
36
|
+
class="modal modal-open"
|
|
37
|
+
aria-modal="true"
|
|
38
|
+
aria-labelledby={firstTitle ? modalTitleId : undefined}
|
|
39
|
+
aria-label={firstTitle ? undefined : (i18n?.t('feedback.title') ?? 'Feedback')}
|
|
40
|
+
onclick={handleBackdropClick}
|
|
41
|
+
>
|
|
33
42
|
<div class="modal-box max-w-3xl">
|
|
34
43
|
<!-- Close button -->
|
|
35
44
|
<button
|
|
36
45
|
class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"
|
|
46
|
+
type="button"
|
|
37
47
|
onclick={handleClose}
|
|
38
|
-
aria-label={i18n?.t('feedback.closeFeedback') ?? 'feedback
|
|
48
|
+
aria-label={i18n?.t('feedback.closeFeedback') ?? 'Close feedback'}
|
|
39
49
|
>
|
|
40
50
|
✕
|
|
41
51
|
</button>
|
|
@@ -44,7 +54,7 @@
|
|
|
44
54
|
{#each feedback as item, index}
|
|
45
55
|
<div class="mb-4 {index < feedback.length - 1 ? 'border-b pb-4' : ''}">
|
|
46
56
|
{#if item.title}
|
|
47
|
-
<h3 class="font-bold text-lg mb-2">{item.title}</h3>
|
|
57
|
+
<h3 id={index === 0 ? modalTitleId : undefined} class="font-bold text-lg mb-2">{item.title}</h3>
|
|
48
58
|
{/if}
|
|
49
59
|
|
|
50
60
|
<!-- Render HTML content with MathJax support -->
|
|
@@ -65,8 +75,8 @@
|
|
|
65
75
|
|
|
66
76
|
<!-- Action buttons -->
|
|
67
77
|
<div class="modal-action">
|
|
68
|
-
<button class="btn btn-primary" onclick={handleClose}>
|
|
69
|
-
{i18n?.t('common.continue') ?? '
|
|
78
|
+
<button class="btn btn-primary" type="button" onclick={handleClose}>
|
|
79
|
+
{i18n?.t('common.continue') ?? 'Continue'}
|
|
70
80
|
</button>
|
|
71
81
|
</div>
|
|
72
82
|
</div>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ResolvedItemDeliveryContext } from '@pie-qti/ims-cp-core';
|
|
2
|
+
|
|
3
|
+
export type StimulusSanitizer = (html: string) => string;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build the effective stimulus content map for an item render.
|
|
7
|
+
*
|
|
8
|
+
* Resolved delivery-context content is the package/assessment source of truth.
|
|
9
|
+
* Explicit content remains as a compatibility override for older host wiring.
|
|
10
|
+
*/
|
|
11
|
+
export function buildEffectiveStimulusContent(
|
|
12
|
+
deliveryContext: ResolvedItemDeliveryContext | undefined,
|
|
13
|
+
explicitStimulusContent: Record<string, string>,
|
|
14
|
+
sanitize: StimulusSanitizer
|
|
15
|
+
): Record<string, string> {
|
|
16
|
+
const resolved = Object.fromEntries(
|
|
17
|
+
Object.entries(deliveryContext?.stimuli ?? {}).map(([identifier, stimulus]) => [
|
|
18
|
+
identifier,
|
|
19
|
+
sanitize(stimulus.bodyHtml),
|
|
20
|
+
])
|
|
21
|
+
);
|
|
22
|
+
const explicit = Object.fromEntries(
|
|
23
|
+
Object.entries(explicitStimulusContent).map(([identifier, content]) => [identifier, sanitize(content)])
|
|
24
|
+
);
|
|
25
|
+
return { ...resolved, ...explicit };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Inject shared stimulus bodies at QTI refs or host-authored docking points.
|
|
30
|
+
*
|
|
31
|
+
* Any resolved stimulus that has no matching docking point is prepended in
|
|
32
|
+
* delivery-context order so undocked package content is still visible.
|
|
33
|
+
*/
|
|
34
|
+
export function injectStimulusContent(itemBodyHtml: string, stimulusContent: Record<string, string>): string {
|
|
35
|
+
if (Object.keys(stimulusContent).length === 0) return itemBodyHtml;
|
|
36
|
+
|
|
37
|
+
const docked = new Set<string>();
|
|
38
|
+
let html = itemBodyHtml.replace(
|
|
39
|
+
/<([a-z][\w:-]*)([^>]*\bdata-stimulus-idref=(["'])([^"']+)\3[^>]*)>\s*<\/\1>/gi,
|
|
40
|
+
(match, tagName, attrs, _quote, identifier) => {
|
|
41
|
+
const content = stimulusContent[identifier];
|
|
42
|
+
if (!content) return match;
|
|
43
|
+
docked.add(identifier);
|
|
44
|
+
return `<${tagName}${mergeClassAttribute(attrs, 'qti-stimulus-dock')}>${content}</${tagName}>`;
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
html = html.replace(
|
|
49
|
+
/<qti-assessment-stimulus-ref\b([^>]*)\/?>\s*(?:<\/qti-assessment-stimulus-ref>)?/gi,
|
|
50
|
+
(match, attrs) => {
|
|
51
|
+
const identifier = extractAttribute(attrs, 'identifier');
|
|
52
|
+
if (!identifier) return match;
|
|
53
|
+
if (docked.has(identifier)) return '';
|
|
54
|
+
const content = stimulusContent[identifier];
|
|
55
|
+
if (!content) return match;
|
|
56
|
+
docked.add(identifier);
|
|
57
|
+
return `<div data-stimulus-idref="${escapeHtmlAttribute(identifier)}" class="qti-stimulus-dock">${content}</div>`;
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const undocked = Object.entries(stimulusContent)
|
|
62
|
+
.filter(([identifier]) => !docked.has(identifier))
|
|
63
|
+
.map(
|
|
64
|
+
([identifier, content]) =>
|
|
65
|
+
`<div data-stimulus-idref="${escapeHtmlAttribute(identifier)}" class="qti-stimulus-block">${content}</div>`
|
|
66
|
+
)
|
|
67
|
+
.join('');
|
|
68
|
+
|
|
69
|
+
return undocked ? undocked + html : html;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function extractAttribute(attrs: string, name: string): string | null {
|
|
73
|
+
const match = attrs.match(new RegExp(`\\b${name}\\s*=\\s*["']([^"']+)["']`, 'i'));
|
|
74
|
+
return match?.[1] ?? null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function mergeClassAttribute(attrs: string, className: string): string {
|
|
78
|
+
const classMatch = attrs.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
|
|
79
|
+
if (!classMatch) return `${attrs} class="${className}"`;
|
|
80
|
+
const quote = classMatch[1]!;
|
|
81
|
+
const existing = classMatch[2] ?? '';
|
|
82
|
+
const classes = new Set(existing.split(/\s+/).filter(Boolean));
|
|
83
|
+
classes.add(className);
|
|
84
|
+
return attrs.replace(classMatch[0], `class=${quote}${Array.from(classes).join(' ')}${quote}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function escapeHtmlAttribute(value: string): string {
|
|
88
|
+
return value
|
|
89
|
+
.replace(/&/g, '&')
|
|
90
|
+
.replace(/"/g, '"')
|
|
91
|
+
.replace(/</g, '<')
|
|
92
|
+
.replace(/>/g, '>');
|
|
93
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ResolvedItemDeliveryContext, ResolvedQtiStylesheetRef } from '@pie-qti/ims-cp-core';
|
|
2
|
+
|
|
3
|
+
const BLOCKED_CSS = /@import\b|url\s*\(|<\/style|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:/i;
|
|
4
|
+
|
|
5
|
+
export function buildScopedStylesheetCss(
|
|
6
|
+
deliveryContext: ResolvedItemDeliveryContext | undefined,
|
|
7
|
+
scopeSelector = '[data-qti-item-body-scope]'
|
|
8
|
+
): string {
|
|
9
|
+
if (!deliveryContext) return '';
|
|
10
|
+
return deliveryContext.stylesheets
|
|
11
|
+
.map((stylesheet) => stylesheetToScopedCss(stylesheet, scopeSelector))
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join('\n');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function stylesheetToScopedCss(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {
|
|
17
|
+
const css = stylesheet.cssText?.trim();
|
|
18
|
+
if (!css || BLOCKED_CSS.test(css)) return '';
|
|
19
|
+
const stylesheetScope = getStylesheetScopeSelector(stylesheet, scopeSelector);
|
|
20
|
+
const scoped = scopeCssRules(css, stylesheetScope);
|
|
21
|
+
if (!scoped) return '';
|
|
22
|
+
return scoped;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function scopeCssRules(css: string, scopeSelector = '[data-qti-item-body-scope]'): string {
|
|
26
|
+
const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
27
|
+
let scoped = '';
|
|
28
|
+
const rulePattern = /([^{}@]+)\{([^{}]*)\}/g;
|
|
29
|
+
for (const match of withoutComments.matchAll(rulePattern)) {
|
|
30
|
+
const selectorList = match[1]?.trim();
|
|
31
|
+
const declarations = match[2]?.trim();
|
|
32
|
+
if (!selectorList || !declarations) continue;
|
|
33
|
+
const selectors = selectorList
|
|
34
|
+
.split(',')
|
|
35
|
+
.map((selector) => scopeSelectorText(selector.trim(), scopeSelector))
|
|
36
|
+
.filter(Boolean);
|
|
37
|
+
if (selectors.length === 0) continue;
|
|
38
|
+
scoped += `${selectors.join(', ')} { ${declarations} }\n`;
|
|
39
|
+
}
|
|
40
|
+
return scoped.trim();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getStylesheetScopeSelector(stylesheet: ResolvedQtiStylesheetRef, scopeSelector: string): string {
|
|
44
|
+
if (stylesheet.source !== 'stimulus' || !stylesheet.stimulusIdentifier) return scopeSelector;
|
|
45
|
+
return `${scopeSelector} [data-stimulus-idref="${escapeCssString(stylesheet.stimulusIdentifier)}"]`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function scopeSelectorText(selector: string, scopeSelector: string): string {
|
|
49
|
+
if (!selector) return '';
|
|
50
|
+
if (selector.startsWith(scopeSelector)) return selector;
|
|
51
|
+
if (selector === ':root' || selector === 'html' || selector === 'body') return scopeSelector;
|
|
52
|
+
if (selector.startsWith(':')) return `${scopeSelector}${selector}`;
|
|
53
|
+
return `${scopeSelector} ${selector}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function escapeCssString(value: string): string {
|
|
57
|
+
return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n|\r|\f/g, ' ');
|
|
58
|
+
}
|