From bb725e981a278b0582884b4ab29f96bc6006849f Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 17 Apr 2019 18:21:41 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=80=83=E8=AF=95=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E3=80=81=E9=A1=B9=E7=9B=AE=E3=80=81=E5=AE=9E=E8=AE=AD=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 9 ++------- app/controllers/projects_controller.rb | 8 ++++++++ app/controllers/users_controller.rb | 2 +- app/services/games_service.rb | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index eefedb5b..d7f04759 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -62,14 +62,9 @@ module Mobile end def memo_authenticate! - pass = (request.path.match(/memos\/\d+/).present? && !request.path.include?("reply")) || - request.path.include?("get_memos_list") || - request.path.include?("memos?page=") || request.path.match(/memos$/).present? - - unless pass - error!('401 Unauthorized', 401) unless current_user + if LocalSetting.first.try(:exam) && !current_user.admin? + redirect '/' end - end def discusses_authenticate! diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8078da87..096fe5a4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -29,6 +29,7 @@ class ProjectsController < ApplicationController # menu_item :share, :only => :share skip_before_filter :verify_authenticity_token, :only => [:training_task_status] skip_before_filter :check_if_login_required, :only => [:training_task_status] + before_filter :local_exam before_filter :check_authentication before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise, :view_homework_attaches,:join_project, :project_home, :training_execute, :training_task_status] @@ -37,6 +38,7 @@ class ProjectsController < ApplicationController before_filter :require_admin, :only => [ :copy, :unarchive, :calendar] before_filter :require_admin_or_manager, :only => [ :destroy] before_filter :file + before_filter :local_exam # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 @@ -738,6 +740,12 @@ class ProjectsController < ApplicationController def file end + def local_exam + if LocalSetting.first.try(:exam) && !User.current.admin? + render_403 + end + end + def statistics end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5a160436..c0ac28da 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -315,7 +315,7 @@ class UsersController < ApplicationController end def message_detail - if User.current == @user || User.current.admin? + if (User.current == @user && !LocalSetting.first.try(:exam)) || User.current.admin? @target_user = User.where(:id => params[:user_id]).includes(:user_extensions).first if @target_user.present? @message_list = @user.private_messages.where(:target_id => params[:user_id], :status => [0, 1]).order("send_time asc") diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 8573c683..cf709c4d 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -73,7 +73,8 @@ class GamesService :challenge => game_challenge.try(:attributes), :game => game.try(:attributes), :shixun => shixun.try(:attributes), :record => record, :grade => grade, :prev_game => prev_game, :next_game => next_game, :username => username, :image_url => image_url, :user_url => user_url, :praise_count => praise_count, :user_praise => user_praise, :time_limit => time_limit, - :tomcat_url => Redmine::Configuration['tomcat_php'], :is_teacher => is_teacher, :power => power, :myshixun_manager => myshixun_manager} + :tomcat_url => Redmine::Configuration['tomcat_php'], :is_teacher => is_teacher, :power => power, :myshixun_manager => myshixun_manager, + :local_exam => LocalSetting.first.try(:exam)} # 区分选择题和编程题,st:0编程题; if st == 0 From 9837411f69491406e07b58b4be307a2f92f2176f Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 17 Apr 2019 18:29:07 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=97=AE=E7=AD=94=E5=8C=BA=E5=B1=8F?= =?UTF-8?q?=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/categories_controller.rb | 6 +++++- app/controllers/forums_controller.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 05b36ba3..dd75c675 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -32,6 +32,10 @@ class CategoriesController < ApplicationController private def render_react - render "/common/index", :layout => false + if LocalSetting.first.try(:exam) && !current_user.admin? + render_403 + else + render "/common/index", :layout => false + end end end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index afb5b7dd..c1dae86e 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -28,7 +28,11 @@ class ForumsController < ApplicationController private def render_react - render "/common/index", :layout => false + if LocalSetting.first.try(:exam) && !current_user.admin? + render_403 + else + render "/common/index", :layout => false + end end end From ae1fd57e06164a2a1bcdb9624557eb87d65581fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 17 Apr 2019 18:40:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=A1=B5=E9=9D=A2=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_shixun.html.erb | 2 +- app/views/exercise/_new_shixun.html.erb | 215 +++++++++++++++++------ 2 files changed, 166 insertions(+), 51 deletions(-) diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb index 23396e40..6f44f7f9 100644 --- a/app/views/exercise/_edit_shixun.html.erb +++ b/app/views/exercise/_edit_shixun.html.erb @@ -40,7 +40,7 @@
实训题
- +
初级题 diff --git a/app/views/exercise/_new_shixun.html.erb b/app/views/exercise/_new_shixun.html.erb index 36a7789b..fe3e47aa 100644 --- a/app/views/exercise/_new_shixun.html.erb +++ b/app/views/exercise/_new_shixun.html.erb @@ -38,68 +38,131 @@ <% end %> -
实训题
+ -
-
新增实训题
+
新增实训题
@@ -122,8 +185,60 @@ <% end %> \ No newline at end of file + + function shixunboxdelete(num,key){ + var div=$("#shixunsbox"+num+" div");//获取所有子元素 + $("#shixunsbox"+num+" div")[key].remove(); + console.log(div) + } + + function newshixuns(){ + + var oDiv = document.getElementById('li'); + + } + + From fb0edab5d3b19dcaf4fdee9e68962270ced5b8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 17 Apr 2019 18:42:06 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_shixun.html.erb | 213 ++++++++++++++++++----- 1 file changed, 171 insertions(+), 42 deletions(-) diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb index 6f44f7f9..2475f05e 100644 --- a/app/views/exercise/_edit_shixun.html.erb +++ b/app/views/exercise/_edit_shixun.html.erb @@ -37,65 +37,132 @@ <% end %> +
实训题
-
- 初级题 +
+ +
  • +
    + + 中级题 + +
    + *分值: + 分/题 +
    *大于等于0,且不能大于100
    +
    *不能为空
    +
    *必须大于等于0
    +
    *不能大于100
    +
    + +
    + * + 随机出题量: 题 +
    *不能为空
    +
    *必须为正整数
    +
    *不能大于可用题数
    +
    + +
    + 3 + 题可用 +
    + +
    + + +
  • + + + +
    -
    新增实训题
    +
    新增实训题
    @@ -111,3 +178,65 @@
    + + + + + From 2d06967fc42699f02b4eb0f07a0b92e37b035eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 17 Apr 2019 18:42:25 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_shixun.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercise/_edit_shixun.html.erb b/app/views/exercise/_edit_shixun.html.erb index 2475f05e..f847d3fc 100644 --- a/app/views/exercise/_edit_shixun.html.erb +++ b/app/views/exercise/_edit_shixun.html.erb @@ -180,7 +180,7 @@
    - +