dev_forum
SylorHuang 6 years ago
parent c536e3bc67
commit 42791b4af9

@ -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)

@ -247,7 +247,7 @@ class PollsController < ApplicationController
ActiveRecord::Base.transaction do
begin
check_ids = Poll.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].blank? ? Time.at(((1.month.since.to_i)/3600.0).ceil * 3600) : params[:end_time].to_time
check_ids.each do |poll|
if poll.unified_setting
pl_status = poll.polls_status #则为试卷的状态
@ -263,7 +263,6 @@ class PollsController < ApplicationController
poll_unified = true
e_time = ex_end_time
else
e_time = poll.poll_group_settings.end_time_present.map(&:end_time).max
poll_unified = false
g_course.each do |i|
poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id",i).first #根据课堂分班的id寻找问卷所在的班级
@ -281,7 +280,8 @@ class PollsController < ApplicationController
new_poll_group.save
end
end
group_ids = params[:group_ids]
e_time = poll.poll_group_settings.end_time_present.map(&:end_time).max
# group_ids = params[:group_ids]
end
else
poll.poll_group_settings.destroy_all
@ -300,7 +300,7 @@ class PollsController < ApplicationController
if poll.course_acts.size == 0
poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => poll.course_id)
end
PollPublishNotifyJob.perform_later(poll.id, group_ids)
PollPublishNotifyJob.perform_later(poll.id, g_course)
end
end
normal_status(0, "问卷发布成功!")

Loading…
Cancel
Save