@pie-qti/item-player 0.1.1 → 0.1.5
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 +22 -19
- 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/components/actions/typesetAction.d.ts +24 -0
- package/dist/components/actions/typesetAction.d.ts.map +1 -0
- package/dist/components/actions/typesetAction.js +59 -0
- package/dist/components/utils/assignProps.d.ts +2 -0
- package/dist/components/utils/assignProps.d.ts.map +1 -0
- package/dist/components/utils/assignProps.js +1 -0
- package/dist/components/utils/feedbackUtils.d.ts +73 -0
- package/dist/components/utils/feedbackUtils.d.ts.map +1 -0
- package/dist/components/utils/feedbackUtils.js +93 -0
- package/dist/components/utils/index.d.ts +6 -0
- package/dist/components/utils/index.d.ts.map +1 -0
- package/dist/components/utils/index.js +5 -0
- package/dist/core/ComponentRegistry.d.ts +128 -0
- package/dist/core/ComponentRegistry.d.ts.map +1 -0
- package/dist/core/ComponentRegistry.js +137 -0
- package/dist/core/ItemRenderer.d.ts +91 -0
- package/dist/core/ItemRenderer.d.ts.map +1 -0
- package/dist/core/ItemRenderer.js +261 -0
- package/dist/core/Player.d.ts +195 -0
- package/dist/core/Player.d.ts.map +1 -0
- package/dist/core/Player.js +1235 -0
- package/dist/core/Plugin.d.ts +105 -0
- package/dist/core/Plugin.d.ts.map +1 -0
- package/dist/core/Plugin.js +7 -0
- package/dist/core/PluginManager.d.ts +56 -0
- package/dist/core/PluginManager.d.ts.map +1 -0
- package/dist/core/PluginManager.js +147 -0
- package/dist/core/constants.d.ts +68 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +106 -0
- package/dist/core/declarations.d.ts +45 -0
- package/dist/core/declarations.d.ts.map +1 -0
- package/dist/core/declarations.js +133 -0
- package/dist/core/parsingLimits.d.ts +12 -0
- package/dist/core/parsingLimits.d.ts.map +1 -0
- package/dist/core/parsingLimits.js +45 -0
- package/dist/core/random.d.ts +12 -0
- package/dist/core/random.d.ts.map +1 -0
- package/dist/core/random.js +21 -0
- 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/sanitizer.d.ts +34 -0
- package/dist/core/sanitizer.d.ts.map +1 -0
- package/dist/core/sanitizer.js +198 -0
- package/dist/core/trustedTypes.d.ts +16 -0
- package/dist/core/trustedTypes.d.ts.map +1 -0
- package/dist/core/trustedTypes.js +55 -0
- package/dist/core/urlPolicy.d.ts +8 -0
- package/dist/core/urlPolicy.d.ts.map +1 -0
- package/dist/core/urlPolicy.js +90 -0
- package/dist/element.d.ts +22 -0
- package/dist/element.js +5327 -0
- package/dist/element.js.map +1 -0
- package/dist/extensions/MathLiveEditor.d.ts +32 -0
- package/dist/extensions/MathLiveEditor.d.ts.map +1 -0
- package/dist/extensions/MathLiveEditor.js +249 -0
- package/dist/extraction/ExtractionRegistry.d.ts +112 -0
- package/dist/extraction/ExtractionRegistry.d.ts.map +1 -0
- package/dist/extraction/ExtractionRegistry.js +260 -0
- package/dist/extraction/createContext.d.ts +30 -0
- package/dist/extraction/createContext.d.ts.map +1 -0
- package/dist/extraction/createContext.js +39 -0
- package/dist/extraction/extractors/associateExtractor.d.ts +29 -0
- package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/associateExtractor.js +97 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts +27 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/choiceExtractor.js +93 -0
- package/dist/extraction/extractors/customExtractor.d.ts +20 -0
- package/dist/extraction/extractors/customExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/customExtractor.js +51 -0
- package/dist/extraction/extractors/drawingExtractor.d.ts +30 -0
- package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/drawingExtractor.js +78 -0
- package/dist/extraction/extractors/endAttemptExtractor.d.ts +20 -0
- package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/endAttemptExtractor.js +53 -0
- package/dist/extraction/extractors/extendedTextExtractor.d.ts +21 -0
- package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/extendedTextExtractor.js +63 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts +29 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/gapMatchExtractor.js +155 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +41 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.js +143 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +53 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.js +205 -0
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts +37 -0
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicOrderExtractor.js +121 -0
- package/dist/extraction/extractors/hotspotExtractor.d.ts +38 -0
- package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/hotspotExtractor.js +159 -0
- package/dist/extraction/extractors/hottextExtractor.d.ts +26 -0
- package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/hottextExtractor.js +128 -0
- package/dist/extraction/extractors/index.d.ts +63 -0
- package/dist/extraction/extractors/index.d.ts.map +1 -0
- package/dist/extraction/extractors/index.js +88 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +25 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.js +80 -0
- package/dist/extraction/extractors/matchExtractor.d.ts +37 -0
- package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/matchExtractor.js +160 -0
- package/dist/extraction/extractors/mediaExtractor.d.ts +33 -0
- package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/mediaExtractor.js +125 -0
- package/dist/extraction/extractors/orderExtractor.d.ts +28 -0
- package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/orderExtractor.js +90 -0
- package/dist/extraction/extractors/portableCustomExtractor.d.ts +14 -0
- package/dist/extraction/extractors/portableCustomExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/portableCustomExtractor.js +96 -0
- package/dist/extraction/extractors/positionObjectExtractor.d.ts +59 -0
- package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/positionObjectExtractor.js +191 -0
- package/dist/extraction/extractors/selectPointExtractor.d.ts +31 -0
- package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/selectPointExtractor.js +109 -0
- package/dist/extraction/extractors/sliderExtractor.d.ts +24 -0
- package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/sliderExtractor.js +73 -0
- package/dist/extraction/extractors/textEntryExtractor.d.ts +21 -0
- package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/textEntryExtractor.js +54 -0
- package/dist/extraction/extractors/uploadExtractor.d.ts +20 -0
- package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/uploadExtractor.js +59 -0
- package/dist/extraction/index.d.ts +49 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +49 -0
- package/dist/extraction/types.d.ts +209 -0
- package/dist/extraction/types.d.ts.map +1 -0
- package/dist/extraction/types.js +30 -0
- package/dist/extraction/utils.d.ts +15 -0
- package/dist/extraction/utils.d.ts.map +1 -0
- package/dist/extraction/utils.js +178 -0
- package/dist/iframe/IFramePlayerHost.d.ts +122 -0
- package/dist/iframe/IFramePlayerHost.d.ts.map +1 -0
- package/dist/iframe/IFramePlayerHost.js +172 -0
- package/dist/iframe/index.d.ts +9 -0
- package/dist/iframe/index.d.ts.map +1 -0
- package/dist/iframe/index.js +8 -0
- package/dist/iframe/protocol.d.ts +75 -0
- package/dist/iframe/protocol.d.ts.map +1 -0
- package/dist/iframe/protocol.js +53 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -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/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +10 -0
- package/dist/types/index.d.ts +304 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/interactions.d.ts +412 -0
- package/dist/types/interactions.d.ts.map +1 -0
- package/dist/types/interactions.js +7 -0
- package/dist/types/responseValidation.d.ts +25 -0
- package/dist/types/responseValidation.d.ts.map +1 -0
- package/dist/types/responseValidation.js +1 -0
- package/dist/utils/PerformanceMonitor.d.ts +170 -0
- package/dist/utils/PerformanceMonitor.d.ts.map +1 -0
- package/dist/utils/PerformanceMonitor.js +242 -0
- package/dist/utils/drawingUtils.d.ts +39 -0
- package/dist/utils/drawingUtils.d.ts.map +1 -0
- package/dist/utils/drawingUtils.js +57 -0
- package/dist/utils/responseUtils.d.ts +16 -0
- package/dist/utils/responseUtils.d.ts.map +1 -0
- package/dist/utils/responseUtils.js +45 -0
- package/dist/utils/touchDragHelper.d.ts +2 -0
- package/dist/utils/touchDragHelper.d.ts.map +1 -0
- package/dist/utils/touchDragHelper.js +1 -0
- package/dist/web-components/QTIInteractionBase.d.ts +120 -0
- package/dist/web-components/QTIInteractionBase.d.ts.map +1 -0
- package/dist/web-components/QTIInteractionBase.js +243 -0
- package/dist/web-components/QTIInteractionElement.d.ts +77 -0
- package/dist/web-components/QTIInteractionElement.d.ts.map +1 -0
- package/dist/web-components/QTIInteractionElement.js +61 -0
- package/dist/web-components/index.d.ts +8 -0
- package/dist/web-components/index.d.ts.map +1 -0
- package/dist/web-components/index.js +10 -0
- package/package.json +104 -76
- 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-attribute-extraction.test.ts +174 -0
- package/src/__tests__/qti3-debug.test.ts +140 -0
- package/src/__tests__/qti3-extraction.test.ts +309 -0
- 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 +136 -26
- package/src/components/ItemPlayer.svelte +6 -2
- package/src/components/index.ts +3 -0
- package/src/components/utils/assignProps.ts +1 -23
- package/src/core/ComponentRegistry.ts +14 -0
- package/src/core/ItemRenderer.ts +4 -0
- package/src/core/Player.ts +312 -38
- package/src/core/parsingLimits.ts +1 -1
- package/src/core/rolePolicy.ts +34 -0
- package/src/core/urlPolicy.ts +5 -2
- package/src/element.ts +128 -0
- package/src/extensions/MathLiveEditor.ts +6 -3
- package/src/extraction/ExtractionRegistry.ts +51 -11
- package/src/extraction/createContext.ts +6 -1
- package/src/extraction/extractors/associateExtractor.ts +4 -0
- package/src/extraction/extractors/choiceExtractor.ts +12 -1
- 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/extendedTextExtractor.ts +11 -2
- package/src/extraction/extractors/gapMatchExtractor.ts +36 -21
- package/src/extraction/extractors/graphicAssociateExtractor.ts +4 -0
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +82 -10
- package/src/extraction/extractors/hotspotExtractor.ts +26 -8
- package/src/extraction/extractors/hottextExtractor.ts +15 -5
- package/src/extraction/extractors/index.ts +4 -0
- package/src/extraction/extractors/inlineChoiceExtractor.ts +22 -5
- package/src/extraction/extractors/matchExtractor.ts +33 -6
- package/src/extraction/extractors/orderExtractor.ts +6 -0
- package/src/extraction/extractors/portableCustomExtractor.ts +122 -0
- package/src/extraction/extractors/selectPointExtractor.ts +5 -5
- package/src/extraction/extractors/textEntryExtractor.ts +11 -2
- package/src/extraction/extractors/uploadExtractor.ts +10 -2
- package/src/extraction/utils.ts +99 -16
- package/src/index.ts +19 -1
- 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 +50 -16
- package/src/types/interactions.ts +81 -6
- package/src/types/xmldom.d.ts +12 -0
- package/src/utils/drawingUtils.ts +73 -0
- package/src/utils/touchDragHelper.ts +1 -211
- package/.turbo/turbo-build.log +0 -1
- package/CHANGELOG.md +0 -9
- package/docs/QTI-COMPLIANCE.md +0 -197
- package/docs/WCAG-2.2-COMPLIANCE.md +0 -466
- package/docs/custom-extractors.md +0 -679
- package/docs/iframe-mode.md +0 -78
- package/docs/security-audit.md +0 -236
- package/docs/server-api.md +0 -691
- package/tests/conformance/FIXTURE_POLICY.md +0 -29
- package/tests/conformance/README.md +0 -70
- package/tests/conformance/fixtures/baseTypes_all/cases.json +0 -61
- package/tests/conformance/fixtures/baseTypes_all/item.xml +0 -131
- package/tests/conformance/fixtures/baseTypes_all/manifest.json +0 -7
- package/tests/conformance/fixtures/choice_match_correct/cases.json +0 -17
- package/tests/conformance/fixtures/choice_match_correct/item.xml +0 -55
- package/tests/conformance/fixtures/choice_match_correct/manifest.json +0 -14
- package/tests/conformance/fixtures/contains_multiple/cases.json +0 -12
- package/tests/conformance/fixtures/contains_multiple/item.xml +0 -37
- package/tests/conformance/fixtures/contains_multiple/manifest.json +0 -13
- package/tests/conformance/fixtures/isNull_isNotNull/cases.json +0 -9
- package/tests/conformance/fixtures/isNull_isNotNull/item.xml +0 -41
- package/tests/conformance/fixtures/isNull_isNotNull/manifest.json +0 -23
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/cases.json +0 -27
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/item.xml +0 -30
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/manifest.json +0 -15
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/cases.json +0 -11
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/item.xml +0 -26
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/manifest.json +0 -13
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/cases.json +0 -27
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/item.xml +0 -32
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/manifest.json +0 -7
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/cases.json +0 -9
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/item.xml +0 -25
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/manifest.json +0 -12
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/cases.json +0 -12
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/item.xml +0 -35
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/manifest.json +0 -11
- package/tests/conformance/fixtures/mapping_bounds_upperLower/cases.json +0 -12
- package/tests/conformance/fixtures/mapping_bounds_upperLower/item.xml +0 -37
- package/tests/conformance/fixtures/mapping_bounds_upperLower/manifest.json +0 -11
- package/tests/conformance/fixtures/mapping_mapResponse/cases.json +0 -22
- package/tests/conformance/fixtures/mapping_mapResponse/item.xml +0 -53
- package/tests/conformance/fixtures/mapping_mapResponse/manifest.json +0 -16
- package/tests/conformance/fixtures/member_multiple/cases.json +0 -12
- package/tests/conformance/fixtures/member_multiple/item.xml +0 -37
- package/tests/conformance/fixtures/member_multiple/manifest.json +0 -13
- package/tests/conformance/fixtures/modalFeedback_basic/cases.json +0 -17
- package/tests/conformance/fixtures/modalFeedback_basic/item.xml +0 -52
- package/tests/conformance/fixtures/modalFeedback_basic/manifest.json +0 -13
- package/tests/conformance/fixtures/multiple_unordered_match/cases.json +0 -17
- package/tests/conformance/fixtures/multiple_unordered_match/item.xml +0 -44
- package/tests/conformance/fixtures/multiple_unordered_match/manifest.json +0 -11
- package/tests/conformance/fixtures/ordered_match/cases.json +0 -17
- package/tests/conformance/fixtures/ordered_match/item.xml +0 -48
- package/tests/conformance/fixtures/ordered_match/manifest.json +0 -13
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/cases.json +0 -27
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/item.xml +0 -103
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/manifest.json +0 -7
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/cases.json +0 -15
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/item.xml +0 -33
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/manifest.json +0 -10
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/item.xml +0 -26
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/manifest.json +0 -8
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/cases.json +0 -17
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/item.xml +0 -43
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/manifest.json +0 -16
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/cases.json +0 -27
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/item.xml +0 -37
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/manifest.json +0 -16
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/item.xml +0 -35
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/manifest.json +0 -8
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/item.xml +0 -35
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/manifest.json +0 -8
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/cases.json +0 -15
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/item.xml +0 -39
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/manifest.json +0 -11
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/item.xml +0 -35
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/manifest.json +0 -8
- package/tests/conformance/fixtures/pair_unordered_match/cases.json +0 -22
- package/tests/conformance/fixtures/pair_unordered_match/item.xml +0 -44
- package/tests/conformance/fixtures/pair_unordered_match/manifest.json +0 -13
- package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/cases.json +0 -95
- package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/item.xml +0 -53
- package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/cases.json +0 -115
- package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/item.xml +0 -45
- package/tests/conformance/fixtures/positionObject_mapResponse_wrong/cases.json +0 -29
- package/tests/conformance/fixtures/positionObject_mapResponse_wrong/item.xml +0 -40
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/cases.json +0 -10
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/item.xml +0 -49
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/manifest.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_anyN/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_anyN/item.xml +0 -47
- package/tests/conformance/fixtures/responseProcessing_anyN/manifest.json +0 -16
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/item.xml +0 -69
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/manifest.json +0 -23
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/item.xml +0 -58
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/manifest.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/cases.json +0 -37
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/item.xml +0 -94
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/manifest.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/cases.json +0 -33
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/item.xml +0 -79
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/manifest.json +0 -16
- package/tests/conformance/fixtures/responseProcessing_customOperator/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_customOperator/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_customOperator/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_default_expression/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_default_expression/item.xml +0 -48
- package/tests/conformance/fixtures/responseProcessing_default_expression/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/cases.json +0 -29
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/item.xml +0 -68
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/manifest.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/cases.json +0 -39
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/item.xml +0 -39
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/manifest.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_exitResponse/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_exitResponse/item.xml +0 -25
- package/tests/conformance/fixtures/responseProcessing_exitResponse/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/cases.json +0 -26
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/item.xml +0 -134
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/manifest.json +0 -16
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/item.xml +0 -33
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/item.xml +0 -33
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/item.xml +0 -40
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/manifest.json +0 -18
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/item.xml +0 -33
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/cases.json +0 -29
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/item.xml +0 -26
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/manifest.json +0 -7
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/cases.json +0 -23
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/item.xml +0 -28
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/manifest.json +0 -11
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/cases.json +0 -29
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/item.xml +0 -26
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/manifest.json +0 -7
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/cases.json +0 -31
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/item.xml +0 -102
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/manifest.json +0 -18
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/item.xml +0 -45
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/manifest.json +0 -21
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/cases.json +0 -26
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/item.xml +0 -157
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/manifest.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/item.xml +0 -39
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/manifest.json +0 -18
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/item.xml +0 -51
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/manifest.json +0 -19
- package/tests/conformance/fixtures/responseProcessing_preCondition/cases.json +0 -31
- package/tests/conformance/fixtures/responseProcessing_preCondition/item.xml +0 -44
- package/tests/conformance/fixtures/responseProcessing_preCondition/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/item.xml +0 -42
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/manifest.json +0 -14
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/item.xml +0 -40
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/manifest.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/item.xml +0 -63
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/manifest.json +0 -9
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/item.xml +0 -40
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/item.xml +0 -67
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/manifest.json +0 -9
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/item.xml +0 -69
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/manifest.json +0 -10
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/item.xml +0 -35
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/manifest.json +0 -11
- package/tests/conformance/fixtures/responseProcessing_template_map_response/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_map_response/item.xml +0 -31
- package/tests/conformance/fixtures/responseProcessing_template_map_response/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/item.xml +0 -27
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/item.xml +0 -34
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/manifest.json +0 -7
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/manifest.json +0 -9
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_xiInclude/cases.json +0 -14
- package/tests/conformance/fixtures/responseProcessing_xiInclude/item.xml +0 -25
- package/tests/conformance/fixtures/responseProcessing_xiInclude/manifest.json +0 -9
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/cases.json +0 -12
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/item.xml +0 -52
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/manifest.json +0 -14
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/cases.json +0 -12
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/item.xml +0 -48
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/manifest.json +0 -13
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/cases.json +0 -27
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/item.xml +0 -74
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/manifest.json +0 -22
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/cases.json +0 -17
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/item.xml +0 -133
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/manifest.json +0 -22
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/cases.json +0 -12
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/item.xml +0 -107
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/manifest.json +0 -16
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/cases.json +0 -15
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/item.xml +0 -52
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/manifest.json +0 -14
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/cases.json +0 -16
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/item.xml +0 -49
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/manifest.json +0 -15
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/cases.json +0 -16
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/item.xml +0 -38
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/manifest.json +0 -13
- package/tests/conformance/harness.ts +0 -84
- package/tests/conformance/run-fixtures.test.ts +0 -127
- package/tests/conformance/scripts/normalize-covers.ts +0 -152
- package/tests/conformance/types.ts +0 -53
- package/tests/core/Player.test.ts +0 -563
- package/tests/core/adaptiveItems.test.ts +0 -442
- package/tests/core/correctResponse.test.ts +0 -280
- package/tests/core/interaction-plumbing.test.ts +0 -141
- package/tests/core/modalFeedback.test.ts +0 -308
- package/tests/core/outcome-reset.test.ts +0 -43
- package/tests/extraction/extractors/associateExtractor.test.ts +0 -182
- package/tests/extraction/extractors/choiceExtractor.test.ts +0 -239
- package/tests/extraction/extractors/customExtractor.test.ts +0 -83
- package/tests/extraction/extractors/drawingExtractor.test.ts +0 -94
- package/tests/extraction/extractors/endAttemptExtractor.test.ts +0 -188
- package/tests/extraction/extractors/extendedTextExtractor.test.ts +0 -178
- package/tests/extraction/extractors/gapMatchExtractor.test.ts +0 -318
- package/tests/extraction/extractors/graphicAssociateExtractor.test.ts +0 -260
- package/tests/extraction/extractors/graphicGapMatchExtractor.test.ts +0 -320
- package/tests/extraction/extractors/graphicOrderExtractor.test.ts +0 -223
- package/tests/extraction/extractors/hotspotExtractor.test.ts +0 -298
- package/tests/extraction/extractors/hottextExtractor.test.ts +0 -240
- package/tests/extraction/extractors/inlineChoiceExtractor.test.ts +0 -292
- package/tests/extraction/extractors/matchExtractor.test.ts +0 -241
- package/tests/extraction/extractors/mediaExtractor.test.ts +0 -295
- package/tests/extraction/extractors/orderExtractor.test.ts +0 -212
- package/tests/extraction/extractors/positionObjectExtractor.test.ts +0 -363
- package/tests/extraction/extractors/selectPointExtractor.test.ts +0 -214
- package/tests/extraction/extractors/sliderExtractor.test.ts +0 -293
- package/tests/extraction/extractors/textEntryExtractor.test.ts +0 -133
- package/tests/extraction/extractors/uploadExtractor.test.ts +0 -119
- package/tests/extraction/test-utils.ts +0 -57
- package/tests/iframe/host.test.ts +0 -145
- package/tests/iframe/protocol.test.ts +0 -42
- package/tests/performance/player-benchmarks.bench.ts +0 -191
- package/tests/security/dos-limits.test.ts +0 -56
- package/tests/security/xss-prevention.test.ts +0 -522
- package/tsconfig.json +0 -20
- package/tsconfig.svelte.json +0 -14
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @pie-qti/item-player
|
|
2
2
|
|
|
3
|
-
A modern
|
|
3
|
+
A modern assessment item player for QTI 2.2 and QTI 3.0 content, with role/view-aware rendering and optional backend scoring support.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- ✅ **21 QTI Interaction Types Supported** -
|
|
8
|
-
- ✅ **QTI
|
|
7
|
+
- ✅ **21 QTI Interaction Types Supported** - QTI standard interaction set across 2.2/3.0 naming variants
|
|
8
|
+
- ✅ **QTI Role/View Actors** - candidate, scorer, author, tutor, proctor, testConstructor
|
|
9
9
|
- ✅ **Adaptive Items** - Multi-attempt workflow with progressive feedback
|
|
10
10
|
- ✅ **Full Keyboard Accessibility** (follows WCAG 2.2 Level AA guidelines)
|
|
11
11
|
- ✅ **Client-Side Response Processing** with 45/45 QTI operators
|
|
@@ -37,7 +37,7 @@ import { Player } from '@pie-qti/item-player';
|
|
|
37
37
|
const qtiXml = `<assessmentItem ...>...</assessmentItem>`;
|
|
38
38
|
const player = new Player({
|
|
39
39
|
itemXml: qtiXml,
|
|
40
|
-
role: 'candidate' // QTI
|
|
40
|
+
role: 'candidate' // QTI role/view actor
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// Get interactions
|
|
@@ -60,18 +60,19 @@ For deployments that need stronger isolation for **untrusted** QTI, you can run
|
|
|
60
60
|
- Docs: `docs/iframe-mode.md`
|
|
61
61
|
- Import: `@pie-qti/item-player/iframe` (browser-only)
|
|
62
62
|
|
|
63
|
-
## QTI
|
|
63
|
+
## QTI Role/View Actors
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
QTI roles are primarily audience markers for `view`-controlled content (for example rubric visibility).
|
|
66
|
+
This player applies the following runtime behavior policy on top of that:
|
|
66
67
|
|
|
67
68
|
| Role | Behavior |
|
|
68
69
|
|------|----------|
|
|
69
70
|
| `candidate` | Test-taker - inputs editable, no correct answers shown |
|
|
70
|
-
| `scorer` | Grader - inputs readonly, correct answers shown |
|
|
71
|
-
| `author` | Content
|
|
72
|
-
| `tutor` | Instructional
|
|
73
|
-
| `proctor` | Test
|
|
74
|
-
| `testConstructor` | Test
|
|
71
|
+
| `scorer` | Grader/reviewer - inputs readonly, correct answers shown |
|
|
72
|
+
| `author` | Content authoring review - inputs readonly, correct answers shown |
|
|
73
|
+
| `tutor` | Instructional review - inputs readonly, correct answers shown |
|
|
74
|
+
| `proctor` | Test administration view - inputs readonly, no correct answers shown |
|
|
75
|
+
| `testConstructor` | Test construction review - inputs readonly, correct answers shown |
|
|
75
76
|
|
|
76
77
|
### Role-Based Rendering
|
|
77
78
|
|
|
@@ -116,9 +117,10 @@ const player = new Player({
|
|
|
116
117
|
|
|
117
118
|
## QTI Version Support
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
The player supports **QTI 3.0** and **QTI 2.2**, with compatibility support for QTI 2.0/2.1 content:
|
|
120
121
|
|
|
121
|
-
- **QTI
|
|
122
|
+
- **QTI 3.0**: Supported (kebab-case `qti-` element/attribute forms)
|
|
123
|
+
- **QTI 2.2**: Full support (recommended baseline for legacy 2.x ecosystems)
|
|
122
124
|
- **QTI 2.1**: Supported with CC2 template aliases (`cc2_match`, `cc2_map_response`, etc.)
|
|
123
125
|
- **QTI 2.0**: Limited support - core interactions work, but some features may be unsupported
|
|
124
126
|
|
|
@@ -129,24 +131,24 @@ The player automatically detects QTI version from:
|
|
|
129
131
|
1. Namespace URI (`xmlns="http://www.imsglobal.org/xsd/imsqti_v2pX"`)
|
|
130
132
|
2. Version attribute (`<assessmentItem version="2.X">`)
|
|
131
133
|
|
|
132
|
-
Warnings are logged for
|
|
134
|
+
Warnings are logged for legacy versions or when version cannot be detected.
|
|
133
135
|
|
|
134
136
|
### Template Processing
|
|
135
137
|
|
|
136
138
|
Response processing templates are namespace-agnostic. The player supports:
|
|
137
139
|
|
|
138
|
-
- Standard
|
|
140
|
+
- Standard templates: `match_correct`, `map_response`, etc.
|
|
139
141
|
- QTI 2.1 CC2 aliases: `cc2_match`, `cc2_map_response`, etc.
|
|
140
142
|
|
|
141
143
|
### Strict Compliance Mode
|
|
142
144
|
|
|
143
|
-
For strict QTI 2.2 validation, enable strict compliance:
|
|
145
|
+
For strict QTI 2.2 validation (legacy interoperability mode), enable strict compliance:
|
|
144
146
|
|
|
145
147
|
```typescript
|
|
146
148
|
const player = new Player({
|
|
147
149
|
itemXml: qtiXml,
|
|
148
150
|
strictQtiCompliance: {
|
|
149
|
-
enabled: true, // Enable strict QTI 2.2 validation
|
|
151
|
+
enabled: true, // Enable strict QTI 2.2 validation mode
|
|
150
152
|
rejectUnknownExtensions: true, // Throw errors on non-2.2 versions
|
|
151
153
|
logDeviations: true // Log warnings for spec deviations
|
|
152
154
|
}
|
|
@@ -452,7 +454,7 @@ ISC
|
|
|
452
454
|
|
|
453
455
|
- [@pie-qti/assessment-player](../assessment-player) - Multi-item test player
|
|
454
456
|
- [@pie-qti/player-elements](../player-elements) - Web components
|
|
455
|
-
- [@pie-qti/
|
|
457
|
+
- [@pie-qti/app-demo](../../apps/demo) - Demo application
|
|
456
458
|
- [@pie-qti/to-pie](../to-pie) - QTI to PIE transformer
|
|
457
459
|
|
|
458
460
|
## Contributing
|
|
@@ -461,6 +463,7 @@ Contributions are welcome! Please read our contributing guidelines and submit pu
|
|
|
461
463
|
|
|
462
464
|
## Resources
|
|
463
465
|
|
|
464
|
-
- [QTI
|
|
466
|
+
- [QTI 3.0 Specification](https://www.imsglobal.org/spec/qti/v3p0/)
|
|
467
|
+
- [QTI 2.2.2 Final](https://www.imsglobal.org/content/question-and-test-interoperability-v222-final)
|
|
465
468
|
- [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
|
|
466
469
|
- [PIE Framework](https://github.com/pie-framework)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Player } from '../core/Player.js';
|
|
2
|
+
/**
|
|
3
|
+
* Inject glossary/keyword-translation trigger buttons into a rendered item container.
|
|
4
|
+
*
|
|
5
|
+
* When pnp.content.glossaryOnScreen is true, each [data-catalog-idref] element gets a
|
|
6
|
+
* trigger button. Clicking the button looks up the catalog entry and shows a floating
|
|
7
|
+
* popup rendered by the 'catalogPopup' component from the registry (defaults to
|
|
8
|
+
* pie-qti-catalog-popup). Clicking again or pressing Escape closes it.
|
|
9
|
+
*
|
|
10
|
+
* For platform-level usages (tts-pronunciation, signing-definition, braille-text,
|
|
11
|
+
* audio-description) the player fires a `qti-catalog-lookup` CustomEvent instead of
|
|
12
|
+
* mounting a popup — the host application handles those usages.
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyGlossaryTriggers(container: HTMLElement, player: Player): void;
|
|
15
|
+
//# sourceMappingURL=applyGlossaryTriggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyGlossaryTriggers.d.ts","sourceRoot":"","sources":["../../src/catalog/applyGlossaryTriggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAiFlF"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
const PLATFORM_USAGES = new Set(['tts-pronunciation', 'signing-definition', 'braille-text', 'audio-description']);
|
|
2
|
+
/**
|
|
3
|
+
* Inject glossary/keyword-translation trigger buttons into a rendered item container.
|
|
4
|
+
*
|
|
5
|
+
* When pnp.content.glossaryOnScreen is true, each [data-catalog-idref] element gets a
|
|
6
|
+
* trigger button. Clicking the button looks up the catalog entry and shows a floating
|
|
7
|
+
* popup rendered by the 'catalogPopup' component from the registry (defaults to
|
|
8
|
+
* pie-qti-catalog-popup). Clicking again or pressing Escape closes it.
|
|
9
|
+
*
|
|
10
|
+
* For platform-level usages (tts-pronunciation, signing-definition, braille-text,
|
|
11
|
+
* audio-description) the player fires a `qti-catalog-lookup` CustomEvent instead of
|
|
12
|
+
* mounting a popup — the host application handles those usages.
|
|
13
|
+
*/
|
|
14
|
+
export function applyGlossaryTriggers(container, player) {
|
|
15
|
+
const pnp = player.getPnp();
|
|
16
|
+
if (!pnp)
|
|
17
|
+
return;
|
|
18
|
+
const glossaryOn = pnp.content?.glossaryOnScreen === true;
|
|
19
|
+
const kwTranslation = pnp.content?.keywordTranslation;
|
|
20
|
+
const kwOn = kwTranslation?.active === true && !!kwTranslation.languageCode;
|
|
21
|
+
if (!glossaryOn && !kwOn)
|
|
22
|
+
return;
|
|
23
|
+
const terms = container.querySelectorAll('[data-catalog-idref]');
|
|
24
|
+
if (terms.length === 0)
|
|
25
|
+
return;
|
|
26
|
+
// Track open popup so only one is open at a time
|
|
27
|
+
let currentCleanup = null;
|
|
28
|
+
for (const termEl of Array.from(terms)) {
|
|
29
|
+
const idref = termEl.getAttribute('data-catalog-idref');
|
|
30
|
+
if (!idref)
|
|
31
|
+
continue;
|
|
32
|
+
// Wrap term in a relative-positioned span so we can position popup against it
|
|
33
|
+
const wrapper = document.createElement('span');
|
|
34
|
+
wrapper.className = 'qti-catalog-term';
|
|
35
|
+
wrapper.style.cssText = 'position:relative;display:inline';
|
|
36
|
+
termEl.parentNode?.insertBefore(wrapper, termEl);
|
|
37
|
+
wrapper.appendChild(termEl);
|
|
38
|
+
if (glossaryOn) {
|
|
39
|
+
const btn = createTriggerButton(termEl.textContent ?? idref, 'glossary-on-screen');
|
|
40
|
+
wrapper.appendChild(btn);
|
|
41
|
+
btn.addEventListener('click', () => {
|
|
42
|
+
if (currentCleanup) {
|
|
43
|
+
currentCleanup();
|
|
44
|
+
currentCleanup = null;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const html = player.getCatalogEntry(idref, 'glossary-on-screen');
|
|
48
|
+
if (html !== null) {
|
|
49
|
+
currentCleanup = mountPopup(wrapper, termEl.textContent ?? idref, html, btn, player, () => {
|
|
50
|
+
currentCleanup = null;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (kwOn) {
|
|
56
|
+
const lang = kwTranslation.languageCode;
|
|
57
|
+
const btn = createTriggerButton(termEl.textContent ?? idref, 'keyword-translation');
|
|
58
|
+
wrapper.appendChild(btn);
|
|
59
|
+
btn.addEventListener('click', () => {
|
|
60
|
+
if (currentCleanup) {
|
|
61
|
+
currentCleanup();
|
|
62
|
+
currentCleanup = null;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const html = player.getCatalogEntry(idref, 'keyword-translation', lang);
|
|
66
|
+
if (html !== null) {
|
|
67
|
+
currentCleanup = mountPopup(wrapper, termEl.textContent ?? idref, html, btn, player, () => {
|
|
68
|
+
currentCleanup = null;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Platform-level usages: fire event, no popup
|
|
74
|
+
for (const usage of PLATFORM_USAGES) {
|
|
75
|
+
const html = player.getCatalogEntry(idref, usage);
|
|
76
|
+
if (html !== null) {
|
|
77
|
+
termEl.dispatchEvent(new CustomEvent('qti-catalog-lookup', {
|
|
78
|
+
bubbles: true,
|
|
79
|
+
composed: true,
|
|
80
|
+
detail: { idref, usage, html },
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function createTriggerButton(termText, usage) {
|
|
87
|
+
const btn = document.createElement('button');
|
|
88
|
+
btn.type = 'button';
|
|
89
|
+
btn.className = 'qti-catalog-trigger';
|
|
90
|
+
btn.setAttribute('aria-label', `Show definition: ${termText}`);
|
|
91
|
+
btn.setAttribute('data-catalog-usage', usage);
|
|
92
|
+
btn.textContent = usage === 'keyword-translation' ? 'T' : '?';
|
|
93
|
+
return btn;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Mount a catalog popup via the component registry. Falls back to a minimal
|
|
97
|
+
* vanilla-JS popup if no 'catalogPopup' component is registered (e.g. in tests
|
|
98
|
+
* that don't load default-components). Returns a cleanup function.
|
|
99
|
+
*/
|
|
100
|
+
function mountPopup(anchor, label, html, triggerBtn, player, onClose) {
|
|
101
|
+
const registry = player.getComponentRegistry();
|
|
102
|
+
let popupEl;
|
|
103
|
+
const catalogPopupTag = registry.getTagNameForType('catalogPopup');
|
|
104
|
+
if (catalogPopupTag !== null) {
|
|
105
|
+
const el = document.createElement(catalogPopupTag);
|
|
106
|
+
el.content = html;
|
|
107
|
+
el.label = label;
|
|
108
|
+
el.onClose = cleanup;
|
|
109
|
+
anchor.appendChild(el);
|
|
110
|
+
popupEl = el;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// Minimal fallback for environments without default-components
|
|
114
|
+
popupEl = buildFallbackPopup(label, html);
|
|
115
|
+
anchor.appendChild(popupEl);
|
|
116
|
+
}
|
|
117
|
+
function cleanup() {
|
|
118
|
+
popupEl.remove();
|
|
119
|
+
triggerBtn.focus();
|
|
120
|
+
onClose();
|
|
121
|
+
}
|
|
122
|
+
return cleanup;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Minimal accessible fallback popup used when no catalogPopup component is registered.
|
|
126
|
+
* Uses DaisyUI card classes where available; degrades gracefully without them.
|
|
127
|
+
*/
|
|
128
|
+
function buildFallbackPopup(label, html) {
|
|
129
|
+
const popup = document.createElement('div');
|
|
130
|
+
popup.className = 'card card-bordered bg-base-100 shadow-lg qti-catalog-popup';
|
|
131
|
+
popup.setAttribute('role', 'dialog');
|
|
132
|
+
popup.setAttribute('aria-label', label);
|
|
133
|
+
popup.setAttribute('aria-modal', 'true');
|
|
134
|
+
popup.style.cssText = 'position:absolute;z-index:1000;min-width:16rem;max-width:24rem';
|
|
135
|
+
const header = document.createElement('div');
|
|
136
|
+
header.className = 'card-title flex justify-between items-center px-3 py-2 border-b border-base-300 bg-base-200';
|
|
137
|
+
const title = document.createElement('span');
|
|
138
|
+
title.className = 'text-sm font-semibold';
|
|
139
|
+
title.textContent = label;
|
|
140
|
+
const closeBtn = document.createElement('button');
|
|
141
|
+
closeBtn.type = 'button';
|
|
142
|
+
closeBtn.className = 'btn btn-ghost btn-xs';
|
|
143
|
+
closeBtn.setAttribute('aria-label', 'Close');
|
|
144
|
+
closeBtn.textContent = '✕';
|
|
145
|
+
header.appendChild(title);
|
|
146
|
+
header.appendChild(closeBtn);
|
|
147
|
+
const body = document.createElement('div');
|
|
148
|
+
body.className = 'card-body p-3';
|
|
149
|
+
const isUrl = /^(https?:\/\/|\/)/i.test(html.trim());
|
|
150
|
+
if (isUrl) {
|
|
151
|
+
const img = document.createElement('img');
|
|
152
|
+
img.src = html.trim();
|
|
153
|
+
img.alt = label;
|
|
154
|
+
img.className = 'max-w-full h-auto block mx-auto';
|
|
155
|
+
body.appendChild(img);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
body.innerHTML = html;
|
|
159
|
+
}
|
|
160
|
+
popup.appendChild(header);
|
|
161
|
+
popup.appendChild(body);
|
|
162
|
+
// Focus trap + Escape
|
|
163
|
+
const focusableSelector = 'a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
164
|
+
function handleKeyDown(e) {
|
|
165
|
+
if (e.key === 'Escape') {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
closeBtn.click();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (e.key === 'Tab') {
|
|
171
|
+
const focusable = Array.from(popup.querySelectorAll(focusableSelector)).filter((el) => el.offsetParent !== null);
|
|
172
|
+
if (focusable.length === 0) {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const first = focusable[0];
|
|
177
|
+
const last = focusable[focusable.length - 1];
|
|
178
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
last.focus();
|
|
181
|
+
}
|
|
182
|
+
else if (!e.shiftKey && document.activeElement === last) {
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
first.focus();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
popup.addEventListener('keydown', handleKeyDown);
|
|
189
|
+
closeBtn.addEventListener('click', () => popup.remove());
|
|
190
|
+
// Move focus in on next tick
|
|
191
|
+
setTimeout(() => closeBtn.focus(), 0);
|
|
192
|
+
return popup;
|
|
193
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CatalogIndex } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse an XML string containing a QTI 3.0 <qti-catalog-info> element into a CatalogIndex.
|
|
4
|
+
*
|
|
5
|
+
* The mapper is not needed here because we parse the QTI 3.0 element names directly.
|
|
6
|
+
* All element names use lower-case matching (node-html-parser normalises tags).
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractCatalog(xml: string): CatalogIndex;
|
|
9
|
+
/**
|
|
10
|
+
* Parse a raw QTI item XML string and extract the embedded catalog.
|
|
11
|
+
* Used by Player when integrating with the full item XML.
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractCatalogFromItemXml(itemXml: string): CatalogIndex;
|
|
14
|
+
/**
|
|
15
|
+
* Merge two CatalogIndex maps. itemLevel entries win on collision (same identifier).
|
|
16
|
+
*/
|
|
17
|
+
export declare function mergeCatalogs(base: CatalogIndex, override: CatalogIndex): CatalogIndex;
|
|
18
|
+
//# sourceMappingURL=catalogExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogExtractor.d.ts","sourceRoot":"","sources":["../../src/catalog/catalogExtractor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAUxD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAKvE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,GAAG,YAAY,CAMtF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { parse as parseHtml } from 'node-html-parser';
|
|
2
|
+
/**
|
|
3
|
+
* Parse an XML string containing a QTI 3.0 <qti-catalog-info> element into a CatalogIndex.
|
|
4
|
+
*
|
|
5
|
+
* The mapper is not needed here because we parse the QTI 3.0 element names directly.
|
|
6
|
+
* All element names use lower-case matching (node-html-parser normalises tags).
|
|
7
|
+
*/
|
|
8
|
+
export function extractCatalog(xml) {
|
|
9
|
+
if (!xml.trim())
|
|
10
|
+
return new Map();
|
|
11
|
+
const doc = parseHtml(`<root>${xml}</root>`, { lowerCaseTagName: true });
|
|
12
|
+
// Find <qti-catalog-info> (QTI 3.0 kebab form)
|
|
13
|
+
const infoEl = doc.querySelector('qti-catalog-info');
|
|
14
|
+
if (!infoEl)
|
|
15
|
+
return new Map();
|
|
16
|
+
return buildIndex(infoEl);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse a raw QTI item XML string and extract the embedded catalog.
|
|
20
|
+
* Used by Player when integrating with the full item XML.
|
|
21
|
+
*/
|
|
22
|
+
export function extractCatalogFromItemXml(itemXml) {
|
|
23
|
+
const doc = parseHtml(itemXml, { lowerCaseTagName: true });
|
|
24
|
+
const infoEl = doc.querySelector('qti-catalog-info');
|
|
25
|
+
if (!infoEl)
|
|
26
|
+
return new Map();
|
|
27
|
+
return buildIndex(infoEl);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Merge two CatalogIndex maps. itemLevel entries win on collision (same identifier).
|
|
31
|
+
*/
|
|
32
|
+
export function mergeCatalogs(base, override) {
|
|
33
|
+
const merged = new Map(base);
|
|
34
|
+
for (const [id, card] of override) {
|
|
35
|
+
merged.set(id, card);
|
|
36
|
+
}
|
|
37
|
+
return merged;
|
|
38
|
+
}
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Internal
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
function buildIndex(infoEl) {
|
|
43
|
+
const index = new Map();
|
|
44
|
+
for (const catalogEl of infoEl.querySelectorAll('qti-catalog')) {
|
|
45
|
+
const identifier = catalogEl.getAttribute('id') ?? catalogEl.getAttribute('identifier');
|
|
46
|
+
if (!identifier)
|
|
47
|
+
continue;
|
|
48
|
+
const entries = [];
|
|
49
|
+
for (const cardEl of catalogEl.querySelectorAll('qti-card')) {
|
|
50
|
+
const cardUsage = cardEl.getAttribute('support') ?? cardEl.getAttribute('usage');
|
|
51
|
+
for (const entry of extractCardEntries(cardEl, cardUsage ?? undefined)) {
|
|
52
|
+
entries.push(entry);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (entries.length > 0) {
|
|
56
|
+
index.set(identifier, { entries });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const cardEl of infoEl.querySelectorAll('qti-card')) {
|
|
60
|
+
const identifier = cardEl.getAttribute('identifier');
|
|
61
|
+
if (!identifier)
|
|
62
|
+
continue;
|
|
63
|
+
const entries = extractCardEntries(cardEl);
|
|
64
|
+
if (entries.length > 0) {
|
|
65
|
+
const existing = index.get(identifier);
|
|
66
|
+
if (existing) {
|
|
67
|
+
existing.entries.push(...entries);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
index.set(identifier, { entries });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return index;
|
|
75
|
+
}
|
|
76
|
+
function extractCardEntries(cardEl, fallbackUsage) {
|
|
77
|
+
const explicitEntries = cardEl.querySelectorAll('qti-card-entry');
|
|
78
|
+
const entries = [];
|
|
79
|
+
if (explicitEntries.length > 0) {
|
|
80
|
+
for (const entryEl of explicitEntries) {
|
|
81
|
+
const usage = entryEl.getAttribute('usage') ??
|
|
82
|
+
entryEl.getAttribute('data-reading-type') ??
|
|
83
|
+
fallbackUsage;
|
|
84
|
+
if (!usage)
|
|
85
|
+
continue;
|
|
86
|
+
entries.push({
|
|
87
|
+
usage,
|
|
88
|
+
lang: getLang(entryEl),
|
|
89
|
+
html: extractHtmlContent(entryEl),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return entries;
|
|
93
|
+
}
|
|
94
|
+
if (fallbackUsage) {
|
|
95
|
+
entries.push({
|
|
96
|
+
usage: fallbackUsage,
|
|
97
|
+
lang: getLang(cardEl),
|
|
98
|
+
html: extractHtmlContent(cardEl),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return entries;
|
|
102
|
+
}
|
|
103
|
+
function getLang(el) {
|
|
104
|
+
return el.getAttribute('xml:lang') ?? el.getAttribute('xmllang') ?? el.getAttribute('lang') ?? undefined;
|
|
105
|
+
}
|
|
106
|
+
function extractHtmlContent(el) {
|
|
107
|
+
const htmlContent = el.querySelector('qti-html-content');
|
|
108
|
+
const fileHref = el.querySelector('qti-file-href');
|
|
109
|
+
if (htmlContent)
|
|
110
|
+
return htmlContent.innerHTML ?? htmlContent.text ?? '';
|
|
111
|
+
if (fileHref)
|
|
112
|
+
return fileHref.getAttribute('src') ?? fileHref.text?.trim() ?? '';
|
|
113
|
+
return '';
|
|
114
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CatalogIndex } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Look up a catalog entry by card identifier, usage type, and optional language.
|
|
4
|
+
*
|
|
5
|
+
* Language fallback order (mirrors APIP 1.0 / HTTP Accept-Language conventions):
|
|
6
|
+
* 1. Exact lang match (e.g. 'en-US')
|
|
7
|
+
* 2. Language-prefix match (e.g. 'en' matches entry with lang 'en-US')
|
|
8
|
+
* 3. Entry with no lang specified (universal fallback)
|
|
9
|
+
* 4. null — no match found
|
|
10
|
+
*
|
|
11
|
+
* @param index CatalogIndex built by extractCatalog / extractCatalogFromItemXml
|
|
12
|
+
* @param idref The data-catalog-idref value (maps to qti-card identifier)
|
|
13
|
+
* @param usage Catalog usage type (e.g. 'glossary-on-screen')
|
|
14
|
+
* @param lang Optional preferred language code (e.g. 'en-US', 'es')
|
|
15
|
+
* @returns The matched entry's html string, or null if nothing found
|
|
16
|
+
*/
|
|
17
|
+
export declare function getCatalogEntry(index: CatalogIndex, idref: string, usage: string, lang?: string): string | null;
|
|
18
|
+
//# sourceMappingURL=catalogLookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogLookup.d.ts","sourceRoot":"","sources":["../../src/catalog/catalogLookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CA8Bf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Look up a catalog entry by card identifier, usage type, and optional language.
|
|
3
|
+
*
|
|
4
|
+
* Language fallback order (mirrors APIP 1.0 / HTTP Accept-Language conventions):
|
|
5
|
+
* 1. Exact lang match (e.g. 'en-US')
|
|
6
|
+
* 2. Language-prefix match (e.g. 'en' matches entry with lang 'en-US')
|
|
7
|
+
* 3. Entry with no lang specified (universal fallback)
|
|
8
|
+
* 4. null — no match found
|
|
9
|
+
*
|
|
10
|
+
* @param index CatalogIndex built by extractCatalog / extractCatalogFromItemXml
|
|
11
|
+
* @param idref The data-catalog-idref value (maps to qti-card identifier)
|
|
12
|
+
* @param usage Catalog usage type (e.g. 'glossary-on-screen')
|
|
13
|
+
* @param lang Optional preferred language code (e.g. 'en-US', 'es')
|
|
14
|
+
* @returns The matched entry's html string, or null if nothing found
|
|
15
|
+
*/
|
|
16
|
+
export function getCatalogEntry(index, idref, usage, lang) {
|
|
17
|
+
const card = index.get(idref);
|
|
18
|
+
if (!card)
|
|
19
|
+
return null;
|
|
20
|
+
const candidates = card.entries.filter((e) => e.usage === usage);
|
|
21
|
+
if (candidates.length === 0)
|
|
22
|
+
return null;
|
|
23
|
+
// 1. Exact language match
|
|
24
|
+
if (lang) {
|
|
25
|
+
const exact = candidates.find((e) => e.lang === lang);
|
|
26
|
+
if (exact)
|
|
27
|
+
return exact.html;
|
|
28
|
+
// 2. Language-prefix match: requested lang prefix matches entry lang
|
|
29
|
+
// e.g. lang='en' matches entry.lang='en-US'
|
|
30
|
+
// e.g. lang='en-US' matches entry.lang='en' (broader fallback)
|
|
31
|
+
const prefix = lang.split('-')[0];
|
|
32
|
+
const prefixMatch = candidates.find((e) => e.lang && (e.lang === prefix || e.lang.startsWith(`${prefix}-`) || lang.startsWith(`${e.lang}-`)));
|
|
33
|
+
if (prefixMatch)
|
|
34
|
+
return prefixMatch.html;
|
|
35
|
+
}
|
|
36
|
+
// 3. No-lang fallback (entry without a lang attribute)
|
|
37
|
+
const noLang = candidates.find((e) => !e.lang);
|
|
38
|
+
if (noLang)
|
|
39
|
+
return noLang.html;
|
|
40
|
+
// 4. If we get here and there's only one candidate, return it regardless of lang
|
|
41
|
+
if (candidates.length === 1)
|
|
42
|
+
return candidates[0].html;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Player } from '../core/Player.js';
|
|
2
|
+
export interface GlossaryActionParams {
|
|
3
|
+
player: Player;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Svelte action that reactively applies glossary trigger buttons to
|
|
7
|
+
* [data-catalog-idref] elements in the rendered item body.
|
|
8
|
+
*
|
|
9
|
+
* Applied to the .qti-item-body container. When the player changes (new item
|
|
10
|
+
* loaded), Svelte calls update() after {@html} has replaced the DOM content,
|
|
11
|
+
* so the walk always runs on fresh markup.
|
|
12
|
+
*/
|
|
13
|
+
export declare function glossaryAction(node: HTMLElement, params: GlossaryActionParams): {
|
|
14
|
+
update(newParams: GlossaryActionParams): void;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=glossaryAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glossaryAction.d.ts","sourceRoot":"","sources":["../../src/catalog/glossaryAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB;sBAI1D,oBAAoB;;EAQvC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { applyGlossaryTriggers } from './applyGlossaryTriggers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Svelte action that reactively applies glossary trigger buttons to
|
|
4
|
+
* [data-catalog-idref] elements in the rendered item body.
|
|
5
|
+
*
|
|
6
|
+
* Applied to the .qti-item-body container. When the player changes (new item
|
|
7
|
+
* loaded), Svelte calls update() after {@html} has replaced the DOM content,
|
|
8
|
+
* so the walk always runs on fresh markup.
|
|
9
|
+
*/
|
|
10
|
+
export function glossaryAction(node, params) {
|
|
11
|
+
applyGlossaryTriggers(node, params.player);
|
|
12
|
+
return {
|
|
13
|
+
update(newParams) {
|
|
14
|
+
// {@html} replacement already wiped any previously injected wrappers.
|
|
15
|
+
applyGlossaryTriggers(node, newParams.player);
|
|
16
|
+
},
|
|
17
|
+
destroy() {
|
|
18
|
+
// Node is being removed from DOM — no cleanup needed.
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QTI 3.0 §6.3 Catalog types.
|
|
3
|
+
* A CatalogIndex maps card identifiers to their CatalogCard.
|
|
4
|
+
* Cards hold multiple CatalogEntry records, one per usage/language combination.
|
|
5
|
+
*/
|
|
6
|
+
export type CatalogIndex = Map<string, CatalogCard>;
|
|
7
|
+
export interface CatalogCard {
|
|
8
|
+
entries: CatalogEntry[];
|
|
9
|
+
}
|
|
10
|
+
export interface CatalogEntry {
|
|
11
|
+
/**
|
|
12
|
+
* QTI 3.0 catalog usage type.
|
|
13
|
+
* The 8 standard types are listed below; additional string values are accepted
|
|
14
|
+
* for forward-compatibility and host-defined extensions.
|
|
15
|
+
*/
|
|
16
|
+
usage: 'glossary-on-screen' | 'keyword-translation' | 'illustrated-glossary' | 'tts-pronunciation' | 'signing-definition' | 'braille-text' | 'audio-description' | 'extended-description' | string;
|
|
17
|
+
/** xml:lang value (e.g. 'en-US', 'es'). Undefined when no language is specified. */
|
|
18
|
+
lang?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Inner HTML from <qti-html-content>, or the src URL from <qti-file-href>.
|
|
21
|
+
* For illustrated-glossary entries the player checks whether this looks like a URL
|
|
22
|
+
* and renders an <img> instead of innerHTML.
|
|
23
|
+
*/
|
|
24
|
+
html: string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/catalog/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC5B;;;;OAIG;IACH,KAAK,EACF,oBAAoB,GACpB,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,GACnB,oBAAoB,GACpB,cAAc,GACd,mBAAmB,GACnB,sBAAsB,GACtB,MAAM,CAAC;IACV,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface TypesetActionParams {
|
|
2
|
+
/**
|
|
3
|
+
* Typeset function provided by the host app (KaTeX, MathJax, etc).
|
|
4
|
+
* It should be idempotent or at least safe to call repeatedly on updates.
|
|
5
|
+
* Optional - if not provided, the action is a no-op.
|
|
6
|
+
*/
|
|
7
|
+
typeset?: (root: HTMLElement) => void | Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Observe subtree changes and re-typeset automatically.
|
|
10
|
+
* Default: true
|
|
11
|
+
*/
|
|
12
|
+
observe?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generic Svelte action that calls `params.typeset(node)` initially and on DOM updates.
|
|
16
|
+
*
|
|
17
|
+
* This is intentionally dependency-free so the player/components can be used
|
|
18
|
+
* outside the example app without pulling in a math engine.
|
|
19
|
+
*/
|
|
20
|
+
export declare function typesetAction(node: HTMLElement, params: TypesetActionParams): {
|
|
21
|
+
update(next: TypesetActionParams): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=typesetAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typesetAction.d.ts","sourceRoot":"","sources":["../../../src/components/actions/typesetAction.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,mBAAmB;iBAuC7D,mBAAmB;;EAWjC"}
|