@@ -41,7 +41,7 @@ |
||
41 | 41 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
42 | 42 | $output->writeln('###########################################------Inserting file records------###########################################'); |
43 | 43 | |
44 | - ExaminationStudentsController::callOnClick($this->argument('year'),$this->argument('grade')); |
|
44 | + ExaminationStudentsController::callOnClick($this->argument('year'), $this->argument('grade')); |
|
45 | 45 | $output->writeln('###########################################------Finished inserting file records------###########################################'); |
46 | 46 | } |
47 | 47 | } |
@@ -42,9 +42,9 @@ |
||
42 | 42 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
43 | 43 | $output->writeln('###########################################------Inserting file records------###########################################'); |
44 | 44 | $this->examinationController = new ExaminationStudentsController(2019, 'G4'); |
45 | - $students = Examination_student::all()->toArray(); |
|
45 | + $students = Examination_student::all()->toArray(); |
|
46 | 46 | $func = $this->examinationController; |
47 | - array_walk($students,array($func,'updateCensusNo')); |
|
47 | + array_walk($students, array($func, 'updateCensusNo')); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | } |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | use Maatwebsite\Excel\Concerns\WithBatchInserts; |
19 | 19 | use Maatwebsite\Excel\Concerns\WithChunkReading; |
20 | 20 | |
21 | -class ExaminationStudentsImport implements ToModel, WithStartRow, WithHeadingRow, WithChunkReading, WithBatchInserts , WithValidation ,WithMapping, SkipsOnFailure, SkipsOnError |
|
21 | +class ExaminationStudentsImport implements ToModel, WithStartRow, WithHeadingRow, WithChunkReading, WithBatchInserts, WithValidation, WithMapping, SkipsOnFailure, SkipsOnError |
|
22 | 22 | { |
23 | - use Importable , SkipsFailures, SkipsErrors; |
|
23 | + use Importable, SkipsFailures, SkipsErrors; |
|
24 | 24 | |
25 | - public function __construct($year,$grade) |
|
25 | + public function __construct($year, $grade) |
|
26 | 26 | { |
27 | 27 | $this->year = $year; |
28 | 28 | $this->grade = $grade; |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | |
63 | 63 | private function transformDateTime(string $value, string $format = 'm/d/Y') |
64 | 64 | { |
65 | - try{ |
|
65 | + try { |
|
66 | 66 | $date = date_create_from_format('m/d/Y', $value); |
67 | - if(gettype($date)=='boolean'){ |
|
67 | + if (gettype($date) == 'boolean') { |
|
68 | 68 | $date = date_create_from_format('Y-m-d', $value); |
69 | 69 | } |
70 | 70 | $date = date_format($date, 'Y-m-d'); |
71 | 71 | return $date; |
72 | - }catch(\Exception $e){ |
|
72 | + }catch (\Exception $e) { |
|
73 | 73 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
74 | 74 | $failure = new Failure(2, 'remark', [0 => 'The given date is wrong']); |
75 | 75 | $failures = [0 => $failure]; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | "medium" => $row['medium'], |
92 | 92 | "gender" => $row['gender'], |
93 | 93 | "b_date" => $row['b_date'], |
94 | - "a_income" => $row['a_income'] ? $row['a_income'] : 0 , |
|
94 | + "a_income" => $row['a_income'] ? $row['a_income'] : 0, |
|
95 | 95 | "grade" => $this->grade, |
96 | 96 | 'year' => $this->year, |
97 | 97 | "schoolid" => $row['schoolid'], |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | use Maatwebsite\Excel\Concerns\WithHeadings; |
11 | 11 | use Carbon\Carbon; |
12 | 12 | |
13 | -class ExaminationStudentsExport implements FromQuery , WithHeadings |
|
13 | +class ExaminationStudentsExport implements FromQuery, WithHeadings |
|
14 | 14 | { |
15 | 15 | |
16 | 16 | use Exportable; |
17 | 17 | |
18 | - public function __construct($year,$grade) |
|
18 | + public function __construct($year, $grade) |
|
19 | 19 | { |
20 | 20 | $this->year = $year; |
21 | 21 | $this->grade = $grade; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | return Examination_student::query()->whereNotNull('nsid') |
52 | 52 | ->distinct('nsid') |
53 | - ->where('year',$this->year) |
|
54 | - ->where('grade',$this->grade); |
|
53 | + ->where('year', $this->year) |
|
54 | + ->where('grade', $this->grade); |
|
55 | 55 | } |
56 | 56 | } |
@@ -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 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $Institution = $Institution[0]; |
145 | 145 | if (count($student) == 1) { |
146 | 146 | $student = $student[0]; |
147 | - if (((int)$Institution['id']) != ((int)$student['institution_id'])) { |
|
147 | + if (((int) $Institution['id']) != ((int) $student['institution_id'])) { |
|
148 | 148 | $studentClass = Institution_class_student::where('student_id', $student['student_id']) |
149 | 149 | ->first(); |
150 | 150 | Institution_class_student::where('student_id', $student['student_id'])->delete(); |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | if (!is_null($studentClass)) { |
155 | 155 | $class->updateClassCount($studentClass->toArray()); |
156 | 156 | } |
157 | - $output->writeln('updated student info:' . $data['nsid']); |
|
157 | + $output->writeln('updated student info:'.$data['nsid']); |
|
158 | 158 | } |
159 | - } else { |
|
159 | + }else { |
|
160 | 160 | Institution_student::where('institution_id', '<>', $Institution['id'])->where('student_id', $student[0]['student_id']) |
161 | 161 | ->delete(); |
162 | - $output->writeln('updated student info:' . $Institution['id'] . '==' . $Institution['id']); |
|
162 | + $output->writeln('updated student info:'.$Institution['id'].'=='.$Institution['id']); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $students = []; |
176 | 176 | switch ($mode) { |
177 | 177 | case 'duplicate': |
178 | - $students = DB::table('examination_students as es') |
|
178 | + $students = DB::table('examination_students as es') |
|
179 | 179 | ->select(DB::raw('count(*) as total'), 'e2.*') |
180 | 180 | ->where('grade', $this->grade) |
181 | 181 | ->where('year', $this->year) |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | ->limit($limit) |
188 | 188 | ->get()->toArray(); |
189 | 189 | $students = (array) json_decode(json_encode($students)); |
190 | - $this->output->writeln(count($students) . 'students remaining duplicate'); |
|
190 | + $this->output->writeln(count($students).'students remaining duplicate'); |
|
191 | 191 | array_walk($students, array($this, 'clone')); |
192 | 192 | $this->output->writeln('All are generated'); |
193 | 193 | break; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ->limit($limit) |
201 | 201 | ->get()->toArray(); |
202 | 202 | $students = (array) json_decode(json_encode($students)); |
203 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
203 | + $this->output->writeln(count($students).'students remaining empty'); |
|
204 | 204 | array_walk($students, array($this, 'clone')); |
205 | 205 | $this->output->writeln('All are generated'); |
206 | 206 | break; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ->where('year', $this->year) |
211 | 211 | ->get()->toArray(); |
212 | 212 | $students = (array) json_decode(json_encode($students)); |
213 | - $this->output->writeln(count($students) . 'students remaining with wrong NSID'); |
|
213 | + $this->output->writeln(count($students).'students remaining with wrong NSID'); |
|
214 | 214 | array_walk($students, array($this, 'clone')); |
215 | 215 | $this->output->writeln('All are generated'); |
216 | 216 | break; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | ->count(); |
222 | 222 | $all = Examination_student::select('nsid') |
223 | 223 | ->count(); |
224 | - $this->output->writeln($all . 'Total Unique nsid are: ' . $count); |
|
224 | + $this->output->writeln($all.'Total Unique nsid are: '.$count); |
|
225 | 225 | break; |
226 | 226 | default: |
227 | 227 | $students = Examination_student::offset($offset) |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ->limit($limit) |
231 | 231 | ->get()->toArray(); |
232 | 232 | $students = (array) json_decode(json_encode($students)); |
233 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
233 | + $this->output->writeln(count($students).'students remaining empty'); |
|
234 | 234 | array_walk($students, array($this, 'clone')); |
235 | 235 | $this->output->writeln('All are generated'); |
236 | 236 | } |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function clone($student) |
278 | 278 | { |
279 | - $student = (array)json_decode(json_encode($student)); |
|
279 | + $student = (array) json_decode(json_encode($student)); |
|
280 | 280 | //get student matching with same dob and gender |
281 | 281 | |
282 | 282 | $matchedStudent = $this->getMatchingStudents($student); |
283 | 283 | |
284 | 284 | // if the first match missing do complete insertion |
285 | - $institution = Institution::where('code', '=', (int)$student['schoolid'])->first(); |
|
285 | + $institution = Institution::where('code', '=', (int) $student['schoolid'])->first(); |
|
286 | 286 | |
287 | 287 | if (!is_null($institution)) { |
288 | 288 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | //TODO implement insert student to admission table |
311 | 311 | $student['id'] = $sis_student['id']; |
312 | - $sis_student['student_id'] = $student['id']; |
|
312 | + $sis_student['student_id'] = $student['id']; |
|
313 | 313 | |
314 | 314 | $student = $this->setIsTakingExam($student); |
315 | 315 | if (count($institutionClass) == 1) { |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | Institution_student::createExaminationData($student, $admissionInfo); |
318 | 318 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
319 | 319 | Institution_class_student::createExaminationData($student, $admissionInfo); |
320 | - } else { |
|
320 | + }else { |
|
321 | 321 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
322 | 322 | Institution_student::createExaminationData($student, $admissionInfo); |
323 | 323 | } |
324 | 324 | $this->updateStudentId($student, $sis_student); |
325 | 325 | // update the matched student's data |
326 | - } else { |
|
326 | + }else { |
|
327 | 327 | $student = $this->setIsTakingExam($student); |
328 | 328 | $studentData = $this->student->updateExaminationStudent($student, $matchedStudent); |
329 | 329 | $matchedStudent = array_merge((array) $student, $matchedStudent); |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | Institution_student::updateExaminationData($studentData, $admissionInfo); |
332 | 332 | $this->updateStudentId($student, $studentData); |
333 | 333 | } |
334 | - } else { |
|
334 | + }else { |
|
335 | 335 | |
336 | - $this->output->writeln('Student ' . $student['st_no'] . ' not imorted' . $student['f_name']); |
|
336 | + $this->output->writeln('Student '.$student['st_no'].' not imorted'.$student['f_name']); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
@@ -350,20 +350,20 @@ discard block |
||
350 | 350 | /** |
351 | 351 | */ |
352 | 352 | $sis_student = $this->student->getMatches($student); |
353 | - $doe_students = Examination_student::where('gender', $student['gender']) |
|
353 | + $doe_students = Examination_student::where('gender', $student['gender']) |
|
354 | 354 | ->where('b_date', $student['b_date']) |
355 | 355 | ->where('schoolid', $student['schoolid']) |
356 | - ->where('year',$this->year) |
|
357 | - ->where('grade',$this->grade) |
|
356 | + ->where('year', $this->year) |
|
357 | + ->where('grade', $this->grade) |
|
358 | 358 | ->count(); |
359 | 359 | $count = $this->student->getStudentCount($student); |
360 | 360 | |
361 | 361 | $studentData = []; |
362 | - $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
362 | + $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
363 | 363 | // if the same gender same DOE has more than one |
364 | 364 | if (($doe_students > 1) || ($count > 1)) { |
365 | 365 | $studentData = $this->searchSimilarName($student, $sis_users, false); |
366 | - } else { |
|
366 | + }else { |
|
367 | 367 | $studentData = $this->searchSimilarName($student, $sis_users); |
368 | 368 | } |
369 | 369 | return $studentData; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | } |
414 | 414 | |
415 | 415 | if (count($matches) > 1) { |
416 | - $highest = $this->searchSimilarName($student, $sis_students, false); |
|
416 | + $highest = $this->searchSimilarName($student, $sis_students, false); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | return $highest; |
@@ -429,18 +429,18 @@ discard block |
||
429 | 429 | public function updateStudentId($student, $sis_student) |
430 | 430 | { |
431 | 431 | try { |
432 | - $student['nsid'] = $sis_student['openemis_no']; |
|
432 | + $student['nsid'] = $sis_student['openemis_no']; |
|
433 | 433 | // add new NSID to the examinations data set |
434 | 434 | unset($student['id']); |
435 | 435 | unset($student['taking_g5_exam']); |
436 | 436 | unset($student['taking_al_exam']); |
437 | 437 | unset($student['taking_ol_exam']); |
438 | 438 | unset($student['total']); |
439 | - $students['updated_at'] = now(); |
|
439 | + $students['updated_at'] = now(); |
|
440 | 440 | $this->examination_student->where('st_no', $student['st_no'])->update($student); |
441 | 441 | unset($student['st_no']); |
442 | - $this->output->writeln('Updated to NSID' . $sis_student['openemis_no']); |
|
443 | - } catch (\Exception $th) { |
|
442 | + $this->output->writeln('Updated to NSID'.$sis_student['openemis_no']); |
|
443 | + }catch (\Exception $th) { |
|
444 | 444 | dd($th); |
445 | 445 | $this->output->writeln('error'); |
446 | 446 | Log::error($th); |
@@ -456,9 +456,9 @@ discard block |
||
456 | 456 | { |
457 | 457 | $adminUser = Security_user::where('username', 'admin')->first(); |
458 | 458 | try { |
459 | - (new ExaminationStudentsExport($this->year,$this->grade))->store('examination/student_data_with_nsid.' . time() . '.csv'); |
|
459 | + (new ExaminationStudentsExport($this->year, $this->grade))->store('examination/student_data_with_nsid.'.time().'.csv'); |
|
460 | 460 | (new ExportReady($adminUser)); |
461 | - } catch (\Throwable $th) { |
|
461 | + }catch (\Throwable $th) { |
|
462 | 462 | //throw $th; |
463 | 463 | dd($th); |
464 | 464 | } |
@@ -468,13 +468,13 @@ discard block |
||
468 | 468 | public function downloadErrors() |
469 | 469 | { |
470 | 470 | |
471 | - $file_path = storage_path() . '/app/examination/errors.csv'; |
|
471 | + $file_path = storage_path().'/app/examination/errors.csv'; |
|
472 | 472 | return Response::download($file_path); |
473 | 473 | } |
474 | 474 | |
475 | 475 | public function downloadProcessedFile() |
476 | 476 | { |
477 | - $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv'; |
|
477 | + $file_path = storage_path().'/app/examination/student_data_with_nsid.csv'; |
|
478 | 478 | return Response::download($file_path); |
479 | 479 | } |
480 | 480 | } |