public function seedUnemployment($batches, $allStudents, $collegeid)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalUnemployed = 0;
         foreach ($students as $student) {
             $results = Studentterm::getOneEmploymentCollege($student->studentid, $collegeid);
             $unemployed = 0;
             foreach ($results as $result) {
                 if ($result->employment === 'N') {
                     $unemployed = 1;
                 }
             }
             $totalUnemployed = $totalUnemployed + $unemployed;
         }
         $newCorrelation = new Correlation();
         $newCorrelation->factorid = 8;
         $newCorrelation->batch = $batch;
         $countStudents = count($students);
         if ($countStudents > 0) {
             $newCorrelation->ratio = $totalUnemployed / $countStudents;
         } else {
             $newCorrelation->ratio = 0;
         }
         $newCorrelation->unittype = 'college';
         $newCorrelation->collegeid = $collegeid;
         $newCorrelation->save();
     }
 }
 public function seedHighGrades($batches, $allStudents, $collegeid)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalHigh = 0;
         foreach ($students as $student) {
             $gwa = Studentterm::getOneGradesCollege($student->studentid, $collegeid);
             if ($gwa > 1.0 || $gwa < 3.0) {
                 $totalHigh++;
             }
         }
         $newCorrelation = new Correlation();
         $newCorrelation->factorid = 7;
         $newCorrelation->batch = $batch;
         $countStudents = count($students);
         if ($countStudents > 0) {
             $newCorrelation->ratio = $totalHigh / $countStudents;
         } else {
             $newCorrelation->ratio = 0;
         }
         $newCorrelation->unittype = 'college';
         $newCorrelation->collegeid = $collegeid;
         $newCorrelation->save();
     }
 }
Example #3
0
 public function showSpecificCollege()
 {
     $collegeIDInput = Input::get('college-dropdown');
     $college = College::find($collegeIDInput);
     $collegedepartments = $college->departments()->whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38));
         $q->where('degreelevel', 'U');
     })->get();
     //ave students per year and ave difference
     $programids = $college->programs()->whereNotIn('programid', array(62, 66, 38))->where('degreelevel', 'U')->lists('programid');
     //To get batches of program whithin 2000-2009
     $yearsArray = Studentterm::whereIn('programid', $programids)->where('year', '>', 1999)->where('year', '<', 2014)->groupBy('year')->orderBy('year', 'asc')->lists('year');
     $yearlyStudentAverage = [];
     $collegeDepartmentsAverage = [];
     foreach ($yearsArray as $yearData) {
         $aveStudents = round($college->getYearlyAveStudents($yearData), 2);
         if ($aveStudents > 1) {
             $yearlyStudentAverage[$yearData] = $aveStudents;
         }
     }
     foreach ($collegedepartments as $collegedepartment) {
         $collegeDepartmentsAverage[$collegedepartment->unitname] = round($collegedepartment->getAveStudents(), 2);
     }
     $aveAttrition = $college->getAveAttrition();
     $aveShiftRate = $college->getAveShiftRate();
     $aveYearsBeforeDropout = $college->getAveYearsBeforeDropout();
     $aveYearsBeforeShifting = $college->getAveYearsBeforeShifting();
     $batchAttrition = $college->getBatchAttrition();
     $departmentsAttrition = $college->getDepartmentsAveBatchAttrition();
     $gradeCount = $college->getGradeCount();
     $shiftGradeCount = $college->getShiftGradeCount();
     $stbracketCount = $college->getSTBracketCount();
     $shiftBracketCount = $college->getShiftSTBracketCount();
     return View::make('college.college-specific', ['college' => $college, 'yearlyStudentAverage' => $yearlyStudentAverage, 'collegedepartments' => $collegedepartments, 'collegeDepartmentsAverage' => $collegeDepartmentsAverage, 'aveAttrition' => $aveAttrition, 'batchAttrition' => $batchAttrition, 'aveShiftRate' => $aveShiftRate, 'aveYearsBeforeDropout' => $aveYearsBeforeDropout, 'aveYearsBeforeShifting' => $aveYearsBeforeShifting, 'departmentsAttrition' => $departmentsAttrition, 'gradeCount' => $gradeCount, 'shiftGradeCount' => $shiftGradeCount, 'stbracketCount' => $stbracketCount, 'shiftBracketCount' => $shiftBracketCount]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('correlations', function (Blueprint $table) {
         //
     });
     $batches = [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009];
     foreach ($batches as $batch) {
         $students = Studentterm::getBatchStudents($batch * 100000);
         $totalUnderload = 0;
         $totalNodata = 0;
         foreach ($students as $student) {
             $units = Assessment::getOneAveUnits($student->studentid);
             if ($units === -1) {
                 $totalNodata++;
             } else {
                 if ($units < 15) {
                     $totalUnderload++;
                 } else {
                 }
             }
         }
         $newEntry = new Correlation();
         $newEntry->factorid = 6;
         $newEntry->batch = $batch;
         $newEntry->ratio = $totalUnderload / (count($students) - $totalNodata);
         $newEntry->save();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('correlations', function (Blueprint $table) {
         //
     });
     $entries = Correlation::where('unittype', 'program')->get();
     foreach ($entries as $entry) {
         $batch = $entry->batch;
         $programid = $entry->programid;
         $dropoutsRaw = Studentdropout::getBatchDropoutsProgram($batch * 100000, $programid);
         $shiftsRaw = Studentshift::getBatchShiftsProgram($batch * 100000, $programid);
         $delayedRaw = Studentdelayed::getBatchDelayedProgram($batch * 100000, $programid);
         $studentids = [];
         foreach ($dropoutsRaw as $doRaw) {
             array_push($studentids, $doRaw->studentid);
         }
         foreach ($shiftsRaw as $sRaw) {
             array_push($studentids, $sRaw->studentid);
         }
         foreach ($delayedRaw as $dRaw) {
             array_push($studentids, $dRaw->studentid);
         }
         $studentids = array_values(array_unique($studentids));
         $students = Studentterm::getBatchStudentsCountProgram($batch * 100000, $programid);
         if ($students > 0) {
             $entry->dropouts = count($studentids) / $students;
         } else {
             $entry->dropouts = 0;
         }
         $entry->save();
     }
 }
Example #6
0
 public function showSpecificProgram()
 {
     $programIDInput = Input::get('program-dropdown');
     $program = Program::find($programIDInput);
     //ave students per year and ave difference
     $yearsArray = Studentterm::where('programid', $program->programid)->where('year', '>', 1999)->where('year', '<', 2014)->groupBy('year')->orderBy('year', 'asc')->lists('year');
     $yearlyStudentAverage = [];
     $yearlySemDifference = [];
     foreach ($yearsArray as $yearData) {
         $aveStudents = $program->getYearlyAveStudents($yearData);
         if ($aveStudents > 1) {
             $yearlyStudentAverage[$yearData] = $aveStudents;
         }
     }
     $aveYearsOfStay = $program->getAveYearsOfStay();
     $aveYearsBeforeDropout = $program->getAveYearsBeforeDropout();
     $aveYearsBeforeShifting = $program->getAveYearsBeforeShifting();
     $aveAttrition = $program->getAveAttrition();
     $aveShiftRate = $program->getAveShiftRate();
     $batchAttrition = $program->getBatchAttrition();
     $batchShiftRate = $program->getBatchShiftRate();
     $division = $program->getDivision();
     $numYears = $program->getNumYears();
     $gradeCount = $program->getGradeCount();
     $shiftGradeCount = $program->getShiftGradeCount();
     $stbracketCount = $program->getSTBracketCount();
     $shiftBracketCount = $program->getShiftSTBracketCount();
     return View::make('program.program-specific', ['program' => $program, 'aveYearsOfStay' => $aveYearsOfStay, 'yearlyStudentAverage' => $yearlyStudentAverage, 'aveYearsBeforeShifting' => $aveYearsBeforeShifting, 'aveYearsBeforeDropout' => $aveYearsBeforeDropout, 'aveAttrition' => $aveAttrition, 'batchAttrition' => $batchAttrition, 'aveShiftRate' => $aveShiftRate, 'batchShiftRate' => $batchShiftRate, 'division' => $division, 'numYears' => $numYears, 'gradeCount' => $gradeCount, 'shiftGradeCount' => $shiftGradeCount, 'stbracketCount' => $stbracketCount, 'shiftBracketCount' => $shiftBracketCount]);
 }
 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 countStudentSem($studentid, $programid)
 {
     $aysems = Studentterm::select('aysem')->where('studentid', $studentid)->where('programid', $programid)->get();
     $sems = 0;
     foreach ($aysems as $aysem) {
         $sem = substr($aysem->aysem, -1);
         if ($sem === '1' || $sem === '2') {
             $sems = $sems + 1;
         }
     }
     return $sems;
 }
 public function seedProgram($entry)
 {
     $batch = $entry->batch;
     $programid = $entry->programid;
     $dropouts = Studentdropout::getBatchDropoutsCountProgram($batch * 100000, $programid);
     $students = Studentterm::getBatchStudentsCountProgram($batch * 100000, $programid);
     if ($entry->dropouts > 0) {
         $entry->dropouts = $dropouts / $students;
     } else {
         $entry->dropouts = 0;
     }
     $entry->save();
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('studentdropouts', function (Blueprint $table) {
         //
         $table->integer('lastprogramid')->nullable();
     });
     $studentdropouts = Studentdropout::all();
     foreach ($studentdropouts as $dropout) {
         $lastsem = DB::table('studentterms')->select(DB::raw('MAX(aysem) AS lastsem'))->where('studentid', $dropout->studentid)->lists(DB::raw('lastsem'));
         $lastsemdata = Studentterm::where('studentid', $dropout->studentid)->where('aysem', $lastsem[0])->first();
         $dropout->lastprogramid = $lastsemdata->programid;
         $dropout->save();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('correlations', function (Blueprint $table) {
         //
     });
     $batches = [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009];
     $allStudents = [];
     $colleges = College::select('unitid')->get();
     foreach ($colleges as $college) {
         $collegeid = $college->unitid;
         foreach ($batches as $batch) {
             $allStudents[$batch] = Studentterm::getBatchStudentsCollege($batch * 100000, $collegeid);
         }
         $this->seedUnits($batches, $allStudents, $collegeid);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('correlations', function (Blueprint $table) {
         //
     });
     $batches = [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009];
     $allStudents = [];
     $programs = Program::select('programid')->get();
     foreach ($programs as $program) {
         $programid = $program->programid;
         foreach ($batches as $batch) {
             $allStudents[$batch] = Studentterm::getBatchStudentsProgram($batch * 100000, $programid);
         }
         $this->alterOverload($batches, $allStudents, $programid);
         $this->alterUnits($batches, $allStudents, $programid);
     }
 }
 public function seedHighGrades($batches, $allStudents)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalHigh = 0;
         foreach ($students as $student) {
             $gwa = Studentterm::getOneGrades($student->studentid);
             if ($gwa > 0.0 || $gwa < 3.0) {
                 $totalHigh++;
             }
         }
         $newCorrelation = new Correlation();
         $newCorrelation->factorid = 7;
         $newCorrelation->batch = $batch;
         $newCorrelation->ratio = $totalHigh / count($students);
         $newCorrelation->save();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('studentshifts', function (Blueprint $table) {
         //
         $table->increments('id');
         $table->integer('studentid');
         $table->integer('program1id');
         $table->decimal('program1years');
         $table->integer('program2id');
         $table->decimal('program2years');
         $table->timestamps();
     });
     //create array of programids of graduate programs
     $mastersArray = DB::table('programs')->where('degreelevel', '!=', 'U')->where('programid', '!=', 38)->lists('programid');
     /*get list of students who shifted out
     			1. Join studentterms to itself
     			2. Get studentids of students who have studentterms with different programids
     			3. Get their first and second programs
     			4. Make sure the programs are not graduate programs
     			5. Shifting should be done directly after the program1 aysem (ex. program1 aysem = 20101 and program2 = 20102 or program1 aysem = 20102 and program2 = 20111)
     		*/
     $shiftees = DB::table('studentterms AS e1')->join('studentterms AS e2', DB::raw('e1.studentid'), '=', DB::raw('e2.studentid'))->select(DB::raw('e1.studentid AS studentid'), DB::raw('e1.programid AS program1'), DB::raw('e2.programid AS program2'))->where(DB::raw('e1.programid'), '!=', DB::raw('e2.programid'))->where(DB::raw('e1.studentid'), '>', 200000000)->whereNotIn(DB::raw('e1.programid'), $mastersArray)->whereNotIn(DB::raw('e2.programid'), $mastersArray)->whereIn(DB::raw('e2.aysem::Int4 - e1.aysem::Int4'), array(1, 9))->whereRaw('CAST(e1.aysem AS TEXT) NOT LIKE \'%3\'')->whereRaw('CAST(e2.aysem AS TEXT) NOT LIKE \'%3\'')->groupBy(DB::raw('e1.studentid'), DB::raw('e1.programid'), DB::raw('e2.programid'))->get();
     /*Populate table:
     		  	1. For each student, take note of their programs
     			2. Get the number of sems they spent in each program, exclude summer (aysem ending in 3)
     			3. Divide number of sems by 2 to get the number of years
     		*/
     foreach ($shiftees as $shiftee) {
         $studentid = $shiftee->studentid;
         $program1id = $shiftee->program1;
         $program2id = $shiftee->program2;
         $program1sems = Studentterm::where('studentid', $studentid)->where('programid', $program1id)->whereRaw('CAST(aysem AS TEXT) NOT LIKE \'%3\'')->count();
         $program1years = $program1sems / 2;
         $program2sems = Studentterm::where('studentid', $studentid)->where('programid', $program2id)->whereRaw('CAST(aysem AS TEXT) NOT LIKE \'%3\'')->count();
         $program2years = $program2sems / 2;
         $studentshift = new Studentshift();
         $studentshift->studentid = $studentid;
         $studentshift->program1id = $program1id;
         $studentshift->program1years = $program1years;
         $studentshift->program2id = $program2id;
         $studentshift->program2years = $program2years;
         $studentshift->save();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('correlations', function (Blueprint $table) {
         //
     });
     $entries = Correlation::where('unittype', 'campus')->get();
     foreach ($entries as $entry) {
         $batch = $entry->batch;
         $dropouts = Studentdropout::getBatchDropoutsCount($batch * 100000);
         $delayed = Studentdelayed::getBatchDelayedCount($batch * 100000);
         $students = Studentterm::getBatchStudentsCount($batch * 100000);
         if ($students > 0) {
             $entry->dropouts = ($dropouts + $delayed) / $students;
         } else {
             $entry->dropouts = 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();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('studentdropouts', function (Blueprint $table) {
         //
         /*Add data to include Applied Physics (programid = 117) and batch 2011 and 2012
         		1. Get all students from 2011 and 2012 who is taking applied physics
         		2. Remove students who shifted out
         		3. If batch 2011 and has no studentterm in 2012 and 2013 then add student to studentdropouts table
         		4. If batch 2012 and has no studentterm in 2013 then add student to studentdropouts table
         		*/
         $program = Program::where('programid', 117)->first();
         $shiftees = Studentshift::where('program1id', $program->programid)->lists('studentid');
         $min = 201100000;
         $max = 201300000;
         $studentids = Studentterm::select('studentid')->where('studentid', '>', $min)->where('studentid', '<', $max)->whereNotIn('studentid', $shiftees)->where('programid', $program->programid)->groupBy('studentid')->lists('studentid');
         foreach ($studentids as $studentid) {
             $student = Student::where('studentid', $studentid)->first();
             if ($student->studentid < 201200000) {
                 //batch 2011
                 $stayed = $student->studentterms()->where('year', 2012)->orWhere('year', 2013)->count();
             } else {
                 //batch 2012
                 $stayed = $student->studentterms()->where('year', 2013)->count();
             }
             if ($stayed === 0) {
                 //insert to studentdropout
                 $semcount = $student->studentterms()->where('programid', $program->programid)->whereRaw('CAST(aysem AS TEXT) NOT LIKE \'%3\'')->count();
                 $newDropout = new Studentdropout();
                 $newDropout->studentid = $student->studentid;
                 $newDropout->programid = $program->programid;
                 $newDropout->lastprogramid = $program->programid;
                 $newDropout->collegeid = $program->department->college->unitid;
                 $newDropout->semesters = $semcount;
                 $newDropout->save();
             }
         }
     });
 }
Example #18
0
 public function getShiftSpecificBatchSTBracketCount($batch)
 {
     $min = $batch * 100000;
     $max = $batch + 100000;
     $bracketArray = [];
     $dropouts = DB::table('studentdropouts')->where('lastprogramid', $this->programid)->lists('studentid');
     if ($this->programid == 28) {
         $programShiftees = Studentshift::select('studentid')->where('studentid', '>', $min)->where('studentid', '<', $max)->where('program1id', $this->programid)->where('program2id', '!=', 38)->where('program1years', '<=', $this->numyears) > whereNotIn('studentid', $dropouts)->groupBy('studentid')->lists('studentid');
     } else {
         $programShiftees = Studentshift::select('studentid')->where('studentid', '>', $min)->where('studentid', '<', $max)->where('program1id', $this->programid)->where('program1years', '<', $this->numyears) > whereNotIn('studentid', $dropouts)->groupBy('studentid')->lists('studentid');
     }
     $programShiftees = array_unique($programShiftees);
     $shifteeCount = count($programShiftees);
     $bracketA = 0;
     $bracketB = 0;
     $bracketC = 0;
     $bracketD = 0;
     $bracketE1 = 0;
     $bracketE2 = 0;
     $unstated = 0;
     foreach ($programShiftees as $shiftee) {
         $results = Studentterm::select('stfapbracket')->where('studentid', $shiftee)->where('programid', $this->programid)->groupBy('stfapbracket')->lists('stfapbracket');
         foreach ($results as $result) {
             switch ($result) {
                 case strpos($result, 'A') !== false || strpos($result, '9') !== false:
                     $bracketA++;
                     break;
                 case strpos($result, 'B') !== false:
                     $bracketB++;
                     break;
                 case strpos($result, 'C') !== false:
                     $bracketC++;
                     break;
                 case strpos($result, 'D') !== false:
                     $bracketD++;
                     break;
                 case strpos($result, 'E1') !== false:
                     $bracketE1++;
                     break;
                 case strpos($result, 'E2') !== false || strpos($result, '1') !== false:
                     $bracketE2++;
                     break;
                 default:
             }
         }
     }
     if ($shifteeCount != 0) {
         $tagged = $bracketA + $bracketB + $bracketC + $bracketD + $bracketE1 + $bracketE2;
         $bracketArray["A"] = round($bracketA / $tagged * 100, 2);
         $bracketArray["B"] = round($bracketB / $tagged * 100, 2);
         $bracketArray["C"] = round($bracketC / $tagged * 100, 2);
         $bracketArray["D"] = round($bracketD / $tagged * 100, 2);
         $bracketArray["E1"] = round($bracketE1 / $tagged * 100, 2);
         $bracketArray["E2"] = round($bracketE2 / $tagged * 100, 2);
     } else {
         $bracketArray["No Shiftees"] = 0;
     }
     return $bracketArray;
 }
Example #19
0
 public function getSpecificBatchSTBracketCount($batch)
 {
     $batch = $batch * 100000;
     $batchEnd = $batch + 100000;
     $bracketArray = [];
     $programids = Program::whereNotIn('programid', array(62, 66, 38, 22))->where('degreelevel', 'U')->lists('programid');
     $collegeDropouts = Studentdropout::whereIn('lastprogramid', $programids)->where('studentid', '>', $batch)->where('studentid', '<', $batchEnd)->get();
     $bracketA = 0;
     $bracketB = 0;
     $bracketC = 0;
     $bracketD = 0;
     $bracketE1 = 0;
     $bracketE2 = 0;
     $unstated = 0;
     foreach ($collegeDropouts as $dropout) {
         $results = Studentterm::select('stfapbracket')->where('studentid', $dropout->studentid)->whereIn('programid', $programids)->groupBy('stfapbracket')->lists('stfapbracket');
         $results = array_unique($results);
         foreach ($results as $result) {
             switch ($result) {
                 case strpos($result, 'A') !== false || strpos($result, '9') !== false:
                     $bracketA++;
                     break;
                 case strpos($result, 'B') !== false:
                     $bracketB++;
                     break;
                 case strpos($result, 'C') !== false:
                     $bracketC++;
                     break;
                 case strpos($result, 'D') !== false:
                     $bracketD++;
                     break;
                 case strpos($result, 'E1') !== false:
                     $bracketE1++;
                     break;
                 case strpos($result, 'E2') !== false || strpos($result, '1') !== false:
                     $bracketE2++;
                     break;
                 default:
                     $unstated++;
             }
         }
     }
     $bracketArray["A"] = $bracketA;
     $bracketArray["B"] = $bracketB;
     $bracketArray["C"] = $bracketC;
     $bracketArray["D"] = $bracketD;
     $bracketArray["E1"] = $bracketE1;
     $bracketArray["E2"] = $bracketE2;
     $bracketArray["Unstated"] = $unstated;
     return $bracketArray;
 }
Example #20
0
 public function getAveYearsBeforeShifting()
 {
     //To get batches of program whithin 2000-2009
     $programids = $this->programs()->whereNotIn('programid', array(62, 66, 38, 117))->where('degreelevel', 'U')->lists('programid');
     $progYears = Studentterm::whereIn('programid', $programids)->groupBy('year')->orderBy('year', 'asc')->lists('year');
     if ($this->revisionyear > 2009) {
         $max = 2013;
     } else {
         if ($this->programid == 28) {
             $max = 2013 - 4;
         } else {
             $max = 2013 - $this->numyears;
         }
     }
     $batches = [];
     foreach ($progYears as $progYear) {
         if ($progYear > 1999 && $progYear < $max + 1) {
             array_push($batches, $progYear * 100000);
         }
     }
     $min = min($batches);
     $max = max($batches) + 100000;
     $dropouts = DB::table('studentdropouts')->where('studentid', '>', $min)->where('studentid', '<', $max)->whereIn('lastprogramid', $programids)->lists('studentid');
     $shiftees = DB::table('studentshifts')->join('programs', 'program1id', '=', 'programid')->select('studentid', 'program1years')->where('studentid', '>', $min)->where('studentid', '<', $max)->whereIn('program1id', $programids)->whereNotIn('program2id', $programids)->where('program2id', '!=', 38)->whereRaw('program1years < CAST(numyears AS numeric)')->whereNotIn('studentid', $dropouts)->get();
     $sumYears = 0;
     foreach ($shiftees as $shiftee) {
         $sumYears = $sumYears + $shiftee->program1years;
     }
     if (count($shiftees) != 0) {
         $aveYears = $sumYears / count($shiftees);
     } else {
         $aveYears = 0;
     }
     return round($aveYears, 2);
 }
 public function seedStbracket($batches, $allStudents, $collegeid)
 {
     foreach ($batches as $batch) {
         $students = $allStudents[$batch];
         $totalPoor = 0;
         foreach ($students as $student) {
             $results = Studentterm::getOneStbracketCollege($student->studentid, $collegeid);
             $poor = 0;
             foreach ($results as $result) {
                 if (strpos($result->stfapbracket, 'A') !== false || strpos($result->stfapbracket, 'B') || strpos($result->stfapbracket, '8') !== false || strpos($result->stfapbracket, '9') !== false) {
                     $poor = 1;
                 }
             }
             $totalPoor = $totalPoor + $poor;
         }
         $newCorrelation = new Correlation();
         $newCorrelation->factorid = 3;
         $newCorrelation->batch = $batch;
         $countStudents = count($students);
         if ($countStudents > 0) {
             $newCorrelation->ratio = $totalPoor / $countStudents;
         } else {
             $newCorrelation->ratio = 0;
         }
         $newCorrelation->unittype = 'college';
         $newCorrelation->collegeid = $collegeid;
         $newCorrelation->save();
     }
 }
Example #22
0
 public static function getOneAveUnitsCollege($studentid, $collegeid)
 {
     $programids = Assessment::getCollPrograms($collegeid);
     $semesters = Assessment::select('total_units', 'aysem')->where('studentid', $studentid)->get();
     $totalUnits = 0;
     $totalSemesters = 0;
     $aysemGet = Studentterm::select('aysem')->where('studentid', $studentid)->whereIn('programid', $programids)->get();
     $aysems = [];
     foreach ($aysemGet as $aysem) {
         array_push($aysems, $aysem->aysem);
     }
     foreach ($semesters as $semester) {
         $semesterAysem = $semester->aysem;
         if (in_array($semesterAysem, $aysems) && (substr($semesterAysem, -1) === '1' || substr($semesterAysem, -1) === '2')) {
             $units = $semester->total_units;
             if ($units > 0 && $units <= 21) {
                 $totalUnits = $totalUnits + $units;
                 $totalSemesters = $totalSemesters + 1;
             }
         }
     }
     if ($totalSemesters > 0) {
         return $totalUnits / $totalSemesters;
     } else {
         return -1;
     }
 }
Example #23
0
 public static function getOneStbracketCollege($studentId, $collegeid)
 {
     $programids = Studentterm::getCollPrograms($collegeid);
     return Studentterm::select('stfapbracket')->where('studentid', $studentId)->whereIn('programid', $programids)->get();
 }