|
|
|
@ -73,9 +73,11 @@ class UpdateHomeworkPublishSettingService < ApplicationService
|
|
|
|
|
|
|
|
|
|
# 作业在"提交中"状态时
|
|
|
|
|
else
|
|
|
|
|
if homework.end_time > Time.now && homework.unified_setting
|
|
|
|
|
# 实训作业截止时间已过也可修改截止时间,其他作业暂不支持修改
|
|
|
|
|
if (homework.homework_type == "practice" || homework.end_time > Time.now) && homework.unified_setting
|
|
|
|
|
tip_exception("截止时间不能为空") if params[:end_time].blank?
|
|
|
|
|
tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now
|
|
|
|
|
tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= homework.publish_time
|
|
|
|
|
# tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now
|
|
|
|
|
tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if
|
|
|
|
|
course.end_date.present? && params[:end_time].to_time > course.end_date.end_of_day
|
|
|
|
|
|
|
|
|
@ -93,19 +95,29 @@ class UpdateHomeworkPublishSettingService < ApplicationService
|
|
|
|
|
# 如果该发布规则 没有已发布的分班则需判断发布时间
|
|
|
|
|
tip_exception("发布时间不能早于等于当前时间") if setting[:publish_time].to_time <= Time.now && group_settings.group_published.count == 0
|
|
|
|
|
|
|
|
|
|
tip_exception("截止时间不能早于等于当前时间") if setting[:end_time].to_time <= Time.now && group_settings.none_end.count > 0
|
|
|
|
|
# tip_exception("截止时间不能早于等于当前时间") if setting[:end_time].to_time <= Time.now && group_settings.none_end.count > 0
|
|
|
|
|
tip_exception("截止时间不能早于发布时间") if setting[:publish_time].to_time > setting[:end_time].to_time
|
|
|
|
|
tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if
|
|
|
|
|
course.end_date.present? && setting[:end_time].to_time > course.end_date.end_of_day
|
|
|
|
|
|
|
|
|
|
group_settings.none_published.update_all(publish_time: setting[:publish_time])
|
|
|
|
|
group_settings.none_end.update_all(end_time: setting[:end_time])
|
|
|
|
|
# 实训作业截止时间已过也可修改截止时间,其他作业暂不支持修改
|
|
|
|
|
if homework.homework_type == "practice"
|
|
|
|
|
group_settings.update_all(end_time: setting[:end_time])
|
|
|
|
|
else
|
|
|
|
|
group_settings.none_end.update_all(end_time: setting[:end_time])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
homework.end_time = homework.max_group_end_time
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if homework.end_time > Time.now && homework.homework_detail_manual.try(:comment_status) > 1
|
|
|
|
|
homework.homework_detail_manual.update_attributes!(comment_status: 1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
homework.save!
|
|
|
|
|
UpdateShixunWorkScoreJob.perform_later(homework.id)
|
|
|
|
|
HomeworkCommonPushNotifyJob.perform_later(homework.id, publish_group_ids) if send_tiding
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|