educoder/app/models/shixun.rb

31 lines
1.3 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# status 控制实训的状态0未开启1: 已开启TPM; 2已认证
# 繁忙等级参数80发布实训失败返回code为-181实训开启的时候fork失败;83j 84jenkins系统异常post数据不成功
# 85challenge创建的时候Jenkins处理异常;86实训评测失败jenkins返回错误结果; 87版本库删除异常88点击评测失败没返回数据89重置链接jenkins返回失败
# 116challenge创建关卡的时候返回结果错误
class Shixun < ActiveRecord::Base
attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication, :myshixun_count, :propaedeutics
has_many :users, :through => :shixun_members
has_many :shixun_members, :dependent => :destroy
has_one :repository
has_many :homework_commons_shixunses
has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC"
has_many :myshixuns
has_and_belongs_to_many :homework_commons
# id 转换成 identifier
def to_param
identifier
end
def owner
User.find(self.user_id)
rescue ActiveRecord::RecordNotFound
render_404
end
def collaborators
self.shixun_members.select{|member| member.role == 2} unless self.shixun_members.blank?
end
end