@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,70 @@
|
|
|
1
|
+
import type { AssessmentItemDocument } from '../document/AssessmentItemDocument.js';
|
|
2
|
+
import type { ExtractionRegistry } from './ExtractionRegistry.js';
|
|
3
|
+
import { createExtractionContext } from './createContext.js';
|
|
4
|
+
import { applyInteractionSecurity } from './interactionSecurity.js';
|
|
5
|
+
import type { VariableDeclaration as ExtractionVariableDeclaration } from './types.js';
|
|
6
|
+
import type { DeclarationMap } from '@pie-qti/qti-processing';
|
|
7
|
+
import type { PlayerConfig } from '../types/index.js';
|
|
8
|
+
import type { InteractionData } from '../types/interactions.js';
|
|
9
|
+
|
|
10
|
+
export interface InteractionExtractionPipelineInput {
|
|
11
|
+
document: AssessmentItemDocument;
|
|
12
|
+
extractionRegistry: ExtractionRegistry;
|
|
13
|
+
declarations: DeclarationMap;
|
|
14
|
+
config: PlayerConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function extractInteractionData({
|
|
18
|
+
document,
|
|
19
|
+
extractionRegistry,
|
|
20
|
+
declarations,
|
|
21
|
+
config,
|
|
22
|
+
}: InteractionExtractionPipelineInput): InteractionData[] {
|
|
23
|
+
const declMap = projectDeclarationsForExtraction(declarations);
|
|
24
|
+
const elements = document.findExtractionElements(getRegisteredElementTypes(extractionRegistry));
|
|
25
|
+
|
|
26
|
+
const interactions: InteractionData[] = [];
|
|
27
|
+
for (const discovered of elements) {
|
|
28
|
+
const context = createExtractionContext(
|
|
29
|
+
discovered.element,
|
|
30
|
+
discovered.responseIdentifier,
|
|
31
|
+
discovered.contextRoot,
|
|
32
|
+
declMap,
|
|
33
|
+
config
|
|
34
|
+
);
|
|
35
|
+
const result = extractionRegistry.extract<any>(discovered.element, context);
|
|
36
|
+
if (!result.success) continue;
|
|
37
|
+
|
|
38
|
+
interactions.push({
|
|
39
|
+
type: discovered.normalizedType as any,
|
|
40
|
+
responseId: discovered.responseIdentifier,
|
|
41
|
+
...result.data,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return applyInteractionSecurity(interactions, config.security);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getRegisteredElementTypes(extractionRegistry: ExtractionRegistry): string[] {
|
|
49
|
+
const elementTypes = new Set<string>();
|
|
50
|
+
for (const extractor of extractionRegistry.getExtractors()) {
|
|
51
|
+
for (const elementType of extractor.elementTypes) {
|
|
52
|
+
elementTypes.add(elementType);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return [...elementTypes];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function projectDeclarationsForExtraction(
|
|
59
|
+
declarations: DeclarationMap
|
|
60
|
+
): Map<string, ExtractionVariableDeclaration> {
|
|
61
|
+
const declMap = new Map<string, ExtractionVariableDeclaration>();
|
|
62
|
+
for (const declaration of Object.values(declarations)) {
|
|
63
|
+
declMap.set(declaration.identifier, {
|
|
64
|
+
identifier: declaration.identifier,
|
|
65
|
+
cardinality: declaration.cardinality as any,
|
|
66
|
+
baseType: declaration.baseType,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return declMap;
|
|
70
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { InteractionData } from '../types/interactions.js';
|
|
2
|
+
import type { PlayerSecurityConfig } from '../types/index.js';
|
|
3
|
+
import { toTrustedHtml } from '../core/trustedTypes.js';
|
|
4
|
+
import { sanitizeResourceUrl } from '../core/urlPolicy.js';
|
|
5
|
+
|
|
6
|
+
export function applyInteractionSecurity(
|
|
7
|
+
interactions: InteractionData[],
|
|
8
|
+
security?: PlayerSecurityConfig
|
|
9
|
+
): InteractionData[] {
|
|
10
|
+
const policy = security?.urlPolicy;
|
|
11
|
+
const allowObjectEmbeds = security?.allowObjectEmbeds === true;
|
|
12
|
+
const ttPolicyName = security?.trustedTypesPolicyName;
|
|
13
|
+
|
|
14
|
+
for (const interaction of interactions as any[]) {
|
|
15
|
+
// Wrap known HTML injection fields in TrustedHTML (when enabled).
|
|
16
|
+
// Important: do NOT wrap fields rendered as plain text (e.g. prompt).
|
|
17
|
+
if (interaction.type === 'choiceInteraction' && Array.isArray(interaction.choices)) {
|
|
18
|
+
for (const choice of interaction.choices) {
|
|
19
|
+
if (typeof choice?.text === 'string') {
|
|
20
|
+
choice.text = toTrustedHtml(choice.text, ttPolicyName);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Shared ImageData shape.
|
|
26
|
+
if (interaction.imageData?.src) {
|
|
27
|
+
interaction.imageData.src = sanitizeResourceUrl(interaction.imageData.src, policy, 'img') ?? '';
|
|
28
|
+
}
|
|
29
|
+
if (interaction.imageData?.content && typeof interaction.imageData.content === 'string') {
|
|
30
|
+
interaction.imageData.content = toTrustedHtml(interaction.imageData.content, ttPolicyName);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// positionObject stages.
|
|
34
|
+
if (Array.isArray(interaction.positionObjectStages)) {
|
|
35
|
+
for (const stage of interaction.positionObjectStages) {
|
|
36
|
+
if (stage?.objectData?.src) {
|
|
37
|
+
stage.objectData.src = sanitizeResourceUrl(stage.objectData.src, policy, 'img') ?? '';
|
|
38
|
+
}
|
|
39
|
+
if (stage?.objectData?.content && typeof stage.objectData.content === 'string') {
|
|
40
|
+
stage.objectData.content = toTrustedHtml(stage.objectData.content, ttPolicyName);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// mediaInteraction.
|
|
46
|
+
if (interaction.type === 'mediaInteraction' && interaction.mediaElement?.src) {
|
|
47
|
+
const kind = interaction.mediaElement.type === 'object' ? 'object' : 'media';
|
|
48
|
+
interaction.mediaElement.src =
|
|
49
|
+
sanitizeResourceUrl(interaction.mediaElement.src, policy, kind) ?? '';
|
|
50
|
+
interaction.allowObjectEmbeds = allowObjectEmbeds;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// hottextInteraction content is injected via {@html}.
|
|
54
|
+
if (interaction.type === 'hottextInteraction' && typeof interaction.contentHtml === 'string') {
|
|
55
|
+
interaction.contentHtml = toTrustedHtml(interaction.contentHtml, ttPolicyName);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return interactions;
|
|
60
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @pie-qti/item-player
|
|
3
|
-
* Modern QTI 2.2
|
|
3
|
+
* Modern QTI player (2.2/3.0) - Framework-agnostic with web components
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -15,13 +15,8 @@ export * from './core/constants.js';
|
|
|
15
15
|
export * from './core/declarations.js';
|
|
16
16
|
// Export drawing utilities
|
|
17
17
|
export * from './utils/drawingUtils.js';
|
|
18
|
-
// Export ItemRenderer for framework-agnostic rendering
|
|
19
|
-
export {
|
|
20
|
-
createItemRenderer,
|
|
21
|
-
ItemRenderer,
|
|
22
|
-
type ItemRendererConfig,
|
|
23
|
-
} from './core/ItemRenderer.js';
|
|
24
18
|
export { Player } from './core/Player.js';
|
|
19
|
+
export { getRoleCapabilities, type RoleCapabilities } from './core/rolePolicy.js';
|
|
25
20
|
// Plugin system (new extraction-based plugins)
|
|
26
21
|
export {
|
|
27
22
|
type PluginContext,
|
|
@@ -31,6 +26,7 @@ export {
|
|
|
31
26
|
} from './core/Plugin.js';
|
|
32
27
|
export { PluginManager } from './core/PluginManager.js';
|
|
33
28
|
// Export extraction system (PUBLIC API)
|
|
29
|
+
export * from './interactions/index.js';
|
|
34
30
|
export type {
|
|
35
31
|
ElementExtractor,
|
|
36
32
|
ExtractionContext,
|
|
@@ -49,7 +45,7 @@ export {
|
|
|
49
45
|
isSuccessResult,
|
|
50
46
|
} from './extraction/index.js';
|
|
51
47
|
// NOTE:
|
|
52
|
-
// The player’s primary rendering contract is via web components
|
|
48
|
+
// The player’s primary rendering contract is via web components and the Svelte component entrypoint.
|
|
53
49
|
// If you need non-web-component rendering, build it externally against the public extraction APIs.
|
|
54
50
|
// Export all types including adaptive item types
|
|
55
51
|
export * from './types/index.js';
|
|
@@ -64,6 +60,21 @@ export {
|
|
|
64
60
|
|
|
65
61
|
export { isResponseEmpty } from './utils/responseUtils.js';
|
|
66
62
|
|
|
63
|
+
// PNP profile (QTI 3.0 §6.2)
|
|
64
|
+
export type { PnpProfile } from './pnp/types.js';
|
|
65
|
+
export { applyPnpToRoot } from './pnp/applyPnp.js';
|
|
66
|
+
export { parsePnpXml } from './pnp/parsePnpXml.js';
|
|
67
|
+
|
|
68
|
+
// Catalog (QTI 3.0 §6.3)
|
|
69
|
+
export type { CatalogIndex, CatalogCard, CatalogEntry } from './catalog/types.js';
|
|
70
|
+
export { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from './catalog/catalogExtractor.js';
|
|
71
|
+
export { getCatalogEntry } from './catalog/catalogLookup.js';
|
|
72
|
+
|
|
73
|
+
// PCI — Portable Custom Interaction (QTI 3.0 §6.1)
|
|
74
|
+
export type { PciModule, PciBoundTo, ExtractedPci } from './pci/types.js';
|
|
75
|
+
export { PciLoadError } from './pci/types.js';
|
|
76
|
+
export { PciHost } from './pci/PciHost.js';
|
|
77
|
+
|
|
67
78
|
// Re-export QTI heuristics from @pie-qti/ims-cp-core for convenience
|
|
68
79
|
// (heuristics are now in the shared ingestion layer)
|
|
69
80
|
export {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard QTI associateInteraction extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts data from associateInteraction elements (associating items)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ElementExtractor } from '../../extraction/types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Associate data extracted from associateInteraction elements
|
|
11
|
+
*/
|
|
12
|
+
export interface AssociateData {
|
|
13
|
+
choices: Array<{
|
|
14
|
+
identifier: string;
|
|
15
|
+
text: string;
|
|
16
|
+
matchMax: number;
|
|
17
|
+
matchMin?: number;
|
|
18
|
+
matchGroup?: string[];
|
|
19
|
+
classes?: string[];
|
|
20
|
+
}>;
|
|
21
|
+
shuffle: boolean;
|
|
22
|
+
maxAssociations: number;
|
|
23
|
+
minAssociations?: number;
|
|
24
|
+
prompt: string | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Standard QTI associate interaction extractor
|
|
29
|
+
* Handles associateInteraction elements (creating associations between items)
|
|
30
|
+
*/
|
|
31
|
+
export const standardAssociateExtractor: ElementExtractor<AssociateData> = {
|
|
32
|
+
id: 'qti:associate-interaction',
|
|
33
|
+
name: 'QTI Standard Associate Interaction',
|
|
34
|
+
priority: 10,
|
|
35
|
+
elementTypes: ['associateInteraction'],
|
|
36
|
+
description: 'Extracts standard QTI associateInteraction (associating items)',
|
|
37
|
+
|
|
38
|
+
canHandle(element, context) {
|
|
39
|
+
// All associateInteraction elements with simpleAssociableChoice are standard
|
|
40
|
+
return (
|
|
41
|
+
element.rawTagName === 'associateInteraction' &&
|
|
42
|
+
context.utils.hasChildWithTag(element, 'simpleAssociableChoice')
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
extract(element, context) {
|
|
47
|
+
const { utils } = context;
|
|
48
|
+
|
|
49
|
+
// Extract simpleAssociableChoice children
|
|
50
|
+
const choiceElements = utils.getChildrenByTag(element, 'simpleAssociableChoice');
|
|
51
|
+
const choices = choiceElements.map((choice) => {
|
|
52
|
+
const classes = utils.getClasses(choice);
|
|
53
|
+
const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
|
|
54
|
+
const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
|
|
55
|
+
const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
|
|
56
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
60
|
+
text: utils.getHtmlContent(choice),
|
|
61
|
+
matchMax,
|
|
62
|
+
...(matchMin > 0 ? { matchMin } : {}),
|
|
63
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
64
|
+
...(classes.length > 0 ? { classes } : {}),
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Extract attributes with proper defaults
|
|
69
|
+
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
70
|
+
const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 0);
|
|
71
|
+
const minAssociations = utils.getNumberAttribute(element, 'minAssociations', 0);
|
|
72
|
+
|
|
73
|
+
// Extract prompt (optional)
|
|
74
|
+
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
75
|
+
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
choices,
|
|
79
|
+
shuffle,
|
|
80
|
+
maxAssociations,
|
|
81
|
+
...(minAssociations > 0 ? { minAssociations } : {}),
|
|
82
|
+
prompt,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
validate(data) {
|
|
87
|
+
const errors: string[] = [];
|
|
88
|
+
|
|
89
|
+
// Validate choices exist
|
|
90
|
+
if (!data.choices || data.choices.length < 2) {
|
|
91
|
+
errors.push('associateInteraction must have at least 2 choices');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Validate choice identifiers
|
|
95
|
+
if (data.choices) {
|
|
96
|
+
const identifiers = new Set<string>();
|
|
97
|
+
for (const choice of data.choices) {
|
|
98
|
+
if (!choice.identifier) {
|
|
99
|
+
errors.push('All choices must have an identifier');
|
|
100
|
+
} else if (identifiers.has(choice.identifier)) {
|
|
101
|
+
errors.push(`Duplicate choice identifier: ${choice.identifier}`);
|
|
102
|
+
} else {
|
|
103
|
+
identifiers.add(choice.identifier);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Validate matchMax
|
|
107
|
+
if (choice.matchMax < 0) {
|
|
108
|
+
errors.push(`matchMax must be non-negative for choice ${choice.identifier}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Validate matchMin
|
|
112
|
+
if (choice.matchMin !== undefined && choice.matchMin < 0) {
|
|
113
|
+
errors.push(`matchMin must be non-negative for choice ${choice.identifier}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Validate maxAssociations
|
|
119
|
+
if (data.maxAssociations < 0) {
|
|
120
|
+
errors.push('maxAssociations must be non-negative');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Validate minAssociations
|
|
124
|
+
if (data.minAssociations !== undefined && data.minAssociations < 0) {
|
|
125
|
+
errors.push('minAssociations must be non-negative');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
valid: errors.length === 0,
|
|
130
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { AssociateInteractionData, AssociableChoice } from '../shared/types.js';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard QTI choiceInteraction extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts data from choiceInteraction elements with simpleChoice children
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ChoiceInteractionData } from '../shared/types.js';
|
|
8
|
+
import type { ElementExtractor, ExtractionContext } from '../../extraction/types.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Choice data extracted from simpleChoice elements
|
|
12
|
+
*/
|
|
13
|
+
export interface ChoiceData {
|
|
14
|
+
choices: Array<{ identifier: string; text: string; fixed?: boolean; classes?: string[] }>;
|
|
15
|
+
shuffle: boolean;
|
|
16
|
+
maxChoices: number;
|
|
17
|
+
minChoices: number;
|
|
18
|
+
prompt: string | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Standard QTI choice interaction extractor
|
|
23
|
+
* Handles choiceInteraction elements with simpleChoice children
|
|
24
|
+
*/
|
|
25
|
+
export const standardChoiceExtractor: ElementExtractor<ChoiceData> = {
|
|
26
|
+
id: 'qti:choice-interaction',
|
|
27
|
+
name: 'QTI Standard Choice Interaction',
|
|
28
|
+
priority: 10,
|
|
29
|
+
elementTypes: ['choiceInteraction'],
|
|
30
|
+
description: 'Extracts standard QTI choiceInteraction with simpleChoice elements',
|
|
31
|
+
|
|
32
|
+
canHandle(element, context) {
|
|
33
|
+
// Standard QTI choice interactions have simpleChoice children
|
|
34
|
+
return context.utils.hasChildWithTag(element, 'simpleChoice');
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
extract(element, context) {
|
|
38
|
+
const { utils } = context;
|
|
39
|
+
|
|
40
|
+
// Extract choices
|
|
41
|
+
const simpleChoices = utils.getChildrenByTag(element, 'simpleChoice');
|
|
42
|
+
const choices = simpleChoices.map((choice) => {
|
|
43
|
+
const classes = utils.getClasses(choice);
|
|
44
|
+
const fixed = utils.getBooleanAttribute(choice, 'fixed');
|
|
45
|
+
return {
|
|
46
|
+
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
47
|
+
text: utils.getHtmlContent(choice),
|
|
48
|
+
...(fixed ? { fixed } : {}),
|
|
49
|
+
...(classes.length > 0 ? { classes } : {}),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Extract prompt
|
|
54
|
+
const promptElement = utils.querySelector(element, 'prompt');
|
|
55
|
+
const prompt = promptElement ? utils.getHtmlContent(promptElement) : null;
|
|
56
|
+
|
|
57
|
+
// Extract attributes
|
|
58
|
+
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
59
|
+
const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);
|
|
60
|
+
const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
|
|
61
|
+
const interactionClasses = utils.getClasses(element);
|
|
62
|
+
const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
|
|
63
|
+
const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
choices,
|
|
67
|
+
shuffle,
|
|
68
|
+
maxChoices,
|
|
69
|
+
minChoices,
|
|
70
|
+
prompt,
|
|
71
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
72
|
+
...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
|
|
73
|
+
...(minSelectionsMessage ? { minSelectionsMessage } : {}),
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
validate(data) {
|
|
78
|
+
const errors: string[] = [];
|
|
79
|
+
const warnings: string[] = [];
|
|
80
|
+
|
|
81
|
+
// Validate choices exist
|
|
82
|
+
if (!data.choices || data.choices.length === 0) {
|
|
83
|
+
errors.push('choiceInteraction must have at least one choice');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Validate choice identifiers
|
|
87
|
+
if (data.choices) {
|
|
88
|
+
const identifiers = new Set<string>();
|
|
89
|
+
for (const choice of data.choices) {
|
|
90
|
+
if (!choice.identifier) {
|
|
91
|
+
errors.push('All choices must have an identifier');
|
|
92
|
+
} else if (identifiers.has(choice.identifier)) {
|
|
93
|
+
errors.push(`Duplicate choice identifier: ${choice.identifier}`);
|
|
94
|
+
} else {
|
|
95
|
+
identifiers.add(choice.identifier);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Validate maxChoices
|
|
101
|
+
if (data.maxChoices < 0) {
|
|
102
|
+
errors.push('maxChoices must be non-negative');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (data.maxChoices === 0) {
|
|
106
|
+
warnings.push('maxChoices=0 means unlimited selections');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (data.maxChoices > data.choices.length) {
|
|
110
|
+
warnings.push(
|
|
111
|
+
`maxChoices (${data.maxChoices}) is greater than the number of choices (${data.choices.length})`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
valid: errors.length === 0,
|
|
117
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
118
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ChoiceInteractionData } from '../shared/types.js';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard QTI customInteraction extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts data from customInteraction elements (custom/portable interactions)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ElementExtractor } from '../../extraction/types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Custom interaction data extracted from customInteraction elements
|
|
11
|
+
*/
|
|
12
|
+
export interface CustomData {
|
|
13
|
+
xml: string;
|
|
14
|
+
rawAttributes: Record<string, string>;
|
|
15
|
+
prompt: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Standard QTI custom interaction extractor
|
|
20
|
+
* Handles customInteraction elements (vendor-specific or portable custom interactions)
|
|
21
|
+
*/
|
|
22
|
+
export const standardCustomExtractor: ElementExtractor<CustomData> = {
|
|
23
|
+
id: 'qti:custom-interaction',
|
|
24
|
+
name: 'QTI Standard Custom Interaction',
|
|
25
|
+
priority: 10,
|
|
26
|
+
elementTypes: ['customInteraction'],
|
|
27
|
+
description: 'Extracts standard QTI customInteraction (custom/portable interactions)',
|
|
28
|
+
|
|
29
|
+
canHandle(element, _context) {
|
|
30
|
+
// All customInteraction elements are handled by this extractor
|
|
31
|
+
return element.rawTagName === 'customInteraction';
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
extract(element, context) {
|
|
35
|
+
const { utils } = context;
|
|
36
|
+
|
|
37
|
+
// Capture the raw XML for the custom interaction
|
|
38
|
+
const xml = element.outerHTML || element.toString();
|
|
39
|
+
|
|
40
|
+
// Extract all attributes
|
|
41
|
+
const rawAttributes: Record<string, string> = {};
|
|
42
|
+
if (element.attributes) {
|
|
43
|
+
for (const [key, value] of Object.entries(element.attributes)) {
|
|
44
|
+
rawAttributes[key] = String(value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Extract prompt (optional)
|
|
49
|
+
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
50
|
+
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
xml,
|
|
54
|
+
rawAttributes,
|
|
55
|
+
prompt,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
validate(_data) {
|
|
60
|
+
const warnings: string[] = [];
|
|
61
|
+
|
|
62
|
+
// Warn if no XML content
|
|
63
|
+
if (!_data.xml || _data.xml.trim() === '') {
|
|
64
|
+
warnings.push('customInteraction has no XML content');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
valid: true,
|
|
69
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { CustomInteractionData } from '../shared/types.js';
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard QTI drawingInteraction extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts data from drawingInteraction elements (drawing on canvas)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ElementExtractor } from '../../extraction/types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Image data for drawing interaction
|
|
11
|
+
*/
|
|
12
|
+
export interface ImageData {
|
|
13
|
+
type: 'image' | 'svg';
|
|
14
|
+
src?: string;
|
|
15
|
+
content?: string;
|
|
16
|
+
width?: string;
|
|
17
|
+
height?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Drawing data extracted from drawingInteraction elements
|
|
22
|
+
*/
|
|
23
|
+
export interface DrawingData {
|
|
24
|
+
imageData: ImageData | null;
|
|
25
|
+
rawAttributes: Record<string, string>;
|
|
26
|
+
prompt: string | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Standard QTI drawing interaction extractor
|
|
31
|
+
* Handles drawingInteraction elements (drawing on a canvas)
|
|
32
|
+
*/
|
|
33
|
+
export const standardDrawingExtractor: ElementExtractor<DrawingData> = {
|
|
34
|
+
id: 'qti:drawing-interaction',
|
|
35
|
+
name: 'QTI Standard Drawing Interaction',
|
|
36
|
+
priority: 10,
|
|
37
|
+
elementTypes: ['drawingInteraction'],
|
|
38
|
+
description: 'Extracts standard QTI drawingInteraction (drawing on canvas)',
|
|
39
|
+
|
|
40
|
+
canHandle(element, _context) {
|
|
41
|
+
// All drawingInteraction elements are standard
|
|
42
|
+
return element.rawTagName === 'drawingInteraction';
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
extract(element, context) {
|
|
46
|
+
const { utils } = context;
|
|
47
|
+
|
|
48
|
+
// Extract background image data from object element (optional)
|
|
49
|
+
const objectElements = utils.getChildrenByTag(element, 'object');
|
|
50
|
+
let imageData: ImageData | null = null;
|
|
51
|
+
|
|
52
|
+
if (objectElements.length > 0) {
|
|
53
|
+
const objectElement = objectElements[0];
|
|
54
|
+
const type = utils.getAttribute(objectElement, 'type', '');
|
|
55
|
+
const data = utils.getAttribute(objectElement, 'data', '');
|
|
56
|
+
const width = utils.getAttribute(objectElement, 'width', '');
|
|
57
|
+
const height = utils.getAttribute(objectElement, 'height', '');
|
|
58
|
+
|
|
59
|
+
if (type.startsWith('image/svg')) {
|
|
60
|
+
// Extract inline SVG content
|
|
61
|
+
const content = utils.getHtmlContent(objectElement);
|
|
62
|
+
imageData = {
|
|
63
|
+
type: 'svg',
|
|
64
|
+
content,
|
|
65
|
+
...(width ? { width } : {}),
|
|
66
|
+
...(height ? { height } : {}),
|
|
67
|
+
};
|
|
68
|
+
} else if (data) {
|
|
69
|
+
// External image reference
|
|
70
|
+
imageData = {
|
|
71
|
+
type: 'image',
|
|
72
|
+
src: data,
|
|
73
|
+
...(width ? { width } : {}),
|
|
74
|
+
...(height ? { height } : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Extract all attributes
|
|
80
|
+
const rawAttributes: Record<string, string> = {};
|
|
81
|
+
if (element.attributes) {
|
|
82
|
+
for (const [key, value] of Object.entries(element.attributes)) {
|
|
83
|
+
rawAttributes[key] = String(value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Extract prompt (optional)
|
|
88
|
+
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
89
|
+
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
imageData,
|
|
93
|
+
rawAttributes,
|
|
94
|
+
prompt,
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
validate(data) {
|
|
99
|
+
const warnings: string[] = [];
|
|
100
|
+
|
|
101
|
+
// Warn if no background image
|
|
102
|
+
if (!data.imageData) {
|
|
103
|
+
warnings.push(
|
|
104
|
+
'drawingInteraction has no background image - students will draw on a blank canvas'
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
valid: true,
|
|
110
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { DrawingInteractionData } from '../shared/types.js';
|