Browse Source

Cambios a los seeders, auth necesite el passwd, Admins les sirvan las rúbricas, y dominios diferenciados para graduados y subgraduados en typ

parent
commit
21c7698ad0

+ 1
- 0
.gitignore View File

@@ -10,6 +10,7 @@ app/database/csv/*
10 10
 app/config/packages/*
11 11
 app/config/testing/*
12 12
 app/config/database.php
13
+app/config/app.php
13 14
 app/config/*
14 15
 
15 16
 

+ 6
- 3
app/config/app.php View File

@@ -15,7 +15,7 @@ return array(
15 15
 
16 16
 	//'debug' => $_ENV['APP_DEBUG'] ?: false,
17 17
 
18
-	'debug' => true,
18
+	'debug' => false,
19 19
 	/*
20 20
 	|--------------------------------------------------------------------------
21 21
 	| Application URL
@@ -80,9 +80,12 @@ return array(
80 80
 	*/
81 81
 
82 82
 	// 'key' => 'YourSecretKey!!!',
83
-	'key' => 'JozBz0yQBrZ5kEcPvgxch3RR3E3INSGs',
83
+// 	'key' => 'JozBz0yQBrZ5kEcPvgxch3RR3E3INSGs',
84
+// 
85
+// 	'cipher' => MCRYPT_RIJNDAEL_256,
86
+	'key' => '+H!WZJxd5qwb!EHYR8^MLsX@^X6Y?e@+',
84 87
 
85
-	'cipher' => MCRYPT_RIJNDAEL_256,
88
+	'cipher' => MCRYPT_RIJNDAEL_128,
86 89
 
87 90
 	/*
88 91
 	|--------------------------------------------------------------------------

+ 7
- 1
app/controllers/AdministratorsController.php View File

@@ -322,7 +322,8 @@ class AdministratorsController extends \BaseController
322 322
 		$outcomes = DB::table('overview')
323 323
 			->rightJoin('outcomes', 'outcomes.id', '=', 'overview.outcome_id')
324 324
 			->whereIn('outcomes.level',$levels)
325
-			->selectRaw('outcomes.name, coalesce(outcomes.new_outcome_id,outcomes.id) as id, sum(overview.total_evaluated) as total_evaluated, sum(overview.total_achieved) as total_achieved')
325
+// 			->selectRaw('outcomes.name, coalesce(outcomes.new_outcome_id,outcomes.id) as id, sum(overview.total_evaluated) as total_evaluated, sum(overview.total_achieved) as total_achieved')
326
+			->selectRaw('coalesce(outcomes.new_outcome_id,outcomes.id) as id, sum(overview.total_evaluated) as total_evaluated, sum(overview.total_achieved) as total_achieved')
326 327
 			->orderBy('outcomes.name', 'asc')
327 328
 			->groupBy(DB::raw('coalesce(outcomes.new_outcome_id,outcomes.id)'))
328 329
 			->get();
@@ -347,7 +348,12 @@ class AdministratorsController extends \BaseController
347 348
 				->orderBy('semesters.code', 'asc')
348 349
 				->groupBy('overview.semester_id')
349 350
 				->get();
351
+			$outcome->name=DB::table('outcomes')->select('name')->where('id',$outcome->id)->pluck('name');
350 352
 		}
353
+		usort($outcomes, function ($item1, $item2) {
354
+    if ($item1->name == $item2->name) return 0;
355
+    return $item1->name < $item2->name ? -1 : 1;
356
+});
351 357
 // var_dump($outcomes);
352 358
 // 		exit();
353 359
 // dd(DB::getQueryLog());

+ 3
- 3
app/controllers/AuthController.php View File

@@ -28,9 +28,9 @@ class AuthController extends \BaseController
28 28
 
29 29
 		if (!$validator->fails()) {
30 30
 			//			TODO: Remove this for production environment
31
-			if (App::environment('local', 'staging')) {
32
-				return $this->processLogin();
33
-			}
31
+// 			if (App::environment('local', 'staging')) {
32
+// 				return $this->processLogin();
33
+// 			}
34 34
 			try {
35 35
 				// User input
36 36
 				$username = str_replace('@upr.edu', '', Input::get('email'));

+ 10
- 1
app/controllers/ThreeYearPlanController.php View File

@@ -55,6 +55,8 @@ class ThreeYearPlanController extends \BaseController
55 55
     }
56 56
 
57 57
     $program = Program::find($program_id);
58
+        Log::info($program);
59
+
58 60
     // el ID de los semestres que el usuario tiene seleccionado.
59 61
     $semesters_ids = Session::get('semesters_ids');
60 62
     // buscar informacion de los semestres seleccionados
@@ -70,7 +72,14 @@ class ThreeYearPlanController extends \BaseController
70 72
       ->select('program_id')
71 73
       ->get();
72 74
     $program_id = $program_id[0]->program_id;*/
73
-    $outcomes = DB::table('outcomes')->where('deactivation_date', '=', null)->orderBy('name', 'ASC')->get();
75
+    if($program->is_graduate==0)
76
+    {
77
+	    $outcomes = DB::table('outcomes')->where('deactivation_date', '=', null)->orderBy('name', 'ASC')->get();
78
+    }
79
+    else
80
+    {
81
+	    $outcomes = DB::table('outcomes')->where('deactivation_date', '=', null)->where('level', '=', 3)->orderBy('name', 'ASC')->get();    
82
+    }
74 83
     // se annadio la nueva variable
75 84
     return View::make('global.view-three-year-plan', compact('title', 'last_year', 'outcomes', 'typs', 'criteria', 'semesters', 'program_id'));
76 85
   }

+ 14
- 11
app/database/seeds/CourseTableSeeder.php View File

@@ -13,7 +13,7 @@ class CourseTableSeeder extends Seeder {
13 13
         $time_start = microtime(true);
14 14
 
15 15
         // Open file
16
-        if($file = fopen('app/database/csv/cursos.csv', 'r'))
16
+        if($file = fopen('app/database/csv/PSR010223_C12.txt', 'r'))
17 17
         {
18 18
             // Initialize count variables
19 19
             $read = 0;
@@ -22,7 +22,7 @@ class CourseTableSeeder extends Seeder {
22 22
             $error = 0;
23 23
 
24 24
             // Read each row
25
-            while($data = fgetcsv($file, 5000)) // se cambio delimitador para evitar problemas con nombres separados del apellido por coma
25
+            while($data = fgetcsv($file, 0,"|")) // se cambio delimitador para evitar problemas con nombres separados del apellido por coma
26 26
             {
27 27
                 // Add read count
28 28
                 $read++;
@@ -31,17 +31,18 @@ class CourseTableSeeder extends Seeder {
31 31
                 try
32 32
                 {
33 33
                     // Get row info
34
-                    $name = $data[8];
35
-                    $code = trim(substr($data[1], 0, 4));
36
-                    $number = trim(substr($data[1], 4, 4));
37
-                    $section = trim(substr($data[1], 8, 3));
38
-                    $user_id = User::select('id')->where('ssn', trim($data[11]))->first();
39
-                    $semester_id = Semester::select('id')->where('code', strtoupper(trim($data[3])))->first();
40
-                    $program_code = trim($data[9]);
41
-                    $modality = trim($data[5]);
34
+                    $name = trim($data[14]);
35
+                    $code = trim(substr($data[0], 0, 4));
36
+                    $number = trim(substr($data[0], 4, 4));
37
+                    $section = trim(substr($data[0], 8, 3));
38
+                    $user_id = User::select('id')->where('ssn', trim($data[24]))->first();
39
+                    $semester_id = Semester::select('id')->where('code', strtoupper(trim($data[2])))->first();
40
+                    $program_code = trim($data[15]);
41
+                    $faculty_code = trim($data[13]);
42
+                    $modality = trim($data[6]);
42 43
 
43 44
                     // If any row is empty, raise an exception
44
-                    if($name=='' || $code=='' || $number=='' || $section=='' || trim($data[14])=='' || trim($data[2])=='')
45
+                    if($name=='' || $code=='' || $number=='' || $section=='' || $semester_id=='' || $user_id=='')
45 46
                     {
46 47
                         throw new Exception('NON-FATAL ERROR(line '.$read.'): Missing information, read \''.implode(",", $data).'\'');
47 48
                     }
@@ -67,12 +68,14 @@ class CourseTableSeeder extends Seeder {
67 68
                     elseif(Program::select('id')->where('code', $program_code)->first())
68 69
                     {
69 70
                         $program_id = Program::select('id')->where('code', $program_code)->first()->id;
71
+                        $this->command->info("curso sin programa ".$code.$number." de facultad ".$faculty_code);
70 72
                     }
71 73
 
72 74
                     // Fetch user. If it doesn't exist, set default user
73 75
                     if(!$user_id && !$user_id['id'])
74 76
                     {
75 77
                         $user_id = 60; // Id for default user. Check DB for user with ssn 000000000.
78
+                        $this->command->info("curso sin profesor en sistema ".$code.$number." de facultad ".$faculty_code);
76 79
                     }
77 80
                     else
78 81
                     {

+ 156
- 19
app/database/seeds/StudentTableSeeder.php View File

@@ -5,7 +5,8 @@ class StudentTableSeeder extends Seeder {
5 5
     public function run()
6 6
     {
7 7
         // Set term
8
-        $term = "B91";
8
+        $term = "C12";
9
+		$semester_id = Semester::select('id')->where('code', $term)->first();
9 10
 
10 11
         // Disable query logging to avoid memory exhaustion
11 12
         DB::disableQueryLog();
@@ -14,10 +15,12 @@ class StudentTableSeeder extends Seeder {
14 15
 
15 16
         // Initiates time
16 17
         $time_start = microtime(true);
17
-
18
+/*
19
+		//Primero entra la informacion basica eg. numero_estu, nombre, email
18 20
         // Open file
19
-        $file_path = 'http://136.145.180.72/tools/proceso_files/';
20
-        $file_name = 'webmatri_vivienda_b83-b91.dat';
21
+        $file_path = 'app/database/csv/';
22
+//         $file_name = 'ARCEXTRT-20-C12-20220411-164329.TXT';
23
+        $file_name = 'ARCEXT-20-C12-20220411-164329.TXT';
21 24
 
22 25
         if($file = fopen($file_path.$file_name, 'r'))
23 26
         {
@@ -29,13 +32,13 @@ class StudentTableSeeder extends Seeder {
29 32
             $warning = 0;
30 33
 
31 34
             // Read each row
32
-            while($data = fgetcsv($file, 5000, ";"))
35
+            while($data = fgetcsv($file, 0, ";"))
33 36
             {
34 37
                 // Skip iterations from previous semesters
35
-                if(trim($data[8]) != $term)
36
-                {
37
-                    continue;
38
-                }
38
+//                 if(trim($data[8]) != $term)
39
+//                 {
40
+//                     continue;
41
+//                 }
39 42
 
40 43
                 // Add read count
41 44
                 $read++;
@@ -43,11 +46,11 @@ class StudentTableSeeder extends Seeder {
43 46
                 try
44 47
                 {
45 48
                     // Get row info
46
-                    $number = str_pad(trim($data[1]), 9, '000000000', STR_PAD_LEFT);
47
-                    $name = trim(ucwords(strtoupper($data[2])));
48
-                    $email = trim($data[15]).'@upr.edu';
49
-                    $school_code = trim($data[5]);
50
-                    $conc_code = trim($data[7]);
49
+                    $number = str_pad(trim($data[2]), 9, '000000000', STR_PAD_LEFT);
50
+                    $name = trim(ucwords(strtoupper($data[4])));
51
+                    $email = trim($data[5]).'@upr.edu';
52
+//                     $school_code = trim($data[5]);
53
+                    $gender = trim($data[7]);
51 54
 
52 55
                     // If any row is empty, raise an exception
53 56
                     if(!$number || !$name)
@@ -78,12 +81,13 @@ class StudentTableSeeder extends Seeder {
78 81
                                 array(
79 82
                                     'name' => $name,
80 83
                                     'email' => $email,
81
-                                    'school_code' => $school_code,
82
-                                    'conc_code' => $conc_code,
84
+                                    'gender' => $gender,
85
+//                                     'school_code' => $school_code,
86
+//                                     'conc_code' => $conc_code,
83 87
                                     'updated_at' => date("Y-m-d H:i:s"),
84 88
                                 )
85 89
                             );
86
-                        $this->command->info($read.' - Updated '.$number.': '.$name.' ['.$school_code.' '.$conc_code.']');
90
+                        $this->command->info($read.' - Updated '.$number.': '.$name.' ['.$gender.']');
87 91
                         $updated++;
88 92
 
89 93
                     }
@@ -95,8 +99,9 @@ class StudentTableSeeder extends Seeder {
95 99
                             'number' => $number,
96 100
                             'name' => $name,
97 101
                             'email' => $email,
98
-                            'school_code' => $school_code,
99
-                            'conc_code' => $conc_code,
102
+							'gender' => $gender,
103
+//                             'school_code' => $school_code,
104
+//                             'conc_code' => $conc_code,
100 105
                             'created_at' => date("Y-m-d H:i:s"),
101 106
                             'updated_at' => date("Y-m-d H:i:s")
102 107
                             )
@@ -137,6 +142,138 @@ class StudentTableSeeder extends Seeder {
137 142
         {
138 143
             $this->command->info('File '.$file_name.' could not be opened. Make sure it is located in the app/database/csv directory of this project.');
139 144
         }
145
+*/    
146
+		//  Segundo entra la informacion de programa, grado, nivel, anho y anhade en program_student_semester
147
+         $file_path = 'app/database/csv/';
148
+        $file_name = 'ARCEXTRT-20-C12-20220411-164329.TXT';
149
+//         $file_name = 'ARCEXT-20-C12-20220411-164329.TXT';
150
+
151
+        if($file = fopen($file_path.$file_name, 'r'))
152
+        {
153
+            // Initialize count variables
154
+            $read = 0;
155
+            $added =0;
156
+            $updated = 0;
157
+            $error = 0;
158
+            $warning = 0;
159
+
160
+            // Read each row
161
+            while($data = fgetcsv($file, 0, ";"))
162
+            {
163
+                // Skip iterations from previous semesters
164
+//                 if(trim($data[8]) != $term)
165
+//                 {
166
+//                     continue;
167
+//                 }
168
+// 
169
+                // Add read count
170
+                $read++;
171
+
172
+                try
173
+                {
174
+                    // Get row info
175
+                    $number = str_pad(trim($data[3]), 9, '000000000', STR_PAD_LEFT);
176
+//                     $name = trim(ucwords(strtoupper($data[4])));
177
+//                     $email = trim($data[5]).'@upr.edu';
178
+                    $school_code = trim($data[19]);
179
+                    $conc_code = trim($data[21]);
180
+                    $level = trim($data[16]);
181
+                    $degree = trim($data[23]);
182
+                    $year = trim($data[25]);
183
+//                     $school_code = trim($data[5]);
184
+//                     $conc_code = trim($data[7]);
185
+
186
+                    // If any row is empty, raise an exception
187
+                    if(!$number)
188
+                    {
189
+                        throw new Exception('NON-FATAL ERROR(line '.$read.'): Missing name or student number, read \''.implode(",", $data).'\'');
190
+                    }
191
+
192
+                    $program=DB::table('programs')
193
+                            ->where('code', $conc_code)
194
+                            ->where('degree', $degree)
195
+                            ->select('id')
196
+                            ->first();
197
+//                             var_dump($program_id);
198
+					if(!$program)$program->id=null;
199
+                    // Check if student exists
200
+                    $student = Student::where('number', $number)->count();
201
+
202
+                    // If s/he does, update information and add to updated
203
+                    if($student)
204
+                    {
205
+						$student_id = Student::select('id')->where('number', $number)->first();
206
+//                     print $read."\n";
207
+						
208
+                        DB::table('students')
209
+                            ->where('number', $number)
210
+                            ->update(
211
+                                array(
212
+//                                     'name' => $name,
213
+//                                     'email' => $email,
214
+                                    'school_code' => $school_code,
215
+                                    'conc_code' => $conc_code,
216
+                                    'program_id' => $program->id,
217
+                                    'degree' => $degree,
218
+                                    'level' => $level,
219
+                                    'year' => $year,
220
+                                    'updated_at' => date("Y-m-d H:i:s"),
221
+                                )
222
+                            );
223
+                        $this->command->info($read.' - Updated '.$number.': '.$program->id.' ['.$school_code.' '.$conc_code.']');
224
+                        $updated++;
225
+                        
226
+                        DB::table('program_student_semester')->insert(
227
+							array('student_id' => $student_id->id,
228
+								  'program_id' => $program->id,
229
+								  'semester_id' => $semester_id->id
230
+								  )
231
+						);
232
+
233
+                    }
234
+
235
+                    // Otherwise, add student and add to added
236
+                    else
237
+                    {
238
+                        $this->command->info($read.' - Student not in system'.$number.': '.$name);
239
+                        $warning++;
240
+                    }
241
+
242
+                }
243
+
244
+                // If an exception is raised, show the message and add to error
245
+                catch(Exception $e)
246
+                {
247
+                    $this->command->info($e->getMessage());
248
+                    $error++;
249
+                };
250
+            }
251
+
252
+            // Stop time
253
+            $time_end = microtime(true);
254
+
255
+            // Display results
256
+            $this->command->info('------------------------------------------------------------');
257
+            $this->command->info('Results on '.date('M d, Y, h:i:s a'));
258
+            $this->command->info('- Runtime: '.(round($time_end - $time_start, 3)).' seconds');
259
+            $this->command->info('- Read: '.$read);
260
+            $this->command->info('- Updated (active): '.$updated);
261
+            $this->command->info('- Added (new active, all): '.$added);
262
+            $this->command->info('- Added (new active, without email): '.$warning);
263
+            $this->command->info('- Not updated (inactive): '.(Student::count() - $updated - $added));
264
+            $this->command->info('- Not added/updated (errors or missing information): '.($error));
265
+
266
+            // Close file
267
+            fclose($file);
268
+        }
269
+        // File cannot be opened, display error and exit
270
+        else
271
+        {
272
+            $this->command->info('File '.$file_name.' could not be opened. Make sure it is located in the app/database/csv directory of this project.');
273
+        }
274
+    
275
+   
276
+    
140 277
     }
141 278
 
142 279
 }