diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb
index 68e4b4b0..85735080 100644
--- a/app/controllers/myshixuns_controller.rb
+++ b/app/controllers/myshixuns_controller.rb
@@ -333,7 +333,7 @@ class MyshixunsController < ApplicationController
       shixun_tomcat = Redmine::Configuration['shixun_tomcat']
       uri = "#{shixun_tomcat}/bridge/webssh/getConnectInfo"
       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
       if res && res['code'].to_i != 0
         raise("实训云平台繁忙(繁忙等级:92)")
@@ -362,7 +362,7 @@ class MyshixunsController < ApplicationController
     begin
     uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
     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
     if res && res['code'].to_i != 0
       raise("实训云平台繁忙(繁忙等级:99)")
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index e47938ac..1e3f105b 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -791,7 +791,7 @@ class ShixunsController < ApplicationController
         shixun_script = modify_shixun_script @shixun, shixun_script
       end
     end
-    @shixun.evaluate_script = shixun_script
+    #@shixun.evaluate_script = shixun_script
 
     ActiveRecord::Base.transaction do
       begin
@@ -808,24 +808,27 @@ class ShixunsController < ApplicationController
         @shixun.shixun_members << m
         # 镜像-实训关联表
         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?
           sub_mirrors = sub_type.split(",").map(&:to_i)
           sub_mirrors.each do |mirror|
             ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
+            ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id =>  mirror)
           end
         end
-        # 自动构建版本库
-        repository = Repository.new
-        repository.shixun = @shixun
-        repository.type = 'Repository::Gitlab'
-        repository.identifier = @shixun.identifier.downcase
-        repository.project_id = -1
-        repository.save!
-        s = Trustie::Gitlab::Sync.new
-        gproject = s.create_shixun(@shixun, repository)
-        raise "版本库创建失败" if @shixun.gpid.blank?   # 若和gitlab没同步成功,则抛出异常
-        g = Gitlab.client
-        @shixun.update_column(:git_url, g.project(@shixun.gpid).path_with_namespace)
+        # # 自动构建版本库
+        # repository = Repository.new
+        # repository.shixun = @shixun
+        # repository.type = 'Repository::Gitlab'
+        # repository.identifier = @shixun.identifier.downcase
+        # repository.project_id = -1
+        # repository.save!
+        # s = Trustie::Gitlab::Sync.new
+        # gproject = s.create_shixun(@shixun, repository)
+        # raise "版本库创建失败" if @shixun.gpid.blank?   # 若和gitlab没同步成功,则抛出异常
+        # g = Gitlab.client
+        # @shixun.update_column(:git_url, g.project(@shixun.gpid).path_with_namespace)
         # g = Gitlab.client
         # hook_url = Setting.protocol + "://" + Setting.host_name + "/shixuns/#{@shixun.identifier}" + "/ghook"
         # g.add_project_hook(@shixun.gpid, hook_url)
@@ -1025,6 +1028,7 @@ class ShixunsController < ApplicationController
   end
 
   def update
+    logger.info("#######-----#{params[:config]}")
     @shixun.attributes = params[:shixun]
     #@shixun.language = params[:language]
     @shixun.trainee = params[:trainee]
@@ -1058,6 +1062,19 @@ class ShixunsController < ApplicationController
       end
     end
 
+    # 超级管理员才能保存 中间层服务器pod信息的配置
+    if User.current.admin?
+      @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
       begin
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 34fa1a8d..8ab4e31f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -268,6 +268,21 @@ module ApplicationHelper
     return container.to_json
   end
 
+  def shixun_container_limit shixun
+    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
+  end
+
   # 实训作品列表的提交状态
   def list_work_status work, homework, course_group_id
     if work.work_status == 0
diff --git a/app/models/shixun.rb b/app/models/shixun.rb
index bf06b583..bbc64946 100644
--- a/app/models/shixun.rb
+++ b/app/models/shixun.rb
@@ -52,7 +52,7 @@ class Shixun < ActiveRecord::Base
   has_many :exercise_bank_shixun_challenges, :dependent => :destroy
   has_many :tag_repertoires, :through => :shixun_tag_repertoires
   has_many :shixun_tag_repertoires, :dependent => :destroy
-
+  has_many :shixun_service_configs, :dependent => :destroy
 
   scope :visible, lambda{where(status: [2,3])}
   scope :min, lambda { select([:id, :name, :gpid, :modify_time, :reset_time, :language, :propaedeutics, :status, :identifier,
@@ -66,6 +66,18 @@ class Shixun < ActiveRecord::Base
   #scope :visible, -> { where(status: -1) }
   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?
     self.mirror_repositories.published_main_mirror.first.try(:should_compile)
   end
diff --git a/app/models/shixun_service_config.rb b/app/models/shixun_service_config.rb
new file mode 100644
index 00000000..94d67190
--- /dev/null
+++ b/app/models/shixun_service_config.rb
@@ -0,0 +1,7 @@
+class ShixunServiceConfig < ActiveRecord::Base
+  # attr_accessible :title, :body
+  # image_type: 镜像类型: 1 主镜像、2子镜像
+  belongs_to :shixun
+  belongs_to :mirror_repository
+
+end
diff --git a/app/services/games_service.rb b/app/services/games_service.rb
index c77e7437..8589023a 100644
--- a/app/services/games_service.rb
+++ b/app/services/games_service.rb
@@ -42,7 +42,7 @@ class GamesService
     is_teacher = (user.user_extensions.identity == 0)
     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)
@@ -82,7 +82,7 @@ class GamesService
         shixun_tomcat = Redmine::Configuration['shixun_tomcat']
         service_host = Redmine::Configuration['vnc_url']
         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
         if res && res['code'].to_i != 0
           raise("实训云平台繁忙(繁忙等级:99)")
@@ -573,7 +573,7 @@ class GamesService
     content_modified = params[:content_modified] # 决定文件内容是否有修改,有修改如果中间成pull没有更新,则轮询等待更新
     params = {:tpiID => "#{myshixun.id}", :tpiGitURL  => "#{gitUrl}", :buildID => "#{taskId}",:instanceChallenge  => "#{step}",
               :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,
               :isPublished => (shixun.status < 2 ? 0 : 1), :sec_key => params[:sec_key]}
 
diff --git a/app/views/challenges/_new_or_edit_task_page.html.erb b/app/views/challenges/_new_or_edit_task_page.html.erb
index b31e3373..4ddde7e5 100644
--- a/app/views/challenges/_new_or_edit_task_page.html.erb
+++ b/app/views/challenges/_new_or_edit_task_page.html.erb
@@ -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>
           </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 %>
     <div class="clearfix mt30">
       <a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="challenge_update()">提交</a>
diff --git a/app/views/challenges/_pass_task_show.html.erb b/app/views/challenges/_pass_task_show.html.erb
index 2e116e9f..32527f1b 100644
--- a/app/views/challenges/_pass_task_show.html.erb
+++ b/app/views/challenges/_pass_task_show.html.erb
@@ -55,6 +55,20 @@
         <% end %>
       </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 %>
 <script>
     $(document).ready(function() {
diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb
index 337ecee2..bf34df92 100644
--- a/app/views/shixuns/_form.html.erb
+++ b/app/views/shixuns/_form.html.erb
@@ -39,16 +39,16 @@
   </div>
   <div class="mb10 edu-back-white padding30-20">
     <p class="color-grey-6 font-16 mb15">简介</p>
-    <div class="df mb20">
-      <div class="flex1 mr20">
-        <div id="shixun_introduction" class="fl">
-          <textarea name="shixun[description]"><%= @introduction_sample || @shixun.description %></textarea>
-        </div>
-        <p id="e_tip_desc" class="edu-txt-right color-grey-cd font-12"></p>
-        <p id="e_tips_desc" class="edu-txt-right color-grey-cd font-12"></p>
-      </div>
-      <div style="width: 57px;">&nbsp;</div>
-    </div>
+<!--    <div class="df mb20">-->
+<!--      <div class="flex1 mr20">-->
+<!--        <div id="shixun_introduction" class="fl">-->
+<!--          <textarea name="shixun[description]"><%#= @introduction_sample || @shixun.description %></textarea>-->
+<!--        </div>-->
+<!--        <p id="e_tip_desc" class="edu-txt-right color-grey-cd font-12"></p>-->
+<!--        <p id="e_tips_desc" class="edu-txt-right color-grey-cd font-12"></p>-->
+<!--      </div>-->
+<!--      <div style="width: 57px;">&nbsp;</div>-->
+<!--    </div>-->
   </div>
   <div class="mb10 edu-back-white padding30-20">
     <p class="color-grey-6 font-16 mb15">技术平台</p>
diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb
index 6ebd6138..39fca96b 100644
--- a/app/views/shixuns/_settings_edit.html.erb
+++ b/app/views/shixuns/_settings_edit.html.erb
@@ -1,6 +1,11 @@
 <style>
-  .down-select .magic-radio + label:before, .down-select .magic-checkbox + label:before {top: 10px !important;}
-  .down-select .magic-checkbox + label:after {top: 10px !important}
+  .down-select .magic-radio + label:before, .down-select .magic-checkbox + label:before {
+    top: 10px !important;
+  }
+
+  .down-select .magic-checkbox + label:after {
+    top: 10px !important
+  }
 </style>
 <div class="educontent mt30 mb80">
   <%= form_for(@shixun) do |f| %>
@@ -30,16 +35,16 @@
 
     <div class="mb10 edu-back-white padding40-20">
       <p class="color-grey-6 font-16 mb30">简介</p>
-      <div class="df mb20">
-        <div class="flex1 mr20">
-          <div id="setting_introduction" class="fl">
-            <textarea name="shixun[description]"><%= @shixun.description %></textarea>
-          </div>
-          <p id="e_tip_in" class="edu-txt-right color-grey-cd font-12"></p>
-          <p id="e_tips_in" class="edu-txt-right color-grey-cd font-12"></p>
-        </div>
-        <div style="width: 57px;">&nbsp;</div>
-      </div>
+<!--      <div class="df mb20">-->
+<!--        <div class="flex1 mr20">-->
+<!--          <div id="setting_introduction" class="fl">-->
+<!--            <textarea name="shixun[description]"><%#= @shixun.description %></textarea>-->
+<!--          </div>-->
+<!--          <p id="e_tip_in" class="edu-txt-right color-grey-cd font-12"></p>-->
+<!--          <p id="e_tips_in" class="edu-txt-right color-grey-cd font-12"></p>-->
+<!--        </div>-->
+<!--        <div style="width: 57px;">&nbsp;</div>-->
+<!--      </div>-->
     </div>
 
     <div class="mb10 edu-back-white padding40-20">
@@ -53,7 +58,7 @@
               <input type="text" class="input-100-40 pr20 color-grey-3 font-14 pointer" id="tech_platform_list" readonly value="<%= @shixun.shixun_main_name %>" placeholder="请选择主类别"/>
               <div class="down-select" id="shixun_language_option">
                 <% @main_type.try(:each) do |type| %>
-                    <p data-shixun-value="<%= type.id %>" title="<%= type.description.blank? ? "无描述" : type.description %>"><%= type.type_name %></p>
+                  <p data-shixun-value="<%= type.id %>" title="<%= type.description.blank? ? "无描述" : type.description %>"><%= type.type_name %></p>
                 <% end %>
               </div>
             </div>
@@ -65,10 +70,10 @@
             <input type="text" class="input-100-40 pr20 color-grey-3 font-14 pointer" readonly value="<%= @shixun.shixun_child_name %>" placeholder="请选择小类别"/>
             <div class="down-select" id="shixun_small_language_option" style="padding: 2px 0px">
               <% @small_type.try(:each) do |type| %>
-                  <p data-shixun-value="<%= type.id %>">
-                    <input type="checkbox" class="magic-checkbox" id="mirror_<%= type.id %>" value="<%= type.type_name %>"/>
-                    <label style="top:0px" for="mirror_<%= type.id %>"><%= type.type_name %></label>
-                  </p>
+                <p data-shixun-value="<%= type.id %>">
+                  <input type="checkbox" class="magic-checkbox" id="mirror_<%= type.id %>" value="<%= type.type_name %>"/>
+                  <label style="top:0px" for="mirror_<%= type.id %>"><%= type.type_name %></label>
+                </p>
               <% end %>
             </div>
           </div>
@@ -85,16 +90,16 @@
         <div class="clearfix">
           <div class="with15 pr fl" <%= @power ? "select-for" : "" %>>
             <input type="hidden" name="mirror_script" id="shixun_scenario" value="<%= @shixun.script_tag.try(:id) %>">
-            <input type="text" id="shixun_scenario_name" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" readonly placeholder="请选择脚本" value="<%= @shixun.script_tag.try(:script_type) ?  @shixun.script_tag.try(:script_type) : "无" %>"/>
+            <input type="text" id="shixun_scenario_name" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" readonly placeholder="请选择脚本" value="<%= @shixun.script_tag.try(:script_type) ? @shixun.script_tag.try(:script_type) : "无" %>"/>
             <div class="down-select bor-grey-e user_bg_shadow" id="shixun_scenario_option">
               <p data-shixun-value="-1" title="无">无</p>
               <% @shixun.standrad_script.each do |script| %>
-                  <p data-shixun-value="<%= script.id %>" title="<%= script.script_type %>"><%= script.script_type %></p>
+                <p data-shixun-value="<%= script.id %>" title="<%= script.script_type %>"><%= script.script_type %></p>
               <% end %>
             </div>
           </div>
           <% if @power %>
-              <a href="javascript:void(0)" onclick="define_temp();" id="define_template" class="color-orange-tip mt7 ml20 fl">使用自定义脚本</a>
+            <a href="javascript:void(0)" onclick="define_temp();" id="define_template" class="color-orange-tip mt7 ml20 fl">使用自定义脚本</a>
           <% end %>
           <div class="cl"></div>
           <p class="clearfix mt10" id="script_description"><%= @shixun.script_tag.try(:description) %></p>
@@ -138,42 +143,42 @@
                 其它参数可按实际需求定制
               </p>
             </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 class="mb10 edu-back-white padding40-20">
       <div class="clearfix mb20">
-          <p class="color-grey-6 font-16 mb30 fl">发布信息</p>
-          <div class="clearfix">
-            <span class="color-grey-6 mt5 fl" style="min-width: 95px;"><span class="color-orange fl mr5 mt3">*</span>面向学员:</span>
-            <div class="with15 fl pr" select-for>
-              <input type="hidden" name="trainee" id="shixun_trainee" value="<%= @shixun.trainee %>">
-              <input type="text" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" placeholder="面向学员" readonly value="<%= @shixun.shixun_trainee %>"/>
-              <div class="down-select bor-grey-e user_bg_shadow" id="shixun_trainee_option">
-                <p data-shixun-value="1">初级学员</p>
-                <p data-shixun-value="2">中级学员</p>
-                <p data-shixun-value="3">高级学员</p>
-                <p data-shixun-value="3">顶级学员</p>
-              </div>
+        <p class="color-grey-6 font-16 mb30 fl">发布信息</p>
+        <div class="clearfix">
+          <span class="color-grey-6 mt5 fl" style="min-width: 95px;"><span class="color-orange fl mr5 mt3">*</span>面向学员:</span>
+          <div class="with15 fl pr" select-for>
+            <input type="hidden" name="trainee" id="shixun_trainee" value="<%= @shixun.trainee %>">
+            <input type="text" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" placeholder="面向学员" readonly value="<%= @shixun.shixun_trainee %>"/>
+            <div class="down-select bor-grey-e user_bg_shadow" id="shixun_trainee_option">
+              <p data-shixun-value="1">初级学员</p>
+              <p data-shixun-value="2">中级学员</p>
+              <p data-shixun-value="3">高级学员</p>
+              <p data-shixun-value="3">顶级学员</p>
             </div>
-            <span class="fl ml10 mt6 color-grey">标签,不限定用户群体</span>
           </div>
+          <span class="fl ml10 mt6 color-grey">标签,不限定用户群体</span>
+        </div>
       </div>
       <div class="clearfix mt20">
-          <span class="color-grey-6 mt5 fl" style="min-width: 95px;">复制:</span>
-          <span class="fl">
+        <span class="color-grey-6 mt5 fl" style="min-width: 95px;">复制:</span>
+        <span class="fl">
             <input type="checkbox" <%= @shixun.can_copy ? 'checked' : "" %> name="can_copy" value="<%= @shixun.can_copy ? 1 : 0 %>" id="can_copy" class="ml5 mr5 magic-checkbox">
             <label style="top:6px" class="color-grey-6" for="can_copy">勾选则平台所有已职业认证的教师可以复制</label>
           </span>
       </div>
       <div class="clearfix mt20">
         <span class="color-grey-6 mt5 fl" style="min-width: 95px;">跳关:</span>
-          <span class="fl">
+        <span class="fl">
             <input type="checkbox" <%= @shixun.task_pass ? 'checked' : "" %> name="task_pass" value="<%= @shixun.task_pass ? 1 : 0 %>" id="task_pass" class="ml5 mr5 magic-checkbox">
             <label style="top:6px" class="color-grey-6" for="task_pass">勾选则允许学员跳关挑战实训</label>
           </span>
@@ -197,7 +202,7 @@
 
       <div class="clearfix mt20">
         <span class="color-grey-6 mt5 fl" style="min-width: 95px;">代码目录隐藏:</span>
-          <span class="fl">
+        <span class="fl">
             <input type="checkbox" <%= @shixun.code_hidden ? 'checked' : "" %> name="code_hidden" value="<%= @shixun.code_hidden ? 1 : 0 %>" id="code_hidden" class="ml5 mr5 magic-checkbox">
             <label style="top:6px" class="color-grey-6" for="code_hidden">勾选则对学员隐藏版本库目录</label>
           </span>
@@ -212,13 +217,13 @@
       </div>
 
       <% if User.current.admin? %>
-          <div class="clearfix mt20">
-              <span class="color-grey-6 mt5 fl" style="min-width: 95px;">VNC图形化:</span>
-              <span class="fl">
+        <div class="clearfix mt20">
+          <span class="color-grey-6 mt5 fl" style="min-width: 95px;">VNC图形化:</span>
+          <span class="fl">
                 <input type="checkbox" <%= @shixun.vnc ? 'checked' : "" %> name="vnc" value="<%= @shixun.vnc ? 1 : 0 %>" id="vnc" class="ml5 mr5 magic-checkbox">
               <label style="top:6px" class="color-grey-6" for="vnc">勾选则给学员的实践任务提供Ubuntu系统图形化实践窗口,否则不提供</label>
               </span>
-          </div>
+        </div>
       <% end %>
     </div>
 
@@ -227,7 +232,7 @@
       <div class="df">
         <span class="mr30 color-orange pt10">*</span>
         <div class="flex1 mr20">
-          <%= f.text_field :exec_time, :class => "fl input-48-45 width20 greyInput", :placeholder => "请输入程序执行时间"  %>
+          <%= f.text_field :exec_time, :class => "fl input-48-45 width20 greyInput", :placeholder => "请输入程序执行时间" %>
           <span class="fl ml10 mt6 color-grey">秒</span>
         </div>
         <div style="width: 57px;">
@@ -282,290 +287,342 @@
                 <%= render_shixun_departments %>
               </ul>
             </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>
           <span class="color-orange ml20 fl none" id="public_unit_notice"><i class="fa fa-exclamation-circle mr3"></i>请选择需要公开的单位</span>
         </div>
       </div>
     <% 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 mt30">
-      <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" %>
-    </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">
+        <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" %>
+      </div>
   <% end %>
-</div>
-
-<script>
-    //配置-信息提交
-    function submit_edit_shixun(id) {
-        if (regex_shixun_name() && regex_public_unit() && regex_tech_platform()) {
-            if(script_Codemirror.getValue().trim() == ""){
-                $("#test_script_code").show();
-                $(document).scrollTop(parseInt($("#test_script_code").offset().top)-150);
-                return;
-            }else{
-                $("#test_script_code").hide();
-            }
-            if($("#shixun_exec_time").val() == "")
-                return;
-            $("#edit_shixun_" + id).submit();
-        }
-    }
-
-    function get_mirror_script(){
-        $select.siblings("input[type=hidden]").attr("value", hideValue);
-        $select.siblings("input[type=text]").attr("value", textValue);
-        $parent.hide();
-        var script_id = $("#shixun_scenario").val();
-        $.ajax({
-            url: "<%= get_script_contents_shixun_path(@shixun) %>",
-            data: {script_id: script_id},
-            success: function(data){
-                script_Codemirror.setValue(data.contents);
-                $("#script_description").html(data.description);
-                notice_box("评测脚本生成成功!");
-            },
-            error: function(){
-                notice_box("获取脚本失败!")
-            }
-        })
-    }
-
-    //自定义模板弹框
-    function define_temp(){
-        var html = "<%= j(render :partial => 'define_scenario') %>";
-        pop_box_new(html,400,400);
-    }
-
-    //下拉框
-    $("[select-for]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
-    $("[select-for]").hover(function(){
-        $(this).find(".down-select").show();
-    },function(){
-        $(this).find(".down-select").hide();
-    });
-    var $select, hideValue, textValue, $parent;
-    $("[select-for] .down-select p").live("click",function(){
-        $select = $(this).parents(".down-select");
-        hideValue = $(this).attr("data-shixun-value");
-        textValue = $(this).html().trim();
-        $parent = $(this).parent();
-        var parentId = $(this).parent().attr("id");
-        if(parentId != "shixun_scenario_option"){
-            $select.siblings("input[type=hidden]").attr("value", hideValue);
-            $select.siblings("input[type=text]").attr("value", textValue);
-            $parent.hide();
-        }
-        if(parentId == "shixun_language_option"){
-            var mirror_id = $("#shixun_main_language").val();
-            $.ajax({
-                url: "<%= get_mirror_script_shixuns_path %>",
-                data: { mirror_id: mirror_id},
-                success: function(data){
-                    var lens = data.length;
-                    var htmlContents = "";
-                    $("#shixun_scenario").val("");
-                    $("#shixun_scenario_name").val("");
-                    for(var i = 0; i < lens; i++){
-                        htmlContents += "<p data-shixun-value=\"" + data[i].mirror_script.id + "\" " + "title=\"" + data[i].mirror_script.script_type +"\">"+ data[i].mirror_script.script_type +"</p>"
-                    }
-                    $("#shixun_scenario_option").html(htmlContents);
-                },
-                error: function(){
-                    notice_box("获取技术平台失败!")
-                }
-            });
-        }
-        if(parentId == "shixun_scenario_option"){
-            op_confirm_tip("原有脚本将被新的脚本覆盖,无法撤销<br/>是否确认执行覆盖操作","get_mirror_script");
-        }
-    });
-
-    $("input[name='webssh']").on("click", function(){
-        if($(this).val() == 2){
-            $("#multi_webssh").parent().show();
-        } else{
-            $("#multi_webssh").parent().hide();
-            $("#multi_webssh").attr("checked", false);
-        }
-    });
-
-    /*----------------------------选择镜像小类别--------------*/
-    $("[select-more]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
-    $("[select-more]").hover(function () {
-        $(this).find(".down-select").show();
-    }, function () {
-        $(this).find(".down-select").hide();
-    });
-    $("[select-more] .down-select p input").bind("click", function () {
-        var all = $(this).parents(".down-select");
-        var arr = "";
-        var idarr = [];
-        for (var i = 0; i < all.find("input").length; i++) {
-            if (all.find("input").eq(i).is(':checked')) {
-                arr += ";" + (all.find("input").eq(i).attr("value"));
-                idarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
-            }
-        }
-        $("input[name='small_type']").val(idarr);
-        $(this).parents().prev("input").val(arr.substring(1));
-        //$(this).parents(".down-select").hide();
-    });
-
-    $(function () {
-        //选择自定义脚本
-        $("#diy_script").click(function(){
-            var html = "<%= j(render :partial => 'define_scenario') %>";
-            pop_box_new(html,400,400);
-        });
-
-        $("#webssh").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-        $("#vnc").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-
-
-        $("#can_copy").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-
-        $("#unlock_test_set").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-
-        $("#code_hidden").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-
-        $("#forbid_copy").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-
-        $("#hide_code").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-
-        $("#task_pass").on("click", function(){
-            $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
-        });
-
-        $("#scope-down-list").find("li").live("click",function(){
-            var ul=$(this).parent("ul");
-            var div=$(this).parents("#unit-input-part");
-            var value=$(this).html();
-            ul.siblings("#for_part_search").val(value);
-
-            var width=value.length*2;
-            var label="<label class=\"fl unit-part mb10\"><input type='text' size='" + width + "' id='scope_partment' name='scope_partment[]' readonly value='"+value+"'><span class=\"color-orange03 ml5 eud-pointer\">×</span></label>";
-            div.before(label);
-            ul.siblings("#for_part_search").attr("data-value-was",value);
-            $("#person-unit").hide();
-            $("#scope-down-list").hide();
-        });
-
-        $(".unit-part").find("span").live("click",function(){
-            $(this).parents(".unit-part").remove();
-        });
-
-        if($("#public-part").is(":checked")){
-            $("#person-unit").show();
-            $("#person-unit").find("input").val("");
+  </div>
+
+  <script>
+      //配置-信息提交
+      function submit_edit_shixun(id) {
+          if (regex_shixun_name() && regex_public_unit() && regex_tech_platform()) {
+              if (script_Codemirror.getValue().trim() == "") {
+                  $("#test_script_code").show();
+                  $(document).scrollTop(parseInt($("#test_script_code").offset().top) - 150);
+                  return;
+              } else {
+                  $("#test_script_code").hide();
+              }
+              if ($("#shixun_exec_time").val() == "")
+                  return;
+              $("#edit_shixun_" + id).submit();
+          }
+      }
+
+      function get_mirror_script() {
+          $select.siblings("input[type=hidden]").attr("value", hideValue);
+          $select.siblings("input[type=text]").attr("value", textValue);
+          $parent.hide();
+          var script_id = $("#shixun_scenario").val();
+          $.ajax({
+              url: "<%= get_script_contents_shixun_path(@shixun) %>",
+              data: {script_id: script_id},
+              success: function (data) {
+                  script_Codemirror.setValue(data.contents);
+                  $("#script_description").html(data.description);
+                  notice_box("评测脚本生成成功!");
+              },
+              error: function () {
+                  notice_box("获取脚本失败!")
+              }
+          })
+      }
+
+      //自定义模板弹框
+      function define_temp() {
+          var html = "<%= j(render :partial => 'define_scenario') %>";
+          pop_box_new(html, 400, 400);
+      }
+
+      //下拉框
+      $("[select-for]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
+      $("[select-for]").hover(function () {
+          $(this).find(".down-select").show();
+      }, function () {
+          $(this).find(".down-select").hide();
+      });
+      var $select, hideValue, textValue, $parent;
+      $("[select-for] .down-select p").live("click", function () {
+          $select = $(this).parents(".down-select");
+          hideValue = $(this).attr("data-shixun-value");
+          textValue = $(this).html().trim();
+          $parent = $(this).parent();
+          var parentId = $(this).parent().attr("id");
+          if (parentId != "shixun_scenario_option") {
+              $select.siblings("input[type=hidden]").attr("value", hideValue);
+              $select.siblings("input[type=text]").attr("value", textValue);
+              $parent.hide();
+          }
+          if (parentId == "shixun_language_option") {
+              var mirror_id = $("#shixun_main_language").val();
+              $.ajax({
+                  url: "<%= get_mirror_script_shixuns_path %>",
+                  data: {mirror_id: mirror_id},
+                  success: function (data) {
+                      var lens = data.length;
+                      var htmlContents = "";
+                      $("#shixun_scenario").val("");
+                      $("#shixun_scenario_name").val("");
+                      for (var i = 0; i < lens; i++) {
+                          htmlContents += "<p data-shixun-value=\"" + data[i].mirror_script.id + "\" " + "title=\"" + data[i].mirror_script.script_type + "\">" + data[i].mirror_script.script_type + "</p>"
+                      }
+                      $("#shixun_scenario_option").html(htmlContents);
+                  },
+                  error: function () {
+                      notice_box("获取技术平台失败!")
+                  }
+              });
+          }
+          if (parentId == "shixun_scenario_option") {
+              op_confirm_tip("原有脚本将被新的脚本覆盖,无法撤销<br/>是否确认执行覆盖操作", "get_mirror_script");
+          }
+      });
+
+      $("input[name='webssh']").on("click", function () {
+          if ($(this).val() == 2) {
+              $("#multi_webssh").parent().show();
+          } else {
+              $("#multi_webssh").parent().hide();
+              $("#multi_webssh").attr("checked", false);
+          }
+      });
+
+      /*----------------------------选择镜像小类别--------------*/
+      $("[select-more]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
+      $("[select-more]").hover(function () {
+          $(this).find(".down-select").show();
+      }, function () {
+          $(this).find(".down-select").hide();
+      });
+      $("[select-more] .down-select p input").bind("click", function () {
+          var all = $(this).parents(".down-select");
+          var arr = "";
+          var idarr = [];
+          for (var i = 0; i < all.find("input").length; i++) {
+              if (all.find("input").eq(i).is(':checked')) {
+                  arr += ";" + (all.find("input").eq(i).attr("value"));
+                  idarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
+              }
+          }
+          $("input[name='small_type']").val(idarr);
+          $(this).parents().prev("input").val(arr.substring(1));
+          //$(this).parents(".down-select").hide();
+      });
+
+      $(function () {
+          //选择自定义脚本
+          $("#diy_script").click(function () {
+              var html = "<%= j(render :partial => 'define_scenario') %>";
+              pop_box_new(html, 400, 400);
+          });
+
+          $("#webssh").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+          $("#vnc").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+
+
+          $("#can_copy").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+
+          $("#unlock_test_set").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+
+          $("#code_hidden").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+
+          $("#forbid_copy").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+
+          $("#hide_code").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+
+          $("#task_pass").on("click", function () {
+              $(this).val() == '0' ? $(this).val('1') : $(this).val("0");
+          });
+
+          $("#scope-down-list").find("li").live("click", function () {
+              var ul = $(this).parent("ul");
+              var div = $(this).parents("#unit-input-part");
+              var value = $(this).html();
+              ul.siblings("#for_part_search").val(value);
+
+              var width = value.length * 2;
+              var label = "<label class=\"fl unit-part mb10\"><input type='text' size='" + width + "' id='scope_partment' name='scope_partment[]' readonly value='" + value + "'><span class=\"color-orange03 ml5 eud-pointer\">×</span></label>";
+              div.before(label);
+              ul.siblings("#for_part_search").attr("data-value-was", value);
+              $("#person-unit").hide();
+              $("#scope-down-list").hide();
+          });
+
+          $(".unit-part").find("span").live("click", function () {
+              $(this).parents(".unit-part").remove();
+          });
+
+          if ($("#public-part").is(":checked")) {
+              $("#person-unit").show();
+              $("#person-unit").find("input").val("");
 //            $(".unit-part").remove();
-            $("#unit-all").show();
-        }
-
-        $("input[name='public_degree']").live("click",function(){
-            var item=$(this).attr("id");
-            if($(this).is(":checked") && item == "public-part"){
-                $("#person-unit").show();
-                $("#person-unit").find("input").val("");
-                //$(".unit-part").remove();
-                $("#unit-all").show();
-            }else{
-                $("#unit-all").hide();
-            }
-        });
-
-        $("body").on("click",function(e){
-            //alert($(e.target).attr("id"));
-            if($(e.target).attr("id") != "person-unit"){
-                $("#scope-down-list").hide();
-            }
-        });
-        //设置编辑时显示的单位
-        $(".unit-part input").each(function(){
-            $(this).attr("size",parseInt($(this).val().length)*2);
-        })
-    });
-
-    //申请新建
-    function post_apply() {
-        var html = "<%= escape_javascript(render :partial => 'shixuns/apply_setnew') %>";
-        pop_box_new(html, 460, 416);
-    }
-
-    var setting_editormd =  editormd("setting_introduction", {
-        width   : "100%",
-        height  : 210,
-        syncScrolling : "single",
-        //你的lib目录的路径,我这边用JSP做测试的
-        path    : "/editormd/lib/",
-        tex  : true,
-        toolbarIcons : function() {
-            // Or return editormd.toolbarModes[name]; // full, simple, mini
-            // Using "||" set icons align right.
-            return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
-        },
-        toolbarCustomIcons : {
-            testIcon  : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
-            testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
-        },
-        onload: function(){
-            $("#setting_introduction [type=\"latex\"]").bind("click", function(){
-                setting_editormd.cm.replaceSelection("```latex");
-                setting_editormd.cm.replaceSelection("\n");
-                setting_editormd.cm.replaceSelection("\n");
-                setting_editormd.cm.replaceSelection("```");
-                var __Cursor = setting_editormd.cm.getDoc().getCursor();
-                setting_editormd.cm.setCursor(__Cursor.line-1, 0);
-            });
-
-            $("#setting_introduction [type=\"inline\"]").bind("click", function(){
-                setting_editormd.cm.replaceSelection("$$$$");
-                var __Cursor = setting_editormd.cm.getDoc().getCursor();
-                setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
-                setting_editormd.cm.focus();
-            });
-            $("[type=\"inline\"]").attr("title", "行内公式");
-            $("[type=\"latex\"]").attr("title", "多行公式");
-
-        },
-        //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
-        saveHTMLToTextarea : true,
-        autoFocus: false,
-        // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
-        dialogMaskOpacity : 0.6,
-        placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息",
-        imageUpload : true,
-        imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
-        imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url
-    });
-    md_elocalStorage(setting_editormd, "shixun_edit_<%= User.current.id %>", "in");
-
-    var script_Codemirror = CodeMirror.fromTextArea(document.getElementById("shixun_script"), {
-        lineNumbers: true,
-        theme: "default",
-        // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
-        indentUnit: 4, //代码缩进为一个tab的距离
-        matchBrackets: true,
-        autoRefresh: true,
-        smartIndent: true,//智能换行
-        styleActiveLine: true,
-        lint: true
-    });
-    script_Codemirror.setSize("auto","600px");
-    // 非管理员只能查看
-</script>
\ No newline at end of file
+              $("#unit-all").show();
+          }
+
+          $("input[name='public_degree']").live("click", function () {
+              var item = $(this).attr("id");
+              if ($(this).is(":checked") && item == "public-part") {
+                  $("#person-unit").show();
+                  $("#person-unit").find("input").val("");
+                  //$(".unit-part").remove();
+                  $("#unit-all").show();
+              } else {
+                  $("#unit-all").hide();
+              }
+          });
+
+          $("body").on("click", function (e) {
+              //alert($(e.target).attr("id"));
+              if ($(e.target).attr("id") != "person-unit") {
+                  $("#scope-down-list").hide();
+              }
+          });
+          //设置编辑时显示的单位
+          $(".unit-part input").each(function () {
+              $(this).attr("size", parseInt($(this).val().length) * 2);
+          })
+      });
+
+      //申请新建
+      function post_apply() {
+          var html = "<%= escape_javascript(render :partial => 'shixuns/apply_setnew') %>";
+          pop_box_new(html, 460, 416);
+      }
+
+      var setting_editormd = editormd("setting_introduction", {
+          width: "100%",
+          height: 210,
+          syncScrolling: "single",
+          //你的lib目录的路径,我这边用JSP做测试的
+          path: "/editormd/lib/",
+          tex: true,
+          toolbarIcons: function () {
+              // Or return editormd.toolbarModes[name]; // full, simple, mini
+              // Using "||" set icons align right.
+              return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]
+          },
+          toolbarCustomIcons: {
+              testIcon: "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
+              testIcon1: "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
+          },
+          onload: function () {
+              $("#setting_introduction [type=\"latex\"]").bind("click", function () {
+                  setting_editormd.cm.replaceSelection("```latex");
+                  setting_editormd.cm.replaceSelection("\n");
+                  setting_editormd.cm.replaceSelection("\n");
+                  setting_editormd.cm.replaceSelection("```");
+                  var __Cursor = setting_editormd.cm.getDoc().getCursor();
+                  setting_editormd.cm.setCursor(__Cursor.line - 1, 0);
+              });
+
+              $("#setting_introduction [type=\"inline\"]").bind("click", function () {
+                  setting_editormd.cm.replaceSelection("$$$$");
+                  var __Cursor = setting_editormd.cm.getDoc().getCursor();
+                  setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch - 2);
+                  setting_editormd.cm.focus();
+              });
+              $("[type=\"inline\"]").attr("title", "行内公式");
+              $("[type=\"latex\"]").attr("title", "多行公式");
+
+          },
+          //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
+          saveHTMLToTextarea: true,
+          autoFocus: false,
+          // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
+          dialogMaskOpacity: 0.6,
+          placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息",
+          imageUpload: true,
+          imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
+          imageUploadURL: "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url
+      });
+      md_elocalStorage(setting_editormd, "shixun_edit_<%= User.current.id %>", "in");
+
+      var script_Codemirror = CodeMirror.fromTextArea(document.getElementById("shixun_script"), {
+          lineNumbers: true,
+          theme: "default",
+          // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
+          indentUnit: 4, //代码缩进为一个tab的距离
+          matchBrackets: true,
+          autoRefresh: true,
+          smartIndent: true,//智能换行
+          styleActiveLine: true,
+          lint: true
+      });
+      script_Codemirror.setSize("auto", "600px");
+      // 非管理员只能查看
+  </script>
\ No newline at end of file
diff --git a/db/migrate/20190626064125_create_shixun_service_configs.rb b/db/migrate/20190626064125_create_shixun_service_configs.rb
new file mode 100644
index 00000000..a15a30f6
--- /dev/null
+++ b/db/migrate/20190626064125_create_shixun_service_configs.rb
@@ -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
diff --git a/db/migrate/20190626070641_add_limit_for_shixuns.rb b/db/migrate/20190626070641_add_limit_for_shixuns.rb
new file mode 100644
index 00000000..1de29c80
--- /dev/null
+++ b/db/migrate/20190626070641_add_limit_for_shixuns.rb
@@ -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
diff --git a/spec/factories/shixun_service_configs.rb b/spec/factories/shixun_service_configs.rb
new file mode 100644
index 00000000..e1467908
--- /dev/null
+++ b/spec/factories/shixun_service_configs.rb
@@ -0,0 +1,5 @@
+FactoryGirl.define do
+  factory :shixun_service_config do
+    
+  end
+end
diff --git a/spec/models/shixun_service_config_spec.rb b/spec/models/shixun_service_config_spec.rb
new file mode 100644
index 00000000..ca83dde1
--- /dev/null
+++ b/spec/models/shixun_service_config_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ShixunServiceConfig, :type => :model do
+  pending "add some examples to (or delete) #{__FILE__}"
+end