big start on QuizStatus
This commit is contained in:
@ -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
|
||||
|
@ -1,3 +1,4 @@
|
||||
class Quiz < ApplicationRecord
|
||||
has_many :questions
|
||||
has_many :candidates
|
||||
end
|
||||
|
Reference in New Issue
Block a user