@pie-qti/item-player 0.1.1 → 0.1.4
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/README.md +1 -1
- package/dist/components/actions/typesetAction.d.ts +24 -0
- package/dist/components/actions/typesetAction.d.ts.map +1 -0
- package/dist/components/actions/typesetAction.js +59 -0
- package/dist/components/utils/assignProps.d.ts +2 -0
- package/dist/components/utils/assignProps.d.ts.map +1 -0
- package/dist/components/utils/assignProps.js +1 -0
- package/dist/components/utils/feedbackUtils.d.ts +73 -0
- package/dist/components/utils/feedbackUtils.d.ts.map +1 -0
- package/dist/components/utils/feedbackUtils.js +93 -0
- package/dist/components/utils/index.d.ts +6 -0
- package/dist/components/utils/index.d.ts.map +1 -0
- package/dist/components/utils/index.js +5 -0
- package/dist/core/ComponentRegistry.d.ts +119 -0
- package/dist/core/ComponentRegistry.d.ts.map +1 -0
- package/dist/core/ComponentRegistry.js +123 -0
- package/dist/core/ItemRenderer.d.ts +91 -0
- package/dist/core/ItemRenderer.d.ts.map +1 -0
- package/dist/core/ItemRenderer.js +258 -0
- package/dist/core/Player.d.ts +143 -0
- package/dist/core/Player.d.ts.map +1 -0
- package/dist/core/Player.js +1081 -0
- package/dist/core/Plugin.d.ts +105 -0
- package/dist/core/Plugin.d.ts.map +1 -0
- package/dist/core/Plugin.js +7 -0
- package/dist/core/PluginManager.d.ts +56 -0
- package/dist/core/PluginManager.d.ts.map +1 -0
- package/dist/core/PluginManager.js +147 -0
- package/dist/core/constants.d.ts +68 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +106 -0
- package/dist/core/declarations.d.ts +45 -0
- package/dist/core/declarations.d.ts.map +1 -0
- package/dist/core/declarations.js +133 -0
- package/dist/core/parsingLimits.d.ts +12 -0
- package/dist/core/parsingLimits.d.ts.map +1 -0
- package/dist/core/parsingLimits.js +45 -0
- package/dist/core/random.d.ts +12 -0
- package/dist/core/random.d.ts.map +1 -0
- package/dist/core/random.js +21 -0
- package/dist/core/sanitizer.d.ts +34 -0
- package/dist/core/sanitizer.d.ts.map +1 -0
- package/dist/core/sanitizer.js +198 -0
- package/dist/core/trustedTypes.d.ts +16 -0
- package/dist/core/trustedTypes.d.ts.map +1 -0
- package/dist/core/trustedTypes.js +55 -0
- package/dist/core/urlPolicy.d.ts +8 -0
- package/dist/core/urlPolicy.d.ts.map +1 -0
- package/dist/core/urlPolicy.js +87 -0
- package/dist/extensions/MathLiveEditor.d.ts +32 -0
- package/dist/extensions/MathLiveEditor.d.ts.map +1 -0
- package/dist/extensions/MathLiveEditor.js +249 -0
- package/dist/extraction/ExtractionRegistry.d.ts +112 -0
- package/dist/extraction/ExtractionRegistry.d.ts.map +1 -0
- package/dist/extraction/ExtractionRegistry.js +258 -0
- package/dist/extraction/createContext.d.ts +30 -0
- package/dist/extraction/createContext.d.ts.map +1 -0
- package/dist/extraction/createContext.js +39 -0
- package/dist/extraction/extractors/associateExtractor.d.ts +28 -0
- package/dist/extraction/extractors/associateExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/associateExtractor.js +94 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts +25 -0
- package/dist/extraction/extractors/choiceExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/choiceExtractor.js +83 -0
- package/dist/extraction/extractors/customExtractor.d.ts +20 -0
- package/dist/extraction/extractors/customExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/customExtractor.js +51 -0
- package/dist/extraction/extractors/drawingExtractor.d.ts +30 -0
- package/dist/extraction/extractors/drawingExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/drawingExtractor.js +78 -0
- package/dist/extraction/extractors/endAttemptExtractor.d.ts +20 -0
- package/dist/extraction/extractors/endAttemptExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/endAttemptExtractor.js +53 -0
- package/dist/extraction/extractors/extendedTextExtractor.d.ts +21 -0
- package/dist/extraction/extractors/extendedTextExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/extendedTextExtractor.js +57 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts +28 -0
- package/dist/extraction/extractors/gapMatchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/gapMatchExtractor.js +142 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts +40 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicAssociateExtractor.js +140 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts +42 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicGapMatchExtractor.js +144 -0
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts +37 -0
- package/dist/extraction/extractors/graphicOrderExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/graphicOrderExtractor.js +121 -0
- package/dist/extraction/extractors/hotspotExtractor.d.ts +38 -0
- package/dist/extraction/extractors/hotspotExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/hotspotExtractor.js +140 -0
- package/dist/extraction/extractors/hottextExtractor.d.ts +26 -0
- package/dist/extraction/extractors/hottextExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/hottextExtractor.js +120 -0
- package/dist/extraction/extractors/index.d.ts +62 -0
- package/dist/extraction/extractors/index.d.ts.map +1 -0
- package/dist/extraction/extractors/index.js +84 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts +22 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/inlineChoiceExtractor.js +67 -0
- package/dist/extraction/extractors/matchExtractor.d.ts +32 -0
- package/dist/extraction/extractors/matchExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/matchExtractor.js +134 -0
- package/dist/extraction/extractors/mediaExtractor.d.ts +33 -0
- package/dist/extraction/extractors/mediaExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/mediaExtractor.js +125 -0
- package/dist/extraction/extractors/orderExtractor.d.ts +26 -0
- package/dist/extraction/extractors/orderExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/orderExtractor.js +86 -0
- package/dist/extraction/extractors/positionObjectExtractor.d.ts +59 -0
- package/dist/extraction/extractors/positionObjectExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/positionObjectExtractor.js +191 -0
- package/dist/extraction/extractors/selectPointExtractor.d.ts +31 -0
- package/dist/extraction/extractors/selectPointExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/selectPointExtractor.js +109 -0
- package/dist/extraction/extractors/sliderExtractor.d.ts +24 -0
- package/dist/extraction/extractors/sliderExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/sliderExtractor.js +73 -0
- package/dist/extraction/extractors/textEntryExtractor.d.ts +20 -0
- package/dist/extraction/extractors/textEntryExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/textEntryExtractor.js +48 -0
- package/dist/extraction/extractors/uploadExtractor.d.ts +20 -0
- package/dist/extraction/extractors/uploadExtractor.d.ts.map +1 -0
- package/dist/extraction/extractors/uploadExtractor.js +52 -0
- package/dist/extraction/index.d.ts +49 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +49 -0
- package/dist/extraction/types.d.ts +209 -0
- package/dist/extraction/types.d.ts.map +1 -0
- package/dist/extraction/types.js +30 -0
- package/dist/extraction/utils.d.ts +15 -0
- package/dist/extraction/utils.d.ts.map +1 -0
- package/dist/extraction/utils.js +178 -0
- package/dist/iframe/IFramePlayerHost.d.ts +122 -0
- package/dist/iframe/IFramePlayerHost.d.ts.map +1 -0
- package/dist/iframe/IFramePlayerHost.js +172 -0
- package/dist/iframe/index.d.ts +9 -0
- package/dist/iframe/index.d.ts.map +1 -0
- package/dist/iframe/index.js +8 -0
- package/dist/iframe/protocol.d.ts +75 -0
- package/dist/iframe/protocol.d.ts.map +1 -0
- package/dist/iframe/protocol.js +53 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +10 -0
- package/dist/types/index.d.ts +290 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/interactions.d.ts +323 -0
- package/dist/types/interactions.d.ts.map +1 -0
- package/dist/types/interactions.js +7 -0
- package/dist/types/responseValidation.d.ts +25 -0
- package/dist/types/responseValidation.d.ts.map +1 -0
- package/dist/types/responseValidation.js +1 -0
- package/dist/utils/PerformanceMonitor.d.ts +170 -0
- package/dist/utils/PerformanceMonitor.d.ts.map +1 -0
- package/dist/utils/PerformanceMonitor.js +242 -0
- package/dist/utils/drawingUtils.d.ts +39 -0
- package/dist/utils/drawingUtils.d.ts.map +1 -0
- package/dist/utils/drawingUtils.js +57 -0
- package/dist/utils/responseUtils.d.ts +16 -0
- package/dist/utils/responseUtils.d.ts.map +1 -0
- package/dist/utils/responseUtils.js +45 -0
- package/dist/utils/touchDragHelper.d.ts +2 -0
- package/dist/utils/touchDragHelper.d.ts.map +1 -0
- package/dist/utils/touchDragHelper.js +1 -0
- package/dist/web-components/QTIInteractionBase.d.ts +120 -0
- package/dist/web-components/QTIInteractionBase.d.ts.map +1 -0
- package/dist/web-components/QTIInteractionBase.js +243 -0
- package/dist/web-components/QTIInteractionElement.d.ts +77 -0
- package/dist/web-components/QTIInteractionElement.d.ts.map +1 -0
- package/dist/web-components/QTIInteractionElement.js +61 -0
- package/dist/web-components/index.d.ts +8 -0
- package/dist/web-components/index.d.ts.map +1 -0
- package/dist/web-components/index.js +10 -0
- package/package.json +94 -76
- package/src/__tests__/qti3-attribute-extraction.test.ts +174 -0
- package/src/__tests__/qti3-debug.test.ts +140 -0
- package/src/__tests__/qti3-extraction.test.ts +309 -0
- package/src/components/ItemBody.svelte +3 -1
- package/src/components/utils/assignProps.ts +1 -23
- package/src/core/Player.ts +138 -34
- package/src/core/parsingLimits.ts +1 -1
- package/src/extensions/MathLiveEditor.ts +6 -3
- package/src/extraction/ExtractionRegistry.ts +46 -10
- package/src/extraction/createContext.ts +6 -1
- package/src/extraction/extractors/extendedTextExtractor.ts +5 -2
- package/src/extraction/extractors/matchExtractor.ts +2 -2
- package/src/extraction/extractors/textEntryExtractor.ts +4 -2
- package/src/extraction/utils.ts +99 -16
- package/src/index.ts +2 -0
- package/src/types/index.ts +28 -8
- package/src/types/xmldom.d.ts +12 -0
- package/src/utils/drawingUtils.ts +73 -0
- package/src/utils/touchDragHelper.ts +1 -211
- package/.turbo/turbo-build.log +0 -1
- package/CHANGELOG.md +0 -9
- package/docs/QTI-COMPLIANCE.md +0 -197
- package/docs/WCAG-2.2-COMPLIANCE.md +0 -466
- package/docs/custom-extractors.md +0 -679
- package/docs/iframe-mode.md +0 -78
- package/docs/security-audit.md +0 -236
- package/docs/server-api.md +0 -691
- package/tests/conformance/FIXTURE_POLICY.md +0 -29
- package/tests/conformance/README.md +0 -70
- package/tests/conformance/fixtures/baseTypes_all/cases.json +0 -61
- package/tests/conformance/fixtures/baseTypes_all/item.xml +0 -131
- package/tests/conformance/fixtures/baseTypes_all/manifest.json +0 -7
- package/tests/conformance/fixtures/choice_match_correct/cases.json +0 -17
- package/tests/conformance/fixtures/choice_match_correct/item.xml +0 -55
- package/tests/conformance/fixtures/choice_match_correct/manifest.json +0 -14
- package/tests/conformance/fixtures/contains_multiple/cases.json +0 -12
- package/tests/conformance/fixtures/contains_multiple/item.xml +0 -37
- package/tests/conformance/fixtures/contains_multiple/manifest.json +0 -13
- package/tests/conformance/fixtures/isNull_isNotNull/cases.json +0 -9
- package/tests/conformance/fixtures/isNull_isNotNull/item.xml +0 -41
- package/tests/conformance/fixtures/isNull_isNotNull/manifest.json +0 -23
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/cases.json +0 -27
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/item.xml +0 -30
- package/tests/conformance/fixtures/mapResponse_bounds_default_duplicates/manifest.json +0 -15
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/cases.json +0 -11
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/item.xml +0 -26
- package/tests/conformance/fixtures/mapResponse_integer_mapKey/manifest.json +0 -13
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/cases.json +0 -27
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/item.xml +0 -32
- package/tests/conformance/fixtures/mapResponse_mapEntry_caseSensitive_override/manifest.json +0 -7
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/cases.json +0 -9
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/item.xml +0 -25
- package/tests/conformance/fixtures/mapResponse_mapping_caseSensitive_defaultValue/manifest.json +0 -12
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/cases.json +0 -12
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/item.xml +0 -35
- package/tests/conformance/fixtures/mapResponse_multiple_cardinality/manifest.json +0 -11
- package/tests/conformance/fixtures/mapping_bounds_upperLower/cases.json +0 -12
- package/tests/conformance/fixtures/mapping_bounds_upperLower/item.xml +0 -37
- package/tests/conformance/fixtures/mapping_bounds_upperLower/manifest.json +0 -11
- package/tests/conformance/fixtures/mapping_mapResponse/cases.json +0 -22
- package/tests/conformance/fixtures/mapping_mapResponse/item.xml +0 -53
- package/tests/conformance/fixtures/mapping_mapResponse/manifest.json +0 -16
- package/tests/conformance/fixtures/member_multiple/cases.json +0 -12
- package/tests/conformance/fixtures/member_multiple/item.xml +0 -37
- package/tests/conformance/fixtures/member_multiple/manifest.json +0 -13
- package/tests/conformance/fixtures/modalFeedback_basic/cases.json +0 -17
- package/tests/conformance/fixtures/modalFeedback_basic/item.xml +0 -52
- package/tests/conformance/fixtures/modalFeedback_basic/manifest.json +0 -13
- package/tests/conformance/fixtures/multiple_unordered_match/cases.json +0 -17
- package/tests/conformance/fixtures/multiple_unordered_match/item.xml +0 -44
- package/tests/conformance/fixtures/multiple_unordered_match/manifest.json +0 -11
- package/tests/conformance/fixtures/ordered_match/cases.json +0 -17
- package/tests/conformance/fixtures/ordered_match/item.xml +0 -48
- package/tests/conformance/fixtures/ordered_match/manifest.json +0 -13
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/cases.json +0 -27
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/item.xml +0 -103
- package/tests/conformance/fixtures/outcomeProcessing_derive_percent_passfail/manifest.json +0 -7
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/cases.json +0 -15
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/item.xml +0 -33
- package/tests/conformance/fixtures/outcomeProcessing_exitTest/manifest.json +0 -10
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/item.xml +0 -26
- package/tests/conformance/fixtures/outcomeProcessing_numberExpressions/manifest.json +0 -8
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/cases.json +0 -17
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/item.xml +0 -43
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_equal/manifest.json +0 -16
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/cases.json +0 -27
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/item.xml +0 -37
- package/tests/conformance/fixtures/outcomeProcessing_outcomeCondition_toBoolean/manifest.json +0 -16
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/item.xml +0 -35
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMaximum/manifest.json +0 -8
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/item.xml +0 -35
- package/tests/conformance/fixtures/outcomeProcessing_outcomeMinimum/manifest.json +0 -8
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/cases.json +0 -15
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/item.xml +0 -39
- package/tests/conformance/fixtures/outcomeProcessing_outcomeProcessingFragment/manifest.json +0 -11
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/cases.json +0 -14
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/item.xml +0 -35
- package/tests/conformance/fixtures/outcomeProcessing_testVariables/manifest.json +0 -8
- package/tests/conformance/fixtures/pair_unordered_match/cases.json +0 -22
- package/tests/conformance/fixtures/pair_unordered_match/item.xml +0 -44
- package/tests/conformance/fixtures/pair_unordered_match/manifest.json +0 -13
- package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/cases.json +0 -95
- package/tests/conformance/fixtures/positionObject_coordinateSystem_aspectRatio/item.xml +0 -53
- package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/cases.json +0 -115
- package/tests/conformance/fixtures/positionObject_mapResponsePoint_scoring/item.xml +0 -45
- package/tests/conformance/fixtures/positionObject_mapResponse_wrong/cases.json +0 -29
- package/tests/conformance/fixtures/positionObject_mapResponse_wrong/item.xml +0 -40
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/cases.json +0 -10
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/item.xml +0 -49
- package/tests/conformance/fixtures/responseCondition_elseIf_chain/manifest.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_anyN/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_anyN/item.xml +0 -47
- package/tests/conformance/fixtures/responseProcessing_anyN/manifest.json +0 -16
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/item.xml +0 -69
- package/tests/conformance/fixtures/responseProcessing_anyN_allN/manifest.json +0 -23
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/item.xml +0 -58
- package/tests/conformance/fixtures/responseProcessing_arithmetic_nulls/manifest.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/cases.json +0 -37
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/item.xml +0 -94
- package/tests/conformance/fixtures/responseProcessing_boolean_compare_ops/manifest.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/cases.json +0 -33
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/item.xml +0 -79
- package/tests/conformance/fixtures/responseProcessing_containerSize_index/manifest.json +0 -16
- package/tests/conformance/fixtures/responseProcessing_customOperator/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_customOperator/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_customOperator/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_default_expression/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_default_expression/item.xml +0 -48
- package/tests/conformance/fixtures/responseProcessing_default_expression/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/cases.json +0 -29
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/item.xml +0 -68
- package/tests/conformance/fixtures/responseProcessing_deleteValue_repeat/manifest.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/cases.json +0 -39
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/item.xml +0 -39
- package/tests/conformance/fixtures/responseProcessing_equalRounded_tolerance/manifest.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_exitResponse/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_exitResponse/item.xml +0 -25
- package/tests/conformance/fixtures/responseProcessing_exitResponse/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/cases.json +0 -26
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/item.xml +0 -134
- package/tests/conformance/fixtures/responseProcessing_inside_duration_statsOperator/manifest.json +0 -16
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/item.xml +0 -33
- package/tests/conformance/fixtures/responseProcessing_lookupTable_interpolationTable/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/item.xml +0 -33
- package/tests/conformance/fixtures/responseProcessing_lookupTable_matchTable/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/item.xml +0 -40
- package/tests/conformance/fixtures/responseProcessing_mapOutcome_basic/manifest.json +0 -18
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/item.xml +0 -33
- package/tests/conformance/fixtures/responseProcessing_mapResponsePoint_basic/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/cases.json +0 -29
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/item.xml +0 -26
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_ordered/manifest.json +0 -7
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/cases.json +0 -23
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/item.xml +0 -28
- package/tests/conformance/fixtures/responseProcessing_mapResponse_directedPair_whitespace/manifest.json +0 -11
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/cases.json +0 -29
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/item.xml +0 -26
- package/tests/conformance/fixtures/responseProcessing_mapResponse_pair_unordered/manifest.json +0 -7
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/cases.json +0 -31
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/item.xml +0 -102
- package/tests/conformance/fixtures/responseProcessing_mathOperator_integerUtils/manifest.json +0 -18
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/item.xml +0 -45
- package/tests/conformance/fixtures/responseProcessing_math_max_min_round_truncate/manifest.json +0 -21
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/cases.json +0 -26
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/item.xml +0 -157
- package/tests/conformance/fixtures/responseProcessing_misc_math_string_stats/manifest.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/item.xml +0 -39
- package/tests/conformance/fixtures/responseProcessing_notEqual_basic/manifest.json +0 -18
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/item.xml +0 -51
- package/tests/conformance/fixtures/responseProcessing_patternMatch_caseSensitive/manifest.json +0 -19
- package/tests/conformance/fixtures/responseProcessing_preCondition/cases.json +0 -31
- package/tests/conformance/fixtures/responseProcessing_preCondition/item.xml +0 -44
- package/tests/conformance/fixtures/responseProcessing_preCondition/manifest.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/item.xml +0 -42
- package/tests/conformance/fixtures/responseProcessing_random_lookupOutcomeValue/manifest.json +0 -14
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/item.xml +0 -40
- package/tests/conformance/fixtures/responseProcessing_record_fieldValue/manifest.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/item.xml +0 -63
- package/tests/conformance/fixtures/responseProcessing_responseCondition_toBoolean/manifest.json +0 -9
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/cases.json +0 -12
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/item.xml +0 -40
- package/tests/conformance/fixtures/responseProcessing_responseProcessingFragment/manifest.json +0 -13
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/item.xml +0 -67
- package/tests/conformance/fixtures/responseProcessing_setDefaultValue/manifest.json +0 -9
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/cases.json +0 -27
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/item.xml +0 -69
- package/tests/conformance/fixtures/responseProcessing_setResponseValue_setDefaultValue/manifest.json +0 -10
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/cases.json +0 -15
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/item.xml +0 -35
- package/tests/conformance/fixtures/responseProcessing_subtract_divide/manifest.json +0 -11
- package/tests/conformance/fixtures/responseProcessing_template_map_response/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_map_response/item.xml +0 -31
- package/tests/conformance/fixtures/responseProcessing_template_map_response/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/item.xml +0 -27
- package/tests/conformance/fixtures/responseProcessing_template_map_response_point/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/item.xml +0 -34
- package/tests/conformance/fixtures/responseProcessing_template_match_correct/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/cases.json +0 -22
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_directedPair/manifest.json +0 -7
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_template_match_correct_two_responses/manifest.json +0 -9
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/cases.json +0 -17
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/item.xml +0 -30
- package/tests/conformance/fixtures/responseProcessing_template_match_nothing/manifest.json +0 -8
- package/tests/conformance/fixtures/responseProcessing_xiInclude/cases.json +0 -14
- package/tests/conformance/fixtures/responseProcessing_xiInclude/item.xml +0 -25
- package/tests/conformance/fixtures/responseProcessing_xiInclude/manifest.json +0 -9
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/cases.json +0 -12
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/item.xml +0 -52
- package/tests/conformance/fixtures/stringMatch_caseSensitive_substring/manifest.json +0 -14
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/cases.json +0 -12
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/item.xml +0 -48
- package/tests/conformance/fixtures/templateProcessing_exitTemplate/manifest.json +0 -13
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/cases.json +0 -27
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/item.xml +0 -74
- package/tests/conformance/fixtures/templateProcessing_setCorrectResponse/manifest.json +0 -22
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/cases.json +0 -17
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/item.xml +0 -133
- package/tests/conformance/fixtures/templateProcessing_templateCondition_branching/manifest.json +0 -22
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/cases.json +0 -12
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/item.xml +0 -107
- package/tests/conformance/fixtures/templateProcessing_templateCondition_toBoolean/manifest.json +0 -16
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/cases.json +0 -15
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/item.xml +0 -52
- package/tests/conformance/fixtures/templateProcessing_templateConstraint/manifest.json +0 -14
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/cases.json +0 -16
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/item.xml +0 -49
- package/tests/conformance/fixtures/template_randomFloat_roundTo_mathConstant/manifest.json +0 -15
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/cases.json +0 -16
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/item.xml +0 -38
- package/tests/conformance/fixtures/template_randomInteger_printedVariable/manifest.json +0 -13
- package/tests/conformance/harness.ts +0 -84
- package/tests/conformance/run-fixtures.test.ts +0 -127
- package/tests/conformance/scripts/normalize-covers.ts +0 -152
- package/tests/conformance/types.ts +0 -53
- package/tests/core/Player.test.ts +0 -563
- package/tests/core/adaptiveItems.test.ts +0 -442
- package/tests/core/correctResponse.test.ts +0 -280
- package/tests/core/interaction-plumbing.test.ts +0 -141
- package/tests/core/modalFeedback.test.ts +0 -308
- package/tests/core/outcome-reset.test.ts +0 -43
- package/tests/extraction/extractors/associateExtractor.test.ts +0 -182
- package/tests/extraction/extractors/choiceExtractor.test.ts +0 -239
- package/tests/extraction/extractors/customExtractor.test.ts +0 -83
- package/tests/extraction/extractors/drawingExtractor.test.ts +0 -94
- package/tests/extraction/extractors/endAttemptExtractor.test.ts +0 -188
- package/tests/extraction/extractors/extendedTextExtractor.test.ts +0 -178
- package/tests/extraction/extractors/gapMatchExtractor.test.ts +0 -318
- package/tests/extraction/extractors/graphicAssociateExtractor.test.ts +0 -260
- package/tests/extraction/extractors/graphicGapMatchExtractor.test.ts +0 -320
- package/tests/extraction/extractors/graphicOrderExtractor.test.ts +0 -223
- package/tests/extraction/extractors/hotspotExtractor.test.ts +0 -298
- package/tests/extraction/extractors/hottextExtractor.test.ts +0 -240
- package/tests/extraction/extractors/inlineChoiceExtractor.test.ts +0 -292
- package/tests/extraction/extractors/matchExtractor.test.ts +0 -241
- package/tests/extraction/extractors/mediaExtractor.test.ts +0 -295
- package/tests/extraction/extractors/orderExtractor.test.ts +0 -212
- package/tests/extraction/extractors/positionObjectExtractor.test.ts +0 -363
- package/tests/extraction/extractors/selectPointExtractor.test.ts +0 -214
- package/tests/extraction/extractors/sliderExtractor.test.ts +0 -293
- package/tests/extraction/extractors/textEntryExtractor.test.ts +0 -133
- package/tests/extraction/extractors/uploadExtractor.test.ts +0 -119
- package/tests/extraction/test-utils.ts +0 -57
- package/tests/iframe/host.test.ts +0 -145
- package/tests/iframe/protocol.test.ts +0 -42
- package/tests/performance/player-benchmarks.bench.ts +0 -191
- package/tests/security/dos-limits.test.ts +0 -56
- package/tests/security/xss-prevention.test.ts +0 -522
- package/tsconfig.json +0 -20
- package/tsconfig.svelte.json +0 -14
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ItemRenderer - Framework-agnostic rendering engine for QTI items
|
|
3
|
+
*
|
|
4
|
+
* Replaces ItemBody.svelte with vanilla JavaScript. Creates and manages
|
|
5
|
+
* web component instances for QTI interactions, handles response state,
|
|
6
|
+
* and orchestrates the rendering pipeline.
|
|
7
|
+
*/
|
|
8
|
+
import { htmlToString, toTrustedHtml } from './trustedTypes.js';
|
|
9
|
+
/**
|
|
10
|
+
* ItemRenderer class manages the rendering of QTI items using web components
|
|
11
|
+
*/
|
|
12
|
+
export class ItemRenderer {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
// Tracking for cleanup
|
|
15
|
+
this.renderedElements = [];
|
|
16
|
+
this.eventListeners = [];
|
|
17
|
+
// State for AssociateInteraction (pairing selection)
|
|
18
|
+
this.selectedForPairing = null;
|
|
19
|
+
this.player = config.player;
|
|
20
|
+
this.container = config.container;
|
|
21
|
+
this.componentRegistry = this.player.getComponentRegistry();
|
|
22
|
+
this.responses = config.responses || {};
|
|
23
|
+
this.disabled = config.disabled || false;
|
|
24
|
+
this.typeset = config.typeset;
|
|
25
|
+
this.onResponseChange = config.onResponseChange || (() => { });
|
|
26
|
+
// Initial render
|
|
27
|
+
this.render();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Render the entire item with all interactions
|
|
31
|
+
*/
|
|
32
|
+
render() {
|
|
33
|
+
// Clean up previous render
|
|
34
|
+
this.cleanup();
|
|
35
|
+
// Create wrapper
|
|
36
|
+
const wrapper = document.createElement('div');
|
|
37
|
+
wrapper.className = 'qti-item-body';
|
|
38
|
+
// Get and process interactions using the player's configured ExtractionRegistry
|
|
39
|
+
const interactions = this.player.getInteractionData();
|
|
40
|
+
// Filter block vs inline interactions
|
|
41
|
+
const blockInteractions = interactions.filter((i) => i.type !== 'textEntryInteraction' && i.type !== 'inlineChoiceInteraction');
|
|
42
|
+
// Get item body HTML with interactions removed
|
|
43
|
+
const itemBodyHtml = this.getProcessedItemBodyHtml();
|
|
44
|
+
// Create prose container for body HTML
|
|
45
|
+
const proseContainer = document.createElement('div');
|
|
46
|
+
proseContainer.className = 'prose max-w-none mb-4';
|
|
47
|
+
// Process inline interactions in HTML
|
|
48
|
+
const processedHtml = this.processInlineInteractions(itemBodyHtml, interactions);
|
|
49
|
+
proseContainer.innerHTML = toTrustedHtml(processedHtml, this.player.getTrustedTypesPolicyName());
|
|
50
|
+
wrapper.appendChild(proseContainer);
|
|
51
|
+
// Render block interactions as web components
|
|
52
|
+
for (const interaction of blockInteractions) {
|
|
53
|
+
try {
|
|
54
|
+
const element = this.createInteractionElement(interaction);
|
|
55
|
+
if (element) {
|
|
56
|
+
wrapper.appendChild(element);
|
|
57
|
+
this.renderedElements.push(element);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error(`Failed to create component for ${interaction.type}:`, error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Apply typesetting to the entire wrapper
|
|
65
|
+
if (this.typeset) {
|
|
66
|
+
try {
|
|
67
|
+
this.typeset(wrapper);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error('Typesetting failed:', error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Mount to container
|
|
74
|
+
this.container.innerHTML = '';
|
|
75
|
+
this.container.appendChild(wrapper);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get item body HTML with block interactions removed
|
|
79
|
+
*/
|
|
80
|
+
getProcessedItemBodyHtml() {
|
|
81
|
+
let html = htmlToString(this.player.getItemBodyHtml());
|
|
82
|
+
// Remove block interaction elements (they're rendered separately as web components)
|
|
83
|
+
const interactionPatterns = [
|
|
84
|
+
/<choiceInteraction[\s\S]*?<\/choiceInteraction>/gi,
|
|
85
|
+
/<extendedTextInteraction[\s\S]*?<\/extendedTextInteraction>/gi,
|
|
86
|
+
/<orderInteraction[\s\S]*?<\/orderInteraction>/gi,
|
|
87
|
+
/<matchInteraction[\s\S]*?<\/matchInteraction>/gi,
|
|
88
|
+
/<associateInteraction[\s\S]*?<\/associateInteraction>/gi,
|
|
89
|
+
/<gapMatchInteraction[\s\S]*?<\/gapMatchInteraction>/gi,
|
|
90
|
+
/<sliderInteraction[\s\S]*?<\/sliderInteraction>/gi,
|
|
91
|
+
/<hotspotInteraction[\s\S]*?<\/hotspotInteraction>/gi,
|
|
92
|
+
/<graphicGapMatchInteraction[\s\S]*?<\/graphicGapMatchInteraction>/gi,
|
|
93
|
+
/<graphicOrderInteraction[\s\S]*?<\/graphicOrderInteraction>/gi,
|
|
94
|
+
/<graphicAssociateInteraction[\s\S]*?<\/graphicAssociateInteraction>/gi,
|
|
95
|
+
/<positionObjectInteraction[\s\S]*?<\/positionObjectInteraction>/gi,
|
|
96
|
+
/<endAttemptInteraction[\s\S]*?<\/endAttemptInteraction>/gi,
|
|
97
|
+
/<uploadInteraction[\s\S]*?<\/uploadInteraction>/gi,
|
|
98
|
+
/<drawingInteraction[\s\S]*?<\/drawingInteraction>/gi,
|
|
99
|
+
/<mediaInteraction[\s\S]*?<\/mediaInteraction>/gi,
|
|
100
|
+
/<hottextInteraction[\s\S]*?<\/hottextInteraction>/gi,
|
|
101
|
+
/<selectPointInteraction[\s\S]*?<\/selectPointInteraction>/gi,
|
|
102
|
+
/<customInteraction[\s\S]*?<\/customInteraction>/gi,
|
|
103
|
+
];
|
|
104
|
+
for (const pattern of interactionPatterns) {
|
|
105
|
+
html = html.replace(pattern, '');
|
|
106
|
+
}
|
|
107
|
+
return html;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Process inline interactions (textEntry, inlineChoice)
|
|
111
|
+
* Replaces QTI XML tags with web component placeholders
|
|
112
|
+
*/
|
|
113
|
+
processInlineInteractions(html, interactions) {
|
|
114
|
+
// Replace textEntry with placeholder
|
|
115
|
+
html = html.replace(/<textEntryInteraction[^>]*responseIdentifier="([^"]+)"[^>]*?(?:\/>|><\/textEntryInteraction>)/gi, (match, responseId) => {
|
|
116
|
+
const interaction = interactions.find((i) => i.responseId === responseId && i.type === 'textEntryInteraction');
|
|
117
|
+
if (interaction) {
|
|
118
|
+
return `<span data-inline-interaction="${responseId}" data-type="textEntry"></span>`;
|
|
119
|
+
}
|
|
120
|
+
return match;
|
|
121
|
+
});
|
|
122
|
+
// Replace inlineChoice with placeholder
|
|
123
|
+
html = html.replace(/<inlineChoiceInteraction[^>]*responseIdentifier="([^"]+)"[^>]*>[\s\S]*?<\/inlineChoiceInteraction>/gi, (match, responseId) => {
|
|
124
|
+
const interaction = interactions.find((i) => i.responseId === responseId && i.type === 'inlineChoiceInteraction');
|
|
125
|
+
if (interaction) {
|
|
126
|
+
return `<span data-inline-interaction="${responseId}" data-type="inlineChoice"></span>`;
|
|
127
|
+
}
|
|
128
|
+
return match;
|
|
129
|
+
});
|
|
130
|
+
return html;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Create a web component element for an interaction
|
|
134
|
+
*/
|
|
135
|
+
createInteractionElement(interaction) {
|
|
136
|
+
try {
|
|
137
|
+
// Get tag name from registry
|
|
138
|
+
const tagName = this.componentRegistry.getTagName(interaction);
|
|
139
|
+
// Create element
|
|
140
|
+
const element = document.createElement(tagName);
|
|
141
|
+
// Set standard properties
|
|
142
|
+
element.interaction = interaction;
|
|
143
|
+
element.response = this.responses[interaction.responseId] ?? null;
|
|
144
|
+
element.disabled = this.disabled;
|
|
145
|
+
element.typeset = this.typeset;
|
|
146
|
+
// Special handling for AssociateInteraction (pairing selection)
|
|
147
|
+
if (interaction.type === 'associateInteraction') {
|
|
148
|
+
element.selectedForPairing = this.selectedForPairing;
|
|
149
|
+
// Listen for selection changes
|
|
150
|
+
const selectionHandler = (event) => {
|
|
151
|
+
const customEvent = event;
|
|
152
|
+
this.selectedForPairing = customEvent.detail.selected;
|
|
153
|
+
element.selectedForPairing = this.selectedForPairing;
|
|
154
|
+
};
|
|
155
|
+
element.addEventListener('qti-selection-change', selectionHandler);
|
|
156
|
+
this.eventListeners.push({
|
|
157
|
+
element,
|
|
158
|
+
type: 'qti-selection-change',
|
|
159
|
+
handler: selectionHandler,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// Listen for response changes
|
|
163
|
+
const changeHandler = (event) => {
|
|
164
|
+
const qtiEvent = event;
|
|
165
|
+
this.handleResponseChange(qtiEvent.detail.responseId, qtiEvent.detail.value);
|
|
166
|
+
};
|
|
167
|
+
element.addEventListener('qti-change', changeHandler);
|
|
168
|
+
this.eventListeners.push({
|
|
169
|
+
element,
|
|
170
|
+
type: 'qti-change',
|
|
171
|
+
handler: changeHandler,
|
|
172
|
+
});
|
|
173
|
+
return element;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
console.error(`Failed to create element for ${interaction.type}:`, error);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Handle response change from an interaction
|
|
182
|
+
*/
|
|
183
|
+
handleResponseChange(responseId, value) {
|
|
184
|
+
// Update internal state
|
|
185
|
+
this.responses[responseId] = value;
|
|
186
|
+
// Notify callback
|
|
187
|
+
this.onResponseChange(responseId, value);
|
|
188
|
+
// Update any other elements that depend on this response
|
|
189
|
+
this.updateInteractionElement(responseId, value);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Update a specific interaction element's response value
|
|
193
|
+
*/
|
|
194
|
+
updateInteractionElement(responseId, value) {
|
|
195
|
+
for (const element of this.renderedElements) {
|
|
196
|
+
const interaction = element.interaction;
|
|
197
|
+
if (interaction && interaction.responseId === responseId) {
|
|
198
|
+
element.response = value;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Update all responses at once
|
|
204
|
+
*/
|
|
205
|
+
setResponses(responses) {
|
|
206
|
+
this.responses = { ...responses };
|
|
207
|
+
// Update all rendered elements
|
|
208
|
+
for (const element of this.renderedElements) {
|
|
209
|
+
const interaction = element.interaction;
|
|
210
|
+
if (interaction) {
|
|
211
|
+
element.response = this.responses[interaction.responseId] ?? null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Set disabled state for all interactions
|
|
217
|
+
*/
|
|
218
|
+
setDisabled(disabled) {
|
|
219
|
+
this.disabled = disabled;
|
|
220
|
+
// Update all rendered elements
|
|
221
|
+
for (const element of this.renderedElements) {
|
|
222
|
+
element.disabled = disabled;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get current responses
|
|
227
|
+
*/
|
|
228
|
+
getResponses() {
|
|
229
|
+
return { ...this.responses };
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Clean up event listeners and elements
|
|
233
|
+
*/
|
|
234
|
+
cleanup() {
|
|
235
|
+
// Remove event listeners
|
|
236
|
+
for (const { element, type, handler } of this.eventListeners) {
|
|
237
|
+
element.removeEventListener(type, handler);
|
|
238
|
+
}
|
|
239
|
+
this.eventListeners = [];
|
|
240
|
+
// Clear rendered elements
|
|
241
|
+
this.renderedElements = [];
|
|
242
|
+
// Reset pairing selection
|
|
243
|
+
this.selectedForPairing = null;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Destroy the renderer and clean up all resources
|
|
247
|
+
*/
|
|
248
|
+
destroy() {
|
|
249
|
+
this.cleanup();
|
|
250
|
+
this.container.innerHTML = '';
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create a new ItemRenderer instance
|
|
255
|
+
*/
|
|
256
|
+
export function createItemRenderer(config) {
|
|
257
|
+
return new ItemRenderer(config);
|
|
258
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { type DeclarationMap } from '@pie-qti/qti-processing';
|
|
2
|
+
import type { ExtractionRegistry } from '../extraction/ExtractionRegistry.js';
|
|
3
|
+
import type { AdaptiveAttemptResult, CompletionStatus, HtmlContent, ItemSessionState, PlayerConfig, PlayerSecurityConfig, RubricBlock, ScoringResult } from '../types/index.js';
|
|
4
|
+
import type { InteractionData } from '../types/interactions.js';
|
|
5
|
+
import type { ResponseValidationResult } from '../types/responseValidation.js';
|
|
6
|
+
import type { ComponentRegistry } from './ComponentRegistry.js';
|
|
7
|
+
export declare class Player {
|
|
8
|
+
private role;
|
|
9
|
+
private config;
|
|
10
|
+
private itemXml;
|
|
11
|
+
private doc;
|
|
12
|
+
private assessmentItem;
|
|
13
|
+
private decls;
|
|
14
|
+
private ctx;
|
|
15
|
+
private rng;
|
|
16
|
+
private ops;
|
|
17
|
+
private extractionRegistry;
|
|
18
|
+
private componentRegistry;
|
|
19
|
+
private i18nProvider;
|
|
20
|
+
private mapper;
|
|
21
|
+
private responseProcessingProgram;
|
|
22
|
+
private templateProcessingProgram;
|
|
23
|
+
private outcomeProcessingProgram;
|
|
24
|
+
constructor(config: PlayerConfig);
|
|
25
|
+
/** Breaking-change API: returns the typed declaration map */
|
|
26
|
+
getDeclarations(): DeclarationMap;
|
|
27
|
+
setResponses(responses: Record<string, unknown>): void;
|
|
28
|
+
processResponses(): ScoringResult;
|
|
29
|
+
getSecurityConfig(): PlayerSecurityConfig | undefined;
|
|
30
|
+
getTrustedTypesPolicyName(): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get the i18n provider instance
|
|
33
|
+
* @returns I18nProvider instance
|
|
34
|
+
*/
|
|
35
|
+
getI18nProvider(): any;
|
|
36
|
+
/**
|
|
37
|
+
* Get attribute value with QTI version support.
|
|
38
|
+
* Tries the attribute mapper's native form first, then falls back to direct lookup.
|
|
39
|
+
* @param el - Element to get attribute from
|
|
40
|
+
* @param canonicalName - Canonical (lowercase) attribute name
|
|
41
|
+
* @returns Attribute value or null
|
|
42
|
+
*/
|
|
43
|
+
private getAttrMapped;
|
|
44
|
+
/**
|
|
45
|
+
* Create a simple fallback i18n provider when none is provided
|
|
46
|
+
* This avoids a hard dependency on @pie-qti/i18n
|
|
47
|
+
*/
|
|
48
|
+
private createDefaultI18nProvider;
|
|
49
|
+
/**
|
|
50
|
+
* Detects the QTI version from the assessmentItem element.
|
|
51
|
+
* Checks both namespace URI and version attribute.
|
|
52
|
+
*
|
|
53
|
+
* @returns QTI version string ('2.0', '2.1', '2.2') or 'unknown'
|
|
54
|
+
*/
|
|
55
|
+
private detectQTIVersion;
|
|
56
|
+
/**
|
|
57
|
+
* Validates strict QTI 2.2 compliance if enabled in configuration.
|
|
58
|
+
* Logs warnings or throws errors based on config settings.
|
|
59
|
+
*/
|
|
60
|
+
private validateStrictCompliance;
|
|
61
|
+
private resetOutcomesToDefault;
|
|
62
|
+
getItemBodyHtml(): HtmlContent;
|
|
63
|
+
/**
|
|
64
|
+
* Extract rubric blocks for the current role.
|
|
65
|
+
*
|
|
66
|
+
* QTI uses `<rubricBlock view="...">` to provide role-specific guidance.
|
|
67
|
+
* We return sanitized HTML for direct rendering.
|
|
68
|
+
*/
|
|
69
|
+
getRubrics(): RubricBlock[];
|
|
70
|
+
getComponentRegistry(): ComponentRegistry;
|
|
71
|
+
getExtractionRegistry(): ExtractionRegistry;
|
|
72
|
+
/**
|
|
73
|
+
* Canonical interaction API (new): extracted, typed interaction data.
|
|
74
|
+
*/
|
|
75
|
+
getInteractionData(): InteractionData[];
|
|
76
|
+
/**
|
|
77
|
+
* Convenience API (used by tests/bench): returns a minimal interaction list with QTI-ish field names.
|
|
78
|
+
*/
|
|
79
|
+
getInteractions(): Array<{
|
|
80
|
+
type: string;
|
|
81
|
+
responseIdentifier: string;
|
|
82
|
+
} & Record<string, any>>;
|
|
83
|
+
getResponseInteractions(): Array<{
|
|
84
|
+
type: string;
|
|
85
|
+
responseIdentifier: string;
|
|
86
|
+
} & Record<string, any>>;
|
|
87
|
+
/**
|
|
88
|
+
* Returns response identifiers of endAttempt interactions with countAttempt="false".
|
|
89
|
+
* Used to detect hint-only submissions (e.g. Request Hint button).
|
|
90
|
+
*/
|
|
91
|
+
getHintEndAttemptIdentifiers(): string[];
|
|
92
|
+
getResponseIdentifiers(): string[];
|
|
93
|
+
isAdaptive(): boolean;
|
|
94
|
+
getNumAttempts(): number;
|
|
95
|
+
getCompletionStatus(): CompletionStatus;
|
|
96
|
+
isCompleted(): boolean;
|
|
97
|
+
submitAttempt(countAttempt?: boolean): AdaptiveAttemptResult;
|
|
98
|
+
getResponses(): Record<string, any>;
|
|
99
|
+
/**
|
|
100
|
+
* Get correct response for a specific response identifier
|
|
101
|
+
* @param responseId - The response identifier
|
|
102
|
+
* @returns The correct response value, or undefined if not available
|
|
103
|
+
*/
|
|
104
|
+
getCorrectResponse(responseId: string): any | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Get all correct responses as a map
|
|
107
|
+
* @returns Map of responseId to correct response value
|
|
108
|
+
*/
|
|
109
|
+
getCorrectResponses(): Record<string, any>;
|
|
110
|
+
getTemplateVariables(): Record<string, any>;
|
|
111
|
+
setTemplateVariables(vars: Record<string, any>): void;
|
|
112
|
+
getSessionState(): ItemSessionState;
|
|
113
|
+
validateResponses(responses: Record<string, any>): ResponseValidationResult;
|
|
114
|
+
getProgress(responses: Record<string, any>): {
|
|
115
|
+
total: number;
|
|
116
|
+
answered: number;
|
|
117
|
+
unanswered: number;
|
|
118
|
+
};
|
|
119
|
+
canSubmitResponses(responses: Record<string, any>): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* True if the learner has made any meaningful interaction, even if submission is not yet allowed.
|
|
122
|
+
* Used by assessment/session controllers to track "answered" state.
|
|
123
|
+
*/
|
|
124
|
+
isAttempted(responses: Record<string, any>): boolean;
|
|
125
|
+
private execTemplateProcessing;
|
|
126
|
+
private execResponseProcessingProgram;
|
|
127
|
+
private execOutcomeProcessingProgram;
|
|
128
|
+
private execResponseProcessingTemplate;
|
|
129
|
+
private buildDeclarations;
|
|
130
|
+
private parseMatchTable;
|
|
131
|
+
private parseInterpolationTable;
|
|
132
|
+
private ensureBuiltinDeclarations;
|
|
133
|
+
private applySessionState;
|
|
134
|
+
private parseDefaultValue;
|
|
135
|
+
private parseCorrectResponse;
|
|
136
|
+
private parseMapping;
|
|
137
|
+
private parseAreaMapping;
|
|
138
|
+
private coerceToDeclarationValue;
|
|
139
|
+
private collectOutcomes;
|
|
140
|
+
private renderPrintedVariables;
|
|
141
|
+
private getModalFeedback;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=Player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../../src/core/Player.ts"],"names":[],"mappings":"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"}
|