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 ChallengeChoose < ActiveRecord::Base
|
|
|
|
|
# attr_accessible :title, :body
|
|
|
|
|
# category 1 单选, 2,多选
|
|
|
|
|
# standard_answer 正确答案 answer: 答题的思路, 取标准答案的时候如果该项不为空则优先选择该项
|
|
|
|
|
default_scope :order => 'position'
|
|
|
|
|
belongs_to :challenge
|
|
|
|
|
has_many :challenge_tags, :dependent => :destroy
|
|
|
|
|
has_many :challenge_questions, :dependent => :destroy
|
|
|
|
|
has_one :choose_outputs, :dependent => :destroy
|
|
|
|
|
#has_many :outputs, :dependent => :destroy
|
|
|
|
|
|
|
|
|
|
validates_presence_of :subject
|
|
|
|
|
|
|
|
|
|
# 判断当前用户是否答题
|
|
|
|
|
def current_choose_outputs
|
|
|
|
|
ChooseOutputs.where(:challenge_choose_id => self.id, :user_id => User.current.id).first
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|