Merge branch 'dev_shixun_project' of https://git.trustie.net/jacknudt/trustieforge into dev_shixun_project
This commit is contained in:
commit
1f6751a80c
|
@ -2,7 +2,7 @@ class GamesController < ApplicationController
|
|||
layout "base_myshixun"
|
||||
skip_before_filter :verify_authenticity_token, :only => [:file_update]
|
||||
before_filter :find_myshixun, :only => [:index]
|
||||
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, :game_status]
|
||||
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, :game_status, :change_status]
|
||||
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update]
|
||||
before_filter :allowd_manager
|
||||
include ApplicationHelper
|
||||
|
@ -120,6 +120,17 @@ class GamesController < ApplicationController
|
|||
render :json => {status: @game.status, output: latest_output, results: outputs, had_done: had_done}
|
||||
end
|
||||
|
||||
def change_status
|
||||
@game.update_attribute(:status, 0)
|
||||
outputs = @game.outputs
|
||||
if outputs.count == 0
|
||||
outputs = ""
|
||||
else
|
||||
outputs = outputs.map{|result| [result.code, result.id]}
|
||||
end
|
||||
render :json => {status: @game.status, output: latest_output, results: outputs, had_done: had_done}
|
||||
end
|
||||
|
||||
# 自动推送下一个任务
|
||||
def next_step
|
||||
render_403 if @game.status != 2
|
||||
|
|
|
@ -35,12 +35,7 @@ class ShixunsController < ApplicationController
|
|||
s = Trustie::Gitlab::Sync.new
|
||||
s.sync_user(User.current)
|
||||
end
|
||||
if @shixun.gpid
|
||||
gshixun = g.project(@shixun.gpid)
|
||||
else
|
||||
gshixun = g.fork(@shixun.gpid, User.current.gid)
|
||||
end
|
||||
|
||||
gshixun = g.fork(@shixun.gpid, User.current.gid)
|
||||
if gshixun.id
|
||||
myshixun = copy_myshixun(@shixun, gshixun)
|
||||
challenges = @shixun.challenges
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
$("#code_results").html(html);
|
||||
});
|
||||
function training_task_submmit(){
|
||||
var i = 0;
|
||||
$("#ajax-indicator").show();
|
||||
$("#game_commit").html("<a class='task-btn mb10'>评测中..</a>");
|
||||
$.ajax({
|
||||
|
@ -105,20 +106,36 @@
|
|||
var temp = $("#ajax-indicator");
|
||||
$("#ajax-indicator").remove();
|
||||
var intId = setInterval(function(){
|
||||
$.ajax({
|
||||
url: '<%= game_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
|
||||
data:'test',
|
||||
success:function(data){
|
||||
//如果查到了,就退出
|
||||
if(data.status == 2 || data.status == 0){
|
||||
clearInterval(intId);
|
||||
$("#ajax-position").html(temp);
|
||||
$("#ajax-indicator").hide();
|
||||
var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done});
|
||||
$("#code_results").html(html);
|
||||
}
|
||||
}
|
||||
});
|
||||
var ajaxTimeoutTest = $.ajax({
|
||||
url: '<%= game_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
|
||||
timeout : 50000,
|
||||
data:'test',
|
||||
success:function(data){
|
||||
//如果查到了,就退出
|
||||
i = i + 1;
|
||||
if(data.status == 2 || data.status == 0){
|
||||
clearInterval(intId);
|
||||
$("#ajax-position").html(temp);
|
||||
$("#ajax-indicator").hide();
|
||||
var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done});
|
||||
$("#code_results").html(html);
|
||||
}
|
||||
if(i == 30){
|
||||
$.ajax({
|
||||
url: '<%= change_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
|
||||
success:function(data){
|
||||
clearInterval(intId);
|
||||
var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done});
|
||||
$("#code_results").html(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
complete: function(XMLHttpRequest,status){if(status=='timeout'){
|
||||
ajaxTimeoutTest.abort();
|
||||
clearInterval(intId);
|
||||
}}
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,33 +7,17 @@
|
|||
<div class="sy_popup_con" style="width:380px;">
|
||||
<ul class="sy_popup_add" >
|
||||
<li class="center mb30" style="line-height:20px">
|
||||
确定开启后,将开始计算耗时<br/>请问是否确定继续?
|
||||
您将离开此页面<br/>请问是否确定继续?
|
||||
</li>
|
||||
<div class="task-popup-submit clearfix">
|
||||
<a href="javascript:void(0);" class="task-btn fl" onclick="hideModal()">取消</a>
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="close_web();">确定</a>
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="hideModal();close_web();">确定</a>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function close_web(){
|
||||
if (navigator.userAgent.indexOf("MSIE") > 0) { //IE浏览器
|
||||
if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
|
||||
window.opener = null; window.close();
|
||||
}
|
||||
else {
|
||||
window.open('', '_top'); window.top.close();
|
||||
}
|
||||
}
|
||||
else if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Chrome") > 0 ) { //火狐浏览器和谷歌
|
||||
window.location.href = 'about:blank';
|
||||
//window.history.go(-2);
|
||||
}
|
||||
else { //其他浏览器
|
||||
window.opener = null;
|
||||
window.open('', '_self', '');
|
||||
window.close();
|
||||
}
|
||||
window.location.href = '<%= user_path(User.current) %>';
|
||||
}
|
||||
</script>
|
|
@ -4,7 +4,7 @@
|
|||
<ul class="rightbar-score fr" >
|
||||
<!--<li><i class="fa fa-signal font-14 mr5"></i>排名:<a href="#" class="">123</a></li>-->
|
||||
<li><i class="fa fa-trophy font-14 mr5"></i>积分:<a class=""><%= shixun_final_score(@myshixun).first.try(:score) %></a></li>
|
||||
<li><i class="fa fa-clock-o font-14 mr5"></i>耗时:<a class=""><%= game_avg_hour(@game.created_at, @game.updated_at) %>:<%= game_avg_min(@game.created_at, @game.updated_at) %></a></li>
|
||||
<!--<li><i class="fa fa-clock-o font-14 mr5"></i>耗时:<a class=""><%#= game_avg_hour(@game.created_at, @game.updated_at) %>:<%#= game_avg_min(@game.created_at, @game.updated_at) %></a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
<script>
|
||||
|
|
|
@ -71,6 +71,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'entry'
|
||||
get 'outputs_show'
|
||||
get 'game_status'
|
||||
get 'change_status'
|
||||
post 'file_update'
|
||||
get 'file_edit'
|
||||
end
|
||||
|
|
|
@ -173,5 +173,3 @@ input.knowledge_frame{height:30px;line-height:30px;border:none;background:#f3f5f
|
|||
|
||||
.autoscroll_new{ overflow:auto; }
|
||||
.autoscroll_extend{ overflow:auto; }
|
||||
.ke-edit-iframe{line-height: 1.9;}
|
||||
.task-bg-grey{line-height: 1.9;}
|
||||
|
|
Loading…
Reference in New Issue