<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Models\Session;
use App\Http\Controllers\Controller;
use App\Models\Examen;
use App\Models\Note_Examen;
use App\Metier\GestSession;

class welcomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    protected $gestSession;
    
    public function __construct(GestSession $gestSession){
        $this->gestSession=$gestSession;
    }

    public function index()
    {
        $sessions=$this->gestSession->getSessions();
        return view('welcome',compact('sessions'));    
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($sessionId = null)
    {
        $examens = Examen::join('Stage','Examen.id_Stage','=','Stage.id_Stage')->where('id_Session','=',$sessionId)->get();
        return view('examenViewPublic')->with('sessionId',$sessionId)->with('examens',$examens);
    }

    public function showNotes($sessionId = null,$examenId = null){
        $note_Examens= Note_Examen::whereIdSessionAndIdExamen($sessionId,$examenId)
            ->join('Etudiant','Etudiant.id_Etudiant','=','Note_Examen.id_Etudiant')
            ->get();
        return view('noteExamenViewPublic')
            ->with('note_Examens',$note_Examens)
            ->with('sessionId',$sessionId)
            ->with('examenId',$examenId);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
