diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index b1020d938..4923c629e 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -582,7 +582,7 @@ module UsersHelper option << "请选择发布作业的课程" option << -1 type << option - user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| + user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| option = [] option << course.name+"("+course.time.to_s+course.term+")" option << course.id