diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 606132c27..2a6a8f84b 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -79,7 +79,6 @@ class Exercise < ApplicationRecord published_group_ids end - #判断用户是否属于试卷分班的学生中 def check_user_in_course(user_id,user_identity) ex_group_settings = exercise_group_settings.pluck(:course_group_id) diff --git a/app/models/poll.rb b/app/models/poll.rb index a055fd656..69b717493 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -44,8 +44,8 @@ class Poll < ApplicationRecord if unified_setting #试卷统一设置 poll_users else - ex_group_setting_ids = poll_group_settings.poll_group_published.pluck(:course_group_id) - poll_users.where(user_id: course.students.where(course_group_id:ex_group_setting_ids).pluck(:user_id).uniq) + ex_group_setting_ids = poll_group_settings.poll_group_published.select(:course_group_id).pluck(:course_group_id) + poll_users.where(user_id: course.students.where(course_group_id:ex_group_setting_ids).select(:user_id).pluck(:user_id).uniq) end end @@ -63,15 +63,16 @@ class Poll < ApplicationRecord def poll_published_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] - else - un_group_ids = [] - end - (current_user_groups + un_group_ids).uniq #统一设置时,为当前用户的分班id + current_user_groups.uniq + # if course.none_group_count > 0 #有未分班的,则发布到未发布 + # un_group_ids = [0] + # else + # un_group_ids = [] + # end + # (current_user_groups + un_group_ids).uniq #统一设置时,为当前用户的分班id else ex_group_setting = poll_group_settings.select(:course_group_id).pluck("course_group_id").uniq - ex_group_setting & current_user_groups #当前用户有权限的已发布的分班id #非统一设置时,为当前用户有权限的且已发布分班的id + (ex_group_setting & current_user_groups).uniq #当前用户有权限的已发布的分班id #非统一设置时,为当前用户有权限的且已发布分班的id end end