diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index e3bb92b98..7bf122847 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -15,7 +15,7 @@ class BlogsController < ApplicationController @b_sort = 1 end - sort_name = "updated_on" + sort_name = "updated_at" sort_type = @b_sort == 1 ? "desc" : "asc" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8e08508ed..c4f1de41e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -41,7 +41,7 @@ class UsersController < ApplicationController :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, - :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course] + :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -2845,6 +2845,49 @@ class UsersController < ApplicationController end end + def user_courselist + @order, @c_sort,@type = params[:order] || 1, params[:sort] || 2, params[:type] || 1 + + + #确定 sort_type + if @order.to_i == @type.to_i + @c_sort = @c_sort.to_i == 1 ? 2 : 1 #2降序 1升序 + else + @c_sort = 1 + end + + sort_name = "updated_at" + sort_type = @c_sort == 1 ? "desc" : "asc" + + if @user.courses.visible.count > 0 + course_order_ids = "(" + CourseActivity.find_by_sql("SELECT c.course_id, updated_at FROM(SELECT ca.course_id, MAX(ca.updated_at) AS updated_at FROM course_activities ca WHERE ca.course_id IN (" + @user.courses.visible.select('courses.id').map{|c| c.id}.join(',') + ") GROUP BY ca.course_id) AS c ").map {|c| c.course_id}.join(",") + ")" + @courses = Course.where("id in #{course_order_ids}").order("#{sort_name} #{sort_type}") + else + @courses = [] + end + + #根据 作业+资源数排序 + if @order.to_i == 2 + @type = 2 + @c_sort == 1 ? (@courses = @courses.sort{|x,y| (y.homework_commons.count + visable_attachemnts_incourse(y).count) <=> (x.homework_commons.count + visable_attachemnts_incourse(x).count) }) : (@courses.sort{|x,y| (x.homework_commons.count + visable_attachemnts_incourse(x).count) <=> (y.homework_commons.count + visable_attachemnts_incourse(y).count) }) + else + @type = 1 + end + + #分页 + @limit = 10 + @is_remote = true + @atta_count = @courses.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + @courses = paginateHelper @courses,@limit + + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + end + private def find_user diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index 10ce3ee64..1b9ef992e 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -64,7 +64,7 @@ var rightHeight = $(".homepageRight").height(); if (rightHeight < leftHeight){ var diffHeight = leftHeight - rightHeight; - var blogHeight = $(".listbox").height()+diffHeight; - $(".listbox").css("height",blogHeight); + var tmpHeight = $(".listbox").height()+diffHeight; + $(".listbox").css("height",tmpHeight); } \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 4e1064b7f..5077ecab3 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -186,7 +186,8 @@ <%= link_to "动态",user_activities_path(@user.id),:class => "homepageMenuText"%>
<%= homework_num %>作业| <%= visable_attachemnts_incourse(course).count %>资源
+