实训作业列表调整

chromesetting
cxt 5 years ago
parent faec9aaf6b
commit 1ad274851a

@ -24,109 +24,103 @@ module HomeworkCommonsHelper
time = course.end_date.strftime("%Y-%m-%d") time = course.end_date.strftime("%Y-%m-%d")
time_status = 6 time_status = 6
else else
if homework_common.end_time && homework_common.end_time < Time.now && homework_common.allow_late && ho_detail_manual = homework_common.homework_detail_manual
(homework_common.late_time.nil? || homework_common.late_time > Time.now) if ho_detail_manual
status << "补交中" # 作业状态大于“提交”状态时,不用考虑分班权限
time = "补交剩余时间:" + how_much_time(homework_common.late_time) if ho_detail_manual.comment_status > 1
time_status = 2 case ho_detail_manual.comment_status
else when 3
ho_detail_manual = homework_common.homework_detail_manual if ho_detail_manual.evaluation_end && ho_detail_manual.evaluation_end > Time.now
if ho_detail_manual status << "匿评中"
# 作业状态大于“提交”状态时,不用考虑分班权限 time = "提交剩余时间:" + how_much_time(ho_detail_manual.evaluation_end)
if ho_detail_manual.comment_status > 1 time_status = 3
case ho_detail_manual.comment_status end
when 2 when 4
unless homework_common.allow_late if ho_detail_manual.appeal_time && ho_detail_manual.appeal_time > Time.now
status << "已截止" status << "申诉中"
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : "" time = "申诉剩余时间:" + how_much_time(ho_detail_manual.appeal_time)
time_status = 5 time_status = 4
end end
when 3 else
if ho_detail_manual.evaluation_end && ho_detail_manual.evaluation_end > Time.now if homework_common.end_time && homework_common.end_time < Time.now && homework_common.allow_late &&
status << "匿评中" (homework_common.late_time.nil? || homework_common.late_time > Time.now)
time = "提交剩余时间:" + how_much_time(ho_detail_manual.evaluation_end) status << "补交中"
time_status = 3 time = "补交剩余时间:" + how_much_time(homework_common.late_time)
end time_status = 2
when 4 else
if ho_detail_manual.appeal_time && ho_detail_manual.appeal_time > Time.now
status << "申诉中"
time = "申诉剩余时间:" + how_much_time(ho_detail_manual.appeal_time)
time_status = 4
end
when 5, 6
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 end
# member = course.course_members.find_by(user_id: user.id, is_active: 1) else
# teacher_course_groups = member.try(:teacher_course_groups) # member = course.course_members.find_by(user_id: user.id, is_active: 1)
# identity = user.course_identity(course) # 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)}"
time_status = 0 time_status = 0
when 1 when 1
if homework_common.end_time && homework_common.end_time >= Time.now if homework_common.end_time && homework_common.end_time >= Time.now
status << "提交中" status << "提交中"
time = "提交剩余时间:" + how_much_time(homework_common.end_time) time = "提交剩余时间:" + how_much_time(homework_common.end_time)
time_status = 1 time_status = 1
elsif homework_common.end_time && homework_common.end_time < Time.now elsif homework_common.end_time && homework_common.end_time < Time.now
if homework_common.allow_late && (homework_common.late_time.nil? || homework_common.late_time >= Time.now) if homework_common.allow_late && (homework_common.late_time.nil? || homework_common.late_time >= Time.now)
time = "补交剩余时间:" + how_much_time(homework_common.late_time) time = "补交剩余时间:" + how_much_time(homework_common.late_time)
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 = 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"
if member.role == "STUDENT" && member.course_group_id == 0 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
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
end
if min_publish_time.nil?
status << "未发布" status << "未发布"
time = "" time = "创建于#{time_from_now(homework_common.created_at)}"
time_status = 0 time_status = 0
elsif min_publish_time > Time.now
status << "未发布"
time = "将于 #{format_time(min_publish_time)} 发布"
time_status = 0
elsif max_end_time.present? && max_end_time > Time.now #6.14 -hs 添加present?
status << "提交中"
time = "提交剩余时间:" + how_much_time(max_end_time)
time_status = 1
else else
if member.role == "STUDENT" status << "已截止"
setting = homework_common.homework_group_settings.find_by(course_group_id: member.course_group_id) time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
min_publish_time = setting.try(:publish_time) time_status = 5
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
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
end
if min_publish_time.nil?
status << "未发布"
time = "创建于#{time_from_now(homework_common.created_at)}"
time_status = 0
elsif min_publish_time > Time.now
status << "未发布"
time = "将于 #{format_time(min_publish_time)} 发布"
time_status = 0
elsif max_end_time.present? && max_end_time > Time.now #6.14 -hs 添加present?
status << "提交中"
time = "提交剩余时间:" + how_much_time(max_end_time)
time_status = 1
else
status << "已截止"
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
time_status = 5
end
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

Loading…
Cancel
Save