From 9e93f9c59e87b6cea973f123c0eec71459afdbca Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Sat, 24 Aug 2019 10:34:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B7=B2=E5=8F=91=E5=B8=83=E8=AF=95?= =?UTF-8?q?=E5=8D=B7=E7=BC=96=E8=BE=91=E4=BF=9D=E5=AD=98=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E8=AF=A2=E9=97=AE=E6=98=AF=E5=90=A6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=88=86=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/common/CNotificationHOC.js | 10 +++--- .../modules/courses/exercise/ExerciseNew.js | 22 +++++++++++-- .../courses/exercise/new/JudgeEditor.js | 14 ++++++-- .../courses/exercise/new/NullEditor.js | 14 ++++++-- .../courses/exercise/new/SingleEditor.js | 32 ++++++++++++------- 5 files changed, 69 insertions(+), 23 deletions(-) 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 = () => { } From de0aef568f4e703e5c7dcb579ea17f882e7ed716 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 24 Aug 2019 11:00:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A0=87=E5=87=86=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index f59bee5ac..e65bd2f01 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -44,6 +44,8 @@ module ExercisesHelper stand_answer = 0 end + Rails.logger.info("#######_____________ques_score_________________#{ques_score}") + ques_option = { "q_id":q.id, #该问题的id "q_type":q.question_type, From f4f2dcc114dab53aa3c8b739f6fe8710801bc88e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 24 Aug 2019 11:07:44 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index e65bd2f01..0cc6a9ec5 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -32,7 +32,7 @@ module ExercisesHelper ques_score = 0.0 end else - ques_score = answers_content.select(:score).pluck(:score).sum + ques_score = answers_content.score_reviewed.select(:score).pluck(:score).sum end if ques_score >= q.question_score #满分作答为正确 @@ -44,8 +44,6 @@ module ExercisesHelper stand_answer = 0 end - Rails.logger.info("#######_____________ques_score_________________#{ques_score}") - ques_option = { "q_id":q.id, #该问题的id "q_type":q.question_type,