diff --git a/public/react/src/modules/courses/common/CNotificationHOC.js b/public/react/src/modules/courses/common/CNotificationHOC.js index 95e36957f..9a08268b1 100644 --- a/public/react/src/modules/courses/common/CNotificationHOC.js +++ b/public/react/src/modules/courses/common/CNotificationHOC.js @@ -106,11 +106,11 @@ export function CNotificationHOC(options = {}) { confirm = (object) => { - const { title, content, onOk, onCancel, okText } = object; + const { title, content,subContent, onOk, onCancel, okText } = object; this.onCancel = onCancel this.onOk = onOk this.okText = okText || '' - this.setState({ title, content, dialogOpen: true }) + this.setState({ title, content , subContent , dialogOpen: true }) } onDialogOkBtnClick = () => { this.onOk && this.onOk(); @@ -141,17 +141,17 @@ export function CNotificationHOC(options = {}) { this.onOk = null } render() { - const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical, dialogOpen, content ,defineOpen } = this.state; + const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical, dialogOpen, content ,subContent ,defineOpen } = this.state; return ( - { + let url=`/exercise_questions/${question_id}/update_scores.json` + axios.post((url),{ + standard_answers:answerArray + }).then((result)=>{ + if(result){ + this.props.showNotification(`${result.data.message}`); + this.addSuccess(); + } + }).catch((error)=>{ + console.log(error); + }) + } + fetchExercise = () => { const Id = this.props.match.params.Id this.isEdit = !!Id @@ -507,7 +523,7 @@ class ExerciceNew extends Component{ { exercise_questions.map((item, index) => { if (item.question_type == 0 || item.question_type == 1) { if (item.isNew) { - return + return } else { return + return } else { return } } else if (item.question_type == 3) { if (item.isNew) { - return + return } else { return } diff --git a/public/react/src/modules/courses/exercise/new/JudgeEditor.js b/public/react/src/modules/courses/exercise/new/JudgeEditor.js index ab93b5bc5..16ccad54a 100644 --- a/public/react/src/modules/courses/exercise/new/JudgeEditor.js +++ b/public/react/src/modules/courses/exercise/new/JudgeEditor.js @@ -93,10 +93,20 @@ class SingleEditor extends Component{ question_choices, standard_answers: answerArray, insert_id: question_id_to_insert_after || undefined - }) - .then((response) => { + }).then((response) => { if (response.data.status == 0) { this.props.addSuccess() + }else if(response.data.status == 3){ + this.props.confirm({ + content:'修改了标准答案', + subContent:"是否重新计算学生答题的成绩?", + onOk:()=>{ + this.props.sureChangeScore(question_id,answerArray) + }, + onCancel:()=>{ + this.props.addSuccess(); + } + }) } }) .catch(function (error) { diff --git a/public/react/src/modules/courses/exercise/new/NullEditor.js b/public/react/src/modules/courses/exercise/new/NullEditor.js index dca67032f..f3c736196 100644 --- a/public/react/src/modules/courses/exercise/new/NullEditor.js +++ b/public/react/src/modules/courses/exercise/new/NullEditor.js @@ -133,10 +133,20 @@ class NullEditor extends Component{ standard_answers: answerArray, insert_id: question_id_to_insert_after || undefined, is_ordered:newis_ordered, - }) - .then((response) => { + }).then((response) => { if (response.data.status == 0) { this.props.addSuccess() + }else if(response.data.status == 3){ + this.props.confirm({ + content:'修改了标准答案', + subContent:"是否重新计算学生答题的成绩?", + onOk:()=>{ + this.props.sureChangeScore(question_id,answerArray) + }, + onCancel:()=>{ + this.props.addSuccess(); + } + }) } }) .catch(function (error) { diff --git a/public/react/src/modules/courses/exercise/new/SingleEditor.js b/public/react/src/modules/courses/exercise/new/SingleEditor.js index b979b62c1..8053f4f21 100644 --- a/public/react/src/modules/courses/exercise/new/SingleEditor.js +++ b/public/react/src/modules/courses/exercise/new/SingleEditor.js @@ -105,8 +105,6 @@ class SingleEditor extends Component{ if(!question_title) { this.refs['titleEditor'].showError() this.props.showNotification('题目:不能为空'); return; - - } for(let i = 0; i < question_choices.length; i++) { @@ -115,7 +113,6 @@ class SingleEditor extends Component{ this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`); return; } } - /** { "question_title":"同学朋友间常用的沟通工具是什么?", @@ -134,15 +131,25 @@ class SingleEditor extends Component{ question_choices, standard_answers: answerArray, insert_id: question_id_to_insert_after || undefined + }).then((response) => { + if (response.data.status == 0) { + this.props.addSuccess() + }else if(response.data.status == 3){ + this.props.confirm({ + content:'修改了标准答案', + subContent:"是否重新计算学生答题的成绩?", + onOk:()=>{ + this.props.sureChangeScore(question_id,answerArray) + }, + onCancel:()=>{ + this.props.addSuccess(); + } + }) + } }) - .then((response) => { - if (response.data.status == 0) { - this.props.addSuccess() - } - }) - .catch(function (error) { - console.log(error); - }); + .catch(function (error) { + console.log(error); + }); } else { const url = `/exercises/${Id}/exercise_questions.json` @@ -167,6 +174,9 @@ class SingleEditor extends Component{ onCancel = () => { this.props.onEditorCancel() } + + + componentDidMount = () => { }