|
|
|
@ -33,6 +33,8 @@ class Course < ActiveRecord::Base
|
|
|
|
|
has_many :student_works, :through => :homework_commons, :dependent => :destroy
|
|
|
|
|
|
|
|
|
|
has_many :course_groups, :dependent => :destroy
|
|
|
|
|
# 课程动态
|
|
|
|
|
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
|
|
|
|
|
|
|
|
|
acts_as_taggable
|
|
|
|
|
acts_as_nested_set :order => 'name', :dependent => :destroy
|
|
|
|
@ -44,7 +46,7 @@ class Course < ActiveRecord::Base
|
|
|
|
|
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
|
|
|
|
|
validates_length_of :description, :maximum => 10000
|
|
|
|
|
before_save :self_validate
|
|
|
|
|
after_create :create_board_sync
|
|
|
|
|
after_create :create_board_sync, :act_as_course_activity
|
|
|
|
|
before_destroy :delete_all_members
|
|
|
|
|
|
|
|
|
|
safe_attributes 'extra',
|
|
|
|
@ -310,6 +312,11 @@ class Course < ActiveRecord::Base
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#课程动态公共表记录
|
|
|
|
|
def act_as_course_activity
|
|
|
|
|
self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
|
|
|
|
#def name
|
|
|
|
|
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
|
|
|
|