@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/src/element.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pie-qti-item-player custom element.
|
|
3
|
+
*
|
|
4
|
+
* Side-effect import that registers <pie-qti-item-player>:
|
|
5
|
+
* import '@pie-qti/item-player/element';
|
|
6
|
+
*
|
|
7
|
+
* String/boolean props map to HTML attributes (item-xml, role, disabled).
|
|
8
|
+
* Complex props (typeset, i18n, security, onResponseChange, onSubmit, onComplete)
|
|
9
|
+
* are JS-only properties — set them on the element instance directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { mount, unmount } from 'svelte';
|
|
13
|
+
import ItemPlayer from './components/ItemPlayer.svelte';
|
|
14
|
+
import type { AdaptiveAttemptResult, PlayerSecurityConfig, QTIRole } from './types/index.js';
|
|
15
|
+
import type { I18nProvider } from '@pie-qti/i18n';
|
|
16
|
+
|
|
17
|
+
const TAG = 'pie-qti-item-player';
|
|
18
|
+
|
|
19
|
+
class PieQtiItemPlayerElement extends HTMLElement {
|
|
20
|
+
static observedAttributes = ['item-xml', 'role', 'disabled'];
|
|
21
|
+
|
|
22
|
+
#container: HTMLDivElement | null = null;
|
|
23
|
+
#instance: any = null;
|
|
24
|
+
|
|
25
|
+
// Attribute-backed props
|
|
26
|
+
#itemXml = '';
|
|
27
|
+
#role: QTIRole = 'candidate';
|
|
28
|
+
#disabled = false;
|
|
29
|
+
|
|
30
|
+
// JS-only props
|
|
31
|
+
#typeset: ((el: HTMLElement) => void) | undefined;
|
|
32
|
+
#i18n: I18nProvider | undefined;
|
|
33
|
+
#security: PlayerSecurityConfig | undefined;
|
|
34
|
+
#onResponseChange: ((id: string, value: unknown) => void) | undefined;
|
|
35
|
+
#onSubmit: ((responses: Record<string, unknown>, result: unknown) => void) | undefined;
|
|
36
|
+
#onComplete: ((result: AdaptiveAttemptResult) => void) | undefined;
|
|
37
|
+
|
|
38
|
+
// --- JS-only property accessors ---
|
|
39
|
+
|
|
40
|
+
get typeset() { return this.#typeset; }
|
|
41
|
+
set typeset(v: ((el: HTMLElement) => void) | undefined) { this.#typeset = v; this.#update(); }
|
|
42
|
+
|
|
43
|
+
get i18n() { return this.#i18n; }
|
|
44
|
+
set i18n(v: I18nProvider | undefined) { this.#i18n = v; this.#update(); }
|
|
45
|
+
|
|
46
|
+
get security() { return this.#security; }
|
|
47
|
+
set security(v: PlayerSecurityConfig | undefined) { this.#security = v; this.#update(); }
|
|
48
|
+
|
|
49
|
+
get onResponseChange() { return this.#onResponseChange; }
|
|
50
|
+
set onResponseChange(v: ((id: string, value: unknown) => void) | undefined) { this.#onResponseChange = v; this.#update(); }
|
|
51
|
+
|
|
52
|
+
get onSubmit() { return this.#onSubmit; }
|
|
53
|
+
set onSubmit(v: ((responses: Record<string, unknown>, result: unknown) => void) | undefined) { this.#onSubmit = v; this.#update(); }
|
|
54
|
+
|
|
55
|
+
get onComplete() { return this.#onComplete; }
|
|
56
|
+
set onComplete(v: ((result: AdaptiveAttemptResult) => void) | undefined) { this.#onComplete = v; this.#update(); }
|
|
57
|
+
|
|
58
|
+
// --- Lifecycle ---
|
|
59
|
+
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
this.#mount();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
disconnectedCallback() {
|
|
65
|
+
this.#teardown();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null) {
|
|
69
|
+
if (name === 'item-xml') this.#itemXml = value ?? '';
|
|
70
|
+
else if (name === 'role') this.#role = (value ?? 'candidate') as QTIRole;
|
|
71
|
+
else if (name === 'disabled') this.#disabled = value !== null;
|
|
72
|
+
this.#update();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// --- Private helpers ---
|
|
76
|
+
|
|
77
|
+
#getProps() {
|
|
78
|
+
return {
|
|
79
|
+
itemXml: this.#itemXml,
|
|
80
|
+
role: this.#role,
|
|
81
|
+
disabled: this.#disabled,
|
|
82
|
+
typeset: this.#typeset,
|
|
83
|
+
i18n: this.#i18n,
|
|
84
|
+
security: this.#security,
|
|
85
|
+
onResponseChange: this.#onResponseChange,
|
|
86
|
+
onSubmit: this.#onSubmit,
|
|
87
|
+
onComplete: this.#onComplete,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#mount() {
|
|
92
|
+
if (this.#instance) return;
|
|
93
|
+
if (!this.#container) {
|
|
94
|
+
this.#container = document.createElement('div');
|
|
95
|
+
this.#container.style.display = 'contents';
|
|
96
|
+
this.appendChild(this.#container);
|
|
97
|
+
}
|
|
98
|
+
this.#instance = mount(ItemPlayer, { target: this.#container, props: this.#getProps() });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#update() {
|
|
102
|
+
if (!this.#instance) return;
|
|
103
|
+
if (typeof this.#instance.$set === 'function') {
|
|
104
|
+
this.#instance.$set(this.#getProps());
|
|
105
|
+
} else {
|
|
106
|
+
// Svelte 5 runes components: remount with new props
|
|
107
|
+
this.#teardown();
|
|
108
|
+
this.#mount();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#teardown() {
|
|
113
|
+
if (this.#instance) {
|
|
114
|
+
try { unmount(this.#instance); } catch { /* ignore */ }
|
|
115
|
+
this.#instance = null;
|
|
116
|
+
}
|
|
117
|
+
if (this.#container) {
|
|
118
|
+
this.#container.remove();
|
|
119
|
+
this.#container = null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!customElements.get(TAG)) {
|
|
125
|
+
customElements.define(TAG, PieQtiItemPlayerElement);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { PieQtiItemPlayerElement };
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
import type { MathfieldElement } from 'mathlive';
|
|
11
11
|
import type { I18nProvider } from '@pie-qti/i18n';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// Import MathLive CSS from the local package
|
|
14
|
+
import 'mathlive/mathlive-static.css';
|
|
15
|
+
|
|
16
|
+
const DEFAULT_MATHLIVE_CSS_URL = ''; // No longer needed - CSS is imported above
|
|
14
17
|
|
|
15
18
|
// Dynamically import MathLive to register the custom element
|
|
16
19
|
let mathLiveLoaded: Promise<void> | null = null;
|
|
@@ -21,8 +24,8 @@ async function ensureMathLiveLoaded(cssUrl: string = DEFAULT_MATHLIVE_CSS_URL):
|
|
|
21
24
|
// Import MathLive to register the <math-field> custom element
|
|
22
25
|
await import('mathlive');
|
|
23
26
|
|
|
24
|
-
//
|
|
25
|
-
if (!document.querySelector('link[href*="mathlive"]')) {
|
|
27
|
+
// CSS is already imported at the top of this file, but allow custom URL if provided
|
|
28
|
+
if (cssUrl && !document.querySelector('link[href*="mathlive"]')) {
|
|
26
29
|
const link = document.createElement('link');
|
|
27
30
|
link.rel = 'stylesheet';
|
|
28
31
|
link.href = cssUrl;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - Validation and error handling
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { Qti2xElementNameMapper, type ElementNameMapper } from '@pie-qti/qti-common';
|
|
11
12
|
import type { QTIElement } from '../types/interactions.js';
|
|
12
13
|
import type {
|
|
13
14
|
ElementExtractor,
|
|
@@ -30,6 +31,16 @@ export class ExtractionRegistry {
|
|
|
30
31
|
/** Cache for element -> extractor lookups (WeakMap for automatic GC) */
|
|
31
32
|
private extractorCache = new WeakMap<QTIElement, ElementExtractor>();
|
|
32
33
|
|
|
34
|
+
/** Optional element name mapper for QTI version handling */
|
|
35
|
+
private elementNameMapper?: ElementNameMapper;
|
|
36
|
+
|
|
37
|
+
/** QTI 2.x mapper for converting canonical names to extractor registry keys */
|
|
38
|
+
private qti2xMapper = new Qti2xElementNameMapper();
|
|
39
|
+
|
|
40
|
+
constructor(elementNameMapper?: ElementNameMapper) {
|
|
41
|
+
this.elementNameMapper = elementNameMapper;
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
/**
|
|
34
45
|
* Register an extractor with the registry
|
|
35
46
|
*
|
|
@@ -76,11 +87,16 @@ export class ExtractionRegistry {
|
|
|
76
87
|
this.extractorsById.set(extractor.id, extractor as ElementExtractor);
|
|
77
88
|
|
|
78
89
|
// Register by type for fast lookup
|
|
90
|
+
// Normalize element types to canonical (lowercase) form for version-agnostic lookup
|
|
79
91
|
for (const type of extractor.elementTypes) {
|
|
80
|
-
|
|
92
|
+
// Convert to canonical form - extractors specify QTI 2.x names (e.g., 'choiceInteraction')
|
|
93
|
+
// but we store them in canonical form (e.g., 'choiceinteraction') for QTI version independence
|
|
94
|
+
const canonicalType = this.qti2xMapper.toCanonical(type);
|
|
95
|
+
|
|
96
|
+
let extractors = this.extractorsByType.get(canonicalType);
|
|
81
97
|
if (!extractors) {
|
|
82
98
|
extractors = [];
|
|
83
|
-
this.extractorsByType.set(
|
|
99
|
+
this.extractorsByType.set(canonicalType, extractors);
|
|
84
100
|
}
|
|
85
101
|
|
|
86
102
|
extractors.push(extractor as ElementExtractor);
|
|
@@ -103,9 +119,10 @@ export class ExtractionRegistry {
|
|
|
103
119
|
// Remove from ID map
|
|
104
120
|
this.extractorsById.delete(id);
|
|
105
121
|
|
|
106
|
-
// Remove from type maps
|
|
122
|
+
// Remove from type maps (using canonical form)
|
|
107
123
|
for (const type of extractor.elementTypes) {
|
|
108
|
-
const
|
|
124
|
+
const canonicalType = this.qti2xMapper.toCanonical(type);
|
|
125
|
+
const extractors = this.extractorsByType.get(canonicalType);
|
|
109
126
|
if (extractors) {
|
|
110
127
|
const index = extractors.findIndex((e) => e.id === id);
|
|
111
128
|
if (index !== -1) {
|
|
@@ -113,7 +130,7 @@ export class ExtractionRegistry {
|
|
|
113
130
|
}
|
|
114
131
|
// Clean up empty arrays
|
|
115
132
|
if (extractors.length === 0) {
|
|
116
|
-
this.extractorsByType.delete(
|
|
133
|
+
this.extractorsByType.delete(canonicalType);
|
|
117
134
|
}
|
|
118
135
|
}
|
|
119
136
|
}
|
|
@@ -137,8 +154,24 @@ export class ExtractionRegistry {
|
|
|
137
154
|
const cached = this.extractorCache.get(element);
|
|
138
155
|
if (cached) return cached;
|
|
139
156
|
|
|
157
|
+
// Get element type - normalize using mapper for QTI version handling
|
|
158
|
+
// Extractors are registered in canonical (lowercase) form for version independence.
|
|
159
|
+
// Convert any QTI version element name to canonical form for lookup.
|
|
160
|
+
//
|
|
161
|
+
// Example for QTI 3.0:
|
|
162
|
+
// 'qti-choice-interaction' → 'choiceinteraction' (canonical)
|
|
163
|
+
// Example for QTI 2.x:
|
|
164
|
+
// 'choiceInteraction' → 'choiceinteraction' (canonical)
|
|
165
|
+
let lookupKey = element.rawTagName || '';
|
|
166
|
+
const originalKey = lookupKey;
|
|
167
|
+
|
|
168
|
+
if (lookupKey && this.elementNameMapper) {
|
|
169
|
+
// Convert element's raw tag to canonical form using the document's mapper
|
|
170
|
+
lookupKey = this.elementNameMapper.toCanonical(lookupKey);
|
|
171
|
+
}
|
|
172
|
+
|
|
140
173
|
// Get extractors for this element type (O(1) map lookup)
|
|
141
|
-
const extractors = this.extractorsByType.get(
|
|
174
|
+
const extractors = this.extractorsByType.get(lookupKey);
|
|
142
175
|
if (!extractors || extractors.length === 0) {
|
|
143
176
|
return null;
|
|
144
177
|
}
|
|
@@ -146,7 +179,11 @@ export class ExtractionRegistry {
|
|
|
146
179
|
// Evaluate canHandle in priority order (O(M) where M = extractors for this type)
|
|
147
180
|
for (const extractor of extractors) {
|
|
148
181
|
try {
|
|
149
|
-
|
|
182
|
+
const canHandle = extractor.canHandle(element, context);
|
|
183
|
+
const typeMatchedThroughMapper = !!this.elementNameMapper && extractor.elementTypes.some(
|
|
184
|
+
(type) => this.qti2xMapper.toCanonical(type) === lookupKey
|
|
185
|
+
);
|
|
186
|
+
if (canHandle || typeMatchedThroughMapper) {
|
|
150
187
|
// Cache the result
|
|
151
188
|
this.extractorCache.set(element, extractor);
|
|
152
189
|
return extractor;
|
|
@@ -252,7 +289,9 @@ export class ExtractionRegistry {
|
|
|
252
289
|
* @returns Read-only array of extractors for this type, sorted by priority
|
|
253
290
|
*/
|
|
254
291
|
getExtractorsForType(elementType: string): ReadonlyArray<ElementExtractor> {
|
|
255
|
-
|
|
292
|
+
// Convert to canonical form for lookup
|
|
293
|
+
const canonicalType = this.qti2xMapper.toCanonical(elementType);
|
|
294
|
+
return this.extractorsByType.get(canonicalType) || [];
|
|
256
295
|
}
|
|
257
296
|
|
|
258
297
|
/**
|
|
@@ -278,7 +317,7 @@ export class ExtractionRegistry {
|
|
|
278
317
|
* @returns New registry with same extractors
|
|
279
318
|
*/
|
|
280
319
|
clone(): ExtractionRegistry {
|
|
281
|
-
const cloned = new ExtractionRegistry();
|
|
320
|
+
const cloned = new ExtractionRegistry(this.elementNameMapper);
|
|
282
321
|
for (const extractor of this.extractorsById.values()) {
|
|
283
322
|
cloned.register(extractor);
|
|
284
323
|
}
|
|
@@ -288,8 +327,9 @@ export class ExtractionRegistry {
|
|
|
288
327
|
|
|
289
328
|
/**
|
|
290
329
|
* Create a new extraction registry
|
|
330
|
+
* @param elementNameMapper - Optional element name mapper for QTI version handling
|
|
291
331
|
* @returns Empty registry ready for extractor registration
|
|
292
332
|
*/
|
|
293
|
-
export function createExtractionRegistry(): ExtractionRegistry {
|
|
294
|
-
return new ExtractionRegistry();
|
|
333
|
+
export function createExtractionRegistry(elementNameMapper?: ElementNameMapper): ExtractionRegistry {
|
|
334
|
+
return new ExtractionRegistry(elementNameMapper);
|
|
295
335
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Creates ExtractionContext instances with utilities and metadata
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type { ElementNameMapper, AttributeNameMapper } from '@pie-qti/qti-common';
|
|
7
8
|
import type { PlayerConfig } from '../types/index.js';
|
|
8
9
|
import type { QTIElement } from '../types/interactions.js';
|
|
9
10
|
import type { ExtractionContext, VariableDeclaration } from './types.js';
|
|
@@ -36,12 +37,16 @@ export function createExtractionContext(
|
|
|
36
37
|
declarations: Map<string, VariableDeclaration>,
|
|
37
38
|
config: PlayerConfig
|
|
38
39
|
): ExtractionContext {
|
|
40
|
+
// Pass both element and attribute name mappers for QTI version handling
|
|
41
|
+
const elementMapper = config.elementNameMapper as ElementNameMapper | undefined;
|
|
42
|
+
const attributeMapper = config.attributeNameMapper as AttributeNameMapper | undefined;
|
|
43
|
+
|
|
39
44
|
return {
|
|
40
45
|
element,
|
|
41
46
|
responseId,
|
|
42
47
|
dom,
|
|
43
48
|
declarations,
|
|
44
|
-
utils: createExtractionUtils(config.security),
|
|
49
|
+
utils: createExtractionUtils(config.security, elementMapper, attributeMapper),
|
|
45
50
|
config,
|
|
46
51
|
};
|
|
47
52
|
}
|
|
@@ -15,6 +15,7 @@ export interface AssociateData {
|
|
|
15
15
|
text: string;
|
|
16
16
|
matchMax: number;
|
|
17
17
|
matchMin?: number;
|
|
18
|
+
matchGroup?: string[];
|
|
18
19
|
classes?: string[];
|
|
19
20
|
}>;
|
|
20
21
|
shuffle: boolean;
|
|
@@ -51,12 +52,15 @@ export const standardAssociateExtractor: ElementExtractor<AssociateData> = {
|
|
|
51
52
|
const classes = utils.getClasses(choice);
|
|
52
53
|
const matchMax = utils.getNumberAttribute(choice, 'matchMax', 1);
|
|
53
54
|
const matchMin = utils.getNumberAttribute(choice, 'matchMin', 0);
|
|
55
|
+
const matchGroupRaw = utils.getAttribute(choice, 'matchGroup', '');
|
|
56
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
54
57
|
|
|
55
58
|
return {
|
|
56
59
|
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
57
60
|
text: utils.getHtmlContent(choice),
|
|
58
61
|
matchMax,
|
|
59
62
|
...(matchMin > 0 ? { matchMin } : {}),
|
|
63
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
60
64
|
...(classes.length > 0 ? { classes } : {}),
|
|
61
65
|
};
|
|
62
66
|
});
|
|
@@ -11,9 +11,10 @@ import type { ElementExtractor, ExtractionContext } from '../types.js';
|
|
|
11
11
|
* Choice data extracted from simpleChoice elements
|
|
12
12
|
*/
|
|
13
13
|
export interface ChoiceData {
|
|
14
|
-
choices: Array<{ identifier: string; text: string; classes?: string[] }>;
|
|
14
|
+
choices: Array<{ identifier: string; text: string; fixed?: boolean; classes?: string[] }>;
|
|
15
15
|
shuffle: boolean;
|
|
16
16
|
maxChoices: number;
|
|
17
|
+
minChoices: number;
|
|
17
18
|
prompt: string | null;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -40,9 +41,11 @@ export const standardChoiceExtractor: ElementExtractor<ChoiceData> = {
|
|
|
40
41
|
const simpleChoices = utils.getChildrenByTag(element, 'simpleChoice');
|
|
41
42
|
const choices = simpleChoices.map((choice) => {
|
|
42
43
|
const classes = utils.getClasses(choice);
|
|
44
|
+
const fixed = utils.getBooleanAttribute(choice, 'fixed');
|
|
43
45
|
return {
|
|
44
46
|
identifier: utils.getAttribute(choice, 'identifier', ''),
|
|
45
47
|
text: utils.getHtmlContent(choice),
|
|
48
|
+
...(fixed ? { fixed } : {}),
|
|
46
49
|
...(classes.length > 0 ? { classes } : {}),
|
|
47
50
|
};
|
|
48
51
|
});
|
|
@@ -54,12 +57,20 @@ export const standardChoiceExtractor: ElementExtractor<ChoiceData> = {
|
|
|
54
57
|
// Extract attributes
|
|
55
58
|
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
56
59
|
const maxChoices = utils.getNumberAttribute(element, 'maxChoices', 1);
|
|
60
|
+
const minChoices = utils.getNumberAttribute(element, 'minChoices', 0);
|
|
61
|
+
const interactionClasses = utils.getClasses(element);
|
|
62
|
+
const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
|
|
63
|
+
const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
|
|
57
64
|
|
|
58
65
|
return {
|
|
59
66
|
choices,
|
|
60
67
|
shuffle,
|
|
61
68
|
maxChoices,
|
|
69
|
+
minChoices,
|
|
62
70
|
prompt,
|
|
71
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
72
|
+
...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
|
|
73
|
+
...(minSelectionsMessage ? { minSelectionsMessage } : {}),
|
|
63
74
|
};
|
|
64
75
|
},
|
|
65
76
|
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { Player } from '../../core/Player.js';
|
|
3
|
+
|
|
4
|
+
const qti3Item = (identifier: string, body: string, declarations = '') => `<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<qti-assessment-item xmlns="http://www.imsglobal.org/xsd/imsqtiasi_v3p0"
|
|
6
|
+
identifier="${identifier}" title="${identifier}" adaptive="false" time-dependent="false">
|
|
7
|
+
${declarations}
|
|
8
|
+
<qti-item-body>${body}</qti-item-body>
|
|
9
|
+
</qti-assessment-item>`;
|
|
10
|
+
|
|
11
|
+
describe('QTI 3.0 Advanced clean-room item extraction', () => {
|
|
12
|
+
it('Q6: extracts gap match selection messages and gap choices', () => {
|
|
13
|
+
const xml = qti3Item(
|
|
14
|
+
'qti3-gap-match',
|
|
15
|
+
`<qti-gap-match-interaction response-identifier="RESPONSE"
|
|
16
|
+
class="qti-choices-top"
|
|
17
|
+
data-max-selections-message="You have used all labels."
|
|
18
|
+
data-min-selections-message="Use at least one label.">
|
|
19
|
+
<qti-prompt>Complete the sentence.</qti-prompt>
|
|
20
|
+
<qti-gap-text identifier="producer" match-max="1">producer</qti-gap-text>
|
|
21
|
+
<qti-gap-text identifier="consumer" match-max="1">consumer</qti-gap-text>
|
|
22
|
+
<p>A plant is a <qti-gap identifier="gap_1"/>.</p>
|
|
23
|
+
</qti-gap-match-interaction>`,
|
|
24
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="multiple" base-type="directedPair"/>'
|
|
25
|
+
);
|
|
26
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
27
|
+
|
|
28
|
+
expect(interaction.type).toBe('gapMatchInteraction');
|
|
29
|
+
expect(interaction.interactionClasses).toContain('qti-choices-top');
|
|
30
|
+
expect(interaction.maxSelectionsMessage).toBe('You have used all labels.');
|
|
31
|
+
expect(interaction.minSelectionsMessage).toBe('Use at least one label.');
|
|
32
|
+
expect(interaction.gaps).toHaveLength(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('Q8: extracts graphic gap match choices and hotspots', () => {
|
|
36
|
+
const xml = qti3Item(
|
|
37
|
+
'qti3-graphic-gap',
|
|
38
|
+
`<qti-graphic-gap-match-interaction response-identifier="RESPONSE">
|
|
39
|
+
<qti-object data="images/food-web.svg" type="image/svg+xml" width="500" height="300">Food web</qti-object>
|
|
40
|
+
<qti-gap-text identifier="grass" match-max="1">Grass</qti-gap-text>
|
|
41
|
+
<qti-gap-img identifier="hawk" match-max="1" src="images/hawk.svg"/>
|
|
42
|
+
<qti-associable-hotspot identifier="A" match-max="1" shape="rect" coords="20,20,120,80"/>
|
|
43
|
+
<qti-associable-hotspot identifier="B" match-max="1" shape="circle" coords="350,140,32"/>
|
|
44
|
+
</qti-graphic-gap-match-interaction>`,
|
|
45
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="multiple" base-type="directedPair"/>'
|
|
46
|
+
);
|
|
47
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
48
|
+
|
|
49
|
+
expect(interaction.type).toBe('graphicGapMatchInteraction');
|
|
50
|
+
expect(interaction.imageData.src).toBe('images/food-web.svg');
|
|
51
|
+
expect(interaction.gapTexts).toHaveLength(1);
|
|
52
|
+
expect(interaction.gapImages).toHaveLength(1);
|
|
53
|
+
expect(interaction.hotspots).toHaveLength(2);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Q10: extracts hotspot shapes from QTI 3.0 element names', () => {
|
|
57
|
+
const xml = qti3Item(
|
|
58
|
+
'qti3-hotspot',
|
|
59
|
+
`<qti-hotspot-interaction response-identifier="RESPONSE" max-choices="1">
|
|
60
|
+
<qti-object data="images/water-cycle.svg" type="image/svg+xml" width="400" height="300">Water cycle</qti-object>
|
|
61
|
+
<qti-hotspot-choice identifier="evaporation" shape="circle" coords="100,200,35"/>
|
|
62
|
+
<qti-hotspot-choice identifier="condensation" shape="poly" coords="210,60,260,70,250,120,205,115"/>
|
|
63
|
+
</qti-hotspot-interaction>`,
|
|
64
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>'
|
|
65
|
+
);
|
|
66
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
67
|
+
|
|
68
|
+
expect(interaction.type).toBe('hotspotInteraction');
|
|
69
|
+
expect(interaction.maxChoices).toBe(1);
|
|
70
|
+
expect(interaction.hotspotChoices.map((h: any) => h.shape)).toEqual(['circle', 'poly']);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('Q11: extracts hottext choices from QTI 3.0 markup', () => {
|
|
74
|
+
const xml = qti3Item(
|
|
75
|
+
'qti3-hottext',
|
|
76
|
+
`<qti-hottext-interaction response-identifier="RESPONSE" max-choices="1">
|
|
77
|
+
<qti-prompt>Select the adjective.</qti-prompt>
|
|
78
|
+
<p>The <qti-hottext identifier="word_1">bright</qti-hottext> star <qti-hottext identifier="word_2">shines</qti-hottext>.</p>
|
|
79
|
+
</qti-hottext-interaction>`,
|
|
80
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>'
|
|
81
|
+
);
|
|
82
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
83
|
+
|
|
84
|
+
expect(interaction.type).toBe('hottextInteraction');
|
|
85
|
+
expect(interaction.hottextChoices.map((h: any) => h.identifier)).toEqual(['word_1', 'word_2']);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('Q12: extracts inline choices with MathML content', () => {
|
|
89
|
+
const xml = qti3Item(
|
|
90
|
+
'qti3-inline-choice',
|
|
91
|
+
`<p>The value of
|
|
92
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>2</mn><mo>+</mo><mn>3</mn></math>
|
|
93
|
+
is <qti-inline-choice-interaction response-identifier="RESPONSE">
|
|
94
|
+
<qti-inline-choice identifier="five">5</qti-inline-choice>
|
|
95
|
+
<qti-inline-choice identifier="six">6</qti-inline-choice>
|
|
96
|
+
</qti-inline-choice-interaction>.
|
|
97
|
+
</p>`,
|
|
98
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>'
|
|
99
|
+
);
|
|
100
|
+
const player = new Player({ itemXml: xml });
|
|
101
|
+
const interaction = player.getInteractionData()[0] as any;
|
|
102
|
+
|
|
103
|
+
expect(interaction.type).toBe('inlineChoiceInteraction');
|
|
104
|
+
expect(interaction.choices).toHaveLength(2);
|
|
105
|
+
expect(player.getItemBodyHtml()).toContain('<math');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('Q13: extracts tabular match shared vocabulary classes', () => {
|
|
109
|
+
const xml = qti3Item(
|
|
110
|
+
'qti3-match',
|
|
111
|
+
`<qti-match-interaction response-identifier="RESPONSE" max-associations="2"
|
|
112
|
+
class="qti-match-tabular qti-header-hidden">
|
|
113
|
+
<qti-simple-match-set>
|
|
114
|
+
<qti-simple-associable-choice identifier="herbivore" match-max="1">Herbivore</qti-simple-associable-choice>
|
|
115
|
+
<qti-simple-associable-choice identifier="carnivore" match-max="1">Carnivore</qti-simple-associable-choice>
|
|
116
|
+
</qti-simple-match-set>
|
|
117
|
+
<qti-simple-match-set>
|
|
118
|
+
<qti-simple-associable-choice identifier="eats_plants" match-max="1">Eats plants</qti-simple-associable-choice>
|
|
119
|
+
<qti-simple-associable-choice identifier="eats_animals" match-max="1">Eats animals</qti-simple-associable-choice>
|
|
120
|
+
</qti-simple-match-set>
|
|
121
|
+
</qti-match-interaction>`,
|
|
122
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="multiple" base-type="directedPair"/>'
|
|
123
|
+
);
|
|
124
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
125
|
+
|
|
126
|
+
expect(interaction.type).toBe('matchInteraction');
|
|
127
|
+
expect(interaction.interactionClasses).toContain('qti-match-tabular');
|
|
128
|
+
expect(interaction.interactionClasses).toContain('qti-header-hidden');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('I17: extracts composite QTI 3.0 items with multiple interactions', () => {
|
|
132
|
+
const xml = qti3Item(
|
|
133
|
+
'qti3-composite',
|
|
134
|
+
`<qti-choice-interaction response-identifier="CHOICE" max-choices="1">
|
|
135
|
+
<qti-simple-choice identifier="A">A</qti-simple-choice>
|
|
136
|
+
<qti-simple-choice identifier="B">B</qti-simple-choice>
|
|
137
|
+
</qti-choice-interaction>
|
|
138
|
+
<p>Short answer: <qti-text-entry-interaction response-identifier="TEXT" expected-length="12"/></p>
|
|
139
|
+
<qti-extended-text-interaction response-identifier="ESSAY" expected-lines="4"/>`,
|
|
140
|
+
`<qti-response-declaration identifier="CHOICE" cardinality="single" base-type="identifier"/>
|
|
141
|
+
<qti-response-declaration identifier="TEXT" cardinality="single" base-type="string"/>
|
|
142
|
+
<qti-response-declaration identifier="ESSAY" cardinality="single" base-type="string"/>`
|
|
143
|
+
);
|
|
144
|
+
const types = new Player({ itemXml: xml }).getInteractionData().map((i) => i.type).sort();
|
|
145
|
+
|
|
146
|
+
expect(types).toEqual(['choiceInteraction', 'extendedTextInteraction', 'textEntryInteraction']);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('QTI 3.0 Advanced clean-room content preservation', () => {
|
|
151
|
+
it('I4: preserves shared stimulus references for package-level stimulus loading', () => {
|
|
152
|
+
const xml = qti3Item(
|
|
153
|
+
'qti3-shared-stimulus',
|
|
154
|
+
`<qti-assessment-stimulus-ref identifier="stimulus_1" href="../stimuli/river-study.xml" data-stimulus-idref="stimulus_1"/>
|
|
155
|
+
<p data-stimulus-idref="stimulus_1"></p>
|
|
156
|
+
<qti-choice-interaction response-identifier="RESPONSE" max-choices="1">
|
|
157
|
+
<qti-simple-choice identifier="A">Erosion</qti-simple-choice>
|
|
158
|
+
<qti-simple-choice identifier="B">Condensation</qti-simple-choice>
|
|
159
|
+
</qti-choice-interaction>`,
|
|
160
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>'
|
|
161
|
+
);
|
|
162
|
+
const html = new Player({ itemXml: xml }).getItemBodyHtml();
|
|
163
|
+
|
|
164
|
+
expect(html).toContain('qti-assessment-stimulus-ref');
|
|
165
|
+
expect(html).toContain('data-stimulus-idref="stimulus_1"');
|
|
166
|
+
expect(html).toContain('../stimuli/river-study.xml');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('I19b/I20: preserves full Shared Vocabulary classes in item body HTML', () => {
|
|
170
|
+
const xml = qti3Item(
|
|
171
|
+
'qti3-shared-vocabulary',
|
|
172
|
+
`<div class="qti-align-center qti-fullwidth">
|
|
173
|
+
<p class="qti-underline qti-italic">Observe the emphasized vocabulary.</p>
|
|
174
|
+
</div>
|
|
175
|
+
<qti-choice-interaction response-identifier="RESPONSE" max-choices="1">
|
|
176
|
+
<qti-simple-choice identifier="A">Kept</qti-simple-choice>
|
|
177
|
+
</qti-choice-interaction>`,
|
|
178
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>'
|
|
179
|
+
);
|
|
180
|
+
const html = new Player({ itemXml: xml }).getItemBodyHtml();
|
|
181
|
+
|
|
182
|
+
expect(html).toContain('qti-underline');
|
|
183
|
+
expect(html).toContain('qti-italic');
|
|
184
|
+
expect(html).toContain('qti-align-center');
|
|
185
|
+
expect(html).toContain('qti-fullwidth');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('P7: tolerates QTI metadata while delivering item content', () => {
|
|
189
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
190
|
+
<qti-assessment-item xmlns="http://www.imsglobal.org/xsd/imsqtiasi_v3p0"
|
|
191
|
+
xmlns:lom="http://ltsc.ieee.org/xsd/LOM"
|
|
192
|
+
identifier="qti3-metadata" title="Metadata Item" adaptive="false" time-dependent="false">
|
|
193
|
+
<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>
|
|
194
|
+
<lom:lom><lom:general><lom:title><lom:string>Clean-room metadata</lom:string></lom:title></lom:general></lom:lom>
|
|
195
|
+
<qti-item-body>
|
|
196
|
+
<qti-choice-interaction response-identifier="RESPONSE" max-choices="1">
|
|
197
|
+
<qti-simple-choice identifier="A">Metadata is not candidate-visible.</qti-simple-choice>
|
|
198
|
+
</qti-choice-interaction>
|
|
199
|
+
</qti-item-body>
|
|
200
|
+
</qti-assessment-item>`;
|
|
201
|
+
const player = new Player({ itemXml: xml });
|
|
202
|
+
|
|
203
|
+
expect(player.getInteractionData()).toHaveLength(1);
|
|
204
|
+
expect(player.getItemBodyHtml()).toContain('Metadata is not candidate-visible');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('A13/A15: preserves caption tracks and glossary catalog references', () => {
|
|
208
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
209
|
+
<qti-assessment-item xmlns="http://www.imsglobal.org/xsd/imsqtiasi_v3p0"
|
|
210
|
+
identifier="qti3-captions-glossary" title="Captions and Glossary" adaptive="false" time-dependent="false">
|
|
211
|
+
<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>
|
|
212
|
+
<qti-catalog-info>
|
|
213
|
+
<qti-card identifier="word-delta">
|
|
214
|
+
<qti-card-entry usage="glossary-on-screen">
|
|
215
|
+
<qti-html-content>A landform where a river divides before entering a larger body of water.</qti-html-content>
|
|
216
|
+
</qti-card-entry>
|
|
217
|
+
</qti-card>
|
|
218
|
+
</qti-catalog-info>
|
|
219
|
+
<qti-item-body>
|
|
220
|
+
<video controls="controls" width="320">
|
|
221
|
+
<source src="media/river-delta.mp4" type="video/mp4"/>
|
|
222
|
+
<track kind="captions" srclang="en" src="media/river-delta-captions.vtt" label="English captions"/>
|
|
223
|
+
</video>
|
|
224
|
+
<p>The <span data-catalog-idref="word-delta">delta</span> changes over time.</p>
|
|
225
|
+
<qti-choice-interaction response-identifier="RESPONSE" max-choices="1">
|
|
226
|
+
<qti-simple-choice identifier="A">True</qti-simple-choice>
|
|
227
|
+
</qti-choice-interaction>
|
|
228
|
+
</qti-item-body>
|
|
229
|
+
</qti-assessment-item>`;
|
|
230
|
+
const player = new Player({ itemXml: xml });
|
|
231
|
+
const html = player.getItemBodyHtml();
|
|
232
|
+
|
|
233
|
+
expect(html).toContain('<video');
|
|
234
|
+
expect(html).toContain('<track');
|
|
235
|
+
expect(html).toContain('kind="captions"');
|
|
236
|
+
expect(html).toContain('data-catalog-idref="word-delta"');
|
|
237
|
+
expect(player.getCatalogEntry('word-delta', 'glossary-on-screen')).toContain('river divides');
|
|
238
|
+
});
|
|
239
|
+
});
|