15a5b6b706
completes #105
18 lines
440 B
Ruby
18 lines
440 B
Ruby
# 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
|