From b3dc059d2627d03ee74780ffd26908b44fb49b18 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Mon, 22 Jan 2024 13:32:56 +0200 Subject: [PATCH] fix multiple choice get updated node --- .../components/SwitchComponent.js | 13 ++++++++++++- .../components/SwitchComponent.js | 13 ++++++++++++- .../components/TrueFalseSwitch.js | 2 +- .../components/SwitchComponent.js | 13 ++++++++++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/SwitchComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/SwitchComponent.js index 2fb008ce4..21bba2e42 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/SwitchComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/SwitchComponent.js @@ -81,6 +81,17 @@ const CustomSwitch = ({ node, getPos }) => { main.dispatch(tr); }; + const getUpdatedNode = () => { + let nodeFound = node; + const allNodes = getNodes(main); + allNodes.forEach(singNode => { + if (singNode.node.attrs.id === node.attrs.id) { + nodeFound = singNode; + } + }); + return nodeFound; + }; + return ( <YesNoSwitch checked={checked} @@ -88,7 +99,7 @@ const CustomSwitch = ({ node, getPos }) => { customProps={customProps} handleChange={handleChange} isEditable={isEditable} - node={node} + node={getUpdatedNode()} /> ); }; diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/SwitchComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/SwitchComponent.js index 5fdd636b3..11c010449 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/SwitchComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/SwitchComponent.js @@ -46,6 +46,17 @@ const CustomSwitch = ({ node, getPos }) => { }); }; + const getUpdatedNode = () => { + let nodeFound = node; + const allNodes = getNodes(main); + allNodes.forEach(singNode => { + if (singNode.node.attrs.id === node.attrs.id) { + nodeFound = singNode; + } + }); + return nodeFound; + }; + return ( <TrueFalseSwitch checked={checked} @@ -53,7 +64,7 @@ const CustomSwitch = ({ node, getPos }) => { customProps={customProps} handleChange={handleChange} isEditable={isEditable} - node={node} + node={getUpdatedNode()} /> ); }; diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/TrueFalseSwitch.js b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/TrueFalseSwitch.js index f7b7dedf7..1f2865672 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/TrueFalseSwitch.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/TrueFalseSwitch.js @@ -61,7 +61,7 @@ const StyledIconWrong = styled(Icon)` const TrueFalseSwitch = ({ customProps, - node, + node: { node }, isEditable, handleChange, checked, diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/SwitchComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/SwitchComponent.js index 73aeb1ac7..ee8c6c608 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/SwitchComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/SwitchComponent.js @@ -81,6 +81,17 @@ const CustomSwitch = ({ node, getPos }) => { main.dispatch(tr); }; + const getUpdatedNode = () => { + let nodeFound = node; + const allNodes = getNodes(main); + allNodes.forEach(singNode => { + if (singNode.node.attrs.id === node.attrs.id) { + nodeFound = singNode; + } + }); + return nodeFound; + }; + return ( <TrueFalseSwitch checked={checked} @@ -88,7 +99,7 @@ const CustomSwitch = ({ node, getPos }) => { customProps={customProps} handleChange={handleChange} isEditable={isEditable} - node={node} + node={getUpdatedNode()} /> ); }; -- GitLab