예제 #1
0
 /**
  * Responds to requests to GET /quizzes
  */
 public function getQuizzes()
 {
     if (Auth::user()->teacher) {
         return redirect()->action('EditController@getQuizzes');
     }
     // get grades for logged in user and put the quizzes in an array
     $grades = Grade::where('user_id', Auth::user()->id)->get()->lists('quiz_id');
     // get ready quizzes that have not been graded
     $quizzes = Quiz::whereNotIn('id', $grades)->where('ready', TRUE)->get();
     // if there are no ungraded quizzes flash message
     if ($quizzes->count() == 0) {
         \Session::flash('flash_message', 'You have no ungraded quizzes.');
         return redirect('/');
     }
     return view('quiz.list')->with('quizzes', $quizzes);
 }