/** * Run the migrations. * * @return void */ public function up() { Schema::create('studentdelayed', function (Blueprint $table) { $table->increments('id'); $table->integer('studentid'); $table->integer('programid'); $table->integer('collegeid'); $table->integer('semesters'); $table->timestamps(); }); $students = Studentdropout::select('studentid', 'programid', 'collegeid', 'semesters')->where('semesters', '>', 8)->get(); foreach ($students as $student) { $programid = $student->programid; $semesters = $student->semesters; $programYears = Program::select('numyears')->where('programid', $programid)->first()->numyears; if ($semesters > $programYears * 2) { $newEntry = new Studentdelayed(); $newEntry->studentid = $student->studentid; $newEntry->programid = $programid; $newEntry->collegeid = $student->collegeid; $newEntry->semesters = $semesters; $newEntry->save(); } } }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('studentdropouts', function (Blueprint $table) { // }); $students = Studentdropout::select('id', 'programid', 'semesters')->where('semesters', '>', 8)->get(); foreach ($students as $student) { $programYears = Program::select('numyears')->where('programid', $student->programid)->first()->numyears; if ($student->semesters > $programYears * 2) { Studentdropout::find($student->id)->delete(); } } }
public function getBatchDropoutRate() { $batchDropoutRate = []; $programids = $this->programs()->whereNotIn('programid', array(62, 66, 38, 117))->where('degreelevel', 'U')->lists('programid'); //To get batches of program whithin 2000-2009 $progYears = Studentterm::whereIn('programid', $programids)->groupBy('year')->orderBy('year', 'asc')->lists('year'); $max = 2009; $batches = []; foreach ($progYears as $progYear) { if ($progYear > 1999 && $progYear < $max + 1) { array_push($batches, $progYear * 100000); } } foreach ($batches as $batch) { $batchEnd = $batch + 100000; $allBatchStudents = count(Studentterm::select('studentid')->where('studentid', '>', $batch)->where('studentid', '<', $batchEnd)->whereIn('programid', $programids)->groupBy('studentid')->get()); $allBatchDropouts = Studentdropout::select('studentid')->where('studentid', '>', $batch)->where('studentid', '<', $batchEnd)->whereIn('lastprogramid', $programids)->count(); $batchDropoutRate[$batch / 100000] = round($allBatchDropouts / $allBatchStudents * 100, 2); } return $batchDropoutRate; }
public static function getBatchDropoutsCollege($batch, $collegeid) { $batchEnd = $batch + 100000; $programids = Studentdropout::getCollPrograms($collegeid); return Studentdropout::select('studentid')->where('studentid', '>=', $batch)->where('studentid', '<', $batchEnd)->whereIn('programid', $programids)->get(); }
public function getBatchDropoutRate() { $batchDropoutRate = []; //To get batches of program whithin 2000-2009 $progYears = Studentterm::where('programid', $this->programid)->groupBy('year')->orderBy('year', 'asc')->lists('year'); if ($this->revisionyear > 2009) { $max = 2012; } 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); } } foreach ($batches as $batch) { $batchEnd = $batch + 100000; $allBatchStudents = count(Studentterm::select('studentid')->where('studentid', '>', $batch)->where('studentid', '<', $batchEnd)->where('programid', $this->programid)->groupBy('studentid')->get()); $allBatchDropouts = Studentdropout::select('studentid')->where('studentid', '>', $batch)->where('studentid', '<', $batchEnd)->where('lastprogramid', $this->programid)->count(); $batchDropoutRate[$batch / 100000] = round($allBatchDropouts / $allBatchStudents * 100, 2); } return $batchDropoutRate; }