dev_bj
caishi 5 years ago
commit ca1ad8ccec

@ -55,6 +55,7 @@ gem 'chinese_pinyin'
# gem 'sunspot' # gem 'sunspot'
# gem 'progress_bar' # gem 'progress_bar'
gem 'ansi' gem 'ansi'
gem 'diff-lcs', '~> 1.3'
gem 'kaminari' gem 'kaminari'
gem 'elasticsearch-model' gem 'elasticsearch-model'

@ -3389,7 +3389,7 @@ end
@is_remote = true @is_remote = true
@users_pages = Paginator.new @users_count, @limit, params['page'] || 1 @users_pages = Paginator.new @users_count, @limit, params['page'] || 1
@offset ||= @users_pages.offset @offset ||= @users_pages.offset
@users = paginateHelper users.includes(:real_name_authentication_apply, :professional_authentication_apply, @users = paginateHelper users.preload(:real_name_authentication_apply, :professional_authentication_apply,
user_extensions: [:department, :school]), @limit user_extensions: [:department, :school]), @limit
respond_to do |format| respond_to do |format|

@ -333,7 +333,7 @@ class MyshixunsController < ApplicationController
shixun_tomcat = Redmine::Configuration['shixun_tomcat'] shixun_tomcat = Redmine::Configuration['shixun_tomcat']
uri = "#{shixun_tomcat}/bridge/webssh/getConnectInfo" uri = "#{shixun_tomcat}/bridge/webssh/getConnectInfo"
user_id = User.current.id user_id = User.current.id
params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh), containers:(Base64.urlsafe_encode64(container_limit @myshixun.shixun.mirror_repositories))} params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh), containers:(Base64.urlsafe_encode64(shixun_container_limit @myshixun.shixun))}
res = uri_exec uri, params res = uri_exec uri, params
if res && res['code'].to_i != 0 if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级92") raise("实训云平台繁忙繁忙等级92")
@ -362,7 +362,7 @@ class MyshixunsController < ApplicationController
begin begin
uri = "#{shixun_tomcat}/bridge/vnc/getvnc" uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
shixun = @myshixun.shixun shixun = @myshixun.shixun
params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}"} params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
res = uri_exec uri, params res = uri_exec uri, params
if res && res['code'].to_i != 0 if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99") raise("实训云平台繁忙繁忙等级99")

@ -791,7 +791,7 @@ class ShixunsController < ApplicationController
shixun_script = modify_shixun_script @shixun, shixun_script shixun_script = modify_shixun_script @shixun, shixun_script
end end
end end
@shixun.evaluate_script = shixun_script #@shixun.evaluate_script = shixun_script
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@ -808,10 +808,13 @@ class ShixunsController < ApplicationController
@shixun.shixun_members << m @shixun.shixun_members << m
# 镜像-实训关联表 # 镜像-实训关联表
ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => main_type.to_i) if main_type.present? ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => main_type.to_i) if main_type.present?
# 创建Pod配置信息
ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id => main_type.to_i)
if sub_type.present? if sub_type.present?
sub_mirrors = sub_type.split(",").map(&:to_i) sub_mirrors = sub_type.split(",").map(&:to_i)
sub_mirrors.each do |mirror| sub_mirrors.each do |mirror|
ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror) ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
end end
end end
# 自动构建版本库 # 自动构建版本库
@ -1025,6 +1028,7 @@ class ShixunsController < ApplicationController
end end
def update def update
logger.info("#######-----#{params[:config]}")
@shixun.attributes = params[:shixun] @shixun.attributes = params[:shixun]
#@shixun.language = params[:language] #@shixun.language = params[:language]
@shixun.trainee = params[:trainee] @shixun.trainee = params[:trainee]
@ -1058,6 +1062,19 @@ class ShixunsController < ApplicationController
end end
end end
# 超级管理员才能保存 中间层服务器pod信息的配置
if User.current.admin? || User.current.business?
@shixun.shixun_service_configs.each_with_index do |config, index|
config.update_attributes(:cpu_limit => params[:cpu_limit][index],
:lower_cpu_limit => params[:lower_cpu_limit][index],
:memory_limit => params[:memory_limit][index],
# :resource_limit => params[:resource_limit][index],
:request_limit => params[:request_limit][index],
:mirror_repository_id => params[:mirror_id][index])
end
end
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin

@ -2017,10 +2017,10 @@ class StudentWorkController < ApplicationController
if @homework.homework_type == 1 #普通作业 if @homework.homework_type == 1 #普通作业
if @homework.anonymous_comment ==0 if @homework.anonymous_comment ==0
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_course_group),l(:excel_homework_des), sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_course_group),l(:excel_homework_des),
l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time)]) l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time), "评语"])
else else
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_course_group),l(:excel_homework_des), sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_course_group),l(:excel_homework_des),
l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time)]) l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time), "评语"])
end end
count_row = 1 count_row = 1
items.each do |homework| items.each do |homework|
@ -2039,10 +2039,12 @@ class StudentWorkController < ApplicationController
sheet1[count_row,11] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,11] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty
sheet1[count_row,12] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score) sheet1[count_row,12] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score)
sheet1[count_row,13] = format_time(homework.update_time) sheet1[count_row,13] = format_time(homework.update_time)
sheet1[count_row,14] = work_comment(homework)
else else
sheet1[count_row,9] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,9] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty
sheet1[count_row,10] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score) sheet1[count_row,10] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score)
sheet1[count_row,11] = format_time(homework.update_time) sheet1[count_row,11] = format_time(homework.update_time)
sheet1[count_row,12] = work_comment(homework)
end end
count_row += 1 count_row += 1
end end
@ -2082,10 +2084,10 @@ class StudentWorkController < ApplicationController
elsif @homework.homework_type == 3 #分组作业 elsif @homework.homework_type == 3 #分组作业
if @homework.anonymous_comment ==0 if @homework.anonymous_comment ==0
sheet1.row(0).concat([l(:excel_group),l(:excel_group_member),l(:excel_course_group),l(:excel_homework_des), sheet1.row(0).concat([l(:excel_group),l(:excel_group_member),l(:excel_course_group),l(:excel_homework_des),
l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time)]) l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time), "评语"])
else else
sheet1.row(0).concat([l(:excel_group),l(:excel_group_member),l(:excel_course_group),l(:excel_homework_des), sheet1.row(0).concat([l(:excel_group),l(:excel_group_member),l(:excel_course_group),l(:excel_homework_des),
l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time)]) l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time), "评语"])
end end
count_row = 1 count_row = 1
items.each do |homework| items.each do |homework|
@ -2101,16 +2103,18 @@ class StudentWorkController < ApplicationController
sheet1[count_row,8] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,8] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty
sheet1[count_row,9] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score) sheet1[count_row,9] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score)
sheet1[count_row,10] = format_time(homework.update_time) sheet1[count_row,10] = format_time(homework.update_time)
sheet1[count_row,11] = work_comment(homework)
else else
sheet1[count_row,6] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty sheet1[count_row,6] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty
sheet1[count_row,7] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score) sheet1[count_row,7] = homework.respond_to?("work_score") ? homework.work_score.nil? ? l(:label_without_score) : homework.work_score.round(1) : l(:label_without_score)
sheet1[count_row,8] = format_time(homework.update_time) sheet1[count_row,8] = format_time(homework.update_time)
sheet1[count_row,9] = work_comment(homework)
end end
count_row += 1 count_row += 1
end end
elsif @homework.homework_type == 4 #实训作业 elsif @homework.homework_type == 4 #实训作业
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_course_group),l(:excel_homework_complete_time), sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_course_group),l(:excel_homework_complete_time),
l(:excel_homework_complete_status), l(:excel_homework_evaluate_times), l(:excel_homework_spend_time),l(:excel_homework_total_exp),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time)]) l(:excel_homework_complete_status), l(:excel_homework_evaluate_times), l(:excel_homework_spend_time),l(:excel_homework_total_exp),l(:excel_l_penalty),l(:excel_f_score),l(:excel_update_time), "评语"])
count_row = 1 count_row = 1
shixun = @homework.homework_commons_shixuns.shixun shixun = @homework.homework_commons_shixuns.shixun
items.each do |homework| items.each do |homework|
@ -2129,6 +2133,7 @@ class StudentWorkController < ApplicationController
sheet1[count_row,11] = homework.late_penalty sheet1[count_row,11] = homework.late_penalty
sheet1[count_row,12] = homework.respond_to?("work_score") ? homework.work_score.nil? ? "--" : homework.work_score.round(1) : "--" sheet1[count_row,12] = homework.respond_to?("work_score") ? homework.work_score.nil? ? "--" : homework.work_score.round(1) : "--"
sheet1[count_row,13] = homework.update_time ? format_time(homework.update_time) : "--" sheet1[count_row,13] = homework.update_time ? format_time(homework.update_time) : "--"
sheet1[count_row,14] = work_comment(homework)
count_row += 1 count_row += 1
end end

@ -4178,7 +4178,8 @@ class UsersController < ApplicationController
###add by huang ###add by huang
def user_watchlist def user_watchlist
watch_query = User.watched_by(@user.id) watch_query = User.joins('left join watchers on watchers.watchable_id = users.id and watchers.watchable_type in ("Principal", "User")')
.where('watchers.user_id = ?', @user.id)
@user_watchlist_count = watch_query.size @user_watchlist_count = watch_query.size
@user_watchlist = watch_query.order("#{Watcher.table_name}.id desc") @user_watchlist = watch_query.order("#{Watcher.table_name}.id desc")
@limit = 10 @limit = 10
@ -4191,7 +4192,8 @@ class UsersController < ApplicationController
###add by huang ###add by huang
def user_fanslist def user_fanslist
fan_query = @user.watcher_users fan_query = User.joins('left join watchers on watchers.user_id = users.id and watchers.watchable_type in ("Principal", "User")')
.where('watchers.watchable_id = ?', @user.id)
@user_fanlist_count = fan_query.size @user_fanlist_count = fan_query.size
@user_fanlist = fan_query.order("#{Watcher.table_name}.id desc") @user_fanlist = fan_query.order("#{Watcher.table_name}.id desc")
@ -4204,10 +4206,12 @@ class UsersController < ApplicationController
end end
def user_wathlist_and_fanslist def user_wathlist_and_fanslist
watch_query = User.watched_by(@user.id) watch_query = User.joins('left join watchers on watchers.watchable_id = users.id and watchers.watchable_type in ("Principal", "User")')
.where('watchers.user_id = ?', @user.id)
@user_watchlist_count = watch_query.count @user_watchlist_count = watch_query.count
@user_watchlist = watch_query.order("#{Watcher.table_name}.id desc") @user_watchlist = watch_query.order("#{Watcher.table_name}.id desc")
fan_query = @user.watcher_users fan_query = User.joins('left join watchers on watchers.user_id = users.id and watchers.watchable_type in ("Principal", "User")')
.where('watchers.watchable_id = ?', @user.id)
@user_fanlist_count = fan_query.count @user_fanlist_count = fan_query.count
@user_fanlist = fan_query.order("#{Watcher.table_name}.id desc") @user_fanlist = fan_query.order("#{Watcher.table_name}.id desc")
respond_to do |format| respond_to do |format|

@ -268,6 +268,24 @@ module ApplicationHelper
return container.to_json return container.to_json
end end
def shixun_container_limit shixun
container = []
shixun.shixun_service_configs.each do |config|
mirror = config.mirror_repository
if mirror.name.present?
container << {:image => mirror.name,
:cpuLimit => config.cpu_limit,
:cpuRequest => config.lower_cpu_limit,
:memoryLimit => "#{config.memory_limit}M",
:memoryRequest => "#{config.request_limit}",
:resourceLimit => "#{config.resource_limit}K",
:type => mirror.try(:main_type) == "1" ? "main" : "sub"}
end
end
Rails.logger.info("#########container: #{container.to_json}")
return container.to_json
end
# 实训作品列表的提交状态 # 实训作品列表的提交状态
def list_work_status work, homework, course_group_id def list_work_status work, homework, course_group_id
if work.work_status == 0 if work.work_status == 0

@ -3,6 +3,17 @@ include UserScoreHelper
module StudentWorkHelper module StudentWorkHelper
# 作品的评语(拼接导出excel成绩)
def work_comment work
comment = ""
work_scores = work.student_works_scores.order("created_at desc")
work_scores.each do |score|
comment += "#{score.user.show_real_name} #{format_time(score.created_at)} #{score.score}\n"
comment += "#{score.comment}\n\n"
end
comment
end
#获取当前用户的项目列表 #获取当前用户的项目列表
def user_projects_option def user_projects_option
projects = User.current.projects.visible projects = User.current.projects.visible

@ -20,7 +20,7 @@ class Challenge < ActiveRecord::Base
# validates_presence_of :score # validates_presence_of :score
validates_presence_of :task_pass validates_presence_of :task_pass
validates_length_of :subject, :maximum => 255 validates_length_of :subject, :maximum => 255
scope :min, lambda { select([:id, :subject, :position, :shixun_id, :st, :score, :path, :task_pass, :modify_time, :web_route, :answer]) } scope :min, lambda { select([:id, :subject, :position, :shixun_id, :st, :score, :exec_time, :path, :task_pass, :modify_time, :web_route, :answer]) }
scope :choose_type, lambda{where(st: 1)} scope :choose_type, lambda{where(st: 1)}
scope :practice_type, lambda{where(st: 0)} scope :practice_type, lambda{where(st: 0)}

@ -52,10 +52,10 @@ class Shixun < ActiveRecord::Base
has_many :exercise_bank_shixun_challenges, :dependent => :destroy has_many :exercise_bank_shixun_challenges, :dependent => :destroy
has_many :tag_repertoires, :through => :shixun_tag_repertoires has_many :tag_repertoires, :through => :shixun_tag_repertoires
has_many :shixun_tag_repertoires, :dependent => :destroy has_many :shixun_tag_repertoires, :dependent => :destroy
has_many :shixun_service_configs, :dependent => :destroy
scope :visible, lambda{where(status: [2,3])} scope :visible, lambda{where(status: [2,3])}
scope :min, lambda { select([:id, :name, :gpid, :modify_time, :reset_time, :language, :propaedeutics, :status, :identifier, scope :min, lambda { select([:id, :name, :gpid, :modify_time, :reset_time, :language, :status, :identifier,
:test_set_permission, :hide_code, :forbid_copy, :hidden, :webssh, :user_id, :code_hidden, :test_set_permission, :hide_code, :forbid_copy, :hidden, :webssh, :user_id, :code_hidden,
:task_pass, :exec_time, :multi_webssh, :vnc]) } :task_pass, :exec_time, :multi_webssh, :vnc]) }
scope :published, lambda{where(status: 2)} scope :published, lambda{where(status: 2)}
@ -66,6 +66,18 @@ class Shixun < ActiveRecord::Base
#scope :visible, -> { where(status: -1) } #scope :visible, -> { where(status: -1) }
after_create :send_tiding after_create :send_tiding
def description
self.has_attribute?(:description) ? self[:description] : ""
end
def propaedeutics
self.has_attribute?(:propaedeutics) ? self[:propaedeutics] : ""
end
def evaluate_script
self.has_attribute?(:evaluate_script) ? self[:evaluate_script] : ""
end
def should_compile? def should_compile?
self.mirror_repositories.published_main_mirror.first.try(:should_compile) self.mirror_repositories.published_main_mirror.first.try(:should_compile)
end end

@ -0,0 +1,7 @@
class ShixunServiceConfig < ActiveRecord::Base
# attr_accessible :title, :body
# image_type: 镜像类型: 1 主镜像、2子镜像
belongs_to :shixun
belongs_to :mirror_repository
end

@ -28,7 +28,7 @@ class Training < ActiveRecord::Base
def pay_order_title def pay_order_title
case training_type case training_type
when 3 then '全国高校大数据和人工智能暑期师资培训会-报名费' when 3 then '全国高校大数据和人工智能暑期师资培训会-报名费'
when 4 then '工程教育认证培训会-报名费' when 4 then '工程教育专业认证师资培训会-报名费'
end end
end end
@ -38,7 +38,7 @@ class Training < ActiveRecord::Base
# 三人以上 8折 # 三人以上 8折
num >= 3 ? 3000.0 * 0.8 * num : 3000.0 * num num >= 3 ? 3000.0 * 0.8 * num : 3000.0 * num
when 4 then when 4 then
700.0 * num 500.0 * num
else else
raise ArgumentError raise ArgumentError
end end

@ -42,7 +42,7 @@ class GamesService
is_teacher = (user.user_extensions.identity == 0) is_teacher = (user.user_extensions.identity == 0)
tpm_identifier = shixun.try(:identifier) tpm_identifier = shixun.try(:identifier)
# 实训超时设置 # 实训超时设置
time_limit = shixun.exec_time time_limit = game_challenge.exec_time
# 高性能取上一关、下一关 # 高性能取上一关、下一关
prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position)
@ -82,7 +82,7 @@ class GamesService
shixun_tomcat = Redmine::Configuration['shixun_tomcat'] shixun_tomcat = Redmine::Configuration['shixun_tomcat']
service_host = Redmine::Configuration['vnc_url'] service_host = Redmine::Configuration['vnc_url']
uri = "#{shixun_tomcat}/bridge/vnc/getvnc" uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
params = {tpiID: myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}"} params = {tpiID: myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
res = uri_exec uri, params res = uri_exec uri, params
if res && res['code'].to_i != 0 if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99") raise("实训云平台繁忙繁忙等级99")
@ -573,7 +573,7 @@ class GamesService
content_modified = params[:content_modified] # 决定文件内容是否有修改有修改如果中间成pull没有更新则轮询等待更新 content_modified = params[:content_modified] # 决定文件内容是否有修改有修改如果中间成pull没有更新则轮询等待更新
params = {:tpiID => "#{myshixun.id}", :tpiGitURL => "#{gitUrl}", :buildID => "#{taskId}",:instanceChallenge => "#{step}", params = {:tpiID => "#{myshixun.id}", :tpiGitURL => "#{gitUrl}", :buildID => "#{taskId}",:instanceChallenge => "#{step}",
:testCases => "#{testCases}", :resubmit => "#{resubmit}", :times => params[:first].to_i, :podType => shixun.webssh, :testCases => "#{testCases}", :resubmit => "#{resubmit}", :times => params[:first].to_i, :podType => shixun.webssh,
:containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}", :tpmScript => "#{tpmScript}", :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}", :tpmScript => "#{tpmScript}",
:timeLimit => "#{shixun.exec_time}", :content_modified => content_modified, :persistenceName => shixun.identifier, :timeLimit => "#{shixun.exec_time}", :content_modified => content_modified, :persistenceName => shixun.identifier,
:isPublished => (shixun.status < 2 ? 0 : 1), :sec_key => params[:sec_key]} :isPublished => (shixun.status < 2 ? 0 : 1), :sec_key => params[:sec_key]}
@ -584,11 +584,11 @@ class GamesService
params[:needPortMapping] = 8080 if myshixun.mirror_name.include?("Web") params[:needPortMapping] = 8080 if myshixun.mirror_name.include?("Web")
# 中间层交互 # 中间层交互
if shixun.sigle_training #if shixun.sigle_training
uri = "#{shixun_tomcat}/bridge/game/persistence/gameEvaluate" # uri = "#{shixun_tomcat}/bridge/game/persistence/gameEvaluate"
else #else
uri = "#{shixun_tomcat}/bridge/game/gameEvaluate" uri = "#{shixun_tomcat}/bridge/game/gameEvaluate"
end #end
res = interface_post uri, params, 502 res = interface_post uri, params, 502
# 单评测类型(比较快的类型实时返回结果即不用中间层再回调trainint_task_status) # 单评测类型(比较快的类型实时返回结果即不用中间层再回调trainint_task_status)

@ -82,6 +82,52 @@
<span class="color-orange mt7 fl ml20 none" id="stage_name_notice"><i class="fa fa-exclamation-circle mr3"></i>必填项</span> <span class="color-orange mt7 fl ml20 none" id="stage_name_notice"><i class="fa fa-exclamation-circle mr3"></i>必填项</span>
</div> </div>
</div> </div>
<div class="edu-back-white padding40-20 mb20">
<p class="color-grey-6 font-16 mb30">服务配置</p>
<div class="clearfix mb5">
<label class="panel-form-label fl">评测时限(S)</label>
<div class="pr fl with80 status_con">
<input type="text" name="challenge[exec_time]" value="<%= @challenge.exec_time %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<%# if User.current.admin? %>
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">CPU(核)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="challenge[cpu_limit]" value="<%#= @challenge.cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">最低CPU(核)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="challenge[lower_cpu_limit]" value="<%#= @challenge.lower_cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">内存限制(M)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="challenge[memory_limit]" value="<%#= @challenge.memory_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">内存要求(M)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="challenge[request_limit]" value="<%#= @challenge.request_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<%# end %>
</div>
<% end %> <% end %>
<div class="clearfix mt30"> <div class="clearfix mt30">
<a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="challenge_update()">提交</a> <a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="challenge_update()">提交</a>

@ -55,6 +55,20 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<div class="edu-back-white padding40-20 mb20">
<p class="color-grey-6 font-16 ">评测时限(S)</p>
<input type="text" value="<%= @challenge.exec_time %>" class="winput-240-40" disabled/>
<%# if User.current.admin? %>
<!-- <p class="color-grey-6 font-16 mt10">CPU(核)</p>-->
<!-- <input type="text" value="<%#= @challenge.cpu_limit %>" class="winput-240-40" disabled/>-->
<!-- <p class="color-grey-6 font-16 mt10">最低CPU(核)</p>-->
<!-- <input type="text" value="<%#= @challenge.lower_cpu_limit %>" class="winput-240-40" disabled/>-->
<!-- <p class="color-grey-6 font-16 mt10">内存限制(M)</p>-->
<!-- <input type="text" value="<%#= @challenge.memory_limit %>" class="winput-240-40" disabled/>-->
<!-- <p class="color-grey-6 font-16 mt10">内存要求(M)</p>-->
<!-- <input type="text" value="<%#= @challenge.request_limit %>" class="winput-240-40" disabled/>-->
<%# end %>
</div>
<% end %> <% end %>
<script> <script>
$(document).ready(function() { $(document).ready(function() {

@ -1,6 +1,11 @@
<style> <style>
.down-select .magic-radio + label:before, .down-select .magic-checkbox + label:before {top: 10px !important;} .down-select .magic-radio + label:before, .down-select .magic-checkbox + label:before {
.down-select .magic-checkbox + label:after {top: 10px !important} top: 10px !important;
}
.down-select .magic-checkbox + label:after {
top: 10px !important
}
</style> </style>
<div class="educontent mt30 mb80"> <div class="educontent mt30 mb80">
<%= form_for(@shixun) do |f| %> <%= form_for(@shixun) do |f| %>
@ -138,14 +143,14 @@
其它参数可按实际需求定制 其它参数可按实际需求定制
</p> </p>
</div> </div>
<p class="inviteTipbtn with100 fl"><a href="javascript:void(0);" onclick="$('#test_script_tip').hide();">知道了</a></p> <p class="inviteTipbtn with100 fl">
<a href="javascript:void(0);" onclick="$('#test_script_tip').hide();">知道了</a></p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="mb10 edu-back-white padding40-20"> <div class="mb10 edu-back-white padding40-20">
<div class="clearfix mb20"> <div class="clearfix mb20">
<p class="color-grey-6 font-16 mb30 fl">发布信息</p> <p class="color-grey-6 font-16 mb30 fl">发布信息</p>
@ -282,13 +287,65 @@
<%= render_shixun_departments %> <%= render_shixun_departments %>
</ul> </ul>
</div> </div>
<a class="edu-default-btn edu-blueline-btn fl mt1" href="javascript:void(0)" onclick="$('#person-unit').show();$('#person-unit').find('input').val('');$('#scope-down-list').hide();">+ 添加</a> <a class="edu-default-btn edu-blueline-btn fl mt1" href="javascript:void(0)" onclick="$('#person-unit').show();$('#person-unit').find('input').val('');$('#scope-down-list').hide();">+
添加</a>
</div> </div>
<span class="color-orange ml20 fl none" id="public_unit_notice"><i class="fa fa-exclamation-circle mr3"></i>请选择需要公开的单位</span> <span class="color-orange ml20 fl none" id="public_unit_notice"><i class="fa fa-exclamation-circle mr3"></i>请选择需要公开的单位</span>
</div> </div>
</div> </div>
<% end %> <% end %>
<% if User.current.admin? || User.cuurent.business? %>
<div class="edu-back-white padding40-20 mb20">
<p class="color-grey-6 font-16 mb30">服务配置</p>
<% @shixun.shixun_service_configs.each do |config| %>
<p class="color-grey-6 font-16 mt30"><%= config.mirror_repository.try(:type_name) %></p>
<input type="hidden" name="mirror_id[]" value="<%= config.mirror_repository.try(:id) %>'">
<div class="clearfix mb5">
<label class="panel-form-label fl">CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="cpu_limit[]" value="<%= config.cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">最低CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="lower_cpu_limit[]" value="<%= config.lower_cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存限制(M)</label>
<div class="pr fl with80 status_con">
<input type="text" name="memory_limit[]" value="<%= config.memory_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存要求(M)</label>
<div class="pr fl with20 status_con">
<input type="text" name="request_limit[]" value="<%= config.request_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<label class="panel-form-label fl" style="width: 48%">温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div class="cl"></div>
</div>
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">磁盘限制(K)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="resource_limit[]" value="<%#= config.resource_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<% end %>
</div>
<% end %>
<div class="clearfix mt30"> <div class="clearfix mt30">
<a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="submit_edit_shixun(<%= @shixun.id %>);">保存</a> <a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="submit_edit_shixun(<%= @shixun.id %>);">保存</a>
<%= link_to "取消", settings_shixun_path(@shixun), :class => "defalutCancelbtn fl" %> <%= link_to "取消", settings_shixun_path(@shixun), :class => "defalutCancelbtn fl" %>

@ -124,7 +124,7 @@
</script> </script>
<% end %> <% end %>
<div> <div>
<p class="collegeInfo"><%= @training_type == 3 ? '信息技术新工科产学研联盟师资培训班' : '工程教育认证' %></p> <p class="collegeInfo"><%= @training_type == 3 ? '信息技术新工科产学研联盟师资培训班' : '工程教育专业认证师资培训' %></p>
<%= form_for @training do |f| %> <%= form_for @training do |f| %>
<%= hidden_field_tag(:friendly_id, @friendly_id) %> <%= hidden_field_tag(:friendly_id, @friendly_id) %>

@ -13,7 +13,7 @@
</div> </div>
<% if user != User.current %> <% if user != User.current %>
<div class="fr"> <div class="fr">
<% if(user.watched_by?(User.current)) %> <% if Watcher.where(user_id: User.current.id, watchable_id: user.id, watchable_type: %w(Principal User)).exists? %>
<%= link_to "取消关注", <%= link_to "取消关注",
unwatch_path(:object_type => 'user', :object_id => user.id, :target_id => @user.id, :action_name => action), unwatch_path(:object_type => 'user', :object_id => user.id, :target_id => @user.id, :action_name => action),
:class => "user_default_btn user_private_btn fl mr30 mt20", :class => "user_default_btn user_private_btn fl mr30 mt20",

@ -0,0 +1,14 @@
class CreateShixunServiceConfigs < ActiveRecord::Migration
def change
create_table :shixun_service_configs do |t|
t.references :shixun
t.integer :cpu_limit, :default => 1
t.integer :memory_limit, :default => 1024
t.integer :request_limit, :default => 10
t.float :lower_cpu_limit, :default => 0.1
t.integer :resource_limit, :default => 10000
t.references :mirror_repository
t.timestamps
end
end
end

@ -0,0 +1,19 @@
class AddLimitForShixuns < ActiveRecord::Migration
def up
Shixun.find_each do |shixun|
shixun.challenges.update_all(:exec_time => shixun.exec_time)
shixun.mirror_repositories.each do |mirror|
ShixunServiceConfig.create!(:shixun_id => shixun.id,
:cpu_limit => mirror.cpu_limit,
:memory_limit => mirror.memory_limit,
:request_limit => mirror.memory_limit / 3,
:mirror_repository_id => mirror.id)
end
end
end
def down
end
end

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :shixun_service_config do
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ShixunServiceConfig, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save