diff --git a/app/models/course.rb b/app/models/course.rb index f61ff1e2a..d36d5d2c5 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -308,12 +308,12 @@ class Course < ApplicationRecord teacher_power_courses = [] if course_groups.present? common_ids.each do |i| - student_count = students.where(course_group_id:i).count if i == 0 + student_count = students.where(course_group_id:i).count teacher_power_courses << {course_name:"未分班",course_id:0,student_count:student_count} else course_group_name = course_groups.find_by(id:i) - teacher_power_courses << {course_name:course_group_name&.name,course_id:i,student_count:student_count} + teacher_power_courses << {course_name:course_group_name&.name,course_id:i,student_count:course_group_name&.course_members_count} end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 193d9aa6c..70755e508 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -79,7 +79,8 @@ class HomeworkCommon < ApplicationRecord # 根据是否统一发布获取作业的作品列表 def all_works student_works = self.unified_setting ? self.student_works : - self.student_works.joins("join course_members on student_works.user_id=course_members.user_id").where(course_members: {course_group_id: self.published_settings.pluck(:course_group_id)}) + self.student_works.joins("join course_members on student_works.user_id=course_members.user_id"). + where(course_members: {course_group_id: self.published_settings.pluck(:course_group_id)}) end # 分班权限的老师可见的作品列表