From 7e2186ec48d9d3cef78a599e9ce433ba5202f141 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 31 Dec 2019 16:23:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=88=97=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/polls_controller.rb | 4 ++-- app/models/poll.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 2539403af..08d0da42f 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -46,8 +46,8 @@ class PollsController < ApplicationController @polls = member_show_polls.size > 0 ? member_show_polls.public_or_unset : [] else #已分班级的成员,可以查看统一设置和单独设置(试卷是发布在该班级)试卷 # 已发布 当前用户班级分组的 试卷id - not_poll_ids = @course.poll_group_settings.poll_group_not_published.where("course_group_id = #{@member_group_id}").pluck(:poll_id) - @polls = member_show_polls.where.not(id: not_poll_ids) + publish_poll_ids = @course.poll_group_settings.poll_group_published.where("course_group_id = #{@member_group_id}").pluck(:poll_id) + @polls = member_show_polls.unified_setting.or(member_show_polls.where(id: publish_poll_ids)) end else #用户未登陆或不是该课堂成员,仅显示统一设置的(已发布的/已截止的),如有公开,则不显示锁,不公开,则显示锁 @is_teacher_or = 0 diff --git a/app/models/poll.rb b/app/models/poll.rb index 0ea76a8a3..365e46008 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -19,6 +19,7 @@ class Poll < ApplicationRecord scope :poll_by_ids, lambda { |ids| where(id: ids) unless ids.blank? } scope :poll_by_status, lambda { |s| where(polls_status: s) unless s.blank? } scope :poll_group_ended, -> {where("end_time is NOT NULL AND end_time <= ?",Time.now)} + scope :unified_setting, -> { where("unified_setting = ?",true) } scope :poll_search, lambda { |keywords| where("polls_name LIKE ?", "%#{keywords}%") unless keywords.blank?}