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