|
|
|
@ -392,59 +392,6 @@ class GamesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# # 文件更新;数据评测记录
|
|
|
|
|
# # 生成重新评测认证码
|
|
|
|
|
# # content_modified:0 表示文件没有更新;content_modified:1 表示文件有更新
|
|
|
|
|
# def file_update
|
|
|
|
|
# path = params[:path].strip unless params[:path].blank?
|
|
|
|
|
# myshixun = @game.myshixun
|
|
|
|
|
# rev = params[:rev] ? params[:rev] : "master"
|
|
|
|
|
# @content_modified = 0
|
|
|
|
|
# # 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)
|
|
|
|
|
# uid_logger("-- game is #{@game.id}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
|
# student_work_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f
|
|
|
|
|
# record.update_attributes!(:student_work => student_work_time)
|
|
|
|
|
# end
|
|
|
|
|
# # 远程版本库文件内容
|
|
|
|
|
# last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"]
|
|
|
|
|
# last_content = tran_base64_decode64(last_content)
|
|
|
|
|
#
|
|
|
|
|
# content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present?
|
|
|
|
|
# params[:content].gsub(/\t/, ' ')
|
|
|
|
|
# else
|
|
|
|
|
# params[:content]
|
|
|
|
|
# end
|
|
|
|
|
# if content != last_content
|
|
|
|
|
# @content_modified = 1
|
|
|
|
|
# code_file = @g.edit_file(myshixun.gpid, current_user.login, :content => content, :file_path => path,
|
|
|
|
|
# :branch_name => rev, :commit_message => params[:evaluate] == 0 ? "auto commit" : "task commit")
|
|
|
|
|
# uid_logger("-- file update #{code_file}")
|
|
|
|
|
# # REDO:更新失败的处理
|
|
|
|
|
# raise("文件更新失败") unless code_file
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# if record.present?
|
|
|
|
|
# consume_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f
|
|
|
|
|
# record.update_attributes!(:file_update => consume_time)
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# # status为2说明是重新评测
|
|
|
|
|
# if @game.status == 2
|
|
|
|
|
# code = CODES.sample(8).join
|
|
|
|
|
# @resubmit = "#{code}_#{@myshixun.id}"
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# if content != last_content && code_file.blank?
|
|
|
|
|
# raise("实训平台繁忙(繁忙等级:81),请稍后刷新并重试")
|
|
|
|
|
# end
|
|
|
|
|
# rescue Exception => e
|
|
|
|
|
# uid_logger("-- file update failed #{e.message}")
|
|
|
|
|
# raise Educoder::TipException.new("#{e.message}")
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
# 恢复初始代码
|
|
|
|
|
# 注意path为当前打开文件的path
|
|
|
|
|
def reset_original_code
|
|
|
|
|