@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,280 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { Player } from '../../src/core/Player.js';
|
|
3
|
+
|
|
4
|
+
describe('Player - Correct Response Access', () => {
|
|
5
|
+
describe('Single value responses', () => {
|
|
6
|
+
test('choiceInteraction with single correct answer', () => {
|
|
7
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
8
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
9
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
|
|
10
|
+
<correctResponse><value>A</value></correctResponse>
|
|
11
|
+
</responseDeclaration>
|
|
12
|
+
<itemBody>
|
|
13
|
+
<choiceInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
14
|
+
<simpleChoice identifier="A">Choice A</simpleChoice>
|
|
15
|
+
<simpleChoice identifier="B">Choice B</simpleChoice>
|
|
16
|
+
</choiceInteraction>
|
|
17
|
+
</itemBody>
|
|
18
|
+
</assessmentItem>`;
|
|
19
|
+
const player = new Player({ itemXml: xml });
|
|
20
|
+
expect(player.getCorrectResponse('RESPONSE')).toBe('A');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('textEntryInteraction with correct text', () => {
|
|
24
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
25
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
26
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="string">
|
|
27
|
+
<correctResponse><value>Paris</value></correctResponse>
|
|
28
|
+
</responseDeclaration>
|
|
29
|
+
<itemBody>
|
|
30
|
+
<p>Capital of France: <textEntryInteraction responseIdentifier="RESPONSE" /></p>
|
|
31
|
+
</itemBody>
|
|
32
|
+
</assessmentItem>`;
|
|
33
|
+
const player = new Player({ itemXml: xml });
|
|
34
|
+
expect(player.getCorrectResponse('RESPONSE')).toBe('Paris');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('sliderInteraction with correct integer value', () => {
|
|
38
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
39
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
40
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="integer">
|
|
41
|
+
<correctResponse><value>50</value></correctResponse>
|
|
42
|
+
</responseDeclaration>
|
|
43
|
+
<itemBody>
|
|
44
|
+
<sliderInteraction responseIdentifier="RESPONSE" lowerBound="0" upperBound="100" />
|
|
45
|
+
</itemBody>
|
|
46
|
+
</assessmentItem>`;
|
|
47
|
+
const player = new Player({ itemXml: xml });
|
|
48
|
+
expect(player.getCorrectResponse('RESPONSE')).toBe(50);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('Multiple value responses', () => {
|
|
53
|
+
test('choiceInteraction with multiple correct answers', () => {
|
|
54
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
55
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
56
|
+
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="identifier">
|
|
57
|
+
<correctResponse>
|
|
58
|
+
<value>A</value>
|
|
59
|
+
<value>C</value>
|
|
60
|
+
</correctResponse>
|
|
61
|
+
</responseDeclaration>
|
|
62
|
+
<itemBody>
|
|
63
|
+
<choiceInteraction responseIdentifier="RESPONSE" maxChoices="3">
|
|
64
|
+
<simpleChoice identifier="A">Choice A</simpleChoice>
|
|
65
|
+
<simpleChoice identifier="B">Choice B</simpleChoice>
|
|
66
|
+
<simpleChoice identifier="C">Choice C</simpleChoice>
|
|
67
|
+
</choiceInteraction>
|
|
68
|
+
</itemBody>
|
|
69
|
+
</assessmentItem>`;
|
|
70
|
+
const player = new Player({ itemXml: xml });
|
|
71
|
+
const correct = player.getCorrectResponse('RESPONSE');
|
|
72
|
+
expect(Array.isArray(correct)).toBe(true);
|
|
73
|
+
expect(correct).toContain('A');
|
|
74
|
+
expect(correct).toContain('C');
|
|
75
|
+
expect(correct.length).toBe(2);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('orderInteraction with ordered correct response', () => {
|
|
79
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
80
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
81
|
+
<responseDeclaration identifier="RESPONSE" cardinality="ordered" baseType="identifier">
|
|
82
|
+
<correctResponse>
|
|
83
|
+
<value>First</value>
|
|
84
|
+
<value>Second</value>
|
|
85
|
+
<value>Third</value>
|
|
86
|
+
</correctResponse>
|
|
87
|
+
</responseDeclaration>
|
|
88
|
+
<itemBody>
|
|
89
|
+
<orderInteraction responseIdentifier="RESPONSE">
|
|
90
|
+
<simpleChoice identifier="First">First item</simpleChoice>
|
|
91
|
+
<simpleChoice identifier="Second">Second item</simpleChoice>
|
|
92
|
+
<simpleChoice identifier="Third">Third item</simpleChoice>
|
|
93
|
+
</orderInteraction>
|
|
94
|
+
</itemBody>
|
|
95
|
+
</assessmentItem>`;
|
|
96
|
+
const player = new Player({ itemXml: xml });
|
|
97
|
+
const correct = player.getCorrectResponse('RESPONSE');
|
|
98
|
+
expect(correct).toEqual(['First', 'Second', 'Third']);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('hotspotInteraction with multiple correct hotspots', () => {
|
|
102
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
103
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
104
|
+
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="identifier">
|
|
105
|
+
<correctResponse>
|
|
106
|
+
<value>A</value>
|
|
107
|
+
<value>C</value>
|
|
108
|
+
</correctResponse>
|
|
109
|
+
</responseDeclaration>
|
|
110
|
+
<itemBody>
|
|
111
|
+
<hotspotInteraction responseIdentifier="RESPONSE" maxChoices="2">
|
|
112
|
+
<object type="image/png" data="image.png" width="300" height="200" />
|
|
113
|
+
<hotspotChoice identifier="A" shape="rect" coords="0,0,100,100" />
|
|
114
|
+
<hotspotChoice identifier="B" shape="rect" coords="100,0,200,100" />
|
|
115
|
+
<hotspotChoice identifier="C" shape="rect" coords="200,0,300,100" />
|
|
116
|
+
</hotspotInteraction>
|
|
117
|
+
</itemBody>
|
|
118
|
+
</assessmentItem>`;
|
|
119
|
+
const player = new Player({ itemXml: xml });
|
|
120
|
+
const correct = player.getCorrectResponse('RESPONSE');
|
|
121
|
+
expect(Array.isArray(correct)).toBe(true);
|
|
122
|
+
expect(correct).toContain('A');
|
|
123
|
+
expect(correct).toContain('C');
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('Edge cases', () => {
|
|
128
|
+
test('returns undefined for response with no correctResponse', () => {
|
|
129
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
130
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
131
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="string" />
|
|
132
|
+
<itemBody>
|
|
133
|
+
<extendedTextInteraction responseIdentifier="RESPONSE" />
|
|
134
|
+
</itemBody>
|
|
135
|
+
</assessmentItem>`;
|
|
136
|
+
const player = new Player({ itemXml: xml });
|
|
137
|
+
expect(player.getCorrectResponse('RESPONSE')).toBeUndefined();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('returns undefined for non-existent responseId', () => {
|
|
141
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
142
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
143
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
|
|
144
|
+
<correctResponse><value>A</value></correctResponse>
|
|
145
|
+
</responseDeclaration>
|
|
146
|
+
<itemBody>
|
|
147
|
+
<choiceInteraction responseIdentifier="RESPONSE" maxChoices="1">
|
|
148
|
+
<simpleChoice identifier="A">Choice A</simpleChoice>
|
|
149
|
+
</choiceInteraction>
|
|
150
|
+
</itemBody>
|
|
151
|
+
</assessmentItem>`;
|
|
152
|
+
const player = new Player({ itemXml: xml });
|
|
153
|
+
expect(player.getCorrectResponse('NONEXISTENT')).toBeUndefined();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('getCorrectResponses returns only responses with correctResponse', () => {
|
|
157
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
158
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
159
|
+
<responseDeclaration identifier="RESP1" cardinality="single" baseType="identifier">
|
|
160
|
+
<correctResponse><value>A</value></correctResponse>
|
|
161
|
+
</responseDeclaration>
|
|
162
|
+
<responseDeclaration identifier="RESP2" cardinality="single" baseType="identifier">
|
|
163
|
+
<correctResponse><value>B</value></correctResponse>
|
|
164
|
+
</responseDeclaration>
|
|
165
|
+
<responseDeclaration identifier="RESP3" cardinality="single" baseType="identifier" />
|
|
166
|
+
<itemBody>
|
|
167
|
+
<choiceInteraction responseIdentifier="RESP1" maxChoices="1">
|
|
168
|
+
<simpleChoice identifier="A">Choice A</simpleChoice>
|
|
169
|
+
</choiceInteraction>
|
|
170
|
+
<choiceInteraction responseIdentifier="RESP2" maxChoices="1">
|
|
171
|
+
<simpleChoice identifier="B">Choice B</simpleChoice>
|
|
172
|
+
</choiceInteraction>
|
|
173
|
+
<choiceInteraction responseIdentifier="RESP3" maxChoices="1">
|
|
174
|
+
<simpleChoice identifier="C">Choice C</simpleChoice>
|
|
175
|
+
</choiceInteraction>
|
|
176
|
+
</itemBody>
|
|
177
|
+
</assessmentItem>`;
|
|
178
|
+
const player = new Player({ itemXml: xml });
|
|
179
|
+
const allCorrect = player.getCorrectResponses();
|
|
180
|
+
expect(allCorrect.RESP1).toBe('A');
|
|
181
|
+
expect(allCorrect.RESP2).toBe('B');
|
|
182
|
+
expect(allCorrect.RESP3).toBeUndefined();
|
|
183
|
+
expect(Object.keys(allCorrect).length).toBe(2);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('getCorrectResponses returns empty object when no correct responses', () => {
|
|
187
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
188
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
189
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="string" />
|
|
190
|
+
<itemBody>
|
|
191
|
+
<extendedTextInteraction responseIdentifier="RESPONSE" />
|
|
192
|
+
</itemBody>
|
|
193
|
+
</assessmentItem>`;
|
|
194
|
+
const player = new Player({ itemXml: xml });
|
|
195
|
+
const allCorrect = player.getCorrectResponses();
|
|
196
|
+
expect(Object.keys(allCorrect).length).toBe(0);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('Complex interaction types', () => {
|
|
201
|
+
test('matchInteraction with correct pairs', () => {
|
|
202
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
203
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
204
|
+
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="directedPair">
|
|
205
|
+
<correctResponse>
|
|
206
|
+
<value>A X</value>
|
|
207
|
+
<value>B Y</value>
|
|
208
|
+
</correctResponse>
|
|
209
|
+
</responseDeclaration>
|
|
210
|
+
<itemBody>
|
|
211
|
+
<matchInteraction responseIdentifier="RESPONSE" maxAssociations="2">
|
|
212
|
+
<simpleMatchSet>
|
|
213
|
+
<simpleAssociableChoice identifier="A" matchMax="1">Item A</simpleAssociableChoice>
|
|
214
|
+
<simpleAssociableChoice identifier="B" matchMax="1">Item B</simpleAssociableChoice>
|
|
215
|
+
</simpleMatchSet>
|
|
216
|
+
<simpleMatchSet>
|
|
217
|
+
<simpleAssociableChoice identifier="X" matchMax="1">Target X</simpleAssociableChoice>
|
|
218
|
+
<simpleAssociableChoice identifier="Y" matchMax="1">Target Y</simpleAssociableChoice>
|
|
219
|
+
</simpleMatchSet>
|
|
220
|
+
</matchInteraction>
|
|
221
|
+
</itemBody>
|
|
222
|
+
</assessmentItem>`;
|
|
223
|
+
const player = new Player({ itemXml: xml });
|
|
224
|
+
const correct = player.getCorrectResponse('RESPONSE');
|
|
225
|
+
expect(Array.isArray(correct)).toBe(true);
|
|
226
|
+
expect(correct).toContain('A X');
|
|
227
|
+
expect(correct).toContain('B Y');
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test('associateInteraction with correct associations', () => {
|
|
231
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
232
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
233
|
+
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="pair">
|
|
234
|
+
<correctResponse>
|
|
235
|
+
<value>A B</value>
|
|
236
|
+
<value>C D</value>
|
|
237
|
+
</correctResponse>
|
|
238
|
+
</responseDeclaration>
|
|
239
|
+
<itemBody>
|
|
240
|
+
<associateInteraction responseIdentifier="RESPONSE" maxAssociations="2">
|
|
241
|
+
<simpleAssociableChoice identifier="A" matchMax="1">A</simpleAssociableChoice>
|
|
242
|
+
<simpleAssociableChoice identifier="B" matchMax="1">B</simpleAssociableChoice>
|
|
243
|
+
<simpleAssociableChoice identifier="C" matchMax="1">C</simpleAssociableChoice>
|
|
244
|
+
<simpleAssociableChoice identifier="D" matchMax="1">D</simpleAssociableChoice>
|
|
245
|
+
</associateInteraction>
|
|
246
|
+
</itemBody>
|
|
247
|
+
</assessmentItem>`;
|
|
248
|
+
const player = new Player({ itemXml: xml });
|
|
249
|
+
const correct = player.getCorrectResponse('RESPONSE');
|
|
250
|
+
expect(Array.isArray(correct)).toBe(true);
|
|
251
|
+
expect(correct.length).toBe(2);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test('gapMatchInteraction with correct gap fillings', () => {
|
|
255
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
256
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="test">
|
|
257
|
+
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="directedPair">
|
|
258
|
+
<correctResponse>
|
|
259
|
+
<value>W1 G1</value>
|
|
260
|
+
<value>W2 G2</value>
|
|
261
|
+
</correctResponse>
|
|
262
|
+
</responseDeclaration>
|
|
263
|
+
<itemBody>
|
|
264
|
+
<gapMatchInteraction responseIdentifier="RESPONSE">
|
|
265
|
+
<gapText identifier="W1">word1</gapText>
|
|
266
|
+
<gapText identifier="W2">word2</gapText>
|
|
267
|
+
<blockquote>
|
|
268
|
+
<p>The <gap identifier="G1" /> and <gap identifier="G2" />.</p>
|
|
269
|
+
</blockquote>
|
|
270
|
+
</gapMatchInteraction>
|
|
271
|
+
</itemBody>
|
|
272
|
+
</assessmentItem>`;
|
|
273
|
+
const player = new Player({ itemXml: xml });
|
|
274
|
+
const correct = player.getCorrectResponse('RESPONSE');
|
|
275
|
+
expect(Array.isArray(correct)).toBe(true);
|
|
276
|
+
expect(correct).toContain('W1 G1');
|
|
277
|
+
expect(correct).toContain('W2 G2');
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { Player } from '../../src/core/Player.js';
|
|
3
|
+
|
|
4
|
+
describe('interaction plumbing (response shapes)', () => {
|
|
5
|
+
test('associateInteraction: pair + multiple canonicalizes pair values (unordered within pair)', () => {
|
|
6
|
+
const itemXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
7
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="assoc" adaptive="false" timeDependent="false">
|
|
8
|
+
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="pair">
|
|
9
|
+
<correctResponse>
|
|
10
|
+
<value>A B</value>
|
|
11
|
+
<value>C D</value>
|
|
12
|
+
</correctResponse>
|
|
13
|
+
</responseDeclaration>
|
|
14
|
+
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
|
|
15
|
+
<defaultValue><value>0</value></defaultValue>
|
|
16
|
+
</outcomeDeclaration>
|
|
17
|
+
<outcomeDeclaration identifier="MAXSCORE" cardinality="single" baseType="float">
|
|
18
|
+
<defaultValue><value>1</value></defaultValue>
|
|
19
|
+
</outcomeDeclaration>
|
|
20
|
+
<itemBody>
|
|
21
|
+
<associateInteraction responseIdentifier="RESPONSE" shuffle="false" maxAssociations="2">
|
|
22
|
+
<simpleAssociableChoice identifier="A" matchMax="1">A</simpleAssociableChoice>
|
|
23
|
+
<simpleAssociableChoice identifier="B" matchMax="1">B</simpleAssociableChoice>
|
|
24
|
+
<simpleAssociableChoice identifier="C" matchMax="1">C</simpleAssociableChoice>
|
|
25
|
+
<simpleAssociableChoice identifier="D" matchMax="1">D</simpleAssociableChoice>
|
|
26
|
+
</associateInteraction>
|
|
27
|
+
</itemBody>
|
|
28
|
+
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>
|
|
29
|
+
</assessmentItem>`;
|
|
30
|
+
|
|
31
|
+
const player = new Player({ itemXml });
|
|
32
|
+
player.setResponses({ RESPONSE: ['B A', 'C D'] });
|
|
33
|
+
|
|
34
|
+
const r = player.getResponses().RESPONSE as string[];
|
|
35
|
+
expect(Array.isArray(r)).toBe(true);
|
|
36
|
+
// pair is unordered: "B A" should be treated as "A B"
|
|
37
|
+
expect(r).toContain('A B');
|
|
38
|
+
expect(r).toContain('C D');
|
|
39
|
+
|
|
40
|
+
const result = player.processResponses();
|
|
41
|
+
expect(result.score).toBe(1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('matchInteraction: directedPair + multiple preserves order within pair', () => {
|
|
45
|
+
const itemXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
46
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="match" adaptive="false" timeDependent="false">
|
|
47
|
+
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="directedPair">
|
|
48
|
+
<correctResponse>
|
|
49
|
+
<value>A B</value>
|
|
50
|
+
</correctResponse>
|
|
51
|
+
</responseDeclaration>
|
|
52
|
+
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
|
|
53
|
+
<defaultValue><value>0</value></defaultValue>
|
|
54
|
+
</outcomeDeclaration>
|
|
55
|
+
<outcomeDeclaration identifier="MAXSCORE" cardinality="single" baseType="float">
|
|
56
|
+
<defaultValue><value>1</value></defaultValue>
|
|
57
|
+
</outcomeDeclaration>
|
|
58
|
+
<itemBody>
|
|
59
|
+
<matchInteraction responseIdentifier="RESPONSE" shuffle="false" maxAssociations="1">
|
|
60
|
+
<simpleMatchSet>
|
|
61
|
+
<simpleAssociableChoice identifier="A" matchMax="1">A</simpleAssociableChoice>
|
|
62
|
+
</simpleMatchSet>
|
|
63
|
+
<simpleMatchSet>
|
|
64
|
+
<simpleAssociableChoice identifier="B" matchMax="1">B</simpleAssociableChoice>
|
|
65
|
+
</simpleMatchSet>
|
|
66
|
+
</matchInteraction>
|
|
67
|
+
</itemBody>
|
|
68
|
+
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>
|
|
69
|
+
</assessmentItem>`;
|
|
70
|
+
|
|
71
|
+
const player = new Player({ itemXml });
|
|
72
|
+
player.setResponses({ RESPONSE: ['B A'] });
|
|
73
|
+
|
|
74
|
+
const r = player.getResponses().RESPONSE as string[];
|
|
75
|
+
expect(r).toEqual(['B A']);
|
|
76
|
+
|
|
77
|
+
const result = player.processResponses();
|
|
78
|
+
expect(result.score).toBe(0);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('orderInteraction: identifier + ordered preserves order and match is order-sensitive', () => {
|
|
82
|
+
const itemXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
83
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="order" adaptive="false" timeDependent="false">
|
|
84
|
+
<responseDeclaration identifier="RESPONSE" cardinality="ordered" baseType="identifier">
|
|
85
|
+
<correctResponse>
|
|
86
|
+
<value>A</value>
|
|
87
|
+
<value>B</value>
|
|
88
|
+
</correctResponse>
|
|
89
|
+
</responseDeclaration>
|
|
90
|
+
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
|
|
91
|
+
<defaultValue><value>0</value></defaultValue>
|
|
92
|
+
</outcomeDeclaration>
|
|
93
|
+
<outcomeDeclaration identifier="MAXSCORE" cardinality="single" baseType="float">
|
|
94
|
+
<defaultValue><value>1</value></defaultValue>
|
|
95
|
+
</outcomeDeclaration>
|
|
96
|
+
<itemBody>
|
|
97
|
+
<orderInteraction responseIdentifier="RESPONSE" shuffle="false" orientation="horizontal">
|
|
98
|
+
<simpleChoice identifier="A">A</simpleChoice>
|
|
99
|
+
<simpleChoice identifier="B">B</simpleChoice>
|
|
100
|
+
</orderInteraction>
|
|
101
|
+
</itemBody>
|
|
102
|
+
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>
|
|
103
|
+
</assessmentItem>`;
|
|
104
|
+
|
|
105
|
+
const player = new Player({ itemXml });
|
|
106
|
+
player.setResponses({ RESPONSE: ['A', 'B'] });
|
|
107
|
+
expect(player.processResponses().score).toBe(1);
|
|
108
|
+
|
|
109
|
+
player.setResponses({ RESPONSE: ['B', 'A'] });
|
|
110
|
+
expect(player.processResponses().score).toBe(0);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('selectPointInteraction: point + single uses "x y" lexical form', () => {
|
|
114
|
+
const itemXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
115
|
+
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" identifier="pt" adaptive="false" timeDependent="false">
|
|
116
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="point"/>
|
|
117
|
+
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
|
|
118
|
+
<defaultValue><value>0</value></defaultValue>
|
|
119
|
+
</outcomeDeclaration>
|
|
120
|
+
<outcomeDeclaration identifier="MAXSCORE" cardinality="single" baseType="float">
|
|
121
|
+
<defaultValue><value>1</value></defaultValue>
|
|
122
|
+
</outcomeDeclaration>
|
|
123
|
+
<itemBody>
|
|
124
|
+
<selectPointInteraction responseIdentifier="RESPONSE" maxPoints="1">
|
|
125
|
+
<object data="bg.png" type="image/png" width="100" height="100"/>
|
|
126
|
+
</selectPointInteraction>
|
|
127
|
+
</itemBody>
|
|
128
|
+
<responseProcessing>
|
|
129
|
+
<setOutcomeValue identifier="SCORE">
|
|
130
|
+
<mapResponsePoint identifier="RESPONSE"/>
|
|
131
|
+
</setOutcomeValue>
|
|
132
|
+
</responseProcessing>
|
|
133
|
+
</assessmentItem>`;
|
|
134
|
+
|
|
135
|
+
const player = new Player({ itemXml });
|
|
136
|
+
player.setResponses({ RESPONSE: '10 20' });
|
|
137
|
+
expect(player.getResponses().RESPONSE).toBe('10 20');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
|