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

fix type selection

parent 6e84955f
No related branches found
No related tags found
1 merge request!513Student numerical
...@@ -54,8 +54,9 @@ export default ({ node, view, getPos }) => { ...@@ -54,8 +54,9 @@ export default ({ node, view, getPos }) => {
const { const {
options, options,
pmViews: { main }, pmViews: { main },
setOption,
} = context; } = context;
const [answerType, setAnswerType] = useState(node.attrs.answerType);
const customProps = main.props.customValues; const customProps = main.props.customValues;
const { testMode } = customProps; const { testMode } = customProps;
...@@ -81,11 +82,8 @@ export default ({ node, view, getPos }) => { ...@@ -81,11 +82,8 @@ export default ({ node, view, getPos }) => {
}; };
useEffect(() => { useEffect(() => {
const allNodes = getNodes(context.pmViews.main); setOption({
allNodes.forEach(singleNode => { [node.attrs.id]: { numericalAnswer: node.attrs.answerType },
if (singleNode.node.attrs.id === node.attrs.id) {
setAnswerType(singleNode.node.attrs.answerType);
}
}); });
}, []); }, []);
...@@ -113,19 +111,16 @@ export default ({ node, view, getPos }) => { ...@@ -113,19 +111,16 @@ export default ({ node, view, getPos }) => {
view={view} view={view}
/> />
<NumericalAnswerOption> <NumericalAnswerOption>
{!options[node.attrs.id] && answerType === '' && ( {options[node.attrs.id]?.numericalAnswer === '' && (
<>No Type Selected</> <>No Type Selected</>
)} )}
{(options[node.attrs.id]?.numericalAnswer === 'exactAnswer' || {options[node.attrs.id]?.numericalAnswer === 'exactAnswer' && (
answerType === 'exactAnswer') && (
<ExactAnswerComponent node={node} /> <ExactAnswerComponent node={node} />
)} )}
{(options[node.attrs.id]?.numericalAnswer === 'rangeAnswer' || {options[node.attrs.id]?.numericalAnswer === 'rangeAnswer' && (
answerType === 'rangeAnswer') && (
<RangeAnswerComponent node={node} /> <RangeAnswerComponent node={node} />
)} )}
{(options[node.attrs.id]?.numericalAnswer === 'preciseAnswer' || {options[node.attrs.id]?.numericalAnswer === 'preciseAnswer' && (
answerType === 'preciseAnswer') && (
<PreciseAnswerComponent node={node} /> <PreciseAnswerComponent node={node} />
)} )}
</NumericalAnswerOption> </NumericalAnswerOption>
......
...@@ -47,7 +47,7 @@ const RangeAnswerComponent = ({ node }) => { ...@@ -47,7 +47,7 @@ const RangeAnswerComponent = ({ node }) => {
if (singleNode.node.attrs.id === node.attrs.id) { if (singleNode.node.attrs.id === node.attrs.id) {
const obj = { const obj = {
minAnswer: onlyNumbers(minRef.current.value), minAnswer: onlyNumbers(minRef.current.value),
maxError: onlyNumbers(maxRef.current.value), maxAnswer: onlyNumbers(maxRef.current.value),
}; };
context.pmViews.main.dispatch( context.pmViews.main.dispatch(
......
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