big start on QuizStatus

This commit is contained in:
Mark Moser
2016-07-27 11:17:50 -05:00
parent 487351c1b0
commit 7a32057825
16 changed files with 173 additions and 17 deletions

View File

@ -1,4 +1,6 @@
class Candidate < ApplicationRecord
belongs_to :quiz
has_many :questions, through: :quiz
has_many :answers
belongs_to :recruiter, class_name: "User"
@ -8,6 +10,14 @@ class Candidate < ApplicationRecord
validates_presence_of :test_hash
validates_uniqueness_of :test_hash
def submitted_answers
answers.where(submitted: true)
end
def answered_questions
answers.where.not(answer: nil)
end
private
def generate_test_hash

View File

@ -1,3 +1,4 @@
class Quiz < ApplicationRecord
has_many :questions
has_many :candidates
end