课堂的作业列表按照发布时间倒序排序
This commit is contained in:
parent
aac531ca54
commit
cd6486671f
|
|
@ -31,22 +31,22 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
if @order.blank?
|
||||
if @is_teacher
|
||||
@homework_commons = @homework_commons.order("created_at desc")
|
||||
@homework_commons = @homework_commons.order("publish_time desc")
|
||||
else
|
||||
@homework_commons = @homework_commons.where("publish_time <= '#{Time.now}'").order("created_at desc")
|
||||
@homework_commons = @homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time desc")
|
||||
end
|
||||
else
|
||||
case @order
|
||||
when '1'
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and end_time > '#{Time.now}'").order("homework_commons.created_at desc")
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and end_time > '#{Time.now}'").order("homework_commons.publish_time desc")
|
||||
when '3'
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}'").order("homework_commons.created_at desc")
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}'").order("homework_commons.publish_time desc")
|
||||
when '4'
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.appeal_time > '#{Time.now}')").order("homework_commons.created_at desc")
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.appeal_time > '#{Time.now}')").order("homework_commons.publish_time desc")
|
||||
when '5'
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}')").order("homework_commons.created_at desc")
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}')").order("homework_commons.publish_time desc")
|
||||
else
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order}").order("homework_commons.created_at desc")
|
||||
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order}").order("homework_commons.publish_time desc")
|
||||
end
|
||||
end
|
||||
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
||||
|
|
|
|||
|
|
@ -4833,15 +4833,15 @@ def get_hw_index(hw,is_teacher,type=0)
|
|||
homework_commons = hw.course.homework_commons
|
||||
if is_teacher
|
||||
if type != 0
|
||||
homeworks = homework_commons.where("homework_commons.homework_type = #{type}").order("created_at asc")
|
||||
homeworks = homework_commons.where("homework_commons.homework_type = #{type}").order("publish_time desc")
|
||||
else
|
||||
homeworks = homework_commons.order("created_at asc")
|
||||
homeworks = homework_commons.order("publish_time desc")
|
||||
end
|
||||
else
|
||||
if type != 0
|
||||
homeworks = homework_commons.where("homework_commons.homework_type = #{type} and publish_time <= '#{Time.now}'").order("created_at asc")
|
||||
homeworks = homework_commons.where("homework_commons.homework_type = #{type} and publish_time <= '#{Time.now}'").order("publish_time desc")
|
||||
else
|
||||
homeworks = homework_commons.where("publish_time <= '#{Time.now}'").order("created_at asc")
|
||||
homeworks = homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time desc")
|
||||
end
|
||||
end
|
||||
hw_ids = homeworks.map{|hw| hw.id} if !homeworks.blank?
|
||||
|
|
|
|||
Loading…
Reference in New Issue