|
|
|
@ -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].to_time
|
|
|
|
|
ex_end_time = params[:end_time].blank? ? Time.at(((1.month.since.to_i)/3600.0).ceil * 3600) : params[:end_time].to_time
|
|
|
|
|
check_ids.each do |exercise|
|
|
|
|
|
if exercise.present?
|
|
|
|
|
if exercise.unified_setting
|
|
|
|
@ -707,7 +707,6 @@ class ExercisesController < ApplicationController
|
|
|
|
|
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,寻找试卷所在的班级
|
|
|
|
@ -725,7 +724,8 @@ class ExercisesController < ApplicationController
|
|
|
|
|
new_exercise_group.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
group_ids = params[:group_ids]
|
|
|
|
|
# group_ids = params[:group_ids]
|
|
|
|
|
e_time = exercise.exercise_group_settings.end_time_no_null.map(&:end_time).max
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
exercise.exercise_group_settings.destroy_all
|
|
|
|
@ -745,7 +745,7 @@ class ExercisesController < ApplicationController
|
|
|
|
|
if exercise.course_acts.size == 0
|
|
|
|
|
exercise.course_acts << CourseActivity.new(:user_id => exercise.user_id,:course_id => exercise.course_id)
|
|
|
|
|
end
|
|
|
|
|
ExercisePublishNotifyJob.perform_later(exercise.id, group_ids)
|
|
|
|
|
ExercisePublishNotifyJob.perform_later(exercise.id, g_course)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -976,8 +976,14 @@ class ExercisesController < ApplicationController
|
|
|
|
|
def start_answer
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
@exercise_user_current = @exercise.exercise_users.exercise_commit_users(@exercise_current_user_id)&.first
|
|
|
|
|
if @exercise_user_current.blank?
|
|
|
|
|
ex_users_current = @exercise.exercise_users.exercise_commit_users(@exercise_current_user_id)
|
|
|
|
|
@exercise_user_current = ex_users_current&.first
|
|
|
|
|
logger.info("############______________ex_users_current________#######{ex_users_current}")
|
|
|
|
|
if ex_users_current.exists?
|
|
|
|
|
if @exercise_user_current.start_at.blank?
|
|
|
|
|
@exercise_user_current.update_attribute("start_at",Time.now)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if @user_course_identity > Course::ASSISTANT_PROFESSOR #当为老师的时候,不创建exercise_user表,理论上老师是不能进入答题的
|
|
|
|
|
exercise_user_params = {
|
|
|
|
|
:user_id => @exercise_current_user_id,
|
|
|
|
@ -987,16 +993,12 @@ class ExercisesController < ApplicationController
|
|
|
|
|
exercise_user_current = ExerciseUser.new(exercise_user_params)
|
|
|
|
|
exercise_user_current.save
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if @exercise_user_current.start_at.blank?
|
|
|
|
|
@exercise_user_current.update_attribute("start_at",Time.now)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@t_user_exercise_status = @exercise.get_exercise_status(current_user)
|
|
|
|
|
|
|
|
|
|
@user_left_time = nil
|
|
|
|
|
if @user_course_identity < Course::STUDENT || (@t_user_exercise_status == 3) ||
|
|
|
|
|
(@exercise_user_current.present? && @exercise_user_current.commit_status == 1)
|
|
|
|
|
(ex_users_current.exists? && @exercise_user_current.commit_status == 1)
|
|
|
|
|
@user_exercise_status = 1 #当前用户为老师/试卷已截止/试卷已提交不可编辑
|
|
|
|
|
else
|
|
|
|
|
@user_left_time = get_exercise_left_time(@exercise,current_user)
|
|
|
|
|