diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index a859a239e..323bad3cf 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -142,6 +142,9 @@ module ExercisesHelper right_users_count = 0 #该问题的正确率 if ex.question_type == Exercise::MULTIPLE #多选题 + if standard_answer.size == 1 #以前的多选题答案存在一个表里 + standard_answer = standard_answer.first.to_s.split("").map(&:to_i) + end 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 @@ -160,12 +163,7 @@ module ExercisesHelper #每个选项的正确率 ex_choices.each do |c| - Rails.logger.info("######________c__________#############{c}") - Rails.logger.info("######________standard_answer__________#############{standard_answer}") - right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置 - Rails.logger.info("######_______right_answer__________#############{right_answer}") - answer_users_count = effictive_users.select{|answer| answer.exercise_choice_id == c.id}.size answer_percent = (effictive_users_count == 0 ? 0.0 : (answer_users_count / effictive_users_count.to_f ).round(3))