| @@ -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,35 +145,35 @@ 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; | 
| 163 | 163 | case 'count': | 
| 164 | 164 |                  $count = Examination_student::select('nsid') | 
| 165 | -                ->where('nsid','!=',) | |
| 165 | +                ->where('nsid', '!=',) | |
| 166 | 166 |                  ->groupeBy('nsid') | 
| 167 | 167 | ->count(); | 
| 168 | 168 |                  $all = Examination_student::select('nsid') | 
| 169 | 169 | ->count(); | 
| 170 | - $this->output->writeln( $all. 'Total Unique nsid are: ' .$count); | |
| 170 | + $this->output->writeln($all.'Total Unique nsid are: '.$count); | |
| 171 | 171 | default: | 
| 172 | 172 | $students = Examination_student::offset($offset) | 
| 173 | 173 | ->limit($limit) | 
| 174 | 174 | ->get()->toArray(); | 
| 175 | 175 | $students = (array) json_decode(json_encode($students)); | 
| 176 | - $this->output->writeln(count($students) . 'students remaining empty'); | |
| 176 | + $this->output->writeln(count($students).'students remaining empty'); | |
| 177 | 177 | array_walk($students, array($this, 'clone')); | 
| 178 | 178 |                  $this->output->writeln('All are generated'); | 
| 179 | 179 | } | 
| @@ -219,7 +219,7 @@ discard block | ||
| 219 | 219 | */ | 
| 220 | 220 | public function clone($student) | 
| 221 | 221 |      { | 
| 222 | - $student = (array)json_decode(json_encode($student)); | |
| 222 | + $student = (array) json_decode(json_encode($student)); | |
| 223 | 223 | //get student matching with same dob and gender | 
| 224 | 224 | |
| 225 | 225 | $matchedStudent = $this->getMatchingStudents($student); | 
| @@ -252,7 +252,7 @@ discard block | ||
| 252 | 252 | |
| 253 | 253 | //TODO implement insert student to admission table | 
| 254 | 254 | $student['id'] = $sis_student['id']; | 
| 255 | - $sis_student['student_id'] = $student['id']; | |
| 255 | + $sis_student['student_id'] = $student['id']; | |
| 256 | 256 | |
| 257 | 257 | $student = $this->setIsTakingExam($student); | 
| 258 | 258 |                  if (count($institutionClass) == 1) { | 
| @@ -260,13 +260,13 @@ discard block | ||
| 260 | 260 | Institution_student::createExaminationData($student, $admissionInfo); | 
| 261 | 261 | Institution_student_admission::createExaminationData($student, $admissionInfo); | 
| 262 | 262 | Institution_class_student::createExaminationData($student, $admissionInfo); | 
| 263 | -                } else { | |
| 263 | +                }else { | |
| 264 | 264 | Institution_student_admission::createExaminationData($student, $admissionInfo); | 
| 265 | 265 | Institution_student::createExaminationData($student, $admissionInfo); | 
| 266 | 266 | } | 
| 267 | 267 | $this->updateStudentId($student, $sis_student); | 
| 268 | 268 | // update the matched student's data | 
| 269 | -            } else { | |
| 269 | +            }else { | |
| 270 | 270 | $student = $this->setIsTakingExam($student); | 
| 271 | 271 | $studentData = $this->student->updateExaminationStudent($student, $matchedStudent); | 
| 272 | 272 | $matchedStudent = array_merge((array) $student, $matchedStudent); | 
| @@ -274,9 +274,9 @@ discard block | ||
| 274 | 274 | Institution_student::updateExaminationData($studentData, $admissionInfo); | 
| 275 | 275 | $this->updateStudentId($student, $studentData); | 
| 276 | 276 | } | 
| 277 | -        } else { | |
| 277 | +        }else { | |
| 278 | 278 | |
| 279 | -            $this->output->writeln('Student ' . $student['st_no'] . ' not imorted' . $student['f_name']); | |
| 279 | +            $this->output->writeln('Student '.$student['st_no'].' not imorted'.$student['f_name']); | |
| 280 | 280 | } | 
| 281 | 281 | } | 
| 282 | 282 | |
| @@ -294,7 +294,7 @@ discard block | ||
| 294 | 294 | $count = $this->student->getStudentCount($student); | 
| 295 | 295 | |
| 296 | 296 | $studentData = []; | 
| 297 | - $sis_users = (array) json_decode(json_encode($sis_student), true); | |
| 297 | + $sis_users = (array) json_decode(json_encode($sis_student), true); | |
| 298 | 298 | // if the same gender same DOE has more than one | 
| 299 | 299 | $studentData = $this->searchSimilarName($student, $sis_users); | 
| 300 | 300 | return $studentData; | 
| @@ -307,7 +307,7 @@ discard block | ||
| 307 | 307 | * @param array $sis_students | 
| 308 | 308 | * @return array | 
| 309 | 309 | */ | 
| 310 | - public function searchSimilarName($student, $sis_students,$surname_search = true) | |
| 310 | + public function searchSimilarName($student, $sis_students, $surname_search = true) | |
| 311 | 311 |      { | 
| 312 | 312 | $highest = []; | 
| 313 | 313 | $minDistance = 0; | 
| @@ -327,7 +327,7 @@ discard block | ||
| 327 | 327 | } | 
| 328 | 328 | } | 
| 329 | 329 | |
| 330 | -        if($surname_search){ | |
| 330 | +        if ($surname_search) { | |
| 331 | 331 |              if (empty($highest)) { | 
| 332 | 332 |                  foreach ($sis_students as $key => $value) { | 
| 333 | 333 | //search name with last name | 
| @@ -341,9 +341,9 @@ discard block | ||
| 341 | 341 | } | 
| 342 | 342 | } | 
| 343 | 343 | } | 
| 344 | -        if(count($matches) > 1){ | |
| 345 | - $this->searchSimilarName($student,$sis_students,false); | |
| 346 | -        }else{ | |
| 344 | +        if (count($matches) > 1) { | |
| 345 | + $this->searchSimilarName($student, $sis_students, false); | |
| 346 | +        }else { | |
| 347 | 347 | $data = $highest; | 
| 348 | 348 | } | 
| 349 | 349 | return $data; | 
| @@ -359,7 +359,7 @@ discard block | ||
| 359 | 359 | public function updateStudentId($student, $sis_student) | 
| 360 | 360 |      { | 
| 361 | 361 |          try { | 
| 362 | - $student['nsid'] = $sis_student['openemis_no']; | |
| 362 | + $student['nsid'] = $sis_student['openemis_no']; | |
| 363 | 363 | // add new NSID to the examinations data set | 
| 364 | 364 | unset($student['id']); | 
| 365 | 365 | unset($student['taking_g5_exam']); | 
| @@ -368,8 +368,8 @@ discard block | ||
| 368 | 368 | unset($student['total']); | 
| 369 | 369 |              $this->examination_student->where('st_no', $student['st_no'])->update($student); | 
| 370 | 370 | unset($student['st_no']); | 
| 371 | -            $this->output->writeln('Updated  to NSID' . $sis_student['openemis_no']); | |
| 372 | -        } catch (\Exception $th) { | |
| 371 | +            $this->output->writeln('Updated  to NSID'.$sis_student['openemis_no']); | |
| 372 | +        }catch (\Exception $th) { | |
| 373 | 373 | dd($th); | 
| 374 | 374 |              $this->output->writeln('error'); | 
| 375 | 375 | Log::error($th); | 
| @@ -387,7 +387,7 @@ discard block | ||
| 387 | 387 |          try { | 
| 388 | 388 |              (new ExaminationStudentsExport)->store('examination/student_data_with_nsid.csv'); | 
| 389 | 389 | (new ExportReady($adminUser)); | 
| 390 | -        } catch (\Throwable $th) { | |
| 390 | +        }catch (\Throwable $th) { | |
| 391 | 391 | //throw $th; | 
| 392 | 392 | dd($th); | 
| 393 | 393 | } | 
| @@ -397,13 +397,13 @@ discard block | ||
| 397 | 397 | public function downloadErrors() | 
| 398 | 398 |      { | 
| 399 | 399 | |
| 400 | - $file_path = storage_path() . '/app/examination/errors.csv'; | |
| 400 | + $file_path = storage_path().'/app/examination/errors.csv'; | |
| 401 | 401 | return Response::download($file_path); | 
| 402 | 402 | } | 
| 403 | 403 | |
| 404 | 404 | public function downloadProcessedFile() | 
| 405 | 405 |      { | 
| 406 | - $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv'; | |
| 406 | + $file_path = storage_path().'/app/examination/student_data_with_nsid.csv'; | |
| 407 | 407 | return Response::download($file_path); | 
| 408 | 408 | } | 
| 409 | 409 | } | 
| @@ -343,7 +343,7 @@ | ||
| 343 | 343 | } | 
| 344 | 344 |          if(count($matches) > 1){ | 
| 345 | 345 | $this->searchSimilarName($student,$sis_students,false); | 
| 346 | -        }else{ | |
| 346 | +        } else{ | |
| 347 | 347 | $data = $highest; | 
| 348 | 348 | } | 
| 349 | 349 | return $data; | 
| @@ -41,21 +41,21 @@ discard block | ||
| 41 | 41 | public function handle() | 
| 42 | 42 |      { | 
| 43 | 43 | $this->start_time = microtime(TRUE); | 
| 44 | -        $studentsIdsWithDuplication =   DB::table('examination_students as es') | |
| 45 | -        ->select(DB::raw('count(*) as total'),'es.*') | |
| 44 | +        $studentsIdsWithDuplication = DB::table('examination_students as es') | |
| 45 | +        ->select(DB::raw('count(*) as total'), 'es.*') | |
| 46 | 46 |          ->whereNotNull('es.nsid') | 
| 47 | -        ->orWhereNotNull('es.nsid','!=','') | |
| 48 | -        ->having('total','>',1) | |
| 47 | +        ->orWhereNotNull('es.nsid', '!=', '') | |
| 48 | +        ->having('total', '>', 1) | |
| 49 | 49 |          ->groupBy('es.nsid') | 
| 50 | 50 |          ->orderBy('es.nsid') | 
| 51 | -        ->chunk(10000,function($Students){ | |
| 51 | +        ->chunk(10000, function($Students) { | |
| 52 | 52 |              foreach ($Students as $Student) { | 
| 53 | - $this->output->writeln($Student->nsid,'Deleted 100 starting with' .$Students->st_no); | |
| 53 | + $this->output->writeln($Student->nsid, 'Deleted 100 starting with'.$Students->st_no); | |
| 54 | 54 |                  // Examination_student::where('st_no',$Student->st_no)->update(['nsid'=>'']); | 
| 55 | 55 | } | 
| 56 | 56 | $this->end_time = microtime(TRUE); | 
| 57 | -            $this->output->writeln('Deleted 100 starting with' .$Students[0]->st_no); | |
| 58 | -            $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); | |
| 57 | +            $this->output->writeln('Deleted 100 starting with'.$Students[0]->st_no); | |
| 58 | +            $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); | |
| 59 | 59 | }); | 
| 60 | 60 |          // $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); | 
| 61 | 61 | // $this->start_time = microtime(TRUE); | 
| @@ -81,16 +81,16 @@ discard block | ||
| 81 | 81 |      { | 
| 82 | 82 | array_walk($array, array($this, 'deleteDuplication')); | 
| 83 | 83 | $this->end_time = microtime(TRUE); | 
| 84 | -        $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); | |
| 84 | +        $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); | |
| 85 | 85 | $this->output->writeln(count($array).'entries cleaned'); | 
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | 88 | public function deleteDuplication($students) | 
| 89 | 89 |      { | 
| 90 | -        $count =  Examination_student::where('nsid', $students['nsid'])->count(); | |
| 90 | +        $count = Examination_student::where('nsid', $students['nsid'])->count(); | |
| 91 | 91 |          if ($count > 1) { | 
| 92 | 92 |              $count = Examination_student::where('nsid', $students['nsid'])->update(['nsid' => '']); | 
| 93 | - $this->output->writeln($students['nsid'] .'same ID' . $count . ' records removed'); | |
| 93 | + $this->output->writeln($students['nsid'].'same ID'.$count.' records removed'); | |
| 94 | 94 | } | 
| 95 | 95 | } | 
| 96 | 96 | } |