|
|
@ -2,6 +2,7 @@ class HomeworkCommon < ApplicationRecord
|
|
|
|
# homework_type 1:普通作业 2:编程作业(弃用) 3:分组作业 4:实训作业
|
|
|
|
# homework_type 1:普通作业 2:编程作业(弃用) 3:分组作业 4:实训作业
|
|
|
|
enum homework_type: { normal: 1, program: 2, group: 3, practice: 4 }, _suffix: true
|
|
|
|
enum homework_type: { normal: 1, program: 2, group: 3, practice: 4 }, _suffix: true
|
|
|
|
has_many :homework_group_settings, dependent: :destroy
|
|
|
|
has_many :homework_group_settings, dependent: :destroy
|
|
|
|
|
|
|
|
has_many :published_settings, -> { group_published }, class_name: "HomeworkGroupSetting"
|
|
|
|
has_many :student_works, -> { where("is_delete != 1") }
|
|
|
|
has_many :student_works, -> { where("is_delete != 1") }
|
|
|
|
has_one :homework_detail_manual, dependent: :destroy
|
|
|
|
has_one :homework_detail_manual, dependent: :destroy
|
|
|
|
|
|
|
|
|
|
|
@ -78,7 +79,7 @@ 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.where(user_id: self.course.students.where(
|
|
|
|
self.student_works.where(user_id: self.course.students.where(
|
|
|
|
course_group_id: self.homework_group_settings.group_published.pluck(:course_group_id)).
|
|
|
|
course_group_id: self.published_settings.pluck(:course_group_id)).
|
|
|
|
pluck(:user_id))
|
|
|
|
pluck(:user_id))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|