|
|
|
@ -78,20 +78,20 @@ class HomeworkCommon < ApplicationRecord
|
|
|
|
|
# 根据是否统一发布获取作业的作品列表
|
|
|
|
|
def all_works
|
|
|
|
|
student_works = self.unified_setting ? self.student_works :
|
|
|
|
|
self.student_works.where(user_id: self.course.students.where(
|
|
|
|
|
course_group_id: self.published_settings.pluck(:course_group_id)).
|
|
|
|
|
pluck(:user_id))
|
|
|
|
|
self.student_works.joins("join course_members cm on student_works.user_id=cm.user_id").
|
|
|
|
|
where(course_members: {course_group_id: self.published_settings.pluck(:course_group_id)})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 分班权限的老师可见的作品列表
|
|
|
|
|
def teacher_works user_id
|
|
|
|
|
member = course.course_member(user_id)
|
|
|
|
|
def teacher_works member
|
|
|
|
|
# member = course.course_member(user_id)
|
|
|
|
|
teacher_course_groups = member.try(:teacher_course_groups)
|
|
|
|
|
all_student_works = self.all_works
|
|
|
|
|
# 有分班权限的统计管理的分班且已发布的学生情况
|
|
|
|
|
if member.present? && teacher_course_groups.size > 0
|
|
|
|
|
group_ids = teacher_course_groups.pluck(:course_group_id)
|
|
|
|
|
all_student_works = all_student_works.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id))
|
|
|
|
|
all_student_works = all_student_works.joins("join course_members cm on student_works.user_id=cm.user_id").
|
|
|
|
|
where(course_members: {course_group_id: group_ids})
|
|
|
|
|
end
|
|
|
|
|
all_student_works
|
|
|
|
|
end
|
|
|
|
@ -216,17 +216,17 @@ class HomeworkCommon < ApplicationRecord
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 作品未提交数
|
|
|
|
|
def unfinished_count user_id
|
|
|
|
|
self.teacher_works(user_id).unfinished.count
|
|
|
|
|
def unfinished_count member
|
|
|
|
|
self.teacher_works(member).unfinished.count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 任务按时提交数
|
|
|
|
|
def finished_count user_id
|
|
|
|
|
self.teacher_works(user_id).finished.count
|
|
|
|
|
def finished_count member
|
|
|
|
|
self.teacher_works(member).finished.count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def delay_finished_count user_id
|
|
|
|
|
self.teacher_works(user_id).delay_finished.count
|
|
|
|
|
def delay_finished_count member
|
|
|
|
|
self.teacher_works(member).delay_finished.count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 分组作业的最大分组id
|
|
|
|
|