@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
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for standardGraphicAssociateExtractor
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, expect, test } from 'bun:test';
|
|
6
|
-
import { standardGraphicAssociateExtractor } from '../../../src/extraction/extractors/graphicAssociateExtractor.js';
|
|
7
|
-
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
-
|
|
9
|
-
describe('standardGraphicAssociateExtractor', () => {
|
|
10
|
-
test('extracts graphicAssociateInteraction with image', () => {
|
|
11
|
-
const xml = `
|
|
12
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE" maxAssociations="3">
|
|
13
|
-
<prompt>Connect related items</prompt>
|
|
14
|
-
<object data="diagram.png" type="image/png" width="500" height="400"/>
|
|
15
|
-
<associableHotspot identifier="A" shape="rect" coords="50,50,150,100" matchMax="2">Area A</associableHotspot>
|
|
16
|
-
<associableHotspot identifier="B" shape="rect" coords="200,50,300,100" matchMax="2">Area B</associableHotspot>
|
|
17
|
-
<associableHotspot identifier="C" shape="circle" coords="250,250,40" matchMax="1">Area C</associableHotspot>
|
|
18
|
-
</graphicAssociateInteraction>
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
const element = parseQTI(xml);
|
|
22
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
23
|
-
|
|
24
|
-
const result = standardGraphicAssociateExtractor.extract(element, context);
|
|
25
|
-
|
|
26
|
-
expect(result.prompt).toBe('Connect related items');
|
|
27
|
-
expect(result.maxAssociations).toBe(3);
|
|
28
|
-
expect(result.minAssociations).toBe(0);
|
|
29
|
-
expect(result.imageData?.type).toBe('image');
|
|
30
|
-
expect(result.imageData?.src).toBe('diagram.png');
|
|
31
|
-
expect(result.imageData?.width).toBe('500');
|
|
32
|
-
expect(result.imageData?.height).toBe('400');
|
|
33
|
-
expect(result.associableHotspots).toHaveLength(3);
|
|
34
|
-
expect(result.associableHotspots[0].identifier).toBe('A');
|
|
35
|
-
expect(result.associableHotspots[0].label).toBe('Area A');
|
|
36
|
-
expect(result.associableHotspots[0].shape).toBe('rect');
|
|
37
|
-
expect(result.associableHotspots[0].coords).toBe('50,50,150,100');
|
|
38
|
-
expect(result.associableHotspots[0].matchMax).toBe(2);
|
|
39
|
-
expect(result.associableHotspots[2].shape).toBe('circle');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('extracts graphicAssociateInteraction with SVG', () => {
|
|
43
|
-
const xml = `
|
|
44
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE">
|
|
45
|
-
<prompt>Match the connections</prompt>
|
|
46
|
-
<object type="image/svg+xml" width="600" height="400">
|
|
47
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 400">
|
|
48
|
-
<rect width="600" height="400" fill="#f0f0f0"/>
|
|
49
|
-
<circle cx="100" cy="100" r="40" fill="blue"/>
|
|
50
|
-
<circle cx="500" cy="100" r="40" fill="red"/>
|
|
51
|
-
</svg>
|
|
52
|
-
</object>
|
|
53
|
-
<associableHotspot identifier="BLUE" shape="circle" coords="100,100,40">Blue Circle</associableHotspot>
|
|
54
|
-
<associableHotspot identifier="RED" shape="circle" coords="500,100,40">Red Circle</associableHotspot>
|
|
55
|
-
</graphicAssociateInteraction>
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
const element = parseQTI(xml);
|
|
59
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
60
|
-
|
|
61
|
-
const result = standardGraphicAssociateExtractor.extract(element, context);
|
|
62
|
-
|
|
63
|
-
expect(result.imageData?.type).toBe('svg');
|
|
64
|
-
expect(result.imageData?.content).toContain('<svg');
|
|
65
|
-
expect(result.imageData?.content).toContain('blue');
|
|
66
|
-
expect(result.imageData?.width).toBe('600');
|
|
67
|
-
expect(result.imageData?.height).toBe('400');
|
|
68
|
-
expect(result.associableHotspots).toHaveLength(2);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('handles minAssociations attribute', () => {
|
|
72
|
-
const xml = `
|
|
73
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE" minAssociations="2" maxAssociations="5">
|
|
74
|
-
<object data="test.png" type="image/png"/>
|
|
75
|
-
<associableHotspot identifier="A" shape="rect" coords="0,0,50,50">A</associableHotspot>
|
|
76
|
-
<associableHotspot identifier="B" shape="rect" coords="100,0,150,50">B</associableHotspot>
|
|
77
|
-
</graphicAssociateInteraction>
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
const element = parseQTI(xml);
|
|
81
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
82
|
-
|
|
83
|
-
const result = standardGraphicAssociateExtractor.extract(element, context);
|
|
84
|
-
|
|
85
|
-
expect(result.minAssociations).toBe(2);
|
|
86
|
-
expect(result.maxAssociations).toBe(5);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('uses default values when attributes are missing', () => {
|
|
90
|
-
const xml = `
|
|
91
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE">
|
|
92
|
-
<object data="test.png" type="image/png"/>
|
|
93
|
-
<associableHotspot identifier="A">Area A</associableHotspot>
|
|
94
|
-
</graphicAssociateInteraction>
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
const element = parseQTI(xml);
|
|
98
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
99
|
-
|
|
100
|
-
const result = standardGraphicAssociateExtractor.extract(element, context);
|
|
101
|
-
|
|
102
|
-
expect(result.maxAssociations).toBe(1);
|
|
103
|
-
expect(result.minAssociations).toBe(0);
|
|
104
|
-
expect(result.imageData?.width).toBe('500');
|
|
105
|
-
expect(result.imageData?.height).toBe('300');
|
|
106
|
-
expect(result.associableHotspots[0].shape).toBe('rect');
|
|
107
|
-
expect(result.associableHotspots[0].coords).toBe('0,0,50,50');
|
|
108
|
-
expect(result.associableHotspots[0].matchMax).toBe(1);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test('uses identifier as label if text content is empty', () => {
|
|
112
|
-
const xml = `
|
|
113
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE">
|
|
114
|
-
<object data="test.png" type="image/png"/>
|
|
115
|
-
<associableHotspot identifier="HOTSPOT_ONE" shape="rect" coords="0,0,50,50"/>
|
|
116
|
-
</graphicAssociateInteraction>
|
|
117
|
-
`;
|
|
118
|
-
|
|
119
|
-
const element = parseQTI(xml);
|
|
120
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
121
|
-
|
|
122
|
-
const result = standardGraphicAssociateExtractor.extract(element, context);
|
|
123
|
-
|
|
124
|
-
expect(result.associableHotspots[0].label).toBe('HOTSPOT_ONE');
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('handles multiple associableHotspots with different matchMax values', () => {
|
|
128
|
-
const xml = `
|
|
129
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE" maxAssociations="10">
|
|
130
|
-
<object data="network.png" type="image/png"/>
|
|
131
|
-
<associableHotspot identifier="HUB" shape="rect" coords="200,100,300,150" matchMax="4">Hub</associableHotspot>
|
|
132
|
-
<associableHotspot identifier="PC1" shape="rect" coords="50,50,100,100" matchMax="1">PC 1</associableHotspot>
|
|
133
|
-
<associableHotspot identifier="PC2" shape="rect" coords="350,50,400,100" matchMax="1">PC 2</associableHotspot>
|
|
134
|
-
<associableHotspot identifier="PC3" shape="rect" coords="50,200,100,250" matchMax="1">PC 3</associableHotspot>
|
|
135
|
-
</graphicAssociateInteraction>
|
|
136
|
-
`;
|
|
137
|
-
|
|
138
|
-
const element = parseQTI(xml);
|
|
139
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
140
|
-
|
|
141
|
-
const result = standardGraphicAssociateExtractor.extract(element, context);
|
|
142
|
-
|
|
143
|
-
expect(result.associableHotspots).toHaveLength(4);
|
|
144
|
-
expect(result.associableHotspots[0].matchMax).toBe(4); // Hub can connect to 4 devices
|
|
145
|
-
expect(result.associableHotspots[1].matchMax).toBe(1); // PC can connect to 1
|
|
146
|
-
expect(result.associableHotspots[2].matchMax).toBe(1);
|
|
147
|
-
expect(result.associableHotspots[3].matchMax).toBe(1);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test('handles missing prompt', () => {
|
|
151
|
-
const xml = `
|
|
152
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE">
|
|
153
|
-
<object data="test.png" type="image/png"/>
|
|
154
|
-
<associableHotspot identifier="A">Area A</associableHotspot>
|
|
155
|
-
</graphicAssociateInteraction>
|
|
156
|
-
`;
|
|
157
|
-
|
|
158
|
-
const element = parseQTI(xml);
|
|
159
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
160
|
-
|
|
161
|
-
const result = standardGraphicAssociateExtractor.extract(element, context);
|
|
162
|
-
|
|
163
|
-
expect(result.prompt).toBeNull();
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe('canHandle predicate', () => {
|
|
167
|
-
test('handles graphicAssociateInteraction element', () => {
|
|
168
|
-
const xml = `
|
|
169
|
-
<graphicAssociateInteraction responseIdentifier="RESPONSE">
|
|
170
|
-
<associableHotspot identifier="A">A</associableHotspot>
|
|
171
|
-
</graphicAssociateInteraction>
|
|
172
|
-
`;
|
|
173
|
-
const element = parseQTI(xml);
|
|
174
|
-
const context = createTestContext(element);
|
|
175
|
-
|
|
176
|
-
expect(standardGraphicAssociateExtractor.canHandle(element, context)).toBe(true);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test('rejects non-graphicAssociateInteraction elements', () => {
|
|
180
|
-
const xml = `<associateInteraction responseIdentifier="RESPONSE" />`;
|
|
181
|
-
const element = parseQTI(xml);
|
|
182
|
-
const context = createTestContext(element);
|
|
183
|
-
|
|
184
|
-
expect(standardGraphicAssociateExtractor.canHandle(element, context)).toBe(false);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
describe('validation', () => {
|
|
189
|
-
test('validates correct graphicAssociate data', () => {
|
|
190
|
-
const data = {
|
|
191
|
-
associableHotspots: [
|
|
192
|
-
{ identifier: 'A', label: 'A', shape: 'rect', coords: '0,0,100,100', matchMax: 1 },
|
|
193
|
-
{ identifier: 'B', label: 'B', shape: 'rect', coords: '100,0,200,100', matchMax: 1 },
|
|
194
|
-
],
|
|
195
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
196
|
-
maxAssociations: 1,
|
|
197
|
-
minAssociations: 0,
|
|
198
|
-
prompt: null,
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const validation = standardGraphicAssociateExtractor.validate!(data);
|
|
202
|
-
|
|
203
|
-
expect(validation.valid).toBe(true);
|
|
204
|
-
expect(validation.errors).toBeUndefined();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
test('reports error for insufficient hotspots', () => {
|
|
208
|
-
const data = {
|
|
209
|
-
associableHotspots: [
|
|
210
|
-
{ identifier: 'A', label: 'A', shape: 'rect', coords: '0,0,100,100', matchMax: 1 },
|
|
211
|
-
],
|
|
212
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
213
|
-
maxAssociations: 1,
|
|
214
|
-
minAssociations: 0,
|
|
215
|
-
prompt: null,
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const validation = standardGraphicAssociateExtractor.validate!(data);
|
|
219
|
-
|
|
220
|
-
expect(validation.valid).toBe(false);
|
|
221
|
-
expect(validation.errors).toContain('graphicAssociateInteraction must have at least 2 hotspots');
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test('reports error for duplicate identifiers', () => {
|
|
225
|
-
const data = {
|
|
226
|
-
associableHotspots: [
|
|
227
|
-
{ identifier: 'A', label: 'A', shape: 'rect', coords: '0,0,100,100', matchMax: 1 },
|
|
228
|
-
{ identifier: 'A', label: 'B', shape: 'rect', coords: '100,0,200,100', matchMax: 1 },
|
|
229
|
-
],
|
|
230
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
231
|
-
maxAssociations: 1,
|
|
232
|
-
minAssociations: 0,
|
|
233
|
-
prompt: null,
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
const validation = standardGraphicAssociateExtractor.validate!(data);
|
|
237
|
-
|
|
238
|
-
expect(validation.valid).toBe(false);
|
|
239
|
-
expect(validation.errors).toContain('Duplicate hotspot identifier: A');
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
test('reports warning for missing image data', () => {
|
|
243
|
-
const data = {
|
|
244
|
-
associableHotspots: [
|
|
245
|
-
{ identifier: 'A', label: 'A', shape: 'rect', coords: '0,0,100,100', matchMax: 1 },
|
|
246
|
-
{ identifier: 'B', label: 'B', shape: 'rect', coords: '100,0,200,100', matchMax: 1 },
|
|
247
|
-
],
|
|
248
|
-
imageData: null,
|
|
249
|
-
maxAssociations: 1,
|
|
250
|
-
minAssociations: 0,
|
|
251
|
-
prompt: null,
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
const validation = standardGraphicAssociateExtractor.validate!(data);
|
|
255
|
-
|
|
256
|
-
expect(validation.valid).toBe(true);
|
|
257
|
-
expect(validation.warnings).toContain('graphicAssociateInteraction has no image data');
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
});
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for standardGraphicGapMatchExtractor
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, expect, test } from 'bun:test';
|
|
6
|
-
import { standardGraphicGapMatchExtractor } from '../../../src/extraction/extractors/graphicGapMatchExtractor.js';
|
|
7
|
-
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
-
|
|
9
|
-
describe('standardGraphicGapMatchExtractor', () => {
|
|
10
|
-
test('extracts basic graphic gap match interaction', () => {
|
|
11
|
-
const xml = `
|
|
12
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
13
|
-
<prompt>Drag labels to the correct positions</prompt>
|
|
14
|
-
<object type="image/png" data="diagram.png" width="600" height="400" />
|
|
15
|
-
<gapText identifier="G1" matchMax="1">Label A</gapText>
|
|
16
|
-
<gapText identifier="G2" matchMax="1">Label B</gapText>
|
|
17
|
-
<associableHotspot identifier="H1" shape="rect" coords="100,100,200,150" matchMax="1" />
|
|
18
|
-
<associableHotspot identifier="H2" shape="circle" coords="400,200,50" matchMax="1" />
|
|
19
|
-
</graphicGapMatchInteraction>
|
|
20
|
-
`;
|
|
21
|
-
const element = parseQTI(xml);
|
|
22
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
23
|
-
|
|
24
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
25
|
-
|
|
26
|
-
expect(result.prompt).toBe('Drag labels to the correct positions');
|
|
27
|
-
expect(result.gapTexts).toHaveLength(2);
|
|
28
|
-
expect(result.hotspots).toHaveLength(2);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('extracts gapText elements correctly', () => {
|
|
32
|
-
const xml = `
|
|
33
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
34
|
-
<object type="image/png" data="diagram.png" />
|
|
35
|
-
<gapText identifier="T1" matchMax="1">First</gapText>
|
|
36
|
-
<gapText identifier="T2" matchMax="2">Second</gapText>
|
|
37
|
-
<gapText identifier="T3" matchMax="0">Third</gapText>
|
|
38
|
-
<associableHotspot identifier="H1" shape="rect" coords="0,0,100,100" matchMax="1" />
|
|
39
|
-
</graphicGapMatchInteraction>
|
|
40
|
-
`;
|
|
41
|
-
const element = parseQTI(xml);
|
|
42
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
43
|
-
|
|
44
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
45
|
-
|
|
46
|
-
expect(result.gapTexts).toHaveLength(3);
|
|
47
|
-
expect(result.gapTexts[0]).toEqual({ identifier: 'T1', text: 'First', matchMax: 1 });
|
|
48
|
-
expect(result.gapTexts[1]).toEqual({ identifier: 'T2', text: 'Second', matchMax: 2 });
|
|
49
|
-
expect(result.gapTexts[2]).toEqual({ identifier: 'T3', text: 'Third', matchMax: 0 });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('extracts associableHotspot elements correctly', () => {
|
|
53
|
-
const xml = `
|
|
54
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
55
|
-
<object type="image/png" data="diagram.png" />
|
|
56
|
-
<gapText identifier="T1" matchMax="1">Label</gapText>
|
|
57
|
-
<associableHotspot identifier="H1" shape="rect" coords="10,10,110,60" matchMax="1" />
|
|
58
|
-
<associableHotspot identifier="H2" shape="circle" coords="200,200,40" matchMax="2" />
|
|
59
|
-
<associableHotspot identifier="H3" shape="poly" coords="300,100,350,150,300,200" matchMax="0" />
|
|
60
|
-
</graphicGapMatchInteraction>
|
|
61
|
-
`;
|
|
62
|
-
const element = parseQTI(xml);
|
|
63
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
64
|
-
|
|
65
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
66
|
-
|
|
67
|
-
expect(result.hotspots).toHaveLength(3);
|
|
68
|
-
expect(result.hotspots[0]).toEqual({
|
|
69
|
-
identifier: 'H1',
|
|
70
|
-
shape: 'rect',
|
|
71
|
-
coords: '10,10,110,60',
|
|
72
|
-
matchMax: 1,
|
|
73
|
-
});
|
|
74
|
-
expect(result.hotspots[1]).toEqual({
|
|
75
|
-
identifier: 'H2',
|
|
76
|
-
shape: 'circle',
|
|
77
|
-
coords: '200,200,40',
|
|
78
|
-
matchMax: 2,
|
|
79
|
-
});
|
|
80
|
-
expect(result.hotspots[2]).toEqual({
|
|
81
|
-
identifier: 'H3',
|
|
82
|
-
shape: 'poly',
|
|
83
|
-
coords: '300,100,350,150,300,200',
|
|
84
|
-
matchMax: 0,
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('uses default shape for hotspots when not specified', () => {
|
|
89
|
-
const xml = `
|
|
90
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
91
|
-
<object type="image/png" data="diagram.png" />
|
|
92
|
-
<gapText identifier="T1" matchMax="1">Label</gapText>
|
|
93
|
-
<associableHotspot identifier="H1" coords="0,0,100,100" matchMax="1" />
|
|
94
|
-
</graphicGapMatchInteraction>
|
|
95
|
-
`;
|
|
96
|
-
const element = parseQTI(xml);
|
|
97
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
98
|
-
|
|
99
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
100
|
-
|
|
101
|
-
expect(result.hotspots[0].shape).toBe('rect');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test('uses default matchMax for hotspots when not specified', () => {
|
|
105
|
-
const xml = `
|
|
106
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
107
|
-
<object type="image/png" data="diagram.png" />
|
|
108
|
-
<gapText identifier="T1" matchMax="1">Label</gapText>
|
|
109
|
-
<associableHotspot identifier="H1" shape="rect" coords="0,0,100,100" />
|
|
110
|
-
</graphicGapMatchInteraction>
|
|
111
|
-
`;
|
|
112
|
-
const element = parseQTI(xml);
|
|
113
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
114
|
-
|
|
115
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
116
|
-
|
|
117
|
-
expect(result.hotspots[0].matchMax).toBe(1);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test('handles SVG image data', () => {
|
|
121
|
-
const xml = `
|
|
122
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
123
|
-
<object type="image/svg+xml" width="500" height="300">
|
|
124
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
|
125
|
-
<rect x="10" y="10" width="100" height="50" />
|
|
126
|
-
</svg>
|
|
127
|
-
</object>
|
|
128
|
-
<gapText identifier="T1" matchMax="1">Label</gapText>
|
|
129
|
-
<associableHotspot identifier="H1" shape="rect" coords="10,10,110,60" matchMax="1" />
|
|
130
|
-
</graphicGapMatchInteraction>
|
|
131
|
-
`;
|
|
132
|
-
const element = parseQTI(xml);
|
|
133
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
134
|
-
|
|
135
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
136
|
-
|
|
137
|
-
expect(result.imageData).not.toBe(null);
|
|
138
|
-
expect(result.imageData?.type).toBe('svg');
|
|
139
|
-
expect(result.imageData?.content).toContain('rect');
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test('handles interaction without prompt', () => {
|
|
143
|
-
const xml = `
|
|
144
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
145
|
-
<object type="image/png" data="diagram.png" />
|
|
146
|
-
<gapText identifier="T1" matchMax="1">Label</gapText>
|
|
147
|
-
<associableHotspot identifier="H1" shape="rect" coords="0,0,100,100" matchMax="1" />
|
|
148
|
-
</graphicGapMatchInteraction>
|
|
149
|
-
`;
|
|
150
|
-
const element = parseQTI(xml);
|
|
151
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
152
|
-
|
|
153
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
154
|
-
|
|
155
|
-
expect(result.prompt).toBe(null);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test('handles interaction without object element', () => {
|
|
159
|
-
const xml = `
|
|
160
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
161
|
-
<gapText identifier="T1" matchMax="1">Label</gapText>
|
|
162
|
-
<associableHotspot identifier="H1" shape="rect" coords="0,0,100,100" matchMax="1" />
|
|
163
|
-
</graphicGapMatchInteraction>
|
|
164
|
-
`;
|
|
165
|
-
const element = parseQTI(xml);
|
|
166
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
167
|
-
|
|
168
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
169
|
-
|
|
170
|
-
expect(result.imageData).toBe(null);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test('handles gapText with HTML content', () => {
|
|
174
|
-
const xml = `
|
|
175
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
176
|
-
<object type="image/png" data="diagram.png" />
|
|
177
|
-
<gapText identifier="T1" matchMax="1">Label with <strong>bold</strong></gapText>
|
|
178
|
-
<gapText identifier="T2" matchMax="1">Label with <em>italic</em></gapText>
|
|
179
|
-
<associableHotspot identifier="H1" shape="rect" coords="0,0,100,100" matchMax="1" />
|
|
180
|
-
</graphicGapMatchInteraction>
|
|
181
|
-
`;
|
|
182
|
-
const element = parseQTI(xml);
|
|
183
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
184
|
-
|
|
185
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
186
|
-
|
|
187
|
-
expect(result.gapTexts[0].text).toContain('bold');
|
|
188
|
-
expect(result.gapTexts[1].text).toContain('italic');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('handles many gapTexts and hotspots', () => {
|
|
192
|
-
const xml = `
|
|
193
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
194
|
-
<object type="image/png" data="diagram.png" />
|
|
195
|
-
<gapText identifier="T1" matchMax="1">A</gapText>
|
|
196
|
-
<gapText identifier="T2" matchMax="1">B</gapText>
|
|
197
|
-
<gapText identifier="T3" matchMax="1">C</gapText>
|
|
198
|
-
<gapText identifier="T4" matchMax="1">D</gapText>
|
|
199
|
-
<associableHotspot identifier="H1" shape="rect" coords="0,0,50,50" matchMax="1" />
|
|
200
|
-
<associableHotspot identifier="H2" shape="rect" coords="60,0,110,50" matchMax="1" />
|
|
201
|
-
<associableHotspot identifier="H3" shape="rect" coords="120,0,170,50" matchMax="1" />
|
|
202
|
-
<associableHotspot identifier="H4" shape="rect" coords="180,0,230,50" matchMax="1" />
|
|
203
|
-
</graphicGapMatchInteraction>
|
|
204
|
-
`;
|
|
205
|
-
const element = parseQTI(xml);
|
|
206
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
207
|
-
|
|
208
|
-
const result = standardGraphicGapMatchExtractor.extract(element, context);
|
|
209
|
-
|
|
210
|
-
expect(result.gapTexts).toHaveLength(4);
|
|
211
|
-
expect(result.hotspots).toHaveLength(4);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('canHandle predicate', () => {
|
|
215
|
-
test('handles graphicGapMatchInteraction element', () => {
|
|
216
|
-
const xml = `
|
|
217
|
-
<graphicGapMatchInteraction responseIdentifier="RESPONSE">
|
|
218
|
-
<gapText identifier="T1">Text</gapText>
|
|
219
|
-
<associableHotspot identifier="H1" />
|
|
220
|
-
</graphicGapMatchInteraction>
|
|
221
|
-
`;
|
|
222
|
-
const element = parseQTI(xml);
|
|
223
|
-
const context = createTestContext(element);
|
|
224
|
-
|
|
225
|
-
expect(standardGraphicGapMatchExtractor.canHandle(element, context)).toBe(true);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test('rejects non-graphicGapMatchInteraction elements', () => {
|
|
229
|
-
const xml = `<choiceInteraction responseIdentifier="RESPONSE" />`;
|
|
230
|
-
const element = parseQTI(xml);
|
|
231
|
-
const context = createTestContext(element);
|
|
232
|
-
|
|
233
|
-
expect(standardGraphicGapMatchExtractor.canHandle(element, context)).toBe(false);
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
describe('validation', () => {
|
|
238
|
-
test('validates correct graphicGapMatch data', () => {
|
|
239
|
-
const data = {
|
|
240
|
-
gapTexts: [
|
|
241
|
-
{ identifier: 'T1', text: 'Label 1', matchMax: 1 },
|
|
242
|
-
{ identifier: 'T2', text: 'Label 2', matchMax: 1 },
|
|
243
|
-
],
|
|
244
|
-
hotspots: [
|
|
245
|
-
{ identifier: 'H1', shape: 'rect', coords: '0,0,100,100', matchMax: 1 },
|
|
246
|
-
{ identifier: 'H2', shape: 'circle', coords: '200,200,50', matchMax: 1 },
|
|
247
|
-
],
|
|
248
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
249
|
-
prompt: null,
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const validation = standardGraphicGapMatchExtractor.validate!(data);
|
|
253
|
-
|
|
254
|
-
expect(validation.valid).toBe(true);
|
|
255
|
-
expect(validation.errors).toBeUndefined();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
test('reports error for empty gapTexts', () => {
|
|
259
|
-
const data = {
|
|
260
|
-
gapTexts: [],
|
|
261
|
-
hotspots: [{ identifier: 'H1', shape: 'rect', coords: '0,0,100,100', matchMax: 1 }],
|
|
262
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
263
|
-
prompt: null,
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const validation = standardGraphicGapMatchExtractor.validate!(data);
|
|
267
|
-
|
|
268
|
-
expect(validation.valid).toBe(false);
|
|
269
|
-
expect(validation.errors).toContain('graphicGapMatchInteraction must have at least one gapText');
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
test('reports error for empty hotspots', () => {
|
|
273
|
-
const data = {
|
|
274
|
-
gapTexts: [{ identifier: 'T1', text: 'Label', matchMax: 1 }],
|
|
275
|
-
hotspots: [],
|
|
276
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
277
|
-
prompt: null,
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
const validation = standardGraphicGapMatchExtractor.validate!(data);
|
|
281
|
-
|
|
282
|
-
expect(validation.valid).toBe(false);
|
|
283
|
-
expect(validation.errors).toContain('graphicGapMatchInteraction must have at least one hotspot');
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
test('reports error for duplicate gapText identifiers', () => {
|
|
287
|
-
const data = {
|
|
288
|
-
gapTexts: [
|
|
289
|
-
{ identifier: 'T1', text: 'Label 1', matchMax: 1 },
|
|
290
|
-
{ identifier: 'T1', text: 'Label 2', matchMax: 1 },
|
|
291
|
-
],
|
|
292
|
-
hotspots: [{ identifier: 'H1', shape: 'rect', coords: '0,0,100,100', matchMax: 1 }],
|
|
293
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
294
|
-
prompt: null,
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
const validation = standardGraphicGapMatchExtractor.validate!(data);
|
|
298
|
-
|
|
299
|
-
expect(validation.valid).toBe(false);
|
|
300
|
-
expect(validation.errors).toContain('Duplicate gapText identifier: T1');
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
test('reports error for duplicate hotspot identifiers', () => {
|
|
304
|
-
const data = {
|
|
305
|
-
gapTexts: [{ identifier: 'T1', text: 'Label', matchMax: 1 }],
|
|
306
|
-
hotspots: [
|
|
307
|
-
{ identifier: 'H1', shape: 'rect', coords: '0,0,100,100', matchMax: 1 },
|
|
308
|
-
{ identifier: 'H1', shape: 'circle', coords: '200,200,50', matchMax: 1 },
|
|
309
|
-
],
|
|
310
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
311
|
-
prompt: null,
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
const validation = standardGraphicGapMatchExtractor.validate!(data);
|
|
315
|
-
|
|
316
|
-
expect(validation.valid).toBe(false);
|
|
317
|
-
expect(validation.errors).toContain('Duplicate hotspot identifier: H1');
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
});
|