@@ -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 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | ); |
72 | 72 | Session::flash('message', 'File upload successfully!'); |
73 | 73 | // Redirect to index |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | Session::flash('message', 'File too large. File must be less than 20MB.'); |
76 | 76 | } |
77 | - } else { |
|
77 | + }else { |
|
78 | 78 | Session::flash('message', 'Invalid File Extension.'); |
79 | 79 | } |
80 | 80 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $import->import($excelFile, 'local', \Maatwebsite\Excel\Excel::CSV); |
97 | 97 | if ($import->failures()->count() > 0) { |
98 | 98 | $errors = $import->failures(); |
99 | - $columns = [ |
|
99 | + $columns = [ |
|
100 | 100 | 'remarks', |
101 | 101 | 'st_no', |
102 | 102 | 'stu_no', |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | Storage::put($file, implode(',', $columns)); |
118 | 118 | |
119 | 119 | foreach ($errors as $error) { |
120 | - Storage::append($file, implode(':', $error->errors()) . ',' . implode(',', $error->values())); |
|
120 | + Storage::append($file, implode(':', $error->errors()).','.implode(',', $error->values())); |
|
121 | 121 | } |
122 | 122 | } |
123 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
123 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $Institution = $Institution[0]; |
144 | 144 | if (count($student) == 1) { |
145 | 145 | $student = $student[0]; |
146 | - if (((int)$Institution['id']) != ((int)$student['institution_id'])) { |
|
146 | + if (((int) $Institution['id']) != ((int) $student['institution_id'])) { |
|
147 | 147 | $studentClass = Institution_class_student::where('student_id', $student['student_id']) |
148 | 148 | ->first(); |
149 | 149 | Institution_class_student::where('student_id', $student['student_id'])->delete(); |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | if (!is_null($studentClass)) { |
154 | 154 | $class->updateClassCount($studentClass->toArray()); |
155 | 155 | } |
156 | - $output->writeln('updated student info:' . $data['nsid']); |
|
156 | + $output->writeln('updated student info:'.$data['nsid']); |
|
157 | 157 | } |
158 | - } else { |
|
158 | + }else { |
|
159 | 159 | Institution_student::where('institution_id', '<>', $Institution['id'])->where('student_id', $student[0]['student_id']) |
160 | 160 | ->delete(); |
161 | - $output->writeln('updated student info:' . $Institution['id'] . '==' . $Institution['id']); |
|
161 | + $output->writeln('updated student info:'.$Institution['id'].'=='.$Institution['id']); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $students = []; |
175 | 175 | switch ($mode) { |
176 | 176 | case 'duplicate': |
177 | - $students = DB::table('examination_students as es') |
|
177 | + $students = DB::table('examination_students as es') |
|
178 | 178 | ->select(DB::raw('count(*) as total'), 'e2.*') |
179 | 179 | ->where('grade', $this->grade) |
180 | 180 | ->where('year', $this->year) |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | ->limit($limit) |
187 | 187 | ->get()->toArray(); |
188 | 188 | $students = (array) json_decode(json_encode($students)); |
189 | - $this->output->writeln(count($students) . 'students remaining duplicate'); |
|
189 | + $this->output->writeln(count($students).'students remaining duplicate'); |
|
190 | 190 | array_walk($students, array($this, 'clone')); |
191 | 191 | $this->output->writeln('All are generated'); |
192 | 192 | break; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ->limit($limit) |
200 | 200 | ->get()->toArray(); |
201 | 201 | $students = (array) json_decode(json_encode($students)); |
202 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
202 | + $this->output->writeln(count($students).'students remaining empty'); |
|
203 | 203 | array_walk($students, array($this, 'clone')); |
204 | 204 | $this->output->writeln('All are generated'); |
205 | 205 | break; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | ->where('year', $this->year) |
210 | 210 | ->get()->toArray(); |
211 | 211 | $students = (array) json_decode(json_encode($students)); |
212 | - $this->output->writeln(count($students) . 'students remaining with wrong NSID'); |
|
212 | + $this->output->writeln(count($students).'students remaining with wrong NSID'); |
|
213 | 213 | array_walk($students, array($this, 'clone')); |
214 | 214 | $this->output->writeln('All are generated'); |
215 | 215 | break; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ->count(); |
221 | 221 | $all = Examination_student::select('nsid') |
222 | 222 | ->count(); |
223 | - $this->output->writeln($all . 'Total Unique nsid are: ' . $count); |
|
223 | + $this->output->writeln($all.'Total Unique nsid are: '.$count); |
|
224 | 224 | break; |
225 | 225 | default: |
226 | 226 | $students = Examination_student::offset($offset) |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | ->limit($limit) |
230 | 230 | ->get()->toArray(); |
231 | 231 | $students = (array) json_decode(json_encode($students)); |
232 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
232 | + $this->output->writeln(count($students).'students remaining empty'); |
|
233 | 233 | array_walk($students, array($this, 'clone')); |
234 | 234 | $this->output->writeln('All are generated'); |
235 | 235 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function clone($student) |
277 | 277 | { |
278 | - $student = (array)json_decode(json_encode($student)); |
|
278 | + $student = (array) json_decode(json_encode($student)); |
|
279 | 279 | //get student matching with same dob and gender |
280 | 280 | |
281 | 281 | $matchedStudent = $this->getMatchingStudents($student); |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | //TODO implement insert student to admission table |
312 | 312 | $student['id'] = $sis_student['id']; |
313 | - $sis_student['student_id'] = $student['id']; |
|
313 | + $sis_student['student_id'] = $student['id']; |
|
314 | 314 | |
315 | 315 | $student = $this->setIsTakingExam($student); |
316 | 316 | if (count($institutionClass) == 1) { |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | Institution_student::createExaminationData($student, $admissionInfo); |
319 | 319 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
320 | 320 | Institution_class_student::createExaminationData($student, $admissionInfo); |
321 | - } else { |
|
321 | + }else { |
|
322 | 322 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
323 | 323 | Institution_student::createExaminationData($student, $admissionInfo); |
324 | 324 | } |
325 | 325 | $this->updateStudentId($student, $sis_student); |
326 | 326 | // update the matched student's data |
327 | - } else { |
|
327 | + }else { |
|
328 | 328 | $student = $this->setIsTakingExam($student); |
329 | 329 | $studentData = $this->student->updateExaminationStudent($student, $matchedStudent); |
330 | 330 | $matchedStudent = array_merge((array) $student, $matchedStudent); |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | Institution_student::updateExaminationData($studentData, $admissionInfo); |
333 | 333 | $this->updateStudentId($student, $studentData); |
334 | 334 | } |
335 | - } else { |
|
335 | + }else { |
|
336 | 336 | |
337 | - $this->output->writeln('Student ' . $student['st_no'] . ' not imorted' . $student['f_name']); |
|
337 | + $this->output->writeln('Student '.$student['st_no'].' not imorted'.$student['f_name']); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
@@ -351,20 +351,20 @@ discard block |
||
351 | 351 | /** |
352 | 352 | */ |
353 | 353 | $sis_student = $this->student->getMatches($student); |
354 | - $doe_students = Examination_student::where('gender', $student['gender']) |
|
354 | + $doe_students = Examination_student::where('gender', $student['gender']) |
|
355 | 355 | ->where('b_date', $student['b_date']) |
356 | 356 | ->where('schoolid', $student['schoolid']) |
357 | - ->where('year',$this->year) |
|
358 | - ->where('grade',$this->grade) |
|
357 | + ->where('year', $this->year) |
|
358 | + ->where('grade', $this->grade) |
|
359 | 359 | ->count(); |
360 | 360 | $count = $this->student->getStudentCount($student); |
361 | 361 | |
362 | 362 | $studentData = []; |
363 | - $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
363 | + $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
364 | 364 | // if the same gender same DOE has more than one |
365 | 365 | if (($doe_students > 1) || ($count > 1)) { |
366 | 366 | $studentData = $this->searchSimilarName($student, $sis_users, false); |
367 | - } else { |
|
367 | + }else { |
|
368 | 368 | $studentData = $this->searchSimilarName($student, $sis_users); |
369 | 369 | } |
370 | 370 | return $studentData; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | if (count($matches) > 1) { |
417 | - $highest = $this->searchSimilarName($student, $sis_students, false); |
|
417 | + $highest = $this->searchSimilarName($student, $sis_students, false); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | return $highest; |
@@ -430,18 +430,18 @@ discard block |
||
430 | 430 | public function updateStudentId($student, $sis_student) |
431 | 431 | { |
432 | 432 | try { |
433 | - $student['nsid'] = $sis_student['openemis_no']; |
|
433 | + $student['nsid'] = $sis_student['openemis_no']; |
|
434 | 434 | // add new NSID to the examinations data set |
435 | 435 | unset($student['id']); |
436 | 436 | unset($student['taking_g5_exam']); |
437 | 437 | unset($student['taking_al_exam']); |
438 | 438 | unset($student['taking_ol_exam']); |
439 | 439 | unset($student['total']); |
440 | - $students['updated_at'] = now(); |
|
440 | + $students['updated_at'] = now(); |
|
441 | 441 | $this->examination_student->where('st_no', $student['st_no'])->update($student); |
442 | 442 | unset($student['st_no']); |
443 | - $this->output->writeln('Updated to NSID' . $sis_student['openemis_no']); |
|
444 | - } catch (\Exception $th) { |
|
443 | + $this->output->writeln('Updated to NSID'.$sis_student['openemis_no']); |
|
444 | + }catch (\Exception $th) { |
|
445 | 445 | dd($th); |
446 | 446 | $this->output->writeln('error'); |
447 | 447 | Log::error($th); |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | { |
458 | 458 | $adminUser = Security_user::where('username', 'admin')->first(); |
459 | 459 | try { |
460 | - (new ExaminationStudentsExport($this->year,$this->grade))->store('examination/student_data_with_nsid.' . time() . '.csv'); |
|
460 | + (new ExaminationStudentsExport($this->year, $this->grade))->store('examination/student_data_with_nsid.'.time().'.csv'); |
|
461 | 461 | (new ExportReady($adminUser)); |
462 | - } catch (\Throwable $th) { |
|
462 | + }catch (\Throwable $th) { |
|
463 | 463 | //throw $th; |
464 | 464 | dd($th); |
465 | 465 | } |
@@ -469,13 +469,13 @@ discard block |
||
469 | 469 | public function downloadErrors() |
470 | 470 | { |
471 | 471 | |
472 | - $file_path = storage_path() . '/app/examination/errors.csv'; |
|
472 | + $file_path = storage_path().'/app/examination/errors.csv'; |
|
473 | 473 | return Response::download($file_path); |
474 | 474 | } |
475 | 475 | |
476 | 476 | public function downloadProcessedFile() |
477 | 477 | { |
478 | - $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv'; |
|
478 | + $file_path = storage_path().'/app/examination/student_data_with_nsid.csv'; |
|
479 | 479 | return Response::download($file_path); |
480 | 480 | } |
481 | 481 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public static function boot() |
59 | 59 | { |
60 | 60 | parent::boot(); |
61 | - self::creating(function ($model) { |
|
61 | + self::creating(function($model) { |
|
62 | 62 | $model->id = (string) Uuid::generate(4); |
63 | 63 | $model->created = now(); |
64 | 64 | }); |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | |
72 | 72 | public static function getStudentsCount($institution_class_id) |
73 | 73 | { |
74 | - $total_male_students = self::with(['student' => function ($query) { |
|
74 | + $total_male_students = self::with(['student' => function($query) { |
|
75 | 75 | $query->where('student.gender_id', '=', 1); |
76 | - }])->whereHas('student', function ($query) { |
|
76 | + }])->whereHas('student', function($query) { |
|
77 | 77 | $query->where('gender_id', '=', 1); |
78 | 78 | })->where('institution_class_id', '=', $institution_class_id)->count(); |
79 | 79 | |
80 | - $total_female_students = self::with(['student' => function ($query) { |
|
80 | + $total_female_students = self::with(['student' => function($query) { |
|
81 | 81 | $query->where('student.gender_id', '=', 2); |
82 | - }])->whereHas('student', function ($query) { |
|
82 | + }])->whereHas('student', function($query) { |
|
83 | 83 | $query->where('gender_id', '=', 2); |
84 | 84 | })->where('institution_class_id', '=', $institution_class_id)->count(); |
85 | 85 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | ->where('student_id', $student['student_id']) |
110 | 110 | ->join('institution_classes', 'institution_class_students.institution_class_id', '=', 'institution_classes.id') |
111 | 111 | ->where('institution_class_students.student_id', $student['student_id']) |
112 | - ->where('institution_class_students.academic_period_id',$student['academic_period_id']) |
|
113 | - ->where('institution_class_students.institution_id',$student['institution_id']) |
|
112 | + ->where('institution_class_students.academic_period_id', $student['academic_period_id']) |
|
113 | + ->where('institution_class_students.institution_id', $student['institution_id']) |
|
114 | 114 | ->whereNull('institution_class_students.deleted_at') |
115 | 115 | ->get()->first(); |
116 | 116 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | 'student_status_id' => 1, |
136 | 136 | 'created_user_id' => 1 |
137 | 137 | ]); |
138 | - } catch (\Throwable $th) { |
|
138 | + }catch (\Throwable $th) { |
|
139 | 139 | Log::error($th); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - public static function createOrUpdate($studentId,$params,$file){ |
|
143 | + public static function createOrUpdate($studentId, $params, $file) { |
|
144 | 144 | return self::create([ |
145 | 145 | 'student_id' => $studentId, |
146 | 146 | 'institution_class_id' => $params['institution_class']->id, |