From cd6486671f58b238686df15a8a5eec17d782b4fb Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 9 Oct 2017 14:38:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E7=9A=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8C=89=E7=85=A7=E5=8F=91=E5=B8=83=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=80=92=E5=BA=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 14 +++++++------- app/helpers/application_helper.rb | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) 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?