@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,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for all QTI interaction web components
|
|
3
|
+
*
|
|
4
|
+
* Provides common functionality including:
|
|
5
|
+
* - Reactive property system
|
|
6
|
+
* - Shadow DOM management
|
|
7
|
+
* - Event emission helpers
|
|
8
|
+
* - Update scheduling
|
|
9
|
+
* - Lifecycle management
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* export class QTIChoiceInteraction extends QTIInteractionBase<ChoiceInteractionData> {
|
|
14
|
+
* protected render(): void {
|
|
15
|
+
* this.shadowRoot.innerHTML = `...`;
|
|
16
|
+
* this.attachEventListeners();
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* protected cleanup(): void {
|
|
20
|
+
* // Optional cleanup
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { HtmlContent } from '../types/index.js';
|
|
27
|
+
import type { InteractionData } from '../types/interactions.js';
|
|
28
|
+
import {
|
|
29
|
+
QTIChangeEvent,
|
|
30
|
+
QTIErrorEvent,
|
|
31
|
+
type QTIInteractionElement,
|
|
32
|
+
QTIReadyEvent,
|
|
33
|
+
} from './QTIInteractionElement.js';
|
|
34
|
+
|
|
35
|
+
export abstract class QTIInteractionBase<TData extends InteractionData = InteractionData>
|
|
36
|
+
extends HTMLElement
|
|
37
|
+
implements QTIInteractionElement
|
|
38
|
+
{
|
|
39
|
+
private _interaction: TData | null = null;
|
|
40
|
+
private _response: any = null;
|
|
41
|
+
private _disabled = false;
|
|
42
|
+
private _typeset?: (element: HTMLElement) => void;
|
|
43
|
+
|
|
44
|
+
declare shadowRoot: ShadowRoot; // Override HTMLElement's shadowRoot type
|
|
45
|
+
private updateScheduled = false;
|
|
46
|
+
private isInitialized = false;
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
// attachShadow returns ShadowRoot, and we cast to ensure type compatibility
|
|
51
|
+
(this as any).shadowRoot = this.attachShadow({ mode: 'open' });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ========== Property Getters/Setters ==========
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The processed interaction data from QTI XML
|
|
58
|
+
* Required property - throws if accessed before being set
|
|
59
|
+
*/
|
|
60
|
+
get interaction(): TData {
|
|
61
|
+
if (!this._interaction) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`${this.tagName}: interaction property must be set before use`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return this._interaction;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
set interaction(value: TData) {
|
|
70
|
+
if (this._interaction !== value) {
|
|
71
|
+
this._interaction = value;
|
|
72
|
+
this.requestUpdate();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Current response value (type depends on interaction type)
|
|
78
|
+
* May be null if no response has been provided yet
|
|
79
|
+
*/
|
|
80
|
+
get response(): any {
|
|
81
|
+
return this._response;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
set response(value: any) {
|
|
85
|
+
if (this._response !== value) {
|
|
86
|
+
this._response = value;
|
|
87
|
+
this.requestUpdate();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Whether the interaction is in read-only/disabled mode
|
|
93
|
+
*/
|
|
94
|
+
get disabled(): boolean {
|
|
95
|
+
return this._disabled;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
set disabled(value: boolean) {
|
|
99
|
+
const newValue = Boolean(value);
|
|
100
|
+
if (this._disabled !== newValue) {
|
|
101
|
+
this._disabled = newValue;
|
|
102
|
+
this.requestUpdate();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Optional function to apply math typesetting (e.g., KaTeX, MathJax)
|
|
108
|
+
*/
|
|
109
|
+
get typeset(): ((element: HTMLElement) => void) | undefined {
|
|
110
|
+
return this._typeset;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
set typeset(value: ((element: HTMLElement) => void) | undefined) {
|
|
114
|
+
if (this._typeset !== value) {
|
|
115
|
+
this._typeset = value;
|
|
116
|
+
this.requestUpdate();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ========== Lifecycle Hooks ==========
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Called when the element is connected to the DOM
|
|
124
|
+
*/
|
|
125
|
+
connectedCallback(): void {
|
|
126
|
+
if (!this.isInitialized) {
|
|
127
|
+
this.isInitialized = true;
|
|
128
|
+
this.init();
|
|
129
|
+
}
|
|
130
|
+
this.requestUpdate();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Called when the element is disconnected from the DOM
|
|
135
|
+
*/
|
|
136
|
+
disconnectedCallback(): void {
|
|
137
|
+
this.cleanup();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Called once when the element is first connected
|
|
142
|
+
* Override this to perform one-time initialization
|
|
143
|
+
*/
|
|
144
|
+
protected init(): void {
|
|
145
|
+
// Override in subclasses if needed
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ========== Reactive Updates ==========
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Schedule a re-render on the next microtask
|
|
152
|
+
* Multiple calls within the same tick are batched
|
|
153
|
+
*/
|
|
154
|
+
protected requestUpdate(): void {
|
|
155
|
+
if (!this.updateScheduled && this.isConnected) {
|
|
156
|
+
this.updateScheduled = true;
|
|
157
|
+
queueMicrotask(() => {
|
|
158
|
+
this.updateScheduled = false;
|
|
159
|
+
try {
|
|
160
|
+
this.render();
|
|
161
|
+
if (this.isInitialized) {
|
|
162
|
+
this.emitReady();
|
|
163
|
+
}
|
|
164
|
+
} catch (error) {
|
|
165
|
+
this.emitError(error as Error, 'render');
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ========== Abstract Methods ==========
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Render the component's UI
|
|
175
|
+
* Called automatically when properties change
|
|
176
|
+
* Must be implemented by subclasses
|
|
177
|
+
*/
|
|
178
|
+
protected abstract render(): void;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Clean up resources when component is removed from DOM
|
|
182
|
+
* Override this to remove event listeners, cancel timers, etc.
|
|
183
|
+
*/
|
|
184
|
+
protected abstract cleanup(): void;
|
|
185
|
+
|
|
186
|
+
// ========== Event Helpers ==========
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Emit a qti-change event when the user response changes
|
|
190
|
+
* @param value - The new response value
|
|
191
|
+
*/
|
|
192
|
+
protected emitChange(value: any): void {
|
|
193
|
+
if (!this._interaction) {
|
|
194
|
+
console.warn(`${this.tagName}: Cannot emit change without interaction data`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const event = new QTIChangeEvent({
|
|
199
|
+
responseId: this._interaction.responseId,
|
|
200
|
+
value,
|
|
201
|
+
timestamp: Date.now(),
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
this.dispatchEvent(event);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Emit a qti-ready event when component is initialized
|
|
209
|
+
*/
|
|
210
|
+
private emitReady(): void {
|
|
211
|
+
this.dispatchEvent(new QTIReadyEvent());
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Emit a qti-error event when an error occurs
|
|
216
|
+
*/
|
|
217
|
+
protected emitError(error: Error, context: string): void {
|
|
218
|
+
const event = new QTIErrorEvent({ error, context });
|
|
219
|
+
this.dispatchEvent(event);
|
|
220
|
+
console.error(`${this.tagName} error in ${context}:`, error);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ========== Utility Methods ==========
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Apply math typesetting to the shadow root
|
|
227
|
+
* Call this after updating the DOM with math content
|
|
228
|
+
*/
|
|
229
|
+
protected applyTypesetting(): void {
|
|
230
|
+
if (this._typeset && this.shadowRoot) {
|
|
231
|
+
try {
|
|
232
|
+
this._typeset(this.shadowRoot as any);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
this.emitError(error as Error, 'typesetting');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Get base styles for all interaction components
|
|
241
|
+
* Override and call super.getStyles() to extend these styles
|
|
242
|
+
*/
|
|
243
|
+
protected getStyles(): string {
|
|
244
|
+
return `
|
|
245
|
+
:host {
|
|
246
|
+
display: block;
|
|
247
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
|
248
|
+
Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
249
|
+
font-size: 16px;
|
|
250
|
+
line-height: 1.5;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
:host([disabled]) {
|
|
254
|
+
opacity: 0.6;
|
|
255
|
+
pointer-events: none;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
* {
|
|
259
|
+
box-sizing: border-box;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.qti-prompt {
|
|
263
|
+
margin-bottom: 1rem;
|
|
264
|
+
font-weight: 600;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.qti-error {
|
|
268
|
+
color: #dc2626;
|
|
269
|
+
padding: 0.75rem;
|
|
270
|
+
background: #fee2e2;
|
|
271
|
+
border-radius: 0.375rem;
|
|
272
|
+
margin: 0.5rem 0;
|
|
273
|
+
}
|
|
274
|
+
`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Safely set innerHTML with error handling
|
|
279
|
+
*/
|
|
280
|
+
protected safeSetInnerHTML(element: HTMLElement | ShadowRoot, html: HtmlContent): void {
|
|
281
|
+
try {
|
|
282
|
+
element.innerHTML = html as any;
|
|
283
|
+
} catch (error) {
|
|
284
|
+
this.emitError(error as Error, 'setInnerHTML');
|
|
285
|
+
element.innerHTML = `<div class="qti-error">Failed to render content</div>`;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Create an element with classes
|
|
291
|
+
*/
|
|
292
|
+
protected createElement<K extends keyof HTMLElementTagNameMap>(
|
|
293
|
+
tagName: K,
|
|
294
|
+
classes?: string[]
|
|
295
|
+
): HTMLElementTagNameMap[K] {
|
|
296
|
+
const element = document.createElement(tagName);
|
|
297
|
+
if (classes && classes.length > 0) {
|
|
298
|
+
element.className = classes.join(' ');
|
|
299
|
+
}
|
|
300
|
+
return element;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard interface and event types for QTI interaction web components
|
|
3
|
+
*
|
|
4
|
+
* All QTI interaction web components must implement the QTIInteractionElement
|
|
5
|
+
* interface and emit QTIChangeEvent when the user response changes.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { InteractionData } from '../types/interactions.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Standard interface that all QTI interaction web components must implement
|
|
12
|
+
*/
|
|
13
|
+
export interface QTIInteractionElement extends HTMLElement {
|
|
14
|
+
/** The processed interaction data from the QTI XML */
|
|
15
|
+
interaction: InteractionData;
|
|
16
|
+
|
|
17
|
+
/** The current response value (type depends on interaction type) */
|
|
18
|
+
response: any;
|
|
19
|
+
|
|
20
|
+
/** Whether the interaction is in read-only/disabled mode */
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
|
|
23
|
+
/** Optional function to apply math typesetting (e.g., KaTeX, MathJax) */
|
|
24
|
+
typeset?: (element: HTMLElement) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Detail payload for the qti-change event
|
|
29
|
+
*/
|
|
30
|
+
export interface QTIChangeEventDetail {
|
|
31
|
+
/** The response identifier for this interaction */
|
|
32
|
+
responseId: string;
|
|
33
|
+
|
|
34
|
+
/** The new response value */
|
|
35
|
+
value: any;
|
|
36
|
+
|
|
37
|
+
/** Timestamp when the change occurred */
|
|
38
|
+
timestamp: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Custom event emitted when an interaction's response changes
|
|
43
|
+
*
|
|
44
|
+
* This event bubbles and can cross shadow DOM boundaries, making it
|
|
45
|
+
* easy to listen for changes at the container level.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* element.addEventListener('qti-change', (event: QTIChangeEvent) => {
|
|
50
|
+
* console.log('Response changed:', event.detail.responseId, event.detail.value);
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export class QTIChangeEvent extends CustomEvent<QTIChangeEventDetail> {
|
|
55
|
+
constructor(detail: QTIChangeEventDetail) {
|
|
56
|
+
super('qti-change', {
|
|
57
|
+
detail,
|
|
58
|
+
bubbles: true, // Bubble up through DOM tree
|
|
59
|
+
composed: true, // Cross shadow DOM boundaries
|
|
60
|
+
cancelable: false, // Cannot be prevented
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Event emitted when a component is ready (initialized and rendered)
|
|
67
|
+
*/
|
|
68
|
+
export class QTIReadyEvent extends CustomEvent<void> {
|
|
69
|
+
constructor() {
|
|
70
|
+
super('qti-ready', {
|
|
71
|
+
bubbles: true,
|
|
72
|
+
composed: true,
|
|
73
|
+
cancelable: false,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Event emitted when an error occurs in a component
|
|
80
|
+
*/
|
|
81
|
+
export interface QTIErrorEventDetail {
|
|
82
|
+
/** The error that occurred */
|
|
83
|
+
error: Error;
|
|
84
|
+
|
|
85
|
+
/** Context about where the error occurred */
|
|
86
|
+
context: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class QTIErrorEvent extends CustomEvent<QTIErrorEventDetail> {
|
|
90
|
+
constructor(detail: QTIErrorEventDetail) {
|
|
91
|
+
super('qti-error', {
|
|
92
|
+
detail,
|
|
93
|
+
bubbles: true,
|
|
94
|
+
composed: true,
|
|
95
|
+
cancelable: false,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Special event for AssociateInteraction selection state
|
|
102
|
+
* (used for tracking which item is selected for pairing)
|
|
103
|
+
*/
|
|
104
|
+
export interface QTISelectionChangeEventDetail {
|
|
105
|
+
/** The identifier of the selected item, or null if deselected */
|
|
106
|
+
selected: string | null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export class QTISelectionChangeEvent extends CustomEvent<QTISelectionChangeEventDetail> {
|
|
110
|
+
constructor(detail: QTISelectionChangeEventDetail) {
|
|
111
|
+
super('qti-selection-change', {
|
|
112
|
+
detail,
|
|
113
|
+
bubbles: true,
|
|
114
|
+
composed: true,
|
|
115
|
+
cancelable: false,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Components for QTI Interactions
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic web components that can be used in any JavaScript environment
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Export base classes and interfaces
|
|
8
|
+
export { QTIInteractionBase } from './QTIInteractionBase.js';
|
|
9
|
+
export {
|
|
10
|
+
QTIChangeEvent,
|
|
11
|
+
type QTIChangeEventDetail,
|
|
12
|
+
QTIErrorEvent,
|
|
13
|
+
type QTIErrorEventDetail,
|
|
14
|
+
type QTIInteractionElement,
|
|
15
|
+
QTIReadyEvent,
|
|
16
|
+
QTISelectionChangeEvent,
|
|
17
|
+
type QTISelectionChangeEventDetail,
|
|
18
|
+
} from './QTIInteractionElement.js';
|
|
19
|
+
|
|
20
|
+
// Note: Web component implementations are provided by separate packages
|
|
21
|
+
// (e.g., @pie-qti/default-components) that use these base classes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Fixture sourcing & licensing policy
|
|
2
|
+
|
|
3
|
+
This conformance suite is intended to be **redistributable** with this repository.
|
|
4
|
+
|
|
5
|
+
## What we will include in-repo
|
|
6
|
+
- **Minimal, purpose-built QTI XML** authored by us to exercise specific features/operators.
|
|
7
|
+
- **Upstream fixtures only when**:
|
|
8
|
+
- the upstream repository explicitly permits redistribution (e.g., MIT/Apache-2.0/BSD), and
|
|
9
|
+
- we record provenance in `manifest.json`.
|
|
10
|
+
|
|
11
|
+
## What we will NOT include in-repo
|
|
12
|
+
- Vendor content packages or item banks without explicit redistribution rights.
|
|
13
|
+
- 1EdTech/IMS certification test packages or other member-only assets.
|
|
14
|
+
- Anything with unclear or missing licensing.
|
|
15
|
+
|
|
16
|
+
## Required metadata for any non-trivial fixture
|
|
17
|
+
Add `manifest.json` with:
|
|
18
|
+
- `source` (project name or “internal”)
|
|
19
|
+
- `upstreamUrl` (if applicable)
|
|
20
|
+
- `license` (SPDX identifier if known)
|
|
21
|
+
- `notes` (what QTI feature/operator/bug it covers)
|
|
22
|
+
|
|
23
|
+
## Review checklist for new fixtures
|
|
24
|
+
- Is licensing clear and compatible?
|
|
25
|
+
- Is the fixture minimal (no extra interactions/assets)?
|
|
26
|
+
- Does `cases.json` assert only what matters (avoid brittle assertions)?
|
|
27
|
+
- Does it have deterministic behavior (seed where needed)?
|
|
28
|
+
|
|
29
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# QTI Conformance Fixtures (Item Player)
|
|
2
|
+
|
|
3
|
+
This directory contains **fixture-driven conformance/regression tests** for `@pie-qti/item-player`.
|
|
4
|
+
|
|
5
|
+
## Goals
|
|
6
|
+
|
|
7
|
+
- Run stable, CI-friendly tests against `Player` behavior using **real QTI XML** fixtures.
|
|
8
|
+
- Keep fixtures **reviewable** (XML + JSON cases) and **deterministic** (seeded randomness).
|
|
9
|
+
- Track known gaps explicitly via `expect.unsupported`/`expect.warnings` fields (as we evolve).
|
|
10
|
+
|
|
11
|
+
## Directory layout
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
tests/conformance/
|
|
15
|
+
fixtures/
|
|
16
|
+
<fixtureId>/
|
|
17
|
+
item.xml
|
|
18
|
+
cases.json
|
|
19
|
+
manifest.json (optional)
|
|
20
|
+
harness.ts
|
|
21
|
+
run-fixtures.test.ts
|
|
22
|
+
types.ts
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## `cases.json` format
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"id": "choice_match_correct",
|
|
30
|
+
"seed": 12345,
|
|
31
|
+
"cases": [
|
|
32
|
+
{
|
|
33
|
+
"name": "correct",
|
|
34
|
+
"responses": { "RESPONSE": "A" },
|
|
35
|
+
"expect": {
|
|
36
|
+
"outcomes": { "SCORE": 1, "MAXSCORE": 1 }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Fields
|
|
44
|
+
|
|
45
|
+
- `id` (string, required): fixture identifier (should match folder name).
|
|
46
|
+
- `seed` (number, optional): deterministic seed for any random/template operations.
|
|
47
|
+
- `cases` (array, required): one or more test cases.
|
|
48
|
+
|
|
49
|
+
Each case:
|
|
50
|
+
|
|
51
|
+
- `name` (string, required): test case name.
|
|
52
|
+
- `responses` (object, required): response map keyed by response identifiers.
|
|
53
|
+
- `xfail` (boolean, optional): marks a known-gap case that is expected to fail today.
|
|
54
|
+
- `xfailReason` (string, optional): short explanation of why it is expected to fail.
|
|
55
|
+
- `expect` (object, required):
|
|
56
|
+
- `outcomes` (object, optional): expected subset of `result.outcomeValues`.
|
|
57
|
+
- `score` / `maxScore` (number, optional): expected scalar scoring fields.
|
|
58
|
+
- `modalFeedbackIdentifiers` (string[], optional): expected modal feedback identifiers (order-insensitive).
|
|
59
|
+
- `itemBodyContains` (string[], optional): substrings expected in `player.getItemBodyHtml()`.
|
|
60
|
+
- `unsupported` (string[], optional): expected unsupported feature codes (future-proofing).
|
|
61
|
+
- `warnings` (string[], optional): expected warning codes/messages (future-proofing).
|
|
62
|
+
|
|
63
|
+
## `manifest.json` (optional)
|
|
64
|
+
|
|
65
|
+
Used for provenance/licensing metadata:
|
|
66
|
+
|
|
67
|
+
- `source`: upstream project/name
|
|
68
|
+
- `upstreamUrl`: where it came from
|
|
69
|
+
- `license`: SPDX identifier (when known)
|
|
70
|
+
- `notes`: why this fixture exists / what it covers
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "baseTypes_all",
|
|
3
|
+
"cases": [
|
|
4
|
+
{
|
|
5
|
+
"name": "all_baseTypes_happy_path",
|
|
6
|
+
"responses": {
|
|
7
|
+
"B": "true",
|
|
8
|
+
"I": "42",
|
|
9
|
+
"F": "3.5",
|
|
10
|
+
"S": "hello",
|
|
11
|
+
"ID": "X1",
|
|
12
|
+
"U": "https://example.org/a",
|
|
13
|
+
"P": "B A",
|
|
14
|
+
"DP": "A B",
|
|
15
|
+
"PT": "10 20",
|
|
16
|
+
"DUR": "PT1H",
|
|
17
|
+
"FILE": "file://example.txt"
|
|
18
|
+
},
|
|
19
|
+
"expect": {
|
|
20
|
+
"outcomes": {
|
|
21
|
+
"OK_B": true,
|
|
22
|
+
"OK_I": true,
|
|
23
|
+
"OK_F": true,
|
|
24
|
+
"OK_S": true,
|
|
25
|
+
"OK_ID": true,
|
|
26
|
+
"OK_U": true,
|
|
27
|
+
"OK_P": true,
|
|
28
|
+
"OK_DP_AB": true,
|
|
29
|
+
"OK_PT": true,
|
|
30
|
+
"OK_DUR": true,
|
|
31
|
+
"OK_FILE": true,
|
|
32
|
+
"REC_A": 7,
|
|
33
|
+
"REC_B": "ok"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "directedPair_is_ordered",
|
|
39
|
+
"responses": {
|
|
40
|
+
"B": "true",
|
|
41
|
+
"I": "42",
|
|
42
|
+
"F": "3.5",
|
|
43
|
+
"S": "hello",
|
|
44
|
+
"ID": "X1",
|
|
45
|
+
"U": "https://example.org/a",
|
|
46
|
+
"P": "B A",
|
|
47
|
+
"DP": "B A",
|
|
48
|
+
"PT": "10 20",
|
|
49
|
+
"DUR": "PT1H",
|
|
50
|
+
"FILE": "file://example.txt"
|
|
51
|
+
},
|
|
52
|
+
"expect": {
|
|
53
|
+
"outcomes": {
|
|
54
|
+
"OK_DP_AB": false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|