@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function handle() |
40 | 40 | { |
41 | - Institution_student_admission::where('status_id',121)->update([ |
|
41 | + Institution_student_admission::where('status_id', 121)->update([ |
|
42 | 42 | 'status_id' => 122 |
43 | 43 | ]); |
44 | 44 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function handle() |
41 | 41 | { |
42 | - Security_user::where('is_student',true) |
|
42 | + Security_user::where('is_student', true) |
|
43 | 43 | ->whereRaw('CHAR_LENGTH(first_name) <= 90') |
44 | 44 | ->update(['preferred_name' => DB::raw('first_name')]); |
45 | 45 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | public function handle() |
41 | 41 | { |
42 | 42 | Institution_student::where('updated_from', 'doe') |
43 | - ->where('education_grade_id','<>', 4) |
|
43 | + ->where('education_grade_id', '<>', 4) |
|
44 | 44 | ->update(['education_grade_id' => 4]); |
45 | 45 | } |
46 | 46 | } |
@@ -48,24 +48,24 @@ discard block |
||
48 | 48 | { |
49 | 49 | $type = $this->argument('type'); |
50 | 50 | $students = array(); |
51 | - if($type == 'invalid'){ |
|
51 | + if ($type == 'invalid') { |
|
52 | 52 | $students = DB::table('examination_students as es') |
53 | 53 | ->whereRaw('CHAR_LENGTH(nsid) > 11') |
54 | 54 | ->get() |
55 | 55 | ->toArray(); |
56 | - }elseif($type == 'duplicate'){ |
|
56 | + }elseif ($type == 'duplicate') { |
|
57 | 57 | $students = DB::table('security_users') |
58 | 58 | ->where('updated_from', 'doe') |
59 | 59 | ->get() |
60 | 60 | ->toArray(); |
61 | 61 | |
62 | - }elseif($type == 'all'){ |
|
62 | + }elseif ($type == 'all') { |
|
63 | 63 | $students = DB::table('examination_students') |
64 | - ->where('nsid','<>','') |
|
64 | + ->where('nsid', '<>', '') |
|
65 | 65 | ->whereNotNull('nsid') |
66 | 66 | ->get() |
67 | 67 | ->toArray(); |
68 | - }elseif($type == 'lock'){ |
|
68 | + }elseif ($type == 'lock') { |
|
69 | 69 | $students = DB::table('examination_students') |
70 | 70 | ->whereNotNull('nsid') |
71 | 71 | ->get() |
@@ -73,46 +73,46 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | $this->output->writeln('###########################################------Start cleanning exam records------###########################################'); |
76 | - if(count($students) > 0){ |
|
77 | - $this->output->writeln('Total students to clean: '. count($students)); |
|
76 | + if (count($students) > 0) { |
|
77 | + $this->output->writeln('Total students to clean: '.count($students)); |
|
78 | 78 | $students = array_chunk($students, $this->argument('chunk')); |
79 | 79 | $function = array($this, 'process'); |
80 | - processParallel($function,$students, $this->argument('max'),$type); |
|
81 | - }else{ |
|
80 | + processParallel($function, $students, $this->argument('max'), $type); |
|
81 | + }else { |
|
82 | 82 | $this->output->writeln('nothing to process, all are cleaned'); |
83 | 83 | } |
84 | 84 | $this->output->writeln('###########################################------Finished cleaning exam records------###########################################'); |
85 | 85 | } |
86 | 86 | |
87 | - public function process($students,$count,$type){ |
|
88 | - if($type === 'duplicate'){ |
|
89 | - array_walk($students,array($this,'cleanData')); |
|
90 | - }elseif($type === 'lock'){ |
|
91 | - array_walk($students,array($this,'lockData')); |
|
87 | + public function process($students, $count, $type) { |
|
88 | + if ($type === 'duplicate') { |
|
89 | + array_walk($students, array($this, 'cleanData')); |
|
90 | + }elseif ($type === 'lock') { |
|
91 | + array_walk($students, array($this, 'lockData')); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - public function lockData($Student){ |
|
96 | - $Student = json_decode(json_encode($Student),true); |
|
97 | - $student = Security_user::where('openemis_no',(string)$Student['nsid'])->first(); |
|
98 | - if(!empty($student)){ |
|
95 | + public function lockData($Student) { |
|
96 | + $Student = json_decode(json_encode($Student), true); |
|
97 | + $student = Security_user::where('openemis_no', (string) $Student['nsid'])->first(); |
|
98 | + if (!empty($student)) { |
|
99 | 99 | Institution_student::where('student_id', $student->id)->update(['updated_from' => 'doe']); |
100 | 100 | Security_user::where('id', $student->id)->update(['updated_from' => 'doe']); |
101 | - $this->output->writeln('Locked:'. (string)$Student['nsid'] .':' . $student['openemis_no']); |
|
101 | + $this->output->writeln('Locked:'.(string) $Student['nsid'].':'.$student['openemis_no']); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | |
106 | 106 | public function cleanData($Student) |
107 | 107 | { |
108 | - $exist = Examination_student::where('nsid','=', (string)$Student->openemis_no)->count(); |
|
108 | + $exist = Examination_student::where('nsid', '=', (string) $Student->openemis_no)->count(); |
|
109 | 109 | if (!$exist) { |
110 | 110 | Institution_student::where('student_id', $Student->id)->delete(); |
111 | 111 | Institution_class_student::where('student_id', $Student->id)->delete(); |
112 | 112 | Institution_student_admission::where('student_id', $Student->id)->delete(); |
113 | 113 | Security_user::where('id', $Student->id)->delete(); |
114 | - $this->output->writeln('cleaned:'. (string)$Student->openemis_no); |
|
115 | - }else{ |
|
114 | + $this->output->writeln('cleaned:'.(string) $Student->openemis_no); |
|
115 | + }else { |
|
116 | 116 | |
117 | 117 | Institution_student::where('student_id', $Student->id)->update(['updated_from' => 'doe']); |
118 | 118 | Security_user::where('id', $Student->id)->update(['updated_from' => 'doe']); |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | public function cleanInvalidData($Student) |
133 | 133 | { |
134 | 134 | $Student = (array) $Student; |
135 | - $exist = Examination_student::where('nsid',$Student['nsid'])->count(); |
|
135 | + $exist = Examination_student::where('nsid', $Student['nsid'])->count(); |
|
136 | 136 | |
137 | 137 | $this->uniqueUId = new UniqueUid(); |
138 | 138 | |
139 | - $nsid = ltrim(rtrim($Student['nsid'],'-'),'-'); |
|
140 | - if(!$this->uniqueUId::isValidUniqueId('DBY-898-3J2')){ |
|
139 | + $nsid = ltrim(rtrim($Student['nsid'], '-'), '-'); |
|
140 | + if (!$this->uniqueUId::isValidUniqueId('DBY-898-3J2')) { |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
@@ -43,29 +43,29 @@ |
||
43 | 43 | $this->start_time = microtime(TRUE); |
44 | 44 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
45 | 45 | $this->output->writeln('############### Starting delete Duplication ################'); |
46 | - $duplicatedStudents = Institution_student::select(DB::raw('count(*) as total'),'student_id','id','academic_period_id','education_grade_id') |
|
46 | + $duplicatedStudents = Institution_student::select(DB::raw('count(*) as total'), 'student_id', 'id', 'academic_period_id', 'education_grade_id') |
|
47 | 47 | ->groupBy('student_id') |
48 | - ->having('total','>',1) |
|
48 | + ->having('total', '>', 1) |
|
49 | 49 | ->orderBy('student_id') |
50 | 50 | ->get() |
51 | 51 | ->toArray(); |
52 | - if(count($duplicatedStudents)>0){ |
|
53 | - processParallel(array($this,'process'),$duplicatedStudents,10); |
|
54 | - }else{ |
|
52 | + if (count($duplicatedStudents) > 0) { |
|
53 | + processParallel(array($this, 'process'), $duplicatedStudents, 10); |
|
54 | + }else { |
|
55 | 55 | $this->output->writeln('Nothing to Process, all are clean'); |
56 | 56 | } |
57 | - } catch (\Throwable $th) { |
|
57 | + }catch (\Throwable $th) { |
|
58 | 58 | dd($th); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - public function process($Student){ |
|
63 | - Institution_student::where('institution_students.id','>',$Student['id']) |
|
64 | - ->where('institution_students.student_id',$Student['student_id']) |
|
65 | - ->where('institution_students.academic_period_id',$Student['academic_period_id']) |
|
66 | - ->where('institution_students.education_grade_id',$Student['education_grade_id']) |
|
62 | + public function process($Student) { |
|
63 | + Institution_student::where('institution_students.id', '>', $Student['id']) |
|
64 | + ->where('institution_students.student_id', $Student['student_id']) |
|
65 | + ->where('institution_students.academic_period_id', $Student['academic_period_id']) |
|
66 | + ->where('institution_students.education_grade_id', $Student['education_grade_id']) |
|
67 | 67 | ->delete(); |
68 | 68 | $this->end_time = microtime(TRUE); |
69 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
69 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
70 | 70 | } |
71 | 71 | } |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | $this->output->writeln('############### Starting delete Duplication ################'); |
46 | 46 | Student_guardian::withTrashed()->restore(); |
47 | 47 | $this->delete(); |
48 | - $this->end_time = microtime(TRUE); |
|
49 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
50 | - } catch (\Throwable $th) { |
|
48 | + $this->end_time = microtime(TRUE); |
|
49 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
50 | + }catch (\Throwable $th) { |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - public function delete(){ |
|
55 | - try{ |
|
54 | + public function delete() { |
|
55 | + try { |
|
56 | 56 | DB::statement("UPDATE student_guardians t1 |
57 | 57 | INNER JOIN student_guardians t2 |
58 | 58 | set t1.deleted_at=now() |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | t1.id > t2.id AND |
61 | 61 | t1.student_id = t2.student_id AND |
62 | 62 | t1.guardian_id = t2.guardian_id"); |
63 | - }catch(\Exception $e){ |
|
63 | + }catch (\Exception $e) { |
|
64 | 64 | dd($e); |
65 | 65 | } |
66 | 66 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct() |
32 | 32 | { |
33 | - $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
|
33 | + $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
|
34 | 34 | parent::__construct(); |
35 | 35 | } |
36 | 36 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function handle() |
43 | 43 | { |
44 | - $students = Security_user::where('is_student',true)->get()->toArray(); |
|
45 | - array_walk($students,array($this,'process')); |
|
44 | + $students = Security_user::where('is_student', true)->get()->toArray(); |
|
45 | + array_walk($students, array($this, 'process')); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function process($student){ |
|
48 | + public function process($student) { |
|
49 | 49 | $student['student_id'] = $student['id']; |
50 | 50 | Institution_student::updateStudentArea($student); |
51 | - $this->output->writeln('area updated for student:'. $student['openemis_no']) ; |
|
51 | + $this->output->writeln('area updated for student:'.$student['openemis_no']); |
|
52 | 52 | } |
53 | 53 | } |
@@ -48,16 +48,16 @@ |
||
48 | 48 | $year = $this->argument('year'); |
49 | 49 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
50 | 50 | $previousAcademicPeriodYear = $academicPeriod->order; |
51 | - $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
|
51 | + $previousAcademicPeriod = Academic_period::where('order', $previousAcademicPeriodYear + 1)->first(); |
|
52 | 52 | |
53 | 53 | $params = [ |
54 | 54 | 'academic_period' => $academicPeriod, |
55 | 55 | 'previous_academic_period' => $previousAcademicPeriod |
56 | 56 | ]; |
57 | 57 | |
58 | - if($year == '2019' || $year == '2018/19'){ |
|
58 | + if ($year == '2019' || $year == '2018/19') { |
|
59 | 59 | die('Academic Year 2019 or earlier can`t be deleted'); |
60 | - }else{ |
|
60 | + }else { |
|
61 | 61 | $this->clone->cleanConfig($params); |
62 | 62 | } |
63 | 63 | } |
@@ -48,21 +48,21 @@ |
||
48 | 48 | $mode = $this->argument('mode'); |
49 | 49 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
50 | 50 | $previousAcademicPeriodYear = $academicPeriod->order; |
51 | - $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
|
52 | - $institutions = $this->instituion_grade->getInstitutionGradeList($previousAcademicPeriod->code,$limit,$mode); |
|
51 | + $previousAcademicPeriod = Academic_period::where('order', $previousAcademicPeriodYear + 1)->first(); |
|
52 | + $institutions = $this->instituion_grade->getInstitutionGradeList($previousAcademicPeriod->code, $limit, $mode); |
|
53 | 53 | $params = [ |
54 | 54 | 'year' => $year, |
55 | 55 | 'mode'=> $mode |
56 | 56 | ]; |
57 | - if(in_array($mode,['AL','1-5','SP','6-11'])){ |
|
58 | - array_walk($institutions,array($this,'callPromotion'),$params); |
|
59 | - }else{ |
|
57 | + if (in_array($mode, ['AL', '1-5', 'SP', '6-11'])) { |
|
58 | + array_walk($institutions, array($this, 'callPromotion'), $params); |
|
59 | + }else { |
|
60 | 60 | die('The give mode not support'); |
61 | 61 | } |
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | - protected function callPromotion($institution,$count,$params){ |
|
66 | - $this->call('promote:students',['year' => $params['year'],'institution' => $institution['code'],'mode' => $params['mode'] ]); |
|
65 | + protected function callPromotion($institution, $count, $params) { |
|
66 | + $this->call('promote:students', ['year' => $params['year'], 'institution' => $institution['code'], 'mode' => $params['mode']]); |
|
67 | 67 | } |
68 | 68 | } |