From b3b01ee9ecd17e1fd6fa69ad65c0a23c8e04af9b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 15 May 2019 10:27:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/exercise.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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