课程列表修改
This commit is contained in:
parent
c8eaf293e7
commit
d34b3780c8
|
@ -6,25 +6,25 @@ class BlogsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@article = BlogComment.new
|
@article = BlogComment.new
|
||||||
|
|
||||||
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 2, params[:type] || 1
|
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||||
|
|
||||||
#确定 sort_type
|
#确定 sort_type 1升序 2 降序
|
||||||
if @order.to_i == @type.to_i
|
if @order.to_i == @type.to_i
|
||||||
@b_sort = @b_sort.to_i == 1 ? 2 : 1
|
@b_sort = @b_sort.to_i == 1 ? 2 : 1
|
||||||
else
|
else
|
||||||
@b_sort = 1
|
@b_sort = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
sort_name = "updated_at"
|
sort_name = "updated_at"
|
||||||
|
|
||||||
sort_type = @b_sort == 1 ? "desc" : "asc"
|
sort_type = @b_sort == 1 ? "asc" : "desc"
|
||||||
|
|
||||||
@topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{sort_type}")
|
@topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{sort_type}")
|
||||||
|
|
||||||
#根据 赞+回复数排序
|
#根据 赞+回复数排序
|
||||||
if @order.to_i == 2
|
if @order.to_i == 2
|
||||||
@type = 2
|
@type = 2
|
||||||
@b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) }
|
@b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) }
|
||||||
else
|
else
|
||||||
@type = 1
|
@type = 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -2846,18 +2846,18 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_courselist
|
def user_courselist
|
||||||
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 2, params[:type] || 1
|
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||||
|
|
||||||
|
|
||||||
#确定 sort_type
|
#确定 sort_type
|
||||||
if @order.to_i == @type.to_i
|
if @order.to_i == @type.to_i
|
||||||
@c_sort = @c_sort.to_i == 1 ? 2 : 1 #2降序 1升序
|
@c_sort = @c_sort.to_i == 1 ? 2 : 1 #1升序 2降序
|
||||||
else
|
else
|
||||||
@c_sort = 1
|
@c_sort = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
sort_name = "updated_at"
|
sort_name = "updated_at"
|
||||||
sort_type = @c_sort == 1 ? "desc" : "asc"
|
sort_type = @c_sort == 1 ? "asc" : "desc"
|
||||||
|
|
||||||
if @user.courses.visible.count > 0
|
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(",") + ")"
|
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(",") + ")"
|
||||||
|
@ -2869,7 +2869,11 @@ class UsersController < ApplicationController
|
||||||
#根据 作业+资源数排序
|
#根据 作业+资源数排序
|
||||||
if @order.to_i == 2
|
if @order.to_i == 2
|
||||||
@type = 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) })
|
@courses.each do |course|
|
||||||
|
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count)
|
||||||
|
puts course[:infocount]
|
||||||
|
end
|
||||||
|
@c_sort == 1 ? (@courses = @courses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@courses = @courses.sort{|x,y| y[:infocount] <=> x[:infocount]})
|
||||||
else
|
else
|
||||||
@type = 1
|
@type = 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//如果右边的列表比左边的高度低则将右边的高度设为与左边对齐
|
//如果右边的列表比左边的高度低则将右边的高度设为与左边对齐
|
||||||
var leftHeight = $("#LSide").height()-$(".fontGrey5").height()-10;
|
var leftHeight = $("#LSide").height()-$(".fontGrey5").height()-20;
|
||||||
var rightHeight = $(".homepageRight").height();
|
var rightHeight = $(".homepageRight").height();
|
||||||
if (rightHeight < leftHeight){
|
if (rightHeight < leftHeight){
|
||||||
var diffHeight = leftHeight - rightHeight;
|
var diffHeight = leftHeight - rightHeight;
|
||||||
|
|
Loading…
Reference in New Issue