老版课堂调整

dev_aliyun
cxt 5 years ago
parent de7cfe5a6c
commit 31c4e7164e

@ -177,7 +177,7 @@ class Course < ActiveRecord::Base
end
def member_count
Member.find_by_sql("select count(id) as count from members where course_id=#{self.id}").first.try(:count).to_i
CourseMember.find_by_sql("select count(id) as count from course_members where course_id=#{self.id}").first.try(:count).to_i
end
def self.search(query)
@ -257,7 +257,7 @@ class Course < ActiveRecord::Base
# 选出教师数不为0的答辩组
def course_graduation_group
self.graduation_groups.select{|group| group.members.count > 0}
self.graduation_groups.select{|group| group.course_members.count > 0}
end
# 课程的短描述信息
@ -420,11 +420,12 @@ class Course < ActiveRecord::Base
# 删除课程所有成员
def delete_all_members
if self.members && self.members.count > 0
me, mr = Member.table_name, MemberRole.table_name
connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})")
Member.delete_all(['course_id = ?', id])
end
CourseMember.delete_all(['course_id = ?', id])
# if self.members && self.members.count > 0
# me, mr = Member.table_name, MemberRole.table_name
# connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})")
# Member.delete_all(['course_id = ?', id])
# end
end
# 创建课程模块

@ -2,6 +2,7 @@ class GraduationGroup < ActiveRecord::Base
belongs_to :course
belongs_to :user
has_many :members
has_many :course_members
has_one :graduation_task_group_assignation, dependent: :destroy
has_many :graduation_work_comment_assignations, dependent: :destroy
attr_accessible :name, :user_id, :course_id

Loading…
Cancel
Save