Test Setup Failed
Pull Request — master (#461)
by Mohamed
07:38
created
app/Console/Commands/ExaminationCheck.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,17 +42,17 @@
 block discarded – undo
42 42
     {
43 43
         $this->start_time = microtime(TRUE);
44 44
         $count = DB::table('examination_students')->select('nsid')->distinct()->count();
45
-        $studentsIdsWithDuplication =   DB::table('examination_students as es')
46
-        ->select(DB::raw('count(*) as total'),'es.*')
45
+        $studentsIdsWithDuplication = DB::table('examination_students as es')
46
+        ->select(DB::raw('count(*) as total'), 'es.*')
47 47
         ->whereNotNull('es.nsid')
48 48
         ->whereRaw('es.nsid != ""')
49
-        ->having('total','>',1)
49
+        ->having('total', '>', 1)
50 50
         ->groupBy('es.nsid')
51 51
         ->orderBy('es.nsid')
52
-        ->chunk($this->argument('limit'),function($Students){
52
+        ->chunk($this->argument('limit'), function($Students) {
53 53
             foreach ($Students as $Student) {
54
-                $count = Examination_student::where('nsid',$Student->nsid)->update(['nsid'=>'']);
55
-                $this->output->writeln($Student->nsid .'same ID' . $count . ' records removed');
54
+                $count = Examination_student::where('nsid', $Student->nsid)->update(['nsid'=>'']);
55
+                $this->output->writeln($Student->nsid.'same ID'.$count.' records removed');
56 56
             }
57 57
         }); 
58 58
     }
Please login to merge, or discard this patch.
app/Console/Commands/ExaminationStudentMigrate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
             $output->writeln('###########################################------starting export------###########################################');
48 48
             $this->examinationController->export();
49 49
             $output->writeln('###########################################------Finished inserting file records------###########################################');
50
-        } else {
50
+        }else {
51 51
             $this->examinationController->doMatch($this->argument('offset'), $this->argument('limit'), $this->argument(('mode')));
52 52
             $this->examinationController->export();
53 53
         }
Please login to merge, or discard this patch.
app/Http/Controllers/ExaminationStudentsController.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,18 +145,18 @@  discard block
 block discarded – undo
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;
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
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
                 break;
172 172
             default:
173 173
                 $students = Examination_student::offset($offset)
174 174
                     ->limit($limit)
175 175
                     ->get()->toArray();
176 176
                 $students = (array) json_decode(json_encode($students));
177
-                $this->output->writeln(count($students) . 'students remaining empty');
177
+                $this->output->writeln(count($students).'students remaining empty');
178 178
                 array_walk($students, array($this, 'clone'));
179 179
                 $this->output->writeln('All are generated');
180 180
         }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function clone($student)
222 222
     {
223
-        $student = (array)json_decode(json_encode($student));
223
+        $student = (array) json_decode(json_encode($student));
224 224
         //get student matching with same dob and gender
225 225
 
226 226
         $matchedStudent = $this->getMatchingStudents($student);
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 
254 254
                 //TODO implement insert student to admission table
255 255
                 $student['id'] = $sis_student['id'];
256
-                $sis_student['student_id'] =  $student['id'];
256
+                $sis_student['student_id'] = $student['id'];
257 257
 
258 258
                 $student = $this->setIsTakingExam($student);
259 259
                 if (count($institutionClass) == 1) {
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
                     Institution_student::createExaminationData($student, $admissionInfo);
262 262
                     Institution_student_admission::createExaminationData($student, $admissionInfo);
263 263
                     Institution_class_student::createExaminationData($student, $admissionInfo);
264
-                } else {
264
+                }else {
265 265
                     Institution_student_admission::createExaminationData($student, $admissionInfo);
266 266
                     Institution_student::createExaminationData($student, $admissionInfo);
267 267
                 }
268 268
                 $this->updateStudentId($student, $sis_student);
269 269
                 // update the matched student's data    
270
-            } else {
270
+            }else {
271 271
                 $student = $this->setIsTakingExam($student);
272 272
                 $studentData = $this->student->updateExaminationStudent($student, $matchedStudent);
273 273
                 $matchedStudent = array_merge((array) $student, $matchedStudent);
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
                 Institution_student::updateExaminationData($studentData, $admissionInfo);
276 276
                 $this->updateStudentId($student, $studentData);
277 277
             }
278
-        } else {
278
+        }else {
279 279
 
280
-            $this->output->writeln('Student ' . $student['st_no'] . ' not imorted' . $student['f_name']);
280
+            $this->output->writeln('Student '.$student['st_no'].' not imorted'.$student['f_name']);
281 281
         }
282 282
     }
283 283
 
@@ -295,11 +295,11 @@  discard block
 block discarded – undo
295 295
         $count = $this->student->getStudentCount($student);
296 296
 
297 297
         $studentData = [];
298
-        $sis_users  = (array) json_decode(json_encode($sis_student), true);
298
+        $sis_users = (array) json_decode(json_encode($sis_student), true);
299 299
         // if the same gender same DOE has more than one 
300
-        if($count > 1){
301
-            $studentData = $this->searchSimilarName($student, $sis_users,false);
302
-        }else{
300
+        if ($count > 1) {
301
+            $studentData = $this->searchSimilarName($student, $sis_users, false);
302
+        }else {
303 303
             $studentData = $this->searchSimilarName($student, $sis_users);
304 304
         }   
305 305
         return $studentData;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      * @param array $sis_students
313 313
      * @return array
314 314
      */
315
-    public function searchSimilarName($student, $sis_students,$surname_search = true)
315
+    public function searchSimilarName($student, $sis_students, $surname_search = true)
316 316
     {
317 317
         $highest = [];
318 318
         $minDistance = 0;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
             }
333 333
         }
334 334
 
335
-        if($surname_search){
335
+        if ($surname_search) {
336 336
             if (empty($highest)) {
337 337
                 foreach ($sis_students as $key => $value) {
338 338
                     //search name with last name
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
     public function updateStudentId($student, $sis_student)
362 362
     {
363 363
         try {
364
-            $student['nsid'] =  $sis_student['openemis_no'];
364
+            $student['nsid'] = $sis_student['openemis_no'];
365 365
             // add new NSID to the examinations data set
366 366
             unset($student['id']);
367 367
             unset($student['taking_g5_exam']);
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
             unset($student['total']);
371 371
             $this->examination_student->where('st_no', $student['st_no'])->update($student);
372 372
             unset($student['st_no']);
373
-            $this->output->writeln('Updated  to NSID' . $sis_student['openemis_no']);
374
-        } catch (\Exception $th) {
373
+            $this->output->writeln('Updated  to NSID'.$sis_student['openemis_no']);
374
+        }catch (\Exception $th) {
375 375
             dd($th);
376 376
             $this->output->writeln('error');
377 377
             Log::error($th);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         try {
390 390
             (new ExaminationStudentsExport)->store('examination/student_data_with_nsid.'.time().'.csv');
391 391
             (new ExportReady($adminUser));
392
-        } catch (\Throwable $th) {
392
+        }catch (\Throwable $th) {
393 393
             //throw $th;
394 394
             dd($th);
395 395
         }
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
     public function downloadErrors()
400 400
     {
401 401
 
402
-        $file_path = storage_path() . '/app/examination/errors.csv';
402
+        $file_path = storage_path().'/app/examination/errors.csv';
403 403
         return Response::download($file_path);
404 404
     }
405 405
 
406 406
     public function downloadProcessedFile()
407 407
     {
408
-        $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv';
408
+        $file_path = storage_path().'/app/examination/student_data_with_nsid.csv';
409 409
         return Response::download($file_path);
410 410
     }
411 411
 }
Please login to merge, or discard this patch.