@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
package/dist/core/Player.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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
11
|
import { sanitizeResourceUrl } from './urlPolicy.js';
|
|
12
12
|
import { applyPnpToRoot } from '../pnp/applyPnp.js';
|
|
13
|
-
import { extractCatalogFromItemXml, mergeCatalogs } from '../catalog/catalogExtractor.js';
|
|
13
|
+
import { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from '../catalog/catalogExtractor.js';
|
|
14
14
|
import { getCatalogEntry } from '../catalog/catalogLookup.js';
|
|
15
15
|
import { PciHost } from '../pci/PciHost.js';
|
|
16
16
|
export class Player {
|
|
@@ -19,10 +19,16 @@ export class Player {
|
|
|
19
19
|
this.templateProcessingProgram = null;
|
|
20
20
|
this.outcomeProcessingProgram = null;
|
|
21
21
|
this._catalogIndex = new Map();
|
|
22
|
+
this._stimulusCatalogIndexes = new Map();
|
|
22
23
|
this._pciHosts = new Map();
|
|
24
|
+
this._pnpChangeListeners = new Set();
|
|
25
|
+
this.lifecycleStatus = 'initial';
|
|
26
|
+
this.accumulatedDurationMs = 0;
|
|
23
27
|
this.config = config;
|
|
24
28
|
this.itemXml = config.itemXml ?? '';
|
|
25
29
|
this.role = config.role ?? 'candidate';
|
|
30
|
+
this.sessionGuid = createSessionGuid();
|
|
31
|
+
this.sessionStartedAt = Date.now();
|
|
26
32
|
this.rng = config.rng ?? (typeof config.seed === 'number' ? createSeededRng(config.seed) : Math.random);
|
|
27
33
|
// Auto-detect QTI version and create appropriate mappers if not provided
|
|
28
34
|
if (!config.elementNameMapper) {
|
|
@@ -46,12 +52,21 @@ export class Player {
|
|
|
46
52
|
}
|
|
47
53
|
else {
|
|
48
54
|
this.mapper = config.elementNameMapper;
|
|
55
|
+
if (!config.attributeNameMapper) {
|
|
56
|
+
config.attributeNameMapper =
|
|
57
|
+
this.mapper.version === '3.0'
|
|
58
|
+
? new Qti3AttributeNameMapper()
|
|
59
|
+
: new Qti2xAttributeNameMapper();
|
|
60
|
+
}
|
|
49
61
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
this.itemDocument = parseAssessmentItemDocument({
|
|
63
|
+
itemXml: this.itemXml,
|
|
64
|
+
elementNameMapper: this.mapper,
|
|
65
|
+
attributeNameMapper: config.attributeNameMapper,
|
|
66
|
+
security: this.config.security,
|
|
67
|
+
});
|
|
68
|
+
this.assessmentItem = this.itemDocument.getAssessmentItem();
|
|
69
|
+
this.decls = this.buildDeclarations();
|
|
55
70
|
this.ensureBuiltinDeclarations(this.decls);
|
|
56
71
|
this.ctx = new DeclarationContext(this.decls);
|
|
57
72
|
this.ops = new OperatorRegistry();
|
|
@@ -65,8 +80,8 @@ export class Player {
|
|
|
65
80
|
this.componentRegistry = config.componentRegistry ?? createComponentRegistry();
|
|
66
81
|
// I18n provider (defaults to a simple fallback if not provided)
|
|
67
82
|
this.i18nProvider = config.i18nProvider ?? this.createDefaultI18nProvider();
|
|
68
|
-
// Register standard extractors (idempotent per-registry instance)
|
|
69
|
-
for (const ex of
|
|
83
|
+
// Register standard interaction extractors (idempotent per-registry instance)
|
|
84
|
+
for (const ex of getStandardInteractionExtractors()) {
|
|
70
85
|
try {
|
|
71
86
|
this.extractionRegistry.register(ex);
|
|
72
87
|
}
|
|
@@ -85,20 +100,20 @@ export class Player {
|
|
|
85
100
|
}
|
|
86
101
|
}
|
|
87
102
|
// Build ASTs once.
|
|
88
|
-
const templateProcessing =
|
|
103
|
+
const templateProcessing = this.itemDocument.getProcessingElement('template');
|
|
89
104
|
if (templateProcessing) {
|
|
90
105
|
this.templateProcessingProgram = buildTemplateProcessingAst(templateProcessing, {
|
|
91
106
|
elementNameMapper: this.mapper,
|
|
92
107
|
});
|
|
93
108
|
this.execTemplateProcessing();
|
|
94
109
|
}
|
|
95
|
-
const responseProcessing =
|
|
110
|
+
const responseProcessing = this.itemDocument.getProcessingElement('response');
|
|
96
111
|
if (responseProcessing) {
|
|
97
112
|
this.responseProcessingProgram = buildResponseProcessingAst(responseProcessing, {
|
|
98
113
|
elementNameMapper: this.mapper,
|
|
99
114
|
});
|
|
100
115
|
}
|
|
101
|
-
const outcomeProcessing =
|
|
116
|
+
const outcomeProcessing = this.itemDocument.getProcessingElement('outcome');
|
|
102
117
|
if (outcomeProcessing) {
|
|
103
118
|
this.outcomeProcessingProgram = buildOutcomeProcessingAst(outcomeProcessing, {
|
|
104
119
|
elementNameMapper: this.mapper,
|
|
@@ -121,16 +136,24 @@ export class Player {
|
|
|
121
136
|
}
|
|
122
137
|
// Store PNP profile for later use (applyPnpToRoot is called once a root element is available).
|
|
123
138
|
this._pnp = config.pnp;
|
|
124
|
-
// Build catalog index from
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
// Build catalog index from resolved delivery context, legacy shared catalog XML, and item XML.
|
|
140
|
+
// Item/global entries are merged first; item-level entries win on global collisions.
|
|
141
|
+
// Stimulus entries are kept separately so rendered stimulus terms can avoid ID collisions.
|
|
142
|
+
let mergedCatalog = new Map();
|
|
143
|
+
for (const source of config.deliveryContext?.catalogSources ?? []) {
|
|
144
|
+
const sourceCatalog = extractCatalog(source.xml);
|
|
145
|
+
if (source.scope === 'stimulus' && source.stimulusIdentifier) {
|
|
146
|
+
const existing = this._stimulusCatalogIndexes.get(source.stimulusIdentifier) ?? new Map();
|
|
147
|
+
this._stimulusCatalogIndexes.set(source.stimulusIdentifier, mergeCatalogs(existing, sourceCatalog));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
mergedCatalog = mergeCatalogs(mergedCatalog, sourceCatalog);
|
|
151
|
+
}
|
|
130
152
|
}
|
|
131
|
-
|
|
132
|
-
|
|
153
|
+
if (config.catalogXml) {
|
|
154
|
+
mergedCatalog = mergeCatalogs(mergedCatalog, extractCatalogFromItemXml(config.catalogXml));
|
|
133
155
|
}
|
|
156
|
+
this._catalogIndex = mergeCatalogs(mergedCatalog, extractCatalogFromItemXml(this.itemXml));
|
|
134
157
|
// Check strict compliance if enabled
|
|
135
158
|
if (this.config.strictQtiCompliance?.enabled) {
|
|
136
159
|
this.validateStrictCompliance();
|
|
@@ -154,23 +177,47 @@ export class Player {
|
|
|
154
177
|
if (this._rootEl) {
|
|
155
178
|
applyPnpToRoot(this._rootEl, this._pnp);
|
|
156
179
|
}
|
|
180
|
+
for (const listener of this._pnpChangeListeners) {
|
|
181
|
+
listener(this._pnp);
|
|
182
|
+
}
|
|
157
183
|
}
|
|
158
184
|
/** Return the current resolved PNP profile. */
|
|
159
185
|
getPnp() {
|
|
160
186
|
return this._pnp;
|
|
161
187
|
}
|
|
188
|
+
onPnpChange(listener) {
|
|
189
|
+
this._pnpChangeListeners.add(listener);
|
|
190
|
+
return () => this._pnpChangeListeners.delete(listener);
|
|
191
|
+
}
|
|
192
|
+
/** Return the package/assessment-resolved delivery context, if one was supplied. */
|
|
193
|
+
getDeliveryContext() {
|
|
194
|
+
return this.config.deliveryContext;
|
|
195
|
+
}
|
|
162
196
|
/**
|
|
163
197
|
* Look up a catalog entry by card identifier, usage type, and optional language.
|
|
164
198
|
* Returns the HTML string for the matched entry, or null if not found.
|
|
165
199
|
*
|
|
166
200
|
* Language fallback: exact match → prefix match → no-lang entry → null.
|
|
167
201
|
*/
|
|
168
|
-
getCatalogEntry(idref, usage, lang) {
|
|
169
|
-
|
|
202
|
+
getCatalogEntry(idref, usage, lang, options) {
|
|
203
|
+
const stimulusHtml = options?.stimulusIdentifier
|
|
204
|
+
? getCatalogEntry(this._stimulusCatalogIndexes.get(options.stimulusIdentifier) ?? new Map(), idref, usage, lang)
|
|
205
|
+
: null;
|
|
206
|
+
const html = stimulusHtml ?? getCatalogEntry(this._catalogIndex, idref, usage, lang);
|
|
207
|
+
if (html === null)
|
|
208
|
+
return null;
|
|
209
|
+
if (looksLikeCatalogUrl(html)) {
|
|
210
|
+
return sanitizeResourceUrl(html.trim(), this.config.security?.urlPolicy, 'img');
|
|
211
|
+
}
|
|
212
|
+
return this.sanitizeHtmlContent(html);
|
|
213
|
+
}
|
|
214
|
+
/** Sanitize externally resolved item-adjacent HTML before it reaches a rendering sink. */
|
|
215
|
+
sanitizeHtmlContent(html) {
|
|
216
|
+
return sanitizeHtml(html, { security: this.config.security });
|
|
170
217
|
}
|
|
171
218
|
/**
|
|
172
219
|
* Create a PciHost for an extracted PCI and register it for response tracking.
|
|
173
|
-
* The caller
|
|
220
|
+
* The caller is responsible for calling host.load() and
|
|
174
221
|
* host.initialize(domNode) once the DOM element is available.
|
|
175
222
|
*/
|
|
176
223
|
createPciHost(data) {
|
|
@@ -237,45 +284,110 @@ export class Player {
|
|
|
237
284
|
this.destroyPciHosts();
|
|
238
285
|
}
|
|
239
286
|
processResponses() {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
287
|
+
return this.runResponseProcessing({ finalizeNonAdaptiveAttempt: true });
|
|
288
|
+
}
|
|
289
|
+
saveItemSession() {
|
|
290
|
+
this.freezeDuration();
|
|
291
|
+
return this.serializeItemSession();
|
|
292
|
+
}
|
|
293
|
+
restoreItemSession(state) {
|
|
294
|
+
this.sessionGuid = state.sessionGuid;
|
|
295
|
+
this.lifecycleStatus = state.lifecycleStatus;
|
|
296
|
+
this.accumulatedDurationMs = Math.max(0, Number(state.duration) || 0);
|
|
297
|
+
this.sessionStartedAt = Date.now();
|
|
298
|
+
this.applySerializedVariables(state.responseVariables);
|
|
299
|
+
this.applySerializedVariables(state.outcomeVariables);
|
|
300
|
+
this.applySerializedVariables(state.templateVariables);
|
|
301
|
+
this.applySerializedVariables(state.contextVariables);
|
|
302
|
+
this.updateDuration();
|
|
303
|
+
}
|
|
304
|
+
suspendAttempt() {
|
|
305
|
+
const validation = this.validateResponses(this.getResponses());
|
|
306
|
+
this.lifecycleStatus = 'suspended';
|
|
307
|
+
const sessionState = this.saveItemSession();
|
|
308
|
+
return {
|
|
309
|
+
action: 'suspendAttempt',
|
|
310
|
+
lifecycleStatus: this.lifecycleStatus,
|
|
311
|
+
completionStatus: this.getCompletionStatus(),
|
|
312
|
+
numAttempts: this.getNumAttempts(),
|
|
313
|
+
duration: sessionState.duration,
|
|
314
|
+
completed: this.isCompleted(),
|
|
315
|
+
sessionState,
|
|
316
|
+
validation,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
endAttempt(options = {}) {
|
|
320
|
+
const validate = options.validateResponses ?? false;
|
|
321
|
+
const validation = validate ? this.validateResponses(this.getResponses()) : undefined;
|
|
322
|
+
if (validation && !validation.valid) {
|
|
323
|
+
const sessionState = this.saveItemSession();
|
|
324
|
+
return {
|
|
325
|
+
action: 'endAttempt',
|
|
326
|
+
lifecycleStatus: this.lifecycleStatus,
|
|
327
|
+
completionStatus: this.getCompletionStatus(),
|
|
328
|
+
numAttempts: this.getNumAttempts(),
|
|
329
|
+
duration: sessionState.duration,
|
|
330
|
+
completed: this.isCompleted(),
|
|
331
|
+
sessionState,
|
|
332
|
+
validation,
|
|
333
|
+
};
|
|
257
334
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
335
|
+
const scoring = this.isAdaptive()
|
|
336
|
+
? this.submitAttempt(options.countAttempt ?? true)
|
|
337
|
+
: this.runResponseProcessing({
|
|
338
|
+
finalizeNonAdaptiveAttempt: true,
|
|
339
|
+
countAttempt: options.countAttempt ?? true,
|
|
340
|
+
});
|
|
341
|
+
this.lifecycleStatus = scoring.completed ? 'closed' : 'interacting';
|
|
342
|
+
const sessionState = this.saveItemSession();
|
|
343
|
+
return {
|
|
344
|
+
action: 'endAttempt',
|
|
345
|
+
lifecycleStatus: this.lifecycleStatus,
|
|
346
|
+
completionStatus: this.getCompletionStatus(),
|
|
347
|
+
numAttempts: this.getNumAttempts(),
|
|
348
|
+
duration: sessionState.duration,
|
|
349
|
+
completed: scoring.completed,
|
|
350
|
+
sessionState,
|
|
351
|
+
validation,
|
|
352
|
+
scoring,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
scoreAttempt() {
|
|
356
|
+
const scoring = this.runResponseProcessing({ finalizeNonAdaptiveAttempt: false });
|
|
357
|
+
const sessionState = this.saveItemSession();
|
|
358
|
+
return {
|
|
359
|
+
action: 'scoreAttempt',
|
|
360
|
+
lifecycleStatus: this.lifecycleStatus,
|
|
361
|
+
completionStatus: this.getCompletionStatus(),
|
|
362
|
+
numAttempts: this.getNumAttempts(),
|
|
363
|
+
duration: sessionState.duration,
|
|
364
|
+
completed: scoring.completed,
|
|
365
|
+
sessionState,
|
|
366
|
+
scoring,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
newTemplate(options = {}) {
|
|
370
|
+
this.resetOutcomesToDefault();
|
|
371
|
+
if (options.resetResponses ?? true) {
|
|
372
|
+
this.resetResponsesToDefault();
|
|
267
373
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
374
|
+
this.resetTemplatesToDefault();
|
|
375
|
+
this.ctx.setValue('completionStatus', qtiValue('identifier', 'single', 'not_attempted'));
|
|
376
|
+
this.ctx.setValue('numAttempts', qtiValue('integer', 'single', 0));
|
|
377
|
+
this.execTemplateProcessing();
|
|
378
|
+
this.lifecycleStatus = 'initial';
|
|
379
|
+
this.accumulatedDurationMs = 0;
|
|
380
|
+
this.sessionStartedAt = Date.now();
|
|
381
|
+
this.updateDuration();
|
|
382
|
+
const sessionState = this.serializeItemSession();
|
|
273
383
|
return {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
384
|
+
action: 'newTemplate',
|
|
385
|
+
lifecycleStatus: this.lifecycleStatus,
|
|
386
|
+
completionStatus: this.getCompletionStatus(),
|
|
387
|
+
numAttempts: this.getNumAttempts(),
|
|
388
|
+
duration: sessionState.duration,
|
|
389
|
+
completed: this.isCompleted(),
|
|
390
|
+
sessionState,
|
|
279
391
|
};
|
|
280
392
|
}
|
|
281
393
|
getSecurityConfig() {
|
|
@@ -381,17 +493,74 @@ export class Player {
|
|
|
381
493
|
continue;
|
|
382
494
|
// Built-in stateful variables must survive across processing runs.
|
|
383
495
|
// They are updated by the runtime (adaptive attempt tracking), not by outcome defaults.
|
|
384
|
-
if (d.identifier === 'numAttempts' || d.identifier === 'completionStatus')
|
|
496
|
+
if (d.identifier === 'numAttempts' || d.identifier === 'completionStatus' || d.identifier === 'duration')
|
|
497
|
+
continue;
|
|
498
|
+
this.ctx.resetToDefault(d.identifier);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
resetResponsesToDefault() {
|
|
502
|
+
for (const d of Object.values(this.decls)) {
|
|
503
|
+
if (d.__kind !== 'response')
|
|
385
504
|
continue;
|
|
386
505
|
this.ctx.resetToDefault(d.identifier);
|
|
506
|
+
this.setPciResponse(d.identifier, d.value.kind === 'value' ? d.value.value : null);
|
|
387
507
|
}
|
|
388
508
|
}
|
|
509
|
+
resetTemplatesToDefault() {
|
|
510
|
+
for (const d of Object.values(this.decls)) {
|
|
511
|
+
if (!d.isTemplate)
|
|
512
|
+
continue;
|
|
513
|
+
this.ctx.resetToDefault(d.identifier);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
runResponseProcessing(options) {
|
|
517
|
+
this.updateDuration();
|
|
518
|
+
// Spec-aligned behavior: each processing run starts from outcome defaults.
|
|
519
|
+
// This prevents stale outcomes when response/outcome processing doesn't set every variable.
|
|
520
|
+
this.resetOutcomesToDefault();
|
|
521
|
+
// Execute response processing if present
|
|
522
|
+
const rpEl = this.itemDocument.getProcessingElement('response');
|
|
523
|
+
if (rpEl) {
|
|
524
|
+
// If responseProcessing has explicit statements, run the compiled program.
|
|
525
|
+
// Otherwise, fall back to template-based processing (responseProcessing@template).
|
|
526
|
+
const hasStatements = childElements(rpEl).length > 0;
|
|
527
|
+
if (hasStatements) {
|
|
528
|
+
this.execResponseProcessingProgram();
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
const templateUrl = getAttr(rpEl, 'template');
|
|
532
|
+
if (templateUrl)
|
|
533
|
+
this.execResponseProcessingTemplate(templateUrl);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
// Execute outcome processing if present (runs after responseProcessing)
|
|
537
|
+
this.execOutcomeProcessingProgram();
|
|
538
|
+
// Compatibility: processResponses() has historically finalized non-adaptive items.
|
|
539
|
+
// New scoreAttempt() uses this same engine with finalization disabled.
|
|
540
|
+
if (!this.isAdaptive() && options.finalizeNonAdaptiveAttempt) {
|
|
541
|
+
this.ctx.setValue('completionStatus', qtiValue('identifier', 'single', 'completed'));
|
|
542
|
+
if (options.countAttempt ?? true) {
|
|
543
|
+
const currentAttempts = this.getNumAttempts();
|
|
544
|
+
this.ctx.setValue('numAttempts', qtiValue('integer', 'single', currentAttempts + 1));
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
const outcomes = this.collectOutcomes();
|
|
548
|
+
const score = Number(outcomes.SCORE ?? 0);
|
|
549
|
+
const maxScore = Number(outcomes.MAXSCORE ?? 1);
|
|
550
|
+
const completionStatus = outcomes.completionStatus ?? 'not_attempted';
|
|
551
|
+
const completed = completionStatus === 'completed' || (!this.isAdaptive() && options.finalizeNonAdaptiveAttempt);
|
|
552
|
+
return {
|
|
553
|
+
score,
|
|
554
|
+
maxScore,
|
|
555
|
+
completed,
|
|
556
|
+
outcomeValues: outcomes,
|
|
557
|
+
modalFeedback: this.getModalFeedback(outcomes),
|
|
558
|
+
};
|
|
559
|
+
}
|
|
389
560
|
getItemBodyHtml() {
|
|
390
|
-
const
|
|
391
|
-
if (!
|
|
561
|
+
const inner = this.itemDocument.serializeItemBodyChildren();
|
|
562
|
+
if (!inner)
|
|
392
563
|
return '';
|
|
393
|
-
// Serialize children rather than the container tag itself.
|
|
394
|
-
const inner = childElements(itemBody).map((c) => serializeXml(c)).join('');
|
|
395
564
|
const printed = this.renderPrintedVariables(inner);
|
|
396
565
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
397
566
|
return toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -404,7 +573,7 @@ export class Player {
|
|
|
404
573
|
*/
|
|
405
574
|
getRubrics() {
|
|
406
575
|
const role = this.role;
|
|
407
|
-
const rubricEls =
|
|
576
|
+
const rubricEls = this.itemDocument.findRubricElements();
|
|
408
577
|
if (rubricEls.length === 0)
|
|
409
578
|
return [];
|
|
410
579
|
const blocks = [];
|
|
@@ -414,8 +583,7 @@ export class Player {
|
|
|
414
583
|
// If view is specified, show only when it includes the current role.
|
|
415
584
|
if (view.length > 0 && role && !view.includes(role))
|
|
416
585
|
continue;
|
|
417
|
-
|
|
418
|
-
const contentRaw = childElements(el).map((c) => serializeXml(c)).join('') || (el.textContent || '');
|
|
586
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
419
587
|
const printed = this.renderPrintedVariables(contentRaw);
|
|
420
588
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
421
589
|
const html = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -433,118 +601,12 @@ export class Player {
|
|
|
433
601
|
* Canonical interaction API (new): extracted, typed interaction data.
|
|
434
602
|
*/
|
|
435
603
|
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;
|
|
604
|
+
return extractInteractionData({
|
|
605
|
+
document: this.itemDocument,
|
|
606
|
+
extractionRegistry: this.extractionRegistry,
|
|
607
|
+
declarations: this.decls,
|
|
608
|
+
config: this.config,
|
|
609
|
+
});
|
|
548
610
|
}
|
|
549
611
|
/**
|
|
550
612
|
* Convenience API (used by tests/bench): returns a minimal interaction list with QTI-ish field names.
|
|
@@ -571,7 +633,7 @@ export class Player {
|
|
|
571
633
|
return this.getResponseInteractions().map((i) => i.responseIdentifier);
|
|
572
634
|
}
|
|
573
635
|
isAdaptive() {
|
|
574
|
-
return (
|
|
636
|
+
return (this.itemDocument.getAssessmentItemAttribute('adaptive') || '').toLowerCase() === 'true';
|
|
575
637
|
}
|
|
576
638
|
getNumAttempts() {
|
|
577
639
|
return Math.max(0, Math.floor(toNumber(this.ctx.getValue('numAttempts')) || 0));
|
|
@@ -906,7 +968,7 @@ export class Player {
|
|
|
906
968
|
// ----------------------------------------------------------------------------
|
|
907
969
|
// Declarations
|
|
908
970
|
// ----------------------------------------------------------------------------
|
|
909
|
-
buildDeclarations(
|
|
971
|
+
buildDeclarations() {
|
|
910
972
|
const decls = {};
|
|
911
973
|
const addDecl = (kind, el) => {
|
|
912
974
|
const identifier = this.getAttrMapped(el, 'identifier');
|
|
@@ -956,11 +1018,11 @@ export class Player {
|
|
|
956
1018
|
}
|
|
957
1019
|
}
|
|
958
1020
|
};
|
|
959
|
-
for (const el of
|
|
1021
|
+
for (const el of this.itemDocument.findDeclarationElements('response'))
|
|
960
1022
|
addDecl('response', el);
|
|
961
|
-
for (const el of
|
|
1023
|
+
for (const el of this.itemDocument.findDeclarationElements('outcome'))
|
|
962
1024
|
addDecl('outcome', el);
|
|
963
|
-
for (const el of
|
|
1025
|
+
for (const el of this.itemDocument.findDeclarationElements('template'))
|
|
964
1026
|
addDecl('template', el);
|
|
965
1027
|
return decls;
|
|
966
1028
|
}
|
|
@@ -1011,12 +1073,25 @@ export class Player {
|
|
|
1011
1073
|
identifier: 'numAttempts',
|
|
1012
1074
|
baseType: 'integer',
|
|
1013
1075
|
cardinality: 'single',
|
|
1076
|
+
defaultValue: qtiValue('integer', 'single', 0),
|
|
1014
1077
|
value: qtiValue('integer', 'single', 0),
|
|
1015
1078
|
isTemplate: false,
|
|
1016
1079
|
// @ts-expect-error internal marker
|
|
1017
1080
|
__kind: 'outcome',
|
|
1018
1081
|
};
|
|
1019
1082
|
}
|
|
1083
|
+
if (!decls.duration) {
|
|
1084
|
+
decls.duration = {
|
|
1085
|
+
identifier: 'duration',
|
|
1086
|
+
baseType: 'duration',
|
|
1087
|
+
cardinality: 'single',
|
|
1088
|
+
defaultValue: qtiValue('duration', 'single', 0),
|
|
1089
|
+
value: qtiValue('duration', 'single', 0),
|
|
1090
|
+
isTemplate: false,
|
|
1091
|
+
// @ts-expect-error internal marker
|
|
1092
|
+
__kind: 'outcome',
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1020
1095
|
// Common scoring defaults
|
|
1021
1096
|
if (!decls.SCORE) {
|
|
1022
1097
|
decls.SCORE = {
|
|
@@ -1048,6 +1123,91 @@ export class Player {
|
|
|
1048
1123
|
continue;
|
|
1049
1124
|
d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, raw);
|
|
1050
1125
|
}
|
|
1126
|
+
const restoredDuration = Number(state.duration);
|
|
1127
|
+
if (Number.isFinite(restoredDuration) && restoredDuration >= 0) {
|
|
1128
|
+
this.accumulatedDurationMs = restoredDuration;
|
|
1129
|
+
this.sessionStartedAt = Date.now();
|
|
1130
|
+
this.updateDuration();
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
applySerializedVariables(vars) {
|
|
1134
|
+
for (const v of Object.values(vars)) {
|
|
1135
|
+
const d = this.decls[v.identifier];
|
|
1136
|
+
if (!d)
|
|
1137
|
+
continue;
|
|
1138
|
+
d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, v.value);
|
|
1139
|
+
if (d.__kind === 'response') {
|
|
1140
|
+
this.setPciResponse(d.identifier, v.value);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
serializeItemSession() {
|
|
1145
|
+
const responseVariables = {};
|
|
1146
|
+
const outcomeVariables = {};
|
|
1147
|
+
const templateVariables = {};
|
|
1148
|
+
const contextVariables = {};
|
|
1149
|
+
const contextIds = new Set(['completionStatus', 'numAttempts', 'duration']);
|
|
1150
|
+
for (const d of Object.values(this.decls)) {
|
|
1151
|
+
const variable = this.serializeVariable(d);
|
|
1152
|
+
if (d.isTemplate) {
|
|
1153
|
+
templateVariables[d.identifier] = { ...variable, kind: 'template' };
|
|
1154
|
+
}
|
|
1155
|
+
else if (contextIds.has(d.identifier)) {
|
|
1156
|
+
contextVariables[d.identifier] = { ...variable, kind: 'context' };
|
|
1157
|
+
}
|
|
1158
|
+
else if (d.__kind === 'response') {
|
|
1159
|
+
responseVariables[d.identifier] = { ...variable, kind: 'response' };
|
|
1160
|
+
}
|
|
1161
|
+
else if (d.__kind === 'outcome') {
|
|
1162
|
+
outcomeVariables[d.identifier] = { ...variable, kind: 'outcome' };
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
const validation = this.validateResponses(this.getResponses());
|
|
1166
|
+
return {
|
|
1167
|
+
itemIdentifier: this.itemDocument.getAssessmentItemAttribute('identifier') ?? undefined,
|
|
1168
|
+
sessionGuid: this.sessionGuid,
|
|
1169
|
+
lifecycleStatus: this.lifecycleStatus,
|
|
1170
|
+
completionStatus: this.getCompletionStatus(),
|
|
1171
|
+
numAttempts: this.getNumAttempts(),
|
|
1172
|
+
duration: this.getDuration(),
|
|
1173
|
+
responseVariables,
|
|
1174
|
+
outcomeVariables,
|
|
1175
|
+
templateVariables,
|
|
1176
|
+
contextVariables,
|
|
1177
|
+
validationMessages: validation.issues,
|
|
1178
|
+
savedAt: new Date().toISOString(),
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
serializeVariable(d) {
|
|
1182
|
+
return {
|
|
1183
|
+
identifier: d.identifier,
|
|
1184
|
+
kind: (d.__kind ?? (d.isTemplate ? 'template' : 'context')),
|
|
1185
|
+
baseType: d.baseType,
|
|
1186
|
+
cardinality: d.cardinality,
|
|
1187
|
+
value: this.qtiValueToSerializable(d.value),
|
|
1188
|
+
defaultValue: this.qtiValueToSerializable(d.defaultValue),
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
qtiValueToSerializable(value) {
|
|
1192
|
+
if (!value || value.kind !== 'value')
|
|
1193
|
+
return null;
|
|
1194
|
+
return value.value;
|
|
1195
|
+
}
|
|
1196
|
+
updateDuration() {
|
|
1197
|
+
const elapsedMs = Math.max(0, Date.now() - this.sessionStartedAt);
|
|
1198
|
+
const durationMs = this.accumulatedDurationMs + elapsedMs;
|
|
1199
|
+
this.ctx.setValue('duration', qtiValue('duration', 'single', durationMs));
|
|
1200
|
+
}
|
|
1201
|
+
freezeDuration() {
|
|
1202
|
+
this.updateDuration();
|
|
1203
|
+
const duration = this.getDuration();
|
|
1204
|
+
this.accumulatedDurationMs = duration;
|
|
1205
|
+
this.sessionStartedAt = Date.now();
|
|
1206
|
+
return duration;
|
|
1207
|
+
}
|
|
1208
|
+
getDuration() {
|
|
1209
|
+
const value = this.ctx.getValue('duration');
|
|
1210
|
+
return Math.max(0, Math.floor(toNumber(value) || 0));
|
|
1051
1211
|
}
|
|
1052
1212
|
parseDefaultValue(declEl, baseType, cardinality) {
|
|
1053
1213
|
const defaultEl = findFirstDescendant(declEl, this.mapper.toNative('defaultvalue'));
|
|
@@ -1204,14 +1364,14 @@ export class Player {
|
|
|
1204
1364
|
return out;
|
|
1205
1365
|
}
|
|
1206
1366
|
getModalFeedback(outcomes) {
|
|
1207
|
-
const feedbackEls =
|
|
1367
|
+
const feedbackEls = this.itemDocument.findModalFeedbackElements();
|
|
1208
1368
|
const active = [];
|
|
1209
1369
|
for (const el of feedbackEls) {
|
|
1210
|
-
const identifier =
|
|
1211
|
-
const outcomeIdentifier =
|
|
1212
|
-
const showHide = (
|
|
1213
|
-
const title =
|
|
1214
|
-
const contentRaw =
|
|
1370
|
+
const identifier = this.getAttrMapped(el, 'identifier') || '';
|
|
1371
|
+
const outcomeIdentifier = this.getAttrMapped(el, 'outcomeIdentifier') || '';
|
|
1372
|
+
const showHide = (this.getAttrMapped(el, 'showHide') || 'show');
|
|
1373
|
+
const title = this.getAttrMapped(el, 'title') || undefined;
|
|
1374
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
1215
1375
|
const sanitized = sanitizeHtml(contentRaw, { security: this.config.security });
|
|
1216
1376
|
const content = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
1217
1377
|
const outcomeValue = outcomes[outcomeIdentifier];
|
|
@@ -1233,3 +1393,14 @@ function mergePnp(base, partial) {
|
|
|
1233
1393
|
cognitive: { ...(base?.cognitive ?? {}), ...(partial.cognitive ?? {}) },
|
|
1234
1394
|
};
|
|
1235
1395
|
}
|
|
1396
|
+
function createSessionGuid() {
|
|
1397
|
+
if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) {
|
|
1398
|
+
return crypto.randomUUID();
|
|
1399
|
+
}
|
|
1400
|
+
return `item-session-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
1401
|
+
}
|
|
1402
|
+
function looksLikeCatalogUrl(value) {
|
|
1403
|
+
const trimmed = value.trim();
|
|
1404
|
+
return /^(https?:\/\/|\/\/|\/|\.{0,2}\/|data:|blob:)/i.test(trimmed) ||
|
|
1405
|
+
/\.(png|jpe?g|gif|webp|svg|mp3|wav|ogg|mp4|webm|pdf)(\?.*)?$/i.test(trimmed);
|
|
1406
|
+
}
|