@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
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { InteractionData } from '../types';
|
|
3
3
|
import type { Player } from '../core/Player';
|
|
4
|
+
import type { InteractionResponseValue, QTIChangeEventDetail } from '../web-components';
|
|
4
5
|
import type { I18nProvider } from '@pie-qti/i18n';
|
|
5
6
|
import { normalizeHeuristicsConfig, type QtiHeuristicsConfig } from '@pie-qti/ims-cp-core';
|
|
6
7
|
import { processFeedbackInline } from './utils/feedbackUtils';
|
|
7
8
|
import { typesetAction } from './actions/typesetAction';
|
|
9
|
+
import { glossaryAction } from '../catalog/glossaryAction';
|
|
8
10
|
import { assignProps } from './utils/assignProps';
|
|
11
|
+
import { getRoleCapabilities } from '../core/rolePolicy';
|
|
12
|
+
import InlineChoice from '../interactions/inline-choice/InlineChoice.svelte';
|
|
13
|
+
import InlineTextEntry from '../interactions/text-entry/InlineTextEntry.svelte';
|
|
14
|
+
import { createInlineRenderPlan, isInlineInteractionTagName, isInlineInteractionType } from '../interactions/inline/render-plan';
|
|
15
|
+
|
|
16
|
+
type ItemResponseValue = InteractionResponseValue | null;
|
|
17
|
+
type ItemResponseMap = Record<string, ItemResponseValue>;
|
|
18
|
+
type QtiChangeDomEvent = CustomEvent<QTIChangeEventDetail<ItemResponseValue>>;
|
|
9
19
|
|
|
10
20
|
interface Props {
|
|
11
21
|
player: Player;
|
|
12
|
-
responses?:
|
|
22
|
+
responses?: ItemResponseMap;
|
|
13
23
|
disabled?: boolean;
|
|
14
24
|
role?: 'candidate' | 'scorer' | 'author' | 'tutor' | 'proctor' | 'testConstructor';
|
|
15
25
|
i18n?: I18nProvider;
|
|
16
26
|
typeset?: (element: HTMLElement) => void;
|
|
17
|
-
onResponseChange?: (responseId: string, value:
|
|
27
|
+
onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
|
|
18
28
|
outcomeValues?: Record<string, any>; // Needed for feedbackInline visibility
|
|
19
29
|
heuristicsConfig?: QtiHeuristicsConfig; // Optional heuristics configuration
|
|
30
|
+
/** QTI 3.0 shared stimulus content: map of stimulus identifier → HTML string */
|
|
31
|
+
stimulusContent?: Record<string, string>;
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
let {
|
|
@@ -29,6 +41,7 @@
|
|
|
29
41
|
onResponseChange = () => {},
|
|
30
42
|
outcomeValues = {},
|
|
31
43
|
heuristicsConfig,
|
|
44
|
+
stimulusContent = {},
|
|
32
45
|
}: Props = $props();
|
|
33
46
|
|
|
34
47
|
// Normalize heuristics configuration with defaults
|
|
@@ -36,23 +49,24 @@
|
|
|
36
49
|
|
|
37
50
|
// Get the component registry from the player
|
|
38
51
|
const componentRegistry = $derived(player.getComponentRegistry());
|
|
52
|
+
const roleCapabilities = $derived(getRoleCapabilities(role));
|
|
53
|
+
const effectiveDisabled = $derived(disabled || roleCapabilities.isReadOnly);
|
|
39
54
|
|
|
40
55
|
// Process interactions
|
|
41
56
|
const interactions = $derived<InteractionData[]>(player.getInteractionData());
|
|
42
57
|
|
|
43
|
-
// Get correct responses
|
|
58
|
+
// Get correct responses for roles allowed by policy.
|
|
44
59
|
const correctResponses = $derived.by(() => {
|
|
45
|
-
return
|
|
60
|
+
return roleCapabilities.canViewCorrectResponses ? player.getCorrectResponses() : {};
|
|
46
61
|
});
|
|
47
62
|
|
|
48
|
-
// Get components for block-level interactions only (not inline interactions)
|
|
49
|
-
//
|
|
63
|
+
// Get components for block-level interactions only (not inline interactions).
|
|
64
|
+
// Type is always normalized to QTI 2.x camelCase by Player (qti-text-entry-interaction → textEntryInteraction).
|
|
50
65
|
const interactionComponents = $derived(
|
|
51
66
|
interactions
|
|
52
67
|
.filter(
|
|
53
68
|
(interaction) =>
|
|
54
|
-
interaction.type
|
|
55
|
-
interaction.type !== 'inlineChoiceInteraction'
|
|
69
|
+
!isInlineInteractionType(interaction.type)
|
|
56
70
|
)
|
|
57
71
|
.map((interaction) => {
|
|
58
72
|
try {
|
|
@@ -76,16 +90,32 @@
|
|
|
76
90
|
const itemBodyHtml = $derived.by(() => {
|
|
77
91
|
let html = player.getItemBodyHtml();
|
|
78
92
|
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
// QTI 3.0 Shared Stimulus: inject stimulus HTML at data-stimulus-idref docking points.
|
|
94
|
+
// Any stimulus identifier that has no docking div is prepended to the body.
|
|
95
|
+
if (stimulusContent && Object.keys(stimulusContent).length > 0) {
|
|
96
|
+
const docked = new Set<string>();
|
|
97
|
+
// Replace docking divs: <div ... data-stimulus-idref="ID" ...></div>
|
|
98
|
+
html = html.replace(
|
|
99
|
+
/<div([^>]*)\bdata-stimulus-idref="([^"]+)"([^>]*)>\s*<\/div>/gi,
|
|
100
|
+
(match, before, identifier, after) => {
|
|
101
|
+
const content = stimulusContent[identifier];
|
|
102
|
+
if (content) {
|
|
103
|
+
docked.add(identifier);
|
|
104
|
+
// Preserve any other attributes on the docking div
|
|
105
|
+
return `<div${before} data-stimulus-idref="${identifier}"${after} class="qti-stimulus-dock">${content}</div>`;
|
|
106
|
+
}
|
|
107
|
+
return match; // no content found — leave as-is
|
|
108
|
+
}
|
|
88
109
|
);
|
|
110
|
+
// Prepend any stimuli that had no docking div
|
|
111
|
+
const undocked = Object.entries(stimulusContent)
|
|
112
|
+
.filter(([id]) => !docked.has(id))
|
|
113
|
+
.map(([, content]) => `<div class="qti-stimulus-block">${content}</div>`)
|
|
114
|
+
.join('');
|
|
115
|
+
if (undocked) {
|
|
116
|
+
html = undocked + html;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
89
119
|
|
|
90
120
|
// Process feedbackInline elements - conditionally show/hide based on outcome values
|
|
91
121
|
html = processFeedbackInline(html, {
|
|
@@ -94,14 +124,14 @@
|
|
|
94
124
|
wrapWithSpan: false
|
|
95
125
|
});
|
|
96
126
|
|
|
97
|
-
// Wrap all block-level
|
|
98
|
-
//
|
|
127
|
+
// Wrap all block-level interaction elements with a hidden marker.
|
|
128
|
+
// Matches both QTI 2.x camelCase (*Interaction) and QTI 3.0 kebab-case (qti-*-interaction).
|
|
99
129
|
html = html.replace(
|
|
100
|
-
/<(\w+Interaction)(\s[^>]*)?>[\s\S]*?<\/\1>/gi,
|
|
130
|
+
/<(\w+Interaction|qti-[\w-]+-interaction)(\s[^>]*)?>[\s\S]*?<\/\1>/gi,
|
|
101
131
|
(match, tagName) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
132
|
+
const lower = tagName.toLowerCase();
|
|
133
|
+
// Inline interactions are rendered in-flow by the inline render plan.
|
|
134
|
+
if (isInlineInteractionTagName(lower)) {
|
|
105
135
|
return match;
|
|
106
136
|
}
|
|
107
137
|
// Wrap block interactions with a hidden span
|
|
@@ -112,75 +142,19 @@
|
|
|
112
142
|
return html;
|
|
113
143
|
});
|
|
114
144
|
|
|
115
|
-
|
|
116
|
-
// around component props inference in runes mode.
|
|
117
|
-
interface ParsedSegment {
|
|
118
|
-
type: 'html' | 'textEntry' | 'inlineChoice';
|
|
119
|
-
content?: string;
|
|
120
|
-
interaction?: any;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const inlineSegments = $derived.by(() => {
|
|
124
|
-
const html = itemBodyHtml;
|
|
125
|
-
const result: ParsedSegment[] = [];
|
|
126
|
-
|
|
127
|
-
let lastIndex = 0;
|
|
128
|
-
let match: RegExpExecArray | null;
|
|
129
|
-
|
|
130
|
-
// Find placeholders in order.
|
|
131
|
-
const combinedPattern = /\[TEXTENTRY:([^\]]+)\]|\[INLINECHOICE:([^\]]+)\]/g;
|
|
132
|
-
|
|
133
|
-
while ((match = combinedPattern.exec(html)) !== null) {
|
|
134
|
-
if (match.index > lastIndex) {
|
|
135
|
-
result.push({ type: 'html', content: html.substring(lastIndex, match.index) });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (match[0].startsWith('[TEXTENTRY:')) {
|
|
139
|
-
const responseId = match[1];
|
|
140
|
-
const interaction = (interactions as any[]).find((i) => i.responseId === responseId);
|
|
141
|
-
if (interaction) result.push({ type: 'textEntry', interaction });
|
|
142
|
-
} else if (match[0].startsWith('[INLINECHOICE:')) {
|
|
143
|
-
const responseId = match[2];
|
|
144
|
-
const interaction = (interactions as any[]).find((i) => i.responseId === responseId);
|
|
145
|
-
if (interaction) result.push({ type: 'inlineChoice', interaction });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
lastIndex = match.index + match[0].length;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (lastIndex < html.length) {
|
|
152
|
-
result.push({ type: 'html', content: html.substring(lastIndex) });
|
|
153
|
-
}
|
|
145
|
+
const inlineSegments = $derived(createInlineRenderPlan(itemBodyHtml, interactions));
|
|
154
146
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return result;
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
function handleResponseChange(responseId: string, value: any) {
|
|
163
|
-
onResponseChange(responseId, value);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function handleTextEntryInput(responseId: string, e: Event) {
|
|
167
|
-
const value = (e.currentTarget as HTMLInputElement | null)?.value ?? '';
|
|
168
|
-
handleResponseChange(responseId, value);
|
|
147
|
+
function getStringResponse(responseId: string): string {
|
|
148
|
+
const response = responses[responseId];
|
|
149
|
+
return typeof response === 'string' ? response : '';
|
|
169
150
|
}
|
|
170
151
|
|
|
171
|
-
function
|
|
172
|
-
|
|
173
|
-
handleResponseChange(responseId, value);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Helper to find correct choice for inline choice interactions
|
|
177
|
-
function findCorrectChoice(choices: any[], correctAnswer: string | null): any {
|
|
178
|
-
if (!correctAnswer) return null;
|
|
179
|
-
return choices.find((c: any) => c.identifier === correctAnswer) || null;
|
|
152
|
+
function handleResponseChange(responseId: string, value: ItemResponseValue) {
|
|
153
|
+
onResponseChange(responseId, value);
|
|
180
154
|
}
|
|
181
155
|
|
|
182
156
|
// Handle qti:change events from web components
|
|
183
|
-
function handleQtiChange(event:
|
|
157
|
+
function handleQtiChange(event: QtiChangeDomEvent) {
|
|
184
158
|
const { responseId, value } = event.detail;
|
|
185
159
|
handleResponseChange(responseId, value);
|
|
186
160
|
}
|
|
@@ -190,7 +164,7 @@
|
|
|
190
164
|
let rootEl: HTMLDivElement | null = $state(null);
|
|
191
165
|
$effect(() => {
|
|
192
166
|
if (!rootEl) return;
|
|
193
|
-
const handler = (e: Event) => handleQtiChange(e as
|
|
167
|
+
const handler = (e: Event) => handleQtiChange(e as QtiChangeDomEvent);
|
|
194
168
|
const el = rootEl; // Capture reference for cleanup
|
|
195
169
|
el.addEventListener('qti-change', handler as EventListener);
|
|
196
170
|
return () => {
|
|
@@ -241,7 +215,7 @@
|
|
|
241
215
|
}
|
|
242
216
|
</script>
|
|
243
217
|
|
|
244
|
-
<div bind:this={rootEl} class="qti-item-body" use:typesetAction={{ typeset }}>
|
|
218
|
+
<div bind:this={rootEl} class="qti-item-body" use:typesetAction={{ typeset }} use:glossaryAction={{ player }}>
|
|
245
219
|
<!-- Item body with inline interactions -->
|
|
246
220
|
<div class="prose max-w-none mb-4">
|
|
247
221
|
<div class="inline-interaction-container">
|
|
@@ -249,52 +223,25 @@
|
|
|
249
223
|
{#if segment.type === 'html'}
|
|
250
224
|
{@html segment.content}
|
|
251
225
|
{:else if segment.type === 'textEntry'}
|
|
252
|
-
{@const correctAnswer =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
style="width: {segment.interaction.expectedLength * 8}px; min-width: 100px; display: inline-block; margin: 0 4px;"
|
|
261
|
-
placeholder="..."
|
|
262
|
-
aria-label={`Text entry ${segment.interaction.responseId}${correctAnswer ? '. Correct answer: ' + correctAnswer : ''}`}
|
|
263
|
-
value={displayValue}
|
|
264
|
-
oninput={(e) => handleTextEntryInput(segment.interaction.responseId, e)}
|
|
265
|
-
{disabled}
|
|
226
|
+
{@const correctAnswer = roleCapabilities.canViewCorrectResponses ? (correctResponses[segment.interaction.responseId] ?? null) : null}
|
|
227
|
+
<InlineTextEntry
|
|
228
|
+
interaction={segment.interaction}
|
|
229
|
+
response={getStringResponse(segment.interaction.responseId)}
|
|
230
|
+
correctAnswer={roleCapabilities.canViewCorrectResponses ? correctAnswer : null}
|
|
231
|
+
disabled={effectiveDisabled}
|
|
232
|
+
{i18n}
|
|
233
|
+
onResponseChange={handleResponseChange}
|
|
266
234
|
/>
|
|
267
235
|
{:else if segment.type === 'inlineChoice'}
|
|
268
|
-
{@const correctAnswer =
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
class:bg-opacity-10={correctAnswer !== null}
|
|
278
|
-
style="display: inline-block; margin: 0 4px; width: auto; min-width: 120px;"
|
|
279
|
-
aria-label={`Inline choice ${segment.interaction.responseId}${correctAnswer && correctChoice ? '. Correct answer: ' + (correctChoice as any).text : ''}`}
|
|
280
|
-
value={displayValue}
|
|
281
|
-
onchange={(e) => handleInlineChoiceChange(segment.interaction.responseId, e)}
|
|
282
|
-
{disabled}
|
|
283
|
-
>
|
|
284
|
-
<option value="">{i18n?.t('interactions.inline.selectPlaceholder', 'Select...')}</option>
|
|
285
|
-
{#each segment.interaction.choices as choice}
|
|
286
|
-
{@const isCorrect = correctAnswer === choice.identifier}
|
|
287
|
-
<option value={choice.identifier}>
|
|
288
|
-
{choice.text}{isCorrect ? ' ✓' : ''}
|
|
289
|
-
</option>
|
|
290
|
-
{/each}
|
|
291
|
-
</select>
|
|
292
|
-
{#if correctAnswer !== null && correctChoice}
|
|
293
|
-
<span class="badge badge-success badge-sm" style="position: absolute; top: -1.5rem; left: 0; white-space: nowrap; font-size: 0.7rem;">
|
|
294
|
-
{i18n?.t('interactions.choice.correct', 'Correct') ?? 'Correct'}: {(correctChoice as any).text}
|
|
295
|
-
</span>
|
|
296
|
-
{/if}
|
|
297
|
-
</span>
|
|
236
|
+
{@const correctAnswer = roleCapabilities.canViewCorrectResponses ? (correctResponses[segment.interaction.responseId] ?? null) : null}
|
|
237
|
+
<InlineChoice
|
|
238
|
+
interaction={segment.interaction}
|
|
239
|
+
response={getStringResponse(segment.interaction.responseId)}
|
|
240
|
+
correctAnswer={roleCapabilities.canViewCorrectResponses ? correctAnswer : null}
|
|
241
|
+
disabled={effectiveDisabled}
|
|
242
|
+
{i18n}
|
|
243
|
+
onResponseChange={handleResponseChange}
|
|
244
|
+
/>
|
|
298
245
|
{/if}
|
|
299
246
|
{/each}
|
|
300
247
|
</div>
|
|
@@ -310,11 +257,11 @@
|
|
|
310
257
|
typeset,
|
|
311
258
|
interaction,
|
|
312
259
|
response: responses[interaction.responseId] ?? null,
|
|
313
|
-
correctResponse:
|
|
314
|
-
disabled,
|
|
260
|
+
correctResponse: roleCapabilities.canViewCorrectResponses ? correctRespForInteraction : null,
|
|
261
|
+
disabled: effectiveDisabled,
|
|
315
262
|
// Avoid invalid ARIA role values on custom-element hosts.
|
|
316
263
|
// Components default to candidate when role is omitted.
|
|
317
|
-
role:
|
|
264
|
+
role: roleCapabilities.canViewCorrectResponses ? 'scorer' : undefined,
|
|
318
265
|
}}
|
|
319
266
|
/>
|
|
320
267
|
{/each}
|
|
@@ -381,4 +328,27 @@
|
|
|
381
328
|
border-left: 2px solid var(--color-base-content, currentColor);
|
|
382
329
|
opacity: 0.8;
|
|
383
330
|
}
|
|
331
|
+
|
|
332
|
+
/* QTI 3.0 Shared Stimulus: stimulus blocks that were prepended before the item body */
|
|
333
|
+
:global(.qti-stimulus-block) {
|
|
334
|
+
margin-bottom: 1rem;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/* QTI 3.0 Shared Vocabulary: qti-input-width-N sets minimum input width in character units. */
|
|
338
|
+
:global(.qti-input-width-1) { min-width: 1ch; }
|
|
339
|
+
:global(.qti-input-width-2) { min-width: 2ch; }
|
|
340
|
+
:global(.qti-input-width-3) { min-width: 3ch; }
|
|
341
|
+
:global(.qti-input-width-4) { min-width: 4ch; }
|
|
342
|
+
:global(.qti-input-width-5) { min-width: 5ch; }
|
|
343
|
+
:global(.qti-input-width-6) { min-width: 6ch; }
|
|
344
|
+
:global(.qti-input-width-10) { min-width: 10ch; }
|
|
345
|
+
:global(.qti-input-width-15) { min-width: 15ch; }
|
|
346
|
+
:global(.qti-input-width-20) { min-width: 20ch; }
|
|
347
|
+
:global(.qti-input-width-25) { min-width: 25ch; }
|
|
348
|
+
:global(.qti-input-width-30) { min-width: 30ch; }
|
|
349
|
+
:global(.qti-input-width-35) { min-width: 35ch; }
|
|
350
|
+
:global(.qti-input-width-40) { min-width: 40ch; }
|
|
351
|
+
:global(.qti-input-width-45) { min-width: 45ch; }
|
|
352
|
+
:global(.qti-input-width-50) { min-width: 50ch; }
|
|
353
|
+
:global(.qti-input-width-72) { min-width: 72ch; }
|
|
384
354
|
</style>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Player } from '../core/Player';
|
|
3
|
-
import type { AdaptiveAttemptResult, ModalFeedback, PlayerSecurityConfig, QTIRole } from '../types';
|
|
3
|
+
import type { AdaptiveAttemptResult, ModalFeedback, PlayerSecurityConfig, QTIRole, ScoringResult } from '../types';
|
|
4
|
+
import type { InteractionResponseValue } from '../web-components';
|
|
4
5
|
import type { I18nProvider } from '@pie-qti/i18n';
|
|
6
|
+
import { typesetMathInElement } from '@pie-qti/typeset-katex';
|
|
5
7
|
import ItemBody from './ItemBody.svelte';
|
|
6
8
|
import ModalFeedbackDisplay from './ModalFeedbackDisplay.svelte';
|
|
7
9
|
|
|
10
|
+
type ItemResponseValue = InteractionResponseValue | null;
|
|
11
|
+
type ItemResponseMap = Record<string, ItemResponseValue>;
|
|
12
|
+
|
|
8
13
|
interface Props {
|
|
9
14
|
itemXml: string;
|
|
10
15
|
role?: QTIRole;
|
|
@@ -13,8 +18,8 @@
|
|
|
13
18
|
disabled?: boolean;
|
|
14
19
|
typeset?: (element: HTMLElement) => void;
|
|
15
20
|
i18n?: I18nProvider;
|
|
16
|
-
onResponseChange?: (responseId: string, value:
|
|
17
|
-
onSubmit?: (responses:
|
|
21
|
+
onResponseChange?: (responseId: string, value: ItemResponseValue) => void;
|
|
22
|
+
onSubmit?: (responses: ItemResponseMap, scoringResult: ScoringResult) => void;
|
|
18
23
|
/** Called when adaptive item completes (all attempts exhausted) */
|
|
19
24
|
onComplete?: (finalResult: AdaptiveAttemptResult) => void;
|
|
20
25
|
}
|
|
@@ -31,9 +36,12 @@
|
|
|
31
36
|
onComplete,
|
|
32
37
|
}: Props = $props();
|
|
33
38
|
|
|
39
|
+
// Use host-provided typeset if given, otherwise fall back to the built-in KaTeX typesetter.
|
|
40
|
+
const effectiveTypeset = $derived(typeset ?? typesetMathInElement);
|
|
41
|
+
|
|
34
42
|
// Create player instance
|
|
35
43
|
let player = $state<Player | null>(null);
|
|
36
|
-
let responses = $state<
|
|
44
|
+
let responses = $state<ItemResponseMap>({});
|
|
37
45
|
let error = $state<string | null>(null);
|
|
38
46
|
let modalFeedback = $state<ModalFeedback[]>([]);
|
|
39
47
|
let outcomeValues = $state<Record<string, any>>({});
|
|
@@ -59,7 +67,7 @@
|
|
|
59
67
|
}
|
|
60
68
|
});
|
|
61
69
|
|
|
62
|
-
function handleResponseChange(responseId: string, value:
|
|
70
|
+
function handleResponseChange(responseId: string, value: ItemResponseValue) {
|
|
63
71
|
responses = { ...responses, [responseId]: value };
|
|
64
72
|
onResponseChange?.(responseId, value);
|
|
65
73
|
}
|
|
@@ -116,7 +124,7 @@
|
|
|
116
124
|
{responses}
|
|
117
125
|
{disabled}
|
|
118
126
|
{role}
|
|
119
|
-
{
|
|
127
|
+
typeset={effectiveTypeset}
|
|
120
128
|
{i18n}
|
|
121
129
|
{outcomeValues}
|
|
122
130
|
onResponseChange={handleResponseChange}
|
|
@@ -146,7 +154,7 @@
|
|
|
146
154
|
{/if}
|
|
147
155
|
|
|
148
156
|
<!-- Modal feedback display -->
|
|
149
|
-
<ModalFeedbackDisplay feedback={modalFeedback} onClose={closeFeedback} {
|
|
157
|
+
<ModalFeedbackDisplay feedback={modalFeedback} onClose={closeFeedback} typeset={effectiveTypeset} {i18n} />
|
|
150
158
|
{:else}
|
|
151
159
|
<div class="alert alert-info">
|
|
152
160
|
<span>{i18n?.t('item.loading') ?? 'item.loading'}</span>
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
// Show modal if there's feedback
|
|
16
16
|
const hasActiveFeedback = $derived(feedback.length > 0);
|
|
17
|
+
const modalTitleId = 'item-player-modal-feedback-title';
|
|
18
|
+
const firstTitle = $derived(feedback.find((item) => item.title)?.title);
|
|
17
19
|
|
|
18
20
|
function handleClose() {
|
|
19
21
|
onClose?.();
|
|
@@ -29,13 +31,21 @@
|
|
|
29
31
|
|
|
30
32
|
{#if hasActiveFeedback}
|
|
31
33
|
<!-- DaisyUI Modal -->
|
|
32
|
-
<dialog
|
|
34
|
+
<dialog
|
|
35
|
+
open
|
|
36
|
+
class="modal modal-open"
|
|
37
|
+
aria-modal="true"
|
|
38
|
+
aria-labelledby={firstTitle ? modalTitleId : undefined}
|
|
39
|
+
aria-label={firstTitle ? undefined : (i18n?.t('feedback.title') ?? 'Feedback')}
|
|
40
|
+
onclick={handleBackdropClick}
|
|
41
|
+
>
|
|
33
42
|
<div class="modal-box max-w-3xl">
|
|
34
43
|
<!-- Close button -->
|
|
35
44
|
<button
|
|
36
45
|
class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"
|
|
46
|
+
type="button"
|
|
37
47
|
onclick={handleClose}
|
|
38
|
-
aria-label={i18n?.t('feedback.closeFeedback') ?? 'feedback
|
|
48
|
+
aria-label={i18n?.t('feedback.closeFeedback') ?? 'Close feedback'}
|
|
39
49
|
>
|
|
40
50
|
✕
|
|
41
51
|
</button>
|
|
@@ -44,7 +54,7 @@
|
|
|
44
54
|
{#each feedback as item, index}
|
|
45
55
|
<div class="mb-4 {index < feedback.length - 1 ? 'border-b pb-4' : ''}">
|
|
46
56
|
{#if item.title}
|
|
47
|
-
<h3 class="font-bold text-lg mb-2">{item.title}</h3>
|
|
57
|
+
<h3 id={index === 0 ? modalTitleId : undefined} class="font-bold text-lg mb-2">{item.title}</h3>
|
|
48
58
|
{/if}
|
|
49
59
|
|
|
50
60
|
<!-- Render HTML content with MathJax support -->
|
|
@@ -65,8 +75,8 @@
|
|
|
65
75
|
|
|
66
76
|
<!-- Action buttons -->
|
|
67
77
|
<div class="modal-action">
|
|
68
|
-
<button class="btn btn-primary" onclick={handleClose}>
|
|
69
|
-
{i18n?.t('common.continue') ?? '
|
|
78
|
+
<button class="btn btn-primary" type="button" onclick={handleClose}>
|
|
79
|
+
{i18n?.t('common.continue') ?? 'Continue'}
|
|
70
80
|
</button>
|
|
71
81
|
</div>
|
|
72
82
|
</div>
|
package/src/components/index.ts
CHANGED
|
@@ -17,3 +17,6 @@ export { default as ModalFeedbackDisplay } from './ModalFeedbackDisplay.svelte';
|
|
|
17
17
|
|
|
18
18
|
// Utility actions (dependency-free)
|
|
19
19
|
export { typesetAction } from './actions/typesetAction';
|
|
20
|
+
|
|
21
|
+
// Catalog actions
|
|
22
|
+
export { glossaryAction, type GlossaryActionParams } from '../catalog/glossaryAction';
|
|
@@ -21,8 +21,9 @@ export interface ComponentConfig<TData extends InteractionData = InteractionData
|
|
|
21
21
|
* - 50: Moderately specific custom renderers
|
|
22
22
|
* - 10: Generic custom renderers
|
|
23
23
|
* - 0: Default fallback renderers
|
|
24
|
+
* Default: 0
|
|
24
25
|
*/
|
|
25
|
-
priority
|
|
26
|
+
priority?: number;
|
|
26
27
|
|
|
27
28
|
/** Optional description for debugging/error messages */
|
|
28
29
|
description?: string;
|
|
@@ -31,8 +32,9 @@ export interface ComponentConfig<TData extends InteractionData = InteractionData
|
|
|
31
32
|
* Predicate to determine if this component can handle the interaction
|
|
32
33
|
* Evaluated in priority order (highest first)
|
|
33
34
|
* @returns true if this component should be used
|
|
35
|
+
* Default: always true
|
|
34
36
|
*/
|
|
35
|
-
canHandle
|
|
37
|
+
canHandle?: (data: TData) => boolean;
|
|
36
38
|
|
|
37
39
|
/**
|
|
38
40
|
* Web component tag name (must contain a hyphen per web component spec)
|
|
@@ -57,7 +59,10 @@ export interface ComponentConfig<TData extends InteractionData = InteractionData
|
|
|
57
59
|
* Internal registered component with metadata
|
|
58
60
|
*/
|
|
59
61
|
interface RegisteredComponent<TData extends InteractionData = InteractionData> {
|
|
60
|
-
config: ComponentConfig<TData
|
|
62
|
+
config: ComponentConfig<TData> & {
|
|
63
|
+
priority: number;
|
|
64
|
+
canHandle: (data: TData) => boolean;
|
|
65
|
+
};
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
/**
|
|
@@ -88,8 +93,6 @@ export class ComponentRegistry {
|
|
|
88
93
|
* // Default choice component
|
|
89
94
|
* registry.register('choiceInteraction', {
|
|
90
95
|
* name: 'standard-choice',
|
|
91
|
-
* priority: 0,
|
|
92
|
-
* canHandle: () => true,
|
|
93
96
|
* tagName: 'qti-choice-interaction'
|
|
94
97
|
* });
|
|
95
98
|
*/
|
|
@@ -122,11 +125,23 @@ export class ComponentRegistry {
|
|
|
122
125
|
this.components.set(type, components);
|
|
123
126
|
}
|
|
124
127
|
|
|
125
|
-
// Add component and sort by priority (highest first)
|
|
126
|
-
components.push(
|
|
128
|
+
// Add normalized component and sort by priority (highest first)
|
|
129
|
+
components.push(this.createRegisteredComponent(config) as RegisteredComponent);
|
|
127
130
|
components.sort((a, b) => b.config.priority - a.config.priority);
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
private createRegisteredComponent<TData extends InteractionData>(
|
|
134
|
+
config: ComponentConfig<TData>
|
|
135
|
+
): RegisteredComponent<TData> {
|
|
136
|
+
return {
|
|
137
|
+
config: {
|
|
138
|
+
...config,
|
|
139
|
+
priority: config.priority ?? 0,
|
|
140
|
+
canHandle: config.canHandle ?? (() => true),
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
130
145
|
/**
|
|
131
146
|
* Get a web component tag name for an interaction type
|
|
132
147
|
* Evaluates canHandle predicates in priority order
|
|
@@ -189,6 +204,20 @@ export class ComponentRegistry {
|
|
|
189
204
|
hasComponent(type: string): boolean {
|
|
190
205
|
return this.components.has(type) && this.components.get(type)!.length > 0;
|
|
191
206
|
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get the tag name for a registered type by name (no canHandle evaluation).
|
|
210
|
+
* Useful for non-interaction components like catalogPopup where the type string
|
|
211
|
+
* is known and there is no InteractionData object to pass.
|
|
212
|
+
*
|
|
213
|
+
* Returns the highest-priority registered tag name for the type, or null if
|
|
214
|
+
* the type is not registered.
|
|
215
|
+
*/
|
|
216
|
+
getTagNameForType(type: string): string | null {
|
|
217
|
+
const components = this.components.get(type);
|
|
218
|
+
if (!components || components.length === 0) return null;
|
|
219
|
+
return components[0].config.tagName;
|
|
220
|
+
}
|
|
192
221
|
}
|
|
193
222
|
|
|
194
223
|
/**
|