|
|
@ -43,11 +43,11 @@ class Exercise < ActiveRecord::Base
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def user_question_list exercise_user_id
|
|
|
|
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
|
|
|
|
self.exercise_questions
|
|
|
|
else
|
|
|
|
else
|
|
|
|
self.exercise_questions.where(id: self.exercise_user_questions.where(exercise_user_id: exercise_user_id).
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -55,6 +55,10 @@ class Exercise < ActiveRecord::Base
|
|
|
|
self.exercise_level_settings.where(level: level).first
|
|
|
|
self.exercise_level_settings.where(level: level).first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def questions_count
|
|
|
|
|
|
|
|
self.exercise_questions.where("question_type != 5").size + self.shixun_question_count
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def shixun_question_count
|
|
|
|
def shixun_question_count
|
|
|
|
self.exercise_level_settings.sum(:num)
|
|
|
|
self.exercise_level_settings.sum(:num)
|
|
|
|
end
|
|
|
|
end
|
|
|
|