diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 8cefa5071..5032cb469 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -501,9 +501,11 @@ class ExerciseQuestionsController < ApplicationController if ex_answers.present? #学生有回答时 取学生的答题得分,否则0分 answer_choice_array = [] ex_answers.each do |a| - answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + if a.try(:exercise_choice).try(:choice_position).present? + answer_choice_array.push(a&.exercise_choice&.choice_position) #学生答案的位置 + end end - user_answer_content = answer_choice_array.sort + user_answer_content = answer_choice_array.reject(&:blank?).sort standard_answer = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).sort if standard_answer.size == 1 # 老数据需要判断学生答题是否正确, 正确取原题得分,否则是0分 standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort