@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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { describe, it, expect } 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 Basic/Advanced Shared Vocabulary clean-room extraction', () => {
|
|
12
|
+
it('Q2: extracts qti-labels-none and qti-orientation-horizontal from choice interaction', () => {
|
|
13
|
+
const xml = qti3Item(
|
|
14
|
+
'qti3-choice-sv',
|
|
15
|
+
`<qti-choice-interaction response-identifier="RESPONSE" max-choices="1"
|
|
16
|
+
class="qti-labels-none qti-orientation-horizontal qti-choices-stacking-2">
|
|
17
|
+
<qti-prompt>Select the renewable energy source.</qti-prompt>
|
|
18
|
+
<qti-simple-choice identifier="solar">Solar</qti-simple-choice>
|
|
19
|
+
<qti-simple-choice identifier="coal">Coal</qti-simple-choice>
|
|
20
|
+
</qti-choice-interaction>`,
|
|
21
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>'
|
|
22
|
+
);
|
|
23
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
24
|
+
|
|
25
|
+
expect(interaction.type).toBe('choiceInteraction');
|
|
26
|
+
expect(interaction.maxChoices).toBe(1);
|
|
27
|
+
expect(interaction.interactionClasses).toContain('qti-labels-none');
|
|
28
|
+
expect(interaction.interactionClasses).toContain('qti-orientation-horizontal');
|
|
29
|
+
expect(interaction.interactionClasses).toContain('qti-choices-stacking-2');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('Q2: treats max-choices="0" as unlimited for multiple cardinality', () => {
|
|
33
|
+
const xml = qti3Item(
|
|
34
|
+
'qti3-choice-multiple',
|
|
35
|
+
`<qti-choice-interaction response-identifier="RESPONSE" max-choices="0">
|
|
36
|
+
<qti-simple-choice identifier="oxygen">Oxygen</qti-simple-choice>
|
|
37
|
+
<qti-simple-choice identifier="nitrogen">Nitrogen</qti-simple-choice>
|
|
38
|
+
<qti-simple-choice identifier="water">Water vapor</qti-simple-choice>
|
|
39
|
+
</qti-choice-interaction>`,
|
|
40
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="multiple" base-type="identifier"/>'
|
|
41
|
+
);
|
|
42
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
43
|
+
|
|
44
|
+
expect(interaction.type).toBe('choiceInteraction');
|
|
45
|
+
expect(interaction.maxChoices).toBe(0);
|
|
46
|
+
expect(interaction.choices).toHaveLength(3);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('Q5: extracts qti-height-lines and qti-counter classes from extended text', () => {
|
|
50
|
+
const xml = qti3Item(
|
|
51
|
+
'qti3-extended-text-sv',
|
|
52
|
+
`<qti-extended-text-interaction response-identifier="RESPONSE"
|
|
53
|
+
class="qti-height-lines-6 qti-counter-down"
|
|
54
|
+
expected-lines="6" expected-length="600"/>`,
|
|
55
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="string"/>'
|
|
56
|
+
);
|
|
57
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
58
|
+
|
|
59
|
+
expect(interaction.type).toBe('extendedTextInteraction');
|
|
60
|
+
expect(interaction.expectedLines).toBe(6);
|
|
61
|
+
expect(interaction.interactionClasses).toContain('qti-height-lines-6');
|
|
62
|
+
expect(interaction.interactionClasses).toContain('qti-counter-down');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('Q20: extracts qti-input-width and data-patternmask-message from text entry', () => {
|
|
66
|
+
const xml = qti3Item(
|
|
67
|
+
'qti3-text-entry-sv',
|
|
68
|
+
`<p>Enter the three-letter code:
|
|
69
|
+
<qti-text-entry-interaction response-identifier="RESPONSE"
|
|
70
|
+
class="qti-input-width-6"
|
|
71
|
+
pattern-mask="[A-Z]{3}"
|
|
72
|
+
data-patternmask-message="Use exactly three uppercase letters."/>
|
|
73
|
+
</p>`,
|
|
74
|
+
'<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="string"/>'
|
|
75
|
+
);
|
|
76
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
77
|
+
|
|
78
|
+
expect(interaction.type).toBe('textEntryInteraction');
|
|
79
|
+
expect(interaction.interactionClasses).toContain('qti-input-width-6');
|
|
80
|
+
expect(interaction.patternMaskMessage).toBe('Use exactly three uppercase letters.');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { describe, it, expect } from 'bun:test';
|
|
2
|
+
import { Player } from '../../core/Player.js';
|
|
3
|
+
|
|
4
|
+
const wrapItem = (identifier: string, body: string, declarations = '') => `<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2"
|
|
6
|
+
identifier="${identifier}" title="${identifier}" adaptive="false" timeDependent="false">
|
|
7
|
+
${declarations}
|
|
8
|
+
<itemBody>${body}</itemBody>
|
|
9
|
+
</assessmentItem>`;
|
|
10
|
+
|
|
11
|
+
describe('QTI 2.2 Advanced clean-room extraction coverage', () => {
|
|
12
|
+
it('Q2 Advanced: extracts a choiceInteraction with bounded single selection', () => {
|
|
13
|
+
const xml = wrapItem(
|
|
14
|
+
'q2-advanced-choice',
|
|
15
|
+
`<choiceInteraction responseIdentifier="RESPONSE" shuffle="false" maxChoices="1">
|
|
16
|
+
<prompt>Select the measurement tool for temperature.</prompt>
|
|
17
|
+
<simpleChoice identifier="thermometer">Thermometer</simpleChoice>
|
|
18
|
+
<simpleChoice identifier="ruler">Ruler</simpleChoice>
|
|
19
|
+
</choiceInteraction>`,
|
|
20
|
+
'<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier"/>'
|
|
21
|
+
);
|
|
22
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
23
|
+
|
|
24
|
+
expect(interaction.type).toBe('choiceInteraction');
|
|
25
|
+
expect(interaction.responseId).toBe('RESPONSE');
|
|
26
|
+
expect(interaction.maxChoices).toBe(1);
|
|
27
|
+
expect(interaction.choices.map((c: any) => c.identifier)).toEqual(['thermometer', 'ruler']);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('Q6: extracts gap choices, gaps, and unlimited matchMax values', () => {
|
|
31
|
+
const xml = wrapItem(
|
|
32
|
+
'q6-gap-match',
|
|
33
|
+
`<p>Complete the energy chain:
|
|
34
|
+
<gapMatchInteraction responseIdentifier="RESPONSE">
|
|
35
|
+
<prompt>Drag each source into the correct gap.</prompt>
|
|
36
|
+
<gapText identifier="sunlight" matchMax="0">sunlight</gapText>
|
|
37
|
+
<gapText identifier="plants" matchMax="1">plants</gapText>
|
|
38
|
+
<blockquote>
|
|
39
|
+
<gap identifier="gap_1"/> is captured by <gap identifier="gap_2"/>.
|
|
40
|
+
</blockquote>
|
|
41
|
+
</gapMatchInteraction>
|
|
42
|
+
</p>`,
|
|
43
|
+
'<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="directedPair"/>'
|
|
44
|
+
);
|
|
45
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
46
|
+
|
|
47
|
+
expect(interaction.type).toBe('gapMatchInteraction');
|
|
48
|
+
expect(interaction.gapTexts).toHaveLength(2);
|
|
49
|
+
expect(interaction.gapTexts.find((g: any) => g.identifier === 'sunlight')?.matchMax).toBe(0);
|
|
50
|
+
expect(interaction.gaps).toEqual(['gap_1', 'gap_2']);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('Q8: extracts graphic gap match background, text/image choices, and hotspots', () => {
|
|
54
|
+
const xml = wrapItem(
|
|
55
|
+
'q8-graphic-gap-match',
|
|
56
|
+
`<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
57
|
+
<prompt>Label the parts of the diagram.</prompt>
|
|
58
|
+
<object data="images/cell-diagram.svg" type="image/svg+xml" width="400" height="300">Cell diagram</object>
|
|
59
|
+
<gapText identifier="nucleus" matchMax="1">Nucleus</gapText>
|
|
60
|
+
<gapImg identifier="membrane" matchMax="1" src="images/membrane-label.svg"/>
|
|
61
|
+
<associableHotspot identifier="A" matchMax="1" shape="rect" coords="20,30,120,90"/>
|
|
62
|
+
<associableHotspot identifier="B" matchMax="1" shape="circle" coords="250,150,35"/>
|
|
63
|
+
</graphicGapMatchInteraction>`,
|
|
64
|
+
'<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="directedPair"/>'
|
|
65
|
+
);
|
|
66
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
67
|
+
|
|
68
|
+
expect(interaction.type).toBe('graphicGapMatchInteraction');
|
|
69
|
+
expect(interaction.imageData.src).toBe('images/cell-diagram.svg');
|
|
70
|
+
expect(interaction.imageData.width).toBe(400);
|
|
71
|
+
expect(interaction.gapTexts).toHaveLength(1);
|
|
72
|
+
expect(interaction.gapImages).toHaveLength(1);
|
|
73
|
+
expect(interaction.hotspots.map((h: any) => h.shape)).toEqual(['rect', 'circle']);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('Q10: extracts hotspot choices with single and multiple cardinality metadata', () => {
|
|
77
|
+
const xml = wrapItem(
|
|
78
|
+
'q10-hotspot',
|
|
79
|
+
`<hotspotInteraction responseIdentifier="RESPONSE" maxChoices="0" minChoices="1">
|
|
80
|
+
<prompt>Select all shaded regions.</prompt>
|
|
81
|
+
<object data="images/region-map.svg" type="image/svg+xml" width="320" height="240">Region map</object>
|
|
82
|
+
<hotspotChoice identifier="north" shape="rect" coords="10,10,110,80"/>
|
|
83
|
+
<hotspotChoice identifier="south" shape="poly" coords="20,160,90,150,110,210,30,220"/>
|
|
84
|
+
</hotspotInteraction>`,
|
|
85
|
+
'<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="identifier"/>'
|
|
86
|
+
);
|
|
87
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
88
|
+
|
|
89
|
+
expect(interaction.type).toBe('hotspotInteraction');
|
|
90
|
+
expect(interaction.maxChoices).toBe(0);
|
|
91
|
+
expect(interaction.minChoices).toBe(1);
|
|
92
|
+
expect(interaction.hotspotChoices.map((h: any) => h.shape)).toEqual(['rect', 'poly']);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('Q11: extracts single and multiple hottext choices', () => {
|
|
96
|
+
const xml = wrapItem(
|
|
97
|
+
'q11-hottext',
|
|
98
|
+
`<hottextInteraction responseIdentifier="RESPONSE" maxChoices="2">
|
|
99
|
+
<prompt>Select the two facts.</prompt>
|
|
100
|
+
<p><hottext identifier="fact_1">Water freezes at 0 degrees Celsius.</hottext></p>
|
|
101
|
+
<p><hottext identifier="opinion_1">Winter is the best season.</hottext></p>
|
|
102
|
+
<p><hottext identifier="fact_2">The Moon orbits Earth.</hottext></p>
|
|
103
|
+
</hottextInteraction>`,
|
|
104
|
+
'<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="identifier"/>'
|
|
105
|
+
);
|
|
106
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
107
|
+
|
|
108
|
+
expect(interaction.type).toBe('hottextInteraction');
|
|
109
|
+
expect(interaction.maxChoices).toBe(2);
|
|
110
|
+
expect(interaction.hottextChoices.map((h: any) => h.identifier)).toEqual([
|
|
111
|
+
'fact_1',
|
|
112
|
+
'opinion_1',
|
|
113
|
+
'fact_2',
|
|
114
|
+
]);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('Q12: extracts inline choices and leaves placeholders in item body HTML', () => {
|
|
118
|
+
const xml = wrapItem(
|
|
119
|
+
'q12-inline-choice',
|
|
120
|
+
`<p>A triangle with three equal sides is
|
|
121
|
+
<inlineChoiceInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
122
|
+
<inlineChoice identifier="equilateral">equilateral</inlineChoice>
|
|
123
|
+
<inlineChoice identifier="scalene">scalene</inlineChoice>
|
|
124
|
+
</inlineChoiceInteraction>.
|
|
125
|
+
</p>`,
|
|
126
|
+
'<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier"/>'
|
|
127
|
+
);
|
|
128
|
+
const player = new Player({ itemXml: xml });
|
|
129
|
+
const interaction = player.getInteractionData()[0] as any;
|
|
130
|
+
|
|
131
|
+
expect(interaction.type).toBe('inlineChoiceInteraction');
|
|
132
|
+
expect(interaction.choices.map((c: any) => c.identifier)).toEqual(['equilateral', 'scalene']);
|
|
133
|
+
expect(player.getItemBodyHtml()).toContain('inlineChoiceInteraction');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('Q13: extracts match sets and maxAssociations', () => {
|
|
137
|
+
const xml = wrapItem(
|
|
138
|
+
'q13-match',
|
|
139
|
+
`<matchInteraction responseIdentifier="RESPONSE" shuffle="false" maxAssociations="3">
|
|
140
|
+
<prompt>Match each process to its description.</prompt>
|
|
141
|
+
<simpleMatchSet>
|
|
142
|
+
<simpleAssociableChoice identifier="evaporation" matchMax="1">Evaporation</simpleAssociableChoice>
|
|
143
|
+
<simpleAssociableChoice identifier="condensation" matchMax="1">Condensation</simpleAssociableChoice>
|
|
144
|
+
</simpleMatchSet>
|
|
145
|
+
<simpleMatchSet>
|
|
146
|
+
<simpleAssociableChoice identifier="liquid_to_gas" matchMax="1">Liquid changes to gas</simpleAssociableChoice>
|
|
147
|
+
<simpleAssociableChoice identifier="gas_to_liquid" matchMax="1">Gas changes to liquid</simpleAssociableChoice>
|
|
148
|
+
</simpleMatchSet>
|
|
149
|
+
</matchInteraction>`,
|
|
150
|
+
'<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="directedPair"/>'
|
|
151
|
+
);
|
|
152
|
+
const interaction = new Player({ itemXml: xml }).getInteractionData()[0] as any;
|
|
153
|
+
|
|
154
|
+
expect(interaction.type).toBe('matchInteraction');
|
|
155
|
+
expect(interaction.maxAssociations).toBe(3);
|
|
156
|
+
expect(interaction.sourceSet).toHaveLength(2);
|
|
157
|
+
expect(interaction.targetSet).toHaveLength(2);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('I17: extracts multiple interactions from one composite item', () => {
|
|
161
|
+
const xml = wrapItem(
|
|
162
|
+
'i17-composite',
|
|
163
|
+
`<p>The state of matter with a fixed volume but no fixed shape is
|
|
164
|
+
<inlineChoiceInteraction responseIdentifier="STATE" shuffle="false">
|
|
165
|
+
<inlineChoice identifier="liquid">liquid</inlineChoice>
|
|
166
|
+
<inlineChoice identifier="solid">solid</inlineChoice>
|
|
167
|
+
</inlineChoiceInteraction>.
|
|
168
|
+
</p>
|
|
169
|
+
<p>Write the freezing point of water in Celsius:
|
|
170
|
+
<textEntryInteraction responseIdentifier="TEMP" expectedLength="3"/>
|
|
171
|
+
</p>
|
|
172
|
+
<choiceInteraction responseIdentifier="UNIT" maxChoices="1">
|
|
173
|
+
<simpleChoice identifier="celsius">Celsius</simpleChoice>
|
|
174
|
+
<simpleChoice identifier="fahrenheit">Fahrenheit</simpleChoice>
|
|
175
|
+
</choiceInteraction>`,
|
|
176
|
+
`<responseDeclaration identifier="STATE" cardinality="single" baseType="identifier"/>
|
|
177
|
+
<responseDeclaration identifier="TEMP" cardinality="single" baseType="string"/>
|
|
178
|
+
<responseDeclaration identifier="UNIT" cardinality="single" baseType="identifier"/>`
|
|
179
|
+
);
|
|
180
|
+
const interactions = new Player({ itemXml: xml }).getInteractionData();
|
|
181
|
+
const types = interactions.map((i) => i.type).sort();
|
|
182
|
+
|
|
183
|
+
expect(interactions).toHaveLength(3);
|
|
184
|
+
expect(types).toEqual(['choiceInteraction', 'inlineChoiceInteraction', 'textEntryInteraction']);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('P7: ignores metadata while preserving deliverable item content', () => {
|
|
188
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
189
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2"
|
|
190
|
+
xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
|
|
191
|
+
identifier="p7-metadata" title="Metadata Item" adaptive="false" timeDependent="false">
|
|
192
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier"/>
|
|
193
|
+
<imsmd:lom>
|
|
194
|
+
<imsmd:general><imsmd:title><imsmd:string>Clean-room metadata fixture</imsmd:string></imsmd:title></imsmd:general>
|
|
195
|
+
</imsmd:lom>
|
|
196
|
+
<itemBody>
|
|
197
|
+
<choiceInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
198
|
+
<simpleChoice identifier="A">A public fixture can include metadata.</simpleChoice>
|
|
199
|
+
<simpleChoice identifier="B">Metadata prevents delivery.</simpleChoice>
|
|
200
|
+
</choiceInteraction>
|
|
201
|
+
</itemBody>
|
|
202
|
+
</assessmentItem>`;
|
|
203
|
+
const player = new Player({ itemXml: xml });
|
|
204
|
+
|
|
205
|
+
expect(player.getInteractionData()).toHaveLength(1);
|
|
206
|
+
expect(player.getItemBodyHtml()).toContain('public fixture');
|
|
207
|
+
});
|
|
208
|
+
});
|
|
@@ -28,8 +28,11 @@ export const standardExtendedTextExtractor: ElementExtractor<ExtendedTextData> =
|
|
|
28
28
|
description: 'Extracts standard QTI extendedTextInteraction (multi-line text input)',
|
|
29
29
|
|
|
30
30
|
canHandle(element, _context) {
|
|
31
|
-
// All extendedTextInteraction elements are standard
|
|
32
|
-
return
|
|
31
|
+
// All extendedTextInteraction elements are standard (both QTI 2.x and 3.0)
|
|
32
|
+
return (
|
|
33
|
+
element.rawTagName === 'extendedTextInteraction' ||
|
|
34
|
+
element.rawTagName === 'qti-extended-text-interaction'
|
|
35
|
+
);
|
|
33
36
|
},
|
|
34
37
|
|
|
35
38
|
extract(element, context) {
|
|
@@ -40,12 +43,18 @@ export const standardExtendedTextExtractor: ElementExtractor<ExtendedTextData> =
|
|
|
40
43
|
const expectedLength = utils.getNumberAttribute(element, 'expectedLength', 200);
|
|
41
44
|
const placeholderText = utils.getAttribute(element, 'placeholderText', '');
|
|
42
45
|
const format = utils.getAttribute(element, 'format', 'plain');
|
|
46
|
+
const patternMask = utils.getAttribute(element, 'patternMask', '') || null;
|
|
47
|
+
const patternMaskMessage = utils.getAttribute(element, 'patternMaskMessage', '') || null;
|
|
48
|
+
const interactionClasses = utils.getClasses(element);
|
|
43
49
|
|
|
44
50
|
return {
|
|
45
51
|
expectedLines,
|
|
46
52
|
expectedLength,
|
|
47
53
|
placeholderText,
|
|
48
54
|
format,
|
|
55
|
+
...(patternMask ? { patternMask } : {}),
|
|
56
|
+
...(patternMaskMessage ? { patternMaskMessage } : {}),
|
|
57
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
49
58
|
};
|
|
50
59
|
},
|
|
51
60
|
|
|
@@ -15,6 +15,7 @@ export interface GapMatchData {
|
|
|
15
15
|
text: string;
|
|
16
16
|
matchMax: number;
|
|
17
17
|
matchMin?: number;
|
|
18
|
+
matchGroup?: string[];
|
|
18
19
|
classes?: string[];
|
|
19
20
|
}>;
|
|
20
21
|
gaps: string[];
|
|
@@ -48,12 +49,15 @@ export const standardGapMatchExtractor: ElementExtractor<GapMatchData> = {
|
|
|
48
49
|
const classes = utils.getClasses(gapText);
|
|
49
50
|
const matchMax = utils.getNumberAttribute(gapText, 'matchMax', 1);
|
|
50
51
|
const matchMin = utils.getNumberAttribute(gapText, 'matchMin', 0);
|
|
52
|
+
const matchGroupRaw = utils.getAttribute(gapText, 'matchGroup', '');
|
|
53
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
51
54
|
|
|
52
55
|
return {
|
|
53
56
|
identifier: utils.getAttribute(gapText, 'identifier', ''),
|
|
54
57
|
text: utils.getTextContent(gapText),
|
|
55
58
|
matchMax,
|
|
56
59
|
...(matchMin > 0 ? { matchMin } : {}),
|
|
60
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
57
61
|
...(classes.length > 0 ? { classes } : {}),
|
|
58
62
|
};
|
|
59
63
|
});
|
|
@@ -73,7 +77,7 @@ export const standardGapMatchExtractor: ElementExtractor<GapMatchData> = {
|
|
|
73
77
|
// Get the raw HTML content and extract gaps
|
|
74
78
|
const promptHtml = promptElement.outerHTML || promptElement.toString();
|
|
75
79
|
|
|
76
|
-
// Extract gap elements from prompt
|
|
80
|
+
// Extract gap elements from prompt children
|
|
77
81
|
const gapElements = utils.getChildrenByTag(promptElement, 'gap');
|
|
78
82
|
for (const gap of gapElements) {
|
|
79
83
|
gaps.push(utils.getAttribute(gap, 'identifier', ''));
|
|
@@ -81,39 +85,46 @@ export const standardGapMatchExtractor: ElementExtractor<GapMatchData> = {
|
|
|
81
85
|
|
|
82
86
|
// Replace gap elements with placeholders in the text
|
|
83
87
|
promptText = promptHtml
|
|
84
|
-
.replace(/<prompt[^>]*>/, '')
|
|
85
|
-
.replace(/<\/prompt>/, '')
|
|
86
|
-
.replace(/<gap\s+identifier="([^"]+)"[^>]*>/g, '[GAP:$1]')
|
|
87
|
-
.replace(/<gap\s+identifier='([^']+)'[^>]*>/g, '[GAP:$1]')
|
|
88
|
-
.replace(/<\/gap>/g, '')
|
|
88
|
+
.replace(/<qti-prompt[^>]*>|<prompt[^>]*>/, '')
|
|
89
|
+
.replace(/<\/qti-prompt>|<\/prompt>/, '')
|
|
90
|
+
.replace(/<(?:qti-)?gap\s+identifier="([^"]+)"[^>]*>/g, '[GAP:$1]')
|
|
91
|
+
.replace(/<(?:qti-)?gap\s+identifier='([^']+)'[^>]*>/g, '[GAP:$1]')
|
|
92
|
+
.replace(/<\/(?:qti-)?gap>/g, '')
|
|
89
93
|
.trim();
|
|
90
|
-
}
|
|
91
|
-
// No <prompt> element: derive promptText from the interaction content excluding <gapText> blocks.
|
|
92
|
-
const interactionHtml = element.outerHTML || element.toString();
|
|
94
|
+
}
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
// If gaps were not found inside a <prompt>, search the full interaction body.
|
|
97
|
+
// This handles items where <gap> elements appear in <p>/<blockquote> siblings of <prompt>.
|
|
98
|
+
if (gaps.length === 0) {
|
|
99
|
+
const interactionHtml = element.outerHTML || element.toString();
|
|
95
100
|
const gapIdMatches = Array.from(
|
|
96
|
-
interactionHtml.matchAll(/<gap\s+identifier=(?:"([^"]+)"|'([^']+)')[^>]*\/?>/
|
|
101
|
+
interactionHtml.matchAll(/<(?:qti-)?gap\s+identifier=(?:"([^"]+)"|'([^']+)')[^>]*\/?>/gi)
|
|
97
102
|
);
|
|
98
103
|
for (const m of gapIdMatches) {
|
|
99
104
|
const id = (m[1] || m[2] || '').trim();
|
|
100
105
|
if (id) gaps.push(id);
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
promptText
|
|
104
|
-
.
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
if (!promptText) {
|
|
109
|
+
// No prompt element either: build promptText from full interaction content.
|
|
110
|
+
const interactionHtml2 = element.outerHTML || element.toString();
|
|
111
|
+
promptText = interactionHtml2
|
|
112
|
+
.replace(/<(?:qti-)?gap-match-interaction[^>]*>|<gapMatchInteraction[^>]*>/, '')
|
|
113
|
+
.replace(/<\/(?:qti-)?gap-match-interaction>|<\/gapMatchInteraction>/, '')
|
|
114
|
+
.replace(/<(?:qti-)?gap-text[\s\S]*?<\/(?:qti-)?gap-text>|<gapText[\s\S]*?<\/gapText>/g, '')
|
|
115
|
+
.replace(/<(?:qti-)?gap\s+identifier="([^"]+)"[^>]*\/?>/g, '[GAP:$1]')
|
|
116
|
+
.replace(/<(?:qti-)?gap\s+identifier='([^']+)'[^>]*\/?>/g, '[GAP:$1]')
|
|
117
|
+
.replace(/<\/(?:qti-)?gap>/g, '')
|
|
118
|
+
.trim();
|
|
119
|
+
}
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
// Extract attributes
|
|
116
123
|
const shuffle = utils.getBooleanAttribute(element, 'shuffle');
|
|
124
|
+
const interactionClasses = utils.getClasses(element);
|
|
125
|
+
const choicesContainerWidth = utils.getAttribute(element, 'data-choices-container-width', '') || null;
|
|
126
|
+
const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
|
|
127
|
+
const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
|
|
117
128
|
|
|
118
129
|
return {
|
|
119
130
|
gapTexts,
|
|
@@ -121,6 +132,10 @@ export const standardGapMatchExtractor: ElementExtractor<GapMatchData> = {
|
|
|
121
132
|
shuffle,
|
|
122
133
|
prompt,
|
|
123
134
|
promptText,
|
|
135
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
136
|
+
...(choicesContainerWidth ? { choicesContainerWidth } : {}),
|
|
137
|
+
...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
|
|
138
|
+
...(minSelectionsMessage ? { minSelectionsMessage } : {}),
|
|
124
139
|
};
|
|
125
140
|
},
|
|
126
141
|
|
|
@@ -29,6 +29,7 @@ export interface GraphicAssociateData {
|
|
|
29
29
|
coords: string;
|
|
30
30
|
matchMax: number;
|
|
31
31
|
matchMin?: number;
|
|
32
|
+
matchGroup?: string[];
|
|
32
33
|
classes?: string[];
|
|
33
34
|
}>;
|
|
34
35
|
maxAssociations: number;
|
|
@@ -95,6 +96,8 @@ export const standardGraphicAssociateExtractor: ElementExtractor<GraphicAssociat
|
|
|
95
96
|
const coords = utils.getAttribute(hotspot, 'coords', '0,0,50,50');
|
|
96
97
|
const matchMax = utils.getNumberAttribute(hotspot, 'matchMax', 1);
|
|
97
98
|
const matchMin = utils.getNumberAttribute(hotspot, 'matchMin', 0);
|
|
99
|
+
const matchGroupRaw = utils.getAttribute(hotspot, 'matchGroup', '');
|
|
100
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
98
101
|
|
|
99
102
|
// Get text content as label, use identifier as fallback
|
|
100
103
|
const textContent = utils.getTextContent(hotspot).trim();
|
|
@@ -107,6 +110,7 @@ export const standardGraphicAssociateExtractor: ElementExtractor<GraphicAssociat
|
|
|
107
110
|
coords,
|
|
108
111
|
matchMax,
|
|
109
112
|
...(matchMin > 0 ? { matchMin } : {}),
|
|
113
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
110
114
|
...(classes.length > 0 ? { classes } : {}),
|
|
111
115
|
};
|
|
112
116
|
});
|
|
@@ -22,13 +22,24 @@ export interface ImageData {
|
|
|
22
22
|
*/
|
|
23
23
|
export interface GraphicGapMatchData {
|
|
24
24
|
imageData: ImageData | null;
|
|
25
|
+
maxAssociations: number;
|
|
25
26
|
gapTexts: Array<{
|
|
26
27
|
identifier: string;
|
|
27
28
|
text: string;
|
|
28
29
|
matchMax: number;
|
|
29
30
|
matchMin?: number;
|
|
31
|
+
matchGroup?: string[];
|
|
30
32
|
classes?: string[];
|
|
31
33
|
}>;
|
|
34
|
+
gapImages: Array<{
|
|
35
|
+
identifier: string;
|
|
36
|
+
src: string;
|
|
37
|
+
alt: string;
|
|
38
|
+
matchMax: number;
|
|
39
|
+
matchGroup?: string[];
|
|
40
|
+
width?: number;
|
|
41
|
+
height?: number;
|
|
42
|
+
}>;
|
|
32
43
|
hotspots: Array<{ identifier: string; shape: string; coords: string; matchMax: number }>;
|
|
33
44
|
prompt: string | null;
|
|
34
45
|
}
|
|
@@ -64,14 +75,27 @@ export const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchD
|
|
|
64
75
|
const height = utils.getNumberAttribute(objectElement, 'height', 0);
|
|
65
76
|
|
|
66
77
|
if (type.startsWith('image/svg')) {
|
|
67
|
-
//
|
|
78
|
+
// Inline SVG: <object type="image/svg+xml"><svg>...</svg></object>
|
|
79
|
+
// External SVG: <object type="image/svg+xml" data="path/to/file.svg"/>
|
|
80
|
+
// The <object> may contain alt text (not SVG markup) — only treat as inline if content has <svg.
|
|
68
81
|
const content = utils.getHtmlContent(objectElement);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
const hasSvgMarkup = /<svg[\s>]/i.test(content);
|
|
83
|
+
if (hasSvgMarkup) {
|
|
84
|
+
imageData = {
|
|
85
|
+
type: 'svg',
|
|
86
|
+
content,
|
|
87
|
+
...(width > 0 ? { width } : {}),
|
|
88
|
+
...(height > 0 ? { height } : {}),
|
|
89
|
+
};
|
|
90
|
+
} else {
|
|
91
|
+
// External SVG file reference — render via <img src>
|
|
92
|
+
imageData = {
|
|
93
|
+
type: 'image',
|
|
94
|
+
src: data,
|
|
95
|
+
...(width > 0 ? { width } : {}),
|
|
96
|
+
...(height > 0 ? { height } : {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
75
99
|
} else {
|
|
76
100
|
// External image reference
|
|
77
101
|
imageData = {
|
|
@@ -83,12 +107,17 @@ export const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchD
|
|
|
83
107
|
}
|
|
84
108
|
}
|
|
85
109
|
|
|
110
|
+
// Extract interaction-level attributes
|
|
111
|
+
const maxAssociations = utils.getNumberAttribute(element, 'maxAssociations', 0);
|
|
112
|
+
|
|
86
113
|
// Extract gapText children (draggable text labels)
|
|
87
114
|
const gapTextElements = utils.getChildrenByTag(element, 'gapText');
|
|
88
115
|
const gapTexts = gapTextElements.map((gapText) => {
|
|
89
116
|
const classes = utils.getClasses(gapText);
|
|
90
117
|
const matchMax = utils.getNumberAttribute(gapText, 'matchMax', 1);
|
|
91
118
|
const matchMin = utils.getNumberAttribute(gapText, 'matchMin', 0);
|
|
119
|
+
const matchGroupRaw = utils.getAttribute(gapText, 'matchGroup', '');
|
|
120
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
92
121
|
const text = utils.getHtmlContent(gapText);
|
|
93
122
|
|
|
94
123
|
return {
|
|
@@ -96,10 +125,42 @@ export const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchD
|
|
|
96
125
|
text,
|
|
97
126
|
matchMax,
|
|
98
127
|
...(matchMin > 0 ? { matchMin } : {}),
|
|
128
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
99
129
|
...(classes.length > 0 ? { classes } : {}),
|
|
100
130
|
};
|
|
101
131
|
});
|
|
102
132
|
|
|
133
|
+
// Extract gapImg children (draggable image labels)
|
|
134
|
+
const gapImgElements = utils.getChildrenByTag(element, 'gapImg');
|
|
135
|
+
const gapImages = gapImgElements.map((gapImg) => {
|
|
136
|
+
const matchMax = utils.getNumberAttribute(gapImg, 'matchMax', 1);
|
|
137
|
+
const matchGroupRaw = utils.getAttribute(gapImg, 'matchGroup', '');
|
|
138
|
+
const matchGroup = matchGroupRaw.split(/\s+/).filter(Boolean);
|
|
139
|
+
const objectChildren = utils.getChildrenByTag(gapImg, 'object');
|
|
140
|
+
let src = '';
|
|
141
|
+
let alt = '';
|
|
142
|
+
let width: number | undefined;
|
|
143
|
+
let height: number | undefined;
|
|
144
|
+
if (objectChildren.length > 0) {
|
|
145
|
+
const obj = objectChildren[0];
|
|
146
|
+
src = utils.getAttribute(obj, 'data', '');
|
|
147
|
+
alt = utils.getTextContent(obj);
|
|
148
|
+
const w = utils.getNumberAttribute(obj, 'width', 0);
|
|
149
|
+
const h = utils.getNumberAttribute(obj, 'height', 0);
|
|
150
|
+
if (w > 0) width = w;
|
|
151
|
+
if (h > 0) height = h;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
identifier: utils.getAttribute(gapImg, 'identifier', ''),
|
|
155
|
+
src,
|
|
156
|
+
alt,
|
|
157
|
+
matchMax,
|
|
158
|
+
...(matchGroup.length > 0 ? { matchGroup } : {}),
|
|
159
|
+
...(width !== undefined ? { width } : {}),
|
|
160
|
+
...(height !== undefined ? { height } : {}),
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
|
|
103
164
|
// Extract associableHotspot elements (gap targets)
|
|
104
165
|
const hotspotElements = utils.getChildrenByTag(element, 'associableHotspot');
|
|
105
166
|
const hotspots = hotspotElements.map((hotspot) => ({
|
|
@@ -113,11 +174,22 @@ export const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchD
|
|
|
113
174
|
const promptElements = utils.getChildrenByTag(element, 'prompt');
|
|
114
175
|
const prompt = promptElements.length > 0 ? utils.getHtmlContent(promptElements[0]) : null;
|
|
115
176
|
|
|
177
|
+
const interactionClasses = utils.getClasses(element);
|
|
178
|
+
const choicesContainerWidth = utils.getAttribute(element, 'data-choices-container-width', '') || null;
|
|
179
|
+
const maxSelectionsMessage = utils.getAttribute(element, 'data-max-selections-message', '') || null;
|
|
180
|
+
const minSelectionsMessage = utils.getAttribute(element, 'data-min-selections-message', '') || null;
|
|
181
|
+
|
|
116
182
|
return {
|
|
117
183
|
imageData,
|
|
184
|
+
maxAssociations,
|
|
118
185
|
gapTexts,
|
|
186
|
+
gapImages,
|
|
119
187
|
hotspots,
|
|
120
188
|
prompt,
|
|
189
|
+
...(interactionClasses.length > 0 ? { interactionClasses } : {}),
|
|
190
|
+
...(choicesContainerWidth ? { choicesContainerWidth } : {}),
|
|
191
|
+
...(maxSelectionsMessage ? { maxSelectionsMessage } : {}),
|
|
192
|
+
...(minSelectionsMessage ? { minSelectionsMessage } : {}),
|
|
121
193
|
};
|
|
122
194
|
},
|
|
123
195
|
|
|
@@ -134,9 +206,9 @@ export const standardGraphicGapMatchExtractor: ElementExtractor<GraphicGapMatchD
|
|
|
134
206
|
errors.push('graphicGapMatchInteraction must have SVG content');
|
|
135
207
|
}
|
|
136
208
|
|
|
137
|
-
// Validate
|
|
138
|
-
if (!data.gapTexts || data.gapTexts.length === 0) {
|
|
139
|
-
errors.push('graphicGapMatchInteraction must have at least one gapText');
|
|
209
|
+
// Validate that at least one draggable choice type is present
|
|
210
|
+
if ((!data.gapTexts || data.gapTexts.length === 0) && (!data.gapImages || data.gapImages.length === 0)) {
|
|
211
|
+
errors.push('graphicGapMatchInteraction must have at least one gapText or gapImg');
|
|
140
212
|
}
|
|
141
213
|
|
|
142
214
|
// Validate hotspots exist
|