diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index a2c2da8bf..adb37e2fc 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -42,19 +42,19 @@ class ChallengesController < ApplicationController end end # 向jenkins端发送请求,构建pipeline片段,实时返回结果 - jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] - params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.exec_path}", :trainingID => "#{@shixun.id}", :operationEnvironment => @shixun.language} - uri = URI("#{jenkins_shixuns}/jenkins-exec/game/generatePipelineScriptForChallenge") - res = uri_exec uri, {challengeInfo: params.to_json} - if res && res['code'] == 0 - @challenge.update_attribute(:pipeline_script, res['msg']) - respond_to do |format| - format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)} - end - else - logger.error("res['code'] is #{res['code']}, res['msg'] is #{res['msg']}") - raise("实训云平台繁忙(繁忙等级:116)") - end + # jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] + # params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.exec_path}", :trainingID => "#{@shixun.id}", :operationEnvironment => @shixun.language} + # uri = URI("#{jenkins_shixuns}/jenkins-exec/game/generatePipelineScriptForChallenge") + # res = uri_exec uri, {challengeInfo: params.to_json} + # if res && res['code'] == 0 + # @challenge.update_attribute(:pipeline_script, res['msg']) + # respond_to do |format| + # format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)} + # end + # else + # logger.error("res['code'] is #{res['code']}, res['msg'] is #{res['msg']}") + # raise("实训云平台繁忙(繁忙等级:116)") + # end rescue Exception => e flash[:error] = "#{e.message}" redirect_to new_shixun_challenge_path(:shixun_id => @shixun) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f3a49c43a..4efdc93f1 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -171,20 +171,7 @@ class ShixunsController < ApplicationController testSet = [] testCases = [] begin - challenges = @shixun.challenges.includes(:test_sets) - challenges.each do |challenge| - pipeline_script = challenge.try(:pipeline_script) - challenge_script = {:challengeStage => "#{challenge.position}", :challengePipeline => "#{pipeline_script}"} - fragments << challenge_script - # 每一关所有的测试集 - challenge.test_sets.each do |test_set| - test_cases = {:caseId => test_set.id.to_s, :input => test_set.input, :output => test_set.output, :isPublic => (test_set.is_public ? "1" : "0")} - testSet << test_cases - end - test_sets_list = {:challengeStage => challenge.position.to_s, :challengeTestCases => testSet} - testCases << test_sets_list - testSet = [] - end + testCases = @shixun.test_sets gameInfo = {:trainingID => @shixun.id.to_s, :operationEnvironment => @shixun.language, :challengePipelines => fragments, :testCases => testCases} uri = URI("#{jenkins_shixuns}/jenkins-exec/game/publishGame") params = {gameInfo:gameInfo.to_json} @@ -197,6 +184,7 @@ class ShixunsController < ApplicationController @jenkin_error = true end rescue Exception => e + @jenkin_error = true logger.error("pushlish game #{e}") respond_to do |format| format.js diff --git a/db/migrate/20170619091405_add_is_modified_to_shixun.rb b/db/migrate/20170619091405_add_is_modified_to_shixun.rb new file mode 100644 index 000000000..8cca908bd --- /dev/null +++ b/db/migrate/20170619091405_add_is_modified_to_shixun.rb @@ -0,0 +1,5 @@ +class AddIsModifiedToShixun < ActiveRecord::Migration + def change + add_column :shixuns, :is_updated, :integer, :default => 0, :limit => 1 + end +end