dev_course
SylorHuang 6 years ago
parent a6c1a7e155
commit 26e6ecba6d

@ -436,7 +436,7 @@ class ExercisesController < ApplicationController
exercise_status = @exercise.get_exercise_status(current_user.id)
if exercise_status == 1 && (course_group_ids - [0]).count > 0 # 试卷未发布且老师的分班大于1 ,才可以修改统一设置,否则按试卷默认的来处理
if exercise_status == 1 && course_group_ids.size > 0 # 试卷未发布且老师的分班大于1 ,才可以修改统一设置,否则按试卷默认的来处理
unified_setting = params[:unified_setting]
else
unified_setting = @exercise.unified_setting
@ -450,7 +450,7 @@ class ExercisesController < ApplicationController
answer_open = params[:answer_open] ? true : false #答案是否公开
# 统一设置或者分班为0则更新试卷并删除试卷分组
if unified_setting || (course_group_ids.count == 0)
if unified_setting || (course_group_ids.size == 0)
params_publish_time = params[:publish_time].blank? ? nil : params[:publish_time].to_time
params_end_time = nil
if params[:end_time].blank?
@ -798,12 +798,13 @@ class ExercisesController < ApplicationController
if exercise_status == 2 #跳过已截止的或未发布的
g_course = params[:group_ids]
if g_course.present?
user_course_groups= @course.teacher_course_groups.get_user_groups(current_user.id)
if user_course_groups.present?
teacher_course_group_ids = user_course_groups.pluck(:course_group_id)
else
teacher_course_group_ids = @course.course_groups.pluck(:id)
end
# user_course_groups= @course.teacher_course_groups.get_user_groups(current_user.id)
# if user_course_groups.present?
# teacher_course_group_ids = user_course_groups.pluck(:course_group_id)
# else
# teacher_course_group_ids = @course.course_groups.pluck(:id)
# end
teacher_course_group_ids = @course.charge_group_ids(current_user)
if g_course.map(&:to_i).sort == teacher_course_group_ids.sort #开始为统一设置
exercise.exercise_group_settings.destroy_all
new_ex_status = set_exercise_status(exercise.publish_time,Time.now)

@ -691,7 +691,7 @@ class PollsController < ApplicationController
course_group_ids = @course.charge_group_ids(current_user) #当前老师的班级id数组
poll_status = @poll.get_poll_status(current_user.id)
if poll_status == 1 && (course_group_ids - [0]).count > 0 # 问卷未发布且老师的分班大于1 才可以修改统一设置否则按poll默认的来处理
if poll_status == 1 && course_group_ids.size > 0 # 问卷未发布且老师的分班大于1 才可以修改统一设置否则按poll默认的来处理
unified_setting = params[:unified_setting]
else
unified_setting = @poll.unified_setting

@ -121,7 +121,7 @@ class Course < ApplicationRecord
end
#当前老师的班级id
def teacher_course_group_ids(user_id)
def teacher_course_ids(user_id)
course_teacher_member = teacher_course_groups.get_user_groups(user_id) #获取当前老师的分班
if course_teacher_member.blank?
if none_group_count > 0 #有未分班的,则发布到未发布分班

@ -66,7 +66,7 @@ class Exercise < ApplicationRecord
#当前用户已发布的班级id和试卷分组已发布的班级id的交集
def common_published_ids(user_id)
current_user_groups = course.teacher_course_group_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id)
if unified_setting
if course.none_group_count > 0 #有未分班的,则发布到未发布分班
un_group_ids = [0]

@ -62,7 +62,7 @@ class Poll < ApplicationRecord
#当前用户已发布的班级id和试卷分组已发布的班级id的交集
def poll_published_ids(user_id)
current_user_groups = course.teacher_course_group_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id)
if unified_setting
if course.none_group_count > 0 #有未分班的,则发布到未发布
un_group_ids = [0]

Loading…
Cancel
Save