47 lines
1.2 KiB
Ruby
47 lines
1.2 KiB
Ruby
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
|
|
|
|
# <?php
|
|
# $TotalQuestions;
|
|
# $progressBarValue;
|
|
# //Get Total Number of Questions
|
|
# $TotalQuestions = "SELECT * FROM questions";
|
|
# $result = $link->query($TotalQuestions);
|
|
# $TotalQuestions = $result->num_rows + 1;
|
|
#
|
|
# $progressBarValue = round($questionId/$TotalQuestions * 100);
|
|
# $_SESSION['pBarValue'] = $progressBarValue;
|
|
#
|
|
# $pValue = $_SESSION['pBarValue'];
|
|
#
|
|
# if(!isset($_GET['qid'])) { ?>
|
|
# <div class="progress ignore-margin">
|
|
# <div class="progress-bar" role="progressbar" aria-valuenow="<?php echo $pValue; ?>"
|
|
# aria-valuemin="0" aria-valuemax="100" style="width:<?php echo $pValue; ?>%">
|
|
# <span><?php echo $pValue; ?>%</span>
|
|
# </div>
|
|
# </div>
|
|
# <?php }
|
|
# ?>
|
|
end
|