|
|
|
@ -347,10 +347,12 @@ class GamesService
|
|
|
|
|
rev = params[:rev] ? params[:rev] : "master"
|
|
|
|
|
content_modified = 0
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
sec_key = generates_identifier(EvaluateRecord, 10)
|
|
|
|
|
# params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过
|
|
|
|
|
# 自动保存的时候evaluate为0;点评测的时候为1
|
|
|
|
|
if params[:evaluate] == 1
|
|
|
|
|
record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun.id, :game_id => @game.id)
|
|
|
|
|
record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun.id,
|
|
|
|
|
:game_id => @game.id, :identifier => sec_key)
|
|
|
|
|
Rails.logger.warn("##game is is #{@game.id}, record id is #{record.id}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
|
# @myshixun.student_works.update_all(:update_time => Time.now) if !@myshixun.student_works.blank?
|
|
|
|
|
student_work_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f
|
|
|
|
@ -385,7 +387,7 @@ class GamesService
|
|
|
|
|
if content != last_content && code_file.blank?
|
|
|
|
|
raise("update file failed")
|
|
|
|
|
else
|
|
|
|
|
return {:success => "success", :resubmit => resubmit ,:content_modified => content_modified}
|
|
|
|
|
return {:success => "success", :resubmit => resubmit ,:content_modified => content_modified, sec_key: record.identifier}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
@ -546,7 +548,7 @@ class GamesService
|
|
|
|
|
:testCases => "#{testCases}", :resubmit => "#{resubmit}", :times => params[:first].to_i, :podType => shixun.webssh,
|
|
|
|
|
:containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}", :tpmScript => "#{tpmScript}",
|
|
|
|
|
:timeLimit => "#{shixun.exec_time}", :content_modified => content_modified, :persistenceName => shixun.identifier,
|
|
|
|
|
:isPublished => (shixun.status < 2 ? 0 : 1)}
|
|
|
|
|
:isPublished => (shixun.status < 2 ? 0 : 1), :sec_key => params[:sec_key]}
|
|
|
|
|
|
|
|
|
|
# 评测有文件输出的需要特殊传字段 path:表示文件存储的位置
|
|
|
|
|
params['file'] = Base64.urlsafe_encode64({:path => "#{game_challenge.picture_path}"}.to_json) if game_challenge.picture_path.present?
|
|
|
|
@ -569,7 +571,8 @@ class GamesService
|
|
|
|
|
# ----单测模式end
|
|
|
|
|
|
|
|
|
|
return {:result => "success", :resubmit => resubmit, :ableToCreate => res['ableToCreate'], :waitNum => res['waitNum'],
|
|
|
|
|
:waitingTime => res['waitingTime'], :position => game_challenge.position, :port => res['port'], :had_done => game.had_done }
|
|
|
|
|
:waitingTime => res['waitingTime'], :position => game_challenge.position, :port => res['port'],
|
|
|
|
|
:had_done => game.had_done}
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
Rails.logger.error("评测出错,详情:" + e.message)
|
|
|
|
|
return {:result => 'fail', :contents =>"实训云平台繁忙(繁忙等级:502),请稍后刷新并重试", :position => game_challenge.position, :had_done => game.had_done}
|
|
|
|
@ -878,7 +881,7 @@ class GamesService
|
|
|
|
|
mirror_name = shixun.mirror_name
|
|
|
|
|
|
|
|
|
|
# 轮询结束,更新评测耗时
|
|
|
|
|
e_record = EvaluateRecord.where(:game_id => game.id).first
|
|
|
|
|
e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first
|
|
|
|
|
if game_status == 0 || game_status == 2
|
|
|
|
|
if e_record
|
|
|
|
|
front_js = format("%.3f", (Time.now.to_f - e_record.try(:updated_at).to_f)).to_f
|
|
|
|
|