educoder/app/models/poll_group_setting.rb

15 lines
707 B

6 years ago
class PollGroupSetting < ApplicationRecord
belongs_to :poll
belongs_to :course_group
belongs_to :course
scope :group_settings_by_ids, lambda { |ids| where(id: ids) unless ids.blank? }
scope :find_in_poll_group, lambda { |name,ids| where("#{name}": ids)}
scope :end_time_present, -> { where("end_time is not NULL")}
scope :publish_time_present, -> { where("publish_time is not NULL")}
scope :poll_group_published, -> {where("publish_time IS NOT NULL AND publish_time <= ?",Time.now)}
scope :poll_group_ended, -> {where("end_time is NOT NULL AND end_time <= ?",Time.now)}
scope :poll_group_not_published, -> {where("publish_time is NULL OR publish_time > ?",Time.now)}
end