# frozen_string_literal: true class Quiz < ApplicationRecord has_many :questions, -> { order(:sort) } has_many :candidates has_many :reviewer_to_quizzes has_many :reviewers, through: :reviewer_to_quizzes, source: :user validates :name, presence: true, uniqueness: true validates :dept, presence: true validates :unit, presence: true class << self def all_active Quiz.joins(:questions).distinct end end end