You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
class ExerciseAnswer < ApplicationRecord
|
|
|
|
|
#学生答题
|
|
|
|
|
belongs_to :user
|
|
|
|
|
belongs_to :exercise_question
|
|
|
|
|
belongs_to :exercise_choice, optional: true
|
|
|
|
|
has_many :exercise_answer_comments
|
|
|
|
|
|
|
|
|
|
scope :search_exercise_answer, lambda { |name,key| where("#{name} = ?",key)}
|
|
|
|
|
scope :search_answer_users, lambda {|name,ids| where("#{name}":ids)}
|
|
|
|
|
scope :exercise_no_full_scores, lambda { |score| where("score > 0.0 AND score < ?",score)}
|
|
|
|
|
scope :exercise_answer_is_right, -> {where("score > ?",0.0)} #判断答案是否正确,根据分数总和大于0
|
|
|
|
|
scope :score_reviewed, lambda {where("score >= ?",0.0)} #是否评分,用于判断主观题的
|
|
|
|
|
|
|
|
|
|
after_destroy :destroy_answers_relations
|
|
|
|
|
|
|
|
|
|
def destroy_answers_relations
|
|
|
|
|
exercise_answer_comments.destroy_all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|