搜索课程结果列表课程动态

This commit is contained in:
sw 2015-08-13 11:47:08 +08:00
parent 29092db557
commit 23f8bd8312
2 changed files with 43 additions and 43 deletions

View File

@ -124,47 +124,47 @@ class CoursesController < ApplicationController
@course_pages = Paginator.new @course_count, per_page_option, params['page']
# 课程的动态数
@course_activity_count=Hash.new
@courses_all.each do |course|
@course_activity_count[course.id]=0
end
case params[:course_sort_type]
when '0'
@courses = @courses_all.order("created_at desc")
@s_type = 0
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
when '1'
@courses = @courses_all.order("course_ac_para desc")
@s_type = 1
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
when '2'
@courses = @courses_all.order("watchers_count desc")
@s_type = 2
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
when '3'
@course_activity_count=get_course_activity @courses_all,@course_activity_count_array
@courses=handle_course @courses_all,@course_activity_count
@s_type = 3
@courses = @courses[@course_pages.offset, @course_pages.per_page]
else
@s_type = 0
@courses = @courses_all.order("created_at desc")
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
end
# @course_activity_count=Hash.new
# @courses_all.each do |course|
# @course_activity_count[course.id]=0
# end
#
# case params[:course_sort_type]
# when '0'
# @courses = @courses_all.order("created_at desc")
# @s_type = 0
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# when '1'
# @courses = @courses_all.order("course_ac_para desc")
# @s_type = 1
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# when '2'
# @courses = @courses_all.order("watchers_count desc")
# @s_type = 2
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# when '3'
# @course_activity_count=get_course_activity @courses_all,@course_activity_count_array
# @courses=handle_course @courses_all,@course_activity_count
# @s_type = 3
# @courses = @courses[@course_pages.offset, @course_pages.per_page]
#
# else
# @s_type = 0
# @courses = @courses_all.order("created_at desc")
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# end
end
respond_to do |format|

View File

@ -61,8 +61,8 @@
<!--gcm-->
<p class="stats">
<%= content_tag('span', link_to("#{course_activity_count @course}", course_path(@course)), :class => "info") %>
<%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %>
<%= content_tag('span', link_to("#{@course.course_activities.count}", course_path(@course)), :class => "info") %>
<%= content_tag('span', l(:label_x_activity, :count => @course.course_activities.count)) %>
</p>
<!--gcm-->