From 1cbd20b57add58f719a7cefbf7f07af8320378d1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 13:58:43 +0800 Subject: [PATCH] fix bug --- app/controllers/polls_controller.rb | 2 ++ app/models/poll.rb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 24aa54309..e1ea02016 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -961,6 +961,8 @@ class PollsController < ApplicationController @poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生 get_poll_answers(@poll_users_list) logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}") + logger.info("#######F__________@users_ids________________####{PollUser.where(id:@poll_users_list.pluck(:id)).pluck(:user_id)}") + if @poll_list_status == 1 @poll_course_groups =[] diff --git a/app/models/poll.rb b/app/models/poll.rb index f72239ba7..7e71505ba 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -52,12 +52,12 @@ class Poll < ApplicationRecord # 统一设置,为当前老师有权限的分班学生,分班设置,也为当前老师有权限的分班的学生 def all_poll_users(user_id) - poll_users = self.poll_users + poll_all_users = poll_users group_ids = poll_published_ids(user_id) if group_ids.present? - poll_users = poll_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id)) + poll_all_users = poll_all_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id).uniq) end - poll_users + poll_all_users end #当前用户已发布的班级id和试卷分组已发布的班级id的交集