public function get()
 {
     $test_options = TestOption::all();
     //push 'messages' to view
     $messages = $this->messageController->getMessages($this::MESSAGE_KEY);
     return View::make('admin-test-options', array('test_options' => $test_options, 'messages' => $messages));
 }
 public function get()
 {
     $messages = $this->messageController->getMessages($this::MESSAGE_KEY);
     //contestant take test only one time, so
     //if !admin && has-result >>> redirect to 'result'
     //(admin not blocked, need to review test-page)
     $contestant = Auth::user();
     if ($contestant->id != 1 && $contestant->result != "") {
         return Redirect::to('result');
     }
     //load random-question from database
     $chapters = Chapter::all();
     $random_questions = array();
     foreach ($chapters as $chapter) {
         //each chapter, load random-questions by chapter-rate
         //then store in $random_questions
         //            if($chapter->rate != 0){//make sure chapter has question
         //                $random_questions[] = $chapter->getQuestions->random($chapter->rate);
         //            }
         if (count($chapter->getQuestions) > $chapter->rate) {
             $random_questions[] = $chapter->getQuestions->random($chapter->rate);
         }
     }
     //get timer from test option
     $test_options = TestOption::all();
     $timer = $test_options[0];
     return View::make('test-bootstrap', array('random_questions' => $random_questions, 'timer' => $timer, 'messages' => $messages));
 }