@pie-qti/item-player 0.1.1
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/.turbo/turbo-build.log +1 -0
- package/CHANGELOG.md +9 -0
- package/README.md +466 -0
- package/docs/QTI-COMPLIANCE.md +197 -0
- package/docs/WCAG-2.2-COMPLIANCE.md +466 -0
- package/docs/custom-extractors.md +679 -0
- package/docs/iframe-mode.md +78 -0
- package/docs/security-audit.md +236 -0
- package/docs/server-api.md +691 -0
- package/package.json +78 -0
- package/src/components/ItemBody.svelte +382 -0
- package/src/components/ItemPlayer.svelte +155 -0
- package/src/components/ModalFeedbackDisplay.svelte +87 -0
- package/src/components/actions/typesetAction.ts +74 -0
- package/src/components/index.ts +19 -0
- package/src/components/utils/assignProps.ts +24 -0
- package/src/components/utils/feedbackUtils.ts +140 -0
- package/src/components/utils/index.ts +13 -0
- package/src/core/ComponentRegistry.ts +219 -0
- package/src/core/ItemRenderer.ts +367 -0
- package/src/core/Player.ts +1152 -0
- package/src/core/Plugin.ts +123 -0
- package/src/core/PluginManager.ts +182 -0
- package/src/core/constants.ts +117 -0
- package/src/core/declarations.ts +171 -0
- package/src/core/parsingLimits.ts +62 -0
- package/src/core/random.ts +24 -0
- package/src/core/sanitizer.ts +235 -0
- package/src/core/trustedTypes.ts +63 -0
- package/src/core/urlPolicy.ts +95 -0
- package/src/extensions/MathLiveEditor.ts +310 -0
- package/src/extraction/ExtractionRegistry.ts +295 -0
- package/src/extraction/createContext.ts +47 -0
- package/src/extraction/extractors/associateExtractor.ts +129 -0
- package/src/extraction/extractors/choiceExtractor.ts +110 -0
- package/src/extraction/extractors/customExtractor.ts +72 -0
- package/src/extraction/extractors/drawingExtractor.ts +113 -0
- package/src/extraction/extractors/endAttemptExtractor.ts +74 -0
- package/src/extraction/extractors/extendedTextExtractor.ts +80 -0
- package/src/extraction/extractors/gapMatchExtractor.ts +178 -0
- package/src/extraction/extractors/graphicAssociateExtractor.ts +188 -0
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +185 -0
- package/src/extraction/extractors/graphicOrderExtractor.ts +162 -0
- package/src/extraction/extractors/hotspotExtractor.ts +190 -0
- package/src/extraction/extractors/hottextExtractor.ts +153 -0
- package/src/extraction/extractors/index.ts +111 -0
- package/src/extraction/extractors/inlineChoiceExtractor.ts +88 -0
- package/src/extraction/extractors/matchExtractor.ts +160 -0
- package/src/extraction/extractors/mediaExtractor.ts +168 -0
- package/src/extraction/extractors/orderExtractor.ts +114 -0
- package/src/extraction/extractors/positionObjectExtractor.ts +243 -0
- package/src/extraction/extractors/selectPointExtractor.ts +143 -0
- package/src/extraction/extractors/sliderExtractor.ts +102 -0
- package/src/extraction/extractors/textEntryExtractor.ts +70 -0
- package/src/extraction/extractors/uploadExtractor.ts +73 -0
- package/src/extraction/index.ts +109 -0
- package/src/extraction/types.ts +246 -0
- package/src/extraction/utils.ts +160 -0
- package/src/iframe/IFramePlayerHost.ts +265 -0
- package/src/iframe/index.ts +11 -0
- package/src/iframe/protocol.ts +137 -0
- package/src/index.ts +87 -0
- package/src/server.ts +14 -0
- package/src/types/index.ts +301 -0
- package/src/types/interactions.ts +354 -0
- package/src/types/responseValidation.ts +29 -0
- package/src/utils/PerformanceMonitor.ts +335 -0
- package/src/utils/responseUtils.ts +51 -0
- package/src/utils/touchDragHelper.ts +211 -0
- package/src/web-components/QTIInteractionBase.ts +302 -0
- package/src/web-components/QTIInteractionElement.ts +118 -0
- package/src/web-components/index.ts +21 -0
- package/tests/conformance/FIXTURE_POLICY.md +29 -0
- package/tests/conformance/README.md +70 -0
- package/tests/conformance/fixtures/baseTypes_all/cases.json +61 -0
- package/tests/conformance/fixtures/baseTypes_all/item.xml +131 -0
- package/tests/conformance/fixtures/baseTypes_all/manifest.json +7 -0
- package/tests/conformance/fixtures/choice_match_correct/cases.json +17 -0
- package/tests/conformance/fixtures/choice_match_correct/item.xml +55 -0
- package/tests/conformance/fixtures/choice_match_correct/manifest.json +14 -0
- package/tests/conformance/fixtures/contains_multiple/cases.json +12 -0
- package/tests/conformance/fixtures/contains_multiple/item.xml +37 -0
- package/tests/conformance/fixtures/contains_multiple/manifest.json +13 -0
- package/tests/conformance/fixtures/isNull_isNotNull/cases.json +9 -0
- package/tests/conformance/fixtures/isNull_isNotNull/item.xml +41 -0
- package/tests/conformance/fixtures/isNull_isNotNull/manifest.json +23 -0
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/cases.json +27 -0
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/item.xml +30 -0
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/manifest.json +15 -0
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/cases.json +11 -0
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/item.xml +26 -0
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/manifest.json +13 -0
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/cases.json +27 -0
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/item.xml +32 -0
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/manifest.json +7 -0
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/cases.json +9 -0
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/item.xml +25 -0
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/manifest.json +12 -0
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/cases.json +12 -0
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/item.xml +35 -0
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/manifest.json +11 -0
- package/tests/conformance/fixtures/mapping_bounds_upperLower/cases.json +12 -0
- package/tests/conformance/fixtures/mapping_bounds_upperLower/item.xml +37 -0
- package/tests/conformance/fixtures/mapping_bounds_upperLower/manifest.json +11 -0
- package/tests/conformance/fixtures/mapping_mapResponse/cases.json +22 -0
- package/tests/conformance/fixtures/mapping_mapResponse/item.xml +53 -0
- package/tests/conformance/fixtures/mapping_mapResponse/manifest.json +16 -0
- package/tests/conformance/fixtures/member_multiple/cases.json +12 -0
- package/tests/conformance/fixtures/member_multiple/item.xml +37 -0
- package/tests/conformance/fixtures/member_multiple/manifest.json +13 -0
- package/tests/conformance/fixtures/modalFeedback_basic/cases.json +17 -0
- package/tests/conformance/fixtures/modalFeedback_basic/item.xml +52 -0
- package/tests/conformance/fixtures/modalFeedback_basic/manifest.json +13 -0
- package/tests/conformance/fixtures/multiple_unordered_match/cases.json +17 -0
- package/tests/conformance/fixtures/multiple_unordered_match/item.xml +44 -0
- package/tests/conformance/fixtures/multiple_unordered_match/manifest.json +11 -0
- package/tests/conformance/fixtures/ordered_match/cases.json +17 -0
- package/tests/conformance/fixtures/ordered_match/item.xml +48 -0
- package/tests/conformance/fixtures/ordered_match/manifest.json +13 -0
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/cases.json +27 -0
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/item.xml +103 -0
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/manifest.json +7 -0
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/cases.json +15 -0
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/item.xml +33 -0
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/manifest.json +10 -0
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/cases.json +14 -0
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/item.xml +26 -0
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/manifest.json +8 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/cases.json +17 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/item.xml +43 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/manifest.json +16 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/cases.json +27 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/item.xml +37 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/manifest.json +16 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/cases.json +14 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/item.xml +35 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/manifest.json +8 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/cases.json +14 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/item.xml +35 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/manifest.json +8 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/cases.json +15 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/item.xml +39 -0
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/manifest.json +11 -0
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/cases.json +14 -0
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/item.xml +35 -0
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/manifest.json +8 -0
- package/tests/conformance/fixtures/pair_unordered_match/cases.json +22 -0
- package/tests/conformance/fixtures/pair_unordered_match/item.xml +44 -0
- package/tests/conformance/fixtures/pair_unordered_match/manifest.json +13 -0
- package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/cases.json +95 -0
- package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/item.xml +53 -0
- package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/cases.json +115 -0
- package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/item.xml +45 -0
- package/tests/conformance/fixtures/positionObject_mapResponse_wrong/cases.json +29 -0
- package/tests/conformance/fixtures/positionObject_mapResponse_wrong/item.xml +40 -0
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/cases.json +10 -0
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/item.xml +49 -0
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/manifest.json +15 -0
- package/tests/conformance/fixtures/responseProcessing_anyN/cases.json +27 -0
- package/tests/conformance/fixtures/responseProcessing_anyN/item.xml +47 -0
- package/tests/conformance/fixtures/responseProcessing_anyN/manifest.json +16 -0
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/cases.json +27 -0
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/item.xml +69 -0
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/manifest.json +23 -0
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/cases.json +15 -0
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/item.xml +58 -0
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/manifest.json +15 -0
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/cases.json +37 -0
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/item.xml +94 -0
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/manifest.json +27 -0
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/cases.json +33 -0
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/item.xml +79 -0
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/manifest.json +16 -0
- package/tests/conformance/fixtures/responseProcessing_customOperator/cases.json +15 -0
- package/tests/conformance/fixtures/responseProcessing_customOperator/item.xml +30 -0
- package/tests/conformance/fixtures/responseProcessing_customOperator/manifest.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_default_expression/cases.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_default_expression/item.xml +48 -0
- package/tests/conformance/fixtures/responseProcessing_default_expression/manifest.json +13 -0
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/cases.json +29 -0
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/item.xml +68 -0
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/manifest.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/cases.json +39 -0
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/item.xml +39 -0
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/manifest.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_exitResponse/cases.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_exitResponse/item.xml +25 -0
- package/tests/conformance/fixtures/responseProcessing_exitResponse/manifest.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/cases.json +26 -0
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/item.xml +134 -0
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/manifest.json +16 -0
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/cases.json +27 -0
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/item.xml +33 -0
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/manifest.json +13 -0
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/cases.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/item.xml +33 -0
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/manifest.json +13 -0
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/cases.json +27 -0
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/item.xml +40 -0
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/manifest.json +18 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/cases.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/item.xml +33 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/manifest.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/cases.json +29 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/item.xml +26 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/manifest.json +7 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/cases.json +23 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/item.xml +28 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/manifest.json +11 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/cases.json +29 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/item.xml +26 -0
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/manifest.json +7 -0
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/cases.json +31 -0
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/item.xml +102 -0
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/manifest.json +18 -0
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/cases.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/item.xml +45 -0
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/manifest.json +21 -0
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/cases.json +26 -0
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/item.xml +157 -0
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/manifest.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/cases.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/item.xml +39 -0
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/manifest.json +18 -0
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/cases.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/item.xml +51 -0
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/manifest.json +19 -0
- package/tests/conformance/fixtures/responseProcessing_preCondition/cases.json +31 -0
- package/tests/conformance/fixtures/responseProcessing_preCondition/item.xml +44 -0
- package/tests/conformance/fixtures/responseProcessing_preCondition/manifest.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/cases.json +27 -0
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/item.xml +42 -0
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/manifest.json +14 -0
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/cases.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/item.xml +40 -0
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/manifest.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/cases.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/item.xml +63 -0
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/manifest.json +9 -0
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/cases.json +12 -0
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/item.xml +40 -0
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/manifest.json +13 -0
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/cases.json +15 -0
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/item.xml +67 -0
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/manifest.json +9 -0
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/cases.json +27 -0
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/item.xml +69 -0
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/manifest.json +10 -0
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/cases.json +15 -0
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/item.xml +35 -0
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/manifest.json +11 -0
- package/tests/conformance/fixtures/responseProcessing_template_map_response/cases.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_template_map_response/item.xml +31 -0
- package/tests/conformance/fixtures/responseProcessing_template_map_response/manifest.json +8 -0
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/cases.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/item.xml +27 -0
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/manifest.json +8 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/cases.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/item.xml +34 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/manifest.json +8 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/cases.json +22 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/item.xml +30 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/manifest.json +7 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/cases.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/item.xml +30 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/manifest.json +9 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/cases.json +17 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/item.xml +30 -0
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/manifest.json +8 -0
- package/tests/conformance/fixtures/responseProcessing_xiInclude/cases.json +14 -0
- package/tests/conformance/fixtures/responseProcessing_xiInclude/item.xml +25 -0
- package/tests/conformance/fixtures/responseProcessing_xiInclude/manifest.json +9 -0
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/cases.json +12 -0
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/item.xml +52 -0
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/manifest.json +14 -0
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/cases.json +12 -0
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/item.xml +48 -0
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/manifest.json +13 -0
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/cases.json +27 -0
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/item.xml +74 -0
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/manifest.json +22 -0
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/cases.json +17 -0
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/item.xml +133 -0
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/manifest.json +22 -0
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/cases.json +12 -0
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/item.xml +107 -0
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/manifest.json +16 -0
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/cases.json +15 -0
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/item.xml +52 -0
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/manifest.json +14 -0
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/cases.json +16 -0
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/item.xml +49 -0
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/manifest.json +15 -0
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/cases.json +16 -0
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/item.xml +38 -0
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/manifest.json +13 -0
- package/tests/conformance/harness.ts +84 -0
- package/tests/conformance/run-fixtures.test.ts +127 -0
- package/tests/conformance/scripts/normalize-covers.ts +152 -0
- package/tests/conformance/types.ts +53 -0
- package/tests/core/Player.test.ts +563 -0
- package/tests/core/adaptiveItems.test.ts +442 -0
- package/tests/core/correctResponse.test.ts +280 -0
- package/tests/core/interaction-plumbing.test.ts +141 -0
- package/tests/core/modalFeedback.test.ts +308 -0
- package/tests/core/outcome-reset.test.ts +43 -0
- package/tests/extraction/extractors/associateExtractor.test.ts +182 -0
- package/tests/extraction/extractors/choiceExtractor.test.ts +239 -0
- package/tests/extraction/extractors/customExtractor.test.ts +83 -0
- package/tests/extraction/extractors/drawingExtractor.test.ts +94 -0
- package/tests/extraction/extractors/endAttemptExtractor.test.ts +188 -0
- package/tests/extraction/extractors/extendedTextExtractor.test.ts +178 -0
- package/tests/extraction/extractors/gapMatchExtractor.test.ts +318 -0
- package/tests/extraction/extractors/graphicAssociateExtractor.test.ts +260 -0
- package/tests/extraction/extractors/graphicGapMatchExtractor.test.ts +320 -0
- package/tests/extraction/extractors/graphicOrderExtractor.test.ts +223 -0
- package/tests/extraction/extractors/hotspotExtractor.test.ts +298 -0
- package/tests/extraction/extractors/hottextExtractor.test.ts +240 -0
- package/tests/extraction/extractors/inlineChoiceExtractor.test.ts +292 -0
- package/tests/extraction/extractors/matchExtractor.test.ts +241 -0
- package/tests/extraction/extractors/mediaExtractor.test.ts +295 -0
- package/tests/extraction/extractors/orderExtractor.test.ts +212 -0
- package/tests/extraction/extractors/positionObjectExtractor.test.ts +363 -0
- package/tests/extraction/extractors/selectPointExtractor.test.ts +214 -0
- package/tests/extraction/extractors/sliderExtractor.test.ts +293 -0
- package/tests/extraction/extractors/textEntryExtractor.test.ts +133 -0
- package/tests/extraction/extractors/uploadExtractor.test.ts +119 -0
- package/tests/extraction/test-utils.ts +57 -0
- package/tests/iframe/host.test.ts +145 -0
- package/tests/iframe/protocol.test.ts +42 -0
- package/tests/performance/player-benchmarks.bench.ts +191 -0
- package/tests/security/dos-limits.test.ts +56 -0
- package/tests/security/xss-prevention.test.ts +522 -0
- package/tsconfig.json +20 -0
- package/tsconfig.svelte.json +14 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for standardExtendedTextExtractor
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'bun:test';
|
|
6
|
+
import { standardExtendedTextExtractor } from '../../../src/extraction/extractors/extendedTextExtractor.js';
|
|
7
|
+
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
+
|
|
9
|
+
describe('standardExtendedTextExtractor', () => {
|
|
10
|
+
test('extracts basic extended text interaction', () => {
|
|
11
|
+
const xml = `
|
|
12
|
+
<extendedTextInteraction
|
|
13
|
+
responseIdentifier="RESPONSE"
|
|
14
|
+
expectedLines="5"
|
|
15
|
+
expectedLength="500"
|
|
16
|
+
/>
|
|
17
|
+
`;
|
|
18
|
+
const element = parseQTI(xml);
|
|
19
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
20
|
+
|
|
21
|
+
const result = standardExtendedTextExtractor.extract(element, context);
|
|
22
|
+
|
|
23
|
+
expect(result.expectedLines).toBe(5);
|
|
24
|
+
expect(result.expectedLength).toBe(500);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('uses default values when attributes not specified', () => {
|
|
28
|
+
const xml = `<extendedTextInteraction responseIdentifier="RESPONSE" />`;
|
|
29
|
+
const element = parseQTI(xml);
|
|
30
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
31
|
+
|
|
32
|
+
const result = standardExtendedTextExtractor.extract(element, context);
|
|
33
|
+
|
|
34
|
+
expect(result.expectedLines).toBe(3);
|
|
35
|
+
expect(result.expectedLength).toBe(200);
|
|
36
|
+
expect(result.format).toBe('plain');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('handles placeholderText attribute', () => {
|
|
40
|
+
const xml = `
|
|
41
|
+
<extendedTextInteraction
|
|
42
|
+
responseIdentifier="RESPONSE"
|
|
43
|
+
placeholderText="Type your essay here..."
|
|
44
|
+
/>
|
|
45
|
+
`;
|
|
46
|
+
const element = parseQTI(xml);
|
|
47
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
48
|
+
|
|
49
|
+
const result = standardExtendedTextExtractor.extract(element, context);
|
|
50
|
+
|
|
51
|
+
expect(result.placeholderText).toBe('Type your essay here...');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('handles format attribute', () => {
|
|
55
|
+
const xml = `
|
|
56
|
+
<extendedTextInteraction
|
|
57
|
+
responseIdentifier="RESPONSE"
|
|
58
|
+
format="preFormatted"
|
|
59
|
+
/>
|
|
60
|
+
`;
|
|
61
|
+
const element = parseQTI(xml);
|
|
62
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
63
|
+
|
|
64
|
+
const result = standardExtendedTextExtractor.extract(element, context);
|
|
65
|
+
|
|
66
|
+
expect(result.format).toBe('preFormatted');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('handles xhtml format', () => {
|
|
70
|
+
const xml = `
|
|
71
|
+
<extendedTextInteraction
|
|
72
|
+
responseIdentifier="RESPONSE"
|
|
73
|
+
format="xhtml"
|
|
74
|
+
expectedLines="10"
|
|
75
|
+
/>
|
|
76
|
+
`;
|
|
77
|
+
const element = parseQTI(xml);
|
|
78
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
79
|
+
|
|
80
|
+
const result = standardExtendedTextExtractor.extract(element, context);
|
|
81
|
+
|
|
82
|
+
expect(result.format).toBe('xhtml');
|
|
83
|
+
expect(result.expectedLines).toBe(10);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('handles large expectedLength values', () => {
|
|
87
|
+
const xml = `
|
|
88
|
+
<extendedTextInteraction
|
|
89
|
+
responseIdentifier="RESPONSE"
|
|
90
|
+
expectedLength="5000"
|
|
91
|
+
/>
|
|
92
|
+
`;
|
|
93
|
+
const element = parseQTI(xml);
|
|
94
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
95
|
+
|
|
96
|
+
const result = standardExtendedTextExtractor.extract(element, context);
|
|
97
|
+
|
|
98
|
+
expect(result.expectedLength).toBe(5000);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('canHandle predicate', () => {
|
|
102
|
+
test('handles extendedTextInteraction element', () => {
|
|
103
|
+
const xml = `<extendedTextInteraction responseIdentifier="RESPONSE" />`;
|
|
104
|
+
const element = parseQTI(xml);
|
|
105
|
+
const context = createTestContext(element);
|
|
106
|
+
|
|
107
|
+
expect(standardExtendedTextExtractor.canHandle(element, context)).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('rejects non-extendedTextInteraction elements', () => {
|
|
111
|
+
const xml = `<textEntryInteraction responseIdentifier="RESPONSE" />`;
|
|
112
|
+
const element = parseQTI(xml);
|
|
113
|
+
const context = createTestContext(element);
|
|
114
|
+
|
|
115
|
+
expect(standardExtendedTextExtractor.canHandle(element, context)).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('validation', () => {
|
|
120
|
+
test('validates correct extended text data', () => {
|
|
121
|
+
const data = {
|
|
122
|
+
expectedLines: 5,
|
|
123
|
+
expectedLength: 500,
|
|
124
|
+
format: 'plain',
|
|
125
|
+
placeholderText: '',
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const validation = standardExtendedTextExtractor.validate!(data);
|
|
129
|
+
|
|
130
|
+
expect(validation.valid).toBe(true);
|
|
131
|
+
expect(validation.errors).toBeUndefined();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('reports error for invalid expectedLines', () => {
|
|
135
|
+
const data = {
|
|
136
|
+
expectedLines: 0,
|
|
137
|
+
expectedLength: 200,
|
|
138
|
+
format: 'plain',
|
|
139
|
+
placeholderText: '',
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const validation = standardExtendedTextExtractor.validate!(data);
|
|
143
|
+
|
|
144
|
+
expect(validation.valid).toBe(false);
|
|
145
|
+
expect(validation.errors).toContain('expectedLines must be at least 1');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('reports error for invalid expectedLength', () => {
|
|
149
|
+
const data = {
|
|
150
|
+
expectedLines: 3,
|
|
151
|
+
expectedLength: -100,
|
|
152
|
+
format: 'plain',
|
|
153
|
+
placeholderText: '',
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const validation = standardExtendedTextExtractor.validate!(data);
|
|
157
|
+
|
|
158
|
+
expect(validation.valid).toBe(false);
|
|
159
|
+
expect(validation.errors).toContain('expectedLength must be positive');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('reports warning for invalid format value', () => {
|
|
163
|
+
const data = {
|
|
164
|
+
expectedLines: 3,
|
|
165
|
+
expectedLength: 200,
|
|
166
|
+
format: 'markdown',
|
|
167
|
+
placeholderText: '',
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const validation = standardExtendedTextExtractor.validate!(data);
|
|
171
|
+
|
|
172
|
+
expect(validation.valid).toBe(true);
|
|
173
|
+
expect(validation.warnings).toContain(
|
|
174
|
+
'Unrecognized format "markdown" - expected plain, preFormatted, or xhtml'
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for standardGapMatchExtractor
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'bun:test';
|
|
6
|
+
import { standardGapMatchExtractor } from '../../../src/extraction/extractors/gapMatchExtractor.js';
|
|
7
|
+
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
+
|
|
9
|
+
describe('standardGapMatchExtractor', () => {
|
|
10
|
+
test('extracts basic gap match interaction', () => {
|
|
11
|
+
const xml = `
|
|
12
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
13
|
+
<prompt>Fill in the <gap identifier="G1" /> with the correct word.</prompt>
|
|
14
|
+
<gapText identifier="T1" matchMax="1">cat</gapText>
|
|
15
|
+
<gapText identifier="T2" matchMax="1">dog</gapText>
|
|
16
|
+
</gapMatchInteraction>
|
|
17
|
+
`;
|
|
18
|
+
const element = parseQTI(xml);
|
|
19
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
20
|
+
|
|
21
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
22
|
+
|
|
23
|
+
expect(result.shuffle).toBe(false);
|
|
24
|
+
expect(result.gapTexts).toHaveLength(2);
|
|
25
|
+
expect(result.promptText).toContain('[GAP:G1]');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('extracts gapText elements with matchMax values', () => {
|
|
29
|
+
const xml = `
|
|
30
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
31
|
+
<prompt>Fill the gaps: <gap identifier="G1" /> and <gap identifier="G2" /></prompt>
|
|
32
|
+
<gapText identifier="T1" matchMax="1">first</gapText>
|
|
33
|
+
<gapText identifier="T2" matchMax="2">second</gapText>
|
|
34
|
+
<gapText identifier="T3" matchMax="0">unlimited</gapText>
|
|
35
|
+
</gapMatchInteraction>
|
|
36
|
+
`;
|
|
37
|
+
const element = parseQTI(xml);
|
|
38
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
39
|
+
|
|
40
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
41
|
+
|
|
42
|
+
expect(result.gapTexts).toHaveLength(3);
|
|
43
|
+
expect(result.gapTexts[0]).toEqual({ identifier: 'T1', text: 'first', matchMax: 1 });
|
|
44
|
+
expect(result.gapTexts[1]).toEqual({ identifier: 'T2', text: 'second', matchMax: 2 });
|
|
45
|
+
expect(result.gapTexts[2]).toEqual({ identifier: 'T3', text: 'unlimited', matchMax: 0 });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('uses default matchMax when not specified', () => {
|
|
49
|
+
const xml = `
|
|
50
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
51
|
+
<prompt>Fill the gap: <gap identifier="G1" /></prompt>
|
|
52
|
+
<gapText identifier="T1">word without matchMax</gapText>
|
|
53
|
+
</gapMatchInteraction>
|
|
54
|
+
`;
|
|
55
|
+
const element = parseQTI(xml);
|
|
56
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
57
|
+
|
|
58
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
59
|
+
|
|
60
|
+
expect(result.gapTexts[0].matchMax).toBe(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('extracts gap identifiers from prompt content', () => {
|
|
64
|
+
const xml = `
|
|
65
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
66
|
+
<prompt>The <gap identifier="G1" /> jumps over the <gap identifier="G2" />.</prompt>
|
|
67
|
+
<gapText identifier="T1" matchMax="1">cat</gapText>
|
|
68
|
+
<gapText identifier="T2" matchMax="1">fence</gapText>
|
|
69
|
+
</gapMatchInteraction>
|
|
70
|
+
`;
|
|
71
|
+
const element = parseQTI(xml);
|
|
72
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
73
|
+
|
|
74
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
75
|
+
|
|
76
|
+
expect(result.promptText).toContain('[GAP:G1]');
|
|
77
|
+
expect(result.promptText).toContain('[GAP:G2]');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('processes promptText with gap placeholders replaced', () => {
|
|
81
|
+
const xml = `
|
|
82
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
83
|
+
<prompt>The <gap identifier="G1" /> is <gap identifier="G2" />.</prompt>
|
|
84
|
+
<gapText identifier="T1" matchMax="1">sky</gapText>
|
|
85
|
+
<gapText identifier="T2" matchMax="1">blue</gapText>
|
|
86
|
+
</gapMatchInteraction>
|
|
87
|
+
`;
|
|
88
|
+
const element = parseQTI(xml);
|
|
89
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
90
|
+
|
|
91
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
92
|
+
|
|
93
|
+
expect(result.promptText).toBe('The [GAP:G1] is [GAP:G2].');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('handles interaction with shuffle enabled', () => {
|
|
97
|
+
const xml = `
|
|
98
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="true">
|
|
99
|
+
<prompt>Fill the gap: <gap identifier="G1" /></prompt>
|
|
100
|
+
<gapText identifier="T1" matchMax="1">answer</gapText>
|
|
101
|
+
</gapMatchInteraction>
|
|
102
|
+
`;
|
|
103
|
+
const element = parseQTI(xml);
|
|
104
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
105
|
+
|
|
106
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
107
|
+
|
|
108
|
+
expect(result.shuffle).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('handles interaction without shuffle attribute', () => {
|
|
112
|
+
const xml = `
|
|
113
|
+
<gapMatchInteraction responseIdentifier="RESPONSE">
|
|
114
|
+
<prompt>Fill the gap: <gap identifier="G1" /></prompt>
|
|
115
|
+
<gapText identifier="T1" matchMax="1">answer</gapText>
|
|
116
|
+
</gapMatchInteraction>
|
|
117
|
+
`;
|
|
118
|
+
const element = parseQTI(xml);
|
|
119
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
120
|
+
|
|
121
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
122
|
+
|
|
123
|
+
expect(result.shuffle).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('handles interaction without prompt', () => {
|
|
127
|
+
const xml = `
|
|
128
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
129
|
+
<gapText identifier="T1" matchMax="1">answer</gapText>
|
|
130
|
+
</gapMatchInteraction>
|
|
131
|
+
`;
|
|
132
|
+
const element = parseQTI(xml);
|
|
133
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
134
|
+
|
|
135
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
136
|
+
|
|
137
|
+
expect(result.prompt).toBe(null);
|
|
138
|
+
expect(result.promptText).toBe('');
|
|
139
|
+
expect(result.gaps).toHaveLength(0);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('handles interaction with no gapText elements', () => {
|
|
143
|
+
const xml = `
|
|
144
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
145
|
+
<prompt>Fill the gap: <gap identifier="G1" /></prompt>
|
|
146
|
+
</gapMatchInteraction>
|
|
147
|
+
`;
|
|
148
|
+
const element = parseQTI(xml);
|
|
149
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
150
|
+
|
|
151
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
152
|
+
|
|
153
|
+
expect(result.gapTexts).toHaveLength(0);
|
|
154
|
+
expect(result.promptText).toContain('[GAP:G1]');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('handles prompt with no gap elements', () => {
|
|
158
|
+
const xml = `
|
|
159
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
160
|
+
<prompt>This is a prompt without any gaps.</prompt>
|
|
161
|
+
<gapText identifier="T1" matchMax="1">unused</gapText>
|
|
162
|
+
</gapMatchInteraction>
|
|
163
|
+
`;
|
|
164
|
+
const element = parseQTI(xml);
|
|
165
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
166
|
+
|
|
167
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
168
|
+
|
|
169
|
+
expect(result.promptText).toBe('This is a prompt without any gaps.');
|
|
170
|
+
expect(result.promptText).not.toContain('[GAP');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('handles gapText with HTML content', () => {
|
|
174
|
+
const xml = `
|
|
175
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
176
|
+
<prompt>Fill the gap: <gap identifier="G1" /></prompt>
|
|
177
|
+
<gapText identifier="T1" matchMax="1">text with <strong>bold</strong></gapText>
|
|
178
|
+
<gapText identifier="T2" matchMax="1">text with <em>italic</em></gapText>
|
|
179
|
+
</gapMatchInteraction>
|
|
180
|
+
`;
|
|
181
|
+
const element = parseQTI(xml);
|
|
182
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
183
|
+
|
|
184
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
185
|
+
|
|
186
|
+
expect(result.gapTexts[0].text).toContain('bold');
|
|
187
|
+
expect(result.gapTexts[1].text).toContain('italic');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('handles multiple gaps in complex prompt', () => {
|
|
191
|
+
const xml = `
|
|
192
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
193
|
+
<prompt>
|
|
194
|
+
In <gap identifier="G1" />, the capital is <gap identifier="G2" />.
|
|
195
|
+
The population is <gap identifier="G3" /> million.
|
|
196
|
+
</prompt>
|
|
197
|
+
<gapText identifier="T1" matchMax="1">France</gapText>
|
|
198
|
+
<gapText identifier="T2" matchMax="1">Paris</gapText>
|
|
199
|
+
<gapText identifier="T3" matchMax="1">67</gapText>
|
|
200
|
+
</gapMatchInteraction>
|
|
201
|
+
`;
|
|
202
|
+
const element = parseQTI(xml);
|
|
203
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
204
|
+
|
|
205
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
206
|
+
|
|
207
|
+
expect(result.promptText).toContain('[GAP:G1]');
|
|
208
|
+
expect(result.promptText).toContain('[GAP:G2]');
|
|
209
|
+
expect(result.promptText).toContain('[GAP:G3]');
|
|
210
|
+
expect(result.gapTexts).toHaveLength(3);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test('handles self-closing gap tags with extra whitespace', () => {
|
|
214
|
+
const xml = `
|
|
215
|
+
<gapMatchInteraction responseIdentifier="RESPONSE" shuffle="false">
|
|
216
|
+
<prompt>Gap 1: <gap identifier="G1" /> and Gap 2: <gap identifier="G2" /></prompt>
|
|
217
|
+
<gapText identifier="T1" matchMax="1">answer</gapText>
|
|
218
|
+
</gapMatchInteraction>
|
|
219
|
+
`;
|
|
220
|
+
const element = parseQTI(xml);
|
|
221
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
222
|
+
|
|
223
|
+
const result = standardGapMatchExtractor.extract(element, context);
|
|
224
|
+
|
|
225
|
+
expect(result.promptText).toContain('[GAP:G1]');
|
|
226
|
+
expect(result.promptText).toContain('[GAP:G2]');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('canHandle predicate', () => {
|
|
230
|
+
test('handles gapMatchInteraction element', () => {
|
|
231
|
+
const xml = `
|
|
232
|
+
<gapMatchInteraction responseIdentifier="RESPONSE">
|
|
233
|
+
<gapText identifier="T1">text</gapText>
|
|
234
|
+
</gapMatchInteraction>
|
|
235
|
+
`;
|
|
236
|
+
const element = parseQTI(xml);
|
|
237
|
+
const context = createTestContext(element);
|
|
238
|
+
|
|
239
|
+
expect(standardGapMatchExtractor.canHandle(element, context)).toBe(true);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test('rejects non-gapMatchInteraction elements', () => {
|
|
243
|
+
const xml = `<choiceInteraction responseIdentifier="RESPONSE" />`;
|
|
244
|
+
const element = parseQTI(xml);
|
|
245
|
+
const context = createTestContext(element);
|
|
246
|
+
|
|
247
|
+
expect(standardGapMatchExtractor.canHandle(element, context)).toBe(false);
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
describe('validation', () => {
|
|
252
|
+
test('validates correct gapMatch data', () => {
|
|
253
|
+
const data = {
|
|
254
|
+
gapTexts: [
|
|
255
|
+
{ identifier: 'T1', text: 'Text 1', matchMax: 1 },
|
|
256
|
+
{ identifier: 'T2', text: 'Text 2', matchMax: 1 },
|
|
257
|
+
],
|
|
258
|
+
gaps: ['G1', 'G2'],
|
|
259
|
+
promptText: 'Fill [GAP:G1] and [GAP:G2]',
|
|
260
|
+
shuffle: false,
|
|
261
|
+
prompt: 'Fill the gaps',
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const validation = standardGapMatchExtractor.validate!(data);
|
|
265
|
+
|
|
266
|
+
expect(validation.valid).toBe(true);
|
|
267
|
+
expect(validation.errors).toBeUndefined();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test('reports error for empty gapTexts', () => {
|
|
271
|
+
const data = {
|
|
272
|
+
gapTexts: [],
|
|
273
|
+
gaps: ['G1'],
|
|
274
|
+
promptText: '[GAP:G1]',
|
|
275
|
+
shuffle: false,
|
|
276
|
+
prompt: null,
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const validation = standardGapMatchExtractor.validate!(data);
|
|
280
|
+
|
|
281
|
+
expect(validation.valid).toBe(false);
|
|
282
|
+
expect(validation.errors).toContain('gapMatchInteraction must have at least one gapText');
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
test('reports error for empty gaps', () => {
|
|
286
|
+
const data = {
|
|
287
|
+
gapTexts: [{ identifier: 'T1', text: 'Text', matchMax: 1 }],
|
|
288
|
+
gaps: [],
|
|
289
|
+
promptText: 'No gaps',
|
|
290
|
+
shuffle: false,
|
|
291
|
+
prompt: null,
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const validation = standardGapMatchExtractor.validate!(data);
|
|
295
|
+
|
|
296
|
+
expect(validation.valid).toBe(false);
|
|
297
|
+
expect(validation.errors).toContain('gapMatchInteraction must have at least one gap in the prompt');
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test('reports error for duplicate gapText identifiers', () => {
|
|
301
|
+
const data = {
|
|
302
|
+
gapTexts: [
|
|
303
|
+
{ identifier: 'T1', text: 'Text 1', matchMax: 1 },
|
|
304
|
+
{ identifier: 'T1', text: 'Text 2', matchMax: 1 },
|
|
305
|
+
],
|
|
306
|
+
gaps: ['G1'],
|
|
307
|
+
promptText: '[GAP:G1]',
|
|
308
|
+
shuffle: false,
|
|
309
|
+
prompt: null,
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const validation = standardGapMatchExtractor.validate!(data);
|
|
313
|
+
|
|
314
|
+
expect(validation.valid).toBe(false);
|
|
315
|
+
expect(validation.errors).toContain('Duplicate gapText identifier: T1');
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|