From 1bdffb56cdf8947eb78ce4db9ddb42a0cd3e27d2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 15 Jul 2019 18:43:12 +0800 Subject: [PATCH] fixbug --- app/helpers/exercises_helper.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index c9c213c47..a416dfcbe 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -113,9 +113,15 @@ module ExercisesHelper if ex.question_type <= Exercise::JUDGMENT #选择题和判断题 standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置 right_users_count = 0 #该问题的回答正确的人数 + + #计算每个问题的答案人数 user_ids.each do |user_id| - user_an_choice = effictive_users.where(user_id:user_id).pluck(:exercise_choice_id).sort - if user_an_choice == standard_answer + user_an_choice = ex_answers.where(user_id:user_id) + answer_choice_array = [] + user_an_choice.each do |a| + answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + end + if answer_choice_array == standard_answer right_users_count += 1 end end