试卷答题列表的分班数据

dev_course
cxt 5 years ago
parent 904f2ce49c
commit f96e8e70e3

@ -308,12 +308,12 @@ class Course < ApplicationRecord
teacher_power_courses = [] teacher_power_courses = []
if course_groups.present? if course_groups.present?
common_ids.each do |i| common_ids.each do |i|
student_count = students.where(course_group_id:i).count
if i == 0 if i == 0
student_count = students.where(course_group_id:i).count
teacher_power_courses << {course_name:"未分班",course_id:0,student_count:student_count} teacher_power_courses << {course_name:"未分班",course_id:0,student_count:student_count}
else else
course_group_name = course_groups.find_by(id:i) 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 end
end end

@ -79,7 +79,8 @@ class HomeworkCommon < ApplicationRecord
# 根据是否统一发布获取作业的作品列表 # 根据是否统一发布获取作业的作品列表
def all_works def all_works
student_works = self.unified_setting ? self.student_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 end
# 分班权限的老师可见的作品列表 # 分班权限的老师可见的作品列表

Loading…
Cancel
Save