@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
package/src/core/Player.ts
CHANGED
|
@@ -12,17 +12,14 @@ import {
|
|
|
12
12
|
type DeclarationMap,
|
|
13
13
|
evalExpr,
|
|
14
14
|
execProgram,
|
|
15
|
-
findAssessmentItem,
|
|
16
15
|
findDescendants,
|
|
17
16
|
findFirstDescendant,
|
|
18
17
|
getAttr,
|
|
19
18
|
OperatorRegistry,
|
|
20
19
|
type ProcessingProgram,
|
|
21
|
-
parseXml,
|
|
22
20
|
type QtiValue,
|
|
23
21
|
qtiNull,
|
|
24
22
|
qtiValue,
|
|
25
|
-
serializeXml,
|
|
26
23
|
toBoolean,
|
|
27
24
|
toNumber,
|
|
28
25
|
toStringValue,
|
|
@@ -35,11 +32,12 @@ import {
|
|
|
35
32
|
Qti3AttributeNameMapper,
|
|
36
33
|
detectQtiVersion,
|
|
37
34
|
} from '@pie-qti/qti-common';
|
|
38
|
-
import {
|
|
35
|
+
import type { AssessmentItemDocument } from '../document/AssessmentItemDocument.js';
|
|
36
|
+
import { parseAssessmentItemDocument } from '../document/AssessmentItemDocument.js';
|
|
39
37
|
import type { ExtractionRegistry } from '../extraction/ExtractionRegistry.js';
|
|
40
38
|
import { createExtractionRegistry } from '../extraction/ExtractionRegistry.js';
|
|
41
|
-
import {
|
|
42
|
-
import
|
|
39
|
+
import { extractInteractionData } from '../extraction/interactionExtractionPipeline.js';
|
|
40
|
+
import { getStandardInteractionExtractors } from '../interactions/modules.js';
|
|
43
41
|
import type {
|
|
44
42
|
AdaptiveAttemptResult,
|
|
45
43
|
CompletionStatus,
|
|
@@ -52,15 +50,20 @@ import type {
|
|
|
52
50
|
RubricBlock,
|
|
53
51
|
ScoringResult,
|
|
54
52
|
} from '../types/index.js';
|
|
55
|
-
import type { InteractionData
|
|
53
|
+
import type { InteractionData } from '../types/interactions.js';
|
|
56
54
|
import type { ResponseValidationResult } from '../types/responseValidation.js';
|
|
57
55
|
import type { ComponentRegistry } from './ComponentRegistry.js';
|
|
58
56
|
import { createComponentRegistry } from './ComponentRegistry.js';
|
|
59
|
-
import { enforceItemXmlLimits } from './parsingLimits.js';
|
|
60
57
|
import { createSeededRng } from './random.js';
|
|
61
58
|
import { sanitizeHtml } from './sanitizer.js';
|
|
62
59
|
import { toTrustedHtml } from './trustedTypes.js';
|
|
63
|
-
import {
|
|
60
|
+
import type { PnpProfile } from '../pnp/types.js';
|
|
61
|
+
import { applyPnpToRoot } from '../pnp/applyPnp.js';
|
|
62
|
+
import type { CatalogIndex } from '../catalog/types.js';
|
|
63
|
+
import { extractCatalogFromItemXml, mergeCatalogs } from '../catalog/catalogExtractor.js';
|
|
64
|
+
import { getCatalogEntry } from '../catalog/catalogLookup.js';
|
|
65
|
+
import { PciHost } from '../pci/PciHost.js';
|
|
66
|
+
import type { ExtractedPci } from '../pci/types.js';
|
|
64
67
|
|
|
65
68
|
type DeclKind = 'response' | 'outcome' | 'template';
|
|
66
69
|
|
|
@@ -68,7 +71,7 @@ export class Player {
|
|
|
68
71
|
private role: QTIRole;
|
|
69
72
|
private config: PlayerConfig;
|
|
70
73
|
private itemXml: string;
|
|
71
|
-
private
|
|
74
|
+
private itemDocument: AssessmentItemDocument;
|
|
72
75
|
private assessmentItem: Element;
|
|
73
76
|
private decls: DeclarationMap;
|
|
74
77
|
private ctx: DeclarationContext;
|
|
@@ -82,6 +85,10 @@ export class Player {
|
|
|
82
85
|
private responseProcessingProgram: ProcessingProgram | null = null;
|
|
83
86
|
private templateProcessingProgram: ProcessingProgram | null = null;
|
|
84
87
|
private outcomeProcessingProgram: ProcessingProgram | null = null;
|
|
88
|
+
private _pnp: PnpProfile | undefined;
|
|
89
|
+
private _rootEl: HTMLElement | undefined;
|
|
90
|
+
private _catalogIndex: CatalogIndex = new Map();
|
|
91
|
+
private _pciHosts: Map<string, PciHost> = new Map();
|
|
85
92
|
|
|
86
93
|
constructor(config: PlayerConfig) {
|
|
87
94
|
this.config = config;
|
|
@@ -109,15 +116,23 @@ export class Player {
|
|
|
109
116
|
}
|
|
110
117
|
} else {
|
|
111
118
|
this.mapper = config.elementNameMapper as ElementNameMapper;
|
|
119
|
+
if (!config.attributeNameMapper) {
|
|
120
|
+
(config as any).attributeNameMapper =
|
|
121
|
+
this.mapper.version === '3.0'
|
|
122
|
+
? new Qti3AttributeNameMapper()
|
|
123
|
+
: new Qti2xAttributeNameMapper();
|
|
124
|
+
}
|
|
112
125
|
}
|
|
113
126
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
this.itemDocument = parseAssessmentItemDocument({
|
|
128
|
+
itemXml: this.itemXml,
|
|
129
|
+
elementNameMapper: this.mapper,
|
|
130
|
+
attributeNameMapper: config.attributeNameMapper as AttributeNameMapper,
|
|
131
|
+
security: this.config.security,
|
|
132
|
+
});
|
|
133
|
+
this.assessmentItem = this.itemDocument.getAssessmentItem();
|
|
119
134
|
|
|
120
|
-
this.decls = this.buildDeclarations(
|
|
135
|
+
this.decls = this.buildDeclarations();
|
|
121
136
|
this.ensureBuiltinDeclarations(this.decls);
|
|
122
137
|
this.ctx = new DeclarationContext(this.decls);
|
|
123
138
|
this.ops = new OperatorRegistry();
|
|
@@ -135,8 +150,8 @@ export class Player {
|
|
|
135
150
|
// I18n provider (defaults to a simple fallback if not provided)
|
|
136
151
|
this.i18nProvider = config.i18nProvider ?? this.createDefaultI18nProvider();
|
|
137
152
|
|
|
138
|
-
// Register standard extractors (idempotent per-registry instance)
|
|
139
|
-
for (const ex of
|
|
153
|
+
// Register standard interaction extractors (idempotent per-registry instance)
|
|
154
|
+
for (const ex of getStandardInteractionExtractors()) {
|
|
140
155
|
try {
|
|
141
156
|
this.extractionRegistry.register(ex as any);
|
|
142
157
|
} catch {
|
|
@@ -155,7 +170,7 @@ export class Player {
|
|
|
155
170
|
}
|
|
156
171
|
|
|
157
172
|
// Build ASTs once.
|
|
158
|
-
const templateProcessing =
|
|
173
|
+
const templateProcessing = this.itemDocument.getProcessingElement('template');
|
|
159
174
|
if (templateProcessing) {
|
|
160
175
|
this.templateProcessingProgram = buildTemplateProcessingAst(templateProcessing, {
|
|
161
176
|
elementNameMapper: this.mapper,
|
|
@@ -163,14 +178,14 @@ export class Player {
|
|
|
163
178
|
this.execTemplateProcessing();
|
|
164
179
|
}
|
|
165
180
|
|
|
166
|
-
const responseProcessing =
|
|
181
|
+
const responseProcessing = this.itemDocument.getProcessingElement('response');
|
|
167
182
|
if (responseProcessing) {
|
|
168
183
|
this.responseProcessingProgram = buildResponseProcessingAst(responseProcessing, {
|
|
169
184
|
elementNameMapper: this.mapper,
|
|
170
185
|
});
|
|
171
186
|
}
|
|
172
187
|
|
|
173
|
-
const outcomeProcessing =
|
|
188
|
+
const outcomeProcessing = this.itemDocument.getProcessingElement('outcome');
|
|
174
189
|
if (outcomeProcessing) {
|
|
175
190
|
this.outcomeProcessingProgram = buildOutcomeProcessingAst(outcomeProcessing, {
|
|
176
191
|
elementNameMapper: this.mapper,
|
|
@@ -196,12 +211,111 @@ export class Player {
|
|
|
196
211
|
);
|
|
197
212
|
}
|
|
198
213
|
|
|
214
|
+
// Store PNP profile for later use (applyPnpToRoot is called once a root element is available).
|
|
215
|
+
this._pnp = config.pnp;
|
|
216
|
+
|
|
217
|
+
// Build catalog index from item XML and optional shared catalog.
|
|
218
|
+
const itemCatalog = extractCatalogFromItemXml(this.itemXml);
|
|
219
|
+
if (config.catalogXml) {
|
|
220
|
+
const sharedCatalog = extractCatalogFromItemXml(config.catalogXml);
|
|
221
|
+
// Item-level wins on collision: merge shared first, then override with item entries.
|
|
222
|
+
this._catalogIndex = mergeCatalogs(sharedCatalog, itemCatalog);
|
|
223
|
+
} else {
|
|
224
|
+
this._catalogIndex = itemCatalog;
|
|
225
|
+
}
|
|
226
|
+
|
|
199
227
|
// Check strict compliance if enabled
|
|
200
228
|
if (this.config.strictQtiCompliance?.enabled) {
|
|
201
229
|
this.validateStrictCompliance();
|
|
202
230
|
}
|
|
203
231
|
}
|
|
204
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Apply the PNP profile to a player root element.
|
|
235
|
+
* Call this once the root DOM element is available (e.g. after mounting).
|
|
236
|
+
* The player stores the element reference so updatePnp() can re-apply without re-parsing the item.
|
|
237
|
+
*/
|
|
238
|
+
public applyPnp(rootEl: HTMLElement): void {
|
|
239
|
+
this._rootEl = rootEl;
|
|
240
|
+
applyPnpToRoot(rootEl, this._pnp);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Update the PNP profile mid-session without re-parsing the item XML.
|
|
245
|
+
* Deep-merges the partial profile into the current profile and re-applies.
|
|
246
|
+
*/
|
|
247
|
+
public updatePnp(partial: Partial<PnpProfile>): void {
|
|
248
|
+
this._pnp = mergePnp(this._pnp, partial);
|
|
249
|
+
if (this._rootEl) {
|
|
250
|
+
applyPnpToRoot(this._rootEl, this._pnp);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Return the current resolved PNP profile. */
|
|
255
|
+
public getPnp(): PnpProfile | undefined {
|
|
256
|
+
return this._pnp;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Look up a catalog entry by card identifier, usage type, and optional language.
|
|
261
|
+
* Returns the HTML string for the matched entry, or null if not found.
|
|
262
|
+
*
|
|
263
|
+
* Language fallback: exact match → prefix match → no-lang entry → null.
|
|
264
|
+
*/
|
|
265
|
+
public getCatalogEntry(idref: string, usage: string, lang?: string): string | null {
|
|
266
|
+
return getCatalogEntry(this._catalogIndex, idref, usage, lang);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Create a PciHost for an extracted PCI and register it for response tracking.
|
|
271
|
+
* The caller is responsible for calling host.load() and
|
|
272
|
+
* host.initialize(domNode) once the DOM element is available.
|
|
273
|
+
*/
|
|
274
|
+
public createPciHost(data: ExtractedPci): PciHost {
|
|
275
|
+
const baseUrl = this.config.pciBaseUrl ?? (typeof document !== 'undefined' ? document.baseURI : '');
|
|
276
|
+
const host = new PciHost(data, baseUrl);
|
|
277
|
+
|
|
278
|
+
// Wire response changes back into the player's declaration context
|
|
279
|
+
host.onResponseChange((responseId: string, value: unknown) => {
|
|
280
|
+
const d = this.decls[responseId];
|
|
281
|
+
if (d) {
|
|
282
|
+
d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, value);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
this._pciHosts.set(data.responseIdentifier, host);
|
|
287
|
+
return host;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Push a response value into the PCI identified by responseIdentifier.
|
|
292
|
+
* Called from setResponses() so session restore reaches PCI modules.
|
|
293
|
+
*/
|
|
294
|
+
public setPciResponse(responseIdentifier: string, value: unknown): void {
|
|
295
|
+
this._pciHosts.get(responseIdentifier)?.setResponse(value);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Disable/enable all PCI hosts based on role.
|
|
300
|
+
* 'candidate' = enabled; any other role = disabled.
|
|
301
|
+
*/
|
|
302
|
+
public syncPciDisabledState(): void {
|
|
303
|
+
const disabled = this.role !== 'candidate';
|
|
304
|
+
for (const host of this._pciHosts.values()) {
|
|
305
|
+
if (disabled) host.disable(); else host.enable();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Destroy all PCI hosts. Call on player teardown.
|
|
311
|
+
*/
|
|
312
|
+
public destroyPciHosts(): void {
|
|
313
|
+
for (const host of this._pciHosts.values()) {
|
|
314
|
+
host.destroy();
|
|
315
|
+
}
|
|
316
|
+
this._pciHosts.clear();
|
|
317
|
+
}
|
|
318
|
+
|
|
205
319
|
/** Breaking-change API: returns the typed declaration map */
|
|
206
320
|
public getDeclarations(): DeclarationMap {
|
|
207
321
|
return this.decls;
|
|
@@ -212,16 +326,26 @@ export class Player {
|
|
|
212
326
|
const d = this.decls[id];
|
|
213
327
|
if (!d) continue;
|
|
214
328
|
d.value = this.coerceToDeclarationValue(d.baseType, d.cardinality, raw);
|
|
329
|
+
// Push restored responses into any mounted PCI modules
|
|
330
|
+
this.setPciResponse(id, raw);
|
|
215
331
|
}
|
|
216
332
|
}
|
|
217
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Destroy all resources owned by this player instance (PCI modules, etc.).
|
|
336
|
+
* Call when unmounting to prevent memory leaks.
|
|
337
|
+
*/
|
|
338
|
+
public destroy(): void {
|
|
339
|
+
this.destroyPciHosts();
|
|
340
|
+
}
|
|
341
|
+
|
|
218
342
|
public processResponses(): ScoringResult {
|
|
219
343
|
// Spec-aligned behavior: each processing run starts from outcome defaults.
|
|
220
344
|
// This prevents stale outcomes when response/outcome processing doesn't set every variable.
|
|
221
345
|
this.resetOutcomesToDefault();
|
|
222
346
|
|
|
223
347
|
// Execute response processing if present
|
|
224
|
-
const rpEl =
|
|
348
|
+
const rpEl = this.itemDocument.getProcessingElement('response');
|
|
225
349
|
if (rpEl) {
|
|
226
350
|
// If responseProcessing has explicit statements, run the compiled program.
|
|
227
351
|
// Otherwise, fall back to template-based processing (responseProcessing@template).
|
|
@@ -372,11 +496,9 @@ export class Player {
|
|
|
372
496
|
}
|
|
373
497
|
|
|
374
498
|
public getItemBodyHtml(): HtmlContent {
|
|
375
|
-
const
|
|
376
|
-
if (!
|
|
499
|
+
const inner = this.itemDocument.serializeItemBodyChildren();
|
|
500
|
+
if (!inner) return '';
|
|
377
501
|
|
|
378
|
-
// Serialize children rather than the container tag itself.
|
|
379
|
-
const inner = childElements(itemBody).map((c) => serializeXml(c)).join('');
|
|
380
502
|
const printed = this.renderPrintedVariables(inner);
|
|
381
503
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
382
504
|
return toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -390,7 +512,7 @@ export class Player {
|
|
|
390
512
|
*/
|
|
391
513
|
public getRubrics(): RubricBlock[] {
|
|
392
514
|
const role = this.role;
|
|
393
|
-
const rubricEls =
|
|
515
|
+
const rubricEls = this.itemDocument.findRubricElements();
|
|
394
516
|
if (rubricEls.length === 0) return [];
|
|
395
517
|
|
|
396
518
|
const blocks: RubricBlock[] = [];
|
|
@@ -401,8 +523,7 @@ export class Player {
|
|
|
401
523
|
// If view is specified, show only when it includes the current role.
|
|
402
524
|
if (view.length > 0 && role && !view.includes(role)) continue;
|
|
403
525
|
|
|
404
|
-
|
|
405
|
-
const contentRaw = childElements(el).map((c) => serializeXml(c)).join('') || (el.textContent || '');
|
|
526
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
406
527
|
const printed = this.renderPrintedVariables(contentRaw);
|
|
407
528
|
const sanitized = sanitizeHtml(printed, { security: this.config.security });
|
|
408
529
|
const html = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
@@ -425,120 +546,12 @@ export class Player {
|
|
|
425
546
|
* Canonical interaction API (new): extracted, typed interaction data.
|
|
426
547
|
*/
|
|
427
548
|
public getInteractionData(): InteractionData[] {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
const docRoot = parse(this.itemXml, { lowerCaseTagName: false, comment: false }) as any as QTIElement;
|
|
435
|
-
// node-html-parser's CSS selectors match lowercase tag names.
|
|
436
|
-
// Search for itemBody in the native form for this QTI version (itembody for 2.x, qti-item-body for 3.0)
|
|
437
|
-
const itemBodyTag = this.mapper.toNative('itembody').toLowerCase();
|
|
438
|
-
const parsedItemBody = (docRoot.querySelector?.(itemBodyTag) as any as QTIElement | null) ?? null;
|
|
439
|
-
const root = parsedItemBody ?? docRoot;
|
|
440
|
-
|
|
441
|
-
const declMap = new Map<string, ExtractionVariableDeclaration>();
|
|
442
|
-
for (const d of Object.values(this.decls)) {
|
|
443
|
-
declMap.set(d.identifier, {
|
|
444
|
-
identifier: d.identifier,
|
|
445
|
-
cardinality: d.cardinality as any,
|
|
446
|
-
baseType: d.baseType,
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// Discover all elements that match any standard extractor elementType.
|
|
451
|
-
// Extractors specify element types in QTI 2.x form (e.g., 'choiceInteraction').
|
|
452
|
-
// We use the mapper to convert to the appropriate form for this QTI version
|
|
453
|
-
// (e.g., 'choiceInteraction' for QTI 2.x, 'qti-choice-interaction' for QTI 3.0).
|
|
454
|
-
const tagSet = new Set<string>();
|
|
455
|
-
for (const ex of ALL_STANDARD_EXTRACTORS) {
|
|
456
|
-
for (const t of ex.elementTypes ?? []) {
|
|
457
|
-
// Convert to canonical form (lowercase), then to native form using mapper
|
|
458
|
-
const canonical = t.toLowerCase();
|
|
459
|
-
const native = this.mapper.toNative(canonical);
|
|
460
|
-
tagSet.add(native.toLowerCase());
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
const elements: QTIElement[] = [];
|
|
465
|
-
for (const tag of tagSet) {
|
|
466
|
-
try {
|
|
467
|
-
elements.push(...(root.querySelectorAll(tag) as any));
|
|
468
|
-
} catch {
|
|
469
|
-
// ignore selector errors
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const interactions: InteractionData[] = [];
|
|
474
|
-
for (const el of elements) {
|
|
475
|
-
// Try both QTI 2.x (responseIdentifier) and QTI 3.0 (response-identifier) attribute names
|
|
476
|
-
const responseId = el.getAttribute?.('responseIdentifier') ||
|
|
477
|
-
el.getAttribute?.('response-identifier') ||
|
|
478
|
-
el.getAttribute?.('responseidentifier') ||
|
|
479
|
-
'';
|
|
480
|
-
if (!responseId) continue;
|
|
481
|
-
|
|
482
|
-
const ctx = createExtractionContext(el, responseId, root, declMap, this.config);
|
|
483
|
-
const res = this.extractionRegistry.extract<any>(el, ctx);
|
|
484
|
-
if (!res.success) continue;
|
|
485
|
-
|
|
486
|
-
interactions.push({
|
|
487
|
-
type: el.rawTagName as any,
|
|
488
|
-
responseId,
|
|
489
|
-
...res.data,
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// Apply URL policy + embed allowances to standard extracted URL fields.
|
|
494
|
-
const policy = this.config.security?.urlPolicy;
|
|
495
|
-
const allowObjectEmbeds = this.config.security?.allowObjectEmbeds === true;
|
|
496
|
-
const ttPolicyName = this.config.security?.trustedTypesPolicyName;
|
|
497
|
-
|
|
498
|
-
for (const i of interactions as any[]) {
|
|
499
|
-
// Wrap known HTML injection fields in TrustedHTML (when enabled).
|
|
500
|
-
// Important: do NOT wrap fields that are rendered as plain text in our Svelte components
|
|
501
|
-
// (e.g. prompt) to avoid "[object Object]" rendering.
|
|
502
|
-
if (i.type === 'choiceInteraction' && Array.isArray(i.choices)) {
|
|
503
|
-
for (const c of i.choices) {
|
|
504
|
-
if (typeof c?.text === 'string') c.text = toTrustedHtml(c.text, ttPolicyName);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Shared ImageData shape
|
|
509
|
-
if (i.imageData?.src) {
|
|
510
|
-
i.imageData.src = sanitizeResourceUrl(i.imageData.src, policy, 'img') ?? '';
|
|
511
|
-
}
|
|
512
|
-
if (i.imageData?.content && typeof i.imageData.content === 'string') {
|
|
513
|
-
i.imageData.content = toTrustedHtml(i.imageData.content, ttPolicyName);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// positionObject stages
|
|
517
|
-
if (Array.isArray(i.positionObjectStages)) {
|
|
518
|
-
for (const st of i.positionObjectStages) {
|
|
519
|
-
if (st?.objectData?.src) {
|
|
520
|
-
st.objectData.src = sanitizeResourceUrl(st.objectData.src, policy, 'img') ?? '';
|
|
521
|
-
}
|
|
522
|
-
if (st?.objectData?.content && typeof st.objectData.content === 'string') {
|
|
523
|
-
st.objectData.content = toTrustedHtml(st.objectData.content, ttPolicyName);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// mediaInteraction
|
|
529
|
-
if (i.type === 'mediaInteraction' && i.mediaElement?.src) {
|
|
530
|
-
const kind = i.mediaElement.type === 'object' ? 'object' : 'media';
|
|
531
|
-
i.mediaElement.src = sanitizeResourceUrl(i.mediaElement.src, policy, kind) ?? '';
|
|
532
|
-
i.allowObjectEmbeds = allowObjectEmbeds;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// hottextInteraction content is injected via {@html}
|
|
536
|
-
if (i.type === 'hottextInteraction' && typeof i.contentHtml === 'string') {
|
|
537
|
-
i.contentHtml = toTrustedHtml(i.contentHtml, ttPolicyName);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
return interactions;
|
|
549
|
+
return extractInteractionData({
|
|
550
|
+
document: this.itemDocument,
|
|
551
|
+
extractionRegistry: this.extractionRegistry,
|
|
552
|
+
declarations: this.decls,
|
|
553
|
+
config: this.config,
|
|
554
|
+
});
|
|
542
555
|
}
|
|
543
556
|
|
|
544
557
|
/**
|
|
@@ -570,7 +583,7 @@ export class Player {
|
|
|
570
583
|
}
|
|
571
584
|
|
|
572
585
|
public isAdaptive(): boolean {
|
|
573
|
-
return (
|
|
586
|
+
return (this.itemDocument.getAssessmentItemAttribute('adaptive') || '').toLowerCase() === 'true';
|
|
574
587
|
}
|
|
575
588
|
|
|
576
589
|
public getNumAttempts(): number {
|
|
@@ -697,8 +710,40 @@ export class Player {
|
|
|
697
710
|
const minPlays = Number(i.minPlays || 0);
|
|
698
711
|
complete = Number(value || 0) >= minPlays;
|
|
699
712
|
} else if (required) {
|
|
700
|
-
if (Array.isArray(value))
|
|
701
|
-
|
|
713
|
+
if (Array.isArray(value)) {
|
|
714
|
+
complete = value.length > 0;
|
|
715
|
+
// Enforce minChoices / minAssociations where applicable
|
|
716
|
+
const minChoices = Number(i.minChoices || i.minAssociations || 0);
|
|
717
|
+
if (complete && minChoices > 0) {
|
|
718
|
+
complete = value.length >= minChoices;
|
|
719
|
+
}
|
|
720
|
+
// Enforce matchMin per-choice: each pairing entry "id1 id2" in value must
|
|
721
|
+
// appear at least matchMin times for the relevant choice.
|
|
722
|
+
// Collect all choice arrays that can carry matchMin across all pairing interaction types.
|
|
723
|
+
const choices: Array<{ identifier: string; matchMin?: number }> = [
|
|
724
|
+
...(i.choices ?? []),
|
|
725
|
+
...(i.gapTexts ?? []),
|
|
726
|
+
...(i.gapImages ?? []),
|
|
727
|
+
...(i.sourceSet ?? []),
|
|
728
|
+
...(i.targetSet ?? []),
|
|
729
|
+
...(i.associableHotspots ?? []),
|
|
730
|
+
];
|
|
731
|
+
for (const choice of choices) {
|
|
732
|
+
const min = Number(choice.matchMin || 0);
|
|
733
|
+
if (min > 0) {
|
|
734
|
+
const count = (value as string[]).filter((p) => {
|
|
735
|
+
const parts = p.split(' ');
|
|
736
|
+
return parts[0] === choice.identifier || parts[1] === choice.identifier;
|
|
737
|
+
}).length;
|
|
738
|
+
if (count < min) {
|
|
739
|
+
complete = false;
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
} else {
|
|
745
|
+
complete = value !== null && value !== undefined && value !== '';
|
|
746
|
+
}
|
|
702
747
|
}
|
|
703
748
|
|
|
704
749
|
const errors: string[] = [];
|
|
@@ -820,7 +865,7 @@ export class Player {
|
|
|
820
865
|
}
|
|
821
866
|
|
|
822
867
|
private execResponseProcessingTemplate(templateUrl: string): void {
|
|
823
|
-
const name = templateUrl.split('/').pop()?.toLowerCase();
|
|
868
|
+
const name = templateUrl.split('/').pop()?.toLowerCase().replace(/\.xml$/, '');
|
|
824
869
|
if (!name) {
|
|
825
870
|
console.warn(`[QTI Player] Could not extract template name from URL: ${templateUrl}`);
|
|
826
871
|
return;
|
|
@@ -905,7 +950,7 @@ export class Player {
|
|
|
905
950
|
// Declarations
|
|
906
951
|
// ----------------------------------------------------------------------------
|
|
907
952
|
|
|
908
|
-
private buildDeclarations(
|
|
953
|
+
private buildDeclarations(): DeclarationMap {
|
|
909
954
|
const decls: DeclarationMap = {};
|
|
910
955
|
|
|
911
956
|
const addDecl = (kind: DeclKind, el: Element) => {
|
|
@@ -959,9 +1004,9 @@ export class Player {
|
|
|
959
1004
|
}
|
|
960
1005
|
};
|
|
961
1006
|
|
|
962
|
-
for (const el of
|
|
963
|
-
for (const el of
|
|
964
|
-
for (const el of
|
|
1007
|
+
for (const el of this.itemDocument.findDeclarationElements('response')) addDecl('response', el);
|
|
1008
|
+
for (const el of this.itemDocument.findDeclarationElements('outcome')) addDecl('outcome', el);
|
|
1009
|
+
for (const el of this.itemDocument.findDeclarationElements('template')) addDecl('template', el);
|
|
965
1010
|
|
|
966
1011
|
return decls;
|
|
967
1012
|
}
|
|
@@ -1230,16 +1275,16 @@ export class Player {
|
|
|
1230
1275
|
}
|
|
1231
1276
|
|
|
1232
1277
|
private getModalFeedback(outcomes: Record<string, any>): ModalFeedback[] {
|
|
1233
|
-
const feedbackEls =
|
|
1278
|
+
const feedbackEls = this.itemDocument.findModalFeedbackElements();
|
|
1234
1279
|
const active: ModalFeedback[] = [];
|
|
1235
1280
|
|
|
1236
1281
|
for (const el of feedbackEls) {
|
|
1237
|
-
const identifier =
|
|
1238
|
-
const outcomeIdentifier =
|
|
1239
|
-
const showHide = (
|
|
1240
|
-
const title =
|
|
1282
|
+
const identifier = this.getAttrMapped(el, 'identifier') || '';
|
|
1283
|
+
const outcomeIdentifier = this.getAttrMapped(el, 'outcomeIdentifier') || '';
|
|
1284
|
+
const showHide = (this.getAttrMapped(el, 'showHide') || 'show') as 'show' | 'hide';
|
|
1285
|
+
const title = this.getAttrMapped(el, 'title') || undefined;
|
|
1241
1286
|
|
|
1242
|
-
const contentRaw =
|
|
1287
|
+
const contentRaw = this.itemDocument.serializeChildren(el) || (el.textContent || '');
|
|
1243
1288
|
const sanitized = sanitizeHtml(contentRaw, { security: this.config.security });
|
|
1244
1289
|
const content = toTrustedHtml(sanitized, this.config.security?.trustedTypesPolicyName);
|
|
1245
1290
|
|
|
@@ -1253,4 +1298,14 @@ export class Player {
|
|
|
1253
1298
|
}
|
|
1254
1299
|
}
|
|
1255
1300
|
|
|
1301
|
+
// ---------------------------------------------------------------------------
|
|
1302
|
+
// Module-level helpers
|
|
1303
|
+
// ---------------------------------------------------------------------------
|
|
1256
1304
|
|
|
1305
|
+
function mergePnp(base: PnpProfile | undefined, partial: Partial<PnpProfile>): PnpProfile {
|
|
1306
|
+
return {
|
|
1307
|
+
display: { ...(base?.display ?? {}), ...(partial.display ?? {}) },
|
|
1308
|
+
content: { ...(base?.content ?? {}), ...(partial.content ?? {}) },
|
|
1309
|
+
cognitive: { ...(base?.cognitive ?? {}), ...(partial.cognitive ?? {}) },
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { QTIRole } from '../types/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Product policy layered on top of QTI role/view semantics.
|
|
5
|
+
*
|
|
6
|
+
* QTI defines these roles as audience markers for view-controlled content
|
|
7
|
+
* (for example rubric/outcome visibility). It does not define a universal
|
|
8
|
+
* interaction UI behavior matrix. The player policy below keeps runtime
|
|
9
|
+
* behavior explicit and consistent across integrations.
|
|
10
|
+
*/
|
|
11
|
+
export interface RoleCapabilities {
|
|
12
|
+
isCandidate: boolean;
|
|
13
|
+
isReadOnly: boolean;
|
|
14
|
+
canViewCorrectResponses: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ROLES_WITH_CORRECT_RESPONSE_ACCESS: ReadonlySet<QTIRole> = new Set([
|
|
18
|
+
'scorer',
|
|
19
|
+
'author',
|
|
20
|
+
'tutor',
|
|
21
|
+
'testConstructor',
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
export function getRoleCapabilities(role: QTIRole): RoleCapabilities {
|
|
25
|
+
const isCandidate = role === 'candidate';
|
|
26
|
+
const canViewCorrectResponses = ROLES_WITH_CORRECT_RESPONSE_ACCESS.has(role);
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
isCandidate,
|
|
30
|
+
isReadOnly: !isCandidate,
|
|
31
|
+
canViewCorrectResponses,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
package/src/core/urlPolicy.ts
CHANGED
|
@@ -62,14 +62,17 @@ export function sanitizeResourceUrl(raw: string, policy?: UrlPolicyConfig, kind:
|
|
|
62
62
|
if (s.startsWith('//')) return p.allowProtocolRelative ? `https:${s}` : null;
|
|
63
63
|
|
|
64
64
|
// Relative/absolute-path URLs: allow and optionally resolve.
|
|
65
|
-
|
|
65
|
+
// Bare relative paths (e.g. "images/foo.png" from IMS CP manifests) are treated
|
|
66
|
+
// the same as "./" paths — they have no scheme and are safe to pass through.
|
|
67
|
+
if (s.startsWith('/') || s.startsWith('./') || s.startsWith('../') || !/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(s)) {
|
|
66
68
|
if (p.assetBaseUrl) {
|
|
67
69
|
try {
|
|
68
70
|
// Strip leading '/' to make URL constructor resolve relative to base path, not origin
|
|
69
71
|
const relativePath = s.startsWith('/') ? s.slice(1) : s;
|
|
70
72
|
return new URL(relativePath, p.assetBaseUrl).toString();
|
|
71
73
|
} catch {
|
|
72
|
-
return
|
|
74
|
+
// assetBaseUrl resolution failed; return the raw relative path as-is
|
|
75
|
+
return s;
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
return s;
|