function pause($question_quiz_id = 0, $from_review = 0, $last_paused = 0)
 {
     if ($this->Session->check('quiz_id')) {
         $quiz_id = $this->Session->read('quiz_id');
         // <<-- load the start time session
         if ($this->Session->check('start_time')) {
             $start_time = $this->Session->read('start_time');
             // <<-- load the start time session
             $elapse = get_elapse_time($start_time);
             $value = $this->Quiz->update_logs($elapse, $start_time, $quiz_id);
             $this->Session->delete('start_time');
         }
         //used to get the remaining time
         $used_time = $this->Quiz->calculate_used_time($quiz_id);
         $remaining_time = $this->Quiz->calculate_remaining_time($quiz_id, $used_time);
         $time_hr = intval($remaining_time / 3600);
         $time_min = intval($remaining_time % 3600 / 60);
         $time_sec = $remaining_time % 60;
         $time = $time_hr . ":" . $time_min . ":" . $time_sec;
         $review = $this->params['named']['review'];
         $this->set('review', $review);
         // used to get the status of the questions
         $results = $this->Quiz->findByQuizID($quiz_id);
         $questions = $results['Question'];
         $unanswered_unmarked = 0;
         $unanswered_marked = 0;
         $answered_unmarked = 0;
         $answered_marked = 0;
         foreach ($questions as $item) {
             if ($item['QuestionQuiz']['answered'] == 0 && $item['QuestionQuiz']['is_marked'] == 1) {
                 $unanswered_marked += 1;
             } else {
                 if ($item['QuestionQuiz']['answered'] != 0 && $item['QuestionQuiz']['is_marked'] == 0) {
                     $answered_unmarked += 1;
                 } else {
                     if ($item['QuestionQuiz']['answered'] != 0 && $item['QuestionQuiz']['is_marked'] == 1) {
                         $answered_marked += 1;
                     }
                 }
             }
         }
         $this->set('question_quiz_id', $question_quiz_id);
         $this->set('answered_unmarked', $answered_unmarked);
         $this->set('answered_marked', $answered_marked);
         $this->set('unanswered_unmarked', $unanswered_unmarked);
         $this->set('unanswered_marked', $unanswered_marked);
         $this->set('time', $time);
         $this->set('from_review', $from_review);
         $this->set('last_paused', $last_paused);
     } else {
         $this->Session->setFlash('Session timeout. Enter the code sent to your email to continue the quiz.', true);
         $this->redirect("/quizzes/resume");
     }
 }
 function review($question_quiz_id = 0, $from_review = 0)
 {
     if ($this->Session->check('quiz_id')) {
         $quiz_id = $this->Session->read('quiz_id');
         // <<-- load the session
         if ($this->Session->check('start_time')) {
             $start_time = $this->Session->read('start_time');
             // <<-- load the start time session
             $elapse = get_elapse_time($start_time);
             $value = $this->Question->Quiz->update_logs($elapse, $start_time, $quiz_id);
             $this->Session->delete('start_time');
         }
         $used_time = $this->Question->Quiz->calculate_used_time($quiz_id);
         $remaining_time = $this->Question->Quiz->calculate_remaining_time($quiz_id, $used_time);
         $time_hr = intval($remaining_time / 3600);
         $time_min = intval($remaining_time % 3600 / 60);
         $time_sec = $remaining_time % 60;
         $time = $time_hr . ":" . $time_min . ":" . $time_sec;
         $this->set('remaining_time', $time);
         $all_questions = $this->Question->review_questions($quiz_id);
         $count_data = count($all_questions);
         $this->set('question_quiz_id', $question_quiz_id);
         $this->set('data', $all_questions);
         $this->set('count_data', $count_data);
         $counter_unanswered_marked = $this->Question->count_unanswered_marked($quiz_id);
         $this->set('counter_unanswered_marked', $counter_unanswered_marked);
         $review = $this->params['named']['review'];
         $this->set('review', $review);
         $this->set('from_review', $from_review);
     } else {
         $this->Session->setFlash('Session timeout. Enter the code sent to your email to continue the quiz.', true);
         $this->redirect("/quizzes/resume");
     }
 }