dev_local
daiao 6 years ago
parent aee5cf576d
commit fd831f32bf

@ -142,6 +142,13 @@ class ApplicationController < ActionController::Base
end end
end end
# 本地考试使用
def local_exam
if LocalSetting.first.try(:exam) && !User.current.admin?
render_403
end
end
def user_agent def user_agent
logger.info "HTTP_USER_AGENT #{request.env["HTTP_USER_AGENT"]}" logger.info "HTTP_USER_AGENT #{request.env["HTTP_USER_AGENT"]}"
end end

@ -18,6 +18,7 @@
class BoardsController < ApplicationController class BoardsController < ApplicationController
layout 'base_projects'#by young layout 'base_projects'#by young
default_search_scope :messages default_search_scope :messages
before_filter :local_exam
# before_filter :check_authentication, :except => [] # before_filter :check_authentication, :except => []
before_filter :find_project_by_project_id, :find_board_if_available, :except => [:join_to_org_subfields] before_filter :find_project_by_project_id, :find_board_if_available, :except => [:join_to_org_subfields]
before_filter :authorize, :except => [:new, :show, :create, :index, :join_to_org_subfields, :update_position, :update_name, :update_boards_position, :update_boards_name] before_filter :authorize, :except => [:new, :show, :create, :index, :join_to_org_subfields, :update_position, :update_name, :update_boards_position, :update_boards_name]

@ -13,6 +13,7 @@ class CoursesController < ApplicationController
include ApplicationHelper include ApplicationHelper
helper SyllabusesHelper helper SyllabusesHelper
before_filter :local_exam, :except => [:show]
# before_filter :auth_login1, :only => [:show, :course_activity, :feedback] # before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
if Redmine::Configuration['gitlab_address'].include?("test") if Redmine::Configuration['gitlab_address'].include?("test")
skip_before_filter :verify_authenticity_token, :only => [:update_course_module, :join_course_multi_role] skip_before_filter :verify_authenticity_token, :only => [:update_course_module, :join_course_multi_role]
@ -1617,6 +1618,8 @@ class CoursesController < ApplicationController
end end
def show def show
if LocalSetting.first.try(:exam) && !User.current.admin?
else
# 被删除的课程只有超级管理员才能看到is_delete为1的时候标记课程被删除 # 被删除的课程只有超级管理员才能看到is_delete为1的时候标记课程被删除
# if @course.is_delete == 1 && !User.current.admin? # if @course.is_delete == 1 && !User.current.admin?
# render_403 # render_403
@ -1745,6 +1748,7 @@ class CoursesController < ApplicationController
@left_nav_type = 1 @left_nav_type = 1
@show_page = true @show_page = true
end
respond_to do |format| respond_to do |format|
format.js format.js
format.html{render :layout => 'base_courses'} format.html{render :layout => 'base_courses'}

@ -27,6 +27,10 @@ class ExerciseController < ApplicationController
return return
end end
if LocalSetting.first.try(:exam) && !User.current.admin?
params[:type] = 2
end
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
if @is_teacher if @is_teacher
exercises = @course.exercises.order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC") exercises = @course.exercises.order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")

@ -20,6 +20,7 @@ class FilesController < ApplicationController
layout 'base_projects' #by young layout 'base_projects' #by young
menu_item :files menu_item :files
before_filter :local_exam
# before_filter :check_authentication, :except => [] # before_filter :check_authentication, :except => []
# before_filter :auth_login1, :only => [:index] # before_filter :auth_login1, :only => [:index]
# before_filter :logged_user_by_apptoken,:only => [:index] # before_filter :logged_user_by_apptoken,:only => [:index]

@ -1,5 +1,6 @@
#encoding: utf-8 #encoding: utf-8
class GraduationTasksController < ApplicationController class GraduationTasksController < ApplicationController
before_filter :local_exam
before_filter :find_course, :only => [:index, :new, :create] before_filter :find_course, :only => [:index, :new, :create]
before_filter :find_task, :only => [:show, :edit, :update, :destroy, :task_discuss, :task_setting, :publish_task, :end_task] before_filter :find_task, :only => [:show, :edit, :update, :destroy, :task_discuss, :task_setting, :publish_task, :end_task]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy] before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy]

@ -1,5 +1,6 @@
#encoding: utf-8 #encoding: utf-8
class GraduationTopicsController < ApplicationController class GraduationTopicsController < ApplicationController
before_filter :local_exam
before_filter :find_course, :only => [:index, :new, :create, :search_teacher, :export] before_filter :find_course, :only => [:index, :new, :create, :search_teacher, :export]
before_filter :find_topic, :only => [:show, :edit, :update, :destroy, :set_public, :student_select_topic, :cancel_topic_select, :refuse_select, before_filter :find_topic, :only => [:show, :edit, :update, :destroy, :set_public, :student_select_topic, :cancel_topic_select, :refuse_select,
:accept_select] :accept_select]

@ -8,6 +8,7 @@ class HomeworkCommonController < ApplicationController
include StudentWorkHelper include StudentWorkHelper
include ApplicationHelper include ApplicationHelper
# before_filter :check_authentication, :except => [] # before_filter :check_authentication, :except => []
before_filter :local_exam
before_filter :find_course, :only => [:index,:new,:create, :shixuns, :create_shixun_homework, :publish_shixun_homework] before_filter :find_course, :only => [:index,:new,:create, :shixuns, :create_shixun_homework, :publish_shixun_homework]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set, before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,
:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works, :set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,

@ -1,5 +1,6 @@
#encoding utf-8 #encoding utf-8
class PollController < ApplicationController class PollController < ApplicationController
before_filter :local_exam
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:publish_notice,:end_notice,:cancel_publish,:poll_result, before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:publish_notice,:end_notice,:cancel_publish,:poll_result,
:close_poll,:export_poll,:save_poll,:update_question_num, :student_poll_list, :poll_setting, :set_public, :add_to_exercise_bank] :close_poll,:export_poll,:save_poll,:update_question_num, :student_poll_list, :poll_setting, :set_public, :add_to_exercise_bank]
before_filter :find_container, :only => [:new,:create, :index] before_filter :find_container, :only => [:new,:create, :index]

@ -10,7 +10,11 @@
<div class="with78 fl"> <div class="with78 fl">
<div class="ml20 clearfix"> <div class="ml20 clearfix">
<div id="course_activities_content"> <div id="course_activities_content">
<% if LocalSetting.first.try(:exam) && !User.current.admin? %>
<%= render :partial => 'welcome/no_data' %>
<% else %>
<%= render :partial => 'courses/course_activity_content', :locals => {:course_activities => @course_activities} %> <%= render :partial => 'courses/course_activity_content', :locals => {:course_activities => @course_activities} %>
<% end %>
</div> </div>
</div> </div>
</div> </div>
Loading…
Cancel
Save