优化统计结果页面

dev_forum
SylorHuang 5 years ago
parent 7bd8ed383b
commit 8a78d0d375

@ -115,10 +115,12 @@ module ExercisesHelper
right_users_count = 0 #该问题的回答正确的人数
#计算每个问题的答案人数
user_ids.each do |user_id|
answer_choice_array = effictive_users.where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
if answer_choice_array.sort == standard_answer
right_users_count += 1
effictive_users.transaction do
user_ids.each do |user_id|
answer_choice_array = effictive_users.where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
if answer_choice_array.sort == standard_answer
right_users_count += 1
end
end
end
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0

Loading…
Cancel
Save