Browse Source

Trabajando para presentar los resultados basados en los estudiantes

parent
commit
4dccfde8a8

+ 3
- 0
app/controllers/OutcomesController.php View File

921
     /**
921
     /**
922
      * School Assessment Reports
922
      * School Assessment Reports
923
      */
923
      */
924
+private function cmp($a, $b) {
925
+    return strcmp($a->name, $b->name);
926
+}
924
     public function schoolAssessmentReport()
927
     public function schoolAssessmentReport()
925
     {
928
     {
926
 
929
 

+ 256
- 0
app/controllers/SchoolsController.php View File

213
         }
213
         }
214
     }
214
     }
215
 
215
 
216
+	private function cmp($a, $b) 
217
+	{
218
+		return strcmp($a->name, $b->name);
219
+	}
220
+
221
+    public function studentSchoolAssessmentReport($school_id)
222
+    {
223
+		$id=$school_id;
224
+		ini_set('memory_limit', -1);
225
+		ini_set('max_execution_time', 300);
226
+	
227
+		$outcomes = Outcome::orderBy('name', 'asc')->get();
228
+		$school = School::find($school_id);
229
+		$title= $school->name;
230
+		$outcomeCount = Outcome::all()->count();
231
+		$programs=Program::where('school_id','=',$school_id)->get();
232
+		$programs_ids=array();
233
+// 				var_dump($programs);exit();
234
+		$programs_name=array();
235
+		foreach($programs as $program)
236
+		{
237
+// 			var_dump($program);
238
+			$programs_ids[]=$program->id;
239
+			$programs_name[$program->id]=$program->name;
240
+		}
241
+
242
+        $grouped_courses = Course::
243
+            //             select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
244
+            select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
245
+            ->with('semester')
246
+            ->with('program')
247
+            ->whereIn('courses.program_id', $programs_ids)
248
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
249
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
250
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
251
+            ->orderBy('courses.code')
252
+            ->orderBy('courses.number')
253
+            ->orderBy('courses.semester_id')
254
+            ->get();
255
+
256
+
257
+		$role=Auth::user()->role;
258
+
259
+		$users =array();
260
+
261
+
262
+		$resultados_todos_obj = DB::table('assessments')
263
+         						->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
264
+         						->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
265
+         						->join('courses', 'courses.id', '=', 'activities.course_id')
266
+         						->join('students', 'students.id', '=', 'assessments.student_id')
267
+         						->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
268
+         						->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
269
+         						->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
270
+         						->join('semesters', 'semesters.id', '=', 'courses.semester_id')
271
+          						->whereIn('students.program_id',$programs_ids)
272
+                   			   	->whereIn('semester_id', Session::get('semesters_ids'))
273
+                   			   	->where('semesters.is_visible','=',1)
274
+                    			->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'criterion_objective_outcome.criterion_id','score','expected_points')
275
+								->distinct()
276
+                    			->get();
277
+
278
+		foreach($resultados_todos_obj as $resultado)
279
+		{
280
+			if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']))
281
+			{
282
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']=array();
283
+			}
284
+			$resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters'][]=$resultado->code;
285
+			$resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']=array_unique($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']);
286
+			if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']))
287
+			{
288
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']=0;
289
+			}
290
+			$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']++;
291
+
292
+			if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']))
293
+			{
294
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']=0;
295
+			}
296
+			if($resultado->score>=$resultado->expected_points)
297
+			{
298
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']++;
299
+			}
300
+		}
301
+
302
+		$outcomes_colap=array();
303
+		$programs=array();
304
+// 			$outcomes_colap=array();
305
+		$i=0;
306
+		$outcomes_attempted=array();
307
+		$outcomes_attempted_colap=array();
308
+		$outcomes_achieved_colap=array();
309
+		$outcomes_attempted_semesters=array();
310
+		foreach($resultados_todos as $program_id => $resultados_prog)
311
+		{
312
+	     	$outcomes_attempted_semesters[$program_id]=array();
313
+			foreach($resultados_prog as $out=>$datos_out)
314
+			{
315
+				$outcomes_achieved[$program_id][$out] = 0;
316
+				$outcomes_attempted[$program_id][$out] = 0;
317
+// 				var_dump($datos_out);outcomes_attempted_semesters
318
+				$outcomes_attempted_semesters[$program_id][$out]=$datos_out['semesters'];
319
+				unset($datos_out['semesters']);
320
+// 				var_dump($outcomes_attempted_semesters[$program_id][$out]);
321
+// 				var_dump($datos_out);
322
+// 				exit();
323
+				foreach($datos_out as $res)
324
+				{
325
+					$outcomes_attempted[$program_id][$out]++;
326
+					if(3*$res['achieved']>=2*$res['attempted'])
327
+						$outcomes_achieved[$program_id][$out]++;
328
+				}		
329
+			}
330
+			$programs[]=Program::find($program_id);
331
+			if(Program::find($program_id)->is_graduate)
332
+			{
333
+				$colapso=array(1=>array(),3=>array(),2=>array(11),12=>array(7,14),10=>array(),4=>array(6,15));
334
+			}
335
+			else
336
+			{
337
+				$colapso=array(10=>array(),1=>array(),12=>array(7),3=>array(9,8,14),2=>array(11),5=>array(),4=>array(6,13),16=>array());
338
+			}	
339
+		
340
+			$resultados_todos_colap[$program_id]=array();
341
+			foreach($colapso as $out=>$pares)
342
+			{
343
+				$resultados_todos_colap[$program_id][$out]["semesters"]=array();
344
+				if(isset($resultados_todos[$program_id][$out]))
345
+					$resultados_todos_colap[$program_id][$out]=$resultados_todos[$program_id][$out];
346
+					else $resultados_todos_colap[$program_id][$out]=array();
347
+				foreach($pares as $par)
348
+				{
349
+					if(isset($resultados_todos[$program_id][$par]))
350
+					{	
351
+// 						unset($resultados_todos[$program_id][$par]['semesters']);
352
+						
353
+						foreach($resultados_todos[$program_id][$par] as $estu => $resus)
354
+						{
355
+							if($estu!="semesters")
356
+							{
357
+								if(!isset($resultados_todos_colap[$program_id][$out][$estu]))
358
+								{
359
+									$resultados_todos_colap[$program_id][$out][$estu]['attempted']=0;
360
+									$resultados_todos_colap[$program_id][$out][$estu]['achieved']=0;
361
+
362
+								}
363
+	// 							print $program_id." ".$par." ".$estu."<br>";
364
+	// 							var_dump($resultados_todos[$program_id][$par][$estu]); 
365
+								$resultados_todos_colap[$program_id][$out][$estu]['attempted']+=$resultados_todos[$program_id][$par][$estu]['attempted'];
366
+								$resultados_todos_colap[$program_id][$out][$estu]['achieved']+=$resultados_todos[$program_id][$par][$estu]['achieved'];
367
+							}
368
+							else if(isset($resultados_todos[$program_id][$par]["semesters"]))
369
+							{
370
+								if(isset($resultados_todos_colap[$program_id][$out]["semesters"]))
371
+								{
372
+									$tmp=array_merge($resultados_todos_colap[$program_id][$out]["semesters"],$resultados_todos[$program_id][$par]["semesters"]);
373
+// 									var_dump(($tmp));
374
+// 									var_dump(array_unique($tmp));
375
+// 									exit();
376
+
377
+									$resultados_todos_colap[$program_id][$out]["semesters"]=array_unique($tmp);
378
+								}
379
+								else 
380
+									$resultados_todos_colap[$program_id][$out]["semesters"]=array_unique($resultados_todos[$program_id][$par]["semesters"]);
381
+							}
382
+						}
383
+					}
384
+				}
385
+		
386
+			}
387
+// 			var_dump($resultados_todos_colap);
388
+			
389
+			$outcomes_attempted_colap[$program_id]=array();
390
+			$outcomes_achieved_colap[$program_id]=array();
391
+			$outcomes_attempted_colap_semesters[$program_id]=array();
392
+// 			print $program_id."<br>";
393
+// 				var_dump($resultados_todos_colap[$program_id]);
394
+// 			print "<br>";
395
+			foreach($resultados_todos_colap[$program_id] as $out=>$datos_out)
396
+			{
397
+				if(!$i)$outcomes_colap[]=Outcome::find($out);
398
+// 				$outcomes_attempted_colap_semesters[$program_id][$out]=array();
399
+				if(isset($datos_out['semesters']))
400
+				{
401
+					$outcomes_attempted_colap_semesters[$program_id][$out]=$datos_out['semesters'];
402
+					unset($datos_out['semesters']);
403
+				}
404
+				foreach($datos_out as $res)
405
+				{
406
+					if(!isset($outcomes_attempted_colap[$program_id][$out]))
407
+					{
408
+						$outcomes_attempted_colap[$program_id][$out]=0;
409
+						$outcomes_achieved_colap[$program_id][$out]=0;
410
+					
411
+					}
412
+					$outcomes_attempted_colap[$program_id][$out]++;
413
+					if(3*$res['achieved']>=2*$res['attempted'])
414
+						$outcomes_achieved_colap[$program_id][$out]++;
415
+				}
416
+				if(empty($datos_out))
417
+				{
418
+					$outcomes_attempted_colap[$program_id][$out]=0;
419
+					$outcomes_achieved_colap[$program_id][$out]=0;
420
+				}
421
+
422
+			}
423
+			$i++;
424
+		}		
425
+		usort($outcomes_colap, array($this, "cmp"));
426
+	// 		var_dump($outcomes_attempted_colap); print "<br>";
427
+	// 		var_dump($outcomes_achieved_colap); print "<br>";
428
+	// 	exit();
429
+		$outcomes_attempted_colap_todo=array();
430
+		$outcomes_achieved_colap_todo=array();
431
+		foreach($outcomes_attempted_colap as $program_id => $out_res)
432
+		{
433
+			foreach($out_res as $out=>$res)
434
+			{
435
+				if(!isset($outcomes_attempted_colap_todo[$out]))
436
+				{
437
+					$outcomes_attempted_colap_todo[$out]=0;
438
+					$outcomes_achieved_colap_todo[$out]=0;
439
+			
440
+				}
441
+				$outcomes_attempted_colap_todo[$out]+=$outcomes_attempted_colap[$program_id][$out];
442
+				$outcomes_achieved_colap_todo[$out]+=$outcomes_achieved_colap[$program_id][$out];
443
+		
444
+		
445
+			}
446
+	
447
+		}
448
+		$outcomes_attempted_todo=array();
449
+		$outcomes_achieved_todo=array();
450
+		foreach($outcomes_attempted as $program_id => $out_res)
451
+		{
452
+			foreach($out_res as $out=>$res)
453
+			{
454
+				if(!isset($outcomes_attempted_todo[$out]))
455
+				{
456
+					$outcomes_attempted_todo[$out]=0;
457
+					$outcomes_achieved_todo[$out]=0;
458
+			
459
+				}
460
+				$outcomes_attempted_todo[$out]+=$outcomes_attempted[$program_id][$out];
461
+				$outcomes_achieved_todo[$out]+=$outcomes_achieved[$program_id][$out];
462
+		
463
+		
464
+			}
465
+	
466
+		}
467
+	
468
+
469
+	    return View::make('local.managers.shared.school_student_result', compact('title','outcomes_attempted_colap_semesters','outcomes_attempted_semesters','outcomes_attempted_colap_todo','outcomes_achieved_colap_todo','outcomes_attempted_todo','outcomes_achieved_todo','school','programs_name','role','outcomes','outcomes_colap', 'outcomes_attempted', 'outcomes_achieved', 'outcomes_attempted_colap', 'outcomes_achieved_colap', 'programs', 'users','program_courses','grouped_courses'));
470
+    }
471
+
216
     public function showQuasiOri($id)
472
     public function showQuasiOri($id)
217
     {
473
     {
218
         ini_set('memory_limit', '256M');
474
         ini_set('memory_limit', '256M');

+ 1
- 0
app/routes.php View File

381
         // Assessment reports
381
         // Assessment reports
382
 
382
 
383
         Route::get('school-assessment-report', 'OutcomesController@schoolAssessmentReport');
383
         Route::get('school-assessment-report', 'OutcomesController@schoolAssessmentReport');
384
+        Route::get('student_school_assessment-report/{school_id}', 'SchoolsController@studentSchoolAssessmentReport');
384
 
385
 
385
         // Gabriel added this, so the school coordinator can add criterias and objectives
386
         // Gabriel added this, so the school coordinator can add criterias and objectives
386
         Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
387
         Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));

+ 1
- 0
app/views/local/managers/shared/school.blade.php View File

9
 @stop
9
 @stop
10
 
10
 
11
 @section('main')
11
 @section('main')
12
+<a href="{{ action('SchoolsController@studentSchoolAssessmentReport', array($school->id)); }}" class="btn btn-primary pull-left" alt="print">Go to Performance by School Students</a>
12
 <a href="{{ action('SchoolsController@print_school', array($school->id)); }}" class="btn btn-primary pull-right" alt="print"><span class="glyphicon glyphicon-print"></span></a>
13
 <a href="{{ action('SchoolsController@print_school', array($school->id)); }}" class="btn btn-primary pull-right" alt="print"><span class="glyphicon glyphicon-print"></span></a>
13
 <br>
14
 <br>
14
 <br>
15
 <br>