@@ -47,7 +47,7 @@ |
||
| 47 | 47 | $output->writeln('###########################################------starting export------###########################################'); |
| 48 | 48 | $this->examinationController->export(); |
| 49 | 49 | $output->writeln('###########################################------Finished inserting file records------###########################################'); |
| 50 | - } else { |
|
| 50 | + }else { |
|
| 51 | 51 | $this->examinationController->doMatch($this->argument('offset'), $this->argument('limit'), $this->argument(('mode'))); |
| 52 | 52 | $this->examinationController->export(); |
| 53 | 53 | } |
@@ -37,8 +37,8 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * @return \Illuminate\Support\Collection |
|
| 41 | - */ |
|
| 40 | + * @return \Illuminate\Support\Collection |
|
| 41 | + */ |
|
| 42 | 42 | public function query() |
| 43 | 43 | { |
| 44 | 44 | return Examination_student::query()->whereNotNull('nsid') |
@@ -306,7 +306,7 @@ |
||
| 306 | 306 | // if the same gender same DOE has more than one |
| 307 | 307 | if(($doe_students > 1) || ($count > 1)){ |
| 308 | 308 | $studentData = $this->searchSimilarName($student, $sis_users,false); |
| 309 | - }else{ |
|
| 309 | + } else{ |
|
| 310 | 310 | $studentData = $this->searchSimilarName($student, $sis_users); |
| 311 | 311 | } |
| 312 | 312 | return $studentData; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $this->grade = $grade; |
| 31 | 31 | $this->student = new Security_user(); |
| 32 | 32 | $this->examination_student = new Examination_student(); |
| 33 | - $this->academic_period = Academic_period::where('code', '=', $this->year)->first(); |
|
| 33 | + $this->academic_period = Academic_period::where('code', '=', $this->year)->first(); |
|
| 34 | 34 | $this->education_grade = Education_grade::where('code', '=', $this->grade)->first(); |
| 35 | 35 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 36 | 36 | } |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | ); |
| 73 | 73 | Session::flash('message', 'File upload successfully!'); |
| 74 | 74 | // Redirect to index |
| 75 | - } else { |
|
| 75 | + }else { |
|
| 76 | 76 | Session::flash('message', 'File too large. File must be less than 20MB.'); |
| 77 | 77 | } |
| 78 | - } else { |
|
| 78 | + }else { |
|
| 79 | 79 | Session::flash('message', 'Invalid File Extension.'); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $import->import($excelFile, 'local', \Maatwebsite\Excel\Excel::CSV); |
| 98 | 98 | if ($import->failures()->count() > 0) { |
| 99 | 99 | $errors = $import->failures(); |
| 100 | - $columns = [ |
|
| 100 | + $columns = [ |
|
| 101 | 101 | 'remarks', |
| 102 | 102 | 'st_no', |
| 103 | 103 | 'stu_no', |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | Storage::put($file, implode(',', $columns)); |
| 119 | 119 | |
| 120 | 120 | foreach ($errors as $error) { |
| 121 | - Storage::append($file, implode(':', $error->errors()) . ',' . implode(',', $error->values())); |
|
| 121 | + Storage::append($file, implode(':', $error->errors()).','.implode(',', $error->values())); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 124 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | $students = []; |
| 136 | 136 | switch ($mode) { |
| 137 | 137 | case 'duplicate': |
| 138 | - $students = DB::table('examination_students as es') |
|
| 138 | + $students = DB::table('examination_students as es') |
|
| 139 | 139 | ->select(DB::raw('count(*) as total'), 'e2.*') |
| 140 | - ->join('examination_students as e2', 'es.nsid','e2.nsid') |
|
| 140 | + ->join('examination_students as e2', 'es.nsid', 'e2.nsid') |
|
| 141 | 141 | ->having('total', '>', 1) |
| 142 | 142 | ->groupBy('e2.st_no') |
| 143 | 143 | ->orderBy('e2.st_no') |
@@ -145,18 +145,18 @@ discard block |
||
| 145 | 145 | ->limit($limit) |
| 146 | 146 | ->get()->toArray(); |
| 147 | 147 | $students = (array) json_decode(json_encode($students)); |
| 148 | - $this->output->writeln(count($students) . 'students remaining duplicate'); |
|
| 148 | + $this->output->writeln(count($students).'students remaining duplicate'); |
|
| 149 | 149 | array_walk($students, array($this, 'clone')); |
| 150 | 150 | $this->output->writeln('All are generated'); |
| 151 | 151 | break; |
| 152 | 152 | case 'empty'; |
| 153 | 153 | $students = Examination_student::whereNull('nsid') |
| 154 | - ->orWhere('nsid','<>','') |
|
| 154 | + ->orWhere('nsid', '<>', '') |
|
| 155 | 155 | ->offset($offset) |
| 156 | 156 | ->limit($limit) |
| 157 | 157 | ->get()->toArray(); |
| 158 | 158 | $students = (array) json_decode(json_encode($students)); |
| 159 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
| 159 | + $this->output->writeln(count($students).'students remaining empty'); |
|
| 160 | 160 | array_walk($students, array($this, 'clone')); |
| 161 | 161 | $this->output->writeln('All are generated'); |
| 162 | 162 | break; |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | ->count(); |
| 166 | 166 | $all = Examination_student::select('nsid') |
| 167 | 167 | ->count(); |
| 168 | - $this->output->writeln( $all. 'Total Unique nsid are: ' .$count); |
|
| 168 | + $this->output->writeln($all.'Total Unique nsid are: '.$count); |
|
| 169 | 169 | break; |
| 170 | 170 | default: |
| 171 | 171 | $students = Examination_student::offset($offset) |
| 172 | 172 | ->limit($limit) |
| 173 | 173 | ->get()->toArray(); |
| 174 | 174 | $students = (array) json_decode(json_encode($students)); |
| 175 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
| 175 | + $this->output->writeln(count($students).'students remaining empty'); |
|
| 176 | 176 | array_walk($students, array($this, 'clone')); |
| 177 | 177 | $this->output->writeln('All are generated'); |
| 178 | 178 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function clone($student) |
| 220 | 220 | { |
| 221 | - $student = (array)json_decode(json_encode($student)); |
|
| 221 | + $student = (array) json_decode(json_encode($student)); |
|
| 222 | 222 | //get student matching with same dob and gender |
| 223 | 223 | |
| 224 | 224 | $matchedStudent = $this->getMatchingStudents($student); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | //TODO implement insert student to admission table |
| 253 | 253 | $student['id'] = $sis_student['id']; |
| 254 | - $sis_student['student_id'] = $student['id']; |
|
| 254 | + $sis_student['student_id'] = $student['id']; |
|
| 255 | 255 | |
| 256 | 256 | $student = $this->setIsTakingExam($student); |
| 257 | 257 | if (count($institutionClass) == 1) { |
@@ -259,13 +259,13 @@ discard block |
||
| 259 | 259 | Institution_student::createExaminationData($student, $admissionInfo); |
| 260 | 260 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
| 261 | 261 | Institution_class_student::createExaminationData($student, $admissionInfo); |
| 262 | - } else { |
|
| 262 | + }else { |
|
| 263 | 263 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
| 264 | 264 | Institution_student::createExaminationData($student, $admissionInfo); |
| 265 | 265 | } |
| 266 | 266 | $this->updateStudentId($student, $sis_student); |
| 267 | 267 | // update the matched student's data |
| 268 | - } else { |
|
| 268 | + }else { |
|
| 269 | 269 | $student = $this->setIsTakingExam($student); |
| 270 | 270 | $studentData = $this->student->updateExaminationStudent($student, $matchedStudent); |
| 271 | 271 | $matchedStudent = array_merge((array) $student, $matchedStudent); |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | Institution_student::updateExaminationData($studentData, $admissionInfo); |
| 274 | 274 | $this->updateStudentId($student, $studentData); |
| 275 | 275 | } |
| 276 | - } else { |
|
| 276 | + }else { |
|
| 277 | 277 | |
| 278 | - $this->output->writeln('Student ' . $student['st_no'] . ' not imorted' . $student['f_name']); |
|
| 278 | + $this->output->writeln('Student '.$student['st_no'].' not imorted'.$student['f_name']); |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
@@ -292,18 +292,18 @@ discard block |
||
| 292 | 292 | /** |
| 293 | 293 | */ |
| 294 | 294 | $sis_student = $this->student->getMatches($student); |
| 295 | - $doe_students = Examination_student::where('gender',$student['gender']) |
|
| 296 | - ->where('b_date',$student['b_date']) |
|
| 297 | - ->where('schoolid',$student['schoolid']) |
|
| 295 | + $doe_students = Examination_student::where('gender', $student['gender']) |
|
| 296 | + ->where('b_date', $student['b_date']) |
|
| 297 | + ->where('schoolid', $student['schoolid']) |
|
| 298 | 298 | ->count(); |
| 299 | 299 | $count = $this->student->getStudentCount($student); |
| 300 | 300 | |
| 301 | 301 | $studentData = []; |
| 302 | - $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
| 302 | + $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
| 303 | 303 | // if the same gender same DOE has more than one |
| 304 | - if(($doe_students > 1) || ($count > 1)){ |
|
| 305 | - $studentData = $this->searchSimilarName($student, $sis_users,false); |
|
| 306 | - }else{ |
|
| 304 | + if (($doe_students > 1) || ($count > 1)) { |
|
| 305 | + $studentData = $this->searchSimilarName($student, $sis_users, false); |
|
| 306 | + }else { |
|
| 307 | 307 | $studentData = $this->searchSimilarName($student, $sis_users); |
| 308 | 308 | } |
| 309 | 309 | return $studentData; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param array $sis_students |
| 317 | 317 | * @return array |
| 318 | 318 | */ |
| 319 | - public function searchSimilarName($student, $sis_students,$surname_search = true) |
|
| 319 | + public function searchSimilarName($student, $sis_students, $surname_search = true) |
|
| 320 | 320 | { |
| 321 | 321 | $highest = []; |
| 322 | 322 | $minDistance = 0; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if($surname_search){ |
|
| 339 | + if ($surname_search) { |
|
| 340 | 340 | if (empty($highest)) { |
| 341 | 341 | foreach ($sis_students as $key => $value) { |
| 342 | 342 | //search name with last name |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if(count($matches)>1){ |
|
| 356 | - $highest = $this->searchSimilarName($student, $sis_students,false); |
|
| 355 | + if (count($matches) > 1) { |
|
| 356 | + $highest = $this->searchSimilarName($student, $sis_students, false); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | return $highest; |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | public function updateStudentId($student, $sis_student) |
| 370 | 370 | { |
| 371 | 371 | try { |
| 372 | - $student['nsid'] = $sis_student['openemis_no']; |
|
| 372 | + $student['nsid'] = $sis_student['openemis_no']; |
|
| 373 | 373 | // add new NSID to the examinations data set |
| 374 | 374 | unset($student['id']); |
| 375 | 375 | unset($student['taking_g5_exam']); |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | unset($student['total']); |
| 379 | 379 | $this->examination_student->where('st_no', $student['st_no'])->update($student); |
| 380 | 380 | unset($student['st_no']); |
| 381 | - $this->output->writeln('Updated to NSID' . $sis_student['openemis_no']); |
|
| 382 | - } catch (\Exception $th) { |
|
| 381 | + $this->output->writeln('Updated to NSID'.$sis_student['openemis_no']); |
|
| 382 | + }catch (\Exception $th) { |
|
| 383 | 383 | dd($th); |
| 384 | 384 | $this->output->writeln('error'); |
| 385 | 385 | Log::error($th); |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | try { |
| 398 | 398 | (new ExaminationStudentsExport)->store('examination/student_data_with_nsid.'.time().'.csv'); |
| 399 | 399 | (new ExportReady($adminUser)); |
| 400 | - } catch (\Throwable $th) { |
|
| 400 | + }catch (\Throwable $th) { |
|
| 401 | 401 | //throw $th; |
| 402 | 402 | dd($th); |
| 403 | 403 | } |
@@ -407,13 +407,13 @@ discard block |
||
| 407 | 407 | public function downloadErrors() |
| 408 | 408 | { |
| 409 | 409 | |
| 410 | - $file_path = storage_path() . '/app/examination/errors.csv'; |
|
| 410 | + $file_path = storage_path().'/app/examination/errors.csv'; |
|
| 411 | 411 | return Response::download($file_path); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | public function downloadProcessedFile() |
| 415 | 415 | { |
| 416 | - $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv'; |
|
| 416 | + $file_path = storage_path().'/app/examination/student_data_with_nsid.csv'; |
|
| 417 | 417 | return Response::download($file_path); |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -44,21 +44,21 @@ |
||
| 44 | 44 | $this->start_time = microtime(TRUE); |
| 45 | 45 | $count = DB::table('examination_students')->select('nsid')->distinct()->count(); |
| 46 | 46 | $this->examinationController = new ExaminationStudentsController($this->argument('year'), $this->argument('grade')); |
| 47 | - $studentsIdsWithDuplication = DB::table('examination_students as es') |
|
| 48 | - ->select(DB::raw('count(*) as total'),'es.*') |
|
| 47 | + $studentsIdsWithDuplication = DB::table('examination_students as es') |
|
| 48 | + ->select(DB::raw('count(*) as total'), 'es.*') |
|
| 49 | 49 | ->whereNotNull('es.nsid') |
| 50 | - ->having('total','>',1) |
|
| 50 | + ->having('total', '>', 1) |
|
| 51 | 51 | ->groupBy('es.nsid') |
| 52 | 52 | ->orderBy('es.nsid') |
| 53 | - ->chunk($this->argument('limit'),function($Students){ |
|
| 53 | + ->chunk($this->argument('limit'), function($Students) { |
|
| 54 | 54 | foreach ($Students as $Student) { |
| 55 | - $count = Examination_student::where('nsid',$Student->nsid)->count(); |
|
| 56 | - if($count> 1){ |
|
| 57 | - Examination_student::where('nsid',$Student->nsid)->update(['nsid'=>'']); |
|
| 55 | + $count = Examination_student::where('nsid', $Student->nsid)->count(); |
|
| 56 | + if ($count > 1) { |
|
| 57 | + Examination_student::where('nsid', $Student->nsid)->update(['nsid'=>'']); |
|
| 58 | 58 | $students = (array) json_decode(json_encode($Students), true); |
| 59 | 59 | array_walk($students, array($this->examinationController, 'clone')); |
| 60 | 60 | } |
| 61 | - $this->output->writeln($Student->nsid .'same ID' . $count . ' records removed'); |
|
| 61 | + $this->output->writeln($Student->nsid.'same ID'.$count.' records removed'); |
|
| 62 | 62 | } |
| 63 | 63 | }); |
| 64 | 64 | } |
@@ -48,10 +48,10 @@ |
||
| 48 | 48 | DB::table('institution_students as is') |
| 49 | 49 | ->join('security_users as su', 'su.id', 'is.student_id') |
| 50 | 50 | ->where('is.updated_from', 'doe') |
| 51 | - ->orWhere('su.updated_from','doe') |
|
| 51 | + ->orWhere('su.updated_from', 'doe') |
|
| 52 | 52 | ->groupBy('is.student_id') |
| 53 | 53 | ->orderBy('is.student_id') |
| 54 | - ->chunk($this->argument('limit'), function ($Students) use ($output) { |
|
| 54 | + ->chunk($this->argument('limit'), function($Students) use ($output) { |
|
| 55 | 55 | $output->writeln('###########################################------Start cleanning exam records------###########################################'); |
| 56 | 56 | foreach ($Students as $Student) { |
| 57 | 57 | $exist = Examination_student::where('nsid', $Student->openemis_no)->exist(); |