diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index d99c59c85..e20a8bd28 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -816,7 +816,7 @@ class ExercisesController < ApplicationController ex_user_ids = exercise_users.pluck(:id) - EndExerciseCalculateJob.perform_later(ex_user_ids, exercise, Time.now.to_s, true, 4) + EndExerciseCalculateJob.perform_later(ex_user_ids, exercise.id, Time.now.to_s, true, 4) # exercise_users.each do |user| # if user.commit_status == 0 && user.start_at.present? # objective_score = calculate_student_score(exercise,user.user)[:total_score] @@ -1194,7 +1194,7 @@ class ExercisesController < ApplicationController start_time = Time.current - @exercise.time * 60 ex_user_ids = @exercise_users_list.where("start_at <= '#{Time.at(start_time)}' and commit_status = 0").pluck(:id) if ex_user_ids.size > 0 - EndExerciseCalculateJob.perform_later(ex_user_ids, @exercise, Time.now.to_s, false, 2) + EndExerciseCalculateJob.perform_later(ex_user_ids, @exercise.id, Time.now.to_s, false, 2) end end diff --git a/app/jobs/end_exercise_calculate_job.rb b/app/jobs/end_exercise_calculate_job.rb index 28f1f6901..3354be2d5 100644 --- a/app/jobs/end_exercise_calculate_job.rb +++ b/app/jobs/end_exercise_calculate_job.rb @@ -5,7 +5,9 @@ class EndExerciseCalculateJob < ApplicationJob queue_as :default - def perform(ex_user_ids,exercise,end_time,work_time,commit_method) + def perform(ex_user_ids,exercise_id,end_time,work_time,commit_method) + exercise = Exercise.find_by(id: exercise_id) + return if exercise.blank? exercise_users = ExerciseUser.where(id: ex_user_ids) exercise_users.each do |user| if user.commit_status == 0 && user.start_at.present?