diff --git a/.idea/bigdate.iml b/.idea/bigdate.iml index 1ef1abf03..8fb4a98f2 100644 --- a/.idea/bigdate.iml +++ b/.idea/bigdate.iml @@ -33,6 +33,8 @@ + + @@ -109,7 +111,7 @@ - + @@ -121,7 +123,7 @@ - + @@ -135,7 +137,7 @@ - + @@ -153,7 +155,7 @@ - + @@ -218,7 +220,6 @@ - @@ -242,7 +243,6 @@ - @@ -262,7 +262,6 @@ - diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index b7bd531f9..5069efca9 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -4,25 +4,25 @@ mysql com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie2 + jdbc:mysql://127.0.0.1/0604new root - df9bdf98df99df9edf9fdf9c + df9bdf98df99df9e mysql com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie2 + jdbc:mysql://127.0.0.1/20161227data root - df9bdf98df99df9edf9fdf9c + df9bdf98df99df9e mysql com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie2 + jdbc:mysql://127.0.0.1/0623newblank root - df9bdf98df99df9edf9fdf9c + df9bdf98df99df9e diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 65bbd4b7c..798ebd8c5 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -94,7 +94,7 @@ class AccountController < ApplicationController def logout if User.current.anonymous? redirect_to signin_path - elsif request.post? + else logout_user redirect_to signin_path end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index de9c1b713..8fdc0801a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -433,7 +433,7 @@ class ApplicationController < ActionController::Base if params[:project_id] @project = Project.find(params[:project_id]) elsif params[:shixun_id] - @shixun = Shixun.find(params[:shixun_id]) + @shixun = Shixun.find_by_identifier(params[:shixun_id]) elsif params[:course_id] @course = Course.find(params[:course_id]) elsif params[:org_subfield_id] diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index d1ef60a12..ca6f6912f 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -49,7 +49,7 @@ class BoardsController < ApplicationController @boards = @course.boards.includes(:last_message => :author).all if @course.boards.empty? @board = @course.boards.build - @board.name = " #{l(:label_borad_course) }" + @board.name = "#{l(:label_borad_course)}" @board.description = @course.name.to_s @board.project_id = -1 if @board.save diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index a1d69ebd7..0036f4838 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -42,7 +42,7 @@ class ChallengesController < ApplicationController end # 向jenkins端发送请求,构建pipeline片段,实时返回结果 jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] - params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.path}", :trainingID => "#{@shixun.id}"} + params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.exec_path}", :trainingID => "#{@shixun.id}"} uri = URI("#{jenkins_shixuns}/jenkins-exec/game/generatePipelineScriptForChallenge") res = uri_exec uri, {challengeInfo: params.to_json} if res['code'] == 0 @@ -70,7 +70,6 @@ class ChallengesController < ApplicationController def index # 顶部导航 @challenges = @shixun.challenges.order("position desc") - respond_to do |format| format.js format.html @@ -117,7 +116,7 @@ class ChallengesController < ApplicationController end # 向jenkins端发送请求,构建pipeline片段,实时返回结果 jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] - params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.path}", :trainingID => "#{@shixun.id}"} + params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}", :challengeProgramName => "#{@challenge.exec_path}", :trainingID => "#{@shixun.id}"} uri = URI("#{jenkins_shixuns}/jenkins-exec/game/generatePipelineScriptForChallenge") res = uri_exec uri, {challengeInfo: params.to_json} if res['code'] == 0 @@ -216,7 +215,11 @@ class ChallengesController < ApplicationController # Find project of id params[:id] def find_shixun shixun_id = params[:shixun_id] || (params[:challenge] && params[:challenge][:shixun_id]) - @shixun = Shixun.find(shixun_id) + @shixun = Shixun.find_by_identifier(shixun_id) + if @shixun.nil? + render_404 + return + end rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index c40e0af95..4d7308362 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -134,7 +134,7 @@ class GamesController < ApplicationController game_challenge = @game.challenge gitUrl = git_repository_url(@myshixun, "Myshixun") gitUrl = Base64.encode64(gitUrl) - taskId = params[:id] + taskId = @game.id jobName = "myshixun_#{@myshixun.id}" ActiveRecord::Base.transaction do @game.update_attributes!(:status => 1) @@ -163,6 +163,7 @@ class GamesController < ApplicationController # 下一关自动开启 if had_done != 1 && @game.status == 2 @game.next_game.update_attribute(:status, 0) + @myshixun.update_attribute(:status, 1) end test_sets = game_challenge.test_sets unless test_sets.blank? @@ -202,7 +203,7 @@ class GamesController < ApplicationController next_game = @game.next_game next_game.update_attributes(:status => 0, :open_time => Time.now) if next_game.status == 3 - redirect_to myshixun_game_path(next_game, :myshixun_id => @myshixun.id) + redirect_to myshixun_game_path(next_game, :myshixun_id => @myshixun) end @@ -291,13 +292,22 @@ class GamesController < ApplicationController # Find myshixun of id params[:id] def find_myshixun myshixun_id = params[:myshixun_id] || (params[:game] && params[:game][:myshixun_id]) - @myshixun = Myshixun.find(myshixun_id) + @myshixun = Myshixun.find_by_identifier(myshixun_id) + if @myshixun.nil? + render_404 + return + end rescue ActiveRecord::RecordNotFound render_404 end def find_game - @game = Game.find(params[:id]) + # myshixun_id = params[:myshixun_id] + @game = Game.find_by_identifier(params[:id]) + if @game.nil? + render_404 + return + end @myshixun = @game.myshixun rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index fe0dadbad..567250cdb 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -14,7 +14,7 @@ class MyshixunsController < ApplicationController jsonTestDetails = JSON.parse(params[:jsonTestDetails]) status = jsonTestDetails['status'] game_id = jsonTestDetails['buildID'] - outPut = Base64.decode64(jsonTestDetails['outPut']) unless jsonTestDetails['outPut'].blank? + outPut = Base64.urlsafe_decode64(jsonTestDetails['outPut']) unless jsonTestDetails['outPut'].blank? jenkins_testsets = jsonTestDetails['msg'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? game = Game.find(game_id) @@ -51,7 +51,7 @@ class MyshixunsController < ApplicationController private # Find myshixun of id params[:id] def find_myshixun - @myshixun = Myshixun.find(params[:id]) + @myshixun = Myshixun.find_by_identifier(params[:id]) rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 81bd8d432..dde5f55d9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -900,7 +900,7 @@ update end def find_project_and_repository - @shixun = Shixun.find(params[:id]) + @shixun = Shixun.find_by_identifier(params[:id]) @repository = @shixun.repository render_404 if @shixun.gpid.nil? @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 4b6e764a0..c647c1b53 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -3,7 +3,7 @@ class ShixunsController < ApplicationController layout 'base_shixun' before_filter :require_login - before_filter :find_shixun, :except => [ :index, :new, :create, :index] + before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search] before_filter :shixun_view_allow, :only => [:show] before_filter :require_manager, :only => [ :settings, :add_script, :publish] @@ -21,12 +21,28 @@ class ShixunsController < ApplicationController end def index - @shixuns = Shixun.all - + @shixuns = Shixun.where(:authentication => 1).order('updated_at desc') + @shixun_my_score = Game.sum(:final_score) + @current_user_had_passed = Myshixun.where(:status => 1).count @shixuns_count = @shixuns.count render :layout => "base_edu" end + def search + # 确定 sort 1升序 2 降序 + if params[:time_reorder] + order = "#{Shixun.table_name}.created_at #{params[:time_reorder]}" + elsif params[:hot_reorder] + order = "myshixun_count #{params[:hot_reorder]}, #{Shixun.table_name}.updated_at #{params[:hot_reorder]}" + else + order = "#{Shixun.table_name}.created_at desc" + end + @shixuns = Shixun.where(:authentication => 1).reorder(order) + respond_to do |format| + format.js + end + end + # jenkins回调脚本 # gameID 及实训ID def publish @@ -42,7 +58,7 @@ class ShixunsController < ApplicationController fragments << challenge_script # 每一关所有的测试集 challenge.test_sets.each do |test_set| - test_cases = {:caseId => test_set.id.to_s, :input => test_set.input, :output => test_set.output} + test_cases = {:caseId => test_set.id.to_s, :input => test_set.input, :output => test_set.output, :isPublic => test_set.is_public} testSet << test_cases end test_sets_list = {:challengeStage => challenge.position.to_s, :challengeTestCases => testSet} @@ -93,11 +109,14 @@ class ShixunsController < ApplicationController gshixun = @g.fork(@shixun.gpid, User.current.gid) if !gshixun.id.nil? myshixun = copy_myshixun(@shixun, gshixun) + @shixun.update_attribute(:myshixun_count, (@shixun.myshixun_count + 1)) challenges = @shixun.challenges # 之所以增加user_id是为了方便统计查询性能 challenges.each_with_index do |challenge, index| status = (index == 0 ? 0 : 3) - Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id, :open_time => Time.now) + code = CODES.sample(12).join + code = CODES.sample(12).join if Game.where(identifier: code).present? + Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id, :open_time => Time.now, :identifier => code) end else raise("网络异常,请稍后重试") @@ -123,16 +142,20 @@ class ShixunsController < ApplicationController end end + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) def create + identifier = generate_identifier @shixun = Shixun.new(params[:shixun]) @shixun.user_id = User.current.id @shixun.language = params[:language] + @shixun.identifier = identifier (params[:shixun][:is_public] == "1" ? @shixun.is_public = true : @shixun.is_public = false) respond_to do |format| if @shixun.save + generate_identifier m = ShixunMember.new(:user_id => User.current.id, :role => 1) @shixun.shixun_members << m - format.html { redirect_to @shixun, notice: l(:notice_successful_create) } + format.html { redirect_to shixun_path @shixun, notice: l(:notice_successful_create) } format.js else format.html { render action: "new" } @@ -147,6 +170,13 @@ class ShixunsController < ApplicationController end end + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + def generate_identifier + code = CODES.sample(8).join + return generate_identifier if Shixun.where(identifier: code).present? + code + end + def edit end @@ -209,7 +239,8 @@ class ShixunsController < ApplicationController # Find shixun of id params[:id] def find_shixun - @shixun = Shixun.find(params[:id]) + @shixun = Shixun.find_by_identifier(params[:id]) + render_404 if @shixun.nil? rescue ActiveRecord::RecordNotFound render_404 end @@ -232,14 +263,18 @@ class ShixunsController < ApplicationController # REDO: 新增类型copy的时候 # 复制项目 # gshixun --> gitlab project + CODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) def copy_myshixun shixun, gshixun myshixun = Myshixun.new - myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status") + myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier") myshixun.shixun_id = shixun.id myshixun.user_id = User.current.id myshixun.gpid = gshixun.id jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] if myshixun.save! + code = CODES.sample(10).join + code = CODES.sample(10).join if Myshixun.where(identifier: code).present? + myshixun.update_attribute(:identifier, code) MyshixunMember.create!(:myshixun_id => myshixun.id, :user_id => User.current.id, :role => 1) rep = Repository.new(:myshixun_id => myshixun.id, :identifier => gshixun.name,:project_id => -1, :shixun_id => -2) rep.type = "Repository::Gitlab" diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1ec6ee91d..6fe2a5180 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -353,6 +353,14 @@ module ApplicationHelper super end + # 重置user_path,目的是将id转换成用户名 + # def shixun_path(resource, parameters = {}) + # if Fixnum === resource + # resource = Shixun.find(resource) + # end + # super + # end + # 历史数据(老版本库数据)处理完则可以修改该放放 def get_rep_identifier_by_project project identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) diff --git a/app/models/game.rb b/app/models/game.rb index 9bff76d7e..0bed87484 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -1,7 +1,7 @@ class Game < ActiveRecord::Base # stauts 0: can exe 1:doing 2:successed 3:locked default_scope :order => 'created_at desc' - attr_accessible :myshixun_id, :user_id, :status, :final_score, :challenge_id, :open_time + attr_accessible :myshixun_id, :user_id, :status, :final_score, :challenge_id, :open_time, :identifier belongs_to :myshixun,:touch=> true belongs_to :user belongs_to :challenge @@ -9,6 +9,12 @@ class Game < ActiveRecord::Base has_many :test_sets, :dependent => :destroy has_many :challenge_samples, :dependent => :destroy + # id 转换成 challenge'position + def to_param + identifier + end + + def last_game challenge = self.challenge last_challenge_id = challenge.last_challenge diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index c9894d4ee..cd7a035a3 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -1,11 +1,16 @@ class Myshixun < ActiveRecord::Base - attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public + attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public, :identifier has_many :users, :through => :myshixun_members has_many :myshixun_members has_one :repository has_many :games, :dependent => :destroy, :order => "games.id ASC" belongs_to :shixun + # id 转换成 identifier + def to_param + identifier + end + # 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录) # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 0bc98ff0c..5f472ff49 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -1,6 +1,6 @@ # status 控制实训的状态,0:未开启;1: 已开启(TPM); 2:已认证 class Shixun < ActiveRecord::Base - attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language + attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication, :myshixun_count has_many :users, :through => :shixun_members has_many :shixun_members @@ -8,6 +8,11 @@ class Shixun < ActiveRecord::Base has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC" has_many :myshixuns + # id 转换成 identifier + def to_param + identifier + end + def owner User.find(self.user_id) rescue ActiveRecord::RecordNotFound diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index 2bafa9ee9..5906c63d5 100644 --- a/app/views/challenges/_form.html.erb +++ b/app/views/challenges/_form.html.erb @@ -85,6 +85,10 @@ <%= f.text_field :path, :class => "panel-form-width-690 panel-box-sizing fl", :no_label => true, :placeholder => "进入实训后将默认打开该文件,如:app/controllers/welcome_controller.rb", :maxlength => "256" %> +
  • + + <%= f.text_field :exec_path, :class => "panel-form-width-690 panel-box-sizing fl", :no_label => true, :placeholder => "输入关卡需要执行的文件路径,如:app/controllers/welcome_controller.rb", :maxlength => "256" %> +
  • @@ -167,7 +171,7 @@
    - +
  • @@ -297,6 +301,12 @@ } }) + // 知识技能点添加,清空输入框,并focus + $("#add_knowledge").click(function(){ + $("#shixun_skill_input").val(""); + $("#shixun_skill_input").focus(); + }); + }); // 设置textarea的宽度到140以后出现滚动条 var text1 = document.getElementById("textarea_sample_input_test"); @@ -409,6 +419,8 @@ " "); $(".task-tag-input").attr("value",""); } + $("#shixun_skill_input").val(""); + $("#shixun_skill_input").focus(); } function close_tag(thisObj){ diff --git a/app/views/challenges/show.html.erb b/app/views/challenges/show.html.erb index 13d2158c4..98d8cfcdc 100644 --- a/app/views/challenges/show.html.erb +++ b/app/views/challenges/show.html.erb @@ -52,6 +52,12 @@ <%= @challenge.path.blank? ? "无" : (h @challenge.path.html_safe) %> +
  • + +
    + <%= @challenge.exec_path.blank? ? "无" : (h @challenge.exec_path) %> +
    +
  • diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index e24dd5b09..890f11dd2 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -12,7 +12,7 @@ :class => "task-btn task-btn-blue mr15 mt8", :remote => true %> <% else %> - 退出实训 + 退出实训 <% end %> <% end %>
    @@ -106,9 +106,4 @@ }); } - function exit_shixun(){ - window.opener=null; - window.open('<%= shixuns_path() %>','_self'); - window.close(); - } \ No newline at end of file diff --git a/app/views/games/_file_edit_form.html.erb b/app/views/games/_file_edit_form.html.erb index 9b5da6ad6..cbd3dab09 100644 --- a/app/views/games/_file_edit_form.html.erb +++ b/app/views/games/_file_edit_form.html.erb @@ -2,9 +2,9 @@ .CodeMirror{line-height: 1.2; font-size: 14px} -
    +
  • - +
  • @@ -19,11 +19,11 @@ var editor_CodeMirror = CodeMirror.fromTextArea(document.getElementById("challenge-answer-edit-small"), { mode: {name: "text/x-java", // version: 2, - singleLineStringErrors: false}, + singleLineStringErrors: false}, lineNumbers: true, theme: "ambiance", // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键 - indentUnit: 4, //代码缩进为一个tab的距离 + indentUnit: 2, //代码缩进为一个tab的距离 matchBrackets: true, autoRefresh: true, smartIndent: true//智能换行 @@ -42,7 +42,7 @@ $("#save_status").html("保存中..."); $.ajax({ type: "POST", - url: '<%= file_update_myshixun_game_path(@myshixun.id, @game.id, :path => @path) %>', + url: '<%= file_update_myshixun_game_path(@game, :myshixun_id => @myshixun, :path => @path) %>', data:{ content: $('#challenge-answer-edit-small').val()}, success: function(data){ $("#save_status").html("已保存"); @@ -65,6 +65,7 @@ editor_CodeMirror.setSize("auto","auto"); editor_CodeMirror.refresh(); var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10; - $(".CodeMirror-scroll").css("min-height", h); + $("#file_entry_content").find(".CodeMirror-scroll").css("min-height", h); + $("#file_entry_content").find(".CodeMirror-scroll").css("max-height", h); }); \ No newline at end of file diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 5f0f5dfe0..0eb1ec83f 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -46,7 +46,7 @@
    -
    +
    <%= @game_challenge.answer %>
    @@ -113,7 +113,8 @@ flowChart : true, // 默认不解析 sequenceDiagram : true // 默认不解析 }); - myCodeMirror.setSize('auto','auto');//设置版本库codemirror的高度 + myCodeMirror.setSize("auto", "auto");//设置版本库codemirror的高度 + $("#game_answer_show").find(".CodeMirror-scroll").css("margin-bottom", 0); $("#game_answer_show" ).children(".CodeMirror").css("line-height", 1.2); $("#game_answer_show").children().css("border", 0); // 设置图片最大宽度不能超出边框 diff --git a/app/views/games/_repository.html.erb b/app/views/games/_repository.html.erb index 8c3be616d..f8f3e4fb0 100644 --- a/app/views/games/_repository.html.erb +++ b/app/views/games/_repository.html.erb @@ -18,7 +18,7 @@
    <% else %> <% unless @entries.blank? %> - <%= render :partial => 'tree', :locals => { :extend => false}%> + <%= render :partial => 'tree', :locals => { :extend => false} %> <% end %> <% end %> diff --git a/app/views/games/_send_error_pop.html.erb b/app/views/games/_send_error_pop.html.erb index 13f755582..194195d97 100644 --- a/app/views/games/_send_error_pop.html.erb +++ b/app/views/games/_send_error_pop.html.erb @@ -19,6 +19,9 @@ data: {user: user, text: $("#error_contents").val(), game_id: '<%= @game.id %>', shixun_name:'<%= @myshixun.name %>', shixun_author_id:'<%= @game_challenge.user_id %>', position:'<%= @game_challenge.position %>'}, type: "POST", success: function (data) { + var htmlvalue = "<%= j (render :partial => 'games/send_success_pop') %>"; + pop_box_new(htmlvalue,460,300); + $("#error_contents").val(""); } }); } diff --git a/app/views/games/_send_success_pop.html.erb b/app/views/games/_send_success_pop.html.erb new file mode 100644 index 000000000..3e98f982b --- /dev/null +++ b/app/views/games/_send_success_pop.html.erb @@ -0,0 +1,14 @@ +
    +
    +

    发送成功

    + +
    +
    +
    +
      +
    • + 已发送给导师和管理员 +
    • +
    +
    +
    diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 40696988d..e5df62bbf 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -37,7 +37,8 @@ control = 0; } var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10; - $(".CodeMirror-scroll").css("min-height", h); + $("#file_entry_content").find(".CodeMirror-scroll").css("min-height", h); + $("#file_entry_content").find(".CodeMirror-scroll").css("max-height", h); } // 测评的扩大与缩小 function valuation_extend_and_zoom(){ diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index c8928019a..3c4ed59a8 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -19,7 +19,7 @@
    • <%= link_to "智能课堂", user_course_community_path(User.current), :class => "new-nav-a", :target => "_blank" %>
    • -
    • <%= link_to "游戏实训", user_project_community_path(User.current), :class => "new-nav-a", :target => "_blank" %>
    • +
    • <%= link_to "项目实训", shixuns_path, :class => "new-nav-a", :target => "_blank" %>
    • <%= link_to "论坛", forums_path, :class =>"new-nav-a", :target => "_blank" %>
    • <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "new-nav-a", :target=>"_blank" %>
    • diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index 8d399f3e1..5299453d2 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -18,8 +18,6 @@
        -
      • <%= link_to "智能课堂", user_course_community_path(User.current), :class => "new-nav-a", :target => "_blank" %>
      • -
      • <%= link_to "游戏实训", user_project_community_path(User.current), :class => "new-nav-a", :target => "_blank" %>
      • <%= link_to "论坛", forums_path, :class =>"new-nav-a", :target => "_blank" %>
      • <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "new-nav-a", :target=>"_blank" %>
      • diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb index fc1ce97f8..b8a2176d1 100644 --- a/app/views/shixuns/_form.html.erb +++ b/app/views/shixuns/_form.html.erb @@ -33,7 +33,7 @@
      • - <%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby"], "Java"), :id => 'shixun[language]', :class => "ml5", :style => "height: 28px;" %> + <%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby","Mysql-Java"], "Java"), :id => 'shixun[language]', :class => "ml5", :style => "height: 28px;" %>
      • diff --git a/app/views/shixuns/_monitor_tip.html.erb b/app/views/shixuns/_monitor_tip.html.erb index 0a1717639..7a8c99547 100644 --- a/app/views/shixuns/_monitor_tip.html.erb +++ b/app/views/shixuns/_monitor_tip.html.erb @@ -4,10 +4,14 @@
        -
        +
        • - 服务器异常,请联系系统管理员 + <% if result %> + 发布成功 + <% else %> + 服务器异常,请联系系统管理员 + <% end %>
        diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 6f2dada29..3046d12cc 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -25,7 +25,7 @@
      • - <%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby"], @shixun.language), :id => 'shixun[language]', :style => "height:40px;" %> + <%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby","Mysql-Java"], @shixun.language), :id => 'shixun[language]', :style => "height:40px;" %>
      • diff --git a/app/views/shixuns/_shixun_list.html.erb b/app/views/shixuns/_shixun_list.html.erb new file mode 100644 index 000000000..0951a819a --- /dev/null +++ b/app/views/shixuns/_shixun_list.html.erb @@ -0,0 +1,36 @@ +<% @shixuns.each do |shixun| %> +
        +
        +
        + <%= shixun.authentication ? "已审核" : "未审核" %> +

        <%= shixun.name %>

        +
        + <%= link_to image_tag(url_to_avatar(shixun.owner), :width =>"60", :height => "60", :class => "panel-warp-img mr10 fl", :alt=>"头像"), user_path(shixun.owner)%> + <%= link_to shixun.owner.try(:show_name), user_path(shixun.owner), :class => "task-index-name task-hide fl" %> +
        + +
        +

        <%= shixun.description %>

        +
        +
        +
        +
          +
        • <%= shixun.challenges.count %>
        • + +
        • <%= shixun.myshixuns.count %>
        • +
        +
        + +
        +<% end %> +
        + + + + + + + + + + \ No newline at end of file diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb index 8bfe1f784..8c78aec16 100644 --- a/app/views/shixuns/_shixun_top.html.erb +++ b/app/views/shixuns/_shixun_top.html.erb @@ -8,14 +8,14 @@ <% if allow_shixun_exec(@shixun) %> <% if User.current.id == @shixun.user_id %> <% if @shixun.status == 1 %> - 已发布 + <%= link_to "重新发布", publish_shixun_path(@shixun, :type => "retry"), :class => "fr task-btn task-btn-orange font-14", :id => "challenge_begin", :remote => true %> <% else %> - <%= link_to "发布实训", publish_shixun_path(@shixun), :class => "fr task-btn task-btn-orange", :id => "challenge_begin", :remote => true %> + <%= link_to "发布实训", publish_shixun_path(@shixun), :class => "fr task-btn task-btn-orange font-14", :id => "challenge_begin", :remote => true %> <% end %> <% else %> <% if @shixun.status == 1 %>
        - <%= link_to "开始挑战", shixun_exec_shixun_path(@shixun), :class => "fr task-btn task-btn-orange", :id => "challenge_begin" %> + <%= link_to "开始挑战", shixun_exec_shixun_path(@shixun), :class => "fr task-btn task-btn-orange font-14", :id => "challenge_begin", :onclick =>"$('#ajax-indicator').css('opacity','0.8').text('正在加载实训项目,请稍等……').show();" %>
        <% end %> <% end %> diff --git a/app/views/shixuns/index.html.erb b/app/views/shixuns/index.html.erb index 08073a00f..8d948a01a 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -1,42 +1,33 @@ -
        -
        -
        -

        游戏实训

        - <%= link_to "创建", new_shixun_path, :class => "task-btn task-btn-green fr" %> -
        +
        +
        +
        +

        游戏实训

        + <%= link_to "创建", new_shixun_path, :class => "task-btn task-btn-green fr" %> +
        +
        +
          +
        • <%= @shixuns_count %>
          全部实训
        • +
        • <%= @current_user_had_passed %>
          你已通过
        • +
        • <%= @shixun_my_score %>
          取得成绩
        • +
        -
          -
        • <%= @shixuns_count %>
          全部实训
        • -
        • 3
          你已通过
        • -
        • 280
          取得成绩
        • -
        -
        -
        -
      • - -
        -
        -
        - - -
        - -
        -
        -

        -

        - 时间排序 - -
        -
        - 热度排序 - -
        - - 排序方式: - 102 个搜索结果 -

        - - -
        - <% @shixuns.each do |shixun| %> -
        -
        -
        - 未审核 -

        <%= shixun.name %>

        -
        - <%= link_to image_tag(url_to_avatar(shixun.owner), :width =>"60", :height => "60", :class => "panel-warp-img mr10 fl", :alt=>"头像"),user_path(shixun.owner)%> - <%= link_to shixun.owner.try(:show_name), user_path(shixun.owner), :class => "task-index-name task-hide fl" %> -
        -
        -

        <%= shixun.description %>

        + –> + --> + -
      • <%= shixun.myshixuns.count %>
      • -
      - - - - <% end %> -
      -
      - 上一页 - 1 - 2 - 3 - ... - 31 - 下一页 -
      + --> +

      +

      + 热度排序 + +
      +
      + 时间排序 + +
      + 排序方式: + +

      +
      + +
      + <%= render "shixun_list" %>
      - \ No newline at end of file diff --git a/app/views/shixuns/publish.js.erb b/app/views/shixuns/publish.js.erb index 6ad466d10..ba4fed6fc 100644 --- a/app/views/shixuns/publish.js.erb +++ b/app/views/shixuns/publish.js.erb @@ -2,5 +2,7 @@ var htmlvalue = "<%= escape_javascript(render :partial => 'shixuns/monitor_tip') %>"; pop_box_new(htmlvalue,460,406); <% else %> + var htmlvalue = "<%= escape_javascript(render :partial => 'shixuns/monitor_tip', :locals => {:result => true}) %>"; + pop_box_new(htmlvalue,460,406); $("#shixun_top").html('<%= escape_javascript(render :partial => 'shixuns/shixun_top') %>'); <% end %> diff --git a/app/views/shixuns/search.js.erb b/app/views/shixuns/search.js.erb new file mode 100644 index 000000000..e82692b2f --- /dev/null +++ b/app/views/shixuns/search.js.erb @@ -0,0 +1 @@ +$("#shixun_list_content").html('<%= escape_javascript( render :partial => 'shixuns/shixun_list') %>'); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index abf41129a..88af78475 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,6 +44,7 @@ RedmineApp::Application.routes.draw do match 'publish', :via => [:get, :post] end collection do + get 'search' end resources :challenges do @@ -69,7 +70,7 @@ RedmineApp::Application.routes.draw do collection do match 'training_task_status', :via => [:get, :post] end - resources :games do + resources :games, :path => "stages" do member do match 'game_build', :via => [:get, :post] match 'next_step', :via => [:get, :post] diff --git a/db/migrate/20170425072017_add_identifier_to_shixun.rb b/db/migrate/20170425072017_add_identifier_to_shixun.rb new file mode 100644 index 000000000..ef77db474 --- /dev/null +++ b/db/migrate/20170425072017_add_identifier_to_shixun.rb @@ -0,0 +1,5 @@ +class AddIdentifierToShixun < ActiveRecord::Migration + def change + add_column :shixuns, :identifier, :string + end +end diff --git a/db/migrate/20170425085926_sync_identifier_to_shixun.rb b/db/migrate/20170425085926_sync_identifier_to_shixun.rb new file mode 100644 index 000000000..47d0199ce --- /dev/null +++ b/db/migrate/20170425085926_sync_identifier_to_shixun.rb @@ -0,0 +1,14 @@ +class SyncIdentifierToShixun < ActiveRecord::Migration + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + def up + @shixuns = Shixun.all + @shixuns.each do |shixun| + code = CODES.sample(8).join + code = CODES.sample(8).join if Shixun.where(identifier: code).present? + shixun.update_attribute(:identifier, code) + end + end + + def down + end +end diff --git a/db/migrate/20170425092430_add_identifier_to_myshixun.rb b/db/migrate/20170425092430_add_identifier_to_myshixun.rb new file mode 100644 index 000000000..d2d1cff4d --- /dev/null +++ b/db/migrate/20170425092430_add_identifier_to_myshixun.rb @@ -0,0 +1,5 @@ +class AddIdentifierToMyshixun < ActiveRecord::Migration + def change + add_column :myshixuns, :identifier, :string + end +end diff --git a/db/migrate/20170426020613_add_shixun_count_to_shixuns.rb b/db/migrate/20170426020613_add_shixun_count_to_shixuns.rb new file mode 100644 index 000000000..e33f4a15c --- /dev/null +++ b/db/migrate/20170426020613_add_shixun_count_to_shixuns.rb @@ -0,0 +1,5 @@ +class AddShixunCountToShixuns < ActiveRecord::Migration + def change + add_column :shixuns, :shixun_count, :integer, default: 0 + end +end diff --git a/db/migrate/20170426024708_add_identifier_to_games.rb b/db/migrate/20170426024708_add_identifier_to_games.rb new file mode 100644 index 000000000..afe752b22 --- /dev/null +++ b/db/migrate/20170426024708_add_identifier_to_games.rb @@ -0,0 +1,5 @@ +class AddIdentifierToGames < ActiveRecord::Migration + def change + add_column :games, :identifier, :string + end +end diff --git a/db/migrate/20170426024822_sync_game_identifier.rb b/db/migrate/20170426024822_sync_game_identifier.rb new file mode 100644 index 000000000..0590dad3c --- /dev/null +++ b/db/migrate/20170426024822_sync_game_identifier.rb @@ -0,0 +1,14 @@ +class SyncGameIdentifier < ActiveRecord::Migration + CODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) + def up + games = Game.all + games.each do |game| + code = CODES.sample(12).join + code = CODES.sample(12).join if Game.where(identifier: code).present? + game.update_attribute(:identifier, code) + end + end + + def down + end +end diff --git a/db/migrate/20170426060122_sync_identifier_to_myshixun.rb b/db/migrate/20170426060122_sync_identifier_to_myshixun.rb new file mode 100644 index 000000000..eece1f3d8 --- /dev/null +++ b/db/migrate/20170426060122_sync_identifier_to_myshixun.rb @@ -0,0 +1,14 @@ +class SyncIdentifierToMyshixun < ActiveRecord::Migration + CODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) + def up + myshixuns = Myshixun.all + myshixuns.each do |myshixun| + code = CODES.sample(10).join + code = CODES.sample(10).join if Myshixun.where(identifier: code).present? + myshixun.update_attribute(:identifier, code) + end + end + + def down + end +end diff --git a/db/migrate/20170427011453_rename_shixun_count.rb b/db/migrate/20170427011453_rename_shixun_count.rb new file mode 100644 index 000000000..d2177b307 --- /dev/null +++ b/db/migrate/20170427011453_rename_shixun_count.rb @@ -0,0 +1,8 @@ +class RenameShixunCount < ActiveRecord::Migration + def up + rename_column :shixuns, :shixun_count, :myshixun_count + end + + def down + end +end diff --git a/db/migrate/20170427013052_sync_myshixun_count.rb b/db/migrate/20170427013052_sync_myshixun_count.rb new file mode 100644 index 000000000..52ca4e215 --- /dev/null +++ b/db/migrate/20170427013052_sync_myshixun_count.rb @@ -0,0 +1,12 @@ +class SyncMyshixunCount < ActiveRecord::Migration + def up + shixuns = Shixun.all + shixuns.each do |shixun| + myshixun_count = shixun.myshixuns.count + shixun.update_attribute(:myshixun_count, myshixun_count) + end + end + + def down + end +end diff --git a/db/migrate/20170427031044_add_exec_path_to_challenges.rb b/db/migrate/20170427031044_add_exec_path_to_challenges.rb new file mode 100644 index 000000000..e9aaa7076 --- /dev/null +++ b/db/migrate/20170427031044_add_exec_path_to_challenges.rb @@ -0,0 +1,5 @@ +class AddExecPathToChallenges < ActiveRecord::Migration + def change + add_column :challenges, :exec_path, :string + end +end diff --git a/public/stylesheets/css/bigdata-common.css b/public/stylesheets/css/bigdata-common.css index 932e5de0d..4647f5aff 100644 --- a/public/stylesheets/css/bigdata-common.css +++ b/public/stylesheets/css/bigdata-common.css @@ -129,4 +129,27 @@ a:hover.task-btn-ver{background:#5f7cab;} .break_word_firefox{white-space: pre-wrap !important;word-break: break-all;} .pr {position:relative;} +/***** Ajax indicator ******/ +#ajax-indicator { + position: absolute; /* fixed not supported by IE */ + background-color:#eee; + border: 1px solid #bbb; + top:35%; + left:40%; + width:20%; + font-weight:bold; + text-align:center; + padding:0.6em; + z-index:100; + opacity: 0.5; +} +html>body #ajax-indicator { position: fixed; } + +#ajax-indicator span { + background-position: 0% 40%; + background-repeat: no-repeat; + background-image: url(/images/loading.gif); + padding-left: 26px; + vertical-align: bottom; +} diff --git a/public/stylesheets/css/taskstyle.css b/public/stylesheets/css/taskstyle.css index 7792ff8a8..dde542c21 100644 --- a/public/stylesheets/css/taskstyle.css +++ b/public/stylesheets/css/taskstyle.css @@ -185,6 +185,7 @@ input.knowledge_frame{height:30px;line-height:30px;border:none;background:#f3f5f .greytab-inner{ background:#fff; } .blacktab-inner{ background:#333;} .task-padding16{ padding:16px;} +.task-padding-new{ padding-top: 16px} /* TPM统计 20170321byLB */ .panel-warp-3{ width: 30%; background:#23b181; color:#fff; margin:2.5%; margin-right:0; position: relative; } .panel-warp-3-over{ background:#fff;opacity:0.8; color:#29bd8b; width: 100%; height:135px; position: absolute; top:0; left:0; text-align: center; padding-top:130px;}