diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 5b81b1b3..c2c17dd9 100755 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -43,11 +43,11 @@ class Exercise < ActiveRecord::Base end def user_question_list exercise_user_id - if self.exercise_user_questions.where(exercise_user_id: exercise_user_id).count == 0 + if self.exercise_user_questions.where(exercise_user_id: exercise_user_id).size == 0 self.exercise_questions else self.exercise_questions.where(id: self.exercise_user_questions.where(exercise_user_id: exercise_user_id). - pluck(:exercise_question_id)) + limit(self.questions_count).pluck(:exercise_question_id)) end end @@ -55,6 +55,10 @@ class Exercise < ActiveRecord::Base self.exercise_level_settings.where(level: level).first end + def questions_count + self.exercise_questions.where("question_type != 5").size + self.shixun_question_count + end + def shixun_question_count self.exercise_level_settings.sum(:num) end