public function alterStbracket($batches, $allStudents)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalPoor = 0;
         foreach ($students as $student) {
             $results = Studentterm::getOneStbracket($student->studentid);
             $poor = 0;
             foreach ($results as $result) {
                 if (strpos($result->stfapbracket, 'A') !== false || strpos($result->stfapbracket, 'B') !== false || strpos($result->stfapbracket, '8') !== false || strpos($result->stfapbracket, '9') !== false) {
                     $poor = 1;
                 }
             }
             $totalPoor = $totalPoor + $poor;
         }
         $entry = Correlation::where('batch', $batch)->where('unittype', 'campus')->where('factorid', 3)->first();
         $countStudents = count($students);
         if ($countStudents > 0) {
             $entry->ratio = $totalPoor / $countStudents;
         } else {
             $entry->ratio = 0;
         }
         $entry->save();
     }
 }
 public function seedStbracket($batches, $allStudents)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalPoor = 0;
         foreach ($students as $student) {
             $results = Studentterm::getOneStbracket($student->studentid);
             $poor = 0;
             foreach ($results as $result) {
                 if (strpos($result->stfapbracket, 'A') !== false || strpos($result->stfapbracket, 'B') !== false) {
                     $poor = 1;
                 }
             }
             $totalPoor = $totalPoor + $poor;
         }
         $newCorrelation = new Correlation();
         $newCorrelation->factorid = 3;
         $newCorrelation->batch = $batch;
         $newCorrelation->ratio = $totalPoor / count($students);
         $newCorrelation->save();
     }
 }