From 62b579df71871cf06d388db9652e67f640362f63 Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 16 Apr 2017 10:16:36 +0800 Subject: [PATCH] =?UTF-8?q?game=E7=BB=93=E6=9E=9C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 15 +-- app/controllers/myshixuns_controller.rb | 40 +++--- app/views/challenges/_form.html.erb | 68 ++-------- app/views/games/_game_results.html.erb | 165 ++++++++++++++++++++++- 4 files changed, 196 insertions(+), 92 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index d939f02f5..6b0efec93 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -27,15 +27,8 @@ class ChallengesController < ApplicationController ActiveRecord::Base.transaction do begin @challenge.save! - if params[:sample][:input].length > 0 - params[:sample][:input].each_with_index do |value, index| - unless (value == params[:sample][:output][index] && value.blank?) - ChallengeSample.create(:challenge_id => @challenge.id, :input => value, :output => params[:sample][:output][index]) - end - end - end - if params[:program][:output].length > 0 - params[:program][:output].each do |output| + if params[:test_set][:output].length > 0 + params[:test_set][:output].each do |output| TestSet.create(:challenge_id => @challenge.id, :input => nil, :output => output) end end @@ -45,11 +38,10 @@ class ChallengesController < ApplicationController end end # 向jenkins端发送请求,构建pipeline片段,实时返回结果 -=begin begin jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] params = {:shixunType => "#{@challenge.evaluation_way.to_i}", :filePath => "#{@challenge.path}", :step => "#{@challenge.position}", :challengeId => "#{@challenge.id}"} - uri = URI("#{jenkins_shixuns}/jenkins-exec/api/generateScriptPerChallenge") + uri = URI("#{jenkins_shixuns}/jenkins-exec/api/generatePipelineScriptForEachChallenge") res = uri_exec uri, params if res.blank? raise("jenkins服务器异常") @@ -57,7 +49,6 @@ class ChallengesController < ApplicationController rescue raise("jenkins服务器异常") end -=end respond_to do |format| format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '创建成功!'} end diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index b8df444b3..4d274d0bf 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -10,26 +10,26 @@ class MyshixunsController < ApplicationController # output 为测试用户编译输出结果 # myshixun:status 1为完成实训 def training_task_status - status = params[:status].to_i - task_id = params[:taskId] - outPut = Base64.decode64(params[:outPut]) unless params[:outPut].blank? - message = Base64.decode64(params[:msg]) unless params[:msg].blank? - game = Game.find(task_id) - challenge = game.challenge - if status == 0 - myshixun = game.myshixun - games_count = myshixun.games.count - if challenge.position == games_count - myshixun.update_attribute(:status, 1) - end - game_outputs = Output.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut) - game.update_attribute(:status, 2) - game.update_attribute(:final_score, challenge.score) - else - game_outputs = Output.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut) - game.update_attribute(:status, 0) - end - render :json => {:data => "success"} + # status = params[:status].to_i + # task_id = params[:taskId] + # outPut = Base64.decode64(params[:outPut]) unless params[:outPut].blank? + # message = Base64.decode64(params[:msg]) unless params[:msg].blank? + # game = Game.find(task_id) + # challenge = game.challenge + # if status == 0 + # myshixun = game.myshixun + # games_count = myshixun.games.count + # if challenge.position == games_count + # myshixun.update_attribute(:status, 1) + # end + # game_outputs = Output.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut) + # game.update_attribute(:status, 2) + # game.update_attribute(:final_score, challenge.score) + # else + # game_outputs = Output.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut) + # game.update_attribute(:status, 0) + # end + # render :json => {:data => "success"} end def show diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index daf25b887..ee726f84b 100644 --- a/app/views/challenges/_form.html.erb +++ b/app/views/challenges/_form.html.erb @@ -81,25 +81,15 @@
  • - 锁定 + 锁定

    - - -
  • - - +
  • @@ -142,7 +132,7 @@
  • 组<%= index + 1 %> - 锁定 + 锁定 <% if index == 0 %> 温馨提示:选中“锁定”,则对学员隐藏该条测试集,但在“提交评测”时也将被自动检测。 <% end %> @@ -151,8 +141,8 @@ <% end %>

    - - + +
  • <% end %> @@ -163,53 +153,15 @@

    组1 温馨提示:选中“锁定”,则对学员隐藏该条测试集,但在“提交评测”时也将被自动检测。 - 锁定 + 锁定

    - - + + <% end %> -
  • - <% if params[:action] == "edit" && @challenge.test_sets.count > 0 %> - -
      - <% @challenge.test_sets.each_with_index do |test, index| %> -
    • -

      - 测试集<%= index + 1 %> - <% if index == 0%> - 温馨提示:在学员"提交评测"时进行自动检测。 - <% end %> - - <% if index > 0 %> - - <% end %> -

      - - -
    • - <% end %> -
    - <% else %> - -
      -
    • -

      - 测试集1 - 温馨提示:在学员"提交评测"时进行自动检测。 - -

      - - -
    • -
    - <% end %> -
  • - -
  • diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index e96b7e0a6..510925e0f 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -1,3 +1,6 @@ +<%= content_for(:header_tags) do %> + <%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %> +<% end %>
    -
    +
    + + + +
    @@ -35,8 +43,8 @@
  • 期望输出:<%= test_set.output %>
  • - <% end %> + <% end %> @@ -68,4 +76,157 @@ $("#test_case_"+id).toggle(); } } + + + + + + + + + + + \ No newline at end of file