From 8ac2640a097804b488d51107b9dd8c7eba72f3f4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 8 Oct 2014 10:48:10 +0800 Subject: [PATCH] =?UTF-8?q?#1293=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E8=AF=BE=E7=A8=8B=E5=AE=9E?= =?UTF-8?q?=E8=B7=B5=E9=A1=B5=E9=9D=A2url=E8=BF=9B=E5=85=A5=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E7=A7=81=E6=9C=89=E8=AF=BE=E7=A8=8B=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E7=9A=84BUG=20=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=EF=BC=9A?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E6=8C=89=E9=92=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD=EF=BC=9B=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=AE=9E=E8=B7=B5=E7=95=8C=E9=9D=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 32 ++++++++++++++----------- app/helpers/watchers_helper.rb | 2 +- app/views/layouts/base_courses.html.erb | 1 - 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e24a7386d..0ee9dc968 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -470,23 +470,27 @@ class CoursesController < ApplicationController end def homework - @offset, @limit = api_offset_and_limit({:limit => 10}) - @bids = @course.homeworks.order('deadline DESC') - @bids = @bids.like(params[:name]) if params[:name].present? - @bid_count = @bids.count - @bid_pages = Paginator.new @bid_count, @limit, params['page'] - - @offset ||= @bid_pages.reverse_offset - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse + if @course.is_public == 0 + render_403 else - limit = @bid_count % @limit - if limit == 0 - limit = 10 + @offset, @limit = api_offset_and_limit({:limit => 10}) + @bids = @course.homeworks.order('deadline DESC') + @bids = @bids.like(params[:name]) if params[:name].present? + @bid_count = @bids.count + @bid_pages = Paginator.new @bid_count, @limit, params['page'] + + @offset ||= @bid_pages.reverse_offset + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + if limit == 0 + limit = 10 + end + @bids = @bids.offset(@offset).limit(limit).all.reverse end - @bids = @bids.offset(@offset).limit(limit).all.reverse + render :layout => 'base_courses' end - render :layout => 'base_courses' end # 新建作业 diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 56b2ec0f4..155485b4c 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -97,7 +97,7 @@ module WatchersHelper return '' unless user && user.logged? # modify by nwb # 主讲教师不允许退出课程 - return '' if user.id == course.tea_id + return '' if user.id == course.tea_id || course.is_public == 0 joined = user.member_of_course?(course) text = joined ? l(:label_exit_course) : l(:label_join_course) url_t = join_path(:object_id => course.id) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 4554b0466..906574b9e 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -78,7 +78,6 @@ <%= link_to l(:label_course_modify_settings), {:controller => 'courses', :action => 'settings', :id => @course} %> <%= render :partial => 'courses/set_course_time', :locals => {:course => @course} %> <% else %> - <%= join_in_course(@course, User.current) %> <% end %> <% unless User.current.member_of_course?(@course) %>