完成上线关

This commit is contained in:
huang 2017-03-20 11:25:15 +08:00
parent dd9b7e95ca
commit 563febc7c4
9 changed files with 62 additions and 9 deletions

View File

@ -53,7 +53,7 @@ class ChallengesController < ApplicationController
def index
# 顶部导航
@challenges = @shixun.challenges
@challenges = @shixun.challenges.order("position desc")
respond_to do |format|
format.js
@ -80,18 +80,20 @@ class ChallengesController < ApplicationController
end
def index_down
@challenges = @shixun.challenges
# @challenges = @shixun.challenges
next_challenge = @challenge.next_challenge
position = @challenge.position
@challenge.update_attribute(:position, (position + 1))
next_challenge.update_attribute(:position, next_challenge.position - 1)
@challenges = @shixun.challenges
end
def index_up
@challenges = @shixun.challenges
position = @challenge.position
last_challenge = @challenge.last_challenge
@challenge.update_attribute(:position, (position - 1))
@challenge.last_challenge.update_attribute(:position, position + 1)
last_challenge.update_attribute(:position, last_challenge.position + 1)
@challenges = @shixun.challenges
end
# build job 只负责发送请求

View File

@ -1,8 +1,8 @@
class GamesController < ApplicationController
layout "base_myshixun"
before_filter :find_myshixun, :only => [:index]
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :output_show]
before_filter :find_repository, :only => [:show, :entry]
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :output_show, :file_edit, :file_update]
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update]
before_filter :allowd_manager, :only => [:game_build]
include ApplicationHelper
@ -35,6 +35,16 @@ class GamesController < ApplicationController
end
end
def file_edit
entry_and_raw(false)
@content = @repository.cat(@path, @rev)
@content
end
def file_update
end
# json调用显示左边的隐藏具体详情@game 字段 msg
# 刷新右边的输出结果 @game out_put
def output_show

View File

@ -46,6 +46,7 @@ class ShixunsController < ApplicationController
format.html{redirect_to myshixun_path(myshixun)}
end
rescue Exception => e
raise ActiveRecord::Rollback
respond_to do |format|
format.html{
flash[:notice] = l(:notice_shixun_failed_exec)+ ":" + e.message

View File

@ -1,4 +1,5 @@
class Challenge < ActiveRecord::Base
default_scope :order => 'position'
belongs_to :shixun,:touch=> true
belongs_to :user
has_many :challenge_samples, :dependent => :destroy
@ -17,7 +18,8 @@ class Challenge < ActiveRecord::Base
def last_challenge
render_404 if self.position < 2
Challenge.where(:position => (self.position -1), :shixun_id => self.shixun).first
position = self.position - 1
Challenge.where(:position => position, :shixun_id => self.shixun).first
end
end

View File

@ -6,7 +6,7 @@
</h3>
<div class="fr mt5 ">
<% if params[:action] == "entry" %>
<a href="#"><i class="fa fa-edit font-18 fl color-grey mr10"></i></a>
<a href="<%= file_edit_myshixun_game_path(@game, :myshixun_id => @myshixun) %>"><i class="fa fa-edit font-18 fl color-grey mr10"></i></a>
<% end %>
<a href="#"><i class="fa fa-check-circle font-18 fl color-grey"></i></a>
</div>

View File

@ -0,0 +1,3 @@
<textarea>
</textarea>

View File

@ -0,0 +1,33 @@
<%= 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">
<%= @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>

View File

@ -49,7 +49,7 @@
<script>
$(document).ready(function(){
$.ajax({
url:"<%= rep_tree_changes_shixun_path(@shixun, :rev => @rev, :ent_path => ent_path, :gpid => @shixun.gpid) %>",
url:"<%= rep_tree_changes_shixun_path(@project, :rev => @rev, :ent_path => ent_path, :gpid => @project.gpid) %>",
type: "GET",
data: "text",
success:function(data){

View File

@ -71,6 +71,8 @@ RedmineApp::Application.routes.draw do
get 'entry'
get 'outputs_show'
get 'game_status'
post 'file_update'
get 'file_edit'
end
end
end