|
|
|
@ -255,7 +255,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
challenge_settings = @homework.homework_challenge_settings
|
|
|
|
|
myshixuns.find_each(batch_size: 100) do |myshixun|
|
|
|
|
|
work = student_works.select{|work| work.user_id == myshixun.user_id}.first
|
|
|
|
|
if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.games.pluck(:updated_at).max)
|
|
|
|
|
if work && myshixun
|
|
|
|
|
games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id))
|
|
|
|
|
HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings
|
|
|
|
|
end
|
|
|
|
@ -276,13 +276,13 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
myshixun = Myshixun.find_by(shixun_id: params[:shixun_id], user_id: current_user.id)
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.games.pluck(:updated_at).max)
|
|
|
|
|
if work && myshixun
|
|
|
|
|
challenge_settings = @homework.homework_challenge_settings
|
|
|
|
|
games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id))
|
|
|
|
|
HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings
|
|
|
|
|
normal_status("更新成功")
|
|
|
|
|
else
|
|
|
|
|
normal_status("已是最新成绩")
|
|
|
|
|
normal_status("还开启挑战,暂不能更新成绩")
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|