From acdefcfe83c4ace15dc08b8ae40b8f0d170df831 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 17:30:06 +0800 Subject: [PATCH 1/2] xx --- app/helpers/exercises_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 33d61d203..058a09595 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -214,8 +214,9 @@ module ExercisesHelper # percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0 user_right_count = effictive_users.where("score > 0.0").pluck(:user_id).uniq + unanswer_user_count = effictive_users.where("score < 0.0 and answer_text is null").pluck(:user_id).uniq user_wrong_counts = effictive_users.where("score < 0.0 and answer_text is not null").pluck(:user_id).uniq - user_wrong_count = (user_wrong_counts - user_right_count).size + user_wrong_count = (user_wrong_counts - user_right_count - unanswer_user_count).size if effictive_users_count > 0 && user_wrong_count >= 0 wrong_percent = (user_wrong_count / effictive_users_count.to_f ).round(3) From b6dc800ec44366994f9f3860ffc0a9b645cab5b8 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 13 Nov 2019 17:43:14 +0800 Subject: [PATCH 2/2] xx --- app/helpers/exercises_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 058a09595..8afd9e3d3 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -214,8 +214,8 @@ module ExercisesHelper # percent = commit_user_ids > 0 ? (all_user_count / commit_user_ids.to_f).round(3)*100 : 0.0 user_right_count = effictive_users.where("score > 0.0").pluck(:user_id).uniq - unanswer_user_count = effictive_users.where("score < 0.0 and answer_text is null").pluck(:user_id).uniq - user_wrong_counts = effictive_users.where("score < 0.0 and answer_text is not null").pluck(:user_id).uniq + unanswer_user_count = effictive_users.where("score < 0.0 and answer_text != ''").pluck(:user_id).uniq + user_wrong_counts = effictive_users.where("score < 0.0 and answer_text is not null and answer_text != ''").pluck(:user_id).uniq user_wrong_count = (user_wrong_counts - user_right_count - unanswer_user_count).size if effictive_users_count > 0 && user_wrong_count >= 0