From f96e8e70e3315f9f9e03573ae4d3e2290c356e31 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 8 Jul 2019 16:24:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=AD=94=E9=A2=98=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E5=88=86=E7=8F=AD=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 4 ++-- app/models/homework_common.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) 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 # 分班权限的老师可见的作品列表