作业的状态过滤

ecloud_sso
cxt 5 years ago
parent dc30bd9491
commit 6ef7ff36b2

@ -70,17 +70,25 @@ class HomeworkCommonsController < ApplicationController
else
case order
when '1'
unified_homework_ids = @homework_commons.published_no_end.unified_setting.pluck(:id)
group_homework_ids = @course.homework_group_settings.published_no_end.pluck(:homework_common_id)
homework_ids = unified_homework_ids + group_homework_ids
homework_ids = homework_ids.blank? ? "(-1)" : "(" + homework_ids.join(",") + ")"
sql_str = %Q(homework_commons.id in #{homework_ids})
if @user_course_identity == Course::STUDENT
unified_homework_ids = @homework_commons.published_no_end.unified_setting.pluck(:id)
group_homework_ids = @course.homework_group_settings.where("course_group_id = #{@member.course_group_id&.to_i}").published_no_end.pluck(:homework_common_id)
homework_ids = unified_homework_ids + group_homework_ids
homework_ids = homework_ids.blank? ? "(-1)" : "(" + homework_ids.join(",") + ")"
sql_str = %Q(homework_commons.id in #{homework_ids})
else
sql_str = %Q(homework_detail_manuals.comment_status = #{order} and homework_commons.end_time > '#{Time.now}')
end
when '2'
unified_homework_ids = @homework_commons.homework_ended.unified_setting.pluck(:id)
group_homework_ids = @course.homework_group_settings.has_end.pluck(:homework_common_id)
homework_ids = unified_homework_ids + group_homework_ids
homework_ids = homework_ids.blank? ? "(-1)" : "(" + homework_ids.join(",") + ")"
sql_str = %Q(homework_commons.id in #{homework_ids} and allow_late = 1 and (late_time is null or late_time > '#{Time.now}'))
if @user_course_identity == Course::STUDENT
unified_homework_ids = @homework_commons.homework_ended.unified_setting.pluck(:id)
group_homework_ids = @course.homework_group_settings.where("course_group_id = #{@member.course_group_id&.to_i}").has_end.pluck(:homework_common_id)
homework_ids = unified_homework_ids + group_homework_ids
homework_ids = homework_ids.blank? ? "(-1)" : "(" + homework_ids.join(",") + ")"
sql_str = %Q(homework_commons.id in #{homework_ids} and allow_late = 1 and (late_time is null or late_time > '#{Time.now}'))
else
sql_str = %Q(allow_late = 1 and homework_commons.end_time < '#{Time.now}' and (late_time is null or late_time > '#{Time.now}'))
end
when '3'
sql_str = %Q(homework_detail_manuals.comment_status = #{order} and homework_detail_manuals.evaluation_end > '#{Time.now}')
when '4'

Loading…
Cancel
Save