@@ -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 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function uploadFile(Request $request) |
| 44 | 44 | { |
| 45 | 45 | ini_set('upload_max_filesize', '50M'); |
| 46 | - ini_set('post_max_size','50M'); |
|
| 46 | + ini_set('post_max_size', '50M'); |
|
| 47 | 47 | if ($request->input('submit') != null) { |
| 48 | 48 | |
| 49 | 49 | $file = $request->file('file'); |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | ); |
| 74 | 74 | Session::flash('message', 'File upload successfully!'); |
| 75 | 75 | // Redirect to index |
| 76 | - } else { |
|
| 76 | + }else { |
|
| 77 | 77 | Session::flash('message', 'File too large. File must be less than 20MB.'); |
| 78 | 78 | } |
| 79 | - } else { |
|
| 79 | + }else { |
|
| 80 | 80 | Session::flash('message', 'Invalid File Extension.'); |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $import->import($excelFile, 'local', \Maatwebsite\Excel\Excel::CSV); |
| 99 | 99 | if ($import->failures()->count() > 0) { |
| 100 | 100 | $errors = $import->failures(); |
| 101 | - $columns = [ |
|
| 101 | + $columns = [ |
|
| 102 | 102 | 'remarks', |
| 103 | 103 | 'st_no', |
| 104 | 104 | 'stu_no', |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | Storage::put($file, implode(',', $columns)); |
| 120 | 120 | |
| 121 | 121 | foreach ($errors as $error) { |
| 122 | - Storage::append($file, implode(':', $error->errors()) . ',' . implode(',', $error->values())); |
|
| 122 | + Storage::append($file, implode(':', $error->errors()).','.implode(',', $error->values())); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 125 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $Institution = $Institution[0]; |
| 146 | 146 | if (count($student) == 1) { |
| 147 | 147 | $student = $student[0]; |
| 148 | - if (((int)$Institution['id']) != ((int)$student['institution_id'])) { |
|
| 148 | + if (((int) $Institution['id']) != ((int) $student['institution_id'])) { |
|
| 149 | 149 | $studentClass = Institution_class_student::where('student_id', $student['student_id']) |
| 150 | 150 | ->first(); |
| 151 | 151 | Institution_class_student::where('student_id', $student['student_id'])->delete(); |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | if (!is_null($studentClass)) { |
| 156 | 156 | $class->updateClassCount($studentClass->toArray()); |
| 157 | 157 | } |
| 158 | - $output->writeln('updated student info:' . $data['nsid']); |
|
| 158 | + $output->writeln('updated student info:'.$data['nsid']); |
|
| 159 | 159 | } |
| 160 | - } else { |
|
| 160 | + }else { |
|
| 161 | 161 | Institution_student::where('institution_id', '<>', $Institution['id'])->where('student_id', $student[0]['student_id']) |
| 162 | 162 | ->delete(); |
| 163 | - $output->writeln('updated student info:' . $Institution['id'] . '==' . $Institution['id']); |
|
| 163 | + $output->writeln('updated student info:'.$Institution['id'].'=='.$Institution['id']); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $students = []; |
| 177 | 177 | switch ($mode) { |
| 178 | 178 | case 'duplicate': |
| 179 | - $students = DB::table('examination_students as es') |
|
| 179 | + $students = DB::table('examination_students as es') |
|
| 180 | 180 | ->select(DB::raw('count(*) as total'), 'e2.*') |
| 181 | 181 | ->where('grade', $this->grade) |
| 182 | 182 | ->where('year', $this->year) |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | ->limit($limit) |
| 189 | 189 | ->get()->toArray(); |
| 190 | 190 | $students = (array) json_decode(json_encode($students)); |
| 191 | - $this->output->writeln(count($students) . 'students remaining duplicate'); |
|
| 191 | + $this->output->writeln(count($students).'students remaining duplicate'); |
|
| 192 | 192 | array_walk($students, array($this, 'clone')); |
| 193 | 193 | $this->output->writeln('All are generated'); |
| 194 | 194 | break; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | ->limit($limit) |
| 202 | 202 | ->get()->toArray(); |
| 203 | 203 | $students = (array) json_decode(json_encode($students)); |
| 204 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
| 204 | + $this->output->writeln(count($students).'students remaining empty'); |
|
| 205 | 205 | array_walk($students, array($this, 'clone')); |
| 206 | 206 | $this->output->writeln('All are generated'); |
| 207 | 207 | break; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | ->where('year', $this->year) |
| 212 | 212 | ->get()->toArray(); |
| 213 | 213 | $students = (array) json_decode(json_encode($students)); |
| 214 | - $this->output->writeln(count($students) . 'students remaining with wrong NSID'); |
|
| 214 | + $this->output->writeln(count($students).'students remaining with wrong NSID'); |
|
| 215 | 215 | array_walk($students, array($this, 'clone')); |
| 216 | 216 | $this->output->writeln('All are generated'); |
| 217 | 217 | break; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | ->count(); |
| 223 | 223 | $all = Examination_student::select('nsid') |
| 224 | 224 | ->count(); |
| 225 | - $this->output->writeln($all . 'Total Unique nsid are: ' . $count); |
|
| 225 | + $this->output->writeln($all.'Total Unique nsid are: '.$count); |
|
| 226 | 226 | break; |
| 227 | 227 | default: |
| 228 | 228 | $students = Examination_student::offset($offset) |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | ->limit($limit) |
| 232 | 232 | ->get()->toArray(); |
| 233 | 233 | $students = (array) json_decode(json_encode($students)); |
| 234 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
| 234 | + $this->output->writeln(count($students).'students remaining empty'); |
|
| 235 | 235 | array_walk($students, array($this, 'clone')); |
| 236 | 236 | $this->output->writeln('All are generated'); |
| 237 | 237 | } |
@@ -277,13 +277,13 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function clone($student) |
| 279 | 279 | { |
| 280 | - $student = (array)json_decode(json_encode($student)); |
|
| 280 | + $student = (array) json_decode(json_encode($student)); |
|
| 281 | 281 | //get student matching with same dob and gender |
| 282 | 282 | |
| 283 | 283 | $matchedStudent = $this->getMatchingStudents($student); |
| 284 | 284 | |
| 285 | 285 | // if the first match missing do complete insertion |
| 286 | - $institution = Institution::where('code', '=', (int)$student['schoolid'])->first(); |
|
| 286 | + $institution = Institution::where('code', '=', (int) $student['schoolid'])->first(); |
|
| 287 | 287 | |
| 288 | 288 | if (!is_null($institution)) { |
| 289 | 289 | |
@@ -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 | } |