diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 6e56e44c6..26f89d0e3 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -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)) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 78c0920a3..93f500d9d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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?