2015-05-19 09:49:26 +08:00
|
|
|
#老师布置的作业表
|
2015-05-20 16:49:19 +08:00
|
|
|
#homework_type: 0:普通作业;1:匿评作业;2:编程作业
|
2015-05-19 09:49:26 +08:00
|
|
|
class HomeworkCommon < ActiveRecord::Base
|
2015-05-20 15:05:35 +08:00
|
|
|
# attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id
|
|
|
|
include Redmine::SafeAttributes
|
2015-06-02 11:59:59 +08:00
|
|
|
include ApplicationHelper
|
2015-05-19 09:49:26 +08:00
|
|
|
|
|
|
|
belongs_to :course
|
|
|
|
belongs_to :user
|
2015-05-19 10:20:07 +08:00
|
|
|
has_one :homework_detail_manual, :dependent => :destroy
|
|
|
|
has_one :homework_detail_programing, :dependent => :destroy
|
|
|
|
has_many :homework_tests, :dependent => :destroy
|
2015-05-19 10:36:30 +08:00
|
|
|
has_many :student_works, :dependent => :destroy
|
2015-05-19 11:18:19 +08:00
|
|
|
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
|
2015-06-02 11:58:21 +08:00
|
|
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
|
2015-05-19 17:12:43 +08:00
|
|
|
acts_as_attachable
|
2015-06-02 14:35:17 +08:00
|
|
|
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
|
|
|
|
:description => :description,
|
|
|
|
:author => :author,
|
|
|
|
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
|
2015-06-02 11:58:21 +08:00
|
|
|
after_create :act_as_activity
|
|
|
|
after_destroy :delete_kindeditor_assets
|
|
|
|
|
|
|
|
def act_as_activity
|
|
|
|
self.acts << Activity.new(:user_id => self.user_id)
|
|
|
|
end
|
|
|
|
#删除对应的图片
|
|
|
|
def delete_kindeditor_assets
|
|
|
|
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON
|
|
|
|
end
|
2015-05-19 09:49:26 +08:00
|
|
|
end
|