|
|
|
@ -676,13 +676,13 @@ class ShixunsController < ApplicationController
|
|
|
|
|
myshixun_params = {user_id: current_user.id, identifier: myshixun_identifier,
|
|
|
|
|
modify_time: @shixun.modify_time, reset_time: @shixun.reset_time,
|
|
|
|
|
onclick_time: Time.now, commit_id: commit_id}
|
|
|
|
|
myshixun = @shixun.myshixuns.create!(myshixun_params)
|
|
|
|
|
@myshixun = @shixun.myshixuns.create!(myshixun_params)
|
|
|
|
|
# 其它创建关卡等操作
|
|
|
|
|
challenges = @shixun.challenges
|
|
|
|
|
# 之所以增加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}
|
|
|
|
|
base_attr = {myshixun_id: @myshixun.id, user_id: @myshixun.user_id}
|
|
|
|
|
challenges.each_with_index do |challenge, index|
|
|
|
|
|
status = (index == 0 ? 0 : 3)
|
|
|
|
|
game_identifier = generate_identifier(Game, 12)
|
|
|
|
@ -690,7 +690,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
identifier: game_identifier, modify_time: challenge.modify_time))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@current_task = myshixun.current_task(myshixun.games)
|
|
|
|
|
@current_task = @myshixun.current_task(@myshixun.games)
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error("------ActiveRecord::RecordInvalid: #{e.message}")
|
|
|
|
|
raise("ActiveRecord::RecordInvalid")
|
|
|
|
@ -701,12 +701,12 @@ class ShixunsController < ApplicationController
|
|
|
|
|
unless is_choice_type
|
|
|
|
|
# fork仓库
|
|
|
|
|
cloud_bridge = edu_setting('cloud_bridge')
|
|
|
|
|
project_fork(myshixun, @repo_path, current_user.login)
|
|
|
|
|
project_fork(@myshixun, @repo_path, current_user.login)
|
|
|
|
|
rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path)
|
|
|
|
|
uid_logger("start openGameInstance")
|
|
|
|
|
uri = "#{cloud_bridge}/bridge/game/openGameInstance"
|
|
|
|
|
logger.info("end openGameInstance")
|
|
|
|
|
params = {tpiID: "#{myshixun.id}", tpmGitURL: rep_url, tpiRepoName: myshixun.repo_name.split("/").last}
|
|
|
|
|
params = {tpiID: "#{@myshixun.id}", tpmGitURL: rep_url, tpiRepoName: @myshixun.repo_name.split("/").last}
|
|
|
|
|
uid_logger("openGameInstance params is #{params}")
|
|
|
|
|
interface_post uri, params, 83, "实训云平台繁忙(繁忙等级:83)"
|
|
|
|
|
end
|
|
|
|
|