Skip to content
Snippets Groups Projects
Commit dae37b30 authored by chris's avatar chris
Browse files

keep type per question

parent 832b25ec
No related branches found
No related tags found
1 merge request!511Numerical answer
...@@ -22,7 +22,8 @@ const NumericalAnswerContainerTool = styled.div` ...@@ -22,7 +22,8 @@ const NumericalAnswerContainerTool = styled.div`
border: 3px solid #f5f5f7; border: 3px solid #f5f5f7;
border-bottom: none; border-bottom: none;
height: 33px; height: 33px;
display: flex;
flex-direction: row;
span:first-of-type { span:first-of-type {
position: relative; position: relative;
top: 3px; top: 3px;
...@@ -39,9 +40,8 @@ const ActionButton = styled.button` ...@@ -39,9 +40,8 @@ const ActionButton = styled.button`
margin-top: 16px; margin-top: 16px;
border: none; border: none;
position: relative; position: relative;
bottom: 40px; margin-left: auto;
left: -11px; bottom: 13px;
float: right;
`; `;
const StyledIconActionRemove = styled(Icon)` const StyledIconActionRemove = styled(Icon)`
...@@ -55,7 +55,6 @@ export default ({ node, view, getPos }) => { ...@@ -55,7 +55,6 @@ export default ({ node, view, getPos }) => {
options, options,
pmViews: { main }, pmViews: { main },
} = context; } = context;
const { numericalAnswer } = options;
const customProps = main.props.customValues; const customProps = main.props.customValues;
const { testMode } = customProps; const { testMode } = customProps;
...@@ -105,10 +104,16 @@ export default ({ node, view, getPos }) => { ...@@ -105,10 +104,16 @@ export default ({ node, view, getPos }) => {
view={view} view={view}
/> />
<NumericalAnswerOption> <NumericalAnswerOption>
{!numericalAnswer && <>No Type Selected</>} {!options[node.attrs.id] && <>No Type Selected</>}
{numericalAnswer === 'exactAnswer' && <ExactAnswerComponent />} {options[node.attrs.id]?.numericalAnswer === 'exactAnswer' && (
{numericalAnswer === 'rangeAnswer' && <RangeAnswerComponent />} <ExactAnswerComponent />
{numericalAnswer === 'preciseAnswer' && <PreciseAnswerComponent />} )}
{options[node.attrs.id]?.numericalAnswer === 'rangeAnswer' && (
<RangeAnswerComponent />
)}
{options[node.attrs.id]?.numericalAnswer === 'preciseAnswer' && (
<PreciseAnswerComponent />
)}
</NumericalAnswerOption> </NumericalAnswerOption>
{!testMode && !(readOnly && feedback === '') && ( {!testMode && !(readOnly && feedback === '') && (
<FeedbackComponent <FeedbackComponent
......
...@@ -69,7 +69,6 @@ const StyledIcon = styled(Icon)` ...@@ -69,7 +69,6 @@ const StyledIcon = styled(Icon)`
`; `;
const NumericalAnswerDropDownCompontent = ({ nodeId }) => { const NumericalAnswerDropDownCompontent = ({ nodeId }) => {
console.log(nodeId);
const dropDownOptions = [ const dropDownOptions = [
{ {
label: 'Exact answer with margin of error', label: 'Exact answer with margin of error',
...@@ -157,7 +156,7 @@ const NumericalAnswerDropDownCompontent = ({ nodeId }) => { ...@@ -157,7 +156,7 @@ const NumericalAnswerDropDownCompontent = ({ nodeId }) => {
}; };
const onChange = option => { const onChange = option => {
context.setOption({ numericalAnswer: option.value }); context.setOption({ [nodeId]: { numericalAnswer: option.value } });
main.dispatch(main.state.tr.setMeta('addToHistory', false)); main.dispatch(main.state.tr.setMeta('addToHistory', false));
setLabel(option.label); setLabel(option.label);
openCloseMenu(); openCloseMenu();
......
...@@ -3,6 +3,7 @@ const NumericalAnswerContainerNode = { ...@@ -3,6 +3,7 @@ const NumericalAnswerContainerNode = {
id: { default: '' }, id: { default: '' },
class: { default: 'numerical-answer' }, class: { default: 'numerical-answer' },
feedback: { default: '' }, feedback: { default: '' },
answerType: { default: '' },
}, },
group: 'block questions', group: 'block questions',
atom: true, atom: true,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment