diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index faea30242..f88217f7b 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -937,8 +937,14 @@ class HomeworkCommonsController < ApplicationController publish_groups = charge_group_ids & group_ids if group_ids # ActiveRecord::Base.transaction do + messages = [] homeworks.each do |homework| # 作业未发布时 + max_end_time = params[:detail] ? group_end_times.max : params[:end_time] + if homework.allow_late && max_end_time.to_time >= homework.late_time + messages << "#{homework.name}" + next + end if homework.homework_detail_manual.try(:comment_status) == 0 if !params[:group_ids].blank? @@ -1018,7 +1024,14 @@ class HomeworkCommonsController < ApplicationController # 更新学生状态及成绩(手动点击计算) # HomeworkPublishUpdateWorkStatusJob.perform_later(tiding_group_ids, homework.id) end - normal_status(0, "发布成功") + unless messages.blank? + return_message = messages.join("、") + return_message += messages.size == 1 ? "" : "等" + return_message += "作业发布失败,原因:截止时间必须早于补交结束时间" + else + return_message = "发布成功" + end + normal_status(0, return_message) # end end