|
|
|
@ -243,43 +243,40 @@ class MyshixunsController < ApplicationController
|
|
|
|
|
# -----Repository
|
|
|
|
|
# TODO: 之类需要一个resubmit参数,但是是关于games.
|
|
|
|
|
def update_file
|
|
|
|
|
begin
|
|
|
|
|
@hide_code = Shixun.where(id: @myshixun.shixun_id).pluck(:hide_code).first
|
|
|
|
|
tip_exception("技术平台为空!") if @myshixun.mirror_name.blank?
|
|
|
|
|
path = params[:path].strip unless params[:path].blank?
|
|
|
|
|
game_id = params[:game_id]
|
|
|
|
|
game = Game.find(game_id)
|
|
|
|
|
@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)
|
|
|
|
|
@sec_key = generate_identifier(EvaluateRecord, 12)
|
|
|
|
|
record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun_id, :game_id => game_id,
|
|
|
|
|
:identifier => @sec_key)
|
|
|
|
|
uid_logger("-- game build: file update #{@sec_key}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
|
end
|
|
|
|
|
unless @hide_code
|
|
|
|
|
# 远程版本库文件内容
|
|
|
|
|
last_content = GitService.file_content(repo_path: @repo_path, path: path)["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
|
|
|
|
|
content = params[:content]
|
|
|
|
|
|
|
|
|
|
if content != last_content
|
|
|
|
|
@content_modified = 1
|
|
|
|
|
|
|
|
|
|
author_name = current_user.full_name
|
|
|
|
|
author_email = current_user.mail
|
|
|
|
|
message = params[:evaluate] == 0 ? "auto commit" : "task commit"
|
|
|
|
|
message = params[:evaluate] == 0 ? "System automatically submitted" : "User submitted"
|
|
|
|
|
@content = GitService.update_file(repo_path: @repo_path,
|
|
|
|
|
file_path: path,
|
|
|
|
|
message: message,
|
|
|
|
|
content: content,
|
|
|
|
|
author_name: author_name,
|
|
|
|
|
author_email: author_email)
|
|
|
|
|
|
|
|
|
|
uid_logger("-- file update #{@content}")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -293,6 +290,10 @@ class MyshixunsController < ApplicationController
|
|
|
|
|
consume_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f
|
|
|
|
|
record.update_attributes!(:file_update => consume_time)
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception("文件内容更新异常,请稍后重试")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 渲染实训代码
|
|
|
|
|