ajax获取结果
This commit is contained in:
parent
50f5c4a735
commit
5a1284e42d
|
@ -66,30 +66,30 @@ class GamesController < ApplicationController
|
|||
gitUrl = Base64.encode64(gitUrl)
|
||||
taskId = params[:id]
|
||||
jobName = "myshixun_#{@myshixun.id}"
|
||||
input = {}
|
||||
output = {}
|
||||
test_sets = @game.test_sets
|
||||
unless test_sets.blank?
|
||||
test_sets.each_with_index do |test_set, index|
|
||||
input.store("input_#{index}",test_set.try(:input))
|
||||
output.store("output_#{index}",test_set.try(:output))
|
||||
end
|
||||
end
|
||||
# input = {}
|
||||
# output = {}
|
||||
# test_sets = @game.test_sets
|
||||
# unless test_sets.blank?
|
||||
# test_sets.each_with_index do |test_set, index|
|
||||
# input.store("input_#{index}",test_set.try(:input))
|
||||
# output.store("output_#{index}",test_set.try(:output))
|
||||
# end
|
||||
# end
|
||||
|
||||
step = @game.stage
|
||||
if @game.status == 0
|
||||
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}", :input => input, :output => output }
|
||||
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}"}
|
||||
uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob")
|
||||
res = uri_exec uri, params
|
||||
@game.update_attribute(:status, 1)
|
||||
|
||||
@outputs = @game.outputs
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def game_status
|
||||
render :json => {status: @game.status}
|
||||
@outputs = @game.outputs
|
||||
render :json => {status: @game.status, outputs: @outputs}
|
||||
end
|
||||
|
||||
# 自动推送下一个任务
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
</div>
|
||||
<div class="content-submitbox">
|
||||
<a href="javascript:void(0)" class="task-btn mb10" onclick="file_edit_submit()">保存修改</a>
|
||||
|
||||
|
||||
<! if(status == 0){ !>
|
||||
<div id="game_commit">
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-green" onclick="training_task_submmit();">提交评测</a>
|
||||
|
@ -84,9 +86,9 @@
|
|||
function training_task_submmit(){
|
||||
|
||||
$.ajax({
|
||||
url: '<%= game_build_myshixun_game_path(@game, @myshixun) %>',
|
||||
url: '<%= game_build_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
|
||||
success: function (){
|
||||
$("#training_tasl_commit").html("<span class='task-display-span alert-blue mt10'>当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>");
|
||||
// $("#training_tasl_commit").html("<span class='task-display-span alert-blue mt10'>当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>");
|
||||
//循环等1分钟
|
||||
var intId = setInterval(function(){
|
||||
$.ajax({
|
||||
|
@ -96,7 +98,7 @@
|
|||
//如果查到了,就退出
|
||||
alert(data.status);
|
||||
clearInterval(intId);
|
||||
var html = bt('t:exec_results',{status: 2});
|
||||
var html = bt('t:exec_results', data);
|
||||
console.log(html);
|
||||
$("#code_results").html(html);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue