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(); } }
public function seedUnits($batches, $allStudents, $collegeid) { foreach ($batches as $batch) { $students = $allStudents[$batch]; $totalUnderload = 0; $totalNodata = 0; foreach ($students as $student) { $units = Assessment::getOneAveUnitsCollege($student->studentid, $collegeid); 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 = 'college'; $newCorrelation->collegeid = $collegeid; $newCorrelation->save(); } }
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(); } }
/** * 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(); } }
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(); } }
/** * 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(); } }
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(); } }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('correlations', function (Blueprint $table) { // }); $entries = Correlation::get(); foreach ($entries as $entry) { if ($entry->unittype === 'campus') { $this->seedCampus($entry); } else { if ($entry->unittype === 'college') { $this->seedCollege($entry); } else { if ($entry->unittype === 'department') { $this->seedDepartment($entry); } else { if ($entry->unittype === 'program') { $this->seedProgram($entry); } else { } } } } } }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('correlations', function (Blueprint $table) { $table->float('dropouts')->nullable(); $table->string('unittype')->nullable(); $table->integer('programid')->nullable(); $table->integer('departmentid')->nullable(); $table->integer('collegeid')->nullable(); }); $entries = Correlation::get(); foreach ($entries as $entry) { $entry->unittype = 'campus'; $entry->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(); } }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('correlations', function (Blueprint $table) { // }); $departmentlist = Department::whereHas('programs', function ($q) { $q->whereNotIn('programid', array(62, 66, 38)); $q->where('degreelevel', 'U'); })->get(); $collegelist = []; $departmentids = []; foreach ($departmentlist as $department) { array_push($collegelist, $department->college); array_push($departmentids, $department->unitid); } $collegelist = array_unique($collegelist); $collegeids = []; foreach ($collegelist as $college) { array_push($collegeids, $college->unitid); } $entries = Correlation::where('unittype', 'college')->orWhere('unittype', 'department')->get(); foreach ($entries as $entry) { if ($entry->unittype === 'college') { $collegeid = $entry->collegeid; if (in_array($collegeid, $collegeids)) { } else { $entry->delete(); } } elseif ($entry->unittype === 'department') { $departmentid = $entry->departmentid; if (in_array($departmentid, $departmentids)) { } else { $entry->delete(); } } else { } } }
public function seedRegion($batches, $allStudents) { $regions = ['VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'ARMM']; foreach ($batches as $batch) { $totalFar = 0; $students = $allStudents[$batch]; foreach ($students as $student) { $regionHolder = Studentaddress::getOneRegion($student->studentid); if (count($regionHolder) > 0) { if (in_array($regionHolder->regioncode, $regions)) { $totalFar++; } } } $newCorrelation = new Correlation(); $newCorrelation->factorid = 4; $newCorrelation->batch = $batch; $newCorrelation->ratio = $totalFar / count($students); $newCorrelation->save(); } }
public function testDescribe() { $X = [1, 2, 3, 4, 5]; $Y = [2, 3, 4, 4, 6]; $stats = Correlation::describe($X, $Y); $this->assertTrue(is_array($stats)); $this->assertArrayHasKey('cov', $stats); $this->assertArrayHasKey('r', $stats); $this->assertArrayHasKey('R2', $stats); $this->assertArrayHasKey('tau', $stats); $this->assertArrayHasKey('rho', $stats); $this->assertTrue(is_numeric($stats['cov'])); $this->assertTrue(is_numeric($stats['r'])); $this->assertTrue(is_numeric($stats['R2'])); $this->assertTrue(is_numeric($stats['tau'])); $this->assertTrue(is_numeric($stats['rho'])); }
public function seedOverload($batches, $allStudents) { foreach ($batches as $batch) { $students = $allStudents[$batch]; $totalOverload = 0; $totalNodata = 0; foreach ($students as $student) { $units = Assessment::getOneAveUnits($student->studentid); if ($units === -1) { $totalNodata++; } else { if ($units > 18) { $totalOverload++; } else { } } } $newCorrelation = new Correlation(); $newCorrelation->factorid = 9; $newCorrelation->batch = $batch; $newCorrelation->ratio = $totalOverload / (count($students) - $totalNodata); $newCorrelation->save(); } }
public function corrOverloading($level, $levelid = null) { $rateOverloading = []; $attrition = []; $batches = []; $results = Correlation::getOverloading($level, $levelid); foreach ($results as $result) { array_push($batches, $result->batch); $rateOverloading[$result->batch] = $result->ratio; $attrition[$result->batch] = $result->dropouts; } return round($this->getCorrelation($rateOverloading, $attrition, $batches), 2); }
public static function getOverloading($level, $levelid = null) { switch ($level) { case 'campus': return Correlation::select('batch', 'ratio', 'dropouts')->where('factorid', 9)->where('unittype', 'campus')->get(); case 'college': return Correlation::select('batch', 'ratio', 'dropouts')->where('factorid', 9)->where('unittype', 'college')->where('collegeid', $levelid)->get(); case 'department': return Correlation::select('batch', 'ratio', 'dropouts')->where('factorid', 9)->where('unittype', 'department')->where('departmentid', $levelid)->get(); case 'program': return Correlation::select('batch', 'ratio', 'dropouts')->where('factorid', 9)->where('unittype', 'program')->where('programid', $levelid)->get(); default: # code... break; } }