/** * Show the application dashboard to the user. * * @return Response */ public function index() { $user = \Auth::user(); $posts = \App\Post::all(); $posts = \App\Post::paginate(3); $users = \App\User::all(); $users = \App\User::paginate(3); $fiches = \App\Fiche::all(); if ($user->role == "teacher") { $fiches = \App\Fiche::paginate(3); } if ($user->role == "teacher") { return view('back.index', compact('posts', 'users', 'fiches', 'user')); } else { return view('backStudent.index', compact('fiches', 'user')); } }
/** * Store a newly created resource in storage. * * @return Response */ public function scoreCalcul() { $user = \Auth::user(); $fiche_id_2 = Session::get('fiche_id_2'); $input = Request::all(); $questions = \App\Fiche::find($fiche_id_2)->question; $score = 0; $lol = array_shift($input); $input = array_values($input); $reponse = []; foreach ($questions as $question) { array_push($reponse, $question->reponse); } $test = array_intersect_assoc($input, $reponse); $test = count($test); $reponse = count($reponse); return view('backStudent.resultat', compact('reponse', 'test', 'fiche_id_2', 'user', 'questions')); }