@pie-qti/item-player 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -18
- package/dist/catalog/applyGlossaryTriggers.d.ts +15 -0
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -0
- package/dist/catalog/applyGlossaryTriggers.js +193 -0
- package/dist/catalog/catalogExtractor.d.ts +18 -0
- package/dist/catalog/catalogExtractor.d.ts.map +1 -0
- package/dist/catalog/catalogExtractor.js +114 -0
- package/dist/catalog/catalogLookup.d.ts +18 -0
- package/dist/catalog/catalogLookup.d.ts.map +1 -0
- package/dist/catalog/catalogLookup.js +44 -0
- package/dist/catalog/glossaryAction.d.ts +17 -0
- package/dist/catalog/glossaryAction.d.ts.map +1 -0
- package/dist/catalog/glossaryAction.js +21 -0
- package/dist/catalog/types.d.ts +26 -0
- package/dist/catalog/types.d.ts.map +1 -0
- package/dist/catalog/types.js +6 -0
- package/dist/core/ComponentRegistry.d.ts +14 -4
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +25 -4
- package/dist/core/ItemRenderer.d.ts.map +1 -1
- package/dist/core/ItemRenderer.js +8 -18
- package/dist/core/Player.d.ts +53 -1
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +195 -142
- package/dist/core/rolePolicy.d.ts +16 -0
- package/dist/core/rolePolicy.d.ts.map +1 -0
- package/dist/core/rolePolicy.js +15 -0
- package/dist/core/urlPolicy.d.ts.map +1 -1
- package/dist/core/urlPolicy.js +5 -2
- 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.d.ts +22 -0
- package/dist/element.js +5548 -0
- package/dist/element.js.map +1 -0
- package/dist/extraction/ExtractionRegistry.d.ts.map +1 -1
- package/dist/extraction/ExtractionRegistry.js +3 -1
- package/dist/extraction/extractors/associateExtractor.d.ts +1 -27
- package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/associateExtractor.js +1 -94
- package/dist/extraction/extractors/choiceExtractor.d.ts +1 -24
- package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/choiceExtractor.js +1 -83
- 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 -57
- package/dist/extraction/extractors/gapMatchExtractor.d.ts +1 -27
- package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/gapMatchExtractor.js +1 -142
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +1 -39
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicAssociateExtractor.js +1 -140
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +1 -41
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/graphicGapMatchExtractor.js +1 -144
- 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 -140
- 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 -120
- package/dist/extraction/extractors/index.d.ts +5 -58
- package/dist/extraction/extractors/index.d.ts.map +1 -1
- package/dist/extraction/extractors/index.js +5 -81
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +1 -21
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/inlineChoiceExtractor.js +1 -67
- package/dist/extraction/extractors/matchExtractor.d.ts +1 -31
- package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/matchExtractor.js +1 -134
- 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 -25
- package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/orderExtractor.js +1 -86
- package/dist/extraction/extractors/portableCustomExtractor.d.ts +2 -0
- package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/portableCustomExtractor.js +1 -0
- 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 -19
- package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -1
- package/dist/extraction/extractors/textEntryExtractor.js +1 -48
- 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 -52
- 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 +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- 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/pci/PciHost.d.ts +53 -0
- package/dist/pci/PciHost.d.ts.map +1 -0
- package/dist/pci/PciHost.js +116 -0
- package/dist/pci/types.d.ts +57 -0
- package/dist/pci/types.d.ts.map +1 -0
- package/dist/pci/types.js +19 -0
- package/dist/pnp/applyPnp.d.ts +9 -0
- package/dist/pnp/applyPnp.d.ts.map +1 -0
- package/dist/pnp/applyPnp.js +19 -0
- package/dist/pnp/parsePnpXml.d.ts +9 -0
- package/dist/pnp/parsePnpXml.d.ts.map +1 -0
- package/dist/pnp/parsePnpXml.js +101 -0
- package/dist/pnp/types.d.ts +40 -0
- package/dist/pnp/types.d.ts.map +1 -0
- package/dist/pnp/types.js +1 -0
- package/dist/types/index.d.ts +22 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interactions.d.ts +4 -319
- 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 +19 -9
- package/src/__tests__/catalog.test.ts +267 -0
- package/src/__tests__/fixtures/pci/echo-pci.js +49 -0
- package/src/__tests__/glossaryTriggers.test.ts +411 -0
- package/src/__tests__/pci.test.ts +353 -0
- package/src/__tests__/pnp.test.ts +250 -0
- package/src/__tests__/qti3-extraction.test.ts +5 -5
- package/src/catalog/applyGlossaryTriggers.ts +232 -0
- package/src/catalog/catalogExtractor.ts +130 -0
- package/src/catalog/catalogLookup.ts +53 -0
- package/src/catalog/glossaryAction.ts +28 -0
- package/src/catalog/types.ts +37 -0
- package/src/components/ItemBody.svelte +105 -135
- package/src/components/ItemPlayer.svelte +15 -7
- package/src/components/ModalFeedbackDisplay.svelte +15 -5
- package/src/components/index.ts +3 -0
- package/src/core/ComponentRegistry.ts +36 -7
- package/src/core/Player.ts +212 -157
- package/src/core/rolePolicy.ts +34 -0
- package/src/core/urlPolicy.ts +5 -2
- package/src/document/AssessmentItemDocument.ts +178 -0
- package/src/element.ts +128 -0
- package/src/extraction/ExtractionRegistry.ts +5 -1
- package/src/extraction/extractors/associateExtractor.ts +1 -129
- package/src/extraction/extractors/choiceExtractor.ts +1 -110
- package/src/extraction/extractors/conformance-qti3-advanced.test.ts +239 -0
- package/src/extraction/extractors/conformance-qti3-basic.test.ts +82 -0
- package/src/extraction/extractors/conformance.test.ts +208 -0
- 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 -83
- package/src/extraction/extractors/gapMatchExtractor.ts +1 -178
- package/src/extraction/extractors/graphicAssociateExtractor.ts +1 -188
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +1 -185
- package/src/extraction/extractors/graphicOrderExtractor.ts +1 -162
- package/src/extraction/extractors/hotspotExtractor.ts +1 -190
- package/src/extraction/extractors/hottextExtractor.ts +1 -153
- package/src/extraction/extractors/index.ts +5 -107
- package/src/extraction/extractors/inlineChoiceExtractor.ts +1 -88
- package/src/extraction/extractors/matchExtractor.ts +1 -160
- package/src/extraction/extractors/mediaExtractor.ts +1 -168
- package/src/extraction/extractors/orderExtractor.ts +1 -114
- package/src/extraction/extractors/portableCustomExtractor.ts +1 -0
- 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 -72
- package/src/extraction/extractors/uploadExtractor.ts +1 -73
- 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 +19 -8
- 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/pci/PciHost.ts +138 -0
- package/src/pci/types.ts +70 -0
- package/src/pnp/applyPnp.ts +23 -0
- package/src/pnp/parsePnpXml.ts +118 -0
- package/src/pnp/types.ts +33 -0
- package/src/types/index.ts +22 -8
- package/src/types/interactions.ts +4 -350
- package/src/web-components/QTIInteractionBase.ts +6 -5
- package/src/web-components/QTIInteractionElement.ts +15 -8
- package/src/web-components/index.ts +1 -0
- package/src/core/ItemRenderer.ts +0 -367
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import type { Player } from '../core/Player.js';
|
|
2
|
+
|
|
3
|
+
const PLATFORM_USAGES = new Set(['tts-pronunciation', 'signing-definition', 'braille-text', 'audio-description']);
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Inject glossary/keyword-translation trigger buttons into a rendered item container.
|
|
7
|
+
*
|
|
8
|
+
* When pnp.content.glossaryOnScreen is true, each [data-catalog-idref] element gets a
|
|
9
|
+
* trigger button. Clicking the button looks up the catalog entry and shows a floating
|
|
10
|
+
* popup rendered by the 'catalogPopup' component from the registry (defaults to
|
|
11
|
+
* pie-qti-catalog-popup). Clicking again or pressing Escape closes it.
|
|
12
|
+
*
|
|
13
|
+
* For platform-level usages (tts-pronunciation, signing-definition, braille-text,
|
|
14
|
+
* audio-description) the player fires a `qti-catalog-lookup` CustomEvent instead of
|
|
15
|
+
* mounting a popup — the host application handles those usages.
|
|
16
|
+
*/
|
|
17
|
+
export function applyGlossaryTriggers(container: HTMLElement, player: Player): void {
|
|
18
|
+
const pnp = player.getPnp();
|
|
19
|
+
if (!pnp) return;
|
|
20
|
+
|
|
21
|
+
const glossaryOn = pnp.content?.glossaryOnScreen === true;
|
|
22
|
+
const kwTranslation = pnp.content?.keywordTranslation;
|
|
23
|
+
const kwOn = kwTranslation?.active === true && !!kwTranslation.languageCode;
|
|
24
|
+
|
|
25
|
+
if (!glossaryOn && !kwOn) return;
|
|
26
|
+
|
|
27
|
+
const terms = container.querySelectorAll<HTMLElement>('[data-catalog-idref]');
|
|
28
|
+
if (terms.length === 0) return;
|
|
29
|
+
|
|
30
|
+
// Track open popup so only one is open at a time
|
|
31
|
+
let currentCleanup: (() => void) | null = null;
|
|
32
|
+
|
|
33
|
+
for (const termEl of Array.from(terms)) {
|
|
34
|
+
const idref = termEl.getAttribute('data-catalog-idref');
|
|
35
|
+
if (!idref) continue;
|
|
36
|
+
|
|
37
|
+
// Wrap term in a relative-positioned span so we can position popup against it
|
|
38
|
+
const wrapper = document.createElement('span');
|
|
39
|
+
wrapper.className = 'qti-catalog-term';
|
|
40
|
+
wrapper.style.cssText = 'position:relative;display:inline';
|
|
41
|
+
|
|
42
|
+
termEl.parentNode?.insertBefore(wrapper, termEl);
|
|
43
|
+
wrapper.appendChild(termEl);
|
|
44
|
+
|
|
45
|
+
if (glossaryOn) {
|
|
46
|
+
const btn = createTriggerButton(termEl.textContent ?? idref, 'glossary-on-screen');
|
|
47
|
+
wrapper.appendChild(btn);
|
|
48
|
+
|
|
49
|
+
btn.addEventListener('click', () => {
|
|
50
|
+
if (currentCleanup) {
|
|
51
|
+
currentCleanup();
|
|
52
|
+
currentCleanup = null;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const html = player.getCatalogEntry(idref, 'glossary-on-screen');
|
|
56
|
+
if (html !== null) {
|
|
57
|
+
currentCleanup = mountPopup(wrapper, termEl.textContent ?? idref, html, btn, player, () => {
|
|
58
|
+
currentCleanup = null;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (kwOn) {
|
|
65
|
+
const lang = kwTranslation!.languageCode;
|
|
66
|
+
const btn = createTriggerButton(termEl.textContent ?? idref, 'keyword-translation');
|
|
67
|
+
wrapper.appendChild(btn);
|
|
68
|
+
|
|
69
|
+
btn.addEventListener('click', () => {
|
|
70
|
+
if (currentCleanup) {
|
|
71
|
+
currentCleanup();
|
|
72
|
+
currentCleanup = null;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const html = player.getCatalogEntry(idref, 'keyword-translation', lang);
|
|
76
|
+
if (html !== null) {
|
|
77
|
+
currentCleanup = mountPopup(wrapper, termEl.textContent ?? idref, html, btn, player, () => {
|
|
78
|
+
currentCleanup = null;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Platform-level usages: fire event, no popup
|
|
85
|
+
for (const usage of PLATFORM_USAGES) {
|
|
86
|
+
const html = player.getCatalogEntry(idref, usage);
|
|
87
|
+
if (html !== null) {
|
|
88
|
+
termEl.dispatchEvent(
|
|
89
|
+
new CustomEvent('qti-catalog-lookup', {
|
|
90
|
+
bubbles: true,
|
|
91
|
+
composed: true,
|
|
92
|
+
detail: { idref, usage, html },
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function createTriggerButton(termText: string, usage: string): HTMLButtonElement {
|
|
101
|
+
const btn = document.createElement('button');
|
|
102
|
+
btn.type = 'button';
|
|
103
|
+
btn.className = 'qti-catalog-trigger';
|
|
104
|
+
btn.setAttribute('aria-label', `Show definition: ${termText}`);
|
|
105
|
+
btn.setAttribute('data-catalog-usage', usage);
|
|
106
|
+
btn.textContent = usage === 'keyword-translation' ? 'T' : '?';
|
|
107
|
+
return btn;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Mount a catalog popup via the component registry. Falls back to a minimal
|
|
112
|
+
* vanilla-JS popup if no 'catalogPopup' component is registered (e.g. in tests
|
|
113
|
+
* that don't load default-components). Returns a cleanup function.
|
|
114
|
+
*/
|
|
115
|
+
function mountPopup(
|
|
116
|
+
anchor: HTMLElement,
|
|
117
|
+
label: string,
|
|
118
|
+
html: string,
|
|
119
|
+
triggerBtn: HTMLButtonElement,
|
|
120
|
+
player: Player,
|
|
121
|
+
onClose: () => void
|
|
122
|
+
): () => void {
|
|
123
|
+
const registry = player.getComponentRegistry();
|
|
124
|
+
|
|
125
|
+
let popupEl: HTMLElement;
|
|
126
|
+
|
|
127
|
+
const catalogPopupTag = registry.getTagNameForType('catalogPopup');
|
|
128
|
+
if (catalogPopupTag !== null) {
|
|
129
|
+
const el = document.createElement(catalogPopupTag) as HTMLElement & {
|
|
130
|
+
content: string;
|
|
131
|
+
label: string;
|
|
132
|
+
onClose: () => void;
|
|
133
|
+
};
|
|
134
|
+
el.content = html;
|
|
135
|
+
el.label = label;
|
|
136
|
+
el.onClose = cleanup;
|
|
137
|
+
anchor.appendChild(el);
|
|
138
|
+
popupEl = el;
|
|
139
|
+
} else {
|
|
140
|
+
// Minimal fallback for environments without default-components
|
|
141
|
+
popupEl = buildFallbackPopup(label, html);
|
|
142
|
+
anchor.appendChild(popupEl);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function cleanup() {
|
|
146
|
+
popupEl.remove();
|
|
147
|
+
triggerBtn.focus();
|
|
148
|
+
onClose();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return cleanup;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Minimal accessible fallback popup used when no catalogPopup component is registered.
|
|
156
|
+
* Uses DaisyUI card classes where available; degrades gracefully without them.
|
|
157
|
+
*/
|
|
158
|
+
function buildFallbackPopup(label: string, html: string): HTMLElement {
|
|
159
|
+
const popup = document.createElement('div');
|
|
160
|
+
popup.className = 'card card-bordered bg-base-100 shadow-lg qti-catalog-popup';
|
|
161
|
+
popup.setAttribute('role', 'dialog');
|
|
162
|
+
popup.setAttribute('aria-label', label);
|
|
163
|
+
popup.setAttribute('aria-modal', 'true');
|
|
164
|
+
popup.style.cssText = 'position:absolute;z-index:1000;min-width:16rem;max-width:24rem';
|
|
165
|
+
|
|
166
|
+
const header = document.createElement('div');
|
|
167
|
+
header.className = 'card-title flex justify-between items-center px-3 py-2 border-b border-base-300 bg-base-200';
|
|
168
|
+
|
|
169
|
+
const title = document.createElement('span');
|
|
170
|
+
title.className = 'text-sm font-semibold';
|
|
171
|
+
title.textContent = label;
|
|
172
|
+
|
|
173
|
+
const closeBtn = document.createElement('button');
|
|
174
|
+
closeBtn.type = 'button';
|
|
175
|
+
closeBtn.className = 'btn btn-ghost btn-xs';
|
|
176
|
+
closeBtn.setAttribute('aria-label', 'Close');
|
|
177
|
+
closeBtn.textContent = '✕';
|
|
178
|
+
|
|
179
|
+
header.appendChild(title);
|
|
180
|
+
header.appendChild(closeBtn);
|
|
181
|
+
|
|
182
|
+
const body = document.createElement('div');
|
|
183
|
+
body.className = 'card-body p-3';
|
|
184
|
+
|
|
185
|
+
const isUrl = /^(https?:\/\/|\/)/i.test(html.trim());
|
|
186
|
+
if (isUrl) {
|
|
187
|
+
const img = document.createElement('img');
|
|
188
|
+
img.src = html.trim();
|
|
189
|
+
img.alt = label;
|
|
190
|
+
img.className = 'max-w-full h-auto block mx-auto';
|
|
191
|
+
body.appendChild(img);
|
|
192
|
+
} else {
|
|
193
|
+
body.innerHTML = html;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
popup.appendChild(header);
|
|
197
|
+
popup.appendChild(body);
|
|
198
|
+
|
|
199
|
+
// Focus trap + Escape
|
|
200
|
+
const focusableSelector = 'a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
201
|
+
|
|
202
|
+
function handleKeyDown(e: KeyboardEvent) {
|
|
203
|
+
if (e.key === 'Escape') {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
closeBtn.click();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (e.key === 'Tab') {
|
|
209
|
+
const focusable = Array.from(popup.querySelectorAll<HTMLElement>(focusableSelector)).filter(
|
|
210
|
+
(el) => el.offsetParent !== null
|
|
211
|
+
);
|
|
212
|
+
if (focusable.length === 0) { e.preventDefault(); return; }
|
|
213
|
+
const first = focusable[0];
|
|
214
|
+
const last = focusable[focusable.length - 1];
|
|
215
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
last.focus();
|
|
218
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
first.focus();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
popup.addEventListener('keydown', handleKeyDown);
|
|
226
|
+
closeBtn.addEventListener('click', () => popup.remove());
|
|
227
|
+
|
|
228
|
+
// Move focus in on next tick
|
|
229
|
+
setTimeout(() => closeBtn.focus(), 0);
|
|
230
|
+
|
|
231
|
+
return popup;
|
|
232
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { parse as parseHtml } from 'node-html-parser';
|
|
2
|
+
import type { HTMLElement as NhpElement } from 'node-html-parser';
|
|
3
|
+
import type { CatalogCard, CatalogEntry, CatalogIndex } from './types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse an XML string containing a QTI 3.0 <qti-catalog-info> element into a CatalogIndex.
|
|
7
|
+
*
|
|
8
|
+
* The mapper is not needed here because we parse the QTI 3.0 element names directly.
|
|
9
|
+
* All element names use lower-case matching (node-html-parser normalises tags).
|
|
10
|
+
*/
|
|
11
|
+
export function extractCatalog(xml: string): CatalogIndex {
|
|
12
|
+
if (!xml.trim()) return new Map();
|
|
13
|
+
|
|
14
|
+
const doc = parseHtml(`<root>${xml}</root>`, { lowerCaseTagName: true });
|
|
15
|
+
|
|
16
|
+
// Find <qti-catalog-info> (QTI 3.0 kebab form)
|
|
17
|
+
const infoEl = doc.querySelector('qti-catalog-info');
|
|
18
|
+
if (!infoEl) return new Map();
|
|
19
|
+
|
|
20
|
+
return buildIndex(infoEl);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Parse a raw QTI item XML string and extract the embedded catalog.
|
|
25
|
+
* Used by Player when integrating with the full item XML.
|
|
26
|
+
*/
|
|
27
|
+
export function extractCatalogFromItemXml(itemXml: string): CatalogIndex {
|
|
28
|
+
const doc = parseHtml(itemXml, { lowerCaseTagName: true });
|
|
29
|
+
const infoEl = doc.querySelector('qti-catalog-info');
|
|
30
|
+
if (!infoEl) return new Map();
|
|
31
|
+
return buildIndex(infoEl);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Merge two CatalogIndex maps. itemLevel entries win on collision (same identifier).
|
|
36
|
+
*/
|
|
37
|
+
export function mergeCatalogs(base: CatalogIndex, override: CatalogIndex): CatalogIndex {
|
|
38
|
+
const merged: CatalogIndex = new Map(base);
|
|
39
|
+
for (const [id, card] of override) {
|
|
40
|
+
merged.set(id, card);
|
|
41
|
+
}
|
|
42
|
+
return merged;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Internal
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
function buildIndex(infoEl: NhpElement): CatalogIndex {
|
|
50
|
+
const index: CatalogIndex = new Map();
|
|
51
|
+
|
|
52
|
+
for (const catalogEl of infoEl.querySelectorAll('qti-catalog')) {
|
|
53
|
+
const identifier = catalogEl.getAttribute('id') ?? catalogEl.getAttribute('identifier');
|
|
54
|
+
if (!identifier) continue;
|
|
55
|
+
|
|
56
|
+
const entries: CatalogEntry[] = [];
|
|
57
|
+
for (const cardEl of catalogEl.querySelectorAll('qti-card')) {
|
|
58
|
+
const cardUsage = cardEl.getAttribute('support') ?? cardEl.getAttribute('usage');
|
|
59
|
+
for (const entry of extractCardEntries(cardEl, cardUsage ?? undefined)) {
|
|
60
|
+
entries.push(entry);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (entries.length > 0) {
|
|
65
|
+
index.set(identifier, { entries });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const cardEl of infoEl.querySelectorAll('qti-card')) {
|
|
70
|
+
const identifier = cardEl.getAttribute('identifier');
|
|
71
|
+
if (!identifier) continue;
|
|
72
|
+
|
|
73
|
+
const entries = extractCardEntries(cardEl);
|
|
74
|
+
|
|
75
|
+
if (entries.length > 0) {
|
|
76
|
+
const existing = index.get(identifier);
|
|
77
|
+
if (existing) {
|
|
78
|
+
existing.entries.push(...entries);
|
|
79
|
+
} else {
|
|
80
|
+
index.set(identifier, { entries });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return index;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function extractCardEntries(cardEl: NhpElement, fallbackUsage?: string): CatalogEntry[] {
|
|
89
|
+
const explicitEntries = cardEl.querySelectorAll('qti-card-entry');
|
|
90
|
+
const entries: CatalogEntry[] = [];
|
|
91
|
+
|
|
92
|
+
if (explicitEntries.length > 0) {
|
|
93
|
+
for (const entryEl of explicitEntries) {
|
|
94
|
+
const usage =
|
|
95
|
+
entryEl.getAttribute('usage') ??
|
|
96
|
+
entryEl.getAttribute('data-reading-type') ??
|
|
97
|
+
fallbackUsage;
|
|
98
|
+
if (!usage) continue;
|
|
99
|
+
entries.push({
|
|
100
|
+
usage,
|
|
101
|
+
lang: getLang(entryEl),
|
|
102
|
+
html: extractHtmlContent(entryEl),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return entries;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (fallbackUsage) {
|
|
109
|
+
entries.push({
|
|
110
|
+
usage: fallbackUsage,
|
|
111
|
+
lang: getLang(cardEl),
|
|
112
|
+
html: extractHtmlContent(cardEl),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return entries;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getLang(el: NhpElement): string | undefined {
|
|
120
|
+
return el.getAttribute('xml:lang') ?? el.getAttribute('xmllang') ?? el.getAttribute('lang') ?? undefined;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function extractHtmlContent(el: NhpElement): string {
|
|
124
|
+
const htmlContent = el.querySelector('qti-html-content');
|
|
125
|
+
const fileHref = el.querySelector('qti-file-href');
|
|
126
|
+
|
|
127
|
+
if (htmlContent) return htmlContent.innerHTML ?? htmlContent.text ?? '';
|
|
128
|
+
if (fileHref) return fileHref.getAttribute('src') ?? fileHref.text?.trim() ?? '';
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CatalogIndex } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Look up a catalog entry by card identifier, usage type, and optional language.
|
|
5
|
+
*
|
|
6
|
+
* Language fallback order (mirrors APIP 1.0 / HTTP Accept-Language conventions):
|
|
7
|
+
* 1. Exact lang match (e.g. 'en-US')
|
|
8
|
+
* 2. Language-prefix match (e.g. 'en' matches entry with lang 'en-US')
|
|
9
|
+
* 3. Entry with no lang specified (universal fallback)
|
|
10
|
+
* 4. null — no match found
|
|
11
|
+
*
|
|
12
|
+
* @param index CatalogIndex built by extractCatalog / extractCatalogFromItemXml
|
|
13
|
+
* @param idref The data-catalog-idref value (maps to qti-card identifier)
|
|
14
|
+
* @param usage Catalog usage type (e.g. 'glossary-on-screen')
|
|
15
|
+
* @param lang Optional preferred language code (e.g. 'en-US', 'es')
|
|
16
|
+
* @returns The matched entry's html string, or null if nothing found
|
|
17
|
+
*/
|
|
18
|
+
export function getCatalogEntry(
|
|
19
|
+
index: CatalogIndex,
|
|
20
|
+
idref: string,
|
|
21
|
+
usage: string,
|
|
22
|
+
lang?: string
|
|
23
|
+
): string | null {
|
|
24
|
+
const card = index.get(idref);
|
|
25
|
+
if (!card) return null;
|
|
26
|
+
|
|
27
|
+
const candidates = card.entries.filter((e) => e.usage === usage);
|
|
28
|
+
if (candidates.length === 0) return null;
|
|
29
|
+
|
|
30
|
+
// 1. Exact language match
|
|
31
|
+
if (lang) {
|
|
32
|
+
const exact = candidates.find((e) => e.lang === lang);
|
|
33
|
+
if (exact) return exact.html;
|
|
34
|
+
|
|
35
|
+
// 2. Language-prefix match: requested lang prefix matches entry lang
|
|
36
|
+
// e.g. lang='en' matches entry.lang='en-US'
|
|
37
|
+
// e.g. lang='en-US' matches entry.lang='en' (broader fallback)
|
|
38
|
+
const prefix = lang.split('-')[0];
|
|
39
|
+
const prefixMatch = candidates.find(
|
|
40
|
+
(e) => e.lang && (e.lang === prefix || e.lang.startsWith(`${prefix}-`) || lang.startsWith(`${e.lang}-`))
|
|
41
|
+
);
|
|
42
|
+
if (prefixMatch) return prefixMatch.html;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 3. No-lang fallback (entry without a lang attribute)
|
|
46
|
+
const noLang = candidates.find((e) => !e.lang);
|
|
47
|
+
if (noLang) return noLang.html;
|
|
48
|
+
|
|
49
|
+
// 4. If we get here and there's only one candidate, return it regardless of lang
|
|
50
|
+
if (candidates.length === 1) return candidates[0].html;
|
|
51
|
+
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Player } from '../core/Player.js';
|
|
2
|
+
import { applyGlossaryTriggers } from './applyGlossaryTriggers.js';
|
|
3
|
+
|
|
4
|
+
export interface GlossaryActionParams {
|
|
5
|
+
player: Player;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Svelte action that reactively applies glossary trigger buttons to
|
|
10
|
+
* [data-catalog-idref] elements in the rendered item body.
|
|
11
|
+
*
|
|
12
|
+
* Applied to the .qti-item-body container. When the player changes (new item
|
|
13
|
+
* loaded), Svelte calls update() after {@html} has replaced the DOM content,
|
|
14
|
+
* so the walk always runs on fresh markup.
|
|
15
|
+
*/
|
|
16
|
+
export function glossaryAction(node: HTMLElement, params: GlossaryActionParams) {
|
|
17
|
+
applyGlossaryTriggers(node, params.player);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
update(newParams: GlossaryActionParams) {
|
|
21
|
+
// {@html} replacement already wiped any previously injected wrappers.
|
|
22
|
+
applyGlossaryTriggers(node, newParams.player);
|
|
23
|
+
},
|
|
24
|
+
destroy() {
|
|
25
|
+
// Node is being removed from DOM — no cleanup needed.
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI 3.0 §6.3 Catalog types.
|
|
3
|
+
* A CatalogIndex maps card identifiers to their CatalogCard.
|
|
4
|
+
* Cards hold multiple CatalogEntry records, one per usage/language combination.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type CatalogIndex = Map<string, CatalogCard>;
|
|
8
|
+
|
|
9
|
+
export interface CatalogCard {
|
|
10
|
+
entries: CatalogEntry[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CatalogEntry {
|
|
14
|
+
/**
|
|
15
|
+
* QTI 3.0 catalog usage type.
|
|
16
|
+
* The 8 standard types are listed below; additional string values are accepted
|
|
17
|
+
* for forward-compatibility and host-defined extensions.
|
|
18
|
+
*/
|
|
19
|
+
usage:
|
|
20
|
+
| 'glossary-on-screen'
|
|
21
|
+
| 'keyword-translation'
|
|
22
|
+
| 'illustrated-glossary'
|
|
23
|
+
| 'tts-pronunciation'
|
|
24
|
+
| 'signing-definition'
|
|
25
|
+
| 'braille-text'
|
|
26
|
+
| 'audio-description'
|
|
27
|
+
| 'extended-description'
|
|
28
|
+
| string;
|
|
29
|
+
/** xml:lang value (e.g. 'en-US', 'es'). Undefined when no language is specified. */
|
|
30
|
+
lang?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Inner HTML from <qti-html-content>, or the src URL from <qti-file-href>.
|
|
33
|
+
* For illustrated-glossary entries the player checks whether this looks like a URL
|
|
34
|
+
* and renders an <img> instead of innerHTML.
|
|
35
|
+
*/
|
|
36
|
+
html: string;
|
|
37
|
+
}
|