diff --git a/app/jobs/course_add_student_create_works_job.rb b/app/jobs/course_add_student_create_works_job.rb index d8bd6363c..fec28f395 100644 --- a/app/jobs/course_add_student_create_works_job.rb +++ b/app/jobs/course_add_student_create_works_job.rb @@ -25,7 +25,7 @@ class CourseAddStudentCreateWorksJob < ApplicationJob student_ids.each do |user_id| same_attrs = {user_id: user_id} course.homework_commons.where(homework_type: %i[normal group practice]).each do |homework| - next if homework.student_works.where(user_id: user_id).any? + next if StudentWork.where(user_id: user_id, homework_common_id: homework.id).any? worker.add same_attrs.merge(homework_common_id: homework.id) end end @@ -36,7 +36,7 @@ class CourseAddStudentCreateWorksJob < ApplicationJob student_ids.each do |user_id| same_attrs = {user_id: user_id} course.exercises.each do |exercise| - next if exercise.exercise_users.where(user_id: user_id).any? + next if ExerciseUser.where(user_id: user_id, exercise_id: exercise.id).any? worker.add same_attrs.merge(exercise_id: exercise.id) end end @@ -47,7 +47,7 @@ class CourseAddStudentCreateWorksJob < ApplicationJob student_ids.each do |user_id| same_attrs = {user_id: user_id} course.polls.each do |poll| - next if poll.poll_users.where(user_id: user_id).any? + next if PollUser.where(user_id: user_id, poll_id: poll.id).any? worker.add same_attrs.merge(poll_id: poll.id) end end @@ -58,7 +58,7 @@ class CourseAddStudentCreateWorksJob < ApplicationJob student_ids.each do |user_id| same_attrs = {user_id: user_id, course_id: course.id} course.graduation_tasks.each do |task| - next if task.graduation_works.where(user_id: user_id).any? + next if GraduationWork.where(user_id: user_id, graduation_task_id: task.id).any? worker.add same_attrs.merge(graduation_task_id: task.id) end end