diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 6f30ba6c3..ace9e062e 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -118,7 +118,7 @@ module ExercisesHelper if ex.question_type == Exercise::MULTIPLE #多选题 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 + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) end right_users_count = right_user_ids.size @@ -130,7 +130,7 @@ module ExercisesHelper # end # end else #单选题和判断题 - standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first.id + standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size end