skill-assessment-app/app/workers/quiz_status.rb

31 lines
585 B
Ruby
Raw Normal View History

2016-07-27 11:17:50 -05:00
class QuizStatus
attr_reader :candidate
def initialize candidate
@candidate = Candidate.find(candidate.to_i)
end
def started
candidate.answers.count > 0
end
def on_summary
candidate.submitted_answers.count == candidate.questions.count
end
def completed
candidate.completed
end
def can_submit
on_summary && candidate.answered_questions.count == candidate.questions.count
end
2016-07-27 22:16:12 -05:00
2016-07-27 22:53:14 -05:00
def progress
answs = candidate.answered_questions.count.to_f
total = candidate.quiz.questions.count.to_f
(answs / total * 100).round.to_i
end
2016-07-27 11:17:50 -05:00
end