@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,411 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for applyGlossaryTriggers using a minimal DOM mock.
|
|
3
|
-
* We set up a lightweight global DOM before each test so the module
|
|
4
|
-
* can call document.createElement, querySelectorAll, etc.
|
|
5
|
-
*/
|
|
6
|
-
import { describe, it, expect, beforeEach, afterEach } from 'bun:test';
|
|
7
|
-
import { applyGlossaryTriggers } from '../catalog/applyGlossaryTriggers.js';
|
|
8
|
-
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Minimal DOM bootstrap (no external deps)
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
type Attrs = Record<string, string>;
|
|
14
|
-
type EventMap = Record<string, ((...args: any[]) => void)[]>;
|
|
15
|
-
|
|
16
|
-
class FakeElement {
|
|
17
|
-
tagName: string;
|
|
18
|
-
className = '';
|
|
19
|
-
textContent = '';
|
|
20
|
-
innerHTML = '';
|
|
21
|
-
style: Record<string, string> = {};
|
|
22
|
-
children: FakeElement[] = [];
|
|
23
|
-
parent: FakeElement | null = null;
|
|
24
|
-
private attrs: Attrs = {};
|
|
25
|
-
private events: EventMap = {};
|
|
26
|
-
|
|
27
|
-
constructor(tag: string) {
|
|
28
|
-
this.tagName = tag.toUpperCase();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
setAttribute(name: string, value: string) { this.attrs[name] = value; }
|
|
32
|
-
getAttribute(name: string) { return this.attrs[name] ?? null; }
|
|
33
|
-
removeAttribute(name: string) { delete this.attrs[name]; }
|
|
34
|
-
hasAttribute(name: string) { return name in this.attrs; }
|
|
35
|
-
|
|
36
|
-
appendChild<T extends FakeElement>(child: T): T {
|
|
37
|
-
// Detach from previous parent (matches real DOM behavior)
|
|
38
|
-
if (child.parent && child.parent !== this) {
|
|
39
|
-
child.parent.children = child.parent.children.filter((c) => c !== child);
|
|
40
|
-
}
|
|
41
|
-
child.parent = this;
|
|
42
|
-
if (!this.children.includes(child)) {
|
|
43
|
-
this.children.push(child);
|
|
44
|
-
}
|
|
45
|
-
return child;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
insertBefore<T extends FakeElement>(newChild: T, ref: FakeElement | null): T {
|
|
49
|
-
if (ref === null || !this.children.includes(ref)) {
|
|
50
|
-
return this.appendChild(newChild);
|
|
51
|
-
}
|
|
52
|
-
const idx = this.children.indexOf(ref);
|
|
53
|
-
newChild.parent = this;
|
|
54
|
-
this.children.splice(idx, 0, newChild);
|
|
55
|
-
return newChild;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
remove() {
|
|
59
|
-
if (this.parent) {
|
|
60
|
-
this.parent.children = this.parent.children.filter((c) => c !== this);
|
|
61
|
-
this.parent = null;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
addEventListener(type: string, handler: (...args: any[]) => void) {
|
|
66
|
-
(this.events[type] ??= []).push(handler);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
removeEventListener(type: string, handler: (...args: any[]) => void) {
|
|
70
|
-
this.events[type] = (this.events[type] ?? []).filter((h) => h !== handler);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
dispatchEvent(event: any): boolean {
|
|
74
|
-
for (const h of this.events[event.type] ?? []) h(event);
|
|
75
|
-
if (event.bubbles && this.parent) this.parent.dispatchEvent(event);
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
focus() {}
|
|
80
|
-
|
|
81
|
-
// querySelectorAll for [data-catalog-idref] and focusable selectors
|
|
82
|
-
querySelectorAll(selector: string): FakeElement[] {
|
|
83
|
-
const results: FakeElement[] = [];
|
|
84
|
-
const visit = (el: FakeElement) => {
|
|
85
|
-
if (matchesSelector(el, selector)) results.push(el);
|
|
86
|
-
for (const c of el.children) visit(c);
|
|
87
|
-
};
|
|
88
|
-
for (const c of this.children) visit(c);
|
|
89
|
-
return results;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// offsetParent: fake non-null so focusable elements are considered visible
|
|
93
|
-
get offsetParent(): FakeElement | null { return this.parent ?? new FakeElement('body'); }
|
|
94
|
-
|
|
95
|
-
get parentNode() { return this.parent; }
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
class FakeEvent {
|
|
99
|
-
type: string;
|
|
100
|
-
bubbles: boolean;
|
|
101
|
-
composed: boolean;
|
|
102
|
-
detail: any;
|
|
103
|
-
defaultPrevented = false;
|
|
104
|
-
key = '';
|
|
105
|
-
shiftKey = false;
|
|
106
|
-
|
|
107
|
-
constructor(type: string, opts: any = {}) {
|
|
108
|
-
this.type = type;
|
|
109
|
-
this.bubbles = opts.bubbles ?? false;
|
|
110
|
-
this.composed = opts.composed ?? false;
|
|
111
|
-
this.detail = opts.detail ?? {};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
preventDefault() { this.defaultPrevented = true; }
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class FakeDocument {
|
|
118
|
-
createElement(tag: string): FakeElement {
|
|
119
|
-
return new FakeElement(tag);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Simple CSS selector matching for our tests
|
|
124
|
-
function matchesSelector(el: FakeElement, selector: string): boolean {
|
|
125
|
-
// [data-catalog-idref]
|
|
126
|
-
if (selector === '[data-catalog-idref]') {
|
|
127
|
-
return el.getAttribute('data-catalog-idref') !== null;
|
|
128
|
-
}
|
|
129
|
-
// focusable selector used by the focus trap
|
|
130
|
-
if (selector.includes('button:not([disabled])')) {
|
|
131
|
-
return el.tagName === 'BUTTON' && el.getAttribute('disabled') === null;
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
let savedDocument: any;
|
|
137
|
-
let savedCustomEvent: any;
|
|
138
|
-
let savedEvent: any;
|
|
139
|
-
|
|
140
|
-
function makeEnv() {
|
|
141
|
-
savedDocument = (globalThis as any).document;
|
|
142
|
-
savedCustomEvent = (globalThis as any).CustomEvent;
|
|
143
|
-
savedEvent = (globalThis as any).Event;
|
|
144
|
-
const doc = new FakeDocument();
|
|
145
|
-
(globalThis as any).document = doc;
|
|
146
|
-
(globalThis as any).CustomEvent = FakeEvent;
|
|
147
|
-
(globalThis as any).Event = FakeEvent;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function clearEnv() {
|
|
151
|
-
if (savedDocument !== undefined) (globalThis as any).document = savedDocument;
|
|
152
|
-
else delete (globalThis as any).document;
|
|
153
|
-
if (savedCustomEvent !== undefined) (globalThis as any).CustomEvent = savedCustomEvent;
|
|
154
|
-
else delete (globalThis as any).CustomEvent;
|
|
155
|
-
if (savedEvent !== undefined) (globalThis as any).Event = savedEvent;
|
|
156
|
-
else delete (globalThis as any).Event;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// ---------------------------------------------------------------------------
|
|
160
|
-
// Test helpers
|
|
161
|
-
// ---------------------------------------------------------------------------
|
|
162
|
-
|
|
163
|
-
const CATALOG_XML = `
|
|
164
|
-
<qti-catalog-info>
|
|
165
|
-
<qti-card identifier="word-osmosis">
|
|
166
|
-
<qti-card-entry usage="glossary-on-screen" xml:lang="en">
|
|
167
|
-
<qti-html-content>Movement of water through a membrane.</qti-html-content>
|
|
168
|
-
</qti-card-entry>
|
|
169
|
-
<qti-card-entry usage="keyword-translation" xml:lang="es">
|
|
170
|
-
<qti-html-content>ósmosis</qti-html-content>
|
|
171
|
-
</qti-card-entry>
|
|
172
|
-
<qti-card-entry usage="tts-pronunciation">
|
|
173
|
-
<qti-html-content>oz-MOH-sis</qti-html-content>
|
|
174
|
-
</qti-card-entry>
|
|
175
|
-
</qti-card>
|
|
176
|
-
</qti-catalog-info>
|
|
177
|
-
`;
|
|
178
|
-
|
|
179
|
-
const ITEM_XML = `<?xml version="1.0" encoding="UTF-8"?>
|
|
180
|
-
<qti-assessment-item
|
|
181
|
-
xmlns="http://www.imsglobal.org/xsd/imsqtiasi_v3p0"
|
|
182
|
-
identifier="glossary-test" title="Glossary Test" adaptive="false" time-dependent="false">
|
|
183
|
-
<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>
|
|
184
|
-
<qti-outcome-declaration identifier="SCORE" cardinality="single" base-type="float"/>
|
|
185
|
-
${CATALOG_XML}
|
|
186
|
-
<qti-item-body>
|
|
187
|
-
<p>The process of <span data-catalog-idref="word-osmosis">osmosis</span> is important.</p>
|
|
188
|
-
<qti-choice-interaction response-identifier="RESPONSE" max-choices="1">
|
|
189
|
-
<qti-simple-choice identifier="A">True</qti-simple-choice>
|
|
190
|
-
</qti-choice-interaction>
|
|
191
|
-
</qti-item-body>
|
|
192
|
-
</qti-assessment-item>`;
|
|
193
|
-
|
|
194
|
-
function makeMockPlayer(pnp: any, catalog: Record<string, Record<string, string | null>> = {}) {
|
|
195
|
-
return {
|
|
196
|
-
getPnp: () => pnp,
|
|
197
|
-
getCatalogEntry: (idref: string, usage: string, _lang?: string) => {
|
|
198
|
-
return catalog[idref]?.[usage] ?? null;
|
|
199
|
-
},
|
|
200
|
-
getComponentRegistry: () => ({
|
|
201
|
-
getTagNameForType: (_type: string) => null,
|
|
202
|
-
}),
|
|
203
|
-
} as any;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// ---------------------------------------------------------------------------
|
|
207
|
-
// Tests
|
|
208
|
-
// ---------------------------------------------------------------------------
|
|
209
|
-
|
|
210
|
-
describe('applyGlossaryTriggers', () => {
|
|
211
|
-
beforeEach(() => makeEnv());
|
|
212
|
-
afterEach(() => clearEnv());
|
|
213
|
-
|
|
214
|
-
it('does nothing when pnp is undefined', () => {
|
|
215
|
-
const container = new FakeElement('div') as any;
|
|
216
|
-
const term = new FakeElement('span') as any;
|
|
217
|
-
term.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
218
|
-
term.textContent = 'osmosis';
|
|
219
|
-
container.appendChild(term);
|
|
220
|
-
|
|
221
|
-
applyGlossaryTriggers(container, makeMockPlayer(undefined));
|
|
222
|
-
// No wrapper or button children should have been added
|
|
223
|
-
expect(container.children.length).toBe(1);
|
|
224
|
-
expect(container.children[0]).toBe(term);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('does nothing when neither glossaryOnScreen nor keywordTranslation is active', () => {
|
|
228
|
-
const container = new FakeElement('div') as any;
|
|
229
|
-
const term = new FakeElement('span') as any;
|
|
230
|
-
term.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
231
|
-
container.appendChild(term);
|
|
232
|
-
|
|
233
|
-
applyGlossaryTriggers(container, makeMockPlayer({ content: { glossaryOnScreen: false } }));
|
|
234
|
-
expect(container.children.length).toBe(1);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('wraps term in a .qti-catalog-term span and adds a trigger button when glossaryOnScreen', () => {
|
|
238
|
-
const container = new FakeElement('div') as any;
|
|
239
|
-
const term = new FakeElement('span') as any;
|
|
240
|
-
term.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
241
|
-
term.textContent = 'osmosis';
|
|
242
|
-
container.appendChild(term);
|
|
243
|
-
|
|
244
|
-
const player = makeMockPlayer(
|
|
245
|
-
{ content: { glossaryOnScreen: true } },
|
|
246
|
-
{ 'word-osmosis': { 'glossary-on-screen': 'Movement of water.' } }
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
applyGlossaryTriggers(container, player);
|
|
250
|
-
|
|
251
|
-
// The container's first child should now be the wrapper
|
|
252
|
-
const wrapper = container.children[0];
|
|
253
|
-
expect(wrapper.className).toBe('qti-catalog-term');
|
|
254
|
-
// Wrapper should contain the original term + 1 trigger button
|
|
255
|
-
expect(wrapper.children.length).toBe(2);
|
|
256
|
-
const btn = wrapper.children[1];
|
|
257
|
-
expect(btn.tagName).toBe('BUTTON');
|
|
258
|
-
expect(btn.getAttribute('aria-label')).toBe('Show definition: osmosis');
|
|
259
|
-
expect(btn.getAttribute('data-catalog-usage')).toBe('glossary-on-screen');
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('adds a keyword-translation trigger when keywordTranslation is active', () => {
|
|
263
|
-
const container = new FakeElement('div') as any;
|
|
264
|
-
const term = new FakeElement('span') as any;
|
|
265
|
-
term.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
266
|
-
term.textContent = 'osmosis';
|
|
267
|
-
container.appendChild(term);
|
|
268
|
-
|
|
269
|
-
const player = makeMockPlayer(
|
|
270
|
-
{ content: { keywordTranslation: { active: true, languageCode: 'es' } } },
|
|
271
|
-
{ 'word-osmosis': { 'keyword-translation': 'ósmosis' } }
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
applyGlossaryTriggers(container, player);
|
|
275
|
-
|
|
276
|
-
const wrapper = container.children[0];
|
|
277
|
-
// Should have term + 1 kw-translation button
|
|
278
|
-
const btn = wrapper.children.find((c: FakeElement) => c.getAttribute('data-catalog-usage') === 'keyword-translation');
|
|
279
|
-
expect(btn).toBeDefined();
|
|
280
|
-
expect((btn as FakeElement).getAttribute('aria-label')).toBe('Show definition: osmosis');
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('clicking a glossary trigger creates a popup with the entry HTML', () => {
|
|
284
|
-
const container = new FakeElement('div') as any;
|
|
285
|
-
const term = new FakeElement('span') as any;
|
|
286
|
-
term.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
287
|
-
term.textContent = 'osmosis';
|
|
288
|
-
container.appendChild(term);
|
|
289
|
-
|
|
290
|
-
const player = makeMockPlayer(
|
|
291
|
-
{ content: { glossaryOnScreen: true } },
|
|
292
|
-
{ 'word-osmosis': { 'glossary-on-screen': 'Movement of water.' } }
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
applyGlossaryTriggers(container, player);
|
|
296
|
-
|
|
297
|
-
const wrapper = container.children[0];
|
|
298
|
-
const btn = wrapper.children[1];
|
|
299
|
-
|
|
300
|
-
// Click opens popup
|
|
301
|
-
btn.dispatchEvent(new FakeEvent('click', {}));
|
|
302
|
-
|
|
303
|
-
// Wrapper should now have: term + triggerBtn + popup
|
|
304
|
-
const popup = wrapper.children.find((c: FakeElement) => c.getAttribute('role') === 'dialog');
|
|
305
|
-
expect(popup).toBeDefined();
|
|
306
|
-
expect(popup!.getAttribute('aria-label')).toBe('osmosis');
|
|
307
|
-
expect(popup!.getAttribute('aria-modal')).toBe('true');
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it('clicking trigger again closes the open popup', () => {
|
|
311
|
-
const container = new FakeElement('div') as any;
|
|
312
|
-
const term = new FakeElement('span') as any;
|
|
313
|
-
term.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
314
|
-
term.textContent = 'osmosis';
|
|
315
|
-
container.appendChild(term);
|
|
316
|
-
|
|
317
|
-
const player = makeMockPlayer(
|
|
318
|
-
{ content: { glossaryOnScreen: true } },
|
|
319
|
-
{ 'word-osmosis': { 'glossary-on-screen': 'Movement of water.' } }
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
applyGlossaryTriggers(container, player);
|
|
323
|
-
const wrapper = container.children[0];
|
|
324
|
-
const btn = wrapper.children[1];
|
|
325
|
-
|
|
326
|
-
btn.dispatchEvent(new FakeEvent('click', {}));
|
|
327
|
-
expect(wrapper.children.some((c: FakeElement) => c.getAttribute('role') === 'dialog')).toBe(true);
|
|
328
|
-
|
|
329
|
-
btn.dispatchEvent(new FakeEvent('click', {}));
|
|
330
|
-
expect(wrapper.children.some((c: FakeElement) => c.getAttribute('role') === 'dialog')).toBe(false);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
it('does not open popup when catalog entry is null', () => {
|
|
334
|
-
const container = new FakeElement('div') as any;
|
|
335
|
-
const term = new FakeElement('span') as any;
|
|
336
|
-
term.setAttribute('data-catalog-idref', 'unknown-term');
|
|
337
|
-
term.textContent = 'unknown';
|
|
338
|
-
container.appendChild(term);
|
|
339
|
-
|
|
340
|
-
const player = makeMockPlayer({ content: { glossaryOnScreen: true } }, {});
|
|
341
|
-
|
|
342
|
-
applyGlossaryTriggers(container, player);
|
|
343
|
-
const wrapper = container.children[0];
|
|
344
|
-
const btn = wrapper.children[1];
|
|
345
|
-
btn.dispatchEvent(new FakeEvent('click', {}));
|
|
346
|
-
|
|
347
|
-
expect(wrapper.children.some((c: FakeElement) => c.getAttribute('role') === 'dialog')).toBe(false);
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('fires qti-catalog-lookup CustomEvent for platform usages (tts-pronunciation)', () => {
|
|
351
|
-
const container = new FakeElement('div') as any;
|
|
352
|
-
const term = new FakeElement('span') as any;
|
|
353
|
-
term.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
354
|
-
term.textContent = 'osmosis';
|
|
355
|
-
container.appendChild(term);
|
|
356
|
-
|
|
357
|
-
const firedEvents: any[] = [];
|
|
358
|
-
container.addEventListener('qti-catalog-lookup', (e: any) => firedEvents.push(e));
|
|
359
|
-
// Override addEventListener to track bubbled events from term
|
|
360
|
-
const origDispatch = term.dispatchEvent.bind(term);
|
|
361
|
-
term.dispatchEvent = (e: any) => {
|
|
362
|
-
if (e.type === 'qti-catalog-lookup') firedEvents.push(e);
|
|
363
|
-
return origDispatch(e);
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
const player = makeMockPlayer(
|
|
367
|
-
{ content: { glossaryOnScreen: true } },
|
|
368
|
-
{ 'word-osmosis': { 'glossary-on-screen': 'Movement of water.', 'tts-pronunciation': 'oz-MOH-sis' } }
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
applyGlossaryTriggers(container, player);
|
|
372
|
-
|
|
373
|
-
const ttsFired = firedEvents.find((e) => e.detail?.usage === 'tts-pronunciation');
|
|
374
|
-
expect(ttsFired).toBeDefined();
|
|
375
|
-
expect(ttsFired.detail.idref).toBe('word-osmosis');
|
|
376
|
-
expect(ttsFired.detail.html).toBe('oz-MOH-sis');
|
|
377
|
-
// No popup was created for tts-pronunciation
|
|
378
|
-
const wrapper = container.children[0];
|
|
379
|
-
expect(wrapper.children.some((c: FakeElement) => c.getAttribute('role') === 'dialog')).toBe(false);
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
it('handles multiple catalog terms independently', () => {
|
|
383
|
-
const container = new FakeElement('div') as any;
|
|
384
|
-
|
|
385
|
-
const term1 = new FakeElement('span') as any;
|
|
386
|
-
term1.setAttribute('data-catalog-idref', 'word-osmosis');
|
|
387
|
-
term1.textContent = 'osmosis';
|
|
388
|
-
|
|
389
|
-
const term2 = new FakeElement('span') as any;
|
|
390
|
-
term2.setAttribute('data-catalog-idref', 'word-mitosis');
|
|
391
|
-
term2.textContent = 'mitosis';
|
|
392
|
-
|
|
393
|
-
container.appendChild(term1);
|
|
394
|
-
container.appendChild(term2);
|
|
395
|
-
|
|
396
|
-
const player = makeMockPlayer(
|
|
397
|
-
{ content: { glossaryOnScreen: true } },
|
|
398
|
-
{
|
|
399
|
-
'word-osmosis': { 'glossary-on-screen': 'Water movement.' },
|
|
400
|
-
'word-mitosis': { 'glossary-on-screen': 'Cell division.' },
|
|
401
|
-
}
|
|
402
|
-
);
|
|
403
|
-
|
|
404
|
-
applyGlossaryTriggers(container, player);
|
|
405
|
-
|
|
406
|
-
// Two wrappers should exist
|
|
407
|
-
expect(container.children.length).toBe(2);
|
|
408
|
-
expect(container.children[0].className).toBe('qti-catalog-term');
|
|
409
|
-
expect(container.children[1].className).toBe('qti-catalog-term');
|
|
410
|
-
});
|
|
411
|
-
});
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'bun:test';
|
|
2
|
-
import { parsePnpXml } from '../pnp/parsePnpXml.js';
|
|
3
|
-
import { applyPnpToRoot } from '../pnp/applyPnp.js';
|
|
4
|
-
import { Player } from '../core/Player.js';
|
|
5
|
-
import type { PnpProfile } from '../pnp/types.js';
|
|
6
|
-
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// parsePnpXml
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
describe('parsePnpXml', () => {
|
|
12
|
-
it('parses default color scheme', () => {
|
|
13
|
-
const profile = parsePnpXml(`
|
|
14
|
-
<personalNeedsProfile>
|
|
15
|
-
<display>
|
|
16
|
-
<colorScheme value="default"/>
|
|
17
|
-
</display>
|
|
18
|
-
</personalNeedsProfile>
|
|
19
|
-
`);
|
|
20
|
-
expect(profile.display?.colorScheme).toBe('default');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it.each(['blackwhite', 'whitenav', 'blackcream', 'yellowblue', 'medgray'] as const)(
|
|
24
|
-
'parses color scheme "%s"',
|
|
25
|
-
(scheme) => {
|
|
26
|
-
const profile = parsePnpXml(`
|
|
27
|
-
<personalNeedsProfile>
|
|
28
|
-
<display>
|
|
29
|
-
<colorScheme value="${scheme}"/>
|
|
30
|
-
</display>
|
|
31
|
-
</personalNeedsProfile>
|
|
32
|
-
`);
|
|
33
|
-
expect(profile.display?.colorScheme).toBe(scheme);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
it('ignores unknown color scheme values', () => {
|
|
38
|
-
const profile = parsePnpXml(`
|
|
39
|
-
<personalNeedsProfile>
|
|
40
|
-
<display>
|
|
41
|
-
<colorScheme value="neon-pink"/>
|
|
42
|
-
</display>
|
|
43
|
-
</personalNeedsProfile>
|
|
44
|
-
`);
|
|
45
|
-
expect(profile.display?.colorScheme).toBeUndefined();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('parses extendedTime', () => {
|
|
49
|
-
const profile = parsePnpXml(`
|
|
50
|
-
<personalNeedsProfile>
|
|
51
|
-
<content>
|
|
52
|
-
<extendedTime active="true" multiplier="1.5"/>
|
|
53
|
-
</content>
|
|
54
|
-
</personalNeedsProfile>
|
|
55
|
-
`);
|
|
56
|
-
expect(profile.content?.extendedTime).toEqual({ active: true, multiplier: 1.5 });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('parses extendedTime with Infinity multiplier', () => {
|
|
60
|
-
const profile = parsePnpXml(`
|
|
61
|
-
<personalNeedsProfile>
|
|
62
|
-
<content>
|
|
63
|
-
<extendedTime active="true" multiplier="Infinity"/>
|
|
64
|
-
</content>
|
|
65
|
-
</personalNeedsProfile>
|
|
66
|
-
`);
|
|
67
|
-
expect(profile.content?.extendedTime?.multiplier).toBe(Infinity);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('parses glossaryOnScreen', () => {
|
|
71
|
-
const profile = parsePnpXml(`
|
|
72
|
-
<personalNeedsProfile>
|
|
73
|
-
<content>
|
|
74
|
-
<glossaryOnScreen enabled="true"/>
|
|
75
|
-
</content>
|
|
76
|
-
</personalNeedsProfile>
|
|
77
|
-
`);
|
|
78
|
-
expect(profile.content?.glossaryOnScreen).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('parses keywordTranslation', () => {
|
|
82
|
-
const profile = parsePnpXml(`
|
|
83
|
-
<personalNeedsProfile>
|
|
84
|
-
<content>
|
|
85
|
-
<keywordTranslation active="true" languageCode="es"/>
|
|
86
|
-
</content>
|
|
87
|
-
</personalNeedsProfile>
|
|
88
|
-
`);
|
|
89
|
-
expect(profile.content?.keywordTranslation).toEqual({ active: true, languageCode: 'es' });
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('parses eliminationTool', () => {
|
|
93
|
-
const profile = parsePnpXml(`
|
|
94
|
-
<personalNeedsProfile>
|
|
95
|
-
<cognitive>
|
|
96
|
-
<eliminationTool enabled="true"/>
|
|
97
|
-
</cognitive>
|
|
98
|
-
</personalNeedsProfile>
|
|
99
|
-
`);
|
|
100
|
-
expect(profile.cognitive?.eliminationTool).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('silently ignores unknown child elements', () => {
|
|
104
|
-
expect(() =>
|
|
105
|
-
parsePnpXml(`
|
|
106
|
-
<personalNeedsProfile>
|
|
107
|
-
<display>
|
|
108
|
-
<unknownFutureThing value="42"/>
|
|
109
|
-
</display>
|
|
110
|
-
<futureSection>
|
|
111
|
-
<anotherThing/>
|
|
112
|
-
</futureSection>
|
|
113
|
-
</personalNeedsProfile>
|
|
114
|
-
`)
|
|
115
|
-
).not.toThrow();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('returns empty profile for empty input', () => {
|
|
119
|
-
const profile = parsePnpXml('');
|
|
120
|
-
expect(profile).toEqual({});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('returns empty profile when no recognized root element', () => {
|
|
124
|
-
// parsePnpXml with an unrecognised root gracefully returns {}
|
|
125
|
-
const profile = parsePnpXml('<somethingElse><display/></somethingElse>');
|
|
126
|
-
expect(profile).toEqual({});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
// applyPnpToRoot — uses a minimal object that satisfies the HTMLElement contract
|
|
132
|
-
// ---------------------------------------------------------------------------
|
|
133
|
-
|
|
134
|
-
function makeEl(): HTMLElement {
|
|
135
|
-
const attrs: Record<string, string> = {};
|
|
136
|
-
return {
|
|
137
|
-
setAttribute(k: string, v: string) { attrs[k] = v; },
|
|
138
|
-
removeAttribute(k: string) { delete attrs[k]; },
|
|
139
|
-
hasAttribute(k: string) { return k in attrs; },
|
|
140
|
-
getAttribute(k: string) { return attrs[k] ?? null; },
|
|
141
|
-
} as unknown as HTMLElement;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
describe('applyPnpToRoot', () => {
|
|
145
|
-
it('sets data-qti-colorscheme for a non-default scheme', () => {
|
|
146
|
-
const el = makeEl();
|
|
147
|
-
applyPnpToRoot(el, { display: { colorScheme: 'blackwhite' } });
|
|
148
|
-
expect(el.getAttribute('data-qti-colorscheme')).toBe('blackwhite');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('removes the attribute for "default" scheme', () => {
|
|
152
|
-
const el = makeEl();
|
|
153
|
-
el.setAttribute('data-qti-colorscheme', 'blackwhite');
|
|
154
|
-
applyPnpToRoot(el, { display: { colorScheme: 'default' } });
|
|
155
|
-
expect(el.hasAttribute('data-qti-colorscheme')).toBe(false);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('removes the attribute when pnp is undefined', () => {
|
|
159
|
-
const el = makeEl();
|
|
160
|
-
el.setAttribute('data-qti-colorscheme', 'blackwhite');
|
|
161
|
-
applyPnpToRoot(el, undefined);
|
|
162
|
-
expect(el.hasAttribute('data-qti-colorscheme')).toBe(false);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('removes the attribute when colorScheme is undefined', () => {
|
|
166
|
-
const el = makeEl();
|
|
167
|
-
el.setAttribute('data-qti-colorscheme', 'blackwhite');
|
|
168
|
-
applyPnpToRoot(el, { display: {} });
|
|
169
|
-
expect(el.hasAttribute('data-qti-colorscheme')).toBe(false);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it.each(['blackwhite', 'whitenav', 'blackcream', 'yellowblue', 'medgray'] as const)(
|
|
173
|
-
'sets correct attribute value for scheme "%s"',
|
|
174
|
-
(scheme) => {
|
|
175
|
-
const el = makeEl();
|
|
176
|
-
applyPnpToRoot(el, { display: { colorScheme: scheme } });
|
|
177
|
-
expect(el.getAttribute('data-qti-colorscheme')).toBe(scheme);
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// ---------------------------------------------------------------------------
|
|
183
|
-
// Player.applyPnp / Player.updatePnp
|
|
184
|
-
// ---------------------------------------------------------------------------
|
|
185
|
-
|
|
186
|
-
const MINIMAL_ITEM_XML = `<?xml version="1.0" encoding="UTF-8"?>
|
|
187
|
-
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2"
|
|
188
|
-
identifier="test" title="Test" adaptive="false" timeDependent="false">
|
|
189
|
-
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier"/>
|
|
190
|
-
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float"/>
|
|
191
|
-
<itemBody><choiceInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
192
|
-
<simpleChoice identifier="A">Alpha</simpleChoice>
|
|
193
|
-
<simpleChoice identifier="B">Beta</simpleChoice>
|
|
194
|
-
</choiceInteraction></itemBody>
|
|
195
|
-
</assessmentItem>`;
|
|
196
|
-
|
|
197
|
-
describe('Player PNP integration', () => {
|
|
198
|
-
it('applyPnp sets the color scheme attribute on the root element', () => {
|
|
199
|
-
const player = new Player({
|
|
200
|
-
itemXml: MINIMAL_ITEM_XML,
|
|
201
|
-
pnp: { display: { colorScheme: 'yellowblue' } },
|
|
202
|
-
});
|
|
203
|
-
const root = makeEl();
|
|
204
|
-
player.applyPnp(root);
|
|
205
|
-
expect(root.getAttribute('data-qti-colorscheme')).toBe('yellowblue');
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('updatePnp changes the attribute without re-parsing the item', () => {
|
|
209
|
-
const player = new Player({ itemXml: MINIMAL_ITEM_XML });
|
|
210
|
-
const root = makeEl();
|
|
211
|
-
player.applyPnp(root);
|
|
212
|
-
|
|
213
|
-
expect(root.hasAttribute('data-qti-colorscheme')).toBe(false);
|
|
214
|
-
|
|
215
|
-
player.updatePnp({ display: { colorScheme: 'blackwhite' } });
|
|
216
|
-
expect(root.getAttribute('data-qti-colorscheme')).toBe('blackwhite');
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('updatePnp deep-merges without losing other fields', () => {
|
|
220
|
-
const player = new Player({
|
|
221
|
-
itemXml: MINIMAL_ITEM_XML,
|
|
222
|
-
pnp: { cognitive: { eliminationTool: true }, display: { colorScheme: 'blackwhite' } },
|
|
223
|
-
});
|
|
224
|
-
const root = makeEl();
|
|
225
|
-
player.applyPnp(root);
|
|
226
|
-
|
|
227
|
-
player.updatePnp({ display: { colorScheme: 'medgray' } });
|
|
228
|
-
|
|
229
|
-
expect(root.getAttribute('data-qti-colorscheme')).toBe('medgray');
|
|
230
|
-
expect(player.getPnp()?.cognitive?.eliminationTool).toBe(true);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('updatePnp to default removes the attribute', () => {
|
|
234
|
-
const player = new Player({
|
|
235
|
-
itemXml: MINIMAL_ITEM_XML,
|
|
236
|
-
pnp: { display: { colorScheme: 'blackwhite' } },
|
|
237
|
-
});
|
|
238
|
-
const root = makeEl();
|
|
239
|
-
player.applyPnp(root);
|
|
240
|
-
|
|
241
|
-
player.updatePnp({ display: { colorScheme: 'default' } });
|
|
242
|
-
expect(root.hasAttribute('data-qti-colorscheme')).toBe(false);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('getPnp returns the current profile', () => {
|
|
246
|
-
const pnp: PnpProfile = { cognitive: { eliminationTool: true } };
|
|
247
|
-
const player = new Player({ itemXml: MINIMAL_ITEM_XML, pnp });
|
|
248
|
-
expect(player.getPnp()?.cognitive?.eliminationTool).toBe(true);
|
|
249
|
-
});
|
|
250
|
-
});
|