diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js index ef075cfc1e1bf3f0cbf69a1dbc17ec7769a8033a..8d372ad10b102b2775d6e05f1a1b6b67169cdd69 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js @@ -32,11 +32,11 @@ class MultipleChoiceQuestionService extends Service { question_node_multiple: questionNode, }); - addPortal({ - nodeView: MultipleChoiceContainerNodeView, - component: MultipleChoiceContainerComponent, - context: this.app, - }); + // addPortal({ + // nodeView: MultipleChoiceContainerNodeView, + // component: MultipleChoiceContainerComponent, + // context: this.app, + // }); addPortal({ nodeView: QuestionNodeView, diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/MultipleChoiceSingleCorrectQuestionService.js b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/MultipleChoiceSingleCorrectQuestionService.js index 79f481c1babf7c2fbf198c863514af80826ff219..0ce78d5415848e1816c030e850a82ea1676c0333 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/MultipleChoiceSingleCorrectQuestionService.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/MultipleChoiceSingleCorrectQuestionService.js @@ -30,11 +30,11 @@ class MultipleChoiceSingleCorrectQuestionService extends Service { question_node_multiple_single: questionSingleNode, }); - addPortal({ - nodeView: MultipleChoiceSingleCorrectContainerNodeView, - component: MultipleChoiceContainerComponent, - context: this.app, - }); + // addPortal({ + // nodeView: MultipleChoiceSingleCorrectContainerNodeView, + // component: MultipleChoiceContainerComponent, + // context: this.app, + // }); addPortal({ nodeView: QuestionMultipleSingleNodeView, diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/AnswerComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/AnswerComponent.js index ceaa25f7a2accf65f481839cad1d5b7b50b2afa8..e7005a3d1622f6e51d23b890b45901a3df4e68ef 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/AnswerComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/MultipleChoiceSingleCorrectQuestionService/components/AnswerComponent.js @@ -131,30 +131,10 @@ export default ({ node, view, getPos }) => { }; }, []); - // const removeOption = () => { - // const answersCount = findAnswerCount(); - // if (answersCount.count >= 1) { - // main.state.doc.nodesBetween(getPos(), getPos() + 1, (sinlgeNode, pos) => { - // if (sinlgeNode.attrs.id === node.attrs.id) { - // main.dispatch( - // main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), - // ); - // } - // }); - // } else { - // main.dispatch( - // main.state.tr.setSelection( - // NodeSelection.create(main.state.doc, answersCount.parentPosition), - // ), - // ); - // main.dispatch(main.state.tr.deleteSelection()); - // } - // }; - const removeOption = () => { const answersCount = findAnswerCount(); if (answersCount.count >= 1) { - answersCount.parentContainer.content.content.forEach(sinlgeNode => { + main.state.doc.nodesBetween(getPos(), getPos() + 1, (sinlgeNode, pos) => { if (sinlgeNode.attrs.id === node.attrs.id) { main.dispatch( main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/TrueFalseQuestionService.js b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/TrueFalseQuestionService.js index c90abf2b7c93002dc1189397486bd427f29ac192..ff8e436cca32ad078b58b3eaf25cf585f7b9b2dc 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/TrueFalseQuestionService.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/TrueFalseQuestionService.js @@ -28,11 +28,11 @@ class TrueFalseQuestionService extends Service { question_node_true_false: questionTrueFalseNode, }); - addPortal({ - nodeView: TrueFalseContainerNodeView, - component: MultipleChoiceContainerComponent, - context: this.app, - }); + // addPortal({ + // nodeView: TrueFalseContainerNodeView, + // component: MultipleChoiceContainerComponent, + // context: this.app, + // }); addPortal({ nodeView: QuestionTrueFalseNodeView, diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/AnswerComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/AnswerComponent.js index 160b67ab30463cf56f605af2f0f7eebfde70026d..8c7af5e73f80e0e6a62d8bf115e1ec5bf21f4f6a 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/AnswerComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseQuestionService/components/AnswerComponent.js @@ -131,30 +131,10 @@ export default ({ node, view, getPos }) => { }; }, []); - // const removeOption = () => { - // const answersCount = findAnswerCount(); - // if (answersCount.count >= 1) { - // main.state.doc.nodesBetween(getPos(), getPos() + 1, (sinlgeNode, pos) => { - // if (sinlgeNode.attrs.id === node.attrs.id) { - // main.dispatch( - // main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), - // ); - // } - // }); - // } else { - // main.dispatch( - // main.state.tr.setSelection( - // NodeSelection.create(main.state.doc, answersCount.parentPosition), - // ), - // ); - // main.dispatch(main.state.tr.deleteSelection()); - // } - // }; - const removeOption = () => { const answersCount = findAnswerCount(); if (answersCount.count >= 1) { - answersCount.parentContainer.content.content.forEach(sinlgeNode => { + main.state.doc.nodesBetween(getPos(), getPos() + 1, (sinlgeNode, pos) => { if (sinlgeNode.attrs.id === node.attrs.id) { main.dispatch( main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/TrueFalseSingleCorrectQuestionService.js b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/TrueFalseSingleCorrectQuestionService.js index 12eaf6789ff1086cf74d6d7fa1a9b0eeef869eae..d042f2b9020bd3ff7f7a6b9aa4a5631b6de48b56 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/TrueFalseSingleCorrectQuestionService.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/TrueFalseSingleCorrectQuestionService.js @@ -30,11 +30,11 @@ class TrueFalseSingleCorrectQuestionService extends Service { true_false_single_correct: trueFalseSingleCorrectNode, }); - addPortal({ - nodeView: TrueFalseSingleCorrectContainerNodeView, - component: MultipleChoiceContainerComponent, - context: this.app, - }); + // addPortal({ + // nodeView: TrueFalseSingleCorrectContainerNodeView, + // component: MultipleChoiceContainerComponent, + // context: this.app, + // }); addPortal({ nodeView: QuestionTrueFalseSingleNodeView, diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/AnswerComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/AnswerComponent.js index 08a653559b63b92a7db1e67d2084e95ef45e9440..818aca43e8ba603fd20c960fb1113a94b4941c9e 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/AnswerComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/TrueFalseSingleCorrectQuestionService/components/AnswerComponent.js @@ -131,30 +131,10 @@ export default ({ node, view, getPos }) => { }; }, []); - // const removeOption = () => { - // const answersCount = findAnswerCount(); - // if (answersCount.count >= 1) { - // main.state.doc.nodesBetween(getPos(), getPos() + 1, (sinlgeNode, pos) => { - // if (sinlgeNode.attrs.id === node.attrs.id) { - // main.dispatch( - // main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), - // ); - // } - // }); - // } else { - // main.dispatch( - // main.state.tr.setSelection( - // NodeSelection.create(main.state.doc, answersCount.parentPosition), - // ), - // ); - // main.dispatch(main.state.tr.deleteSelection()); - // } - // }; - const removeOption = () => { const answersCount = findAnswerCount(); if (answersCount.count >= 1) { - answersCount.parentContainer.content.content.forEach(sinlgeNode => { + main.state.doc.nodesBetween(getPos(), getPos() + 1, (sinlgeNode, pos) => { if (sinlgeNode.attrs.id === node.attrs.id) { main.dispatch( main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/components/AnswerComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/components/AnswerComponent.js index 1110f5481eda645bdd725c3757ef8eef3d7b2b3c..46b2058725d350e957e2c5359ba6add667320bc4 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/components/AnswerComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/components/AnswerComponent.js @@ -130,30 +130,10 @@ export default ({ node, view, getPos }) => { }; }, []); - // const removeOption = () => { - // const answersCount = findAnswerCount(); - // if (answersCount.count >= 1) { - // main.state.doc.nodesBetween(getPos(), getPos() + 1, sinlgeNode => { - // if (sinlgeNode.attrs.id === node.attrs.id) { - // main.dispatch( - // main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), - // ); - // } - // }); - // } else { - // main.dispatch( - // main.state.tr.setSelection( - // NodeSelection.create(main.state.doc, answersCount.parentPosition), - // ), - // ); - // main.dispatch(main.state.tr.deleteSelection()); - // } - // }; - const removeOption = () => { const answersCount = findAnswerCount(); if (answersCount.count >= 1) { - answersCount.parentContainer.content.content.forEach(sinlgeNode => { + main.state.doc.nodesBetween(getPos(), getPos() + 1, sinlgeNode => { if (sinlgeNode.attrs.id === node.attrs.id) { main.dispatch( main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), @@ -170,6 +150,26 @@ export default ({ node, view, getPos }) => { } }; + // const removeOption = () => { + // const answersCount = findAnswerCount(); + // if (answersCount.count >= 1) { + // answersCount.parentContainer.content.content.forEach(sinlgeNode => { + // if (sinlgeNode.attrs.id === node.attrs.id) { + // main.dispatch( + // main.state.tr.deleteRange(getPos(), getPos() + sinlgeNode.nodeSize), + // ); + // } + // }); + // } else { + // main.dispatch( + // main.state.tr.setSelection( + // NodeSelection.create(main.state.doc, answersCount.parentPosition), + // ), + // ); + // main.dispatch(main.state.tr.deleteSelection()); + // } + // }; + const addOption = nodeId => { const newAnswerId = uuidv4(); main.state.doc.descendants((editorNode, index) => { diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js index 421f4aec87f83f449da19d89ebba9eddf9d1ae6d..e9de0a2d42e1e0f15317feb6e2cee1742c914c04 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js @@ -69,6 +69,7 @@ const QuestionEditorComponent = ({ placeholderText = 'Type your item', QuestionType = 'Multiple', forceEditable = false, + showDelete = false, }) => { const editorRef = useRef(); @@ -212,9 +213,11 @@ const QuestionEditorComponent = ({ const addToHistory = !tr.getMeta('exludeToHistoryFromOutside'); const { state, transactions } = questionView.state.applyTransaction(tr); questionView.updateState(state); - setTimeout(() => { - context.updateView({}, questionId); - }); + context.updateView({}, questionId); + + // setTimeout(() => { + // context.updateView({}, questionId); + // }); if (!tr.getMeta('fromOutside')) { const outerTr = view.state.tr; diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/components/QuestionComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/components/QuestionComponent.js index 0f5e0f3039f51aeb09b8c3f038f4a9fb84068de5..2d43386608443b4f352a3eb954cf3c5dea658ca5 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/components/QuestionComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/components/QuestionComponent.js @@ -2,5 +2,5 @@ import React from 'react'; import EditorComponent from './EditorComponent'; export default ({ node, view, getPos }) => { - return <EditorComponent getPos={getPos} node={node} view={view} />; + return <EditorComponent getPos={getPos} node={node} showDelete view={view} />; }; diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/multipleQuestionStyles.css b/wax-questions-service/src/MultipleChoiceQuestionService/multipleQuestionStyles.css index 4fa9fb66638c89a58d6c379817464cf494eb3b2c..2e322bc9287f82205cfd66b4f255edb8822f2ab7 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/multipleQuestionStyles.css +++ b/wax-questions-service/src/MultipleChoiceQuestionService/multipleQuestionStyles.css @@ -4,11 +4,12 @@ .multiple-choice-single-correct, .true-false, .true-false-single-correct { - /* border: 3px solid #f5f5f7; - padding: 20px; */ + border: 3px solid #f5f5f7; + padding: 20px; + margin: 38px; + /* margin: 12px 2px 12px 12px; */ + /* padding-top: 0px; */ counter-reset: question-item-multiple; - margin: 12px 2px 12px 12px; - padding-top: 0px; } .multiple-choice:before,