dev_local
cxt 6 years ago
parent 5081ccc882
commit b3b01ee9ec

@ -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

Loading…
Cancel
Save