|
|
@ -47,7 +47,7 @@ class GamesController < ApplicationController
|
|
|
|
max_query_index = @game.query_index.to_i
|
|
|
|
max_query_index = @game.query_index.to_i
|
|
|
|
|
|
|
|
|
|
|
|
# 统计评测时间
|
|
|
|
# 统计评测时间
|
|
|
|
record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:consume_time)
|
|
|
|
record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:pod_execute)
|
|
|
|
|
|
|
|
|
|
|
|
# myshixun_manager判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者)
|
|
|
|
# myshixun_manager判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者)
|
|
|
|
myshixun_manager = @identity < User::EDU_GAME_MANAGER
|
|
|
|
myshixun_manager = @identity < User::EDU_GAME_MANAGER
|
|
|
@ -712,6 +712,7 @@ class GamesController < ApplicationController
|
|
|
|
uid_logger("################params[:resubmit]: #{params[:resubmit]}")
|
|
|
|
uid_logger("################params[:resubmit]: #{params[:resubmit]}")
|
|
|
|
uid_logger("################resubmit_identifier: #{resubmit_identifier}")
|
|
|
|
uid_logger("################resubmit_identifier: #{resubmit_identifier}")
|
|
|
|
uid_logger("################time_out: #{params[:time_out]}")
|
|
|
|
uid_logger("################time_out: #{params[:time_out]}")
|
|
|
|
|
|
|
|
sec_key = params[:sec_key]
|
|
|
|
if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? &&
|
|
|
|
if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? &&
|
|
|
|
(params[:resubmit] != resubmit_identifier)))
|
|
|
|
(params[:resubmit] != resubmit_identifier)))
|
|
|
|
# 代码评测的信息
|
|
|
|
# 代码评测的信息
|
|
|
@ -740,14 +741,14 @@ class GamesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else # 重新评测
|
|
|
|
else # 重新评测
|
|
|
|
# 如果满足前面的条件,进入此处只可能是结果已返回并存入了数据库
|
|
|
|
# 如果满足前面的条件,进入此处只可能是结果已返回并存入了数据库
|
|
|
|
if params[:resubmit] == resubmit_identifier # 本次重新评测结果已经返回并存入数据库
|
|
|
|
if params[:resubmit] == resubmit_identifier # 本次重新评测结果已经返回并存入数据库
|
|
|
|
game_status = (@game.retry_status == 2 ? 2 : 0) # retry_status是判断重新评测的通关情况。2表示通关
|
|
|
|
game_status = (@game.retry_status == 2 ? 2 : 0) # retry_status是判断重新评测的通关情况。2表示通关
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集
|
|
|
|
# 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集
|
|
|
|
max_query_index = @game.query_index
|
|
|
|
max_query_index = @game.query_index
|
|
|
|
#max_query_index = @game.outputs.first.try(:query_index)
|
|
|
|
# max_query_index = @game.outputs.first.try(:query_index)
|
|
|
|
# 区分评测过未评测过,未评测过按需求取数据
|
|
|
|
# 区分评测过未评测过,未评测过按需求取数据
|
|
|
|
testset_detail max_query_index.to_i, game_challenge
|
|
|
|
testset_detail max_query_index.to_i, game_challenge
|
|
|
|
|
|
|
|
|
|
|
@ -757,9 +758,10 @@ class GamesController < ApplicationController
|
|
|
|
web_route = game_challenge.try(:web_route)
|
|
|
|
web_route = game_challenge.try(:web_route)
|
|
|
|
mirror_name = @shixun.mirror_name
|
|
|
|
mirror_name = @shixun.mirror_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
e_record = EvaluateRecord.where(:identifier => sec_key).first
|
|
|
|
# 轮询结束,更新评测统计耗时
|
|
|
|
# 轮询结束,更新评测统计耗时
|
|
|
|
if game_status == 0 || game_status == 2
|
|
|
|
if game_status == 0 || game_status == 2
|
|
|
|
e_record = EvaluateRecord.where(:game_id => @game.id).first
|
|
|
|
|
|
|
|
if e_record
|
|
|
|
if e_record
|
|
|
|
front_js = format("%.3f", (Time.now.to_f - e_record.try(:updated_at).to_f)).to_f
|
|
|
|
front_js = format("%.3f", (Time.now.to_f - e_record.try(:updated_at).to_f)).to_f
|
|
|
|
consume_time = format("%.3f", (Time.now - e_record.created_at)).to_f
|
|
|
|
consume_time = format("%.3f", (Time.now - e_record.created_at)).to_f
|
|
|
@ -767,9 +769,10 @@ class GamesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
uid_logger("game is is #{@game.id}, record id is #{e_record.try(:id)}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
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")}")
|
|
|
|
# 记录前端总耗时
|
|
|
|
# 记录前端总耗时
|
|
|
|
record_consume_time = EvaluateRecord.where(:game_id => @game.id).first.try(:consume_time)
|
|
|
|
record_consume_time = e_record.try(:pod_execute)
|
|
|
|
|
|
|
|
max_mem = e_record.try(:max_mem)
|
|
|
|
# 实训制作者当前拥有的金币
|
|
|
|
# 实训制作者当前拥有的金币
|
|
|
|
grade = User.where(:id => @game.user_id).pluck(:grade).first
|
|
|
|
grade = User.where(:id => @game.user_id).pluck(:grade).first
|
|
|
|
|
|
|
|
|
|
|
@ -780,7 +783,7 @@ class GamesController < ApplicationController
|
|
|
|
@base_date = {grade: grade, gold: score, experience: experience, status: game_status, had_done: had_done,
|
|
|
|
@base_date = {grade: grade, gold: score, experience: experience, status: game_status, had_done: had_done,
|
|
|
|
position: game_challenge.position, port: port, record_consume_time: record_consume_time,
|
|
|
|
position: game_challenge.position, port: port, record_consume_time: record_consume_time,
|
|
|
|
mirror_name: mirror_name, picture: picture, web_route: web_route, star: @game.star,
|
|
|
|
mirror_name: mirror_name, picture: picture, web_route: web_route, star: @game.star,
|
|
|
|
next_game: next_game, prev_game: prev_game}
|
|
|
|
next_game: next_game, prev_game: prev_game, max_mem: max_mem}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 记录实训花费的时间
|
|
|
|
# 记录实训花费的时间
|
|
|
@ -852,7 +855,7 @@ class GamesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
if max_query_index > 0
|
|
|
|
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("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,
|
|
|
|
@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.query_index, t.is_public, t.input, t.output, o.compile_success FROM outputs o, games g, challenges c,
|
|
|
|
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}
|
|
|
|
test_sets t where g.id=#{@game.id} and c.id=#{challenge.id} and o.query_index=#{max_query_index}
|
|
|
|
and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and
|
|
|
|
and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and
|
|
|
@ -866,8 +869,9 @@ class GamesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@last_compile_output = @qurey_test_sets.first['out_put'].gsub(/\n/, '<br/>').gsub(/\t/, " \; \; \; \; \; \; \; \;") if @qurey_test_sets.first['out_put'].present?
|
|
|
|
@last_compile_output = @qurey_test_sets.first['out_put'].gsub(/\n/, '<br/>').gsub(/\t/, " \; \; \; \; \; \; \; \;") if @qurey_test_sets.first['out_put'].present?
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
# 没有评测过,第一次进来后的呈现方式
|
|
|
|
@qurey_test_sets = TestSet.find_by_sql("SELECT t.is_public, t.input, t.output, t.position
|
|
|
|
@qurey_test_sets = TestSet.find_by_sql("SELECT t.is_public, t.input, t.output, t.position
|
|
|
|
FROM test_sets t where t.challenge_id = #{challenge.id}")
|
|
|
|
FROM test_sets t where t.challenge_id = #{challenge.id}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|