|
|
@ -539,16 +539,21 @@ class ShixunsController < ApplicationController
|
|
|
|
# 其它创建关卡等操作
|
|
|
|
# 其它创建关卡等操作
|
|
|
|
challenges = @shixun.challenges
|
|
|
|
challenges = @shixun.challenges
|
|
|
|
# 之所以增加user_id是为了方便统计查询性能
|
|
|
|
# 之所以增加user_id是为了方便统计查询性能
|
|
|
|
|
|
|
|
game_attrs = %i[challenge_id myshixun_id status user_id open_time identifier modify_time created_at updated_at]
|
|
|
|
|
|
|
|
Game.bulk_insert(*game_attrs) do |worker|
|
|
|
|
|
|
|
|
base_attr = { myshixun_id: myshixun.id, user_id: myshixun.user_id }
|
|
|
|
challenges.each_with_index do |challenge, index|
|
|
|
|
challenges.each_with_index do |challenge, index|
|
|
|
|
status = (index == 0 ? 0 : 3)
|
|
|
|
status = (index == 0 ? 0 : 3)
|
|
|
|
game_identifier = generate_identifier(Game, 12)
|
|
|
|
game_identifier = generate_identifier(Game, 12)
|
|
|
|
Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id,
|
|
|
|
worker.add(base_attr.merge(challenge_id: challenge.id, status: status, open_time: Time.now,
|
|
|
|
:open_time => Time.now, :identifier => game_identifier, :modify_time => challenge.modify_time)
|
|
|
|
identifier: game_identifier, modify_time: challenge.modify_time))
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# REDO:开启实训时更新关联作品的状态
|
|
|
|
# REDO:开启实训时更新关联作品的状态
|
|
|
|
# TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做
|
|
|
|
# TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做
|
|
|
|
HomeworksService.new.update_myshixun_work_status myshixun
|
|
|
|
# HomeworksService.new.update_myshixun_work_status myshixun
|
|
|
|
|
|
|
|
UpdateMyshixunWorkStatusJob.perform_later(myshixun.id)
|
|
|
|
|
|
|
|
|
|
|
|
@current_task = myshixun.current_task
|
|
|
|
@current_task = myshixun.current_task
|
|
|
|
uid_logger("## shixun exec: myshixun id is #{myshixun.id}")
|
|
|
|
uid_logger("## shixun exec: myshixun id is #{myshixun.id}")
|
|
|
@ -559,9 +564,6 @@ class ShixunsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# gameID 及实训ID
|
|
|
|
# gameID 及实训ID
|
|
|
|
# status: 0 , 1 申请过, 2,实训关卡路径未填, 3 实训标签未填, 4 实训未创建关卡
|
|
|
|
# status: 0 , 1 申请过, 2,实训关卡路径未填, 3 实训标签未填, 4 实训未创建关卡
|
|
|
|