@pie-qti/item-player 0.1.1 → 0.1.4
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 +1 -1
- 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 +119 -0
- package/dist/core/ComponentRegistry.d.ts.map +1 -0
- package/dist/core/ComponentRegistry.js +123 -0
- package/dist/core/ItemRenderer.d.ts +91 -0
- package/dist/core/ItemRenderer.d.ts.map +1 -0
- package/dist/core/ItemRenderer.js +258 -0
- package/dist/core/Player.d.ts +143 -0
- package/dist/core/Player.d.ts.map +1 -0
- package/dist/core/Player.js +1081 -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/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 +87 -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 +258 -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 +28 -0
- package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/associateExtractor.js +94 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts +25 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/choiceExtractor.js +83 -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 +57 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts +28 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/gapMatchExtractor.js +142 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +40 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.js +140 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +42 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.js +144 -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 +140 -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 +120 -0
- package/dist/extraction/extractors/index.d.ts +62 -0
- package/dist/extraction/extractors/index.d.ts.map +1 -0
- package/dist/extraction/extractors/index.js +84 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +22 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.js +67 -0
- package/dist/extraction/extractors/matchExtractor.d.ts +32 -0
- package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/matchExtractor.js +134 -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 +26 -0
- package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/orderExtractor.js +86 -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 +20 -0
- package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/textEntryExtractor.js +48 -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 +52 -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 +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -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 +290 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/interactions.d.ts +323 -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 +94 -76
- 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/components/ItemBody.svelte +3 -1
- package/src/components/utils/assignProps.ts +1 -23
- package/src/core/Player.ts +138 -34
- package/src/core/parsingLimits.ts +1 -1
- package/src/extensions/MathLiveEditor.ts +6 -3
- package/src/extraction/ExtractionRegistry.ts +46 -10
- package/src/extraction/createContext.ts +6 -1
- package/src/extraction/extractors/extendedTextExtractor.ts +5 -2
- package/src/extraction/extractors/matchExtractor.ts +2 -2
- package/src/extraction/extractors/textEntryExtractor.ts +4 -2
- package/src/extraction/utils.ts +99 -16
- package/src/index.ts +2 -0
- package/src/types/index.ts +28 -8
- 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,212 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for standardOrderExtractor
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, expect, test } from 'bun:test';
|
|
6
|
-
import { standardOrderExtractor } from '../../../src/extraction/extractors/orderExtractor.js';
|
|
7
|
-
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
-
|
|
9
|
-
describe('standardOrderExtractor', () => {
|
|
10
|
-
test('extracts basic order interaction', () => {
|
|
11
|
-
const xml = `
|
|
12
|
-
<orderInteraction responseIdentifier="RESPONSE" shuffle="true">
|
|
13
|
-
<prompt>Arrange the following in chronological order</prompt>
|
|
14
|
-
<simpleChoice identifier="A">American Revolution</simpleChoice>
|
|
15
|
-
<simpleChoice identifier="B">French Revolution</simpleChoice>
|
|
16
|
-
<simpleChoice identifier="C">Industrial Revolution</simpleChoice>
|
|
17
|
-
</orderInteraction>
|
|
18
|
-
`;
|
|
19
|
-
const element = parseQTI(xml);
|
|
20
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
21
|
-
|
|
22
|
-
const result = standardOrderExtractor.extract(element, context);
|
|
23
|
-
|
|
24
|
-
expect(result.shuffle).toBe(true);
|
|
25
|
-
expect(result.prompt).toBe('Arrange the following in chronological order');
|
|
26
|
-
expect(result.choices).toHaveLength(3);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('extracts choices correctly', () => {
|
|
30
|
-
const xml = `
|
|
31
|
-
<orderInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
32
|
-
<simpleChoice identifier="FIRST">First item</simpleChoice>
|
|
33
|
-
<simpleChoice identifier="SECOND">Second item</simpleChoice>
|
|
34
|
-
<simpleChoice identifier="THIRD">Third item</simpleChoice>
|
|
35
|
-
</orderInteraction>
|
|
36
|
-
`;
|
|
37
|
-
const element = parseQTI(xml);
|
|
38
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
39
|
-
|
|
40
|
-
const result = standardOrderExtractor.extract(element, context);
|
|
41
|
-
|
|
42
|
-
expect(result.choices[0]).toEqual({ identifier: 'FIRST', text: 'First item' });
|
|
43
|
-
expect(result.choices[1]).toEqual({ identifier: 'SECOND', text: 'Second item' });
|
|
44
|
-
expect(result.choices[2]).toEqual({ identifier: 'THIRD', text: 'Third item' });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('handles interaction without prompt', () => {
|
|
48
|
-
const xml = `
|
|
49
|
-
<orderInteraction responseIdentifier="RESPONSE" shuffle="true">
|
|
50
|
-
<simpleChoice identifier="A">Item A</simpleChoice>
|
|
51
|
-
<simpleChoice identifier="B">Item B</simpleChoice>
|
|
52
|
-
</orderInteraction>
|
|
53
|
-
`;
|
|
54
|
-
const element = parseQTI(xml);
|
|
55
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
56
|
-
|
|
57
|
-
const result = standardOrderExtractor.extract(element, context);
|
|
58
|
-
|
|
59
|
-
expect(result.prompt).toBe(null);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('uses default shuffle value when not specified', () => {
|
|
63
|
-
const xml = `
|
|
64
|
-
<orderInteraction responseIdentifier="RESPONSE">
|
|
65
|
-
<simpleChoice identifier="A">Item A</simpleChoice>
|
|
66
|
-
</orderInteraction>
|
|
67
|
-
`;
|
|
68
|
-
const element = parseQTI(xml);
|
|
69
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
70
|
-
|
|
71
|
-
const result = standardOrderExtractor.extract(element, context);
|
|
72
|
-
|
|
73
|
-
expect(result.shuffle).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('handles choices with HTML content', () => {
|
|
77
|
-
const xml = `
|
|
78
|
-
<orderInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
79
|
-
<simpleChoice identifier="A">Step <strong>1</strong>: Preparation</simpleChoice>
|
|
80
|
-
<simpleChoice identifier="B">Step <strong>2</strong>: Execution</simpleChoice>
|
|
81
|
-
</orderInteraction>
|
|
82
|
-
`;
|
|
83
|
-
const element = parseQTI(xml);
|
|
84
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
85
|
-
|
|
86
|
-
const result = standardOrderExtractor.extract(element, context);
|
|
87
|
-
|
|
88
|
-
expect(result.choices[0].text).toContain('Preparation');
|
|
89
|
-
expect(result.choices[1].text).toContain('Execution');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('handles large number of items', () => {
|
|
93
|
-
let xml = '<orderInteraction responseIdentifier="RESPONSE" shuffle="true">';
|
|
94
|
-
for (let i = 1; i <= 10; i++) {
|
|
95
|
-
xml += `<simpleChoice identifier="ITEM_${i}">Item ${i}</simpleChoice>`;
|
|
96
|
-
}
|
|
97
|
-
xml += '</orderInteraction>';
|
|
98
|
-
|
|
99
|
-
const element = parseQTI(xml);
|
|
100
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
101
|
-
|
|
102
|
-
const result = standardOrderExtractor.extract(element, context);
|
|
103
|
-
|
|
104
|
-
expect(result.choices).toHaveLength(10);
|
|
105
|
-
expect(result.choices[0].identifier).toBe('ITEM_1');
|
|
106
|
-
expect(result.choices[9].identifier).toBe('ITEM_10');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('canHandle predicate', () => {
|
|
110
|
-
test('handles orderInteraction element', () => {
|
|
111
|
-
const xml = `
|
|
112
|
-
<orderInteraction responseIdentifier="RESPONSE">
|
|
113
|
-
<simpleChoice identifier="A">Item A</simpleChoice>
|
|
114
|
-
</orderInteraction>
|
|
115
|
-
`;
|
|
116
|
-
const element = parseQTI(xml);
|
|
117
|
-
const context = createTestContext(element);
|
|
118
|
-
|
|
119
|
-
expect(standardOrderExtractor.canHandle(element, context)).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('rejects non-orderInteraction elements', () => {
|
|
123
|
-
const xml = `<choiceInteraction responseIdentifier="RESPONSE" />`;
|
|
124
|
-
const element = parseQTI(xml);
|
|
125
|
-
const context = createTestContext(element);
|
|
126
|
-
|
|
127
|
-
expect(standardOrderExtractor.canHandle(element, context)).toBe(false);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
describe('validation', () => {
|
|
132
|
-
test('validates correct order data', () => {
|
|
133
|
-
const data = {
|
|
134
|
-
choices: [
|
|
135
|
-
{ identifier: 'A', text: 'Item A' },
|
|
136
|
-
{ identifier: 'B', text: 'Item B' },
|
|
137
|
-
],
|
|
138
|
-
shuffle: false,
|
|
139
|
-
prompt: null,
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const validation = standardOrderExtractor.validate!(data);
|
|
143
|
-
|
|
144
|
-
expect(validation.valid).toBe(true);
|
|
145
|
-
expect(validation.errors).toBeUndefined();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
test('reports error for insufficient choices', () => {
|
|
149
|
-
const data = {
|
|
150
|
-
choices: [{ identifier: 'A', text: 'Item A' }],
|
|
151
|
-
shuffle: false,
|
|
152
|
-
prompt: null,
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const validation = standardOrderExtractor.validate!(data);
|
|
156
|
-
|
|
157
|
-
expect(validation.valid).toBe(false);
|
|
158
|
-
expect(validation.errors).toContain('orderInteraction must have at least 2 choices');
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('reports error for missing identifiers', () => {
|
|
162
|
-
const data = {
|
|
163
|
-
choices: [
|
|
164
|
-
{ identifier: 'A', text: 'Item A' },
|
|
165
|
-
{ identifier: '', text: 'Item B' },
|
|
166
|
-
],
|
|
167
|
-
shuffle: false,
|
|
168
|
-
prompt: null,
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const validation = standardOrderExtractor.validate!(data);
|
|
172
|
-
|
|
173
|
-
expect(validation.valid).toBe(false);
|
|
174
|
-
expect(validation.errors).toContain('All choices must have an identifier');
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test('reports error for duplicate identifiers', () => {
|
|
178
|
-
const data = {
|
|
179
|
-
choices: [
|
|
180
|
-
{ identifier: 'A', text: 'Item A' },
|
|
181
|
-
{ identifier: 'A', text: 'Item B' },
|
|
182
|
-
],
|
|
183
|
-
shuffle: false,
|
|
184
|
-
prompt: null,
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const validation = standardOrderExtractor.validate!(data);
|
|
188
|
-
|
|
189
|
-
expect(validation.valid).toBe(false);
|
|
190
|
-
expect(validation.errors).toContain('Duplicate choice identifier: A');
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
test('reports warning for too many choices', () => {
|
|
194
|
-
const choices = [];
|
|
195
|
-
for (let i = 1; i <= 15; i++) {
|
|
196
|
-
choices.push({ identifier: `ITEM_${i}`, text: `Item ${i}` });
|
|
197
|
-
}
|
|
198
|
-
const data = {
|
|
199
|
-
choices,
|
|
200
|
-
shuffle: false,
|
|
201
|
-
prompt: null,
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const validation = standardOrderExtractor.validate!(data);
|
|
205
|
-
|
|
206
|
-
expect(validation.valid).toBe(true);
|
|
207
|
-
expect(validation.warnings).toContain(
|
|
208
|
-
'orderInteraction has 15 choices - this may be difficult for users to order'
|
|
209
|
-
);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
});
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for standardPositionObjectExtractor
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, expect, test } from 'bun:test';
|
|
6
|
-
import { standardPositionObjectExtractor } from '../../../src/extraction/extractors/positionObjectExtractor.js';
|
|
7
|
-
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
-
|
|
9
|
-
describe('standardPositionObjectExtractor', () => {
|
|
10
|
-
test('extracts positionObjectInteraction with image background', () => {
|
|
11
|
-
const xml = `
|
|
12
|
-
<positionObjectInteraction responseIdentifier="RESPONSE" maxChoices="3">
|
|
13
|
-
<prompt>Position the objects on the map</prompt>
|
|
14
|
-
<object data="map.png" type="image/png" width="600" height="400"/>
|
|
15
|
-
<positionObjectStage identifier="CITY1" matchMax="1">
|
|
16
|
-
<object data="city-icon.png" type="image/png" width="30" height="30"/>
|
|
17
|
-
City 1
|
|
18
|
-
</positionObjectStage>
|
|
19
|
-
<positionObjectStage identifier="CITY2" matchMax="1">
|
|
20
|
-
<object data="city-icon.png" type="image/png" width="30" height="30"/>
|
|
21
|
-
City 2
|
|
22
|
-
</positionObjectStage>
|
|
23
|
-
</positionObjectInteraction>
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const element = parseQTI(xml);
|
|
27
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
28
|
-
|
|
29
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
30
|
-
|
|
31
|
-
expect(result.prompt).toBe('Position the objects on the map');
|
|
32
|
-
expect(result.maxChoices).toBe(3);
|
|
33
|
-
expect(result.minChoices).toBe(0);
|
|
34
|
-
expect(result.centerPoint).toBe(true);
|
|
35
|
-
expect(result.imageData?.type).toBe('image');
|
|
36
|
-
expect(result.imageData?.src).toBe('map.png');
|
|
37
|
-
expect(result.imageData?.width).toBe('600');
|
|
38
|
-
expect(result.imageData?.height).toBe('400');
|
|
39
|
-
expect(result.positionObjectStages).toHaveLength(2);
|
|
40
|
-
expect(result.positionObjectStages[0].identifier).toBe('CITY1');
|
|
41
|
-
expect(result.positionObjectStages[0].label).toContain('City 1');
|
|
42
|
-
expect(result.positionObjectStages[0].matchMax).toBe(1);
|
|
43
|
-
expect(result.positionObjectStages[0].objectData?.type).toBe('image');
|
|
44
|
-
expect(result.positionObjectStages[0].objectData?.src).toBe('city-icon.png');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('extracts positionObjectInteraction with SVG background', () => {
|
|
48
|
-
const xml = `
|
|
49
|
-
<positionObjectInteraction responseIdentifier="RESPONSE">
|
|
50
|
-
<prompt>Place the elements</prompt>
|
|
51
|
-
<object type="image/svg+xml" width="500" height="300">
|
|
52
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 300">
|
|
53
|
-
<rect width="500" height="300" fill="#eee"/>
|
|
54
|
-
</svg>
|
|
55
|
-
</object>
|
|
56
|
-
<positionObjectStage identifier="ELEM1">
|
|
57
|
-
<object data="elem.png" type="image/png"/>
|
|
58
|
-
Element
|
|
59
|
-
</positionObjectStage>
|
|
60
|
-
</positionObjectInteraction>
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
const element = parseQTI(xml);
|
|
64
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
65
|
-
|
|
66
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
67
|
-
|
|
68
|
-
expect(result.imageData?.type).toBe('svg');
|
|
69
|
-
expect(result.imageData?.content).toContain('<svg');
|
|
70
|
-
expect(result.imageData?.width).toBe('500');
|
|
71
|
-
expect(result.imageData?.height).toBe('300');
|
|
72
|
-
expect(result.positionObjectStages).toHaveLength(1);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('extracts positionObjectInteraction with SVG objects', () => {
|
|
76
|
-
const xml = `
|
|
77
|
-
<positionObjectInteraction responseIdentifier="RESPONSE">
|
|
78
|
-
<object data="background.png" type="image/png"/>
|
|
79
|
-
<positionObjectStage identifier="SHAPE1" matchMax="3">
|
|
80
|
-
<object type="image/svg+xml" width="40" height="40">
|
|
81
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
82
|
-
<circle cx="20" cy="20" r="18" fill="blue"/>
|
|
83
|
-
</svg>
|
|
84
|
-
</object>
|
|
85
|
-
Blue Circle
|
|
86
|
-
</positionObjectStage>
|
|
87
|
-
</positionObjectInteraction>
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
|
-
const element = parseQTI(xml);
|
|
91
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
92
|
-
|
|
93
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
94
|
-
|
|
95
|
-
expect(result.positionObjectStages[0].objectData?.type).toBe('svg');
|
|
96
|
-
expect(result.positionObjectStages[0].objectData?.content).toContain('<circle');
|
|
97
|
-
expect(result.positionObjectStages[0].objectData?.width).toBe('40');
|
|
98
|
-
expect(result.positionObjectStages[0].objectData?.height).toBe('40');
|
|
99
|
-
expect(result.positionObjectStages[0].matchMax).toBe(3);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('handles minChoices and maxChoices attributes', () => {
|
|
103
|
-
const xml = `
|
|
104
|
-
<positionObjectInteraction responseIdentifier="RESPONSE" minChoices="2" maxChoices="5">
|
|
105
|
-
<object data="test.png" type="image/png"/>
|
|
106
|
-
<positionObjectStage identifier="OBJ1">Object 1</positionObjectStage>
|
|
107
|
-
</positionObjectInteraction>
|
|
108
|
-
`;
|
|
109
|
-
|
|
110
|
-
const element = parseQTI(xml);
|
|
111
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
112
|
-
|
|
113
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
114
|
-
|
|
115
|
-
expect(result.minChoices).toBe(2);
|
|
116
|
-
expect(result.maxChoices).toBe(5);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('handles centerPoint attribute', () => {
|
|
120
|
-
const xml = `
|
|
121
|
-
<positionObjectInteraction responseIdentifier="RESPONSE" centerPoint="false">
|
|
122
|
-
<object data="test.png" type="image/png"/>
|
|
123
|
-
<positionObjectStage identifier="OBJ1">Object 1</positionObjectStage>
|
|
124
|
-
</positionObjectInteraction>
|
|
125
|
-
`;
|
|
126
|
-
|
|
127
|
-
const element = parseQTI(xml);
|
|
128
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
129
|
-
|
|
130
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
131
|
-
|
|
132
|
-
expect(result.centerPoint).toBe(false);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('uses default values when attributes are missing', () => {
|
|
136
|
-
const xml = `
|
|
137
|
-
<positionObjectInteraction responseIdentifier="RESPONSE">
|
|
138
|
-
<object data="test.png" type="image/png"/>
|
|
139
|
-
<positionObjectStage identifier="OBJ1">
|
|
140
|
-
<object data="obj.png" type="image/png"/>
|
|
141
|
-
Object
|
|
142
|
-
</positionObjectStage>
|
|
143
|
-
</positionObjectInteraction>
|
|
144
|
-
`;
|
|
145
|
-
|
|
146
|
-
const element = parseQTI(xml);
|
|
147
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
148
|
-
|
|
149
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
150
|
-
|
|
151
|
-
expect(result.maxChoices).toBe(0);
|
|
152
|
-
expect(result.minChoices).toBe(0);
|
|
153
|
-
expect(result.centerPoint).toBe(true);
|
|
154
|
-
expect(result.imageData?.width).toBe('500');
|
|
155
|
-
expect(result.imageData?.height).toBe('300');
|
|
156
|
-
expect(result.positionObjectStages[0].matchMax).toBe(1);
|
|
157
|
-
expect(result.positionObjectStages[0].objectData?.width).toBe('50');
|
|
158
|
-
expect(result.positionObjectStages[0].objectData?.height).toBe('50');
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('uses identifier as label if text content is empty', () => {
|
|
162
|
-
const xml = `
|
|
163
|
-
<positionObjectInteraction responseIdentifier="RESPONSE">
|
|
164
|
-
<object data="test.png" type="image/png"/>
|
|
165
|
-
<positionObjectStage identifier="OBJECT_ONE">
|
|
166
|
-
<object data="obj.png" type="image/png"/>
|
|
167
|
-
</positionObjectStage>
|
|
168
|
-
</positionObjectInteraction>
|
|
169
|
-
`;
|
|
170
|
-
|
|
171
|
-
const element = parseQTI(xml);
|
|
172
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
173
|
-
|
|
174
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
175
|
-
|
|
176
|
-
expect(result.positionObjectStages[0].label).toBe('OBJECT_ONE');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test('handles missing prompt', () => {
|
|
180
|
-
const xml = `
|
|
181
|
-
<positionObjectInteraction responseIdentifier="RESPONSE">
|
|
182
|
-
<object data="test.png" type="image/png"/>
|
|
183
|
-
<positionObjectStage identifier="OBJ1">Object</positionObjectStage>
|
|
184
|
-
</positionObjectInteraction>
|
|
185
|
-
`;
|
|
186
|
-
|
|
187
|
-
const element = parseQTI(xml);
|
|
188
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
189
|
-
|
|
190
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
191
|
-
|
|
192
|
-
expect(result.prompt).toBeNull();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test('handles multiple objects with different matchMax values', () => {
|
|
196
|
-
const xml = `
|
|
197
|
-
<positionObjectInteraction responseIdentifier="RESPONSE" maxChoices="10">
|
|
198
|
-
<object data="canvas.png" type="image/png"/>
|
|
199
|
-
<positionObjectStage identifier="SINGLE_USE" matchMax="1">
|
|
200
|
-
<object data="obj1.png" type="image/png"/>
|
|
201
|
-
Single Use
|
|
202
|
-
</positionObjectStage>
|
|
203
|
-
<positionObjectStage identifier="MULTI_USE" matchMax="5">
|
|
204
|
-
<object data="obj2.png" type="image/png"/>
|
|
205
|
-
Multi Use
|
|
206
|
-
</positionObjectStage>
|
|
207
|
-
</positionObjectInteraction>
|
|
208
|
-
`;
|
|
209
|
-
|
|
210
|
-
const element = parseQTI(xml);
|
|
211
|
-
const context = createTestContext(element, 'RESPONSE');
|
|
212
|
-
|
|
213
|
-
const result = standardPositionObjectExtractor.extract(element, context);
|
|
214
|
-
|
|
215
|
-
expect(result.positionObjectStages).toHaveLength(2);
|
|
216
|
-
expect(result.positionObjectStages[0].matchMax).toBe(1);
|
|
217
|
-
expect(result.positionObjectStages[1].matchMax).toBe(5);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
describe('canHandle predicate', () => {
|
|
221
|
-
test('handles positionObjectInteraction element', () => {
|
|
222
|
-
const xml = `
|
|
223
|
-
<positionObjectInteraction responseIdentifier="RESPONSE">
|
|
224
|
-
<positionObjectStage identifier="OBJ1">Object</positionObjectStage>
|
|
225
|
-
</positionObjectInteraction>
|
|
226
|
-
`;
|
|
227
|
-
const element = parseQTI(xml);
|
|
228
|
-
const context = createTestContext(element);
|
|
229
|
-
|
|
230
|
-
expect(standardPositionObjectExtractor.canHandle(element, context)).toBe(true);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
test('rejects non-positionObjectInteraction elements', () => {
|
|
234
|
-
const xml = `<selectPointInteraction responseIdentifier="RESPONSE" />`;
|
|
235
|
-
const element = parseQTI(xml);
|
|
236
|
-
const context = createTestContext(element);
|
|
237
|
-
|
|
238
|
-
expect(standardPositionObjectExtractor.canHandle(element, context)).toBe(false);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
describe('validation', () => {
|
|
243
|
-
test('validates correct positionObject data', () => {
|
|
244
|
-
const data = {
|
|
245
|
-
positionObjectStages: [
|
|
246
|
-
{
|
|
247
|
-
identifier: 'OBJ1',
|
|
248
|
-
label: 'Object 1',
|
|
249
|
-
matchMax: 1,
|
|
250
|
-
objectData: { type: 'image', src: 'obj.png', width: '50', height: '50' },
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
254
|
-
maxChoices: 0,
|
|
255
|
-
minChoices: 0,
|
|
256
|
-
centerPoint: true,
|
|
257
|
-
prompt: null,
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const validation = standardPositionObjectExtractor.validate!(data);
|
|
261
|
-
|
|
262
|
-
expect(validation.valid).toBe(true);
|
|
263
|
-
expect(validation.errors).toBeUndefined();
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
test('reports error for empty positionObjectStages', () => {
|
|
267
|
-
const data = {
|
|
268
|
-
positionObjectStages: [],
|
|
269
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
270
|
-
maxChoices: 0,
|
|
271
|
-
minChoices: 0,
|
|
272
|
-
centerPoint: true,
|
|
273
|
-
prompt: null,
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const validation = standardPositionObjectExtractor.validate!(data);
|
|
277
|
-
|
|
278
|
-
expect(validation.valid).toBe(false);
|
|
279
|
-
expect(validation.errors).toContain(
|
|
280
|
-
'positionObjectInteraction must have at least one positionObjectStage'
|
|
281
|
-
);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
test('reports error for duplicate identifiers', () => {
|
|
285
|
-
const data = {
|
|
286
|
-
positionObjectStages: [
|
|
287
|
-
{
|
|
288
|
-
identifier: 'OBJ1',
|
|
289
|
-
label: 'Object 1',
|
|
290
|
-
matchMax: 1,
|
|
291
|
-
objectData: { type: 'image', src: 'obj.png', width: '50', height: '50' },
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
identifier: 'OBJ1',
|
|
295
|
-
label: 'Object 2',
|
|
296
|
-
matchMax: 1,
|
|
297
|
-
objectData: { type: 'image', src: 'obj.png', width: '50', height: '50' },
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
301
|
-
maxChoices: 0,
|
|
302
|
-
minChoices: 0,
|
|
303
|
-
centerPoint: true,
|
|
304
|
-
prompt: null,
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const validation = standardPositionObjectExtractor.validate!(data);
|
|
308
|
-
|
|
309
|
-
expect(validation.valid).toBe(false);
|
|
310
|
-
expect(validation.errors).toContain('Duplicate positionObjectStage identifier: OBJ1');
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
test('reports warning for missing background image', () => {
|
|
314
|
-
const data = {
|
|
315
|
-
positionObjectStages: [
|
|
316
|
-
{
|
|
317
|
-
identifier: 'OBJ1',
|
|
318
|
-
label: 'Object 1',
|
|
319
|
-
matchMax: 1,
|
|
320
|
-
objectData: { type: 'image', src: 'obj.png', width: '50', height: '50' },
|
|
321
|
-
},
|
|
322
|
-
],
|
|
323
|
-
imageData: null,
|
|
324
|
-
maxChoices: 0,
|
|
325
|
-
minChoices: 0,
|
|
326
|
-
centerPoint: true,
|
|
327
|
-
prompt: null,
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
const validation = standardPositionObjectExtractor.validate!(data);
|
|
331
|
-
|
|
332
|
-
expect(validation.valid).toBe(true);
|
|
333
|
-
expect(validation.warnings).toContain('positionObjectInteraction has no background image');
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
test('reports warning about dimension consistency for image backgrounds', () => {
|
|
337
|
-
const data = {
|
|
338
|
-
positionObjectStages: [
|
|
339
|
-
{
|
|
340
|
-
identifier: 'OBJ1',
|
|
341
|
-
label: 'Object 1',
|
|
342
|
-
matchMax: 1,
|
|
343
|
-
objectData: { type: 'image', src: 'obj.png', width: '50', height: '50' },
|
|
344
|
-
},
|
|
345
|
-
],
|
|
346
|
-
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
347
|
-
maxChoices: 0,
|
|
348
|
-
minChoices: 0,
|
|
349
|
-
centerPoint: true,
|
|
350
|
-
prompt: null,
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const validation = standardPositionObjectExtractor.validate!(data);
|
|
354
|
-
|
|
355
|
-
expect(validation.valid).toBe(true);
|
|
356
|
-
expect(validation.warnings).toBeDefined();
|
|
357
|
-
expect(validation.warnings?.some((w) => w.includes('declared width/height match'))).toBe(
|
|
358
|
-
true
|
|
359
|
-
);
|
|
360
|
-
expect(validation.warnings?.some((w) => w.includes('Declared: 500×400'))).toBe(true);
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
});
|