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.
educoder/app/models/exercise_shixun_answer.rb

19 lines
742 B

6 years ago
class ExerciseShixunAnswer < ApplicationRecord
belongs_to :exercise_question
belongs_to :user
belongs_to :exercise_shixun_challenge
has_many :exercise_answer_comments
6 years ago
# status 0: 未通过, 1通过
# attr_accessible :answer_text, :score, :status
scope :search_shixun_answers, lambda {|name,ids| where("#{name}":ids)}
scope :search_shixun_keys, lambda { |name,key| where("#{name} = ?",key)}
scope :shixun_no_full_scores, lambda { |score| where("score > 0.0 AND score < ?",score)}
scope :score_reviewed, lambda {where("score is not NULL AND score >= ?",0.0)} #是否评分
after_destroy :destroy_shixun_relations
def destroy_shixun_relations
exercise_answer_comments.destroy_all
end
6 years ago
end