diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 41ea9c45e..21dac6ada 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -888,23 +888,25 @@ class CoursesController < ApplicationController if params[:type].present? case params[:type] when "homework" - @course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").order('updated_at desc') when "news" - @course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc') when "message" - @course_activities = course_activities.where("course_act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'Message'").order('updated_at desc') when "poll" - @course_activities = course_activities.where("course_act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'Poll'").order('updated_at desc') when "attachment" - @course_activities = course_activities.where("course_act_type = 'Attachment'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'Attachment'").order('updated_at desc') when "journalsForMessage" - @course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").order('updated_at desc') else - @course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.order('updated_at desc') end else - @course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.order('updated_at desc') end + @course_activities_count = @course_activities.count + @course_activities = @course_activities.limit(10).offset(@page * 10) @type = params[:type] @left_nav_type = 1 diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index 16d151d83..993c767d6 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -78,7 +78,7 @@ <% end %> <% end %> -<% if course_activities.count == 10 %> +<% if course_activities.count + page * 10 < @course_activities_count %> <%= link_to "点击展开更多",course_activity_path(@course.id, :type => type, :page => page),:id => "show_more_course_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> <% end %>