dev_hss
daiao 5 years ago
parent df66bde600
commit a1f263c31d

@ -74,6 +74,7 @@ class GamesController < ApplicationController
#@vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless" #@vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless"
# 有域名版本 # 有域名版本
@vnc_url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless" @vnc_url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless"
@vnc_evaluate = @shixun.vnc_evaluate
rescue Exception => e rescue Exception => e
Rails.logger.error(e.message) Rails.logger.error(e.message)
end end
@ -535,13 +536,14 @@ class GamesController < ApplicationController
end end
testCases = Base64.urlsafe_encode64(testSet.to_json) unless testSet.blank? testCases = Base64.urlsafe_encode64(testSet.to_json) unless testSet.blank?
# 评测类型: 012 用于webssh的评测 3用于vnc
podType = @shixun.vnc_evaluate ? 3 : @shixun.webssh
# 注意:这个地方的参数写的时候不能换行 # 注意:这个地方的参数写的时候不能换行
content_modified = params[:content_modified] # 决定文件内容是否有修改有修改如果中间层pull没有更新则轮询等待更新 content_modified = params[:content_modified] # 决定文件内容是否有修改有修改如果中间层pull没有更新则轮询等待更新
br_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}", :buildID => "#{@game.id}", br_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}", :buildID => "#{@game.id}",
:instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}", :instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}",
:times => params[:first].to_i, :podType => @shixun.webssh, :content_modified => content_modified, :times => params[:first].to_i, :podType => podType, :content_modified => content_modified,
:containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}", :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}",
:persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :sec_key => sec_key, :persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :sec_key => sec_key,
:timeLimit => game_challenge.exec_time, :isPublished => (@shixun.status < 2 ? 0 : 1) } :timeLimit => game_challenge.exec_time, :isPublished => (@shixun.status < 2 ? 0 : 1) }

@ -266,7 +266,8 @@ class MyshixunsController < ApplicationController
:identifier => @sec_key, :exec_time => exec_time) :identifier => @sec_key, :exec_time => exec_time)
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")}") 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 end
unless @hide_code # 隐藏代码文件 和 VNC的都不需要走版本库
unless @hide_code || @myshixun.shixun&.vnc_evaluate
# 远程版本库文件内容 # 远程版本库文件内容
last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"]
content = params[:content] content = params[:content]

@ -931,7 +931,7 @@ private
raise("实训名称不能为空") if params[:shixun][:name].blank? raise("实训名称不能为空") if params[:shixun][:name].blank?
params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission, params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission,
:task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, :task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
:hide_code, :forbid_copy) :hide_code, :forbid_copy, :vnc_evaluate)
end end
def shixun_info_params def shixun_info_params

@ -5,6 +5,9 @@ class Shixun < ApplicationRecord
# hide_code 隐藏代码窗口 # hide_code 隐藏代码窗口
# code_hidden: 隐藏代码目录 # code_hidden: 隐藏代码目录
# task_pass: 跳关 # task_pass: 跳关
# webssh 0不开启webssh1开启练习模式; 2开启评测模式
# trainee 实训的难度
# vnc: VCN实训是否用于评测
has_many :challenges, -> {order("challenges.position asc")}, dependent: :destroy has_many :challenges, -> {order("challenges.position asc")}, dependent: :destroy
has_many :challenge_tags, through: :challenges has_many :challenge_tags, through: :challenges
has_many :myshixuns, :dependent => :destroy has_many :myshixuns, :dependent => :destroy

@ -3,6 +3,7 @@ json.(@base_date, :st, :discusses_count, :game_count, :record_onsume_time, :prev
:shixun, :myshixun, :git_url) :shixun, :myshixun, :git_url)
if @shixun.vnc if @shixun.vnc
json.vnc_url @vnc_url json.vnc_url @vnc_url
json.vnc_evaluate @vnc_evaluate
end end
json.user do json.user do
json.partial! 'users/user', user: @user json.partial! 'users/user', user: @user

@ -22,6 +22,7 @@ json.shixun do
json.hide_code @shixun.hide_code # 隐藏代码窗口 json.hide_code @shixun.hide_code # 隐藏代码窗口
json.code_hidden @shixun.code_hidden # 代码目录隐藏 json.code_hidden @shixun.code_hidden # 代码目录隐藏
json.vnc @shixun.vnc json.vnc @shixun.vnc
json.vnc_evaluate @shixun.vnc_evaluate
#json.exec_time @shixun.exec_time #json.exec_time @shixun.exec_time
json.webssh @shixun.webssh json.webssh @shixun.webssh
json.multi_webssh @shixun.multi_webssh json.multi_webssh @shixun.multi_webssh

@ -0,0 +1,5 @@
class AddVncEvaluateForShixuns < ActiveRecord::Migration[5.2]
def change
add_column :shixuns, :vnc_evaluate, :boolean, default: false
end
end
Loading…
Cancel
Save