Merge branch 'dev_shixun_project' of https://git.trustie.net/jacknudt/trustieforge into dev_shixun_project

Conflicts:
	app/views/games/_exec_results.html.erb
This commit is contained in:
huang 2017-03-23 15:08:34 +08:00
commit 77ba9c1958
12 changed files with 135 additions and 28 deletions

View File

@ -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, :output_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]
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update]
before_filter :allowd_manager, :only => [:game_build]
include ApplicationHelper
@ -62,8 +62,11 @@ class GamesController < ApplicationController
# json调用显示左边的隐藏具体详情@game 字段 msg
# 刷新右边的输出结果 @game out_put
def output_show
@game = GameOutputs.find(params[:game_output_id])
def outputs_show
@game = Output.find(params[:game_output_id])
respond_to do |format|
format.js
end
end
# status 0: 未提交测评或者提交测评失败后报错1中间状态还没返回值2返回值并成功

View File

@ -0,0 +1,18 @@
<div class="autoscroll_extend">
<table class="filecontent syntaxhl mt5" style="width:100%">
<tbody>
<% line_num = 1 %>
<% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
<tr>
<th class="line-num" id="L<%= line_num %>" style="vertical-align: top;">
<a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a>
</th>
<td class="line-code">
<pre style="width:auto;overflow: auto; "><%= line.html_safe %></pre>
</td>
</tr>
<% line_num += 1 %>
<% end %>
</tbody>
</table>
</div>

View File

@ -15,4 +15,4 @@
<% end %>
</tbody>
</table>
</div>
</div>

View File

@ -13,11 +13,11 @@
</div>
<div class="content-history-inner" style="height: 100px;">
<% unless @outputs.blank? %>
<% @outputs.each do |output| %>
<% @outputs.each_with_index do |output, index| %>
<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>
<span class="<%= output.code == 0 ? 'icon-success fl mr5' : 'icon-fail fl mr5' %>"><%= index + 1 %></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" %>
<%= link_to "详情", outputs_show_myshixun_game_path(@game, :myshixun_id => @myshixun, :game_output_id => output.id), :class => "fr mr10", :remote => true %>
</div>
<% end %>
<% end %>
@ -31,13 +31,12 @@
</div>
</div>
<div class="content-history-inner">
<!--<! if (results.length != 0) { !>-->
<! for(var i=0;i< results.length; i++) { !>
<! if(results[i][0] == 0){ !>
<div class="clearfix history-success mb10">
<span class="icon-success fl mr5">2</span>
<p class="fl">恭喜,您已经完成了本任务!</p>
<a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" >详情</a>
<% unless @outputs.blank? %>
<% @outputs.each_with_index do |output, index| %>
<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' %>"><%= index + 1%></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", :remote => true %>
</div>
<! }else{ !>
<div class="clearfix history-fail mb10">
@ -55,7 +54,7 @@
<div class="panel-header ">
<h3 >测试输出</h3>
</div>
<div class="content-history-inner">
<div class="content-history-inner" id="game_test_output">
<!=output !>
</div>
</div>
@ -64,7 +63,6 @@
<h3 >操作</h3>
</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>
@ -147,10 +145,4 @@
function hide_windows(){
$(".content-half-fix").hide();
}
function file_edit_submit(){
$('#file_update_id').submit();
}
</script>

View File

@ -0,0 +1,53 @@
<%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %>
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
<form action="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/file_update?path=<%= @path %>" method="post" id="file_update_id" data-remote="true">
<li class="clearfix" xmlns="http://www.w3.org/1999/html" style="height: 700px">
<textarea class = "" id="challenge-answer" name="content">
<%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %>
</textarea>
<script>
var text = document.getElementById("challenge-answer");
</script>
</li>
</form>
<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());
});
var web_h = window.innerHeight;
$(document).ready(function(){
if($.browser.msie) {
$(".CodeMirror").css("height", web_h * 0.825 + "px");
}
else if($.browser.safari)
{
$(".CodeMirror").css("height", web_h * 0.825 + "px");
}
else if($.browser.mozilla)
{
$(".CodeMirror").css("height", web_h * 0.825 + "px");
}
else if($.browser.opera) {
$(".CodeMirror").css("height", web_h * 0.825 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".CodeMirror").css("height", web_h * 0.835 + "px");
}else{
$(".CodeMirror").css("height", web_h * 0.825 + "px");
}
}
});
</script>

View File

@ -0,0 +1,22 @@
<div class="autoscroll_extend" style="line-height: 1.9;">
<table class="list entries" id="browser" style="table-layout: fixed;">
<tbody>
<% @entries.each do |entry| %>
<% tr_id = Digest::MD5.hexdigest(entry.path)
depth = params[:depth].to_i %>
<% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %>
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %>
<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
<td class="filename_no_report hidden">
<%= link_to h(ent_name),
{:action => (entry.is_dir? ? 'show' : 'entry'), :id => @game, :myshixun_id => @myshixun, :path => to_path_param(ent_path), :rev => @rev, :extend => extend },
:remote => true,
:class => (entry.is_dir? ? 'old-icon old-icon-folder' : "old-icon old-icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@ -1,18 +1,21 @@
<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">
<a href="#"><i class="fa fa-minus font-14 mr10 fl color-grey"></i></a>
<% if params[:action] == "entry" %>
<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 %>
<a href="javascript:void(0)" onclick="close_big_repository()"><i class="fa fa-compress font-14 fl color-grey"></i></a>
</div>
</div>
<div class="content-history-extend">
<% if params[:action] == "entry" %>
<div id="file_entry_content_inner">
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content, :extend => true} %>
<%= render :partial => 'common/extend_file', :locals => {:filename => @path, :content => @content, :extend => true} %>
</div>
<% else %>
<% unless @entries.blank? %>
<%= render :partial => 'tree', :locals => { :extend => true} %>
<%= render :partial => 'extend_tree', :locals => { :extend => true} %>
<% end %>
<% end %>
</div>

View File

@ -4,7 +4,9 @@
</h3>
<div class="fr mt5">
<% if params[:action] == "entry" %>
<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>
<a href="javascript:void(0)" class="fl task-btn mb10 mr10" style="display: none" id="sava_edit_btn1" onclick="file_edit_submit()">保存修改</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>
<% end %>
<a href="javascript:void(0)" onclick="extend_repository();"><i class="fa fa-expand font-18 fl color-grey"></i></a>
</div>
@ -52,8 +54,11 @@
}else{
$(".content-half-fix02").css("height", web_h - 80 + "px");
$(".content-half-fix02").css("width", "85.7%");
$(".autoscroll_new").css("height", web_h * 0.58 + "px");
$(".autoscroll_new").css("height", web_h * 0.583 + "px");
}
}
});
function file_edit_submit(){
$('#file_update_id').submit();
}
</script>

View File

@ -12,32 +12,38 @@
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.safari)
{
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.mozilla)
{
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.595 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
else if($.browser.opera) {
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}else if($.browser.chrome){
if(window.navigator.userAgent.indexOf("MetaSr") == -1){
$(".content-half-fix02").css("height", web_h - 85 + "px");
$(".content-half-fix02").css("width", "86%");
$(".autoscroll_new").css("height", web_h * 0.61 + "px");
$(".autoscroll_extend").css("height", web_h * 0.835 + "px");
}else{
$(".content-half-fix02").css("height", web_h - 80 + "px");
$(".content-half-fix02").css("width", "85.7%");
$(".autoscroll_new").css("height", web_h * 0.58 + "px");
$(".autoscroll_extend").css("height", web_h * 0.825 + "px");
}
}
});

View File

@ -1 +1,4 @@
$("#file_entry_content").html('<%= escape_javascript(render :partial => 'games/file_edit_form') %>');
$("#file_entry_content").html('<%= escape_javascript(render :partial => 'games/file_edit_form') %>');
$("#file_entry_content_inner").html('<%= escape_javascript(render :partial => 'games/extend_file_edit_form') %>');
$("#sava_edit_btn1").show();
$("#sava_edit_btn").show();

View File

@ -0,0 +1 @@
$("#game_test_output").html("<%= @game.msg %>");

View File

@ -169,3 +169,4 @@ input.knowledge_frame{height:30px;line-height:30px;border:none;background:#f3f5f
.content-half-fix02{margin:0; position: absolute; top:65px; z-index:99; right:45px;}
.autoscroll_new{ overflow:auto; }
.autoscroll_extend{ overflow:auto; }