实训任务
This commit is contained in:
parent
e098f7abf6
commit
da131b7a0a
|
@ -91,7 +91,7 @@ class GamesController < ApplicationController
|
|||
def game_status
|
||||
@outputs = @game.outputs
|
||||
@latest_output = @game.latest_output.try(:out_put)
|
||||
render :json => {status: @game.status, outputs: @outputs, latest_output:@latest_output}
|
||||
render :json => {status: @game.status, outputs: @outputs, latest_output:@latest_output}
|
||||
end
|
||||
|
||||
# 自动推送下一个任务
|
||||
|
|
|
@ -2,56 +2,7 @@
|
|||
<%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %>
|
||||
<% end %>
|
||||
<div id="code_results">
|
||||
<div class=" col-width fl content-history mt15" >
|
||||
<div class="panel-header clearfix">
|
||||
<h3 class="fl">测评历史</h3>
|
||||
<div class="fr mt5">
|
||||
<a href="#"><i class="fa fa-minus font-14 mr10 fl color-grey"></i></a>
|
||||
<a href="#"><i class="fa fa-minus-square font-14 fl color-grey"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-history-inner">
|
||||
<% unless @outputs.blank? %>
|
||||
<% @outputs.each do |output| %>
|
||||
<div class="<%= output.code == 0 ? 'clearfix history-success mb10' : 'clearfix history-fail mb10' %>">
|
||||
<span class="<%= output.code == 0 ? 'icon-success fl mr5' : 'icon-fail fl mr5' %>">2</span>
|
||||
<p class="fl"><%= output.code == 0 ? '恭喜,您已经完成了本任务!' : '错误结果!' %></p>
|
||||
<%= link_to "详情", outputs_show_myshixun_game_path(@game, :myshixun_id => @myshixun, :game_output_id => output.id), :class => "fr mr10" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class=" col-width fl content-output ml15 mt15">
|
||||
<div class="panel-header ">
|
||||
<h3 >测试输出</h3>
|
||||
</div>
|
||||
<div class="content-history-inner">
|
||||
<% unless @latest_output.nil? %>
|
||||
<%= @latest_output.try(:out_put) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class=" col-width fl content-submit ml15 mt15">
|
||||
<div class="panel-header ">
|
||||
<h3 >操作</h3>
|
||||
</div>
|
||||
<div class="content-submitbox">
|
||||
<a href="#" class="task-btn mb10 ">保存修改</a>
|
||||
<% if @game.status == 0 %>
|
||||
<div id="game_commit">
|
||||
<%= link_to "提交评测", {:controller => 'games', :action => "game_build", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
|
||||
</div>
|
||||
<% elsif @game.status == 1 %>
|
||||
<a class="task-btn mb10">评测中..</a>
|
||||
<% elsif @game.status == 2 %>
|
||||
<%= link_to "下 一 步", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script id="t:exec_results" type="text/html">
|
||||
<div class="col-width fl mt15 content-half-fix undis" style="margin-top:125px;">
|
||||
<div class="panel-header clearfix">
|
||||
|
@ -99,7 +50,11 @@
|
|||
<h3 >测试输出</h3>
|
||||
</div>
|
||||
<div class="content-history-inner">
|
||||
<! data.latest_output !>
|
||||
<% unless @outputs.blank? %>
|
||||
<% @outputs.each do |output| %>
|
||||
<%= output.out_put %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-width fl content-submit ml15 mt15">
|
||||
|
@ -108,14 +63,13 @@
|
|||
</div>
|
||||
<div class="content-submitbox">
|
||||
<a href="javascript:void(0)" class="task-btn mb10" onclick="file_edit_submit()">保存修改</a>
|
||||
|
||||
<! if(data.status == 0){ !>
|
||||
<! if(status == 0){ !>
|
||||
<div id="game_commit">
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-green" onclick="training_task_submmit();">提交评测</a>
|
||||
</div>
|
||||
<! }else if(data.status == 1){ !>
|
||||
<! }else if(status == 1){ !>
|
||||
<a class="task-btn mb10">评测中..</a>
|
||||
<! }else if(data.status == 2){ !>
|
||||
<! }else if(status == 2){ !>
|
||||
<%= link_to "下 一 步", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
|
||||
<! } !>
|
||||
</div>
|
||||
|
@ -123,11 +77,19 @@
|
|||
</script>
|
||||
|
||||
<script >
|
||||
var bt = baidu.template;
|
||||
bt.LEFT_DELIMITER = '<!';
|
||||
bt.RIGHT_DELIMITER = '!>';
|
||||
$(function(){
|
||||
var html = bt('t:exec_results',{status: <%= @game.status %>});
|
||||
$("#code_results").html(html);
|
||||
});
|
||||
|
||||
function training_task_submmit(){
|
||||
$.ajax({
|
||||
url: '<%= game_build_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
|
||||
url: '<%= game_build_myshixun_game_path(@game, @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({
|
||||
|
@ -135,13 +97,14 @@
|
|||
data:'test',
|
||||
success:function(data){
|
||||
//如果查到了,就退出
|
||||
alert(data.outputs);
|
||||
alert(data.status);
|
||||
alert(data.latest_output);
|
||||
clearInterval(intId);
|
||||
var html = bt('t:exec_results', data);
|
||||
console.log(html);
|
||||
$("#code_results").html(html);
|
||||
if(data.status == 2 || data.status == 1){
|
||||
alert("进来了");
|
||||
clearInterval(intId);
|
||||
var html = bt('t:exec_results',{status: data.status});
|
||||
console.log(html);
|
||||
$("#code_results").html(html);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 6000);
|
||||
|
|
Loading…
Reference in New Issue