Merge branch 'dev_shixun_project' of https://git.trustie.net/jacknudt/trustieforge into dev_shixun_project
This commit is contained in:
commit
587b4b73e0
|
@ -17,10 +17,21 @@ class GamesController < ApplicationController
|
|||
end
|
||||
|
||||
# mushixun的版本库必须创建时就创建
|
||||
# 首次进入版本库自动打开文件
|
||||
# path:"" && path: @game.path
|
||||
def show
|
||||
game_path = (@game.path.blank? ? @game.path : @game.path.strip)
|
||||
@rev = @rev.nil? ? "master" : @rev
|
||||
@git_url = git_repository_url(@myshixun, "Myshixun")
|
||||
@entries = @repository.entries(@path, @rev)
|
||||
@type = params[:type]
|
||||
# 默认打开文件
|
||||
if @path == "" && !game_path.nil? && !@repository.cat(game_path, @rev).blank? && @type != "root"
|
||||
@path = game_path
|
||||
@file_open = true
|
||||
@content = @repository.cat(@path, @rev)
|
||||
else
|
||||
@entries = @repository.entries(@path, @rev)
|
||||
end
|
||||
@latest_output = @game.latest_output.try(:out_put)
|
||||
outputs = @game.outputs
|
||||
@had_done = 1 if (@myshixun.games.count == @game.stage && @game.status ==2)
|
||||
|
@ -33,6 +44,8 @@ class GamesController < ApplicationController
|
|||
format.html
|
||||
format.js
|
||||
end
|
||||
rescue Exception => e
|
||||
flash[:error] = e.message
|
||||
end
|
||||
|
||||
# 代码预览
|
||||
|
@ -47,9 +60,9 @@ class GamesController < ApplicationController
|
|||
def file_edit
|
||||
entry_and_raw(false)
|
||||
@content = @repository.cat(@path, @rev).rstrip
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
# respond_to do |format|
|
||||
# format.js
|
||||
# end
|
||||
end
|
||||
|
||||
def file_update
|
||||
|
|
|
@ -95,34 +95,33 @@
|
|||
var html = bt('t:exec_results',{status: <%= @game.status %>, output:"<%= @latest_output %>", results: <%= @results %>, had_done: "<%= @had_done %>"});
|
||||
$("#code_results").html(html);
|
||||
});
|
||||
|
||||
function training_task_submmit(){
|
||||
$("#ajax-indicator").show();
|
||||
$("#game_commit").html("<a class='task-btn mb10'>评测中..</a>");
|
||||
$.ajax({
|
||||
url: '<%= game_build_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
|
||||
success: function (){
|
||||
|
||||
//循环等1分钟
|
||||
//移除载入
|
||||
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){
|
||||
//如果查到了,就退出
|
||||
console.log(html);
|
||||
if(data.status == 2 || data.status == 0){
|
||||
alert("进来了");
|
||||
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});
|
||||
console.log(html);
|
||||
$("#code_results").html(html);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
}
|
||||
function extend_window(){
|
||||
var web_h = window.innerHeight;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% if @path.blank? %>
|
||||
<%= @repository.identifier %>
|
||||
<% else %>
|
||||
<%= link_to "#{@repository.identifier.present? ? h(@repository.identifier) : 'root'}", myshixun_game_path(@game, :myshixun_id => @myshixun) %>
|
||||
<%= link_to "#{@repository.identifier.present? ? h(@repository.identifier) : 'root'}", myshixun_game_path(@game, :myshixun_id => @myshixun, :type => "root"), :remote => true %>
|
||||
<%
|
||||
dirs = path.split('/')
|
||||
if 'file' == kind
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="panel-header clearfix" style="border: none">
|
||||
<h3 class="fl"><%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h3>
|
||||
<div class="fr mt5">
|
||||
<% if params[:action] == "entry" %>
|
||||
<% if params[:action] == "entry" || @file_open %>
|
||||
<a href="javascript:void(0)" class="undis" id="sava_edit_btn" onclick="file_edit_submit()" title="保存修改"><i class="fa fa-save font-18 fl color-grey mr10"></i></a>
|
||||
<a href="<%= file_edit_myshixun_game_path(@game, :myshixun_id => @myshixun, :path => params[:path]) %>" data-remote="true" ><i class="fa fa-edit font-18 fl color-grey mr10"></i></a>
|
||||
<% end %>
|
||||
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="content-history-extend">
|
||||
<% if params[:action] == "entry" %>
|
||||
<% if params[:action] == "entry" || @file_open %>
|
||||
<div id="file_entry_content_inner">
|
||||
<%= render :partial => 'common/extend_file', :locals => {:filename => @path, :content => @content, :extend => true} %>
|
||||
</div>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
|
||||
</h3>
|
||||
<div class="fr mt5">
|
||||
<% if params[:action] == "entry" %>
|
||||
<% if params[:action] == "entry" || @file_open %>
|
||||
<a href="javascript:void(0)" class="undis" id="sava_edit_btn1" onclick="file_edit_submit()" title="保存修改"><i class="fa fa-save font-18 fl color-grey mr10"></i></a>
|
||||
<a href="javascript:void(0)" class="undis" id="sava_edit_btn1" onclick="file_edit_submit()"><i class="fa fa-save font-18 fl color-grey mr10"></i></a>
|
||||
<a href="<%= file_edit_myshixun_game_path(@game, :myshixun_id => @myshixun, :path => params[:path]) %>" data-remote="true" ><i class="fa fa-edit font-18 fl color-grey mr10"></i></a>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="content-editor-inner">
|
||||
<% if params[:action] == "entry" %>
|
||||
<% if params[:action] == "entry" || @file_open %>
|
||||
<div id="file_entry_content">
|
||||
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %>
|
||||
</div>
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %>
|
||||
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
|
||||
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
|
||||
<%= form_tag(:controller => 'games', :action => 'file_update', :id => @game, :myshixun_id => @myshixun) do%>
|
||||
<li class="clearfix" xmlns="http://www.w3.org/1999/html">
|
||||
<label class=" panel-form-label fl"> 参考答案:</label>
|
||||
<textarea class = "panel-form-width-690 panel-form-height-150 fl task-textarea-pd">
|
||||
<%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %>
|
||||
</textarea>
|
||||
<script>
|
||||
var text = document.getElementById("challenge-answer");
|
||||
</script>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<script type="text/javascript">
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("challenge-answer"), {
|
||||
mode: {name: 'text/x-java',
|
||||
version: 2,
|
||||
singleLineStringErrors: false},
|
||||
lineNumbers: true,
|
||||
indentUnit: 2,
|
||||
matchBrackets: true
|
||||
});
|
||||
|
||||
editor.on('change',function(cMirror){
|
||||
// get value right from instance
|
||||
$('#challenge-answer').val(cMirror.getValue());
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
|
@ -48,9 +48,11 @@
|
|||
<%= yield %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ajax-position">
|
||||
<div id="ajax-indicator" style="display:none;">
|
||||
<span><%= l(:label_loading) %></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ajax-modal" style="display:none;"></div>
|
||||
</body>
|
||||
<!-- MathJax的配置 -->
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddPathToGames < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :games, :path, :string
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20170323081518) do
|
||||
ActiveRecord::Schema.define(:version => 20170324054735) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1091,6 +1091,7 @@ ActiveRecord::Schema.define(:version => 20170323081518) do
|
|||
t.text "answer"
|
||||
t.integer "score"
|
||||
t.integer "final_score", :default => 0
|
||||
t.string "path"
|
||||
end
|
||||
|
||||
create_table "groups_users", :id => false, :force => true do |t|
|
||||
|
|
|
@ -62,18 +62,18 @@ module Gitlab
|
|||
# Checks the response code for common errors.
|
||||
# Returns parsed response for successful requests.
|
||||
def validate(response)
|
||||
case response.code
|
||||
when 400; raise Error::BadRequest.new error_message(response)
|
||||
when 401; raise Error::Unauthorized.new error_message(response)
|
||||
when 403; raise Error::Forbidden.new error_message(response)
|
||||
when 404; raise Error::NotFound.new error_message(response)
|
||||
when 405; raise Error::MethodNotAllowed.new error_message(response)
|
||||
when 406; raise Error::DataNotAccepted.new error_message(response)
|
||||
when 409; raise Error::Conflict.new error_message(response)
|
||||
when 500; raise Error::InternalServerError.new error_message(response)
|
||||
when 502; raise Error::BadGateway.new error_message(response)
|
||||
when 503; raise Error::ServiceUnavailable.new error_message(response)
|
||||
end
|
||||
# case response.code
|
||||
# when 400; raise Error::BadRequest.new error_message(response)
|
||||
# when 401; raise Error::Unauthorized.new error_message(response)
|
||||
# when 403; raise Error::Forbidden.new error_message(response)
|
||||
# when 404; raise Error::NotFound.new error_message(response)
|
||||
# when 405; raise Error::MethodNotAllowed.new error_message(response)
|
||||
# when 406; raise Error::DataNotAccepted.new error_message(response)
|
||||
# when 409; raise Error::Conflict.new error_message(response)
|
||||
# when 500; raise Error::InternalServerError.new error_message(response)
|
||||
# when 502; raise Error::BadGateway.new error_message(response)
|
||||
# when 503; raise Error::ServiceUnavailable.new error_message(response)
|
||||
# end
|
||||
|
||||
response.parsed_response
|
||||
end
|
||||
|
|
|
@ -261,7 +261,7 @@ module Redmine
|
|||
elsif @myshixun
|
||||
file = @g.files(@myshixun, path, identifier)
|
||||
end
|
||||
cat = Base64.decode64 file.content
|
||||
cat = Base64.decode64 file.content unless file.content.blank?
|
||||
rescue ScmCommandAborted
|
||||
nil
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue