From 28c2dab8bf3a1da906a160bb8d917e72a3a6316f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 12 Sep 2019 15:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=B0=83=E5=88=86=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_questions_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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