问卷放开截止时间的设置

dev_cxt
cxt 5 years ago
parent e93d7e3d2f
commit 396d4d73f0

@ -722,19 +722,16 @@ class PollsController < ApplicationController
un_anonymous = params[:un_anonymous] ? true : false
# 统一设置或者分班为0则更新问卷并删除问卷分组
if unified_setting || (course_group_ids.size == 0)
params_publish_time = params[:publish_time].present? ? params[:publish_time].to_time : nil
params_end_time = nil
if params[:end_time].blank?
if params_publish_time.present?
params_end_time = params_publish_time + 30.days
end
else
tip_exception("发布时间不能为空") if params[:publish_time].blank?
tip_exception("截止时间不能为空") if params[:end_time].blank?
tip_exception("截止时间不能早于发布时间") if params[:publish_time].to_time > params[:end_time].to_time
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
params_publish_time = params[:publish_time].to_time
params_end_time = params[:end_time].to_time
end
# params_end_time = params[:end_time].present? ? params[:end_time].to_time : nil
if poll_status == 2 && @poll.publish_time != params_publish_time
normal_status(-1,"不允许修改发布时间")
elsif poll_status == 3 && (@poll.end_time != params_end_time || @poll.publish_time != params_publish_time)
if poll_status != 1 && @poll.publish_time != params_publish_time
normal_status(-1,"不允许修改发布时间")
elsif params_publish_time.present? && params_end_time.present? && params_end_time < params_publish_time
normal_status(-1,"截止时间不能小于发布时间")
@ -761,24 +758,25 @@ class PollsController < ApplicationController
total_common_group = poll_groups_ids & total_common #传入的分班与问卷已存在的分班的交集
old_poll_groups = poll_groups_ids - total_common_group #后来传入的分班里,没有了的班级,即需要删除
params_times.each do |t|
course_id = t[:course_group_id] #为数组可能会设置分班为各个班级id的数组
poll_publish_time = t[:publish_time].present? ? t[:publish_time].to_time : nil
# poll_end_time = t[:end_time].present? ? t[:end_time].to_time : nil
poll_end_time = nil
if t[:end_time].blank?
if poll_publish_time.present?
poll_end_time = poll_publish_time + 30.days
end
else
tip_exception("发布时间不能为空") if t[:publish_time].blank?
tip_exception("截止时间不能为空") if t[:end_time].blank?
tip_exception("截止时间不能早于发布时间") if t[:publish_time].to_time > t[:end_time].to_time
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && t[:end_time].to_time > @course.end_date.end_of_day
course_id = t[:course_group_id]
poll_publish_time = t[:publish_time].to_time
poll_end_time = t[:end_time].to_time
end
poll_group = poll_groups.find_in_poll_group("course_group_id",course_id) #判断该分班是否存在
if poll_group.present? && poll_group.first.end_time <= Time.now && (poll_end_time != poll_group.first.end_time || poll_publish_time != poll_group.first.publish_time) #已截止且时间改变的,则提示错误
if poll_group.present? && (poll_group.first.publish_time < Time.now) && (poll_publish_time != poll_group.first.publish_time)
error_count += 1
end
if poll_group.present? && poll_group.first.publish_time < Time.now && poll_publish_time != poll_group.first.publish_time
if poll_group.present? && (poll_group.first.publish_time < Time.now && poll_group.first.end_time > Time.now) && (poll_end_time < Time.now)
error_count += 1
end
if error_count == 0
common_group = poll_groups_ids & course_id #传入的班级与问卷已存在的班级的交集,即表示已有分班的
new_group_ids = course_id - common_group #新传入的班级id

Loading…
Cancel
Save