|
|
|
@ -126,7 +126,6 @@ class PollsController < ApplicationController
|
|
|
|
|
# un_anonymous 是否实名,默认为false,即不公开
|
|
|
|
|
def create
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
poll_name = params[:polls_name]
|
|
|
|
|
poll_desc = params[:polls_description]
|
|
|
|
|
poll_options = {
|
|
|
|
@ -138,11 +137,6 @@ class PollsController < ApplicationController
|
|
|
|
|
:polls_type => "Course",
|
|
|
|
|
}
|
|
|
|
|
@poll = Poll.create!(poll_options)
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception("问卷创建失败!")
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -160,7 +154,6 @@ class PollsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
poll_name = params[:polls_name]
|
|
|
|
|
poll_des = params[:polls_description]
|
|
|
|
|
poll_params = {
|
|
|
|
@ -169,11 +162,6 @@ class PollsController < ApplicationController
|
|
|
|
|
}
|
|
|
|
|
@poll.update!(poll_params)
|
|
|
|
|
normal_status(0, "问卷更新成功!")
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception("没有权限")
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -258,16 +246,14 @@ class PollsController < ApplicationController
|
|
|
|
|
if params[:detail].blank?
|
|
|
|
|
tip_exception("缺少截止时间参数") if params[:end_time].blank?
|
|
|
|
|
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_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] > strf_time(@course.end_date.end_of_day)
|
|
|
|
|
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
|
|
|
|
|
else
|
|
|
|
|
group_end_times = params[:group_end_times].reject(&:blank?).map {|time| time.to_time}
|
|
|
|
|
tip_exception("缺少截止时间参数") if group_end_times.blank?
|
|
|
|
|
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
|
|
|
|
|
group_end_times.each do |time|
|
|
|
|
|
tip_exception("分班截止时间不能早于当前时间") if time <= Time.now
|
|
|
|
|
tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if
|
|
|
|
|
@course.end_date.present? && time > @course.end_date.end_of_day
|
|
|
|
|
tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if @course.end_date.present? && time > @course.end_date.end_of_day
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -725,8 +711,7 @@ class PollsController < ApplicationController
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
@ -761,8 +746,7 @@ class PollsController < ApplicationController
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|