From dae37b30c85cc6498cc1f0f83a9c01f97dfa5245 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 9 Nov 2023 13:28:33 +0200 Subject: [PATCH] keep type per question --- .../NumericalAnswerContainerComponent.js | 23 +++++++++++-------- .../NumericalAnswerDropDownCompontent.js | 3 +-- .../schema/NumericalAnswerContainerNode.js | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerContainerComponent.js b/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerContainerComponent.js index 759259341..8d05991f4 100644 --- a/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerContainerComponent.js +++ b/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerContainerComponent.js @@ -22,7 +22,8 @@ const NumericalAnswerContainerTool = styled.div` border: 3px solid #f5f5f7; border-bottom: none; height: 33px; - + display: flex; + flex-direction: row; span:first-of-type { position: relative; top: 3px; @@ -39,9 +40,8 @@ const ActionButton = styled.button` margin-top: 16px; border: none; position: relative; - bottom: 40px; - left: -11px; - float: right; + margin-left: auto; + bottom: 13px; `; const StyledIconActionRemove = styled(Icon)` @@ -55,7 +55,6 @@ export default ({ node, view, getPos }) => { options, pmViews: { main }, } = context; - const { numericalAnswer } = options; const customProps = main.props.customValues; const { testMode } = customProps; @@ -105,10 +104,16 @@ export default ({ node, view, getPos }) => { view={view} /> <NumericalAnswerOption> - {!numericalAnswer && <>No Type Selected</>} - {numericalAnswer === 'exactAnswer' && <ExactAnswerComponent />} - {numericalAnswer === 'rangeAnswer' && <RangeAnswerComponent />} - {numericalAnswer === 'preciseAnswer' && <PreciseAnswerComponent />} + {!options[node.attrs.id] && <>No Type Selected</>} + {options[node.attrs.id]?.numericalAnswer === 'exactAnswer' && ( + <ExactAnswerComponent /> + )} + {options[node.attrs.id]?.numericalAnswer === 'rangeAnswer' && ( + <RangeAnswerComponent /> + )} + {options[node.attrs.id]?.numericalAnswer === 'preciseAnswer' && ( + <PreciseAnswerComponent /> + )} </NumericalAnswerOption> {!testMode && !(readOnly && feedback === '') && ( <FeedbackComponent diff --git a/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerDropDownCompontent.js b/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerDropDownCompontent.js index 61efd0d2a..8b91aa20c 100644 --- a/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerDropDownCompontent.js +++ b/wax-questions-service/src/NumericalAnswerService/components/NumericalAnswerDropDownCompontent.js @@ -69,7 +69,6 @@ const StyledIcon = styled(Icon)` `; const NumericalAnswerDropDownCompontent = ({ nodeId }) => { - console.log(nodeId); const dropDownOptions = [ { label: 'Exact answer with margin of error', @@ -157,7 +156,7 @@ const NumericalAnswerDropDownCompontent = ({ nodeId }) => { }; const onChange = option => { - context.setOption({ numericalAnswer: option.value }); + context.setOption({ [nodeId]: { numericalAnswer: option.value } }); main.dispatch(main.state.tr.setMeta('addToHistory', false)); setLabel(option.label); openCloseMenu(); diff --git a/wax-questions-service/src/NumericalAnswerService/schema/NumericalAnswerContainerNode.js b/wax-questions-service/src/NumericalAnswerService/schema/NumericalAnswerContainerNode.js index 131107c5e..a98ec716b 100644 --- a/wax-questions-service/src/NumericalAnswerService/schema/NumericalAnswerContainerNode.js +++ b/wax-questions-service/src/NumericalAnswerService/schema/NumericalAnswerContainerNode.js @@ -3,6 +3,7 @@ const NumericalAnswerContainerNode = { id: { default: '' }, class: { default: 'numerical-answer' }, feedback: { default: '' }, + answerType: { default: '' }, }, group: 'block questions', atom: true, -- GitLab