@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,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<assessmentItem
|
|
3
|
+
xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2"
|
|
4
|
+
identifier="templateConstraint-example"
|
|
5
|
+
title="templateConstraint Example"
|
|
6
|
+
adaptive="false"
|
|
7
|
+
timeDependent="false">
|
|
8
|
+
|
|
9
|
+
<templateDeclaration identifier="A" cardinality="single" baseType="integer">
|
|
10
|
+
<defaultValue><value>0</value></defaultValue>
|
|
11
|
+
</templateDeclaration>
|
|
12
|
+
|
|
13
|
+
<templateDeclaration identifier="B" cardinality="single" baseType="integer">
|
|
14
|
+
<defaultValue><value>0</value></defaultValue>
|
|
15
|
+
</templateDeclaration>
|
|
16
|
+
|
|
17
|
+
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="integer">
|
|
18
|
+
<defaultValue><value>0</value></defaultValue>
|
|
19
|
+
</outcomeDeclaration>
|
|
20
|
+
|
|
21
|
+
<itemBody>
|
|
22
|
+
<p>Template values A and B are randomly chosen but must differ.</p>
|
|
23
|
+
</itemBody>
|
|
24
|
+
|
|
25
|
+
<templateProcessing>
|
|
26
|
+
<setTemplateValue identifier="A">
|
|
27
|
+
<randomInteger min="1" max="3" step="1"/>
|
|
28
|
+
</setTemplateValue>
|
|
29
|
+
<setTemplateValue identifier="B">
|
|
30
|
+
<randomInteger min="1" max="3" step="1"/>
|
|
31
|
+
</setTemplateValue>
|
|
32
|
+
<templateConstraint>
|
|
33
|
+
<not>
|
|
34
|
+
<equal>
|
|
35
|
+
<variable identifier="A"/>
|
|
36
|
+
<variable identifier="B"/>
|
|
37
|
+
</equal>
|
|
38
|
+
</not>
|
|
39
|
+
</templateConstraint>
|
|
40
|
+
</templateProcessing>
|
|
41
|
+
|
|
42
|
+
<outcomeProcessing>
|
|
43
|
+
<setOutcomeValue identifier="SCORE">
|
|
44
|
+
<sum>
|
|
45
|
+
<variable identifier="A"/>
|
|
46
|
+
<variable identifier="B"/>
|
|
47
|
+
</sum>
|
|
48
|
+
</setOutcomeValue>
|
|
49
|
+
</outcomeProcessing>
|
|
50
|
+
</assessmentItem>
|
|
51
|
+
|
|
52
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "internal",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"notes": "Covers QTI 2.2.2 templateConstraint restart semantics (retry with template vars reset to defaults until constraint holds or max iterations reached).",
|
|
5
|
+
"covers": [
|
|
6
|
+
"expr.randomInteger",
|
|
7
|
+
"randomInteger",
|
|
8
|
+
"setTemplateValue",
|
|
9
|
+
"stmt.setTemplateValue",
|
|
10
|
+
"stmt.templateConstraint",
|
|
11
|
+
"templateConstraint",
|
|
12
|
+
"templateProcessing"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "template_randomFloat_roundTo_mathConstant",
|
|
3
|
+
"seed": 123,
|
|
4
|
+
"cases": [
|
|
5
|
+
{
|
|
6
|
+
"name": "randomFloat_is_deterministic_with_seed_and_roundTo_and_mathConstant_work",
|
|
7
|
+
"responses": { "RESPONSE": null },
|
|
8
|
+
"expect": {
|
|
9
|
+
"outcomes": { "SCORE": 0 },
|
|
10
|
+
"itemBodyContains": ["X rounded: 0.79", "pi rounded: 3.14"]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<assessmentItem
|
|
3
|
+
xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2"
|
|
4
|
+
identifier="template-randomfloat-roundto-constant"
|
|
5
|
+
title="Template randomFloat + roundTo + mathConstant"
|
|
6
|
+
adaptive="false"
|
|
7
|
+
timeDependent="false">
|
|
8
|
+
|
|
9
|
+
<templateDeclaration identifier="X" cardinality="single" baseType="float">
|
|
10
|
+
<defaultValue><value>0</value></defaultValue>
|
|
11
|
+
</templateDeclaration>
|
|
12
|
+
|
|
13
|
+
<templateDeclaration identifier="XR" cardinality="single" baseType="float">
|
|
14
|
+
<defaultValue><value>0</value></defaultValue>
|
|
15
|
+
</templateDeclaration>
|
|
16
|
+
|
|
17
|
+
<templateDeclaration identifier="PI2" cardinality="single" baseType="float">
|
|
18
|
+
<defaultValue><value>0</value></defaultValue>
|
|
19
|
+
</templateDeclaration>
|
|
20
|
+
|
|
21
|
+
<templateProcessing>
|
|
22
|
+
<setTemplateValue identifier="X">
|
|
23
|
+
<randomFloat min="0" max="1"/>
|
|
24
|
+
</setTemplateValue>
|
|
25
|
+
<setTemplateValue identifier="XR">
|
|
26
|
+
<roundTo roundingMode="decimalPlaces" figures="2">
|
|
27
|
+
<variable identifier="X"/>
|
|
28
|
+
</roundTo>
|
|
29
|
+
</setTemplateValue>
|
|
30
|
+
<setTemplateValue identifier="PI2">
|
|
31
|
+
<roundTo roundingMode="decimalPlaces" figures="2">
|
|
32
|
+
<mathConstant name="pi"/>
|
|
33
|
+
</roundTo>
|
|
34
|
+
</setTemplateValue>
|
|
35
|
+
</templateProcessing>
|
|
36
|
+
|
|
37
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="integer"/>
|
|
38
|
+
|
|
39
|
+
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
|
|
40
|
+
<defaultValue><value>0.0</value></defaultValue>
|
|
41
|
+
</outcomeDeclaration>
|
|
42
|
+
|
|
43
|
+
<itemBody>
|
|
44
|
+
<p>X rounded: <printedVariable identifier="XR"/>; pi rounded: <printedVariable identifier="PI2"/></p>
|
|
45
|
+
<textEntryInteraction responseIdentifier="RESPONSE" expectedLength="3"/>
|
|
46
|
+
</itemBody>
|
|
47
|
+
</assessmentItem>
|
|
48
|
+
|
|
49
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "internal",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"notes": "Template processing with QTI 2.2.2 attribute-based randomFloat/randomInteger + roundTo + mathConstant, asserted via printedVariable rendering.",
|
|
5
|
+
"covers": [
|
|
6
|
+
"expr.mathConstant",
|
|
7
|
+
"expr.randomFloat",
|
|
8
|
+
"expr.roundTo",
|
|
9
|
+
"mathConstant",
|
|
10
|
+
"printedVariable",
|
|
11
|
+
"randomFloat",
|
|
12
|
+
"roundTo",
|
|
13
|
+
"templateProcessing"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "template_randomInteger_printedVariable",
|
|
3
|
+
"seed": 123,
|
|
4
|
+
"cases": [
|
|
5
|
+
{
|
|
6
|
+
"name": "template_processing_initializes_A_and_B_deterministically",
|
|
7
|
+
"responses": { "RESPONSE": null },
|
|
8
|
+
"expect": {
|
|
9
|
+
"outcomes": { "SCORE": 0 },
|
|
10
|
+
"itemBodyContains": ["What is 5 + 3?"]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<assessmentItem
|
|
3
|
+
xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2"
|
|
4
|
+
identifier="template-example"
|
|
5
|
+
title="Template Processing Example"
|
|
6
|
+
adaptive="false"
|
|
7
|
+
timeDependent="false">
|
|
8
|
+
|
|
9
|
+
<templateDeclaration identifier="A" cardinality="single" baseType="integer">
|
|
10
|
+
<defaultValue><value>0</value></defaultValue>
|
|
11
|
+
</templateDeclaration>
|
|
12
|
+
|
|
13
|
+
<templateDeclaration identifier="B" cardinality="single" baseType="integer">
|
|
14
|
+
<defaultValue><value>0</value></defaultValue>
|
|
15
|
+
</templateDeclaration>
|
|
16
|
+
|
|
17
|
+
<templateProcessing>
|
|
18
|
+
<setTemplateValue identifier="A">
|
|
19
|
+
<randomInteger min="5" max="5"/>
|
|
20
|
+
</setTemplateValue>
|
|
21
|
+
<setTemplateValue identifier="B">
|
|
22
|
+
<randomInteger min="3" max="3"/>
|
|
23
|
+
</setTemplateValue>
|
|
24
|
+
</templateProcessing>
|
|
25
|
+
|
|
26
|
+
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="integer"/>
|
|
27
|
+
|
|
28
|
+
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
|
|
29
|
+
<defaultValue><value>0.0</value></defaultValue>
|
|
30
|
+
</outcomeDeclaration>
|
|
31
|
+
|
|
32
|
+
<itemBody>
|
|
33
|
+
<p>What is <printedVariable identifier="A"/> + <printedVariable identifier="B"/>?</p>
|
|
34
|
+
<textEntryInteraction responseIdentifier="RESPONSE" expectedLength="5"/>
|
|
35
|
+
</itemBody>
|
|
36
|
+
</assessmentItem>
|
|
37
|
+
|
|
38
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "internal",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"notes": "templateProcessing + randomInteger + printedVariable substitution in itemBody.",
|
|
5
|
+
"covers": [
|
|
6
|
+
"expr.randomInteger",
|
|
7
|
+
"printedVariable",
|
|
8
|
+
"randomInteger",
|
|
9
|
+
"setTemplateValue",
|
|
10
|
+
"stmt.setTemplateValue",
|
|
11
|
+
"templateProcessing"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { Player } from '../../src/core/Player.js';
|
|
4
|
+
import type { ConformanceCaseFile, ConformanceFixtureManifest } from './types.js';
|
|
5
|
+
|
|
6
|
+
export interface LoadedFixture {
|
|
7
|
+
fixtureDir: string;
|
|
8
|
+
itemXml: string;
|
|
9
|
+
caseFile: ConformanceCaseFile;
|
|
10
|
+
manifest?: ConformanceFixtureManifest;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function listFixtureDirs(fixturesRoot: string): Promise<string[]> {
|
|
14
|
+
const entries = await readdir(fixturesRoot, { withFileTypes: true });
|
|
15
|
+
return entries
|
|
16
|
+
.filter((e) => e.isDirectory())
|
|
17
|
+
.map((e) => join(fixturesRoot, e.name))
|
|
18
|
+
.sort();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function loadFixture(fixtureDir: string): Promise<LoadedFixture> {
|
|
22
|
+
const itemXml = await readFile(join(fixtureDir, 'item.xml'), 'utf8');
|
|
23
|
+
const caseFileRaw = await readFile(join(fixtureDir, 'cases.json'), 'utf8');
|
|
24
|
+
const caseFile = JSON.parse(caseFileRaw) as ConformanceCaseFile;
|
|
25
|
+
|
|
26
|
+
let manifest: ConformanceFixtureManifest | undefined;
|
|
27
|
+
try {
|
|
28
|
+
const manifestRaw = await readFile(join(fixtureDir, 'manifest.json'), 'utf8');
|
|
29
|
+
manifest = JSON.parse(manifestRaw) as ConformanceFixtureManifest;
|
|
30
|
+
} catch {
|
|
31
|
+
// optional
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return { fixtureDir, itemXml, caseFile, manifest };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function normalizeOutcomeValue(value: unknown): unknown {
|
|
38
|
+
// Keep it intentionally simple initially; extend as we add more fixtures.
|
|
39
|
+
if (typeof value === 'number') {
|
|
40
|
+
if (Number.isNaN(value)) return 'NaN';
|
|
41
|
+
if (!Number.isFinite(value)) return value > 0 ? 'Infinity' : '-Infinity';
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(value)) return value.map(normalizeOutcomeValue);
|
|
45
|
+
if (value && typeof value === 'object') {
|
|
46
|
+
// stable key ordering for deep equality comparisons
|
|
47
|
+
const obj = value as Record<string, unknown>;
|
|
48
|
+
return Object.fromEntries(Object.keys(obj).sort().map((k) => [k, normalizeOutcomeValue(obj[k])]));
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function normalizeOutcomes(outcomes: Record<string, unknown>): Record<string, unknown> {
|
|
54
|
+
return Object.fromEntries(
|
|
55
|
+
Object.keys(outcomes)
|
|
56
|
+
.sort()
|
|
57
|
+
.map((k) => [k, normalizeOutcomeValue(outcomes[k])])
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function runItemCase(args: {
|
|
62
|
+
itemXml: string;
|
|
63
|
+
responses: Record<string, unknown>;
|
|
64
|
+
role?: 'candidate' | 'proctor' | 'scorer';
|
|
65
|
+
seed?: number;
|
|
66
|
+
useSubmitAttempt?: boolean;
|
|
67
|
+
countAttempt?: boolean;
|
|
68
|
+
}) {
|
|
69
|
+
const player = new Player({
|
|
70
|
+
itemXml: args.itemXml,
|
|
71
|
+
role: args.role ?? 'candidate',
|
|
72
|
+
seed: args.seed ?? 42,
|
|
73
|
+
});
|
|
74
|
+
player.setResponses(args.responses as any);
|
|
75
|
+
|
|
76
|
+
const itemBodyHtml = player.getItemBodyHtml();
|
|
77
|
+
|
|
78
|
+
if (args.useSubmitAttempt) {
|
|
79
|
+
return { result: player.submitAttempt(args.countAttempt ?? true), itemBodyHtml };
|
|
80
|
+
}
|
|
81
|
+
return { result: player.processResponses(), itemBodyHtml };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { basename, join } from 'node:path';
|
|
3
|
+
import {
|
|
4
|
+
listFixtureDirs,
|
|
5
|
+
loadFixture,
|
|
6
|
+
normalizeOutcomes,
|
|
7
|
+
runItemCase,
|
|
8
|
+
} from './harness.js';
|
|
9
|
+
|
|
10
|
+
const FIXTURES_ROOT = join(import.meta.dir, 'fixtures');
|
|
11
|
+
|
|
12
|
+
describe('conformance fixtures', async () => {
|
|
13
|
+
const fixtureDirs = await listFixtureDirs(FIXTURES_ROOT);
|
|
14
|
+
const coverage = new Map<string, Set<string>>();
|
|
15
|
+
|
|
16
|
+
test('should discover at least one fixture', () => {
|
|
17
|
+
expect(fixtureDirs.length).toBeGreaterThan(0);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
for (const fixtureDir of fixtureDirs) {
|
|
21
|
+
const fixtureId = basename(fixtureDir);
|
|
22
|
+
|
|
23
|
+
describe(fixtureId, async () => {
|
|
24
|
+
let fixture: Awaited<ReturnType<typeof loadFixture>>;
|
|
25
|
+
try {
|
|
26
|
+
fixture = await loadFixture(fixtureDir);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
const code = err && typeof err === 'object' && 'code' in err ? (err as any).code : undefined;
|
|
29
|
+
// In constrained environments (e.g. sandboxed tooling), fixture folders may be unreadable.
|
|
30
|
+
// Only skip for permission-related errors; other errors should fail the suite.
|
|
31
|
+
if (code === 'EACCES' || code === 'EPERM') {
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.warn(`[conformance] skipping fixture "${fixtureId}" (${code})`);
|
|
34
|
+
test.skip('fixture load skipped due to filesystem permissions', () => {});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Collect coverage tags (best-effort)
|
|
41
|
+
const covers = fixture.manifest?.covers || [];
|
|
42
|
+
for (const tag of covers) {
|
|
43
|
+
if (!coverage.has(tag)) coverage.set(tag, new Set());
|
|
44
|
+
coverage.get(tag)?.add(fixtureId);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
test('cases.json id should match folder name', () => {
|
|
48
|
+
expect(fixture.caseFile.id).toBe(fixtureId);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
for (const c of fixture.caseFile.cases) {
|
|
52
|
+
test(c.name, () => {
|
|
53
|
+
const runAndAssert = () => {
|
|
54
|
+
const { result, itemBodyHtml } = runItemCase({
|
|
55
|
+
itemXml: fixture.itemXml,
|
|
56
|
+
responses: c.responses,
|
|
57
|
+
seed: fixture.caseFile.seed,
|
|
58
|
+
useSubmitAttempt: c.useSubmitAttempt,
|
|
59
|
+
countAttempt: c.countAttempt,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (c.expect.score !== undefined) {
|
|
63
|
+
expect(result.score).toBe(c.expect.score);
|
|
64
|
+
}
|
|
65
|
+
if (c.expect.maxScore !== undefined) {
|
|
66
|
+
expect(result.maxScore).toBe(c.expect.maxScore);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (c.expect.outcomes) {
|
|
70
|
+
const actual = normalizeOutcomes(result.outcomeValues || {});
|
|
71
|
+
const expected = normalizeOutcomes(c.expect.outcomes);
|
|
72
|
+
for (const [k, v] of Object.entries(expected)) {
|
|
73
|
+
expect(actual[k]).toEqual(v);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (c.expect.modalFeedbackIdentifiers) {
|
|
78
|
+
const actualIds = (result.modalFeedback || [])
|
|
79
|
+
.map((f) => f.identifier)
|
|
80
|
+
.sort();
|
|
81
|
+
const expectedIds = [...c.expect.modalFeedbackIdentifiers].sort();
|
|
82
|
+
expect(actualIds).toEqual(expectedIds);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (c.expect.itemBodyContains) {
|
|
86
|
+
for (const s of c.expect.itemBodyContains) {
|
|
87
|
+
expect(itemBodyHtml).toContain(s);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (c.xfail) {
|
|
93
|
+
let failedAsExpected = false;
|
|
94
|
+
try {
|
|
95
|
+
runAndAssert();
|
|
96
|
+
} catch {
|
|
97
|
+
failedAsExpected = true;
|
|
98
|
+
}
|
|
99
|
+
if (!failedAsExpected) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`xfail case unexpectedly passed${c.xfailReason ? `: ${c.xfailReason}` : ''}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
runAndAssert();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
test('coverage report (operator/statement -> fixtures)', () => {
|
|
114
|
+
// This is intentionally a lightweight report: it gives visibility into what
|
|
115
|
+
// we *think* we cover, based on fixture manifests.
|
|
116
|
+
const lines: string[] = [];
|
|
117
|
+
for (const tag of [...coverage.keys()].sort()) {
|
|
118
|
+
const fixtures = [...(coverage.get(tag) || [])].sort();
|
|
119
|
+
lines.push(`${tag}: ${fixtures.join(', ')}`);
|
|
120
|
+
}
|
|
121
|
+
// eslint-disable-next-line no-console
|
|
122
|
+
console.log(lines.length ? `\n[conformance coverage]\n${lines.join('\n')}\n` : '\n[conformance coverage]\n(none)\n');
|
|
123
|
+
expect(true).toBe(true);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { readdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
type Manifest = {
|
|
5
|
+
id?: string;
|
|
6
|
+
covers?: string[];
|
|
7
|
+
[k: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const fixturesRoot = join(process.cwd(), 'packages/item-player/tests/conformance/fixtures');
|
|
11
|
+
|
|
12
|
+
// Map non-canonical tags (typically XML element names) to canonical AST-kind coverage tags.
|
|
13
|
+
// Keep this intentionally additive: we do NOT remove existing tags.
|
|
14
|
+
const CANONICAL: Record<string, string> = {
|
|
15
|
+
// statements
|
|
16
|
+
responsecondition: 'stmt.responseCondition',
|
|
17
|
+
outcomecondition: 'stmt.outcomeCondition',
|
|
18
|
+
templatecondition: 'stmt.templateCondition',
|
|
19
|
+
setoutcomevalue: 'stmt.setOutcomeValue',
|
|
20
|
+
settemplatevalue: 'stmt.setTemplateValue',
|
|
21
|
+
setresponsevalue: 'stmt.setResponseValue',
|
|
22
|
+
setcorrectresponse: 'stmt.setCorrectResponse',
|
|
23
|
+
setdefaultvalue: 'stmt.setDefaultValue',
|
|
24
|
+
exitresponse: 'stmt.exitResponse',
|
|
25
|
+
exittemplate: 'stmt.exitTemplate',
|
|
26
|
+
exittest: 'stmt.exitTest',
|
|
27
|
+
templateconstraint: 'stmt.templateConstraint',
|
|
28
|
+
lookupoutcomevalue: 'stmt.lookupOutcomeValue',
|
|
29
|
+
|
|
30
|
+
// expressions (core)
|
|
31
|
+
basevalue: 'expr.baseValue',
|
|
32
|
+
variable: 'expr.variable',
|
|
33
|
+
correct: 'expr.correct',
|
|
34
|
+
null: 'expr.null',
|
|
35
|
+
default: 'expr.default',
|
|
36
|
+
|
|
37
|
+
// boolean / comparison
|
|
38
|
+
and: 'expr.and',
|
|
39
|
+
or: 'expr.or',
|
|
40
|
+
not: 'expr.not',
|
|
41
|
+
equal: 'expr.equal',
|
|
42
|
+
notequal: 'expr.notEqual',
|
|
43
|
+
gt: 'expr.gt',
|
|
44
|
+
gte: 'expr.gte',
|
|
45
|
+
lt: 'expr.lt',
|
|
46
|
+
lte: 'expr.lte',
|
|
47
|
+
alln: 'expr.allN',
|
|
48
|
+
anyn: 'expr.anyN',
|
|
49
|
+
member: 'expr.member',
|
|
50
|
+
contains: 'expr.contains',
|
|
51
|
+
isnull: 'expr.isNull',
|
|
52
|
+
isnotnull: 'expr.isNotNull',
|
|
53
|
+
stringmatch: 'expr.stringMatch',
|
|
54
|
+
patternmatch: 'expr.patternMatch',
|
|
55
|
+
equalrounded: 'expr.equalRounded',
|
|
56
|
+
|
|
57
|
+
// math
|
|
58
|
+
sum: 'expr.sum',
|
|
59
|
+
product: 'expr.product',
|
|
60
|
+
subtract: 'expr.subtract',
|
|
61
|
+
divide: 'expr.divide',
|
|
62
|
+
max: 'expr.max',
|
|
63
|
+
min: 'expr.min',
|
|
64
|
+
round: 'expr.round',
|
|
65
|
+
truncate: 'expr.truncate',
|
|
66
|
+
roundto: 'expr.roundTo',
|
|
67
|
+
mathconstant: 'expr.mathConstant',
|
|
68
|
+
mathoperator: 'expr.mathOperator',
|
|
69
|
+
gcd: 'expr.gcd',
|
|
70
|
+
lcm: 'expr.lcm',
|
|
71
|
+
integermodulus: 'expr.integerModulus',
|
|
72
|
+
integertofloat: 'expr.integerToFloat',
|
|
73
|
+
|
|
74
|
+
// mapping / tables
|
|
75
|
+
mapresponse: 'expr.mapResponse',
|
|
76
|
+
mapoutcome: 'expr.mapOutcome',
|
|
77
|
+
mapresponsepoint: 'expr.mapResponsePoint',
|
|
78
|
+
lookuptable: 'expr.lookupTable',
|
|
79
|
+
|
|
80
|
+
// newer / misc
|
|
81
|
+
delete: 'expr.delete',
|
|
82
|
+
repeat: 'expr.repeat',
|
|
83
|
+
durationlt: 'expr.durationLT',
|
|
84
|
+
durationgte: 'expr.durationGTE',
|
|
85
|
+
inside: 'expr.inside',
|
|
86
|
+
statsoperator: 'expr.statsOperator',
|
|
87
|
+
random: 'expr.random',
|
|
88
|
+
randominteger: 'expr.randomInteger',
|
|
89
|
+
randomfloat: 'expr.randomFloat',
|
|
90
|
+
precondition: 'expr.preCondition',
|
|
91
|
+
customoperator: 'expr.customOperator',
|
|
92
|
+
fieldvalue: 'expr.fieldValue',
|
|
93
|
+
record: 'expr.record',
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
function stableJson(obj: unknown) {
|
|
97
|
+
return JSON.stringify(obj, null, 2) + '\n';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function normalizeTag(s: string): string {
|
|
101
|
+
return s.trim().toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function main() {
|
|
105
|
+
const dirs = (await readdir(fixturesRoot, { withFileTypes: true }))
|
|
106
|
+
.filter((d) => d.isDirectory())
|
|
107
|
+
.map((d) => join(fixturesRoot, d.name))
|
|
108
|
+
.sort();
|
|
109
|
+
|
|
110
|
+
let changed = 0;
|
|
111
|
+
for (const d of dirs) {
|
|
112
|
+
const manifestPath = join(d, 'manifest.json');
|
|
113
|
+
let raw: string;
|
|
114
|
+
try {
|
|
115
|
+
raw = await readFile(manifestPath, 'utf8');
|
|
116
|
+
} catch {
|
|
117
|
+
continue; // optional
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const manifest = JSON.parse(raw) as Manifest;
|
|
121
|
+
const covers = Array.isArray(manifest.covers) ? manifest.covers.slice() : [];
|
|
122
|
+
|
|
123
|
+
const extra: string[] = [];
|
|
124
|
+
for (const c of covers) {
|
|
125
|
+
const k = normalizeTag(c);
|
|
126
|
+
const mapped = CANONICAL[k];
|
|
127
|
+
if (mapped) extra.push(mapped);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const next = Array.from(new Set([...covers, ...extra])).sort((a, b) => a.localeCompare(b));
|
|
131
|
+
const same =
|
|
132
|
+
covers.length === next.length &&
|
|
133
|
+
covers.every((v, i) => v === next[i]);
|
|
134
|
+
|
|
135
|
+
if (!same) {
|
|
136
|
+
manifest.covers = next;
|
|
137
|
+
await writeFile(manifestPath, stableJson(manifest), 'utf8');
|
|
138
|
+
changed++;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// eslint-disable-next-line no-console
|
|
143
|
+
console.log(`normalize-covers: updated ${changed} manifest(s)`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
main().catch((e) => {
|
|
147
|
+
// eslint-disable-next-line no-console
|
|
148
|
+
console.error(e);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface ConformanceCaseFile {
|
|
2
|
+
/** Fixture id (should match the fixture folder name) */
|
|
3
|
+
id: string;
|
|
4
|
+
/** Optional deterministic seed for randomness/template processing */
|
|
5
|
+
seed?: number;
|
|
6
|
+
cases: ConformanceCase[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ConformanceCase {
|
|
10
|
+
name: string;
|
|
11
|
+
/** Response map keyed by response identifier */
|
|
12
|
+
responses: Record<string, unknown>;
|
|
13
|
+
expect: ConformanceExpectations;
|
|
14
|
+
/**
|
|
15
|
+
* If true, this case is expected to fail (known gap).
|
|
16
|
+
* The test will PASS if an assertion fails or an error is thrown,
|
|
17
|
+
* and FAIL if it unexpectedly passes.
|
|
18
|
+
*/
|
|
19
|
+
xfail?: boolean;
|
|
20
|
+
xfailReason?: string;
|
|
21
|
+
/** If true, run `submitAttempt()` (adaptive) instead of `processResponses()` */
|
|
22
|
+
useSubmitAttempt?: boolean;
|
|
23
|
+
/** Passed to `submitAttempt(countAttempt)` when `useSubmitAttempt` is true */
|
|
24
|
+
countAttempt?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ConformanceExpectations {
|
|
28
|
+
score?: number;
|
|
29
|
+
maxScore?: number;
|
|
30
|
+
outcomes?: Record<string, unknown>;
|
|
31
|
+
/** Substrings expected to be present in `player.getItemBodyHtml()` */
|
|
32
|
+
itemBodyContains?: string[];
|
|
33
|
+
/** Modal feedback identifiers (order-insensitive) */
|
|
34
|
+
modalFeedbackIdentifiers?: string[];
|
|
35
|
+
/** Known unsupported feature codes (future-proofing) */
|
|
36
|
+
unsupported?: string[];
|
|
37
|
+
/** Warning codes/messages (future-proofing) */
|
|
38
|
+
warnings?: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ConformanceFixtureManifest {
|
|
42
|
+
source?: string;
|
|
43
|
+
upstreamUrl?: string;
|
|
44
|
+
license?: string;
|
|
45
|
+
notes?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Optional list of coverage tags (operators/statements/features) for reporting.
|
|
48
|
+
* Example: ["responseCondition", "match", "setOutcomeValue"]
|
|
49
|
+
*/
|
|
50
|
+
covers?: string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|