|
|
|
@ -27,13 +27,14 @@ module HomeworkCommonsHelper
|
|
|
|
|
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)
|
|
|
|
|
status << "补交中"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
time = "补交剩余时间:" + how_much_time(homework_common.late_time)
|
|
|
|
|
time_status = 2
|
|
|
|
|
else
|
|
|
|
|
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
|
|
|
|
|
when 2
|
|
|
|
|
unless homework_common.allow_late
|
|
|
|
|
status << "已截止"
|
|
|
|
@ -56,23 +57,16 @@ module HomeworkCommonsHelper
|
|
|
|
|
status << "已截止"
|
|
|
|
|
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
|
|
|
|
|
time_status = 5
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 如果还在补交阶段则显示补交结束时间
|
|
|
|
|
if homework_common.end_time && homework_common.end_time < Time.now && homework_common.allow_late &&
|
|
|
|
|
homework_common.late_time && homework_common.late_time > Time.now
|
|
|
|
|
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)
|
|
|
|
|
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?)
|
|
|
|
|
case ho_detail_manual.comment_status
|
|
|
|
|
case ho_detail_manual.comment_status
|
|
|
|
|
when 0
|
|
|
|
|
status << "未发布"
|
|
|
|
|
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
|
|
|
|
|
else
|
|
|
|
|
status << "已截止"
|
|
|
|
|
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
|
|
|
|
|
time_status = 5
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
# 未分班的学生始终显示“未发布”(按理不会来到这个判断)
|
|
|
|
|
if member.role == "STUDENT" && member.course_group_id == 0
|
|
|
|
|
status << "未发布"
|
|
|
|
|
time = ""
|
|
|
|
|
time_status = 0
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if member.role == "STUDENT"
|
|
|
|
|
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)
|
|
|
|
|
# 未分班的学生始终显示“未发布”(按理不会来到这个判断)
|
|
|
|
|
if member.role == "STUDENT" && member.course_group_id == 0
|
|
|
|
|
status << "未发布"
|
|
|
|
|
time = ""
|
|
|
|
|
time_status = 0
|
|
|
|
|
else
|
|
|
|
|
# 多个分班权限的取最小publish_time,最大end_time
|
|
|
|
|
min_publish_time = homework_common.homework_group_settings.where.not(publish_time: nil).
|
|
|
|
|
if member.role == "STUDENT"
|
|
|
|
|
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).
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
elsif homework_common.allow_late && (homework_common.late_time.nil? || homework_common.late_time >= Time.now)
|
|
|
|
|
time = "补交剩余时间:" + how_much_time(homework_common.late_time)
|
|
|
|
|
time_status = 2
|
|
|
|
|
else
|
|
|
|
|
status << "已截止"
|
|
|
|
|
time = ""
|
|
|
|
|
time_status = 5
|
|
|
|
|
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
|
|
|
|
|
status << "未开启补交" if !homework_common.allow_late && time_status == 1
|
|
|
|
|
end
|
|
|
|
|
status << "未开启补交" if !homework_common.allow_late && time_status == 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# 如果作业状态都没有的话,在课堂结束前,都显示已截止
|
|
|
|
|
if status.blank?
|
|
|
|
|
status << "已截止"
|
|
|
|
|
time = course.end_date.present? ? ("评阅剩余时间:" + how_much_time(course.end_date.end_of_day)) : ""
|
|
|
|
|
time_status = 5
|
|
|
|
|
end
|
|
|
|
|
result[:status] = status
|
|
|
|
|