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

fix

parent f7a3b5e3
No related branches found
No related tags found
1 merge request!348Multiple single
...@@ -39,8 +39,9 @@ const CustomSwitch = ({ node, getPos }) => { ...@@ -39,8 +39,9 @@ const CustomSwitch = ({ node, getPos }) => {
const handleChange = () => { const handleChange = () => {
setChecked(!checked); setChecked(!checked);
context.view.main.state.doc.descendants((editorNode, index) => { context.view.main.state.doc.descendants((editorNode, pos) => {
if (editorNode.type.name === 'multiple_choice_single_correct_container') { if (editorNode.type.name === 'multiple_choice_single_correct_container') {
console.log(editorNode, pos);
editorNode.content.content.forEach(element => { editorNode.content.content.forEach(element => {
if (element.attrs.id === node.attrs.id) { if (element.attrs.id === node.attrs.id) {
context.view.main.dispatch( context.view.main.dispatch(
...@@ -49,8 +50,18 @@ const CustomSwitch = ({ node, getPos }) => { ...@@ -49,8 +50,18 @@ const CustomSwitch = ({ node, getPos }) => {
correct: !checked, correct: !checked,
}), }),
); );
} else { } else if (element.attrs.correct) {
console.log('in else'); console.log(element);
context.view.main.dispatch(
context.view.main.state.tr.setNodeMarkup(
getPos() + 4,
undefined,
{
...element.attrs,
correct: false,
},
),
);
} }
}); });
} }
......
...@@ -16,7 +16,7 @@ const multipleChoiceSingleCorrectContainerNode = { ...@@ -16,7 +16,7 @@ const multipleChoiceSingleCorrectContainerNode = {
return { return {
id: dom.dataset.id, id: dom.dataset.id,
class: dom.getAttribute('class'), class: dom.getAttribute('class'),
correctId: dom.getAttribute('singleCorrect'), correctId: dom.getAttribute('correctId'),
}; };
}, },
}, },
......
...@@ -6,13 +6,11 @@ const multipleChoiceSingleCorrectNode = { ...@@ -6,13 +6,11 @@ const multipleChoiceSingleCorrectNode = {
id: { default: uuidv4() }, id: { default: uuidv4() },
correct: { default: false }, correct: { default: false },
feedback: { default: '' }, feedback: { default: '' },
singleCorrect: { default: true },
}, },
group: 'block questions', group: 'block questions',
content: 'block*', content: 'block*',
defining: true, defining: true,
// atom: true,
parseDOM: [ parseDOM: [
{ {
tag: 'div.multiple-choice-option-single-correct', tag: 'div.multiple-choice-option-single-correct',
...@@ -22,7 +20,6 @@ const multipleChoiceSingleCorrectNode = { ...@@ -22,7 +20,6 @@ const multipleChoiceSingleCorrectNode = {
class: dom.getAttribute('class'), class: dom.getAttribute('class'),
correct: JSON.parse(dom.getAttribute('correct').toLowerCase()), correct: JSON.parse(dom.getAttribute('correct').toLowerCase()),
feedback: dom.getAttribute('feedback'), feedback: dom.getAttribute('feedback'),
singleCorrect: dom.getAttribute('singleCorrect'),
}; };
}, },
}, },
......
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