作业列表调整

chromesetting
cxt 6 years ago
parent 6f8c201692
commit 222d82f078

@ -27,13 +27,14 @@ module HomeworkCommonsHelper
if homework_common.end_time && homework_common.end_time < Time.now && homework_common.allow_late && if homework_common.end_time && homework_common.end_time < Time.now && homework_common.allow_late &&
(homework_common.late_time.nil? || homework_common.late_time > Time.now) (homework_common.late_time.nil? || homework_common.late_time > Time.now)
status << "补交中" status << "补交中"
end time = "补交剩余时间:" + how_much_time(homework_common.late_time)
time_status = 2
ho_detail_manual = homework_common.homework_detail_manual else
if ho_detail_manual ho_detail_manual = homework_common.homework_detail_manual
# 作业状态大于“提交”状态时,不用考虑分班权限 if ho_detail_manual
if ho_detail_manual.comment_status > 1 # 作业状态大于“提交”状态时,不用考虑分班权限
case ho_detail_manual.comment_status if ho_detail_manual.comment_status > 1
case ho_detail_manual.comment_status
when 2 when 2
unless homework_common.allow_late unless homework_common.allow_late
status << "已截止" status << "已截止"
@ -56,23 +57,16 @@ module HomeworkCommonsHelper
status << "已截止" status << "已截止"
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : "" time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
time_status = 5 time_status = 5
end end
else
# 如果还在补交阶段则显示补交结束时间 # member = course.course_members.find_by(user_id: user.id, is_active: 1)
if homework_common.end_time && homework_common.end_time < Time.now && homework_common.allow_late && # teacher_course_groups = member.try(:teacher_course_groups)
homework_common.late_time && homework_common.late_time > Time.now # identity = user.course_identity(course)
time = "补交剩余时间:" + how_much_time(homework_common.late_time)
time_status = 2
end
else
# member = course.course_members.find_by(user_id: user.id, is_active: 1)
# teacher_course_groups = member.try(:teacher_course_groups)
# identity = user.course_identity(course)
# 作业统一设置、游客身份、超级管理员、分班权限不限的老师身份 # 作业统一设置、游客身份、超级管理员、分班权限不限的老师身份
if homework_common.unified_setting || identity > Course::STUDENT || identity == Course::ADMIN || if homework_common.unified_setting || identity > Course::STUDENT || identity == Course::ADMIN ||
(identity < Course::STUDENT && teacher_course_groups.blank?) (identity < Course::STUDENT && teacher_course_groups.blank?)
case ho_detail_manual.comment_status case ho_detail_manual.comment_status
when 0 when 0
status << "未发布" status << "未发布"
time = homework_common.publish_time.present? ? "将于 #{format_time(homework_common.publish_time)} 发布" : "创建于#{time_from_now(homework_common.created_at)}" time = homework_common.publish_time.present? ? "将于 #{format_time(homework_common.publish_time)} 发布" : "创建于#{time_from_now(homework_common.created_at)}"
@ -88,58 +82,58 @@ module HomeworkCommonsHelper
time_status = 2 time_status = 2
else else
status << "已截止" status << "已截止"
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
time_status = 5 time_status = 5
end end
end end
end end
else
# 未分班的学生始终显示“未发布”(按理不会来到这个判断)
if member.role == "STUDENT" && member.course_group_id == 0
status << "未发布"
time = ""
time_status = 0
else else
if member.role == "STUDENT" # 未分班的学生始终显示“未发布”(按理不会来到这个判断)
setting = homework_common.homework_group_settings.find_by(course_group_id: member.course_group_id) if member.role == "STUDENT" && member.course_group_id == 0
min_publish_time = setting.try(:publish_time) status << "未发布"
max_end_time = setting.try(:end_time) time = ""
time_status = 0
else else
# 多个分班权限的取最小publish_time最大end_time if member.role == "STUDENT"
min_publish_time = homework_common.homework_group_settings.where.not(publish_time: nil). setting = homework_common.homework_group_settings.find_by(course_group_id: member.course_group_id)
min_publish_time = setting.try(:publish_time)
max_end_time = setting.try(:end_time)
else
# 多个分班权限的取最小publish_time最大end_time
min_publish_time = homework_common.homework_group_settings.where.not(publish_time: nil).
where(course_group_id: teacher_course_groups.pluck(:course_group_id)).pluck(:publish_time).min where(course_group_id: teacher_course_groups.pluck(:course_group_id)).pluck(:publish_time).min
max_end_time = homework_common.homework_group_settings.where.not(end_time: nil). max_end_time = homework_common.homework_group_settings.where.not(end_time: nil).
where(course_group_id: teacher_course_groups.pluck(:course_group_id)).pluck(:end_time).max where(course_group_id: teacher_course_groups.pluck(:course_group_id)).pluck(:end_time).max
end end
if min_publish_time.nil? if min_publish_time.nil?
status << "未发布" status << "未发布"
time = "创建于#{time_from_now(homework_common.created_at)}" time = "创建于#{time_from_now(homework_common.created_at)}"
time_status = 0 time_status = 0
elsif min_publish_time > Time.now elsif min_publish_time > Time.now
status << "未发布" status << "未发布"
time = "将于 #{format_time(min_publish_time)} 发布" time = "将于 #{format_time(min_publish_time)} 发布"
time_status = 0 time_status = 0
elsif max_end_time.present? && max_end_time > Time.now #6.14 -hs 添加present? elsif max_end_time.present? && max_end_time > Time.now #6.14 -hs 添加present?
status << "提交中" status << "提交中"
time = "提交剩余时间:" + how_much_time(max_end_time) time = "提交剩余时间:" + how_much_time(max_end_time)
time_status = 1 time_status = 1
elsif homework_common.allow_late && (homework_common.late_time.nil? || homework_common.late_time >= Time.now) else
time = "补交剩余时间:" + how_much_time(homework_common.late_time) status << "已截止"
time_status = 2 time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
else time_status = 5
status << "已截止" end
time = ""
time_status = 5
end end
end end
status << "未开启补交" if !homework_common.allow_late && time_status == 1
end end
status << "未开启补交" if !homework_common.allow_late && time_status == 1
end end
end end
end end
# 如果作业状态都没有的话,在课堂结束前,都显示已截止 # 如果作业状态都没有的话,在课堂结束前,都显示已截止
if status.blank? if status.blank?
status << "已截止" status << "已截止"
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
time_status = 5 time_status = 5
end end
result[:status] = status result[:status] = status

Loading…
Cancel
Save