Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
cxt 5 years ago
commit e30854131c

@ -115,12 +115,14 @@ module ExercisesHelper
right_users_count = 0 #该问题的回答正确的人数 right_users_count = 0 #该问题的回答正确的人数
#计算每个问题的答案人数 #计算每个问题的答案人数
effictive_users.transaction do
user_ids.each do |user_id| user_ids.each do |user_id|
answer_choice_array = effictive_users.where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq 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 if answer_choice_array.sort == standard_answer
right_users_count += 1 right_users_count += 1
end end
end end
end
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0 percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
ex.exercise_choices.each do |c| ex.exercise_choices.each do |c|
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置 right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置

Loading…
Cancel
Save