Example #1
0
 function calculeNoteExamen($id_Examen)
 {
     $note_Examens = Note_Examen::whereIdExamen($id_Examen)->get();
     foreach ($note_Examens as $note_Examen) {
         $note_Examen_Note = 0;
         $note_Stations = Note_Station::whereIdNoteExamen($note_Examen->id_Note_Examen)->get();
         foreach ($note_Stations as $note_Station) {
             $note_Items = Note_Item::whereIdNoteStation($note_Station->id_Note_Station)->get();
             $note_Station_Note = 0;
             foreach ($note_Items as $note_Item) {
                 if ($note_Item->note == 1) {
                     $note_Station_Note += Item::whereIdItem($note_Item->id_Item)->first()->valeur;
                 }
             }
             $note_Station->note = $note_Station_Note;
             $note_Station->save();
             $note_Examen_Note += $note_Station_Note * Station::whereIdStation($note_Station->id_Station)->first()->ponderation / 100;
         }
         $note_Examen->note = $note_Examen_Note;
         $note_Examen->save();
     }
 }