|
|
|
@ -11,7 +11,7 @@ class GamesController < ApplicationController
|
|
|
|
|
include ApplicationHelper
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
uid_logger("--games show start")
|
|
|
|
|
uid_logger_dubug("--games show start")
|
|
|
|
|
# 防止评测中途ajaxE被取消;3改成0是为了处理首次进入下一关的问题
|
|
|
|
|
update_game_parameter(@game)
|
|
|
|
|
|
|
|
|
@ -439,7 +439,7 @@ class GamesController < ApplicationController
|
|
|
|
|
path = params[:path] || path
|
|
|
|
|
status = params[:status].to_i
|
|
|
|
|
path = path.try(:strip)
|
|
|
|
|
uid_logger("--rep_content: path is #{path}")
|
|
|
|
|
uid_logger_dubug("--rep_content: path is #{path}")
|
|
|
|
|
begin
|
|
|
|
|
@content = git_fle_content(@myshixun.repo_path, path) || ""
|
|
|
|
|
rescue Exception => e
|
|
|
|
@ -455,7 +455,7 @@ class GamesController < ApplicationController
|
|
|
|
|
# 监测版本库HEAD是否存在,不存在则取最新的HEAD
|
|
|
|
|
uri = "#{shixun_tomcat}/bridge/game/check"
|
|
|
|
|
res = uri_post uri, rep_params
|
|
|
|
|
uid_logger("repo_content to bridge: res is #{res}")
|
|
|
|
|
uid_logger_dubug("repo_content to bridge: res is #{res}")
|
|
|
|
|
# res值:0 表示正常;-1表示有错误;-2表示代码版本库没了
|
|
|
|
|
#
|
|
|
|
|
if status == 0 && res
|
|
|
|
@ -507,11 +507,10 @@ class GamesController < ApplicationController
|
|
|
|
|
else
|
|
|
|
|
{updated_at: Time.now}
|
|
|
|
|
end
|
|
|
|
|
logger.info("#############myshixuns_update: ##{myshixuns_update}")
|
|
|
|
|
@myshixun.update_attributes!(myshixuns_update)
|
|
|
|
|
gitUrl = repo_ip_url @myshixun.repo_path
|
|
|
|
|
|
|
|
|
|
logger.info("#############giturl: ##{gitUrl}")
|
|
|
|
|
uid_logger_dubug("#############giturl: ##{gitUrl}")
|
|
|
|
|
gitUrl = Base64.urlsafe_encode64(gitUrl)
|
|
|
|
|
|
|
|
|
|
shixun_tomcat = edu_setting('cloud_bridge')
|
|
|
|
@ -537,7 +536,7 @@ class GamesController < ApplicationController
|
|
|
|
|
testSet << test_cases
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
logger.info("##############testSet: #{testSet}")
|
|
|
|
|
uid_logger_dubug("##############testSet: #{testSet}")
|
|
|
|
|
|
|
|
|
|
testCases = Base64.urlsafe_encode64(testSet.to_json) unless testSet.blank?
|
|
|
|
|
# 评测类型: 0,1,2 用于webssh的评测, 3用于vnc
|
|
|
|
@ -560,11 +559,11 @@ class GamesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 私密仓库的设置
|
|
|
|
|
secret_rep = @shixun.shixun_secret_repository
|
|
|
|
|
logger.info("############secret_rep: #{secret_rep}")
|
|
|
|
|
uid_logger_dubug("############secret_rep: #{secret_rep}")
|
|
|
|
|
if secret_rep&.repo_name
|
|
|
|
|
secretGitUrl = repo_ip_url secret_rep.repo_path
|
|
|
|
|
br_params.merge!({secretGitUrl: Base64.urlsafe_encode64(secretGitUrl), secretDir: secret_rep.secret_dir_path})
|
|
|
|
|
logger.info("#######br_params:#{br_params}")
|
|
|
|
|
uid_logger_dubug("#######br_params:#{br_params}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 中间层交互
|
|
|
|
@ -580,7 +579,6 @@ class GamesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 选择题评测
|
|
|
|
|
def choose_build
|
|
|
|
|
Rails.logger.error("#################{params}")
|
|
|
|
|
# 选择题如果通关了,则不让再评测
|
|
|
|
|
if @game.status == 2
|
|
|
|
|
raise Educoder::TipException.new("您已通过该关卡")
|
|
|
|
@ -623,7 +621,7 @@ class GamesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 批量插入评测结果
|
|
|
|
|
uid_logger("#------------chooice score: #{score}")
|
|
|
|
|
uid_logger_dubug("#------------chooice score: #{score}")
|
|
|
|
|
sql = "INSERT INTO outputs (game_id, test_set_position, actual_output, result, query_index, created_at, updated_at) VALUES" + str
|
|
|
|
|
ActiveRecord::Base.connection.execute sql
|
|
|
|
|
|
|
|
|
@ -683,10 +681,10 @@ class GamesController < ApplicationController
|
|
|
|
|
resubmit_identifier = @game.resubmit_identifier
|
|
|
|
|
# 如果没有超时并且正在评测中
|
|
|
|
|
# 判断评测中的状态有两种:1、如果之前没有通关的,只需判断status为1即可;如果通过关,则判断game的resubmit_identifier是否更新
|
|
|
|
|
uid_logger("################game_status: #{@game.status}")
|
|
|
|
|
uid_logger("################params[:resubmit]: #{params[:resubmit]}")
|
|
|
|
|
uid_logger("################resubmit_identifier: #{resubmit_identifier}")
|
|
|
|
|
uid_logger("################time_out: #{params[:time_out]}")
|
|
|
|
|
uid_logger_dubug("################game_status: #{@game.status}")
|
|
|
|
|
uid_logger_dubug("################params[:resubmit]: #{params[:resubmit]}")
|
|
|
|
|
uid_logger_dubug("################resubmit_identifier: #{resubmit_identifier}")
|
|
|
|
|
uid_logger_dubug("################time_out: #{params[:time_out]}")
|
|
|
|
|
sec_key = params[:sec_key]
|
|
|
|
|
if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? &&
|
|
|
|
|
(params[:resubmit] != resubmit_identifier)))
|
|
|
|
@ -696,7 +694,7 @@ class GamesController < ApplicationController
|
|
|
|
|
render :json => { running_code_status: running_code_status, running_code_message: running_code_message }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
uid_logger("##### resubmit_identifier is #{resubmit_identifier}")
|
|
|
|
|
uid_logger_dubug("##### resubmit_identifier is #{resubmit_identifier}")
|
|
|
|
|
port = params[:port]
|
|
|
|
|
score = 0
|
|
|
|
|
experience = 0
|
|
|
|
@ -745,7 +743,7 @@ class GamesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
uid_logger("game is #{@game.id}, record id is #{e_record.try(:id)}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
|
uid_logger_dubug("game is #{@game.id}, record id is #{e_record.try(:id)}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
|
# 记录前端总耗时
|
|
|
|
|
record_consume_time = e_record.try(:pod_execute)
|
|
|
|
|
max_mem = e_record.try(:max_mem)
|
|
|
|
@ -791,7 +789,7 @@ class GamesController < ApplicationController
|
|
|
|
|
begin
|
|
|
|
|
shixun_tomcat = edu_setting('cloud_bridge')
|
|
|
|
|
uri = "#{shixun_tomcat}/bridge/webssh/delete"
|
|
|
|
|
Rails.logger.info("#{current_user} => cloese_webssh digest is #{digest}")
|
|
|
|
|
uid_logger_dubug("#{current_user} => cloese_webssh digest is #{digest}")
|
|
|
|
|
params = {:tpiID => myshixun_id, :digestKey => digest_key, :identifier => @game.identifier}
|
|
|
|
|
res = uri_post uri, params
|
|
|
|
|
if res && res['code'].to_i != 0
|
|
|
|
@ -830,7 +828,7 @@ class GamesController < ApplicationController
|
|
|
|
|
@allowed_hidden_testset = @identity < User::EDU_GAME_MANAGER || @game.test_sets_view #解锁的用户
|
|
|
|
|
|
|
|
|
|
if max_query_index > 0
|
|
|
|
|
uid_logger("max_query_index is #{max_query_index} game id is #{@game.id}, challenge_id is #{challenge.id}")
|
|
|
|
|
uid_logger_dubug("max_query_index is #{max_query_index} game id is #{@game.id}, challenge_id is #{challenge.id}")
|
|
|
|
|
@qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output, o.out_put, o.result, o.test_set_position, o.ts_time, o.ts_mem,
|
|
|
|
|
o.query_index, t.is_public, t.input, t.output, o.compile_success FROM outputs o, games g, challenges c,
|
|
|
|
|
test_sets t where g.id=#{@game.id} and c.id=#{challenge.id} and o.query_index=#{max_query_index}
|
|
|
|
|