From fd87038ebcddc84a357b851631b71508a1f48b13 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 25 Apr 2017 14:18:52 +0800 Subject: [PATCH 01/27] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 2 +- app/controllers/games_controller.rb | 1 + app/controllers/shixuns_controller.rb | 22 ++- app/views/shixuns/_shixun_list.html.erb | 36 +++++ app/views/shixuns/index.html.erb | 171 ++++++++++-------------- app/views/shixuns/shixun_search.js.erb | 1 + config/routes.rb | 1 + 7 files changed, 130 insertions(+), 104 deletions(-) create mode 100644 app/views/shixuns/_shixun_list.html.erb create mode 100644 app/views/shixuns/shixun_search.js.erb 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/games_controller.rb b/app/controllers/games_controller.rb index c03f48a8d..d549291c9 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -160,6 +160,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? diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 4b6e764a0..f6f9fe341 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, :shixun_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(:status => 2) + @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 shixun_search + # 确定 sort 1升序 2 降序 + @order, @sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1 + if @order.to_i == @type.to_i + @sort = (@sort.to_i == 1 ? 2 : 1) + else + @sort = 2 + end + sort_name = "updated_on" + sort_type = @sort == 1 ? "asc" : "desc" + @shixuns = Shixun.where(:status => 2).reorder() + order = params[:sort] + @shixuns = Shixun.where(:status => 2).order("#{order.nil? ? 'created_at' : order} desc") + end + # jenkins回调脚本 # gameID 及实训ID def publish diff --git a/app/views/shixuns/_shixun_list.html.erb b/app/views/shixuns/_shixun_list.html.erb new file mode 100644 index 000000000..f4f66c364 --- /dev/null +++ b/app/views/shixuns/_shixun_list.html.erb @@ -0,0 +1,36 @@ +<% @shixuns.each do |shixun| %> +
+
+
+ <%= shixun.status == 2 ? "已审核" : "未审核" %> +

<%= 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/index.html.erb b/app/views/shixuns/index.html.erb index c2c96fc16..ca69cfda1 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -1,106 +1,77 @@
-
-
-

游戏实训

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

游戏实训

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

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

-
+
    +
  • <%= @shixuns_count %>
    全部实训
  • +
  • <%= @current_user_had_passed %>
    你已通过
  • +
  • <%= @shixun_my_score %>
    取得成绩
  • +
+
+
+ + + + + + + + + + + + + + + -
- <% @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.challenges.count %>
  • - -
  • <%= shixun.myshixuns.count %>
  • -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
- <% end %> -
-
- 上一页 - 1 - 2 - 3 - ... - 31 - 下一页 -
+ +

+ 热度排序 + | + <%#= link_to "时间排序", shixun_search_shixuns_path(:type => @type, :sort => @b_sort, :order => 1), :class => "sortTxt", :remote => true %> + + 时间排序 + 排序方式: + +

+
+ +
+ <%= render "shixun_list" %>
-
diff --git a/app/views/shixuns/shixun_search.js.erb b/app/views/shixuns/shixun_search.js.erb new file mode 100644 index 000000000..d2684b6b8 --- /dev/null +++ b/app/views/shixuns/shixun_search.js.erb @@ -0,0 +1 @@ +$("#shixun_list_content").replaceWith('<%= escape_javascript( render :partial => 'shixuns/shixun_list') %>'); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e44c6cf0a..d69219cef 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 'shixun_search' end resources :challenges do From 2218a6371025514b0e859e5da9f2f6485b59f346 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 25 Apr 2017 17:15:37 +0800 Subject: [PATCH 02/27] =?UTF-8?q?shixun=E6=95=B4=E5=9E=8BID=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E6=88=908=E4=BD=8D=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 4 ++-- app/controllers/repositories_controller.rb | 2 +- app/controllers/shixuns_controller.rb | 16 ++++++++++++++-- app/helpers/application_helper.rb | 8 ++++++++ app/models/shixun.rb | 9 ++++++++- app/views/challenges/_content_list.html.erb | 2 +- app/views/shixuns/_shixun_list.html.erb | 4 ++-- config/routes.rb | 2 +- .../20170425072017_add_identifier_to_shixun.rb | 5 +++++ .../20170425085926_sync_identifier_to_shixun.rb | 14 ++++++++++++++ 10 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20170425072017_add_identifier_to_shixun.rb create mode 100644 db/migrate/20170425085926_sync_identifier_to_shixun.rb diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index a1d69ebd7..fdfd0c157 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -70,7 +70,6 @@ class ChallengesController < ApplicationController def index # 顶部导航 @challenges = @shixun.challenges.order("position desc") - respond_to do |format| format.js format.html @@ -216,7 +215,8 @@ 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) + render_404 if @shixun.nil? 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 f6f9fe341..ec52390e6 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -139,16 +139,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" } @@ -163,6 +167,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 @@ -225,7 +236,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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 24842f414..ece734b6f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -349,6 +349,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/shixun.rb b/app/models/shixun.rb index 0bc98ff0c..9cd7c320a 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 has_many :users, :through => :shixun_members has_many :shixun_members @@ -8,6 +8,13 @@ class Shixun < ActiveRecord::Base has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC" has_many :myshixuns + # id 转换成 identifier + # 如果是整数就去ID,否则就取login + # 含有特殊符号的则显示ID + def to_param + identifier + end + def owner User.find(self.user_id) rescue ActiveRecord::RecordNotFound diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index 75526be97..a4da8a706 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -12,7 +12,7 @@ <% @challenges.each_with_index do |challenge, index| -%>

第<%= challenge.position %>关 - <%= link_to challenge.subject, shixun_challenge_path(@shixun.id, challenge), :target => "_blank" %> + <%= link_to challenge.subject, shixun_challenge_path(@shixun, challenge), :target => "_blank" %>

<% if User.current.manager_of_shixun?(@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 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 %>

diff --git a/config/routes.rb b/config/routes.rb index d69219cef..5ac69fc4e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,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 From bf5416fe4b6363ef9237cdc93caf5a41b5ba778c Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 09:39:27 +0800 Subject: [PATCH 03/27] =?UTF-8?q?=E6=B7=BB=E5=8A=A0identifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/myshixun.rb | 2 +- db/migrate/20170425092430_add_identifier_to_myshixun.rb | 5 +++++ db/migrate/20170425093133_sync_identifier_to_myshixun.rb | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170425092430_add_identifier_to_myshixun.rb create mode 100644 db/migrate/20170425093133_sync_identifier_to_myshixun.rb diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index c9894d4ee..ce0e08623 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -1,5 +1,5 @@ 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 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/20170425093133_sync_identifier_to_myshixun.rb b/db/migrate/20170425093133_sync_identifier_to_myshixun.rb new file mode 100644 index 000000000..b927c6690 --- /dev/null +++ b/db/migrate/20170425093133_sync_identifier_to_myshixun.rb @@ -0,0 +1,7 @@ +class SyncIdentifierToMyshixun < ActiveRecord::Migration + def up + end + + def down + end +end From a29b8d7761f8f925785a2f7963218174f373dff0 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 09:49:16 +0800 Subject: [PATCH 04/27] =?UTF-8?q?=E9=A1=B6=E9=83=A8=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9E=E8=AE=AD=E6=B8=B8=E6=88=8F=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_logined_header.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index c8ad22cfc..2539fee54 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -19,7 +19,7 @@
@@ -92,34 +67,69 @@ <%= render "shixun_list" %>
- \ No newline at end of file diff --git a/app/views/shixuns/shixun_search.js.erb b/app/views/shixuns/shixun_search.js.erb index d2684b6b8..e82692b2f 100644 --- a/app/views/shixuns/shixun_search.js.erb +++ b/app/views/shixuns/shixun_search.js.erb @@ -1 +1 @@ -$("#shixun_list_content").replaceWith('<%= escape_javascript( render :partial => 'shixuns/shixun_list') %>'); \ No newline at end of file +$("#shixun_list_content").html('<%= escape_javascript( render :partial => 'shixuns/shixun_list') %>'); \ No newline at end of file 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 From b3c803341ff290f0d4edf5cc22b91aa0d00ed492 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 14:20:07 +0800 Subject: [PATCH 07/27] =?UTF-8?q?url=E9=87=8D=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 5 ++++- app/controllers/games_controller.rb | 9 +++++++-- app/models/game.rb | 8 +++++++- .../20170425093133_sync_identifier_to_myshixun.rb | 9 --------- .../20170426024708_add_identifier_to_games.rb | 5 +++++ db/migrate/20170426024822_sync_game_identifier.rb | 14 ++++++++++++++ .../20170426060122_sync_identifier_to_myshixun.rb | 14 ++++++++++++++ 7 files changed, 51 insertions(+), 13 deletions(-) delete mode 100644 db/migrate/20170425093133_sync_identifier_to_myshixun.rb create mode 100644 db/migrate/20170426024708_add_identifier_to_games.rb create mode 100644 db/migrate/20170426024822_sync_game_identifier.rb create mode 100644 db/migrate/20170426060122_sync_identifier_to_myshixun.rb diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index fdfd0c157..92f9d61cf 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -216,7 +216,10 @@ class ChallengesController < ApplicationController def find_shixun shixun_id = params[:shixun_id] || (params[:challenge] && params[:challenge][:shixun_id]) @shixun = Shixun.find_by_identifier(shixun_id) - render_404 if @shixun.nil? + 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 3bbfa1705..516468047 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -163,7 +163,7 @@ class GamesController < ApplicationController # 下一关自动开启 if had_done != 1 && @game.status == 2 @game.next_game.update_attribute(:status, 0) - @myshixun.update_attribute(:status => 1) + @myshixun.update_attribute(:status, 1) end test_sets = game_challenge.test_sets unless test_sets.blank? @@ -298,7 +298,12 @@ class GamesController < ApplicationController 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/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/db/migrate/20170425093133_sync_identifier_to_myshixun.rb b/db/migrate/20170425093133_sync_identifier_to_myshixun.rb deleted file mode 100644 index c8daaf31d..000000000 --- a/db/migrate/20170425093133_sync_identifier_to_myshixun.rb +++ /dev/null @@ -1,9 +0,0 @@ -class SyncIdentifierToMyshixun < ActiveRecord::Migration - def up - myshixuns = Myshixun.all - myshixuns.each do |myshixun| - identifier = myshixun.shixun.try(:identifier) - myshixun.update_attribute(:identifier, identifier) - end - 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 From 42eb8506c63217fdff878f28cb24a23bbe4010de Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 15:02:12 +0800 Subject: [PATCH 08/27] =?UTF-8?q?shixun=E7=BC=96=E8=BE=91=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0sql=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_settings_edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;" %>
  • From 33c701490eff99e2edff0da173778a8716d237de Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 26 Apr 2017 15:20:32 +0800 Subject: [PATCH 09/27] =?UTF-8?q?=E5=BD=93=E5=9C=A8=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A1=86=E7=9A=84=E5=BA=95=E9=83=A8=E7=BC=96=E5=86=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=97=B6=EF=BC=8C=E5=9B=9E=E8=BD=A6=E6=8D=A2=E8=A1=8C?= =?UTF-8?q?=E5=90=8E=E4=BB=A3=E7=A0=81=E6=A1=86=E6=B2=A1=E6=9C=89=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8B=E7=A7=BB=EF=BC=8C=E5=BF=85=E9=A1=BB=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=BB=9A=E5=8A=A8=E6=89=8D=E8=83=BD=E4=BD=BF=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E6=AD=A3=E5=9C=A8=E8=BE=93=E5=85=A5=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=89=80=E5=9C=A8=E8=A1=8C=E5=9B=9E=E5=88=B0=E8=A7=86=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/bigdate.iml | 98 ++++++++++++------------ app/views/games/_file_edit_form.html.erb | 5 +- app/views/games/show.html.erb | 1 + 3 files changed, 54 insertions(+), 50 deletions(-) diff --git a/.idea/bigdate.iml b/.idea/bigdate.iml index 1ef1abf03..54164e1bd 100644 --- a/.idea/bigdate.iml +++ b/.idea/bigdate.iml @@ -13,26 +13,46 @@ - - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + @@ -57,46 +77,28 @@ - + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/app/views/games/_file_edit_form.html.erb b/app/views/games/_file_edit_form.html.erb index 9b5da6ad6..723aa0038 100644 --- a/app/views/games/_file_edit_form.html.erb +++ b/app/views/games/_file_edit_form.html.erb @@ -4,7 +4,7 @@
  • - +
  • @@ -23,7 +23,7 @@ lineNumbers: true, theme: "ambiance", // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键 - indentUnit: 4, //代码缩进为一个tab的距离 + indentUnit: 2, //代码缩进为一个tab的距离 matchBrackets: true, autoRefresh: true, smartIndent: true//智能换行 @@ -66,5 +66,6 @@ editor_CodeMirror.refresh(); var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10; $(".CodeMirror-scroll").css("min-height", h); + $(".CodeMirror-scroll").css("max-height", h); }); \ No newline at end of file diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 40696988d..64d3d695a 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -38,6 +38,7 @@ } var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10; $(".CodeMirror-scroll").css("min-height", h); + $(".CodeMirror-scroll").css("max-height", h); } // 测评的扩大与缩小 function valuation_extend_and_zoom(){ From 0ccd6c0d6bce1f5196457bb255d45eaa2298e12f Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 15:37:32 +0800 Subject: [PATCH 10/27] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=8A=9F=E8=83=BD=E5=8F=8A=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- app/views/shixuns/_monitor_tip.html.erb | 6 +++++- app/views/shixuns/_shixun_list.html.erb | 2 +- app/views/shixuns/_shixun_top.html.erb | 2 +- app/views/shixuns/publish.js.erb | 2 ++ 5 files changed, 10 insertions(+), 4 deletions(-) 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/views/shixuns/_monitor_tip.html.erb b/app/views/shixuns/_monitor_tip.html.erb index 0a1717639..11473f249 100644 --- a/app/views/shixuns/_monitor_tip.html.erb +++ b/app/views/shixuns/_monitor_tip.html.erb @@ -7,7 +7,11 @@
    • - 服务器异常,请联系系统管理员 + <% if result %> + 发布成功 + <% else %> + 服务器异常,请联系系统管理员 + <% end %>
    diff --git a/app/views/shixuns/_shixun_list.html.erb b/app/views/shixuns/_shixun_list.html.erb index 12b9c7d66..0951a819a 100644 --- a/app/views/shixuns/_shixun_list.html.erb +++ b/app/views/shixuns/_shixun_list.html.erb @@ -2,7 +2,7 @@
    - <%= shixun.status == 2 ? "已审核" : "未审核" %> + <%= 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)%> diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb index 8bfe1f784..f20cf107e 100644 --- a/app/views/shixuns/_shixun_top.html.erb +++ b/app/views/shixuns/_shixun_top.html.erb @@ -8,7 +8,7 @@ <% 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", :id => "challenge_begin", :remote => true %> <% else %> <%= link_to "发布实训", publish_shixun_path(@shixun), :class => "fr task-btn task-btn-orange", :id => "challenge_begin", :remote => true %> <% end %> 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 %> From 9688df346b742f01b861341f203391aef6eb983d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 26 Apr 2017 15:50:22 +0800 Subject: [PATCH 11/27] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTMP=EF=BC=8C=E6=8A=80?= =?UTF-8?q?=E8=83=BD=E4=B8=8E=E7=9F=A5=E8=AF=86=E7=82=B9=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E4=B8=8A=E6=AC=A1=E7=9A=84=E8=BE=93=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E5=B9=B6=E8=81=9A=E7=84=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/_form.html.erb | 10 +++++++++- app/views/games/_repository.html.erb | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index 2bafa9ee9..a97f6144d 100644 --- a/app/views/challenges/_form.html.erb +++ b/app/views/challenges/_form.html.erb @@ -167,7 +167,7 @@
    - +
  • @@ -297,6 +297,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 +415,8 @@ " "); $(".task-tag-input").attr("value",""); } + $("#shixun_skill_input").val(""); + $("#shixun_skill_input").focus(); } function close_tag(thisObj){ 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 %> From 651e02b5cb5b260d884abdb11019774137805ffd Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 16:03:05 +0800 Subject: [PATCH 12/27] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96identifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 6 +++++- app/controllers/shixuns_controller.rb | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 516468047..df1bc8d15 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -292,7 +292,11 @@ 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 diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 4fd84d586..46d8b2ab3 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -128,7 +128,9 @@ class ShixunsController < ApplicationController # 之所以增加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("网络异常,请稍后重试") @@ -275,14 +277,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" From 2d87bfb2ae457c1e7c837ec8ea0ac9815eb002cc Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 17:01:25 +0800 Subject: [PATCH 13/27] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/bigdate.iml | 100 +++++++++++------------ app/controllers/games_controller.rb | 2 +- app/views/games/_file_edit_form.html.erb | 4 +- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/.idea/bigdate.iml b/.idea/bigdate.iml index 54164e1bd..def4eded2 100644 --- a/.idea/bigdate.iml +++ b/.idea/bigdate.iml @@ -13,46 +13,28 @@ - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - + + + + + + + + + @@ -77,28 +59,46 @@ - - + - - - - - + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index df1bc8d15..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) diff --git a/app/views/games/_file_edit_form.html.erb b/app/views/games/_file_edit_form.html.erb index 723aa0038..bd6a1046e 100644 --- a/app/views/games/_file_edit_form.html.erb +++ b/app/views/games/_file_edit_form.html.erb @@ -2,7 +2,7 @@ .CodeMirror{line-height: 1.2; font-size: 14px} -
    +
  • @@ -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("已保存"); From 61e7ccb4de47f524421351cbec734c6a2d04f056 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 26 Apr 2017 18:03:48 +0800 Subject: [PATCH 14/27] =?UTF-8?q?shixun=20=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 19 ++----------------- app/views/games/_file_edit_form.html.erb | 2 +- app/views/shixuns/index.html.erb | 2 +- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 46d8b2ab3..11e0ef7da 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -31,28 +31,13 @@ class ShixunsController < ApplicationController def shixun_search # 确定 sort 1升序 2 降序 if params[:time_reorder] - order = "#{Shixun.table_name}.updated_at #{params[:time_reorder]}" + order = "#{Shixun.table_name}.created_at #{params[:time_reorder]}" elsif params[:hot_reorder] order = "shixun_count #{params[:hot_reorder]}, #{Shixun.table_name}.updated_at #{params[:hot_reorder]}" else - order = "#{Shixun.table_name}.updated_at desc" + order = "#{Shixun.table_name}.created_at desc" end - - # @order, @sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1 -=begin - if @order.to_i == @type.to_i - @sort = (@sort.to_i == 1 ? 2 : 1) - else - @sort = 2 - end - sort_name = "updated_on" - sort_type = @sort == 1 ? "asc" : "desc" -=end @shixuns = Shixun.where(:authentication => 1).reorder(order) -=begin - order = params[:sort] - @shixuns = Shixun.where(:status => 2).order("#{order.nil? ? 'created_at' : order} desc") -=end respond_to do |format| format.js end diff --git a/app/views/games/_file_edit_form.html.erb b/app/views/games/_file_edit_form.html.erb index bd6a1046e..86e257180 100644 --- a/app/views/games/_file_edit_form.html.erb +++ b/app/views/games/_file_edit_form.html.erb @@ -19,7 +19,7 @@ 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"}, // 快捷键 diff --git a/app/views/shixuns/index.html.erb b/app/views/shixuns/index.html.erb index 6975a3e1f..0f01211bd 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -59,7 +59,7 @@ 排序方式: - 102 个搜索结果 +

    From 18543c87ca02b3b0641bf4c8ed7b600c73a3936f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 10:18:15 +0800 Subject: [PATCH 15/27] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0reduce=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/bigdate.iml | 11 ++++------- .idea/dataSources.xml | 12 ++++++------ app/controllers/shixuns_controller.rb | 7 ++++--- app/models/shixun.rb | 2 +- app/views/shixuns/index.html.erb | 12 ++++++------ .../shixuns/{shixun_search.js.erb => search.js.erb} | 0 config/routes.rb | 2 +- db/migrate/20170427011453_rename_shixun_count.rb | 8 ++++++++ db/migrate/20170427013052_sync_myshixun_count.rb | 12 ++++++++++++ 9 files changed, 42 insertions(+), 24 deletions(-) rename app/views/shixuns/{shixun_search.js.erb => search.js.erb} (100%) create mode 100644 db/migrate/20170427011453_rename_shixun_count.rb create mode 100644 db/migrate/20170427013052_sync_myshixun_count.rb diff --git a/.idea/bigdate.iml b/.idea/bigdate.iml index def4eded2..8fb4a98f2 100644 --- a/.idea/bigdate.iml +++ b/.idea/bigdate.iml @@ -111,7 +111,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -137,7 +137,7 @@ - + @@ -155,7 +155,7 @@ - + @@ -220,7 +220,6 @@ - @@ -244,7 +243,6 @@ - @@ -264,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/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 11e0ef7da..5f108b45f 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, :shixun_search] + 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] @@ -28,12 +28,12 @@ class ShixunsController < ApplicationController render :layout => "base_edu" end - def shixun_search + def search # 确定 sort 1升序 2 降序 if params[:time_reorder] order = "#{Shixun.table_name}.created_at #{params[:time_reorder]}" elsif params[:hot_reorder] - order = "shixun_count #{params[:hot_reorder]}, #{Shixun.table_name}.updated_at #{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 @@ -109,6 +109,7 @@ 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| diff --git a/app/models/shixun.rb b/app/models/shixun.rb index e71a5e7bb..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, :identifier, :authentication, :hixun_count + 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 diff --git a/app/views/shixuns/index.html.erb b/app/views/shixuns/index.html.erb index 0f01211bd..8d948a01a 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -75,7 +75,7 @@ nHot.removeClass("sortArrowActiveD sortArrowActiveU"); if(nTime.hasClass("sortArrowActiveD")){ $.ajax({ - url: '<%= shixun_search_shixuns_path() %>' + '.js', + url: '<%= search_shixuns_path() %>' + '.js', data: { time_reorder: 'asc' }, success: function(){ nTime.removeClass("sortArrowActiveD"); @@ -84,7 +84,7 @@ }) }else if(nTime.hasClass("sortArrowActiveU")){ $.ajax({ - url: '<%=shixun_search_shixuns_path() %>' + '.js', + url: '<%= search_shixuns_path() %>' + '.js', data: { time_reorder: 'desc'}, success: function(){ nTime.removeClass("sortArrowActiveU"); @@ -93,7 +93,7 @@ }) }else{ $.ajax({ - url: '<%= shixun_search_shixuns_path() %>' + '.js', + url: '<%= search_shixuns_path() %>' + '.js', data: { time_reorder: 'desc'}, success: function(){ nTime.addClass("sortArrowActiveD"); @@ -105,7 +105,7 @@ nTime.removeClass("sortArrowActiveD sortArrowActiveU"); if(nHot.hasClass("sortArrowActiveD")){ $.ajax({ - url: '<%= shixun_search_shixuns_path() %>' + '.js', + url: '<%= search_shixuns_path() %>' + '.js', data: { hot_reorder: 'asc'}, success: function(){ nHot.removeClass("sortArrowActiveD"); @@ -114,7 +114,7 @@ }) }else if(nHot.hasClass("sortArrowActiveU")){ $.ajax({ - url: '<%= shixun_search_shixuns_path() %>' + '.js', + url: '<%= search_shixuns_path() %>' + '.js', data: { hot_reorder: 'desc'}, success: function(){ nHot.removeClass("sortArrowActiveU"); @@ -123,7 +123,7 @@ }) }else{ $.ajax({ - url: '<%= shixun_search_shixuns_path() %>' + '.js', + url: '<%= search_shixuns_path() %>' + '.js', data: { hot_reorder: 'desc'}, success: function(){ nHot.addClass("sortArrowActiveD"); diff --git a/app/views/shixuns/shixun_search.js.erb b/app/views/shixuns/search.js.erb similarity index 100% rename from app/views/shixuns/shixun_search.js.erb rename to app/views/shixuns/search.js.erb diff --git a/config/routes.rb b/config/routes.rb index f31dbaaa0..88af78475 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,7 +44,7 @@ RedmineApp::Application.routes.draw do match 'publish', :via => [:get, :post] end collection do - get 'shixun_search' + get 'search' end resources :challenges do 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 From a17a1f89101daf16a9229fee52325d74eeebec40 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 11:21:47 +0800 Subject: [PATCH 16/27] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/_form.html.erb | 4 ++++ app/views/challenges/show.html.erb | 6 ++++++ db/migrate/20170427031044_add_exec_path_to_challenges.rb | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 db/migrate/20170427031044_add_exec_path_to_challenges.rb diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index a97f6144d..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" %> +
  • 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/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 From 9e3861af90b80eda31205b204f7551a159c69733 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Apr 2017 11:25:20 +0800 Subject: [PATCH 17/27] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTPM=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=8C=91=E6=88=98=EF=BC=8C=E5=AD=97=E4=BD=93=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=BA14px?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_shixun_top.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb index f20cf107e..611417cbe 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", :id => "challenge_begin", :remote => true %> + <%= 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" %>
    <% end %> <% end %> From 6f19ca9f9b11ba84b894eb05043fd47f33112099 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Apr 2017 14:03:04 +0800 Subject: [PATCH 18/27] =?UTF-8?q?=E7=82=B9=E5=87=BB=E2=80=9C=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=8C=91=E6=88=98=E2=80=9D=E5=90=8E=EF=BC=8C=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E7=AD=89=E5=BE=85=E6=97=B6=EF=BC=8C=E8=A6=81=E6=9C=89?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=BC=B9=E6=A1=86=E6=98=BE=E7=A4=BA=E2=80=9C?= =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E5=8A=A0=E8=BD=BD=E5=AE=9E=E8=AE=AD=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=EF=BC=8C=E8=AF=B7=E7=A8=8D=E7=AD=89=E2=80=A6=20?= =?UTF-8?q?=E2=80=A6=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_shixun_top.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb index 611417cbe..8c78aec16 100644 --- a/app/views/shixuns/_shixun_top.html.erb +++ b/app/views/shixuns/_shixun_top.html.erb @@ -15,7 +15,7 @@ <% else %> <% if @shixun.status == 1 %>
    - <%= link_to "开始挑战", shixun_exec_shixun_path(@shixun), :class => "fr task-btn task-btn-orange font-14", :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 %> From 6197699b7cf89258429e6a2bfb1171aa0bc5340b Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 14:18:47 +0800 Subject: [PATCH 19/27] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=89=88ajax?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/css/bigdata-common.css | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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; +} From 25648fdfbf8d69972cca734bd32f8ceb9326480d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Apr 2017 14:27:25 +0800 Subject: [PATCH 20/27] =?UTF-8?q?=E6=84=8F=E8=A7=81=E5=8F=8D=E9=A6=88?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=EF=BC=8C=E7=BB=99=E5=87=BA=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_send_error_pop.html.erb | 3 +++ app/views/games/_send_success_pop.html.erb | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 app/views/games/_send_success_pop.html.erb 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 @@ +
    +
    +

    发送成功

    + +
    +
    +
    +
      +
    • + 已发送给导师和管理员 +
    • +
    +
    +
    From 01a6f9f894a781dc86889a5e92be8e91766be10a Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 14:33:09 +0800 Subject: [PATCH 21/27] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8F=AF=E8=BF=90=E8=A1=8C=E6=96=87=E4=BB=B6=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 92f9d61cf..962508f26 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 From b184f927f1bc89c1b82fd02fc2732329d55bc88c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Apr 2017 14:36:48 +0800 Subject: [PATCH 22/27] =?UTF-8?q?=E9=80=80=E5=87=BA=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E5=88=B0=E5=AE=9E=E8=AE=AD=E4=B8=BB=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_code_actions.html.erb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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 From 61b46f4aadf725cccf2178e45bcbae6e44f5cb2c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Apr 2017 16:24:29 +0800 Subject: [PATCH 23/27] =?UTF-8?q?codeMirror=E9=AB=98=E5=BA=A6=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=9E=E8=AE=ADjson=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 2 +- app/views/games/_file_edit_form.html.erb | 4 ++-- app/views/games/_game_show.html.erb | 5 +++-- app/views/games/show.html.erb | 4 ++-- app/views/shixuns/_monitor_tip.html.erb | 2 +- public/stylesheets/css/taskstyle.css | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 962508f26..0036f4838 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -116,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 diff --git a/app/views/games/_file_edit_form.html.erb b/app/views/games/_file_edit_form.html.erb index 86e257180..cbd3dab09 100644 --- a/app/views/games/_file_edit_form.html.erb +++ b/app/views/games/_file_edit_form.html.erb @@ -65,7 +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); - $(".CodeMirror-scroll").css("max-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/show.html.erb b/app/views/games/show.html.erb index 64d3d695a..e5df62bbf 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -37,8 +37,8 @@ control = 0; } var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10; - $(".CodeMirror-scroll").css("min-height", h); - $(".CodeMirror-scroll").css("max-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/shixuns/_monitor_tip.html.erb b/app/views/shixuns/_monitor_tip.html.erb index 11473f249..7a8c99547 100644 --- a/app/views/shixuns/_monitor_tip.html.erb +++ b/app/views/shixuns/_monitor_tip.html.erb @@ -4,7 +4,7 @@
    -
    +
    • <% if result %> 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;} From b9ddfec8d27994207b133d8b93a601dc23cddf3a Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 16:29:26 +0800 Subject: [PATCH 24/27] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=94=B9=E6=88=90=E9=A1=B9=E7=9B=AE=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_logined_header.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 93d4433de..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 "游戏实训", shixuns_path, :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" %>
    • From 4d7f192a44f104c64390a104340ce9746c797a17 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 16:40:00 +0800 Subject: [PATCH 25/27] =?UTF-8?q?=E5=8C=BA=E5=88=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=92=8C=E6=B2=A1=E7=99=BB=E9=99=86=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=AF=BC=E8=88=AA=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_unlogin_header.html.erb | 2 -- 1 file changed, 2 deletions(-) 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" %>
    • From 6d5ecdf70c7aafa3f49f15747a14afa241a5aecb Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 17:05:39 +0800 Subject: [PATCH 26/27] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 30507006eb70009469e0fee9c758965d5cf8ccc2 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 27 Apr 2017 17:34:12 +0800 Subject: [PATCH 27/27] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- app/controllers/shixuns_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index eb1c62a8a..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) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5f108b45f..c647c1b53 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -58,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}