parent
ae5c1c05b1
commit
8d2a90a947
@ -1,7 +1,19 @@
|
|||||||
class CourseDeleteStudentDeleteWorksJob < ApplicationJob
|
class CourseDeleteStudentDeleteWorksJob < ApplicationJob
|
||||||
queue_as :course_member
|
queue_as :course_member
|
||||||
|
|
||||||
def perform(*args)
|
def perform(course_id, student_ids)
|
||||||
# Do something later
|
course = Course.find_by(id: course_id)
|
||||||
|
return if course.blank?
|
||||||
|
course = self.course
|
||||||
|
student_works = StudentWork.joins(:homework_common).where(user_id: student_ids, homework_commons: {course_id: course.id})
|
||||||
|
student_works.update_all(is_delete: 1)
|
||||||
|
|
||||||
|
exercise_users = ExerciseUser.joins(:exercise).where(user_id: student_ids, exercises: {course_id: course.id})
|
||||||
|
exercise_users.update_all(is_delete: 1)
|
||||||
|
|
||||||
|
poll_users = PollUser.joins(:poll).where(user_id: student_ids, polls: {course_id: course.id})
|
||||||
|
poll_users.update_all(is_delete: 1)
|
||||||
|
|
||||||
|
course.graduation_works.where(user_id: student_ids).update_all(is_delete: 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in new issue