|
|
|
@ -367,11 +367,6 @@ class ShixunsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
h = {test_set_permission: params[:test_set_permission], code_hidden: params[:code_hidden],
|
|
|
|
|
task_pass: params[:task_pass], hide_code: params[:hide_code], forbid_copy: params[:forbid_copy]}
|
|
|
|
|
|
|
|
|
|
s_params = shixun_params.merge(h)
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
@shixun.shixun_mirror_repositories.destroy_all
|
|
|
|
@ -384,8 +379,8 @@ class ShixunsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@shixun.update_attributes(s_params)
|
|
|
|
|
@shixun.shixun_info.update_attributes(description: params[:description], evaluate_script: params[:evaluate_script])
|
|
|
|
|
@shixun.update_attributes(shixun_params)
|
|
|
|
|
@shixun.shixun_info.update_attributes(shixun_info_params)
|
|
|
|
|
@shixun.shixun_schools.delete_all
|
|
|
|
|
if params[:scope_partment].present? && params[:user_scope].to_i == 1
|
|
|
|
|
arr = []
|
|
|
|
@ -402,13 +397,8 @@ class ShixunsController < ApplicationController
|
|
|
|
|
# 超级管理员和运营人员才能保存 中间层服务器pod信息的配置
|
|
|
|
|
if current_user.admin? || current_user.business?
|
|
|
|
|
@shixun.shixun_service_configs.destroy_all
|
|
|
|
|
params[:mirror_id].each_with_index do |mirror_id, index|
|
|
|
|
|
ShixunServiceConfig.create!(:shixun_id => @shixun.id,
|
|
|
|
|
:cpu_limit => params[:cpu_limit][index],
|
|
|
|
|
:lower_cpu_limit => params[:lower_cpu_limit][index],
|
|
|
|
|
:memory_limit => params[:memory_limit][index],
|
|
|
|
|
:request_limit => params[:request_limit][index],
|
|
|
|
|
:mirror_repository_id => mirror_id)
|
|
|
|
|
params[:shixun_service_configs].each do |config|
|
|
|
|
|
@shixun.shixun_service_configs.create!(config)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
@ -446,6 +436,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
@choice_small_type = @shixun.small_mirror_id
|
|
|
|
|
@main_type = shixun_main_type
|
|
|
|
|
@small_type = shixun_small_type
|
|
|
|
|
@configs = @shixun.shixun_service_configs
|
|
|
|
|
#@mirror_script = MirrorScript.select([:id, :script_type]).find(@shixun.mirror_script_id).attributes if @shixun.mirror_script_id && @shixun.mirror_script_id != 0
|
|
|
|
|
# @shixun_main_mirror = @shixun.show_shixun_mirror
|
|
|
|
|
# @script_type = @shixun.script_tag.try(:script_type) || "无"
|
|
|
|
@ -734,7 +725,13 @@ private
|
|
|
|
|
def shixun_params
|
|
|
|
|
raise("实训名称不能为空") if params[:name].blank?
|
|
|
|
|
params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission,
|
|
|
|
|
:task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id)
|
|
|
|
|
:task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
|
|
|
|
|
:hide_code, :forbid_copy)
|
|
|
|
|
end
|
|
|
|
|
def shixun_info_params
|
|
|
|
|
raise("实训描述不能为空") if params[:description].blank?
|
|
|
|
|
raise("评测脚本不能为空") if params[:evaluate_script].blank?
|
|
|
|
|
params.require(:shixun_info).permit(:description, :evaluate_script)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def find_shixun
|
|
|
|
|