@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,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for standardSelectPointExtractor
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'bun:test';
|
|
6
|
+
import { standardSelectPointExtractor } from '../../../src/extraction/extractors/selectPointExtractor.js';
|
|
7
|
+
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
+
|
|
9
|
+
describe('standardSelectPointExtractor', () => {
|
|
10
|
+
describe('Single Point Selection', () => {
|
|
11
|
+
test('extracts selectPointInteraction with image', () => {
|
|
12
|
+
const xml = `
|
|
13
|
+
<selectPointInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
14
|
+
<prompt>Click on the center of the circle</prompt>
|
|
15
|
+
<object data="circle.png" type="image/png" width="400" height="300"/>
|
|
16
|
+
</selectPointInteraction>
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const element = parseQTI(xml);
|
|
20
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
21
|
+
|
|
22
|
+
const result = standardSelectPointExtractor.extract(element, context);
|
|
23
|
+
|
|
24
|
+
expect(result.prompt).toBe('Click on the center of the circle');
|
|
25
|
+
expect(result.maxChoices).toBe(1);
|
|
26
|
+
expect(result.minChoices).toBe(0);
|
|
27
|
+
expect(result.imageData?.type).toBe('image');
|
|
28
|
+
expect(result.imageData?.src).toBe('circle.png');
|
|
29
|
+
expect(result.imageData?.width).toBe('400');
|
|
30
|
+
expect(result.imageData?.height).toBe('300');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('extracts selectPointInteraction with img element', () => {
|
|
34
|
+
const xml = `
|
|
35
|
+
<selectPointInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
36
|
+
<img src="map.jpg" width="600" height="400"/>
|
|
37
|
+
</selectPointInteraction>
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const element = parseQTI(xml);
|
|
41
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
42
|
+
|
|
43
|
+
const result = standardSelectPointExtractor.extract(element, context);
|
|
44
|
+
|
|
45
|
+
expect(result.imageData?.type).toBe('image');
|
|
46
|
+
expect(result.imageData?.src).toBe('map.jpg');
|
|
47
|
+
expect(result.imageData?.width).toBe('600');
|
|
48
|
+
expect(result.imageData?.height).toBe('400');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('Multiple Point Selection', () => {
|
|
53
|
+
test('extracts selectPointInteraction with maxChoices > 1', () => {
|
|
54
|
+
const xml = `
|
|
55
|
+
<selectPointInteraction responseIdentifier="RESPONSE" maxChoices="3" minChoices="2">
|
|
56
|
+
<prompt>Mark three points on the diagram</prompt>
|
|
57
|
+
<object data="diagram.png" type="image/png" width="500" height="400"/>
|
|
58
|
+
</selectPointInteraction>
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const element = parseQTI(xml);
|
|
62
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
63
|
+
|
|
64
|
+
const result = standardSelectPointExtractor.extract(element, context);
|
|
65
|
+
|
|
66
|
+
expect(result.maxChoices).toBe(3);
|
|
67
|
+
expect(result.minChoices).toBe(2);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('SVG Content', () => {
|
|
72
|
+
test('extracts selectPointInteraction with inline SVG', () => {
|
|
73
|
+
const xml = `
|
|
74
|
+
<selectPointInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
75
|
+
<prompt>Click on the red circle</prompt>
|
|
76
|
+
<object type="image/svg+xml" width="300" height="200">
|
|
77
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 200">
|
|
78
|
+
<circle cx="150" cy="100" r="50" fill="red"/>
|
|
79
|
+
</svg>
|
|
80
|
+
</object>
|
|
81
|
+
</selectPointInteraction>
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
const element = parseQTI(xml);
|
|
85
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
86
|
+
|
|
87
|
+
const result = standardSelectPointExtractor.extract(element, context);
|
|
88
|
+
|
|
89
|
+
expect(result.imageData?.type).toBe('svg');
|
|
90
|
+
expect(result.imageData?.content).toContain('<svg');
|
|
91
|
+
expect(result.imageData?.content).toContain('circle');
|
|
92
|
+
expect(result.imageData?.width).toBe('300');
|
|
93
|
+
expect(result.imageData?.height).toBe('200');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('Default Values', () => {
|
|
98
|
+
test('uses default values when attributes not specified', () => {
|
|
99
|
+
const xml = `
|
|
100
|
+
<selectPointInteraction responseIdentifier="RESPONSE">
|
|
101
|
+
<object data="image.png" type="image/png"/>
|
|
102
|
+
</selectPointInteraction>
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
const element = parseQTI(xml);
|
|
106
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
107
|
+
|
|
108
|
+
const result = standardSelectPointExtractor.extract(element, context);
|
|
109
|
+
|
|
110
|
+
expect(result.maxChoices).toBe(1);
|
|
111
|
+
expect(result.minChoices).toBe(0);
|
|
112
|
+
expect(result.prompt).toBeNull();
|
|
113
|
+
expect(result.imageData?.width).toBe('500');
|
|
114
|
+
expect(result.imageData?.height).toBe('300');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('Edge Cases', () => {
|
|
119
|
+
test('handles missing image element', () => {
|
|
120
|
+
const xml = `
|
|
121
|
+
<selectPointInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
122
|
+
<prompt>Click a point (no image provided)</prompt>
|
|
123
|
+
</selectPointInteraction>
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
const element = parseQTI(xml);
|
|
127
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
128
|
+
|
|
129
|
+
const result = standardSelectPointExtractor.extract(element, context);
|
|
130
|
+
|
|
131
|
+
expect(result.imageData).toBeNull();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('canHandle predicate', () => {
|
|
136
|
+
test('handles selectPointInteraction element', () => {
|
|
137
|
+
const xml = `
|
|
138
|
+
<selectPointInteraction responseIdentifier="RESPONSE">
|
|
139
|
+
<object data="test.png" type="image/png"/>
|
|
140
|
+
</selectPointInteraction>
|
|
141
|
+
`;
|
|
142
|
+
const element = parseQTI(xml);
|
|
143
|
+
const context = createTestContext(element);
|
|
144
|
+
|
|
145
|
+
expect(standardSelectPointExtractor.canHandle(element, context)).toBe(true);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('rejects non-selectPointInteraction elements', () => {
|
|
149
|
+
const xml = `<hotspotInteraction responseIdentifier="RESPONSE" />`;
|
|
150
|
+
const element = parseQTI(xml);
|
|
151
|
+
const context = createTestContext(element);
|
|
152
|
+
|
|
153
|
+
expect(standardSelectPointExtractor.canHandle(element, context)).toBe(false);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('validation', () => {
|
|
158
|
+
test('validates correct selectPoint data', () => {
|
|
159
|
+
const data = {
|
|
160
|
+
maxChoices: 1,
|
|
161
|
+
minChoices: 0,
|
|
162
|
+
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
163
|
+
prompt: null,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const validation = standardSelectPointExtractor.validate!(data);
|
|
167
|
+
|
|
168
|
+
expect(validation.valid).toBe(true);
|
|
169
|
+
expect(validation.errors).toBeUndefined();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('reports error when minChoices > maxChoices', () => {
|
|
173
|
+
const data = {
|
|
174
|
+
maxChoices: 1,
|
|
175
|
+
minChoices: 3,
|
|
176
|
+
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
177
|
+
prompt: null,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const validation = standardSelectPointExtractor.validate!(data);
|
|
181
|
+
|
|
182
|
+
expect(validation.valid).toBe(false);
|
|
183
|
+
expect(validation.errors).toContain('minChoices (3) must be less than or equal to maxChoices (1)');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('reports error for non-positive maxChoices', () => {
|
|
187
|
+
const data = {
|
|
188
|
+
maxChoices: 0,
|
|
189
|
+
minChoices: 0,
|
|
190
|
+
imageData: { type: 'image', src: 'test.png', width: '500', height: '400' },
|
|
191
|
+
prompt: null,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const validation = standardSelectPointExtractor.validate!(data);
|
|
195
|
+
|
|
196
|
+
expect(validation.valid).toBe(false);
|
|
197
|
+
expect(validation.errors).toContain('maxChoices must be at least 1');
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('reports warning for missing image data', () => {
|
|
201
|
+
const data = {
|
|
202
|
+
maxChoices: 1,
|
|
203
|
+
minChoices: 0,
|
|
204
|
+
imageData: null,
|
|
205
|
+
prompt: null,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const validation = standardSelectPointExtractor.validate!(data);
|
|
209
|
+
|
|
210
|
+
expect(validation.valid).toBe(true);
|
|
211
|
+
expect(validation.warnings).toContain('selectPointInteraction has no image data');
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for standardSliderExtractor
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'bun:test';
|
|
6
|
+
import { standardSliderExtractor } from '../../../src/extraction/extractors/sliderExtractor.js';
|
|
7
|
+
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
+
|
|
9
|
+
describe('standardSliderExtractor', () => {
|
|
10
|
+
test('extracts basic slider interaction', () => {
|
|
11
|
+
const xml = `
|
|
12
|
+
<sliderInteraction
|
|
13
|
+
responseIdentifier="RESPONSE"
|
|
14
|
+
lowerBound="0"
|
|
15
|
+
upperBound="100"
|
|
16
|
+
step="1"
|
|
17
|
+
>
|
|
18
|
+
<prompt>Rate your satisfaction (0-100)</prompt>
|
|
19
|
+
</sliderInteraction>
|
|
20
|
+
`;
|
|
21
|
+
const element = parseQTI(xml);
|
|
22
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
23
|
+
|
|
24
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
25
|
+
|
|
26
|
+
expect(result.lowerBound).toBe(0);
|
|
27
|
+
expect(result.upperBound).toBe(100);
|
|
28
|
+
expect(result.step).toBe(1);
|
|
29
|
+
expect(result.prompt).toBe('Rate your satisfaction (0-100)');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('uses default values when attributes not specified', () => {
|
|
33
|
+
const xml = `<sliderInteraction responseIdentifier="RESPONSE" />`;
|
|
34
|
+
const element = parseQTI(xml);
|
|
35
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
36
|
+
|
|
37
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
38
|
+
|
|
39
|
+
expect(result.lowerBound).toBe(0);
|
|
40
|
+
expect(result.upperBound).toBe(100);
|
|
41
|
+
expect(result.step).toBe(1);
|
|
42
|
+
expect(result.orientation).toBe('horizontal');
|
|
43
|
+
expect(result.reverse).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('handles custom bounds and step', () => {
|
|
47
|
+
const xml = `
|
|
48
|
+
<sliderInteraction
|
|
49
|
+
responseIdentifier="RESPONSE"
|
|
50
|
+
lowerBound="10"
|
|
51
|
+
upperBound="50"
|
|
52
|
+
step="5"
|
|
53
|
+
/>
|
|
54
|
+
`;
|
|
55
|
+
const element = parseQTI(xml);
|
|
56
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
57
|
+
|
|
58
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
59
|
+
|
|
60
|
+
expect(result.lowerBound).toBe(10);
|
|
61
|
+
expect(result.upperBound).toBe(50);
|
|
62
|
+
expect(result.step).toBe(5);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('handles decimal step values', () => {
|
|
66
|
+
const xml = `
|
|
67
|
+
<sliderInteraction
|
|
68
|
+
responseIdentifier="RESPONSE"
|
|
69
|
+
lowerBound="0"
|
|
70
|
+
upperBound="10"
|
|
71
|
+
step="0.5"
|
|
72
|
+
/>
|
|
73
|
+
`;
|
|
74
|
+
const element = parseQTI(xml);
|
|
75
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
76
|
+
|
|
77
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
78
|
+
|
|
79
|
+
expect(result.step).toBe(0.5);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('handles vertical orientation', () => {
|
|
83
|
+
const xml = `
|
|
84
|
+
<sliderInteraction
|
|
85
|
+
responseIdentifier="RESPONSE"
|
|
86
|
+
orientation="vertical"
|
|
87
|
+
lowerBound="0"
|
|
88
|
+
upperBound="100"
|
|
89
|
+
/>
|
|
90
|
+
`;
|
|
91
|
+
const element = parseQTI(xml);
|
|
92
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
93
|
+
|
|
94
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
95
|
+
|
|
96
|
+
expect(result.orientation).toBe('vertical');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('handles reverse attribute', () => {
|
|
100
|
+
const xml = `
|
|
101
|
+
<sliderInteraction
|
|
102
|
+
responseIdentifier="RESPONSE"
|
|
103
|
+
reverse="true"
|
|
104
|
+
lowerBound="0"
|
|
105
|
+
upperBound="100"
|
|
106
|
+
/>
|
|
107
|
+
`;
|
|
108
|
+
const element = parseQTI(xml);
|
|
109
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
110
|
+
|
|
111
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
112
|
+
|
|
113
|
+
expect(result.reverse).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('handles negative bounds', () => {
|
|
117
|
+
const xml = `
|
|
118
|
+
<sliderInteraction
|
|
119
|
+
responseIdentifier="RESPONSE"
|
|
120
|
+
lowerBound="-50"
|
|
121
|
+
upperBound="50"
|
|
122
|
+
step="10"
|
|
123
|
+
/>
|
|
124
|
+
`;
|
|
125
|
+
const element = parseQTI(xml);
|
|
126
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
127
|
+
|
|
128
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
129
|
+
|
|
130
|
+
expect(result.lowerBound).toBe(-50);
|
|
131
|
+
expect(result.upperBound).toBe(50);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('handles interaction without prompt', () => {
|
|
135
|
+
const xml = `
|
|
136
|
+
<sliderInteraction
|
|
137
|
+
responseIdentifier="RESPONSE"
|
|
138
|
+
lowerBound="0"
|
|
139
|
+
upperBound="10"
|
|
140
|
+
/>
|
|
141
|
+
`;
|
|
142
|
+
const element = parseQTI(xml);
|
|
143
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
144
|
+
|
|
145
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
146
|
+
|
|
147
|
+
expect(result.prompt).toBe(null);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('handles temperature scale example', () => {
|
|
151
|
+
const xml = `
|
|
152
|
+
<sliderInteraction
|
|
153
|
+
responseIdentifier="TEMP"
|
|
154
|
+
lowerBound="-40"
|
|
155
|
+
upperBound="120"
|
|
156
|
+
step="1"
|
|
157
|
+
orientation="vertical"
|
|
158
|
+
>
|
|
159
|
+
<prompt>Set temperature (°F)</prompt>
|
|
160
|
+
</sliderInteraction>
|
|
161
|
+
`;
|
|
162
|
+
const element = parseQTI(xml);
|
|
163
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
164
|
+
|
|
165
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
166
|
+
|
|
167
|
+
expect(result.lowerBound).toBe(-40);
|
|
168
|
+
expect(result.upperBound).toBe(120);
|
|
169
|
+
expect(result.orientation).toBe('vertical');
|
|
170
|
+
expect(result.prompt).toContain('temperature');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('handles percentage scale with decimals', () => {
|
|
174
|
+
const xml = `
|
|
175
|
+
<sliderInteraction
|
|
176
|
+
responseIdentifier="PERCENT"
|
|
177
|
+
lowerBound="0"
|
|
178
|
+
upperBound="1"
|
|
179
|
+
step="0.01"
|
|
180
|
+
>
|
|
181
|
+
<prompt>Select percentage (0.00 - 1.00)</prompt>
|
|
182
|
+
</sliderInteraction>
|
|
183
|
+
`;
|
|
184
|
+
const element = parseQTI(xml);
|
|
185
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
186
|
+
|
|
187
|
+
const result = standardSliderExtractor.extract(element, context);
|
|
188
|
+
|
|
189
|
+
expect(result.lowerBound).toBe(0);
|
|
190
|
+
expect(result.upperBound).toBe(1);
|
|
191
|
+
expect(result.step).toBe(0.01);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe('canHandle predicate', () => {
|
|
195
|
+
test('handles sliderInteraction element', () => {
|
|
196
|
+
const xml = `<sliderInteraction responseIdentifier="RESPONSE" />`;
|
|
197
|
+
const element = parseQTI(xml);
|
|
198
|
+
const context = createTestContext(element);
|
|
199
|
+
|
|
200
|
+
expect(standardSliderExtractor.canHandle(element, context)).toBe(true);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test('rejects non-sliderInteraction elements', () => {
|
|
204
|
+
const xml = `<choiceInteraction responseIdentifier="RESPONSE" />`;
|
|
205
|
+
const element = parseQTI(xml);
|
|
206
|
+
const context = createTestContext(element);
|
|
207
|
+
|
|
208
|
+
expect(standardSliderExtractor.canHandle(element, context)).toBe(false);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('validation', () => {
|
|
213
|
+
test('validates correct slider data', () => {
|
|
214
|
+
const data = {
|
|
215
|
+
lowerBound: 0,
|
|
216
|
+
upperBound: 100,
|
|
217
|
+
step: 1,
|
|
218
|
+
orientation: 'horizontal',
|
|
219
|
+
reverse: false,
|
|
220
|
+
prompt: null,
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const validation = standardSliderExtractor.validate!(data);
|
|
224
|
+
|
|
225
|
+
expect(validation.valid).toBe(true);
|
|
226
|
+
expect(validation.errors).toBeUndefined();
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('reports error when lowerBound >= upperBound', () => {
|
|
230
|
+
const data = {
|
|
231
|
+
lowerBound: 100,
|
|
232
|
+
upperBound: 0,
|
|
233
|
+
step: 1,
|
|
234
|
+
orientation: 'horizontal',
|
|
235
|
+
reverse: false,
|
|
236
|
+
prompt: null,
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const validation = standardSliderExtractor.validate!(data);
|
|
240
|
+
|
|
241
|
+
expect(validation.valid).toBe(false);
|
|
242
|
+
expect(validation.errors).toContain('lowerBound must be less than upperBound');
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('reports error for non-positive step', () => {
|
|
246
|
+
const data = {
|
|
247
|
+
lowerBound: 0,
|
|
248
|
+
upperBound: 100,
|
|
249
|
+
step: 0,
|
|
250
|
+
orientation: 'horizontal',
|
|
251
|
+
reverse: false,
|
|
252
|
+
prompt: null,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const validation = standardSliderExtractor.validate!(data);
|
|
256
|
+
|
|
257
|
+
expect(validation.valid).toBe(false);
|
|
258
|
+
expect(validation.errors).toContain('step must be greater than 0');
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('reports error for invalid orientation', () => {
|
|
262
|
+
const data = {
|
|
263
|
+
lowerBound: 0,
|
|
264
|
+
upperBound: 100,
|
|
265
|
+
step: 1,
|
|
266
|
+
orientation: 'diagonal',
|
|
267
|
+
reverse: false,
|
|
268
|
+
prompt: null,
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const validation = standardSliderExtractor.validate!(data);
|
|
272
|
+
|
|
273
|
+
expect(validation.valid).toBe(false);
|
|
274
|
+
expect(validation.errors).toContain('orientation must be "horizontal" or "vertical"');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test('reports warning when step > range', () => {
|
|
278
|
+
const data = {
|
|
279
|
+
lowerBound: 0,
|
|
280
|
+
upperBound: 10,
|
|
281
|
+
step: 20,
|
|
282
|
+
orientation: 'horizontal',
|
|
283
|
+
reverse: false,
|
|
284
|
+
prompt: null,
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const validation = standardSliderExtractor.validate!(data);
|
|
288
|
+
|
|
289
|
+
expect(validation.valid).toBe(true);
|
|
290
|
+
expect(validation.warnings).toContain('step (20) is larger than the range (10)');
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for standardTextEntryExtractor
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'bun:test';
|
|
6
|
+
import { standardTextEntryExtractor } from '../../../src/extraction/extractors/textEntryExtractor.js';
|
|
7
|
+
import { createTestContext, parseQTI } from '../test-utils.js';
|
|
8
|
+
|
|
9
|
+
describe('standardTextEntryExtractor', () => {
|
|
10
|
+
test('extracts basic text entry interaction', () => {
|
|
11
|
+
const xml = `
|
|
12
|
+
<textEntryInteraction responseIdentifier="RESPONSE" expectedLength="15" />
|
|
13
|
+
`;
|
|
14
|
+
const element = parseQTI(xml);
|
|
15
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
16
|
+
|
|
17
|
+
const result = standardTextEntryExtractor.extract(element, context);
|
|
18
|
+
|
|
19
|
+
expect(result.expectedLength).toBe(15);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('uses default expectedLength when not specified', () => {
|
|
23
|
+
const xml = `<textEntryInteraction responseIdentifier="RESPONSE" />`;
|
|
24
|
+
const element = parseQTI(xml);
|
|
25
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
26
|
+
|
|
27
|
+
const result = standardTextEntryExtractor.extract(element, context);
|
|
28
|
+
|
|
29
|
+
expect(result.expectedLength).toBe(20);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('handles patternMask attribute', () => {
|
|
33
|
+
const xml = `
|
|
34
|
+
<textEntryInteraction
|
|
35
|
+
responseIdentifier="RESPONSE"
|
|
36
|
+
patternMask="[0-9]{3}-[0-9]{3}-[0-9]{4}"
|
|
37
|
+
/>
|
|
38
|
+
`;
|
|
39
|
+
const element = parseQTI(xml);
|
|
40
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
41
|
+
|
|
42
|
+
const result = standardTextEntryExtractor.extract(element, context);
|
|
43
|
+
|
|
44
|
+
expect(result.patternMask).toBe('[0-9]{3}-[0-9]{3}-[0-9]{4}');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('handles placeholderText attribute', () => {
|
|
48
|
+
const xml = `
|
|
49
|
+
<textEntryInteraction
|
|
50
|
+
responseIdentifier="RESPONSE"
|
|
51
|
+
placeholderText="Enter your answer here"
|
|
52
|
+
/>
|
|
53
|
+
`;
|
|
54
|
+
const element = parseQTI(xml);
|
|
55
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
56
|
+
|
|
57
|
+
const result = standardTextEntryExtractor.extract(element, context);
|
|
58
|
+
|
|
59
|
+
expect(result.placeholderText).toBe('Enter your answer here');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('handles missing optional attributes', () => {
|
|
63
|
+
const xml = `<textEntryInteraction responseIdentifier="RESPONSE" />`;
|
|
64
|
+
const element = parseQTI(xml);
|
|
65
|
+
const context = createTestContext(element, 'RESPONSE');
|
|
66
|
+
|
|
67
|
+
const result = standardTextEntryExtractor.extract(element, context);
|
|
68
|
+
|
|
69
|
+
expect(result.patternMask).toBeFalsy();
|
|
70
|
+
expect(result.placeholderText).toBe('');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('canHandle predicate', () => {
|
|
74
|
+
test('handles textEntryInteraction element', () => {
|
|
75
|
+
const xml = `<textEntryInteraction responseIdentifier="RESPONSE" />`;
|
|
76
|
+
const element = parseQTI(xml);
|
|
77
|
+
const context = createTestContext(element);
|
|
78
|
+
|
|
79
|
+
expect(standardTextEntryExtractor.canHandle(element, context)).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('rejects non-textEntryInteraction elements', () => {
|
|
83
|
+
const xml = `<choiceInteraction responseIdentifier="RESPONSE" />`;
|
|
84
|
+
const element = parseQTI(xml);
|
|
85
|
+
const context = createTestContext(element);
|
|
86
|
+
|
|
87
|
+
expect(standardTextEntryExtractor.canHandle(element, context)).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('validation', () => {
|
|
92
|
+
test('validates correct text entry data', () => {
|
|
93
|
+
const data = {
|
|
94
|
+
expectedLength: 20,
|
|
95
|
+
patternMask: '',
|
|
96
|
+
placeholderText: '',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const validation = standardTextEntryExtractor.validate!(data);
|
|
100
|
+
|
|
101
|
+
expect(validation.valid).toBe(true);
|
|
102
|
+
expect(validation.errors).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('reports error for invalid expectedLength', () => {
|
|
106
|
+
const data = {
|
|
107
|
+
expectedLength: -5,
|
|
108
|
+
patternMask: '',
|
|
109
|
+
placeholderText: '',
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const validation = standardTextEntryExtractor.validate!(data);
|
|
113
|
+
|
|
114
|
+
expect(validation.valid).toBe(false);
|
|
115
|
+
expect(validation.errors).toContain('expectedLength must be positive');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('reports warning for very large expectedLength', () => {
|
|
119
|
+
const data = {
|
|
120
|
+
expectedLength: 10000,
|
|
121
|
+
patternMask: '',
|
|
122
|
+
placeholderText: '',
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const validation = standardTextEntryExtractor.validate!(data);
|
|
126
|
+
|
|
127
|
+
expect(validation.valid).toBe(true);
|
|
128
|
+
expect(validation.warnings).toContain(
|
|
129
|
+
'expectedLength (10000) is very large - consider using extendedTextInteraction'
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|