From 3815715347cb9fb70a65f020bad350f6e6b4a178 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 16 Oct 2019 16:23:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=A1=AB=E7=A9=BA?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 61 ++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 0bff75ee4..59a2d3d25 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -112,43 +112,44 @@ module ExercisesHelper effictive_users_count = effictive_users.size #有效回答数,可能有重复的用户id,这里仅统计是否回答这个问题的全部人数 # - # if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时, - # ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 - # percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 - # - # end - - if ex.question_type != Exercise::MULTIPLE + if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时, ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 - else - multiple_score = 0 - user_ids.each do |user_id| - ex_answer_score = ex_answers.select{|answer| answer.user_id == user_id}&.first&.score.to_f - multiple_score += ex_answer_score - end - - percent = (ex_total_score == 0.0 ? 0.0 : (multiple_score / ex_total_score.to_f).round(3) * 100) #正确率 end + # if ex.question_type != Exercise::MULTIPLE + # ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 + # percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 + # else + # multiple_score = 0 + # user_ids.each do |user_id| + # ex_answer_score = ex_answers.select{|answer| answer.user_id == user_id}&.first&.score.to_f + # multiple_score += ex_answer_score + # end + # percent = (ex_total_score == 0.0 ? 0.0 : (multiple_score / ex_total_score.to_f).round(3) * 100) #正确率 + # end + question_answer_infos = [] if ex.question_type <= Exercise::JUDGMENT #选择题和判断题 ex_choices = ex.exercise_choices standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置 - # right_users_count = 0 - # 该问题的正确率 - # if ex.question_type == Exercise::MULTIPLE #多选题 - # right_user_ids = user_ids - # standard_answer.each do |choice_position| - # standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id - # right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) - # end - # # right_users_count = right_user_ids.size - # else #单选题和判断题 - # standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id - # # right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size - # end + right_users_count = 0 + #该问题的正确率 + if ex.question_type == Exercise::MULTIPLE #多选题 + right_user_ids = user_ids + standard_answer.each do |choice_position| + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id + right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) + end + right_users_count = right_user_ids.size + right_users_scores = right_users_count * ex&.question_score.to_f + else #单选题和判断题 + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id + right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size + right_users_scores = right_users_count * ex&.question_score.to_f + end + percent = (ex_total_score == 0.0 ? 0.0 : (right_users_scores / ex_total_score.to_f).round(3) * 100) #正确率 # percent = commit_user_ids > 0 ? (right_users_count / commit_user_ids.to_f).round(3)*100 : 0.0 @@ -174,6 +175,7 @@ module ExercisesHelper null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text null_stand_text = null_standard_answer.pluck(:answer_text) standard_answer_count = 0 + each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.size).round(3) : 0.0 all_user_count = 0 null_stand_choice.each_with_index do |s,index| user_count = 0 @@ -196,6 +198,9 @@ module ExercisesHelper all_user_count += user_count standard_answer_count += 1 end + answer_user_score = all_user_count * each_null_score + percent = (ex_total_score == 0.0 ? 0.0 : (answer_user_score / ex_total_score.to_f).round(3) * 100) #正确率 + # percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0 user_wrong_count = (effictive_users_count - all_user_count ) From b3f3b03c461aaf291c5098179b71f876c032e3ce Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 16 Oct 2019 16:24:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=BB=93=E6=9E=9C=EF=BC=8C=E5=A1=AB=E7=A9=BA=E9=A2=98?= =?UTF-8?q?=E7=9A=84=E6=AD=A3=E7=A1=AE=E7=8E=87=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 59a2d3d25..9a62e6b1d 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -143,15 +143,15 @@ module ExercisesHelper right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) end right_users_count = right_user_ids.size - right_users_scores = right_users_count * ex&.question_score.to_f + # right_users_scores = right_users_count * ex&.question_score.to_f else #单选题和判断题 standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size - right_users_scores = right_users_count * ex&.question_score.to_f + # right_users_scores = right_users_count * ex&.question_score.to_f end - percent = (ex_total_score == 0.0 ? 0.0 : (right_users_scores / ex_total_score.to_f).round(3) * 100) #正确率 + # percent = (ex_total_score == 0.0 ? 0.0 : (right_users_scores / ex_total_score.to_f).round(3) * 100) #正确率 - # percent = commit_user_ids > 0 ? (right_users_count / commit_user_ids.to_f).round(3)*100 : 0.0 + percent = commit_user_ids > 0 ? (right_users_count / commit_user_ids.to_f).round(3)*100 : 0.0 #每个选项的正确率 ex_choices.each do |c| @@ -175,7 +175,7 @@ module ExercisesHelper null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text null_stand_text = null_standard_answer.pluck(:answer_text) standard_answer_count = 0 - each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.size).round(3) : 0.0 + each_null_score = null_stand_choice.size > 0 ? (ex&.question_score.to_f / null_stand_choice.uniq.size).round(3) : 0.0 all_user_count = 0 null_stand_choice.each_with_index do |s,index| user_count = 0 From 24404ce12f2b4cd044e08ee3874eaa69bc1a7de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 16 Oct 2019 16:25:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?24867=20=E6=8F=8F=E8=BF=B0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=BB=98=E8=AE=A4=E6=8F=90=E7=A4=BA=E8=AF=AD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/shixunHomework/Homeworddescription.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/Homeworddescription.js b/public/react/src/modules/courses/shixunHomework/Homeworddescription.js index df1f33ba8..d7fc20693 100644 --- a/public/react/src/modules/courses/shixunHomework/Homeworddescription.js +++ b/public/react/src/modules/courses/shixunHomework/Homeworddescription.js @@ -65,6 +65,8 @@ class Homeworddescription extends Component { } //获取输入框 settextarea=(e)=>{ + console.log("settextarea"); + console.log(e); this.setState({ description:e }) @@ -89,8 +91,10 @@ class Homeworddescription extends Component { {/**/} - +