public function alterUnits($batches, $allStudents, $programid)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalUnderload = 0;
         $totalNodata = 0;
         foreach ($students as $student) {
             $units = Assessment::getOneAveUnitsProgram($student->studentid, $programid);
             if ($units === -1) {
                 $totalNodata++;
             } else {
                 if ($units < 15) {
                     $totalUnderload++;
                 } else {
                 }
             }
         }
         $entry = Correlation::where('batch', $batch)->where('unittype', 'program')->where('programid', $programid)->where('factorid', 6)->first();
         $countStudents = count($students);
         if ($countStudents - $totalNodata > 0) {
             $entry->ratio = $totalUnderload / ($countStudents - $totalNodata);
         } else {
             $entry->ratio = 0;
         }
         $entry->save();
     }
 }
 public function seedUnits($batches, $allStudents, $programid)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalUnderload = 0;
         $totalNodata = 0;
         foreach ($students as $student) {
             $units = Assessment::getOneAveUnitsProgram($student->studentid, $programid);
             if ($units === -1) {
                 $totalNodata++;
             } else {
                 if ($units < 15) {
                     $totalUnderload++;
                 } else {
                 }
             }
         }
         $newCorrelation = new Correlation();
         $newCorrelation->factorid = 6;
         $newCorrelation->batch = $batch;
         $countStudents = count($students);
         if ($countStudents - $totalNodata > 0) {
             $newCorrelation->ratio = $totalUnderload / ($countStudents - $totalNodata);
         } else {
             $newCorrelation->ratio = 0;
         }
         $newCorrelation->unittype = 'program';
         $newCorrelation->programid = $programid;
         $newCorrelation->save();
     }
 }