@@ -28,7 +28,7 @@ discard block  | 
                                                    ||
| 28 | 28 | $this->grade = $grade;  | 
                                                        
| 29 | 29 | $this->student = new Security_user();  | 
                                                        
| 30 | 30 | $this->examination_student = new Examination_student();  | 
                                                        
| 31 | -        $this->academic_period =  Academic_period::where('code', '=', $this->year)->first(); | 
                                                        |
| 31 | +        $this->academic_period = Academic_period::where('code', '=', $this->year)->first(); | 
                                                        |
| 32 | 32 |          $this->education_grade = Education_grade::where('code', '=', $this->grade)->first(); | 
                                                        
| 33 | 33 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput();  | 
                                                        
| 34 | 34 | }  | 
                                                        
@@ -70,10 +70,10 @@ discard block  | 
                                                    ||
| 70 | 70 | );  | 
                                                        
| 71 | 71 |                      Session::flash('message', 'File upload successfully!'); | 
                                                        
| 72 | 72 | // Redirect to index  | 
                                                        
| 73 | -                } else { | 
                                                        |
| 73 | +                }else { | 
                                                        |
| 74 | 74 |                      Session::flash('message', 'File too large. File must be less than 20MB.'); | 
                                                        
| 75 | 75 | }  | 
                                                        
| 76 | -            } else { | 
                                                        |
| 76 | +            }else { | 
                                                        |
| 77 | 77 |                  Session::flash('message', 'Invalid File Extension.'); | 
                                                        
| 78 | 78 | }  | 
                                                        
| 79 | 79 | }  | 
                                                        
@@ -95,7 +95,7 @@ discard block  | 
                                                    ||
| 95 | 95 | $import->import($excelFile, 'local', \Maatwebsite\Excel\Excel::CSV);  | 
                                                        
| 96 | 96 |              if ($import->failures()->count() > 0) { | 
                                                        
| 97 | 97 | $errors = $import->failures();  | 
                                                        
| 98 | - $columns = [  | 
                                                        |
| 98 | + $columns = [  | 
                                                        |
| 99 | 99 | 'remarks',  | 
                                                        
| 100 | 100 | 'st_no',  | 
                                                        
| 101 | 101 | 'stu_no',  | 
                                                        
@@ -116,10 +116,10 @@ discard block  | 
                                                    ||
| 116 | 116 |                  Storage::put($file, implode(',', $columns)); | 
                                                        
| 117 | 117 | |
| 118 | 118 |                  foreach ($errors as $error) { | 
                                                        
| 119 | -                    Storage::append($file, implode(':', $error->errors()) . ',' . implode(',', $error->values())); | 
                                                        |
| 119 | +                    Storage::append($file, implode(':', $error->errors()).','.implode(',', $error->values())); | 
                                                        |
| 120 | 120 | }  | 
                                                        
| 121 | 121 | }  | 
                                                        
| 122 | -        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { | 
                                                        |
| 122 | +        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { | 
                                                        |
| 123 | 123 | }  | 
                                                        
| 124 | 124 | }  | 
                                                        
| 125 | 125 | |
@@ -207,7 +207,7 @@ discard block  | 
                                                    ||
| 207 | 207 | |
| 208 | 208 | //TODO implement insert student to admission table  | 
                                                        
| 209 | 209 | $student['id'] = $sis_student['id'];  | 
                                                        
| 210 | - $sis_student['student_id'] = $student['id'];  | 
                                                        |
| 210 | + $sis_student['student_id'] = $student['id'];  | 
                                                        |
| 211 | 211 | |
| 212 | 212 | $student = $this->setIsTakingExam($student);  | 
                                                        
| 213 | 213 |                  if (count($institutionClass) == 1) { | 
                                                        
@@ -215,13 +215,13 @@ discard block  | 
                                                    ||
| 215 | 215 | Institution_student::createExaminationData($student, $admissionInfo);  | 
                                                        
| 216 | 216 | Institution_student_admission::createExaminationData($student, $admissionInfo);  | 
                                                        
| 217 | 217 | Institution_class_student::createExaminationData($student, $admissionInfo);  | 
                                                        
| 218 | -                } else { | 
                                                        |
| 218 | +                }else { | 
                                                        |
| 219 | 219 | Institution_student_admission::createExaminationData($student, $admissionInfo);  | 
                                                        
| 220 | 220 | Institution_student::createExaminationData($student, $admissionInfo);  | 
                                                        
| 221 | 221 | }  | 
                                                        
| 222 | 222 | $this->updateStudentId($student, $sis_student);  | 
                                                        
| 223 | 223 | // update the matched student's data  | 
                                                        
| 224 | -            } else { | 
                                                        |
| 224 | +            }else { | 
                                                        |
| 225 | 225 | $studentData = $this->student->updateExaminationStudent($student, $matchedStudent);  | 
                                                        
| 226 | 226 | $matchedStudent = array_merge((array) $student, $matchedStudent);  | 
                                                        
| 227 | 227 | $studentData = array_merge((array) $matchedStudent, $studentData);  | 
                                                        
@@ -247,7 +247,7 @@ discard block  | 
                                                    ||
| 247 | 247 | // if the same gender same DOE has more than one  | 
                                                        
| 248 | 248 |          if (!is_null($sis_users) && (count($sis_users) > 1)) { | 
                                                        
| 249 | 249 | $studentData = $this->searchSimilarName($student, $sis_users);  | 
                                                        
| 250 | -        }else if (!is_null($sis_users) && (count($sis_users) == 1)){ | 
                                                        |
| 250 | +        }else if (!is_null($sis_users) && (count($sis_users) == 1)) { | 
                                                        |
| 251 | 251 | $studentData = $sis_users[0];  | 
                                                        
| 252 | 252 | }  | 
                                                        
| 253 | 253 | return $studentData;  | 
                                                        
@@ -308,12 +308,12 @@ discard block  | 
                                                    ||
| 308 | 308 | public function updateStudentId($student, $sis_student)  | 
                                                        
| 309 | 309 |      { | 
                                                        
| 310 | 310 |          try { | 
                                                        
| 311 | - $student['nsid'] = $sis_student['openemis_no'];  | 
                                                        |
| 311 | + $student['nsid'] = $sis_student['openemis_no'];  | 
                                                        |
| 312 | 312 | // add new NSID to the examinations data set  | 
                                                        
| 313 | 313 | unset($student['id']);  | 
                                                        
| 314 | -            $this->examination_student->where('st_no' , $student['st_no'])->update($student); | 
                                                        |
| 315 | -            $this->output->writeln('Updated ' . $sis_student['student_id'] . ' to NSID' . $sis_student['openemis_no']); | 
                                                        |
| 316 | -        } catch (\Exception $th) { | 
                                                        |
| 314 | +            $this->examination_student->where('st_no', $student['st_no'])->update($student); | 
                                                        |
| 315 | +            $this->output->writeln('Updated '.$sis_student['student_id'].' to NSID'.$sis_student['openemis_no']); | 
                                                        |
| 316 | +        }catch (\Exception $th) { | 
                                                        |
| 317 | 317 | Log::error($th);  | 
                                                        
| 318 | 318 | }  | 
                                                        
| 319 | 319 | }  | 
                                                        
@@ -329,7 +329,7 @@ discard block  | 
                                                    ||
| 329 | 329 |          try { | 
                                                        
| 330 | 330 |              (new ExaminationStudentsExport)->store('examination/student_data_with_nsid.csv'); | 
                                                        
| 331 | 331 | (new ExportReady($adminUser));  | 
                                                        
| 332 | -        } catch (\Throwable $th) { | 
                                                        |
| 332 | +        }catch (\Throwable $th) { | 
                                                        |
| 333 | 333 | //throw $th;  | 
                                                        
| 334 | 334 | dd($th);  | 
                                                        
| 335 | 335 | }  | 
                                                        
@@ -339,13 +339,13 @@ discard block  | 
                                                    ||
| 339 | 339 | public function downloadErrors()  | 
                                                        
| 340 | 340 |      { | 
                                                        
| 341 | 341 | |
| 342 | - $file_path = storage_path() . '/app/examination/errors.csv';  | 
                                                        |
| 342 | + $file_path = storage_path().'/app/examination/errors.csv';  | 
                                                        |
| 343 | 343 | return Response::download($file_path);  | 
                                                        
| 344 | 344 | }  | 
                                                        
| 345 | 345 | |
| 346 | 346 | public function downloadProcessedFile()  | 
                                                        
| 347 | 347 |      { | 
                                                        
| 348 | - $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv';  | 
                                                        |
| 348 | + $file_path = storage_path().'/app/examination/student_data_with_nsid.csv';  | 
                                                        |
| 349 | 349 | return Response::download($file_path);  | 
                                                        
| 350 | 350 | }  | 
                                                        
| 351 | 351 | }  | 
                                                        
@@ -247,7 +247,7 @@  | 
                                                    ||
| 247 | 247 | // if the same gender same DOE has more than one  | 
                                                        
| 248 | 248 |          if (!is_null($sis_users) && (count($sis_users) > 1)) { | 
                                                        
| 249 | 249 | $studentData = $this->searchSimilarName($student, $sis_users);  | 
                                                        
| 250 | -        }else if (!is_null($sis_users) && (count($sis_users) == 1)){ | 
                                                        |
| 250 | +        } else if (!is_null($sis_users) && (count($sis_users) == 1)){ | 
                                                        |
| 251 | 251 | $studentData = $sis_users[0];  | 
                                                        
| 252 | 252 | }  | 
                                                        
| 253 | 253 | return $studentData;  | 
                                                        
@@ -181,7 +181,7 @@ discard block  | 
                                                    ||
| 181 | 181 | $studentData['id'] = $id;  | 
                                                        
| 182 | 182 | $this->uniqueUserId->updateOrInsertRecord($studentData);  | 
                                                        
| 183 | 183 | return $studentData;  | 
                                                        
| 184 | -        } catch (\Exception $th) { | 
                                                        |
| 184 | +        }catch (\Exception $th) { | 
                                                        |
| 185 | 185 | Log::error($th->getMessage());  | 
                                                        
| 186 | 186 | // in case of duplication of the Unique ID this will recursive.  | 
                                                        
| 187 | 187 | $this->insertExaminationStudent($student);  | 
                                                        
@@ -201,7 +201,7 @@ discard block  | 
                                                    ||
| 201 | 201 | $this->uniqueUserId = new Unique_user_id();  | 
                                                        
| 202 | 202 | $this->uniqueUId = new UniqueUid();  | 
                                                        
| 203 | 203 | // regenerate unique id if it's not available  | 
                                                        
| 204 | - $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'],9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric();  | 
                                                        |
| 204 | + $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric();  | 
                                                        |
| 205 | 205 | |
| 206 | 206 | $studentData = [  | 
                                                        
| 207 | 207 |              'username' => str_replace('-', '', $uniqueId), | 
                                                        
@@ -215,11 +215,11 @@ discard block  | 
                                                    ||
| 215 | 215 | ];  | 
                                                        
| 216 | 216 | |
| 217 | 217 |          try { | 
                                                        
| 218 | - self::where( 'id' , $sis_student['student_id'])->update($studentData);  | 
                                                        |
| 218 | +            self::where('id', $sis_student['student_id'])->update($studentData); | 
                                                        |
| 219 | 219 | $studentData['id'] = $sis_student['student_id'];  | 
                                                        
| 220 | 220 | $this->uniqueUserId->updateOrInsertRecord($studentData);  | 
                                                        
| 221 | 221 | return $studentData;  | 
                                                        
| 222 | -        } catch (\Exception $th) { | 
                                                        |
| 222 | +        }catch (\Exception $th) { | 
                                                        |
| 223 | 223 | Log::error($th);  | 
                                                        
| 224 | 224 | // in case of duplication of the Unique ID this will recursive.  | 
                                                        
| 225 | 225 | $this->updateExaminationStudent($student, $sis_student);  |