|
|
|
@ -689,7 +689,7 @@ class ExercisesController < ApplicationController
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
check_ids = Exercise.where(id: params[:check_ids])
|
|
|
|
|
ex_end_time = params[:end_time] || Time.at(((1.month.since.to_i)/3600.0).ceil * 3600)
|
|
|
|
|
ex_end_time = params[:end_time].to_time
|
|
|
|
|
check_ids.each do |exercise|
|
|
|
|
|
if exercise.present?
|
|
|
|
|
if exercise.unified_setting
|
|
|
|
@ -701,20 +701,13 @@ class ExercisesController < ApplicationController
|
|
|
|
|
if ex_status == 1 #如果试卷存在已发布的,或者是已截止的,那么则直接跳过
|
|
|
|
|
g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改
|
|
|
|
|
if g_course
|
|
|
|
|
# course_groups = @course.teacher_course_groups.get_user_groups(current_user.id)
|
|
|
|
|
#
|
|
|
|
|
# if course_groups.blank?
|
|
|
|
|
# user_course_groups = @course.course_groups.present? ? @course.course_groups.pluck(:id) : []
|
|
|
|
|
# else
|
|
|
|
|
# user_course_groups = course_groups.pluck(:course_group_id).reject(&:blank?).uniq
|
|
|
|
|
# end
|
|
|
|
|
user_course_groups = @course.charge_group_ids(current_user)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置
|
|
|
|
|
exercise.exercise_group_settings.destroy_all
|
|
|
|
|
ex_unified = true
|
|
|
|
|
e_time = ex_end_time
|
|
|
|
|
else
|
|
|
|
|
e_time = exercise.exercise_group_settings.end_time_no_null.map(&:end_time).max
|
|
|
|
|
ex_unified = false
|
|
|
|
|
g_course.each do |i|
|
|
|
|
|
exercise_group_setting = exercise.exercise_group_settings.find_in_exercise_group("course_group_id",i).first #根据课堂分班的id,寻找试卷所在的班级
|
|
|
|
@ -732,20 +725,21 @@ class ExercisesController < ApplicationController
|
|
|
|
|
new_exercise_group.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
group_ids = params[:group_ids]
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
exercise.exercise_group_settings.destroy_all
|
|
|
|
|
ex_unified = true
|
|
|
|
|
end
|
|
|
|
|
if exercise.end_time.blank?
|
|
|
|
|
e_time = ex_end_time
|
|
|
|
|
elsif exercise.exercise_group_settings.end_time_no_null.count > 0 # 该试卷分组有结束时间为空的
|
|
|
|
|
e_time = exercise.exercise_group_settings.end_time_no_null.map(&:end_time).max
|
|
|
|
|
else
|
|
|
|
|
e_time = exercise.end_time
|
|
|
|
|
end
|
|
|
|
|
# if exercise.end_time.blank?
|
|
|
|
|
# e_time = ex_end_time
|
|
|
|
|
# elsif exercise.exercise_group_settings.end_time_no_null.count > 0 # 该试卷分组有结束时间为空的
|
|
|
|
|
# e_time = exercise.exercise_group_settings.end_time_no_null.map(&:end_time).max
|
|
|
|
|
# else
|
|
|
|
|
# e_time = ex_end_time
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
ex_status = set_exercise_status(Time.now,e_time)
|
|
|
|
|
exercise_params = {
|
|
|
|
|
:publish_time => Time.now,
|
|
|
|
|