ソースを参照

assessment po estudiantes de escuela y programa

コミット
4926d1bdf7

+ 296
- 0
app/controllers/ProgramsController.php ファイルの表示

@@ -245,6 +245,302 @@ class ProgramsController extends \BaseController
245 245
     return View::make('local.managers.shared.program_report', compact('title', 'programs_info', 'selected_divulgaciones', 'selected_semesters', 'tables_names'));
246 246
   }
247 247
 
248
+	private function cmp($a, $b) 
249
+	{
250
+		return strcmp($a->name, $b->name);
251
+	}
252
+
253
+    public function studentProgramAssessmentReport($program_id)
254
+    {
255
+		$id=$program_id;
256
+		ini_set('memory_limit', -1);
257
+		ini_set('max_execution_time', 300);
258
+
259
+
260
+		$program = Program::find($program_id);
261
+		$title= $program->school->name.': '.$program->name;
262
+		$outcomes = Outcome::orderBy('name', 'asc')->get();
263
+		$schools = School::all();
264
+		$outcomeCount = Outcome::all()->count();
265
+		
266
+		$role=Auth::user()->role;
267
+
268
+		$programs_ids=array($program->id);
269
+
270
+	   $users = User::
271
+        select('users.*')
272
+        ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
273
+        ->where(function($query) use($program)
274
+        {
275
+            $query
276
+                ->where('school_id', $program->school_id)
277
+                ->where('role', 2);
278
+        })
279
+        ->orWhere(function($query) use($program)
280
+        {
281
+            $query
282
+                ->where('role', 3)
283
+                ->where('program_id', $program->id);
284
+        })
285
+        ->orWhere(function($query) use($program)
286
+        {
287
+            $query
288
+                ->where('role', 4)
289
+                ->where('program_id', $program->id);
290
+        })
291
+        ->get();
292
+	
293
+// 		$outcomes = Outcome::orderBy('name', 'asc')->get();
294
+// 		$school = School::find($school_id);
295
+// 		$title= $school->name;
296
+// 		$outcomeCount = Outcome::all()->count();
297
+// 		$programs=Program::where('school_id','=',$school_id)->get();
298
+// 		$programs_ids=array();
299
+// // 				var_dump($programs);exit();
300
+// 		$programs_name=array();
301
+// 		foreach($programs as $program)
302
+// 		{
303
+// // 			var_dump($program);
304
+// 			$programs_ids[]=$program->id;
305
+// 			$programs_name[$program->id]=$program->name;
306
+// 		}
307
+
308
+        $grouped_courses = Course::
309
+            //             select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
310
+            select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
311
+            ->with('semester')
312
+            ->with('program')
313
+            ->whereIn('courses.program_id', $programs_ids)
314
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
315
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
316
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
317
+            ->orderBy('courses.code')
318
+            ->orderBy('courses.number')
319
+            ->orderBy('courses.semester_id')
320
+            ->get();
321
+
322
+
323
+		$role=Auth::user()->role;
324
+
325
+		$users =array();
326
+
327
+
328
+		$resultados_todos_obj = DB::table('assessments')
329
+         						->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
330
+         						->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
331
+         						->join('courses', 'courses.id', '=', 'activities.course_id')
332
+         						->join('students', 'students.id', '=', 'assessments.student_id')
333
+         						->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
334
+         						->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
335
+         						->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
336
+         						->join('semesters', 'semesters.id', '=', 'courses.semester_id')
337
+          						->whereIn('students.program_id',$programs_ids)
338
+                   			   	->whereIn('semester_id', Session::get('semesters_ids'))
339
+                   			   	->where('semesters.is_visible','=',1)
340
+                    			->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'criterion_objective_outcome.criterion_id','score','expected_points')
341
+								->distinct()
342
+                    			->get();
343
+
344
+		foreach($resultados_todos_obj as $resultado)
345
+		{
346
+			if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']))
347
+			{
348
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']=array();
349
+			}
350
+			$resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters'][]=$resultado->code;
351
+			$resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']=array_unique($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']);
352
+			if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']))
353
+			{
354
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']=0;
355
+			}
356
+			$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']++;
357
+
358
+			if(!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']))
359
+			{
360
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']=0;
361
+			}
362
+			if($resultado->score>=$resultado->expected_points)
363
+			{
364
+				$resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']++;
365
+			}
366
+		}
367
+
368
+		$outcomes_colap=array();
369
+		$programs=array();
370
+// 			$outcomes_colap=array();
371
+		$i=0;
372
+		$outcomes_attempted=array();
373
+		$outcomes_attempted_colap=array();
374
+		$outcomes_achieved_colap=array();
375
+		$outcomes_attempted_semesters=array();
376
+		foreach($resultados_todos as $program_id => $resultados_prog)
377
+		{
378
+	     	$outcomes_attempted_semesters[$program_id]=array();
379
+			foreach($resultados_prog as $out=>$datos_out)
380
+			{
381
+				$outcomes_achieved[$program_id][$out] = 0;
382
+				$outcomes_attempted[$program_id][$out] = 0;
383
+// 				var_dump($datos_out);outcomes_attempted_semesters
384
+				$outcomes_attempted_semesters[$program_id][$out]=$datos_out['semesters'];
385
+				unset($datos_out['semesters']);
386
+// 				var_dump($outcomes_attempted_semesters[$program_id][$out]);
387
+// 				var_dump($datos_out);
388
+// 				exit();
389
+				foreach($datos_out as $res)
390
+				{
391
+					$outcomes_attempted[$program_id][$out]++;
392
+					if(3*$res['achieved']>=2*$res['attempted'])
393
+						$outcomes_achieved[$program_id][$out]++;
394
+				}		
395
+			}
396
+			$programs[]=Program::find($program_id);
397
+			if(Program::find($program_id)->is_graduate)
398
+			{
399
+				$colapso=array(1=>array(),3=>array(),2=>array(11),12=>array(7,14),10=>array(),4=>array(6,15));
400
+			}
401
+			else
402
+			{
403
+				$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());
404
+			}	
405
+		
406
+			$resultados_todos_colap[$program_id]=array();
407
+			foreach($colapso as $out=>$pares)
408
+			{
409
+				$resultados_todos_colap[$program_id][$out]["semesters"]=array();
410
+				if(isset($resultados_todos[$program_id][$out]))
411
+					$resultados_todos_colap[$program_id][$out]=$resultados_todos[$program_id][$out];
412
+					else $resultados_todos_colap[$program_id][$out]=array();
413
+				foreach($pares as $par)
414
+				{
415
+					if(isset($resultados_todos[$program_id][$par]))
416
+					{	
417
+// 						unset($resultados_todos[$program_id][$par]['semesters']);
418
+						
419
+						foreach($resultados_todos[$program_id][$par] as $estu => $resus)
420
+						{
421
+							if($estu!="semesters")
422
+							{
423
+								if(!isset($resultados_todos_colap[$program_id][$out][$estu]))
424
+								{
425
+									$resultados_todos_colap[$program_id][$out][$estu]['attempted']=0;
426
+									$resultados_todos_colap[$program_id][$out][$estu]['achieved']=0;
427
+
428
+								}
429
+	// 							print $program_id." ".$par." ".$estu."<br>";
430
+	// 							var_dump($resultados_todos[$program_id][$par][$estu]); 
431
+								$resultados_todos_colap[$program_id][$out][$estu]['attempted']+=$resultados_todos[$program_id][$par][$estu]['attempted'];
432
+								$resultados_todos_colap[$program_id][$out][$estu]['achieved']+=$resultados_todos[$program_id][$par][$estu]['achieved'];
433
+							}
434
+							else if(isset($resultados_todos[$program_id][$par]["semesters"]))
435
+							{
436
+								if(isset($resultados_todos_colap[$program_id][$out]["semesters"]))
437
+								{
438
+									$tmp=array_merge($resultados_todos_colap[$program_id][$out]["semesters"],$resultados_todos[$program_id][$par]["semesters"]);
439
+// 									var_dump(($tmp));
440
+// 									var_dump(array_unique($tmp));
441
+// 									exit();
442
+
443
+									$resultados_todos_colap[$program_id][$out]["semesters"]=array_unique($tmp);
444
+								}
445
+								else 
446
+									$resultados_todos_colap[$program_id][$out]["semesters"]=array_unique($resultados_todos[$program_id][$par]["semesters"]);
447
+							}
448
+						}
449
+					}
450
+				}
451
+		
452
+			}
453
+// 			var_dump($resultados_todos_colap);
454
+			
455
+			$outcomes_attempted_colap[$program_id]=array();
456
+			$outcomes_achieved_colap[$program_id]=array();
457
+			$outcomes_attempted_colap_semesters[$program_id]=array();
458
+// 			print $program_id."<br>";
459
+// 				var_dump($resultados_todos_colap[$program_id]);
460
+// 			print "<br>";
461
+			foreach($resultados_todos_colap[$program_id] as $out=>$datos_out)
462
+			{
463
+				if(!$i)$outcomes_colap[]=Outcome::find($out);
464
+// 				$outcomes_attempted_colap_semesters[$program_id][$out]=array();
465
+				if(isset($datos_out['semesters']))
466
+				{
467
+					$outcomes_attempted_colap_semesters[$program_id][$out]=$datos_out['semesters'];
468
+					unset($datos_out['semesters']);
469
+				}
470
+				foreach($datos_out as $res)
471
+				{
472
+					if(!isset($outcomes_attempted_colap[$program_id][$out]))
473
+					{
474
+						$outcomes_attempted_colap[$program_id][$out]=0;
475
+						$outcomes_achieved_colap[$program_id][$out]=0;
476
+					
477
+					}
478
+					$outcomes_attempted_colap[$program_id][$out]++;
479
+					if(3*$res['achieved']>=2*$res['attempted'])
480
+						$outcomes_achieved_colap[$program_id][$out]++;
481
+				}
482
+				if(empty($datos_out))
483
+				{
484
+					$outcomes_attempted_colap[$program_id][$out]=0;
485
+					$outcomes_achieved_colap[$program_id][$out]=0;
486
+				}
487
+
488
+			}
489
+			$i++;
490
+		}		
491
+		usort($outcomes_colap, array($this, "cmp"));
492
+	// 		var_dump($outcomes_attempted_colap); print "<br>";
493
+	// 		var_dump($outcomes_achieved_colap); print "<br>";
494
+	// 	exit();
495
+		$outcomes_attempted_colap_todo=array();
496
+		$outcomes_achieved_colap_todo=array();
497
+		foreach($outcomes_attempted_colap as $program_id => $out_res)
498
+		{
499
+			foreach($out_res as $out=>$res)
500
+			{
501
+				if(!isset($outcomes_attempted_colap_todo[$out]))
502
+				{
503
+					$outcomes_attempted_colap_todo[$out]=0;
504
+					$outcomes_achieved_colap_todo[$out]=0;
505
+			
506
+				}
507
+				$outcomes_attempted_colap_todo[$out]+=$outcomes_attempted_colap[$program_id][$out];
508
+				$outcomes_achieved_colap_todo[$out]+=$outcomes_achieved_colap[$program_id][$out];
509
+		
510
+		
511
+			}
512
+	
513
+		}
514
+		$outcomes_attempted_todo=array();
515
+		$outcomes_achieved_todo=array();
516
+		foreach($outcomes_attempted as $program_id => $out_res)
517
+		{
518
+			foreach($out_res as $out=>$res)
519
+			{
520
+				if(!isset($outcomes_attempted_todo[$out]))
521
+				{
522
+					$outcomes_attempted_todo[$out]=0;
523
+					$outcomes_achieved_todo[$out]=0;
524
+			
525
+				}
526
+				$outcomes_attempted_todo[$out]+=$outcomes_attempted[$program_id][$out];
527
+				$outcomes_achieved_todo[$out]+=$outcomes_achieved[$program_id][$out];
528
+		
529
+		
530
+			}
531
+	
532
+		}
533
+	$outcomes_attempted_colap=$outcomes_attempted_colap_todo;
534
+	$outcomes_achieved_colap=$outcomes_achieved_colap_todo;
535
+	$outcomes_attempted=$outcomes_attempted_todo;
536
+	$outcomes_achieved=$outcomes_achieved_todo;
537
+// 	var_dump($outcomes_attempted_colap);
538
+// 	var_dump($outcomes_attempted_colap);
539
+// 	    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'));
540
+
541
+    return View::make('local.managers.shared.program_student_result', compact('title','role','outcomes','outcomes_colap', 'outcomes_attempted', 'outcomes_achieved', 'outcomes_attempted_colap', 'outcomes_achieved_colap', 'program', 'users','program_courses','grouped_courses'));
542
+    }
543
+
248 544
   //   public function show($id)
249 545
   //   {
250 546
   //

+ 63
- 0
app/controllers/TemplatesController.php ファイルの表示

@@ -184,6 +184,69 @@ class TemplatesController extends \BaseController
184 184
 		return View::make('local.managers.shared.rubrics', compact('title', 'templates', 'outcomes', 'criteria', 'schools', 'programs'));
185 185
 	}
186 186
 
187
+	public function newTemplate_new()
188
+	{
189
+		$title = "Rubric Builder";
190
+
191
+		$templates = Template::orderBy('name', 'ASC')->get();
192
+		$outcomes = Outcome::where("deactivation_date", '=', null)->orderBy('name', 'ASC')->get();
193
+		$schools = School::orderBy('name', 'ASC')->get();
194
+		$role = Auth::user()->role;
195
+
196
+		$templates = NULL;
197
+		$programs = NULL;
198
+		// Returns templates depending on the type of user
199
+		if ($role == 1) {
200
+			$templates = Template::orderBy('name', 'ASC')->get();
201
+			$programs = Program::orderBy('name', 'ASC')->get();
202
+			$criteria = Criterion::orderBy('name', 'ASC')->get();
203
+		} 
204
+		else
205
+		{
206
+			if ($role == 2) {
207
+				$programs = Auth::user()->school->programs;
208
+			} 
209
+			if ($role == 3) {
210
+				$programs = Auth::user()->programs()->get();
211
+			}
212
+			$program_ids=array();		
213
+			foreach($programs as $program)
214
+			{
215
+				$program_ids[]=$program->id;
216
+			}
217
+			$criteria = Criterion::whereHas('programs', function ($q) use ($program_ids)
218
+			{
219
+				$q->whereIn('program_id', $program_ids );
220
+			}
221
+			)->orderBy('name', 'ASC')->get();
222
+			$templates = Template::where('school_id', '=', Auth::user()->programs[0]->school->id)->orWhere('school_id', '=', NULL)
223
+			->orderBy('name', 'ASC')->get();
224
+			$criteria_ids=array();		
225
+			foreach($criteria as $criterion)
226
+			{
227
+				$criteria_ids[]=$criterion->id;
228
+			}
229
+			$templates_fuera = Template::whereHas('criteria', function ($q) use ($criteria_ids)
230
+			{
231
+				$q->whereNotIn('criterion_id', $criteria_ids );
232
+			})
233
+			->orderBy('name', 'ASC')->get();
234
+			$templates_fuera_ids=array();		
235
+			foreach($templates_fuera as $tf)
236
+			{
237
+				$templates_fuera_ids[]=$tf->id;
238
+			}
239
+			$templates_dentro = Template::whereNotIn('id', $templates_fuera_ids)
240
+			->orderBy('name', 'ASC')->get();
241
+			
242
+	// 			var_dump(json_encode($templates_dentro));
243
+		}		
244
+	
245
+	
246
+
247
+		return View::make('local.managers.shared.rubrics_new', compact('title', 'templates_dentro', 'templates_fuera', 'outcomes', 'criteria', 'schools', 'programs', 'criteria_ids'));
248
+	}
249
+
187 250
 	/**
188 251
 	 * Save a new rubric
189 252
 	 *

+ 6
- 0
app/models/Criterion.php ファイルの表示

@@ -41,6 +41,12 @@ class Criterion extends Eloquent
41 41
 	 *
42 42
 	 * @return Illuminate\Database\Eloquent\Model
43 43
 	 */
44
+	public function programs()
45
+	{
46
+		return $this->belongsToMany('Program','program_criterion');
47
+	}
48
+
49
+
44 50
 	public function program()
45 51
 	{
46 52
 		return $this->belongsTo('Program');

+ 6
- 0
app/models/Template.php ファイルの表示

@@ -12,4 +12,10 @@ class Template extends Eloquent
12 12
         return $this->belongsTo('School');
13 13
     }
14 14
 
15
+	public function criteria()
16
+	{
17
+		return $this->belongsToMany('Criterion','template_criterion');
18
+	}
19
+
20
+
15 21
 }

+ 5
- 1
app/routes.php ファイルの表示

@@ -444,7 +444,8 @@ Route::group(array('before' => 'auth|has_access'), function () {
444 444
     Route::group(array('before' => 'pcoord'), function () {
445 445
         Route::get('program-coordinator', 'ProgramCoordinatorsController@overview');
446 446
         Route::post('deleteObjective', 'Objective2Controller@delete');
447
-        Route::get('rubrics', 'TemplatesController@newTemplate');
447
+        Route::get('rubrics_old', 'TemplatesController@newTemplate');
448
+        Route::get('rubrics', 'TemplatesController@newTemplate_new');
448 449
         Route::get('template/{template}', 'TemplatesController@show');
449 450
 
450 451
         Route::post('saveTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@create'));
@@ -459,6 +460,9 @@ Route::group(array('before' => 'auth|has_access'), function () {
459 460
         Route::get('grouped_course/{code}/{number}/{semester_code}', 'CoursesController@showGrouped');
460 461
         Route::get('template-list', 'TemplatesController@index');
461 462
 
463
+        Route::get('student_program_assessment-report/{program_id}', 'ProgramsController@studentProgramAssessmentReport');
464
+
465
+
462 466
         //Criteria and objectives
463 467
         Route::get('program-criteria', 'CriteriaController@editProgram');
464 468
         Route::post('crtiteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));

+ 1
- 0
app/views/local/managers/shared/program.blade.php ファイルの表示

@@ -11,6 +11,7 @@
11 11
 @stop
12 12
 
13 13
 @section('main')
14
+<a href="{{ action('ProgramsController@studentProgramAssessmentReport', array($program->id)); }}" class="btn btn-primary pull-left" alt="print">Go to Performance by Program Students</a>
14 15
 <a href="{{ action('ProgramsController@print_program', array($program->id)); }}" class="btn btn-primary pull-right" alt="print"><span class="glyphicon glyphicon-print"></span></a>
15 16
 <br>
16 17
 <br>

+ 8
- 2
app/views/local/managers/shared/program_student_result.blade.php ファイルの表示

@@ -55,7 +55,8 @@
55 55
                             </tfoot>
56 56
                             <tbody>
57 57
                                 @foreach($outcomes_colap as $outcome)
58
-                                    <tr>
58
+                                    @if(isset($outcomes_attempted_colap[$program->id][$outcome->id]))
59
+              					<tr>
59 60
 										<td>{{{ $program->id }}}</td>
60 61
 										<td>{{{ $program->is_graduate }}}</td>
61 62
 										<td>{{ link_to_action('OutcomesController@show', $outcome->name, array($outcome->id), $attributes = array()) }}</td>
@@ -69,6 +70,7 @@
69 70
 											@endif
70 71
 										</td>
71 72
                                     </tr>
73
+                                    @endif
72 74
                                 @endforeach
73 75
                             </tbody>
74 76
                         </table>
@@ -110,7 +112,8 @@
110 112
                             </tfoot>
111 113
                             <tbody>
112 114
                                 @foreach($outcomes as $outcome)
113
-                                    <tr>
115
+                                     @if(isset($outcomes_attempted[$program->id][$outcome->id]))
116
+                                   <tr>
114 117
 										<td>{{{ $program->id }}}</td>
115 118
 										<td>{{{ $program->is_graduate }}}</td>
116 119
 										<td>{{ link_to_action('OutcomesController@show', $outcome->name, array($outcome->id), $attributes = array()) }}</td>
@@ -124,6 +127,7 @@
124 127
 											@endif
125 128
 										</td>
126 129
                                     </tr>
130
+                                    @endif
127 131
                                 @endforeach
128 132
                             </tbody>
129 133
                         </table>
@@ -293,7 +297,9 @@ $('#graph').highcharts({
293 297
     xAxis: {
294 298
         categories: [
295 299
             @foreach($outcomes as $outcome)
300
+             @if(isset($outcomes_attempted[$outcome->id]))
296 301
                 "{{{ $outcome->name }}}<br>(N = {{{ $outcomes_attempted[$outcome->id] }}}, {{{ $outcomes_achieved[$outcome->id] }}})",
302
+            @endif
297 303
             @endforeach
298 304
         ],
299 305
         labels: {