diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index b4b89bb0f..b03f6cfa1 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -104,10 +104,17 @@ module CoursesHelper garble count end - alias studentCountOrigin studentCount + # 注意:此方法有问题,速度慢且结果不准 + # alias studentCountOrigin studentCount + #def studentCount course + # count = studentCountOrigin course + #garble count + # end + + # 学生人数计算 + # add by nwb def studentCount course - count = studentCountOrigin course - garble count + course.student.count end def eventToLanguageCourse event_type, course diff --git a/app/models/course.rb b/app/models/course.rb index 1c20edb72..75bac905c 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -21,7 +21,7 @@ class Course < ActiveRecord::Base has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :homework_for_courses, :dependent => :destroy - has_many :student, :through => :students_for_courses, :source => :user + has_many :student, :class_name => 'StudentsForCourse', :source => :user has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy has_many :enabled_modules, :dependent => :delete_all has_many :boards, :dependent => :destroy, :order => "position ASC"