Преглед на файлове

Merge branch 'Merge_gabriel_mayo' of https://git.ccom.uprrp.edu/CDCC/OLAS into Merge_gabriel_mayo

Gabriel Santiago Plaza преди 2 години
родител
ревизия
caa455fbc0

+ 15
- 3
app/controllers/ActivitiesController.php Целия файл

@@ -140,11 +140,23 @@ class ActivitiesController extends \BaseController
140 140
         Log::info($active_semesters);
141 141
         // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
142 142
         $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
143
+
143 144
         $semesters = DB::table('semesters')->where('id', $course->semester_id)->orderBy('start', 'ASC')->first();
144
-        $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
145
+        /*$outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
145 146
             ->whereNull('deleted_at')
146 147
             ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
147
-            ->orderBy('name', 'ASC')->get();
148
+            ->orderBy('name', 'ASC')->get();*/
149
+
150
+//         $outcomes = Outcome::orderBy('name', 'asc')->get();
151
+		 $level = DB::table('courses')
152
+            ->join('programs', 'programs.id', '=', 'courses.program_id')
153
+            ->where('courses.id', $activity->course_id)
154
+//             ->where('courses.number', $number)
155
+//             ->where('courses.semester_id', $semester->id)
156
+            ->select('programs.is_graduate')
157
+            ->first();
158
+            $outcomes = Outcome::active_by_semesters(array($course->semester), $level->is_graduate);
159
+
148 160
         $assessment = DB::table('assessments')
149 161
             ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
150 162
             ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
@@ -988,4 +1000,4 @@ class ActivitiesController extends \BaseController
988 1000
 
989 1001
         return View::make('local.professors.compare_activities', compact('activity_1', 'activity_2', 'activity_criterion_1', 'activity_criterion_2', 'title', 'outcomes', 'outcomes_achieved_1', 'outcomes_attempted_1', 'outcomes_achieved_2', 'outcomes_attempted_2', 'course', 'student_count', 'active_semesters'));
990 1002
     }
991
-}
1003
+}

+ 285
- 48
app/controllers/SchoolCoordinatorsController.php Целия файл

@@ -5,17 +5,234 @@ class SchoolCoordinatorsController extends \BaseController
5 5
 
6 6
     private function participatingPrograms($school)
7 7
     {
8
-        return DB::table('programs')
8
+         return DB::table('programs')
9 9
             ->join('courses', 'courses.program_id', '=', 'programs.id')
10
+            ->join('activities', 'activities.course_id', '=', 'courses.id')
11
+            ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
12
+            ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
10 13
             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
11 14
             ->addSelect('courses.semester_id')
12 15
             ->where('school_id', $school->id)
13 16
             ->whereIn('semester_id', Session::get('semesters_ids'))
14 17
             ->lists('id');
18
+
19
+//        return DB::table('programs')
20
+//             ->join('courses', 'courses.program_id', '=', 'programs.id')
21
+//             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
22
+//             ->addSelect('courses.semester_id')
23
+//             ->where('school_id', $school->id)
24
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
25
+//             ->lists('id');
15 26
     }
16 27
 
17 28
     public function overview()
18 29
     {
30
+        ini_set('memory_limit', '256M');
31
+        DB::connection()->disableQueryLog();
32
+//         $school = School::find($id);
33
+        $school = Auth::user()->school;
34
+        $id = $school->id;
35
+
36
+        $title = $school->name;
37
+        $schools = School::all();
38
+
39
+        $semesters = Semester::whereIn('id',Session::get('semesters_ids'))->get();
40
+
41
+        $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
42
+        $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
43
+
44
+        /**
45
+         * List of grouped courses (grouped sections)
46
+         */
47
+
48
+        $program_ids = $school->programs->lists('id');
49
+
50
+        $undergrad_programs = DB::table('programs')
51
+            ->select('id', 'name', 'school_id', 'is_graduate')
52
+            ->where('is_graduate', '=', 0)
53
+            ->where('school_id', '=', $id)
54
+            ->orderBy('name', 'ASC')
55
+            ->get();
56
+
57
+        $grad_programs = DB::table('programs')
58
+            ->select('id', 'name', 'school_id', 'is_graduate')
59
+            ->where('is_graduate', '=', 1)
60
+            ->where('school_id', '=', $id)
61
+            ->orderBy('name', 'ASC')
62
+            ->get();
63
+
64
+
65
+        $grad_grouped_courses = Course::
66
+            //             select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
67
+            select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
68
+            ->with('semester')
69
+            ->with('program')
70
+            ->whereIn('courses.program_id', $program_ids)
71
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
72
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
73
+            ->where('programs.is_graduate', '=', 1)
74
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
75
+            ->orderBy('courses.code')
76
+            ->orderBy('courses.number')
77
+            ->orderBy('courses.semester_id')
78
+            ->get();
79
+
80
+        $undergrad_grouped_courses = Course::
81
+            //             select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
82
+            select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
83
+            ->with('semester')
84
+            ->with('program')
85
+            ->whereIn('courses.program_id', $program_ids)
86
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
87
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
88
+            ->where('programs.is_graduate', '=', 0)
89
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
90
+            ->orderBy('courses.code')
91
+            ->orderBy('courses.number')
92
+            ->orderBy('courses.semester_id')
93
+            ->get();
94
+
95
+		foreach($undergrad_grouped_courses as $key=>$courses)
96
+		{
97
+			$undergrad_grouped_courses[$key]->outcomes_attempted=NULL;	
98
+			$coursesT=Course::where('courses.code',$courses->code)->where('courses.number',$courses->number)->where('courses.semester_id',$courses->semester_id)->get();
99
+			foreach($coursesT as $course)
100
+    		{
101
+				if($course->isAssessed())
102
+				{
103
+					$undergrad_grouped_courses[$key]->outcomes_attempted=true;
104
+				}
105
+			}
106
+    	}
107
+
108
+		foreach($grad_grouped_courses as $key=>$courses)
109
+		{
110
+			$grad_grouped_courses[$key]->outcomes_attempted=NULL;	
111
+			$coursesT=Course::where('courses.code',$courses->code)->where('courses.number',$courses->number)->where('courses.semester_id',$courses->semester_id)->get();
112
+			foreach($coursesT as $course)
113
+    		{
114
+				if($course->isAssessed())
115
+				{
116
+					$grad_grouped_courses[$key]->outcomes_attempted=true;
117
+				}
118
+			}
119
+    	}
120
+
121
+        // Fetch programs with participation
122
+        $participating_programs = $this->participatingPrograms($school);
123
+
124
+
125
+        /**
126
+         * Calculate how many sections are doing assessment
127
+         */
128
+
129
+        $undergrad_assessed_sections_count = 0;
130
+        $undergrad_school_sections_count = 0;
131
+
132
+        $grad_assessed_sections_count = 0;
133
+        $grad_school_sections_count = 0;
134
+
135
+        foreach ($school->programs as $program) {
136
+            foreach ($program->courses as $course) {
137
+
138
+	            if (!$course->program->is_graduate){
139
+    	            $undergrad_school_sections_count += 1;
140
+    	        	if($course->isAssessed())$undergrad_assessed_sections_count += 1;
141
+    	        }
142
+        	    else {
143
+            	    $grad_school_sections_count += 1;
144
+            		if($course->isAssessed())$grad_assessed_sections_count += 1;
145
+           		}
146
+            }
147
+        }
148
+
149
+        /**
150
+         * Calculate how many programs achieved and attempted each outcome in this school
151
+         */
152
+
153
+        // For each outcome 
154
+        foreach ($outcomes_undergrad as $outcome) {
155
+//         	$attempted_outcomes_per_undergrad_program[$outcome->id]=0;
156
+//         	$achieved_outcomes_per_undergrad_program[$outcome->id]=0;
157
+        	$attemptedUndergradProgramsPerOutcome[$outcome->id]=0;
158
+        	$achievedUndergradProgramsPerOutcome[$outcome->id]=0;
159
+        	$programs_attempted_in_school[$outcome->id]=$outcome->programs_attempted_in_school($semesters, $school->id);
160
+//         	var_dump($programs_attempted_in_school);exit();
161
+        	foreach($programs_attempted_in_school[$outcome->id] as $program_id)
162
+        	{
163
+//         		var_dump($program_id->id);exit();
164
+				$program = DB::table('programs')->where('id', '=', $program_id->id)->first();
165
+
166
+        		if(!$program->is_graduate)
167
+        		{
168
+        			$attemptedUndergradProgramsPerOutcome[$outcome->id]++;
169
+        			$programC=Program::where('id', '=', $program_id->id)->first();
170
+//         			var_dump($programC);exit();
171
+					if($programC->achieved_outcome($outcome->id,$semesters))
172
+					{
173
+						$achievedUndergradProgramsPerOutcome[$outcome->id]++;
174
+					}
175
+        		}
176
+        	}
177
+ 			$undergrad_outcomes_attempted[$outcome->id]=$outcome->attempted_by_school($semesters, $school->id,0);
178
+ 			$undergrad_outcomes_achieved[$outcome->id]=$outcome->achieved_by_school($semesters, $school->id,0);
179
+ 			
180
+            // For each program with courses that do assessment
181
+            $programs_with_courses = Program::with(array('courses' => function ($query) {
182
+                //                 $query->whereNotNull('outcomes_attempted');
183
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
184
+            }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
185
+
186
+        }
187
+
188
+        /**
189
+         * Calculate how many programs achieved and attempted each outcome in this school
190
+         */
191
+
192
+        // For each outcome 
193
+        foreach ($outcomes_grad as $outcome) {
194
+//         	$attempted_outcomes_per_grad_program[$outcome->id]=0;
195
+        	$achieved_outcomes_per_grad_program[$outcome->id]=0;
196
+        	$attemptedGradProgramsPerOutcome[$outcome->id]=0;
197
+        	$achievedGradProgramsPerOutcome[$outcome->id]=0;
198
+ 			$grad_outcomes_attempted[$outcome->id]=$outcome->attempted_by_school($semesters, $school->id,1);
199
+ 			$grad_outcomes_achieved[$outcome->id]=$outcome->achieved_by_school($semesters, $school->id,1);
200
+           // For each program with courses that do assessment
201
+        	foreach($programs_attempted_in_school[$outcome->id] as $program_id)
202
+        	{
203
+//         		var_dump($program_id->id);exit();
204
+				$program = DB::table('programs')
205
+                        ->where('id', '=', $program_id->id)
206
+                        ->first();
207
+//         		$program=Program::where('id', $program_id->id);
208
+//         		var_dump($program);exit();
209
+        		if($program->is_graduate)
210
+        		{
211
+        			$attemptedGradProgramsPerOutcome[$outcome->id]++;
212
+        			$programC=Program::where('id', '=', $program_id->id)->first();
213
+//         			var_dump($programC);exit();
214
+					if($programC->achieved_outcome($outcome->id,$semesters))
215
+					{
216
+						$achievedGradProgramsPerOutcome[$outcome->id]++;
217
+					}
218
+        		}
219
+        	}
220
+            $programs_with_courses = Program::with(array('courses' => function ($query) {
221
+                //                 $query->whereNotNull('outcomes_attempted');
222
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
223
+            }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
224
+
225
+        }
226
+        if ($school->id == 13) {
227
+//             return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
228
+            return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
229
+        } else {
230
+//             return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
231
+            return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
232
+        }
233
+    }
234
+    public function overviewOri()
235
+    {
19 236
         DB::disableQueryLog();
20 237
         Log::debug('user' . Auth::user()->id);
21 238
 
@@ -160,35 +377,48 @@ class SchoolCoordinatorsController extends \BaseController
160 377
 
161 378
         foreach ($school->programs as $program) {
162 379
             foreach ($program->courses as $course) {
163
-                if (!$course->program->is_graduate) {
164
-                    if ($course_outcomes_achieved = $course->outcomes_ach()) {
165
-                        //$course_outcomes_achieved = $course->outcomes_ach();
166
-                        $course_outcomes_attempted = $course->outcomes_att();
167
-                        foreach ($course_outcomes_attempted as $i => $score) {
380
+                        if (!$course->program->is_graduate){
381
+                $undergrad_school_sections_count += 1;
382
+            	if($course->isAssessed())$undergrad_assessed_sections_count += 1;
383
+//             	            Log::info("aqui".$course);
168 384
 
169
-                            $undergrad_outcomes_attempted[$i] += $score;
170
-                        }
171
-                        foreach ($course_outcomes_achieved as $i => $score) {
172
-                            $undergrad_outcomes_achieved[$i] += $score;
173
-                        }
174
-                        $undergrad_assessed_sections_count += 1;
175
-                    }
176
-                    $undergrad_school_sections_count += 1;
177
-                } else {
178
-                    if ($course_outcomes_achieved = $course->outcomes_ach()) {
179
-                        //$course_outcomes_achieved = $course->outcomes_ach();
180
-                        $course_outcomes_attempted = $course->outcomes_att();
181
-                        foreach ($course_outcomes_attempted as $i => $score) {
385
+            }
386
+            else {
387
+                $grad_school_sections_count += 1;
388
+            	if($course->isAssessed())$grad_assessed_sections_count += 1;
389
+//             	            	            Log::info("aqui".$course);
182 390
 
183
-                            $grad_outcomes_attempted[$i] += $score;
184
-                        }
185
-                        foreach ($course_outcomes_achieved as $i => $score) {
186
-                            $grad_outcomes_achieved[$i] += $score;
187
-                        }
188
-                        $grad_assessed_sections_count += 1;
189
-                    }
190
-                    $grad_school_sections_count += 1;
191
-                }
391
+            }
392
+// 
393
+//                 if (!$course->program->is_graduate) {
394
+//                     if ($course_outcomes_achieved = $course->outcomes_ach()) {
395
+//                         //$course_outcomes_achieved = $course->outcomes_ach();
396
+//                         $course_outcomes_attempted = $course->outcomes_att();
397
+//                         foreach ($course_outcomes_attempted as $i => $score) {
398
+// 
399
+//                             $undergrad_outcomes_attempted[$i] += $score;
400
+//                         }
401
+//                         foreach ($course_outcomes_achieved as $i => $score) {
402
+//                             $undergrad_outcomes_achieved[$i] += $score;
403
+//                         }
404
+//                         $undergrad_assessed_sections_count += 1;
405
+//                     }
406
+//                     $undergrad_school_sections_count += 1;
407
+//                 } else {
408
+//                     if ($course_outcomes_achieved = $course->outcomes_ach()) {
409
+//                         //$course_outcomes_achieved = $course->outcomes_ach();
410
+//                         $course_outcomes_attempted = $course->outcomes_att();
411
+//                         foreach ($course_outcomes_attempted as $i => $score) {
412
+// 
413
+//                             $grad_outcomes_attempted[$i] += $score;
414
+//                         }
415
+//                         foreach ($course_outcomes_achieved as $i => $score) {
416
+//                             $grad_outcomes_achieved[$i] += $score;
417
+//                         }
418
+//                         $grad_assessed_sections_count += 1;
419
+//                     }
420
+//                     $grad_school_sections_count += 1;
421
+//                 }
192 422
             }
193 423
         }
194 424
 
@@ -203,15 +433,16 @@ class SchoolCoordinatorsController extends \BaseController
203 433
         $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
204 434
 
205 435
         // Fetch programs with participation for the school
206
-        $participating_undergrad_programs = DB::table('programs')
207
-            ->join('courses', 'courses.program_id', '=', 'programs.id')
208
-            ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
209
-            ->addSelect('courses.semester_id')
210
-            ->whereIn('semester_id', Session::get('semesters_ids'))
211
-            ->where('is_graduate', 0)
212
-            ->where('school_id', $school->id)
213
-            ->groupBy('id')
214
-            ->get();
436
+        
437
+//         $participating_undergrad_programs = DB::table('programs')
438
+//             ->join('courses', 'courses.program_id', '=', 'programs.id')
439
+//             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
440
+//             ->addSelect('courses.semester_id')
441
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
442
+//             ->where('is_graduate', 0)
443
+//             ->where('school_id', $school->id)
444
+//             ->groupBy('id')
445
+//             ->get();
215 446
 
216 447
         $output = array();
217 448
 
@@ -232,7 +463,8 @@ class SchoolCoordinatorsController extends \BaseController
232 463
             }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
233 464
 
234 465
             foreach ($programs_with_courses as $program) {
235
-                // To acummulate all criteria for one program
466
+              if(in_array($program->id,$participating_programs)){
467
+               // To acummulate all criteria for one program
236 468
                 $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
237 469
                 $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
238 470
 
@@ -268,6 +500,7 @@ class SchoolCoordinatorsController extends \BaseController
268 500
                     // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
269 501
                 }
270 502
             }
503
+            }
271 504
         }
272 505
 
273 506
         /**
@@ -281,15 +514,15 @@ class SchoolCoordinatorsController extends \BaseController
281 514
         $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
282 515
 
283 516
         // Fetch programs with participation for the school
284
-        $participating_grad_programs = DB::table('programs')
285
-            ->join('courses', 'courses.program_id', '=', 'programs.id')
286
-            ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
287
-            ->addSelect('courses.semester_id')
288
-            ->whereIn('semester_id', Session::get('semesters_ids'))
289
-            ->where('is_graduate', 1)
290
-            ->where('school_id', $school->id)
291
-            ->groupBy('id')
292
-            ->get();
517
+//         $participating_grad_programs = DB::table('programs')
518
+//             ->join('courses', 'courses.program_id', '=', 'programs.id')
519
+//             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
520
+//             ->addSelect('courses.semester_id')
521
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
522
+//             ->where('is_graduate', 1)
523
+//             ->where('school_id', $school->id)
524
+//             ->groupBy('id')
525
+//             ->get();
293 526
 
294 527
         $output = array();
295 528
 
@@ -310,6 +543,7 @@ class SchoolCoordinatorsController extends \BaseController
310 543
             }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
311 544
 
312 545
             foreach ($programs_with_courses as $program) {
546
+             if(in_array($program->id,$participating_programs)){
313 547
                 // To acummulate all criteria for one program
314 548
                 $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
315 549
                 $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
@@ -346,7 +580,10 @@ class SchoolCoordinatorsController extends \BaseController
346 580
                     // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
347 581
                 }
348 582
             }
583
+ }
349 584
         }
350
-        return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
585
+//         return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
586
+        return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
351 587
     }
588
+
352 589
 }

+ 377
- 91
app/controllers/SchoolsController.php Целия файл

@@ -7,11 +7,22 @@ class SchoolsController extends \BaseController
7 7
     {
8 8
         return DB::table('programs')
9 9
             ->join('courses', 'courses.program_id', '=', 'programs.id')
10
+            ->join('activities', 'activities.course_id', '=', 'courses.id')
11
+            ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
12
+            ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
10 13
             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
11 14
             ->addSelect('courses.semester_id')
12 15
             ->where('school_id', $school->id)
13 16
             ->whereIn('semester_id', Session::get('semesters_ids'))
14 17
             ->lists('id');
18
+
19
+//         return DB::table('programs')
20
+//             ->join('courses', 'courses.program_id', '=', 'programs.id')
21
+//             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
22
+//             ->addSelect('courses.semester_id')
23
+//             ->where('school_id', $school->id)
24
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
25
+//             ->lists('id');
15 26
     }
16 27
 
17 28
     public function show($id)
@@ -22,8 +33,216 @@ class SchoolsController extends \BaseController
22 33
         $title = $school->name;
23 34
         $schools = School::all();
24 35
 
25
-        $outcomes = Outcome::orderBy('name', 'asc')->get();
26
-        $outcomeCount = Outcome::all()->count();
36
+        $semesters = Semester::whereIn('id',Session::get('semesters_ids'))->get();
37
+
38
+        $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
39
+        $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
40
+
41
+        /**
42
+         * List of grouped courses (grouped sections)
43
+         */
44
+
45
+        $program_ids = $school->programs->lists('id');
46
+
47
+        $undergrad_programs = DB::table('programs')
48
+            ->select('id', 'name', 'school_id', 'is_graduate')
49
+            ->where('is_graduate', '=', 0)
50
+            ->where('school_id', '=', $id)
51
+            ->orderBy('name', 'ASC')
52
+            ->get();
53
+
54
+        $grad_programs = DB::table('programs')
55
+            ->select('id', 'name', 'school_id', 'is_graduate')
56
+            ->where('is_graduate', '=', 1)
57
+            ->where('school_id', '=', $id)
58
+            ->orderBy('name', 'ASC')
59
+            ->get();
60
+
61
+
62
+        $grad_grouped_courses = Course::
63
+            //             select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
64
+            select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
65
+            ->with('semester')
66
+            ->with('program')
67
+            ->whereIn('courses.program_id', $program_ids)
68
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
69
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
70
+            ->where('programs.is_graduate', '=', 1)
71
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
72
+            ->orderBy('courses.code')
73
+            ->orderBy('courses.number')
74
+            ->orderBy('courses.semester_id')
75
+            ->get();
76
+
77
+        $undergrad_grouped_courses = Course::
78
+            //             select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
79
+            select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
80
+            ->with('semester')
81
+            ->with('program')
82
+            ->whereIn('courses.program_id', $program_ids)
83
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
84
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
85
+            ->where('programs.is_graduate', '=', 0)
86
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
87
+            ->orderBy('courses.code')
88
+            ->orderBy('courses.number')
89
+            ->orderBy('courses.semester_id')
90
+            ->get();
91
+            
92
+		foreach($undergrad_grouped_courses as $key=>$courses)
93
+		{
94
+			$undergrad_grouped_courses[$key]->outcomes_attempted=NULL;	
95
+			$coursesT=Course::where('courses.code',$courses->code)->where('courses.number',$courses->number)->where('courses.semester_id',$courses->semester_id)->get();
96
+			foreach($coursesT as $course)
97
+    		{
98
+				if($course->isAssessed())
99
+				{
100
+					$undergrad_grouped_courses[$key]->outcomes_attempted=true;
101
+				}
102
+			}
103
+    	}
104
+
105
+		foreach($grad_grouped_courses as $key=>$courses)
106
+		{
107
+			$grad_grouped_courses[$key]->outcomes_attempted=NULL;	
108
+			$coursesT=Course::where('courses.code',$courses->code)->where('courses.number',$courses->number)->where('courses.semester_id',$courses->semester_id)->get();
109
+			foreach($coursesT as $course)
110
+    		{
111
+				if($course->isAssessed())
112
+				{
113
+					$grad_grouped_courses[$key]->outcomes_attempted=true;
114
+				}
115
+			}
116
+    	}
117
+
118
+        // Fetch programs with participation
119
+        $participating_programs = $this->participatingPrograms($school);
120
+
121
+        /**
122
+         * Calculate how many sections are doing assessment
123
+         */
124
+
125
+        $undergrad_assessed_sections_count = 0;
126
+        $undergrad_school_sections_count = 0;
127
+
128
+        $grad_assessed_sections_count = 0;
129
+        $grad_school_sections_count = 0;
130
+
131
+        foreach ($school->programs as $program) {
132
+            foreach ($program->courses as $course) {
133
+
134
+	            if (!$course->program->is_graduate){
135
+    	            $undergrad_school_sections_count += 1;
136
+    	        	if($course->isAssessed())$undergrad_assessed_sections_count += 1;
137
+    	        }
138
+        	    else {
139
+            	    $grad_school_sections_count += 1;
140
+            		if($course->isAssessed())$grad_assessed_sections_count += 1;
141
+           		}
142
+            }
143
+        }
144
+
145
+        /**
146
+         * Calculate how many programs achieved and attempted each outcome in this school
147
+         */
148
+
149
+        // For each outcome 
150
+        foreach ($outcomes_undergrad as $outcome) {
151
+//         	$attempted_outcomes_per_undergrad_program[$outcome->id]=0;
152
+//         	$achieved_outcomes_per_undergrad_program[$outcome->id]=0;
153
+        	$attemptedUndergradProgramsPerOutcome[$outcome->id]=0;
154
+        	$achievedUndergradProgramsPerOutcome[$outcome->id]=0;
155
+        	$programs_attempted_in_school[$outcome->id]=$outcome->programs_attempted_in_school($semesters, $school->id);
156
+//         	var_dump($programs_attempted_in_school);exit();
157
+        	foreach($programs_attempted_in_school[$outcome->id] as $program_id)
158
+        	{
159
+//         		var_dump($program_id->id);exit();
160
+				$program = DB::table('programs')->where('id', '=', $program_id->id)->first();
161
+
162
+        		if(!$program->is_graduate)
163
+        		{
164
+        			$attemptedUndergradProgramsPerOutcome[$outcome->id]++;
165
+        			$programC=Program::where('id', '=', $program_id->id)->first();
166
+//         			var_dump($programC);exit();
167
+					if($programC->achieved_outcome($outcome->id,$semesters))
168
+					{
169
+						$achievedUndergradProgramsPerOutcome[$outcome->id]++;
170
+					}
171
+        		}
172
+        	}
173
+ 			$undergrad_outcomes_attempted[$outcome->id]=$outcome->attempted_by_school($semesters, $school->id,0);
174
+ 			$undergrad_outcomes_achieved[$outcome->id]=$outcome->achieved_by_school($semesters, $school->id,0);
175
+ 			
176
+            // For each program with courses that do assessment
177
+            $programs_with_courses = Program::with(array('courses' => function ($query) {
178
+                //                 $query->whereNotNull('outcomes_attempted');
179
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
180
+            }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
181
+
182
+        }
183
+
184
+        /**
185
+         * Calculate how many Graduate programs achieved and attempted each outcome in this school
186
+         */
187
+
188
+        // For each outcome 
189
+        foreach ($outcomes_grad as $outcome) {
190
+//         	$attempted_outcomes_per_grad_program[$outcome->id]=0;
191
+        	$achieved_outcomes_per_grad_program[$outcome->id]=0;
192
+        	$attemptedGradProgramsPerOutcome[$outcome->id]=0;
193
+        	$achievedGradProgramsPerOutcome[$outcome->id]=0;
194
+ 			$grad_outcomes_attempted[$outcome->id]=$outcome->attempted_by_school($semesters, $school->id,1);
195
+ 			$grad_outcomes_achieved[$outcome->id]=$outcome->achieved_by_school($semesters, $school->id,1);
196
+           // For each program with courses that do assessment
197
+        	foreach($programs_attempted_in_school[$outcome->id] as $program_id)
198
+        	{
199
+//         		var_dump($program_id->id);exit();
200
+				$program = DB::table('programs')
201
+                        ->where('id', '=', $program_id->id)
202
+                        ->first();
203
+//         		$program=Program::where('id', $program_id->id);
204
+//         		var_dump($program);exit();
205
+        		if($program->is_graduate)
206
+        		{
207
+        			$attemptedGradProgramsPerOutcome[$outcome->id]++;
208
+        			$programC=Program::where('id', '=', $program_id->id)->first();
209
+//         			var_dump($programC);exit();
210
+					if($programC->achieved_outcome($outcome->id,$semesters))
211
+					{
212
+						$achievedGradProgramsPerOutcome[$outcome->id]++;
213
+					}
214
+        		}
215
+        	}
216
+            $programs_with_courses = Program::with(array('courses' => function ($query) {
217
+                //                 $query->whereNotNull('outcomes_attempted');
218
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
219
+            }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
220
+
221
+        }
222
+        if ($school->id == 13) {
223
+//             return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
224
+            return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
225
+        } else {
226
+//             return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
227
+            return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
228
+        }
229
+    }
230
+
231
+    public function showQuasiOri($id)
232
+    {
233
+        ini_set('memory_limit', '256M');
234
+        DB::connection()->disableQueryLog();
235
+        $school = School::find($id);
236
+        $title = $school->name;
237
+        $schools = School::all();
238
+
239
+//         $outcomes = Outcome::orderBy('name', 'asc')->get();
240
+//         $outcomeCount = Outcome::all()->count();
241
+        $semesters = Semester::whereIn('id',Session::get('semesters_ids'))->get();
242
+// var_dump($semesters);
243
+// exit();
244
+        $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
245
+        $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
27 246
 
28 247
 
29 248
         /**
@@ -85,41 +304,57 @@ class SchoolsController extends \BaseController
85 304
          * Calculate how many sections are doing assessment
86 305
          */
87 306
 
88
-        $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
89
-        $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
307
+//         $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
308
+//         $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
90 309
         $undergrad_assessed_sections_count = 0;
91 310
         $undergrad_school_sections_count = 0;
92 311
 
93
-        $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
94
-        $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
312
+//         $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
313
+//         $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
95 314
         $grad_assessed_sections_count = 0;
96 315
         $grad_school_sections_count = 0;
97 316
 
98 317
         foreach ($school->programs as $program) {
99 318
             foreach ($program->courses as $course) {
100
-                if (!$course->program->is_graduate) {
101
-                    if ($course->outcomes_achieved != NULL) {
102
-                        $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
103
-                        $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
104
-                        for ($i = 1; $i <= count($undergrad_outcomes_attempted); $i++) {
105
-                            $undergrad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
106
-                            $undergrad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
107
-                        }
108
-                        $undergrad_assessed_sections_count += 1;
109
-                    }
110
-                    $undergrad_school_sections_count += 1;
111
-                } else {
112
-                    if ($course->outcomes_achieved != NULL) {
113
-                        $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
114
-                        $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
115
-                        for ($i = 1; $i <= count($grad_outcomes_attempted); $i++) {
116
-                            $grad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
117
-                            $grad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
118
-                        }
119
-                        $grad_assessed_sections_count += 1;
120
-                    }
121
-                    $grad_school_sections_count += 1;
122
-                }
319
+//             	            Log::info("aqui".$course);
320
+
321
+            if (!$course->program->is_graduate){
322
+                $undergrad_school_sections_count += 1;
323
+            	if($course->isAssessed())$undergrad_assessed_sections_count += 1;
324
+//             	            Log::info("aqui".$course);
325
+
326
+            }
327
+            else {
328
+                $grad_school_sections_count += 1;
329
+            	if($course->isAssessed())$grad_assessed_sections_count += 1;
330
+//             	            	            Log::info("aqui".$course);
331
+
332
+            }
333
+
334
+//                 if (!$course->program->is_graduate) {
335
+//                     if ($course->outcomes_achieved != NULL) {
336
+//                         $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
337
+//                         $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
338
+//                         for ($i = 1; $i <= count($undergrad_outcomes_attempted); $i++) {
339
+//                             $undergrad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
340
+//                             $undergrad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
341
+//                         }
342
+//                         $undergrad_assessed_sections_count += 1;
343
+//                     }
344
+//                     $undergrad_school_sections_count += 1;
345
+//                 } else {
346
+//                     if ($course->outcomes_achieved != NULL) {
347
+//                         $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
348
+//                         $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
349
+//                         for ($i = 1; $i <= count($grad_outcomes_attempted); $i++) {
350
+//                             $grad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
351
+//                             $grad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
352
+//                         }
353
+//                         $grad_assessed_sections_count += 1;
354
+//                     }
355
+//                     $grad_school_sections_count += 1;
356
+//                 }
357
+                
123 358
             }
124 359
         }
125 360
 
@@ -128,27 +363,50 @@ class SchoolsController extends \BaseController
128 363
          */
129 364
 
130 365
         // Number of programs that achieved a particular learning outcome
131
-        $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
366
+//         $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
132 367
 
133 368
         // Number of programs that attempted a particular learning outcome
134
-        $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
369
+//         $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
135 370
 
136 371
         // Fetch programs with participation for the school
137
-        $participating_undergrad_programs = DB::table('programs')
138
-            ->join('courses', 'courses.program_id', '=', 'programs.id')
139
-            ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
140
-            ->addSelect('courses.semester_id')
141
-            ->whereIn('semester_id', Session::get('semesters_ids'))
142
-            ->where('is_graduate', 0)
143
-            ->where('school_id', $school->id)
144
-            ->groupBy('id')
145
-            ->get();
372
+//         $participating_undergrad_programs = DB::table('programs')
373
+//             ->join('courses', 'courses.program_id', '=', 'programs.id')
374
+//             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
375
+//             ->addSelect('courses.semester_id')
376
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
377
+//             ->where('is_graduate', 0)
378
+//             ->where('school_id', $school->id)
379
+//             ->groupBy('id')
380
+//             ->get();
146 381
 
147 382
         $output = array();
148 383
 
149 384
 
150 385
         // For each outcome 
151
-        foreach ($outcomes as $outcome) {
386
+        foreach ($outcomes_undergrad as $outcome) {
387
+//         	$attempted_outcomes_per_undergrad_program[$outcome->id]=0;
388
+        	$achieved_outcomes_per_undergrad_program[$outcome->id]=0;
389
+        	$attemptedUndergradProgramsPerOutcome[$outcome->id]=0;
390
+        	$achievedUndergradProgramsPerOutcome[$outcome->id]=0;
391
+        	$programs_attempted_in_school[$outcome->id]=$outcome->programs_attempted_in_school($semesters, $school->id);
392
+//         	var_dump($programs_attempted_in_school);exit();
393
+        	foreach($programs_attempted_in_school[$outcome->id] as $program_id)
394
+        	{
395
+//         		var_dump($program_id->id);exit();
396
+				$program = DB::table('programs')
397
+                        ->where('id', '=', $program_id->id)
398
+                        ->first();
399
+//         		$program=Program::where('id', $program_id->id);
400
+//         		var_dump($program);exit();
401
+        		if(!$program->is_graduate)
402
+        		{
403
+        			$attemptedUndergradProgramsPerOutcome[$outcome->id]++;
404
+        			
405
+        		}
406
+        	}
407
+ 			$undergrad_outcomes_attempted[$outcome->id]=$outcome->attempted_by_school($semesters, $school->id,0);
408
+ 			$undergrad_outcomes_achieved[$outcome->id]=$outcome->achieved_by_school($semesters, $school->id,0);
409
+ 			
152 410
             // For each program with courses that do assessment
153 411
             $programs_with_courses = Program::with(array('courses' => function ($query) {
154 412
                 //                 $query->whereNotNull('outcomes_attempted');
@@ -156,43 +414,46 @@ class SchoolsController extends \BaseController
156 414
             }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
157 415
 
158 416
             foreach ($programs_with_courses as $program) {
417
+            if(in_array($program->id,$participating_programs)){
159 418
                 // To acummulate all criteria for one program
160
-                $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
161
-                $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
419
+//                 $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
420
+//                 $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
162 421
 
163 422
                 //Flag for counting programs
164 423
                 $flag = false;
165 424
 
166 425
                 // For each course in the program
167
-                foreach ($program->courses as $course) {
168
-                    // If the outcome in question is being evaluated
169
-                    $course_outcomes_attempted2 = $course->outcomes_att();
170
-                    //                     $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
171
-                    //                     $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
172
-                    $course_outcomes_achieved2 = $course->outcomes_ach();
173
-                    if (
174
-                        array_key_exists($outcome->id, $course_outcomes_attempted2) && array_key_exists($outcome->id, $course_outcomes_achieved2)
175
-                        && $course_outcomes_attempted2[$outcome->id] > 0
176
-                    ) {
177
-                        $achieved_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
178
-                        $attempted_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
179
-
180
-                        // Add one to the programs assessing, if it wasn't added before
181
-                        if (!$flag) {
182
-                            $attemptedUndergradProgramsPerOutcome[$outcome->id] += 1;
183
-                            $flag = true;
184
-                        }
185
-                    }
186
-
187
-                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
188
-                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
189
-
190
-                }
426
+ //                foreach ($program->courses as $course) {
427
+//                 if($course->isAssessed()){
428
+//                     // If the outcome in question is being evaluated
429
+//                     $course_outcomes_attempted2 = $course->outcomes_att();
430
+//                     //                     $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
431
+//                     //                     $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
432
+//                     $course_outcomes_achieved2 = $course->outcomes_ach();
433
+//                     if (
434
+//                         array_key_exists($outcome->id, $course_outcomes_attempted2) && array_key_exists($outcome->id, $course_outcomes_achieved2)
435
+//                         && $course_outcomes_attempted2[$outcome->id] > 0
436
+//                     ) {
437
+//                         $achieved_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
438
+// //                         $attempted_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
439
+// 
440
+//                         // Add one to the programs assessing, if it wasn't added before
441
+//                         if (!$flag) {
442
+//                             $attemptedUndergradProgramsPerOutcome[$outcome->id] += 1;
443
+//                             $flag = true;
444
+//                         }
445
+//                     }
446
+// 
447
+//                     // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
448
+//                     // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
449
+// 				}
450
+//                 }
191 451
                 //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
192
-                if ($attempted_outcomes_per_undergrad_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_undergrad_program[$outcome->id] / $attempted_outcomes_per_undergrad_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
193
-                    $achievedUndergradProgramsPerOutcome[$outcome->id] += 1;
194
-                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
195
-                }
452
+//                 if ($attempted_outcomes_per_undergrad_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_undergrad_program[$outcome->id] / $attempted_outcomes_per_undergrad_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
453
+//                     $achievedUndergradProgramsPerOutcome[$outcome->id] += 1;
454
+//                     // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
455
+//                 }
456
+            }
196 457
             }
197 458
         }
198 459
 
@@ -201,43 +462,65 @@ class SchoolsController extends \BaseController
201 462
          */
202 463
 
203 464
         // Number of programs that achieved a particular learning outcome
204
-        $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
465
+//         $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
205 466
 
206 467
         // Number of programs that attempted a particular learning outcome
207
-        $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
208
-
468
+//         $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
469
+// 
209 470
         // Fetch programs with participation for the school
210
-        $participating_grad_programs = DB::table('programs')
211
-            ->join('courses', 'courses.program_id', '=', 'programs.id')
212
-            ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
213
-            ->addSelect('courses.semester_id')
214
-            ->whereIn('semester_id', Session::get('semesters_ids'))
215
-            ->where('is_graduate', 1)
216
-            ->where('school_id', $school->id)
217
-            ->groupBy('id')
218
-            ->get();
471
+//         $participating_grad_programs = DB::table('programs')
472
+//             ->join('courses', 'courses.program_id', '=', 'programs.id')
473
+//             ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
474
+//             ->addSelect('courses.semester_id')
475
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
476
+//             ->where('is_graduate', 1)
477
+//             ->where('school_id', $school->id)
478
+//             ->groupBy('id')
479
+//             ->get();
219 480
 
220 481
         $output = array();
221 482
 
222 483
 
223 484
         // For each outcome 
224
-        foreach ($outcomes as $outcome) {
225
-            // For each program with courses that do assessment
485
+        foreach ($outcomes_grad as $outcome) {
486
+//         	$attempted_outcomes_per_grad_program[$outcome->id]=0;
487
+        	$achieved_outcomes_per_grad_program[$outcome->id]=0;
488
+        	$attemptedGradProgramsPerOutcome[$outcome->id]=0;
489
+        	$achievedGradProgramsPerOutcome[$outcome->id]=0;
490
+ 			$grad_outcomes_attempted[$outcome->id]=$outcome->attempted_by_school($semesters, $school->id,1);
491
+ 			$grad_outcomes_achieved[$outcome->id]=$outcome->achieved_by_school($semesters, $school->id,1);
492
+           // For each program with courses that do assessment
493
+        	foreach($programs_attempted_in_school[$outcome->id] as $program_id)
494
+        	{
495
+//         		var_dump($program_id->id);exit();
496
+				$program = DB::table('programs')
497
+                        ->where('id', '=', $program_id->id)
498
+                        ->first();
499
+//         		$program=Program::where('id', $program_id->id);
500
+//         		var_dump($program);exit();
501
+        		if($program->is_graduate)
502
+        		{
503
+        			$attemptedGradProgramsPerOutcome[$outcome->id]++;
504
+        			
505
+        		}
506
+        	}
226 507
             $programs_with_courses = Program::with(array('courses' => function ($query) {
227 508
                 //                 $query->whereNotNull('outcomes_attempted');
228 509
                 $query->whereIn('semester_id', Session::get('semesters_ids'));
229 510
             }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
230 511
 
231 512
             foreach ($programs_with_courses as $program) {
232
-                // To acummulate all criteria for one program
233
-                $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
234
-                $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
513
+             if(in_array($program->id,$participating_programs)){
514
+               // To acummulate all criteria for one program
515
+//                 $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
516
+//                 $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
235 517
 
236 518
                 //Flag for counting programs
237 519
                 $flag = false;
238 520
 
239 521
                 // For each course in the program
240 522
                 foreach ($program->courses as $course) {
523
+                if($course->isAssessed()){
241 524
                     // If the outcome in question is being evaluated
242 525
                     //                     $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
243 526
                     $course_outcomes_attempted2 = ($course->outcomes_att());
@@ -259,19 +542,22 @@ class SchoolsController extends \BaseController
259 542
 
260 543
                     // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
261 544
                     // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
262
-
545
+			}
263 546
                 }
264 547
                 //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
265 548
                 if ($attempted_outcomes_per_grad_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_grad_program[$outcome->id] / $attempted_outcomes_per_grad_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
266 549
                     $achievedGradProgramsPerOutcome[$outcome->id] += 1;
267 550
                     // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
268 551
                 }
552
+           }
269 553
             }
270 554
         }
271 555
         if ($school->id == 13) {
272
-            return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
556
+//             return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
557
+            return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
273 558
         } else {
274
-            return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
559
+//             return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
560
+            return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
275 561
         }
276 562
     }
277 563
 

+ 12
- 0
app/models/Course.php Целия файл

@@ -361,6 +361,18 @@ class Course extends Eloquent
361 361
     return $all_sections;
362 362
   }
363 363
 
364
+    public function isAssessed()
365
+    {
366
+         $assessed = DB::table('assessments')
367
+            ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
368
+            ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
369
+             ->where('activities.course_id', $this->id)
370
+            ->count();
371
+//             Log::info("aqui".$assessed);
372
+
373
+   		if($assessed)return true;
374
+   		else return false;
375
+    }
364 376
 
365 377
 
366 378
   public function outcomes_achieved()

+ 238
- 0
app/models/Outcome.php Целия файл

@@ -154,6 +154,40 @@ class Outcome extends Eloquent
154 154
 		return $programs;
155 155
 	}
156 156
 
157
+	public function programs_attempted_in_school($semesters, $school_id)
158
+	{
159
+		$semesters_array = [];
160
+		foreach ($semesters as $semester) {
161
+			$semesters_array[] = $semester->id;
162
+		}
163
+		// 		 $programs=DB::table('programs')
164
+		// 	    	->join('courses', 'programs.id', '=', 'courses.program_id')
165
+		// 	    	->join('activities', 'activities.course_id', '=', 'courses.id')
166
+		// 	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
167
+		// 	    	->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
168
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
169
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
170
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
171
+		// 	    	->distinct()
172
+		// 	    	->select('programs.id')
173
+		// 	    	->get()
174
+		// 			;
175
+		$programs = DB::table('programs')
176
+			->join('courses', 'programs.id', '=', 'courses.program_id')
177
+			->join('activities', 'activities.course_id', '=', 'courses.id')
178
+			->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
179
+			->join('criteria', 'activity_criterion.criterion_id', '=', 'criteria.id')
180
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
181
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
182
+			->where('programs.school_id', '=', $school_id)
183
+			->whereIn('courses.semester_id', $semesters_array)
184
+			->distinct()
185
+			->select('programs.id')
186
+			->get();
187
+
188
+		return $programs;
189
+	}
190
+
157 191
 	public function attempted($semesters, $is_grad)
158 192
 	{
159 193
 		$semesters_array = [];
@@ -187,6 +221,101 @@ class Outcome extends Eloquent
187 221
 			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
188 222
 			->distinct()
189 223
 			->get();
224
+			
225
+		$conteo = 0;
226
+		foreach ($criteria as $criterion) {
227
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
228
+			if ($students_attempted) {
229
+				$conteo++;
230
+			}
231
+		}
232
+		// 		var_dump($conteo);
233
+		// 		exit();
234
+		return $conteo;
235
+	}
236
+
237
+	public function attempted_by_school($semesters, $school_id, $is_grad)
238
+	{
239
+		$semesters_array = [];
240
+		foreach ($semesters as $semester) {
241
+			$semesters_array[] = $semester->id;
242
+		}
243
+		// 		 $criteria=DB::table('new_criteria')
244
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
245
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
246
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
247
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
248
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
249
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
250
+		// 	    	->where('programs.is_graduate','=',$is_grad)
251
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
252
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
253
+		// 	    	->distinct()
254
+		// 	    	->get()
255
+		// 			;
256
+		$criteria = DB::table('criteria')
257
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
258
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
259
+			->join('courses', 'activities.course_id', '=', 'courses.id')
260
+			->join('programs', 'programs.id', '=', 'courses.program_id')
261
+			->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
262
+			->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
263
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
264
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
265
+			->where('programs.is_graduate', '=', $is_grad)
266
+			->where('programs.school_id', '=', $school_id)
267
+			->whereIn('courses.semester_id', $semesters_array)
268
+			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
269
+			->distinct()
270
+			->get();
271
+			
272
+		$conteo = 0;
273
+		foreach ($criteria as $criterion) {
274
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
275
+			if ($students_attempted) {
276
+				$conteo++;
277
+			}
278
+		}
279
+		// 		var_dump($conteo);
280
+		// 		exit();
281
+		return $conteo;
282
+	}
283
+
284
+	public function attempted_by_program($semesters, $program_id, $is_grad)
285
+	{
286
+		$semesters_array = [];
287
+		foreach ($semesters as $semester) {
288
+			$semesters_array[] = $semester->id;
289
+		}
290
+		// 		 $criteria=DB::table('new_criteria')
291
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
292
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
293
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
294
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
295
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
296
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
297
+		// 	    	->where('programs.is_graduate','=',$is_grad)
298
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
299
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
300
+		// 	    	->distinct()
301
+		// 	    	->get()
302
+		// 			;
303
+		$criteria = DB::table('criteria')
304
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
305
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
306
+			->join('courses', 'activities.course_id', '=', 'courses.id')
307
+			->join('programs', 'programs.id', '=', 'courses.program_id')
308
+			->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
309
+			->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
310
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
311
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
312
+			->where('programs.is_graduate', '=', $is_grad)
313
+			->where('programs.id', '=', $program_id)
314
+			->whereIn('courses.semester_id', $semesters_array)
315
+			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
316
+			->distinct()
317
+			->get();
318
+			
190 319
 		$conteo = 0;
191 320
 		foreach ($criteria as $criterion) {
192 321
 			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
@@ -348,6 +477,115 @@ class Outcome extends Eloquent
348 477
 		return $conteo;
349 478
 	}
350 479
 
480
+	public function achieved_by_school($semesters, $school_id, $is_grad)
481
+	{
482
+		$semesters_array = [];
483
+		foreach ($semesters as $semester) {
484
+			$semesters_array[] = $semester->id;
485
+		}
486
+
487
+		//   DB::enableQueryLog();
488
+		// 		 $criteria=DB::table('new_criteria')
489
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
490
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
491
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
492
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
493
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
494
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
495
+		// 	    	->where('programs.is_graduate','=',$is_grad)
496
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
497
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
498
+		// 	    	->distinct()
499
+		// 	    	->get()
500
+		// 			;
501
+		$criteria = DB::table('criteria')
502
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
503
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
504
+			->join('courses', 'activities.course_id', '=', 'courses.id')
505
+			->join('programs', 'programs.id', '=', 'courses.program_id')
506
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
507
+			->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
508
+			->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
509
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
510
+			->where('programs.is_graduate', '=', $is_grad)
511
+			->where('programs.school_id', '=', $school_id)
512
+			->whereIn('courses.semester_id', $semesters_array)
513
+			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
514
+			->distinct()
515
+			->get();
516
+		// 		dd(DB::getQueryLog());
517
+
518
+		$conteo = 0;
519
+		foreach ($criteria as $criterion) {
520
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
521
+			$students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
522
+
523
+			if ($students_attempted) {
524
+				$percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
525
+			} else {
526
+				$percentage_students_who_achieved = 0;
527
+			}
528
+			if ($percentage_students_who_achieved >= $criterion->expected_percentage) {
529
+				$conteo++;
530
+			}
531
+		}
532
+		return $conteo;
533
+	}
534
+
535
+	public function achieved_by_program($semesters, $program_id, $is_grad)
536
+	{
537
+		$semesters_array = [];
538
+		foreach ($semesters as $semester) {
539
+			$semesters_array[] = $semester->id;
540
+		}
541
+
542
+		//   DB::enableQueryLog();
543
+		// 		 $criteria=DB::table('new_criteria')
544
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
545
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
546
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
547
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
548
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
549
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
550
+		// 	    	->where('programs.is_graduate','=',$is_grad)
551
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
552
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
553
+		// 	    	->distinct()
554
+		// 	    	->get()
555
+		// 			;
556
+		$criteria = DB::table('criteria')
557
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
558
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
559
+			->join('courses', 'activities.course_id', '=', 'courses.id')
560
+			->join('programs', 'programs.id', '=', 'courses.program_id')
561
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
562
+			->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
563
+			->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
564
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
565
+			->where('programs.is_graduate', '=', $is_grad)
566
+			->where('programs.school_.semester_id', $semesters_array)
567
+			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
568
+			->distinct()
569
+			->get();
570
+		// 		dd(DB::getQueryLog());
571
+
572
+		$conteo = 0;
573
+		foreach ($criteria as $criterion) {
574
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
575
+			$students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
576
+
577
+			if ($students_attempted) {
578
+				$percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
579
+			} else {
580
+				$percentage_students_who_achieved = 0;
581
+			}
582
+			if ($percentage_students_who_achieved >= $criterion->expected_percentage) {
583
+				$conteo++;
584
+			}
585
+		}
586
+		return $conteo;
587
+	}
588
+
351 589
 
352 590
 	// 	public function achieved($semester, $is_grad)
353 591
 	// 	{

+ 4
- 2
app/views/global/view-three-year-plan.blade.php Целия файл

@@ -577,7 +577,8 @@ $('.go-to-temp').on('click', function(){
577 577
             var area = $('.courses-section-0').clone(true);
578 578
             area.attr('class','');
579 579
 
580
-            var title = 'Outcome: ' + outcome_name;
580
+            var title = outcome_name;
581
+<!--             var title = 'Outcome: ' + outcome_name; -->
581 582
             var title_area = $('.title-course-selection-0').clone(true);
582 583
             title_area.attr('class','title-course-selection h3');
583 584
             title_area.find('p').html(title);
@@ -704,7 +705,8 @@ $('.go-to-temp').on('click', function(){
704 705
             var area = $('.courses-section-0').clone(true);
705 706
             area.attr('class','');
706 707
 
707
-            var title = 'Outcome: ' + outcome_name;
708
+<!--             var title = 'Outcome: ' + outcome_name; -->
709
+            var title = outcome_name;
708 710
             var title_area = $('.title-course-selection-0').clone(true);
709 711
             title_area.attr('class','title-course-selection h3');
710 712
             title_area.find('p').html(title);

+ 1
- 1
app/views/local/managers/admins/_navigation.blade.php Целия файл

@@ -61,7 +61,7 @@
61 61
                     <li>{{ HTML::linkAction('OutcomesController@totalAssessmentReport', 'Total Assessment Reports') }}
62 62
                     </li>
63 63
                     @if (count(Auth::user()->courses))
64
-                        <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}
64
+                        <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReport', 'My Courses\' Reports') }}
65 65
                         </li>
66 66
 
67 67
                     @endif

+ 1
- 1
app/views/local/managers/admins/assessment_report.blade.php Целия файл

@@ -178,7 +178,7 @@ Log::info($activity->rubric[0]);
178 178
                                                             @endif
179 179
                                                         </p>
180 180
 
181
-                                                        <h5><strong>Transforming Actions</strong></h5>
181
+                                                        <h5><strong>Transformative Actions</strong></h5>
182 182
                                                         @if($activity->transforming_actions)
183 183
                                                             {{ $activity->transforming_actions }}
184 184
                                                         @else

+ 1
- 1
app/views/local/managers/admins/new-activity-create.blade.php Целия файл

@@ -104,7 +104,7 @@
104 104
                         <button type="button" data-toggle="modal" data-target="#newRubricModal" class="btn btn-sm btn-default">New Instrument</button>
105 105
                     </div>
106 106
                     <div class="form-group">
107
-                        {{ Form::label('transforming_action', 'Transforming Actions') }}
107
+                        {{ Form::label('transforming_action', 'Transformative Actions') }}
108 108
                         <select id="transforming_action" name="transforming_action[]" class="form-control" multiple>
109 109
                             @foreach ($transforming_actions as $transforming_action)
110 110
 {{--                                @if(Input::old('transforming_action')!=$transforming_action->id)--}}

+ 1
- 1
app/views/local/managers/admins/overview2.blade.php Целия файл

@@ -1,4 +1,4 @@
1
-@extends('layouts.master')
1
+@extends('layouts.master_sin_semesterbar')
2 2
 
3 3
 @section('navigation')
4 4
 @include('local.managers.admins._navigation')

+ 1
- 1
app/views/local/managers/pCoords/assessment_report.blade.php Целия файл

@@ -136,7 +136,7 @@
136 136
                                                         @endif
137 137
                                                         </p>
138 138
 
139
-                                                        <h5><strong>Transforming Actions</strong></h5>
139
+                                                        <h5><strong>Transformative Actions</strong></h5>
140 140
                                                         @if($activity->transforming_actions)
141 141
                                                             {{ $activity->transforming_actions }}
142 142
                                                         @else

+ 1
- 1
app/views/local/managers/sCoords/assessment_report.blade.php Целия файл

@@ -170,7 +170,7 @@
170 170
                                                                 @endif
171 171
                                                             </p>
172 172
 
173
-                                                            <h5><strong>Transforming Actions</strong></h5>
173
+                                                            <h5><strong>Transformative Actions</strong></h5>
174 174
                                                             @if ($activity->transforming_actions)
175 175
                                                                 {{ $activity->transforming_actions }}
176 176
                                                             @else

+ 1
- 1
app/views/local/managers/shared/assessment_report_backup.blade.php Целия файл

@@ -119,7 +119,7 @@
119 119
                                                 @endif
120 120
                                                 </p>
121 121
 
122
-                                                <h5>Transforming Actions</h5>
122
+                                                <h5>Transformative Actions</h5>
123 123
                                                 @if($activity->transforming_actions)
124 124
                                                     {{ $activity->transforming_actions }}
125 125
                                                 @else

+ 2
- 2
app/views/local/managers/shared/grouped_course.blade.php Целия файл

@@ -55,13 +55,13 @@
55 55
         </table>
56 56
     </div>
57 57
     <div class="col-md-7">
58
-        <h3>Transforming Action Overview</h3>
58
+        <h3>Transformative Action Overview</h3>
59 59
         <table class="table table-striped table-condensed">
60 60
             <thead>
61 61
                 <tr>
62 62
                     <th>Activity</th>
63 63
                     <th>Section</th>
64
-                    <th>Transforming Action</th>
64
+                    <th>Transformative Action</th>
65 65
                     <th>Comments</th>
66 66
                 </tr>
67 67
             </thead>

+ 1
- 1
app/views/local/managers/shared/limited-course.blade.php Целия файл

@@ -85,7 +85,7 @@
85 85
                             <th>Name</th>
86 86
                             <th>Date</th>
87 87
                             <th>Rubric</th>
88
-                            <th>Transforming Action</th>
88
+                            <th>Transformative Action</th>
89 89
                         </tr>
90 90
                     </thead>
91 91
                     <tbody>

+ 2
- 2
app/views/local/managers/shared/print_course.blade.php Целия файл

@@ -49,13 +49,13 @@
49 49
     </tbody>
50 50
 </table>
51 51
 
52
-<h3>Transforming Action Overview</h3>
52
+<h3>Transformative Action Overview</h3>
53 53
 <table>
54 54
     <thead>
55 55
         <tr>
56 56
             <th class="col-md-3">Activity</th>
57 57
             <th class="col-md-1">Section</th>
58
-            <th class="col-md-8">Transforming Action</th>
58
+            <th class="col-md-8">Transformative Action</th>
59 59
         </tr>
60 60
     </thead>
61 61
     <tbody>

+ 15
- 11
app/views/local/managers/shared/school.blade.php Целия файл

@@ -75,7 +75,7 @@
75 75
                                     <th>Success Rate</th>
76 76
                                 </thead>
77 77
                                 <tbody>
78
-                                    @foreach($outcomes as $outcome)
78
+                                    @foreach($outcomes_undergrad as $outcome)
79 79
                                         <tr>
80 80
                                             <td class="col-md-6">{{ link_to_action('OutcomesController@show', $outcome->name, array($outcome->id), $attributes = array()) }}</td>
81 81
                                             <td class="col-md-2">{{{ $attemptedUndergradProgramsPerOutcome[$outcome->id] }}}</td>
@@ -180,6 +180,7 @@
180 180
                                     <tbody>
181 181
                                         @foreach($school->programs as $program)
182 182
                                             @foreach($program->courses as $course)
183
+                                            	@if(!$course->program->is_graduate)
183 184
                                             <tr>
184 185
                                                 <td class="col-md-2">{{ HTML::linkAction('CoursesController@showLimited', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</td>
185 186
                                                 <td class="col-md-3">{{{ $course->name}}}</td>
@@ -200,6 +201,7 @@
200 201
                                                     @endif
201 202
                                                 </td>
202 203
                                             </tr>
204
+                                            @endif
203 205
                                             @endforeach
204 206
                                         @endforeach
205 207
                                     </tbody>
@@ -268,7 +270,7 @@
268 270
                                     <th>Success Rate</th>
269 271
                                 </thead>
270 272
                                 <tbody>
271
-                                    @foreach($outcomes as $outcome)
273
+                                    @foreach($outcomes_grad as $outcome)
272 274
                                         <tr>
273 275
                                             <td class="col-md-6">{{ link_to_action('OutcomesController@show', $outcome->name, array($outcome->id), $attributes = array()) }}</td>
274 276
                                             <td class="col-md-2">{{{ $attemptedGradProgramsPerOutcome[$outcome->id] }}}</td>
@@ -373,6 +375,7 @@
373 375
                                     <tbody>
374 376
                                         @foreach($school->programs as $program)
375 377
                                             @foreach($program->courses as $course)
378
+                                            	@if($course->program->is_graduate)
376 379
                                             <tr>
377 380
                                                 <td class="col-md-2">{{ HTML::linkAction('CoursesController@showLimited', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</td>
378 381
                                                 <td class="col-md-3">{{{ $course->name}}}</td>
@@ -393,6 +396,7 @@
393 396
                                                     @endif
394 397
                                                 </td>
395 398
                                             </tr>
399
+                                            @endif
396 400
                                             @endforeach
397 401
                                         @endforeach
398 402
                                     </tbody>
@@ -451,7 +455,7 @@ $(function () {
451 455
             },
452 456
             xAxis: {
453 457
                 categories: [
454
-                    @foreach($outcomes as $outcome)
458
+                    @foreach($outcomes_undergrad as $outcome)
455 459
                         "{{{ $outcome->name }}}",
456 460
                     @endforeach
457 461
                 ],
@@ -507,7 +511,7 @@ $(function () {
507 511
                     y:-1
508 512
                 },
509 513
                 data: [
510
-                    @foreach($outcomes as $index => $outcome)
514
+                    @foreach($outcomes_undergrad as $index => $outcome)
511 515
                         @if(
512 516
                             is_array($undergrad_outcomes_attempted)
513 517
                             && array_key_exists($outcome->id, $undergrad_outcomes_attempted)
@@ -534,7 +538,7 @@ $(function () {
534 538
                     y:-1
535 539
                 },
536 540
                 data:[
537
-                    @foreach($outcomes as $index => $outcome)
541
+                    @foreach($outcomes_undergrad as $index => $outcome)
538 542
                         @if(
539 543
                             is_array($undergrad_outcomes_attempted)
540 544
                             && array_key_exists($outcome->id, $undergrad_outcomes_attempted)
@@ -561,7 +565,7 @@ $(function () {
561 565
             },
562 566
             xAxis: {
563 567
                 categories: [
564
-                    @foreach($outcomes as $outcome)
568
+                    @foreach($outcomes_grad as $outcome)
565 569
                         "{{{ $outcome->name }}}",
566 570
                     @endforeach
567 571
                 ],
@@ -617,7 +621,7 @@ $(function () {
617 621
                     y:-1
618 622
                 },
619 623
                 data: [
620
-                    @foreach($outcomes as $index => $outcome)
624
+                    @foreach($outcomes_grad as $index => $outcome)
621 625
                         @if(
622 626
                             is_array($grad_outcomes_attempted)
623 627
                             && array_key_exists($outcome->id, $grad_outcomes_attempted)
@@ -644,7 +648,7 @@ $(function () {
644 648
                     y:-1
645 649
                 },
646 650
                 data:[
647
-                    @foreach($outcomes as $index => $outcome)
651
+                    @foreach($outcomes_grad as $index => $outcome)
648 652
                         @if(
649 653
                             is_array($grad_outcomes_attempted)
650 654
                             && array_key_exists($outcome->id, $grad_outcomes_attempted)
@@ -672,7 +676,7 @@ $(function () {
672 676
             },
673 677
             xAxis: {
674 678
                 categories: [
675
-                    @foreach($outcomes as $outcome)
679
+                    @foreach($outcomes_undergrad as $outcome)
676 680
                         "{{{ $outcome->name }}}",
677 681
                     @endforeach
678 682
                 ],
@@ -728,7 +732,7 @@ $(function () {
728 732
                     y:-1
729 733
                 },
730 734
                 data: [
731
-                    @foreach($outcomes as $index => $outcome)
735
+                    @foreach($outcomes_undergrad as $index => $outcome)
732 736
                         @if(
733 737
                             is_array($undergrad_outcomes_attempted)
734 738
                             && array_key_exists($outcome->id, $undergrad_outcomes_attempted)
@@ -755,7 +759,7 @@ $(function () {
755 759
                     y:-1
756 760
                 },
757 761
                 data:[
758
-                    @foreach($outcomes as $index => $outcome)
762
+                    @foreach($outcomes_undergrad as $index => $outcome)
759 763
                         @if(
760 764
                             is_array($undergrad_outcomes_attempted)
761 765
                             && array_key_exists($outcome->id, $undergrad_outcomes_attempted)

+ 5
- 5
app/views/local/professors/activity.blade.php Целия файл

@@ -58,13 +58,13 @@
58 58
     <div class="modal-content">
59 59
       <div class="modal-header">
60 60
         <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
61
-        <h4 class="modal-title">Edit Transforming Actions</h4>
61
+        <h4 class="modal-title">Edit Formative Actions</h4>
62 62
       </div>
63 63
         <div class="modal-body">
64 64
             {{ Form::open(array('action' => array('TransformativeActionsController@postActivityCriterion', $activity->id))) }}
65 65
                                   
66 66
 
67
-                <p>A Transforming Action is the educational action to be taken to address the criteria of an unachieved Learning Outcome.</p>
67
+                <p>A Formative Action is the educational action to be taken to address the criteria of an unachieved Learning Outcome.</p>
68 68
                 <p>Una acción transformadora es una acción educativa a tomarse para atender el o los criterios de un dominio dado que no se alcanzaron.</p>
69 69
 
70 70
                 <h5>Choose criteria for the transforming action <br>
@@ -93,12 +93,12 @@
93 93
                 <hr>
94 94
                 
95 95
                 <div class ="form-group">
96
-                    {{ Form::label('name_trans', 'Name of Transforming Actions')}}
96
+                    {{ Form::label('name_trans', 'Name of Formative Actions')}}
97 97
                     {{ Form::text('name_trans', '', array('class' => 'form-control')) }}
98 98
                 </div>
99 99
                 
100 100
                 <div class="form-group">
101
-                    {{ Form::label('transforming_actions', 'Transforming Actions') }}
101
+                    {{ Form::label('transforming_actions', 'Formative Actions') }}
102 102
                     {{ Form::textarea('transforming_actions', $activity->transforming_actions, array('class' => 'form-control', 'rows'=> 4, 'placeholder'=>'Actions to improve student performance after assessment (optional)')) }}
103 103
                 </div>
104 104
         </div>
@@ -219,7 +219,7 @@
219 219
                     
220 220
                         {{ HTML::linkAction('ActivitiesController@assess', 'Edit Assessment', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
221 221
                         <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-confirm-delete-assessment">Delete Assessment</button>
222
-                        <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-edit-transforming-actions">Transforming Actions</button>
222
+                        <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-edit-transforming-actions">Formative Actions</button>
223 223
                         <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-edit-assessment-comments">Assessment Comments</button>
224 224
 
225 225
                     @endif