Browse Source

9/17/2021, arreglos a cosas previamente hechas

parent
commit
f72d1bda10

+ 4
- 0
app/controllers/ActivitiesController.php View File

@@ -48,6 +48,10 @@ class ActivitiesController extends \BaseController
48 48
             $activity->name = Input::get('name');
49 49
             $activity->description = Input::get('description');
50 50
             $activity->course_id = $id;
51
+
52
+            // Gabriel añadió aquí
53
+            $activity->draft = 1;
54
+            //
51 55
             $activity->date = date('Y-m-d');
52 56
 
53 57
             /** If activity is saved, send success message */

+ 248
- 274
app/controllers/CoursesController.php View File

@@ -1,268 +1,272 @@
1 1
 <?php
2 2
 
3 3
 class
4
-CoursesController extends \BaseController {
5
-
6
-	/**
7
-	 * Display the specified resource.
8
-	 *
9
-	 * @param  int  $id
10
-	 * @return Response
11
-	 */
12
-	public function show($id)
13
-	{
14
-
15
-		$course = Course::with('semester')->where('id', $id)->first();
16
-		$title=$course->code.$course->number.'-'.$course->section.' <span class="small attention">('.$course->semester->code.')</span>';
17
-
18
-		// If course does not exist, display 404
19
-		if(!$course)
4
+CoursesController extends \BaseController
5
+{
6
+
7
+    /**
8
+     * Display the specified resource.
9
+     *
10
+     * @param  int  $id
11
+     * @return Response
12
+     */
13
+    public function show($id)
14
+    {
15
+
16
+        $course = Course::with('semester')->where('id', $id)->first();
17
+        $title = $course->code . $course->number . '-' . $course->section . ' <span class="small attention">(' . $course->semester->code . ')</span>';
18
+
19
+        // If course does not exist, display 404
20
+        if (!$course)
20 21
             App::abort('404');
21 22
 
22 23
         // If course does not belong to the person
23 24
         if ($course->user_id != Auth::id())
24
-        	App::abort('403', 'Access forbidden.');
25
+            App::abort('403', 'Access forbidden.');
26
+
27
+        $activities = $course->activities;
28
+        $students = $course->students;
25 29
 
26
-		$activities = $course->activities;
27
-		$students = $course->students;
30
+        //$outcomes = Outcome::orderBy('name', 'asc')->get();
31
+        $semesters = Session::get('semesters_ids');
32
+        $semesters = DB::table('semesters')->where('id', $course->semester_id)->orderBy('start', 'ASC')->first();
28 33
 
29
-		$outcomes = Outcome::orderBy('name', 'asc')->get();
30
-		$outcomes_achieved = json_decode($course->outcomes_achieved, true);
31
-        $outcomes_attempted = json_decode($course->outcomes_attempted, true);
34
+        $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
35
+            ->whereNull('deleted_at')
36
+            ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
37
+            ->orderBy('name', 'ASC')->get();
38
+        $outcomes_achieved = $course->outcomes_ach();
39
+        // $outcomes_attempted = json_decode($course->outcomes_attempted, true);
32 40
 
41
+        $outcomes_attempted = $course->outcomes_att();
33 42
         // Get active semesters
34
-        $active_semesters= array();
43
+        $active_semesters = array();
35 44
         $active_semesters_collection = Semester::select('id')->where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get();
36
-        foreach ($active_semesters_collection as $active_semester)
37
-        {
38
-        	$active_semesters[]=$active_semester->id;
45
+        foreach ($active_semesters_collection as $active_semester) {
46
+            $active_semesters[] = $active_semester->id;
39 47
         }
40 48
 
41
-		return View::make('local.professors.course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'active_semesters'));
42
-	}
49
+        return View::make('local.professors.course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'active_semesters'));
50
+    }
43 51
 
44
-	public function newShow($id)
52
+    public function newShow($id)
45 53
     {
46 54
         $course = Course::findOrFail($id);
47 55
         $title = $course->name;
48 56
         $semesters = Semester::where('is_visible', '1')->orderBy('start', 'asc')->get();
49
-        $is_active_semester = $semesters->filter(function($semester) {
57
+        $is_active_semester = $semesters->filter(function ($semester) {
50 58
             return Semester::where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get()->has($semester->id);
51 59
         });
52
-//        $active_semesters = Semester::select('id')->where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get()->toArray()[0];
60
+        //        $active_semesters = Semester::select('id')->where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get()->toArray()[0];
53 61
         $activities = $course->activities;
54 62
 
55
-//        var_dump($active_semesters);
56
-//        var_dump($course->semester->id);
63
+        //        var_dump($active_semesters);
64
+        //        var_dump($course->semester->id);
57 65
 
58
-        return View::make('local.managers.admins.new-course-show', compact('title','course', 'semesters', 'activities', 'is_active_semester'));
66
+        return View::make('local.managers.admins.new-course-show', compact('title', 'course', 'semesters', 'activities', 'is_active_semester'));
59 67
     }
60 68
 
61
-	/**
62
-	 * Display the specified course, but with limited information.
63
-	 *
64
-	 * @param  int  $id
65
-	 * @return Response
66
-	 */
67
-	public function showLimited($id)
68
-	{
69
-		$course = Course::with('semester')->where('id', $id)->first();
70
-		$students = $course->students;
71
-		$title=$course->code.$course->number.'-'.$course->section.' <span class="small attention">('.$course->semester->code.')</span>';
72
-
73
-		// If course does not exist, display 404
74
-		if(!$course)
69
+    /**
70
+     * Display the specified course, but with limited information.
71
+     *
72
+     * @param  int  $id
73
+     * @return Response
74
+     */
75
+    public function showLimited($id)
76
+    {
77
+        $course = Course::with('semester')->where('id', $id)->first();
78
+        $students = $course->students;
79
+        $title = $course->code . $course->number . '-' . $course->section . ' <span class="small attention">(' . $course->semester->code . ')</span>';
80
+
81
+        // If course does not exist, display 404
82
+        if (!$course)
75 83
             App::abort('404');
76 84
 
77
-		$activities = $course->activities;
78
-		$students = $course->students;
79
-
80
-		$level=DB::table('courses')
81
-			->join('programs','programs.id','=','courses.program_id')
82
-			->where('courses.id', $id)
83
-        	->select('programs.is_graduate')
84
-        	->first();
85
-
86
-		$outcomes = Outcome::active_by_semesters(array($course->semester),$level->is_graduate);
87
-// 		$outcomeCount = count((array)$outcomes);
88
-		
89
-		$course = Course::where('id', $id)->first();
90
-		foreach($outcomes as $outcome)
91
-		{
92
-			$outcomes_attempted[$outcome->id]=$outcome->courses_attempted(array($course));
93
-			$outcomes_achieved[$outcome->id]=$outcome->courses_achieved(array($course));
94
-		}
95
-
96
-// 		$outcomes = Outcome::orderBy('name', 'asc')->get();
97
-// 		$outcomes_achieved = json_decode($course->outcomes_achieved, true);
98
-//         $outcomes_attempted = json_decode($course->outcomes_attempted, true);
85
+        $activities = $course->activities;
86
+        $students = $course->students;
87
+
88
+        $level = DB::table('courses')
89
+            ->join('programs', 'programs.id', '=', 'courses.program_id')
90
+            ->where('courses.id', $id)
91
+            ->select('programs.is_graduate')
92
+            ->first();
93
+
94
+        $outcomes = Outcome::active_by_semesters(array($course->semester), $level->is_graduate);
95
+        // 		$outcomeCount = count((array)$outcomes);
96
+
97
+        $course = Course::where('id', $id)->first();
98
+        foreach ($outcomes as $outcome) {
99
+            $outcomes_attempted[$outcome->id] = $outcome->courses_attempted(array($course));
100
+            $outcomes_achieved[$outcome->id] = $outcome->courses_achieved(array($course));
101
+        }
102
+
103
+        // 		$outcomes = Outcome::orderBy('name', 'asc')->get();
104
+        // 		$outcomes_achieved = json_decode($course->outcomes_achieved, true);
105
+        //         $outcomes_attempted = json_decode($course->outcomes_attempted, true);
99 106
 
100 107
         $schools = School::all();
101 108
 
102 109
         $rubrics = array();
103
-        foreach ($activities as $activity )
104
-        {
105
-        	if($activity->rubric_id!=NULL)
106
-    		{
107
-    			$rubrics[]=$activity->rubric;
108
-    		}
110
+        Log::info($activities);
111
+        foreach ($activities as $activity) {
112
+
113
+            if (!empty($activity->rubric)) {
114
+                $rubrics[] = $activity->rubric[0];
115
+            }
109 116
         }
110 117
 
111
-		return View::make('local.managers.shared.limited-course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'schools', 'rubrics', 'students'));
112
-	}
118
+        return View::make('local.managers.shared.limited-course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'schools', 'rubrics', 'students'));
119
+    }
113 120
 
114 121
 
115
-	/**
116
-	 * Show grouped sections of a course
117
-	 */
122
+    /**
123
+     * Show grouped sections of a course
124
+     */
118 125
 
119
-	public function showGrouped($code, $number, $semester_code)
120
-	{
121
-        $title=$code.$number.' ('.$semester_code.')';
126
+    public function showGrouped($code, $number, $semester_code)
127
+    {
128
+        $title = $code . $number . ' (' . $semester_code . ')';
122 129
         $semester = Semester::where('code', $semester_code)->first();
123
-//         $selected_semesters = Semester::find(Session::get('semesters_ids'));
130
+        //         $selected_semesters = Semester::find(Session::get('semesters_ids'));
124 131
         $role = Auth::user()->role;
125
-		$level=DB::table('courses')
126
-			->join('programs','programs.id','=','courses.program_id')
127
-			->where('courses.code', $code)
128
-        	->where('courses.number', $number)
129
-        	->where('courses.semester_id', $semester->id)
130
-        	->select('programs.is_graduate')
131
-        	->first();
132
-//         var_dump($level);
133
-//         exit();
134
-        $grouped_courses = Course::
135
-        	where('code', $code)
136
-        	->where('number', $number)
137
-        	->where('semester_id', $semester->id)
138
-        	->groupBy(array('code', 'number'))->get();
139
-
140
-//         $outcomes = Outcome::orderBy('name', 'asc')->get();
141
-//         $outcomeCount = Outcome::all()->count();
142
-		$outcomes = Outcome::active_by_semesters(array($semester),$level->is_graduate);
143
-		$outcomeCount = count((array)$outcomes);
144
-		
145
-		foreach($outcomes as $outcome)
146
-		{
147
-			$outcomes_attempted[$outcome->id]=$outcome->courses_attempted($grouped_courses);
148
-			$outcomes_achieved[$outcome->id]=$outcome->courses_achieved($grouped_courses);
149
-		}
150
-		
151
-		var_dump($outcomes_attempted);
152
-		print "<br>";
153
-		var_dump($outcomes_achieved);
154
-		print "<br>";
155
-        foreach ($grouped_courses as $index => $grouped_course)
156
-        {
157
-//             // Blank outcomes for one course
158
-//             $outcomes_achieved = array_fill(1, $outcomeCount, 0);
159
-//             $outcomes_attempted = array_fill(1, $outcomeCount, 0);
160
-// 
161
-//             // Find sections for this course
162
-            $sections = Course::
163
-            	where('code', $grouped_course->code)
164
-            	->where('number', $grouped_course->number)
165
-            	->where('semester_id', $grouped_course->semester_id)
166
-            	->get();
167
-// 
168
-//             // For each of the sections, add the attempted and achieved criteria per outcome
169
-//             foreach ($sections as $section)
170
-//             {
171
-//                 if($section->outcomes_achieved!=NULL)
172
-//                 {
173
-//                     $section_outcomes_achieved =count($section->outcomes_attempted());
174
-// //                     var_dump($section_outcomes_achieved);
175
-// //                     exit();
176
-//                     $section_outcomes_attempted =count($section->outcomes_achieved());
177
-// //                     $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
178
-// //                     $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
179
-// 					foreach($outcomes as $outcome)
180
-// 					{
181
-// 						if(!isset($outcomes_achieved[$outcome->id]))$outcomes_achieved[$outcome->id]=0;
182
-// 						if(!isset($outcomes_attempted[$outcome->id]))$outcomes_attempted[$outcome->id]=0;
183
-//                         $outcomes_achieved[$outcome->id]+=$section_outcomes_achieved[$i];
184
-//                         $outcomes_attempted[$outcome->id]+=$section_outcomes_attempted[$i];					
185
-// 					
186
-// 					}
187
-// //                     for($i=1; $i<=count($outcomes_attempted); $i++)
188
-// //                     {
189
-// //                         $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
190
-// //                         $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
191
-// //                     }
192
-//                 }
193
-//             }
132
+        $level = DB::table('courses')
133
+            ->join('programs', 'programs.id', '=', 'courses.program_id')
134
+            ->where('courses.code', $code)
135
+            ->where('courses.number', $number)
136
+            ->where('courses.semester_id', $semester->id)
137
+            ->select('programs.is_graduate')
138
+            ->first();
139
+        //         var_dump($level);
140
+        //         exit();
141
+        $grouped_courses = Course::where('code', $code)
142
+            ->where('number', $number)
143
+            ->where('semester_id', $semester->id)
144
+            ->groupBy(array('code', 'number'))->get();
145
+
146
+        //         $outcomes = Outcome::orderBy('name', 'asc')->get();
147
+        //         $outcomeCount = Outcome::all()->count();
148
+        $outcomes = Outcome::active_by_semesters(array($semester), $level->is_graduate);
149
+        $outcomeCount = count((array)$outcomes);
150
+
151
+        foreach ($outcomes as $outcome) {
152
+            $outcomes_attempted[$outcome->id] = $outcome->courses_attempted($grouped_courses);
153
+            $outcomes_achieved[$outcome->id] = $outcome->courses_achieved($grouped_courses);
194 154
         }
195 155
 
196
-        $section_ids = Course::
197
-        	where('code', $code)
198
-        	->where('number', $number)
199
-        	->where('semester_id', $semester->id)
200
-        	->lists('id');
156
+        // var_dump($outcomes_attempted);
157
+        // print "<br>";
158
+        // var_dump($outcomes_achieved);
159
+        // print "<br>";
160
+        foreach ($grouped_courses as $index => $grouped_course) {
161
+            //             // Blank outcomes for one course
162
+            //             $outcomes_achieved = array_fill(1, $outcomeCount, 0);
163
+            //             $outcomes_attempted = array_fill(1, $outcomeCount, 0);
164
+            // 
165
+            //             // Find sections for this course
166
+            $sections = Course::where('code', $grouped_course->code)
167
+                ->where('number', $grouped_course->number)
168
+                ->where('semester_id', $grouped_course->semester_id)
169
+                ->get();
170
+            // 
171
+            //             // For each of the sections, add the attempted and achieved criteria per outcome
172
+            //             foreach ($sections as $section)
173
+            //             {
174
+            //                 if($section->outcomes_achieved!=NULL)
175
+            //                 {
176
+            //                     $section_outcomes_achieved =count($section->outcomes_attempted());
177
+            // //                     var_dump($section_outcomes_achieved);
178
+            // //                     exit();
179
+            //                     $section_outcomes_attempted =count($section->outcomes_achieved());
180
+            // //                     $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
181
+            // //                     $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
182
+            // 					foreach($outcomes as $outcome)
183
+            // 					{
184
+            // 						if(!isset($outcomes_achieved[$outcome->id]))$outcomes_achieved[$outcome->id]=0;
185
+            // 						if(!isset($outcomes_attempted[$outcome->id]))$outcomes_attempted[$outcome->id]=0;
186
+            //                         $outcomes_achieved[$outcome->id]+=$section_outcomes_achieved[$i];
187
+            //                         $outcomes_attempted[$outcome->id]+=$section_outcomes_attempted[$i];					
188
+            // 					
189
+            // 					}
190
+            // //                     for($i=1; $i<=count($outcomes_attempted); $i++)
191
+            // //                     {
192
+            // //                         $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
193
+            // //                         $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
194
+            // //                     }
195
+            //                 }
196
+            //             }
197
+        }
198
+
199
+        $section_ids = Course::where('code', $code)
200
+            ->where('number', $number)
201
+            ->where('semester_id', $semester->id)
202
+            ->lists('id');
201 203
 
202
-            $activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
204
+        //$activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
203 205
 
204
-		return View::make('local.managers.shared.grouped_course', compact('role', 'title', 'grouped_courses', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'sections', 'transforming_actions', 'activities'));
205
-	}
206
+        $activities = Activity::with('course')->whereIn('course_id', $section_ids)
207
+            ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
208
+            ->join('transformative_activity_criterion as tac', 'ac.id', '=', 'tac.activity_criterion_id')
209
+            ->join('transformative_actions as ta', 'ta.id', '=', 'tac.trans_action_id')
210
+            ->select('activities.*')
211
+            ->addSelect('ta.description as transforming_actions')
212
+            ->distinct()
213
+            ->orderBy('name')->get();
206 214
 
207
-	/**
208
-	 * Printable version for a course (grouped sections)
209
-	 */
215
+        return View::make('local.managers.shared.grouped_course', compact('role', 'title', 'grouped_courses', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'sections', 'transforming_actions', 'activities'));
216
+    }
210 217
 
211
-	public function print_course($code, $number, $semester_code)
212
-	{
213
-        $title=$code.$number.' ('.$semester_code.')';
218
+    /**
219
+     * Printable version for a course (grouped sections)
220
+     */
221
+
222
+    public function print_course($code, $number, $semester_code)
223
+    {
224
+        $title = $code . $number . ' (' . $semester_code . ')';
214 225
         $semester = Semester::where('code', $semester_code)->first();
215 226
         $role = Auth::user()->role;
216 227
 
217
-        $grouped_courses = Course::
218
-        	where('code', $code)
219
-        	->where('number', $number)
220
-        	->where('semester_id', $semester->id)
221
-        	->groupBy(array('code', 'number'))->get();
228
+        $grouped_courses = Course::where('code', $code)
229
+            ->where('number', $number)
230
+            ->where('semester_id', $semester->id)
231
+            ->groupBy(array('code', 'number'))->get();
222 232
 
223 233
         $outcomes = Outcome::orderBy('name', 'asc')->get();
224 234
         $outcomeCount = Outcome::all()->count();
225 235
 
226
-        foreach ($grouped_courses as $index => $grouped_course)
227
-        {
236
+        foreach ($grouped_courses as $index => $grouped_course) {
228 237
             // Blank outcomes for one course
229 238
             $outcomes_achieved = array_fill(1, $outcomeCount, 0);
230 239
             $outcomes_attempted = array_fill(1, $outcomeCount, 0);
231 240
 
232 241
             // Find sections for this course
233
-            $sections = Course::
234
-            	where('code', $grouped_course->code)
235
-            	->where('number', $grouped_course->number)
236
-            	->where('semester_id', $grouped_course->semester_id)
237
-            	->get();
242
+            $sections = Course::where('code', $grouped_course->code)
243
+                ->where('number', $grouped_course->number)
244
+                ->where('semester_id', $grouped_course->semester_id)
245
+                ->get();
238 246
 
239 247
             // For each of the sections, add the attempted and achieved criteria per outcome
240
-            foreach ($sections as $section)
241
-            {
242
-                if($section->outcomes_achieved!=NULL)
243
-                {
244
-                    $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
245
-                    $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
246
-                    for($i=1; $i<=count($outcomes_attempted); $i++)
247
-                    {
248
-                        $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
249
-                        $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
248
+            foreach ($sections as $section) {
249
+                if ($section->outcomes_achieved != NULL) {
250
+                    $section_outcomes_achieved = json_decode($section->outcomes_achieved, true);
251
+                    $section_outcomes_attempted = json_decode($section->outcomes_attempted, true);
252
+                    for ($i = 1; $i <= count($outcomes_attempted); $i++) {
253
+                        $outcomes_achieved[$i] += $section_outcomes_achieved[$i];
254
+                        $outcomes_attempted[$i] += $section_outcomes_attempted[$i];
250 255
                     }
251 256
                 }
252 257
             }
253 258
         }
254 259
 
255
-        $section_ids = Course::
256
-        	where('code', $code)
257
-        	->where('number', $number)
258
-        	->where('semester_id', $semester->id)
259
-        	->lists('id');
260
+        $section_ids = Course::where('code', $code)
261
+            ->where('number', $number)
262
+            ->where('semester_id', $semester->id)
263
+            ->lists('id');
260 264
 
261 265
         // Activities with transforming actions
262
-       	$activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
266
+        $activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
263 267
 
264
-		return View::make('local.managers.shared.print_course', compact('role', 'title', 'grouped_courses', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'sections', 'activities'));
265
-	}
268
+        return View::make('local.managers.shared.print_course', compact('role', 'title', 'grouped_courses', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'sections', 'activities'));
269
+    }
266 270
 
267 271
 
268 272
     private function excelConv(&$value, $key)
@@ -270,7 +274,6 @@ CoursesController extends \BaseController {
270 274
         Log::debug('CoursesController@excelConv');
271 275
 
272 276
         $value = iconv('UTF-8', 'Windows-1252//IGNORE', $value);
273
-
274 277
     }
275 278
 
276 279
 
@@ -282,27 +285,27 @@ CoursesController extends \BaseController {
282 285
         $course = Course::find($id);
283 286
 
284 287
         // Set file name and open file
285
-        $filename = 'olas_student_grades_'.$course->code.$course->number.$course->section.$course->semester->code.'_'.time().'.csv';
286
-        $file= fopen('exports/'.$filename, 'w');
288
+        $filename = 'olas_student_grades_' . $course->code . $course->number . $course->section . $course->semester->code . '_' . time() . '.csv';
289
+        $file = fopen('exports/' . $filename, 'w');
287 290
 
288 291
         // To add an empty line to the csv
289 292
         $empty_line = array(' ');
290 293
 
291 294
         // Set section name at the top
292
-        fputcsv($file, array($course->code.$course->number.$course->section.' ('.$course->semester->code.')'));
295
+        fputcsv($file, array($course->code . $course->number . $course->section . ' (' . $course->semester->code . ')'));
293 296
         fputcsv($file, $empty_line);
294 297
 
295 298
         // Individual activity tables -----------------------------------------
296 299
 
297 300
         // For each activity
298
-        foreach($course->assessedActivities as $activity) {
301
+        foreach ($course->assessedActivities as $activity) {
299 302
             // Set name
300 303
 
301 304
             $activity_name = iconv('UTF-8', 'Windows-1252//IGNORE', $activity->name);
302 305
             fputcsv($file, array($activity_name));
303 306
 
304 307
             // Get assessments
305
-            $assessments = DB::table('assessments')->join('students', 'assessments.student_id','=','students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
308
+            $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
306 309
 
307 310
             // Get rubric contents
308 311
             $rubric_contents = json_decode($activity->rubric->contents);
@@ -317,7 +320,7 @@ CoursesController extends \BaseController {
317 320
             $criterion_list[] = 'Comments';
318 321
 
319 322
             // Change encoding to be compatible with Excel
320
-            array_walk($criterion_list, array($this,'excelConv'));
323
+            array_walk($criterion_list, array($this, 'excelConv'));
321 324
 
322 325
             fputcsv($file, $criterion_list);
323 326
 
@@ -328,7 +331,8 @@ CoursesController extends \BaseController {
328 331
                 fputcsv($file, array_merge(
329 332
                     array($student->number, $student->name, $student->school_code, $student->conc_code),
330 333
                     $scores,
331
-                    array($assessment->percentage, $assessment->comments)));
334
+                    array($assessment->percentage, $assessment->comments)
335
+                ));
332 336
             }
333 337
             fputcsv($file, $empty_line);
334 338
         }
@@ -337,8 +341,8 @@ CoursesController extends \BaseController {
337 341
 
338 342
         // Set headers for table
339 343
         $activity_list = array('#', 'Name', 'School', 'Major');
340
-        foreach($course->assessedActivities as $activity) {
341
-            $activity_list[]=$activity->name;
344
+        foreach ($course->assessedActivities as $activity) {
345
+            $activity_list[] = $activity->name;
342 346
         }
343 347
         $activity_list[] = 'Average';
344 348
 
@@ -346,13 +350,13 @@ CoursesController extends \BaseController {
346 350
         fputcsv($file, array('All Activities'));
347 351
 
348 352
         // Change encoding to be compatible with Excel
349
-        array_walk($activity_list, array($this,'excelConv'));
353
+        array_walk($activity_list, array($this, 'excelConv'));
350 354
 
351 355
         fputcsv($file, $activity_list);
352 356
 
353 357
         // For each student, set info
354 358
         foreach ($activity->course->students as $student) {
355
-            $student_record= array($student->number, $student->name, $student->school_code, $student->conc_code);
359
+            $student_record = array($student->number, $student->name, $student->school_code, $student->conc_code);
356 360
 
357 361
             $assessed_activities = $course->assessedActivities;
358 362
             // Iterate over activities, get percentages and add them to the record array
@@ -367,12 +371,12 @@ CoursesController extends \BaseController {
367 371
 
368 372
             // Average
369 373
             $student_record[] = array_sum(
370
-                                    array_slice(
371
-                                        $student_record,
372
-                                        4,
373
-                                        count($assessed_activities)
374
-                                    )
375
-                                )/count($assessed_activities);
374
+                array_slice(
375
+                    $student_record,
376
+                    4,
377
+                    count($assessed_activities)
378
+                )
379
+            ) / count($assessed_activities);
376 380
 
377 381
             fputcsv($file, $student_record);
378 382
         }
@@ -381,7 +385,7 @@ CoursesController extends \BaseController {
381 385
         fclose($file);
382 386
 
383 387
         // Return response for download
384
-        return Response::download('exports/'.$filename);
388
+        return Response::download('exports/' . $filename);
385 389
     }
386 390
 
387 391
     public function reassign()
@@ -395,16 +399,14 @@ CoursesController extends \BaseController {
395 399
 
396 400
     public function update()
397 401
     {
398
-        if(Input::get('reassign_program'))
399
-        {
402
+        if (Input::get('reassign_program')) {
400 403
             $code = strtoupper(trim(str_replace('*', '%', Input::get('code'))));
401 404
             $number = strtoupper(trim(str_replace('*', '%', Input::get('number'))));
402 405
             $section = strtoupper(trim(str_replace('*', '%', Input::get('section'))));
403 406
 
404
-            if(!$code && !$number && !$section)
405
-            {
406
-                Session::flash('status','danger');
407
-                Session::flash('message','At least one field is required.');
407
+            if (!$code && !$number && !$section) {
408
+                Session::flash('status', 'danger');
409
+                Session::flash('message', 'At least one field is required.');
408 410
 
409 411
                 return Redirect::back()->withInput();
410 412
             }
@@ -412,63 +414,49 @@ CoursesController extends \BaseController {
412 414
             $update_query = Course::orderBy('code', 'asc')->orderBy('number', 'asc')->orderBy('section', 'asc');
413 415
             $fetch_query = Course::orderBy('code', 'asc')->orderBy('number', 'asc')->orderBy('section', 'asc');
414 416
 
415
-            if($code)
416
-            {
417
+            if ($code) {
417 418
                 $update_query->where('code', 'LIKE', $code);
418 419
                 $fetch_query->where('code', 'LIKE', $code);
419 420
             }
420 421
 
421
-            if($number)
422
-            {
422
+            if ($number) {
423 423
                 $update_query->where('number', 'LIKE', $number);
424 424
                 $fetch_query->where('number', 'LIKE', $number);
425 425
             }
426 426
 
427
-            if($section)
428
-            {
427
+            if ($section) {
429 428
                 $update_query->where('section', 'LIKE', $section);
430 429
                 $fetch_query->where('section', 'LIKE', $section);
431 430
             }
432 431
             // If section is blank, results can be grouped by code and number
433
-            else
434
-            {
432
+            else {
435 433
                 $fetch_query->groupBy(array('code', 'number'));
436 434
             }
437 435
 
438 436
             $affected_rows = $fetch_query->get();
439 437
 
440 438
             // If there are results
441
-            if(!$affected_rows->isEmpty())
442
-            {
439
+            if (!$affected_rows->isEmpty()) {
443 440
                 // Try updating and flash success message if successful
444
-                if($update_query->update(array('program_id'=>Input::get('program'))))
445
-                {
441
+                if ($update_query->update(array('program_id' => Input::get('program')))) {
446 442
                     Session::flash('courses', json_encode($affected_rows));
447 443
                     Session::flash('status', 'success');
448 444
                     Session::flash('message', 'Courses succesfully updated.');
449 445
 
450
-                    if($section)
451
-                    {
446
+                    if ($section) {
452 447
                         Session::flash('show_sections', true);
453 448
                     }
454
-
455
-                }
456
-                else
457
-                {
449
+                } else {
458 450
                     Session::flash('status', 'danger');
459 451
                     Session::flash('message', 'Error reassigning courses to a program. Try again later.');
460 452
                 }
461
-            }
462
-            else
463
-            {
453
+            } else {
464 454
                 Session::flash('status', 'warning');
465 455
                 Session::flash('message', 'No courses matched your criteria. Try to broaden your search.');
466 456
             }
467 457
 
468 458
             return Redirect::back()->withInput();
469
-        }
470
-        elseif(Input::get('reassign_professor'))
471
-        {
459
+        } elseif (Input::get('reassign_professor')) {
472 460
 
473 461
             $code = strtoupper(trim(str_replace('*', '%', Input::get('code_prof'))));
474 462
             $number = strtoupper(trim(str_replace('*', '%', Input::get('number_prof'))));
@@ -477,21 +465,18 @@ CoursesController extends \BaseController {
477 465
             $semester = Input::get('semester_prof');
478 466
 
479 467
 
480
-            if(!$code || !$number || !$section)
481
-            {
482
-                Session::flash('status','danger');
483
-                Session::flash('message','Error assigning professor to a course. All fields are required.');
468
+            if (!$code || !$number || !$section) {
469
+                Session::flash('status', 'danger');
470
+                Session::flash('message', 'Error assigning professor to a course. All fields are required.');
484 471
 
485 472
                 return Redirect::back()->withInput();
486 473
             }
487 474
 
488
-            $update_query = Course::
489
-                where('code', '=', $code)
475
+            $update_query = Course::where('code', '=', $code)
490 476
                 ->where('number', '=', $number)
491 477
                 ->where('section', '=', $section)
492 478
                 ->where('semester_id', '=', $semester);
493
-            $fetch_query = Course::
494
-                where('code', '=', $code)
479
+            $fetch_query = Course::where('code', '=', $code)
495 480
                 ->where('number', '=', $number)
496 481
                 ->where('section', '=', $section)
497 482
                 ->orderBy('code', 'asc')
@@ -501,35 +486,24 @@ CoursesController extends \BaseController {
501 486
             $affected_rows = $fetch_query->get();
502 487
 
503 488
             // If there are results
504
-            if(!$affected_rows->isEmpty())
505
-            {
506
-                try
507
-                {
489
+            if (!$affected_rows->isEmpty()) {
490
+                try {
508 491
                     // Try updating and flash success message if successful
509
-                    $update_query->update(array('user_id'=>$user));
492
+                    $update_query->update(array('user_id' => $user));
510 493
 
511 494
                     Session::flash('status', 'success');
512
-                    Session::flash('message', 'Successfully changed professor for '.$code.$number.'-'.$section);
513
-                }
514
-                catch(Exception $e)
515
-                {
495
+                    Session::flash('message', 'Successfully changed professor for ' . $code . $number . '-' . $section);
496
+                } catch (Exception $e) {
516 497
                     Session::flash('status', 'danger');
517
-                    Session::flash('message', 'An error occurred when changing professor for '.$code.$number.'-'.$section).'.';
498
+                    Session::flash('message', 'An error occurred when changing professor for ' . $code . $number . '-' . $section) . '.';
518 499
                 }
519
-            }
520
-            else
521
-            {
500
+            } else {
522 501
                 Session::flash('status', 'warning');
523 502
                 Session::flash('message', 'No course matches your criteria. Try again with different values.');
524 503
             }
525 504
 
526 505
             return Redirect::back()->withInput();
527
-        }
528
-        else
529
-        {
530
-
506
+        } else {
531 507
         }
532 508
     }
533
-
534
-
535 509
 }

+ 2
- 2
app/controllers/CriteriaController.php View File

@@ -41,13 +41,13 @@ class CriteriaController extends \BaseController
41 41
             $listOfId[] = $program->id;
42 42
         }
43 43
 
44
-        $objectives = DB::table('objectives')->whereIn('program_id', $listOfId)->orderBy('text', 'ASC')->lists('text', 'id');
44
+        //$objectives = DB::table('objectives')->whereIn('program_id', $listOfId)->orderBy('text', 'ASC')->lists('text', 'id');
45 45
 
46 46
 
47 47
 
48 48
 
49 49
 
50
-        return View::make('local.managers.sCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
50
+        return View::make('local.managers.sCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs' /* 'objectives'*/));
51 51
     }
52 52
 
53 53
     public function fetchCriterionWithTemplate()

+ 6
- 1
app/controllers/OutcomesController.php View File

@@ -767,7 +767,12 @@ class OutcomesController extends \BaseController
767 767
                     ->with(array('courses' => function ($query2) {
768 768
                         $query2
769 769
                             ->has('activities')
770
-                            ->whereNotNull('outcomes_attempted')
770
+                            //->whereNotNull('outcomes_attempted')
771
+                            ->join('activities', 'activities.course_id', '=', 'courses.id')
772
+                            ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
773
+                            ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
774
+                            ->where('activities.draft', 0)
775
+                            ->select('courses.*')->distinct()
771 776
                             ->whereIn('semester_id', Session::get('semesters_ids'))
772 777
                             ->groupBy(array('code', 'number'));
773 778
                     }));

+ 46
- 3
app/controllers/ProgramCoordinatorsController.php View File

@@ -36,7 +36,8 @@ class ProgramCoordinatorsController extends \BaseController
36 36
     $programs_array = array();
37 37
     $programs_contact = array();
38 38
 
39
-    foreach ($programs as $program) {
39
+    // old code
40
+    /*foreach ($programs as $program) {
40 41
       $program_array = array();
41 42
 
42 43
       $program_array['program'] = $program;
@@ -59,12 +60,55 @@ class ProgramCoordinatorsController extends \BaseController
59 60
           $program_array['assessed_courses_count'] += 1;
60 61
         }
61 62
       }
63
+      */
64
+
65
+    foreach ($programs as $program) {
66
+      $program_array = array();
67
+
68
+      $program_array['program'] = $program;
69
+
70
+      $program_array['outcomes_achieved'] = [];
71
+      $program_array['outcomes_attempted'] = [];
72
+
73
+      $program_array['program_courses'] = $program->courses;
74
+      $program_array['grouped_objectives'] = $program->objectives();
75
+
76
+      $program_array['assessed_courses_count'] = 0;
77
+      foreach ($program_array['program_courses'] as $course) {
78
+        if (!empty($course->outcomes_ach())) {
79
+          $program_array['course_outcomes_achieved'] = $course->outcomes_ach();
80
+          $program_array['course_outcomes_attempted'] = $course->outcomes_att();
81
+          Log::info($program_array['course_outcomes_achieved']);
82
+          foreach ($program_array['course_outcomes_achieved'] as $i => $score) {
83
+            if (array_key_exists($i, $program_array['outcomes_achieved']))  $program_array['outcomes_achieved'][$i] += $program_array['course_outcomes_achieved'][$i];
84
+            else $program_array['outcomes_achieved'][$i] = $program_array['course_outcomes_achieved'][$i];
85
+          }
86
+          foreach ($program_array['course_outcomes_attempted'] as $i => $score) {
87
+
88
+            if (array_key_exists($i, $program_array['outcomes_attempted']))  $program_array['outcomes_attempted'][$i] += $program_array['course_outcomes_attempted'][$i];
89
+            else $program_array['outcomes_attempted'][$i] = $program_array['course_outcomes_attempted'][$i];
90
+          }
91
+
92
+          $program_array['assessed_courses_count'] += 1;
93
+        }
94
+      }
62 95
 
63 96
       /**
64 97
        * List of grouped courses (grouped sections)
65 98
        */
66 99
 
67
-      $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
100
+      //old code
101
+      /* $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
102
+        ->with('semester')
103
+        ->with('program')
104
+        ->where('program_id', $program->id)
105
+        ->whereIn('semester_id', Session::get('semesters_ids'))
106
+        ->groupBy(array('code', 'number', 'semester_id'))
107
+        ->orderBy('code')
108
+        ->orderBy('number')
109
+        ->orderBy('semester_id')
110
+        ->get(); */
111
+      $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, semester_id, program_id'))
68 112
         ->with('semester')
69 113
         ->with('program')
70 114
         ->where('program_id', $program->id)
@@ -75,7 +119,6 @@ class ProgramCoordinatorsController extends \BaseController
75 119
         ->orderBy('semester_id')
76 120
         ->get();
77 121
 
78
-
79 122
       $programs_array[] = $program_array;
80 123
 
81 124
 

+ 347
- 256
app/controllers/ProgramsController.php View File

@@ -11,80 +11,69 @@ class ProgramsController extends \BaseController
11 11
   {
12 12
 
13 13
     $program = Program::find($id);
14
-    $title= $program->school->name.': '.$program->name;
14
+    $title = $program->school->name . ': ' . $program->name;
15 15
     $program_courses = $program->courses;
16
-//     $outcomes = Outcome::orderBy('name', 'asc')->get();
16
+    //     $outcomes = Outcome::orderBy('name', 'asc')->get();
17 17
     $schools = School::all();
18
-//     $outcomeCount = Outcome::all()->count();
18
+    //     $outcomeCount = Outcome::all()->count();
19 19
 
20 20
     $selected_semesters = Semester::find(Session::get('semesters_ids'));
21 21
 
22
-	$level=$program->is_graduate;
23
-	$min_start="9000-01-01 00:00:00";
24
-	$max_end="1000-01-01 00:00:00";
25
-	foreach($selected_semesters as $semester)
26
-	{
27
-		if($min_start>$semester->start)
28
-		{
29
-			$min_start=$semester->start;
30
-		}
31
-		if($max_end<$semester->end)
32
-		{
33
-			$max_end=$semester->end;
34
-		}
35
-	}
36
-	$outcomes = Outcome::where(function($query) use ($min_start)
37
-							   {
38
-									$query->where('deactivation_date', '>=', $min_start)
39
-										  ->orWhere('deactivation_date', null);
40
-							   })
41
-						->where('activation_date', '<=', $max_end)
42
-						->where(function($query2) use ($level)
43
-								{
44
-									$query2->where("level", $level+1)
45
-										   ->orWhere("level",3);
46
-								})
47
-						->orderBy('name', 'ASC')
48
-						->get();
49
-	$outcomeCount = Outcome::where(function($query) use ($min_start)
50
-								   {
51
-										$query->where('deactivation_date', '>=', $min_start)
52
-											  ->orWhere('deactivation_date', null);
53
-									})
54
-						->where('activation_date', '<=', $max_end)
55
-						->where(function($query2) use ($level)
56
-									{
57
-										$query2->where("level",$level+1)
58
-											   ->orWhere("level",3);
59
-									})
60
-							->count();
61
-
62
-	foreach($outcomes as $outcome)
63
-	{
64
-		$outcomes_attempted[$outcome->id]=$program->attempted_outcome($outcome->id, $selected_semesters);
65
-		if($outcomes_attempted[$outcome->id])$outcomes_achieved[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semesters);
66
-	}
67
-
68
-	foreach($outcomes as $outcome)
69
-	{
70
-		$assessed_courses[$outcome->id]=DB::table('activity_criterion')
71
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
72
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
73
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
74
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
75
-	    	->where('criterion_objective_outcome.outcome_id','=',$outcome->id)
76
-	    	->where('programs.id','=',$program->id)
77
-	    	->where('courses.semester_id','=',$semester)
78
-	    	->count(DB::raw('DISTINCT courses.id'))
79
-			;
80
-	}
81
-	$assessed_courses_count=array_sum($assessed_courses);
22
+    $level = $program->is_graduate;
23
+    $min_start = "9000-01-01 00:00:00";
24
+    $max_end = "1000-01-01 00:00:00";
25
+    foreach ($selected_semesters as $semester) {
26
+      if ($min_start > $semester->start) {
27
+        $min_start = $semester->start;
28
+      }
29
+      if ($max_end < $semester->end) {
30
+        $max_end = $semester->end;
31
+      }
32
+    }
33
+    $outcomes = Outcome::where(function ($query) use ($min_start) {
34
+      $query->where('deactivation_date', '>=', $min_start)
35
+        ->orWhere('deactivation_date', null);
36
+    })
37
+      ->where('activation_date', '<=', $max_end)
38
+      ->where(function ($query2) use ($level) {
39
+        $query2->where("level", $level + 1)
40
+          ->orWhere("level", 3);
41
+      })
42
+      ->orderBy('name', 'ASC')
43
+      ->get();
44
+    $outcomeCount = Outcome::where(function ($query) use ($min_start) {
45
+      $query->where('deactivation_date', '>=', $min_start)
46
+        ->orWhere('deactivation_date', null);
47
+    })
48
+      ->where('activation_date', '<=', $max_end)
49
+      ->where(function ($query2) use ($level) {
50
+        $query2->where("level", $level + 1)
51
+          ->orWhere("level", 3);
52
+      })
53
+      ->count();
54
+
55
+    foreach ($outcomes as $outcome) {
56
+      $outcomes_attempted[$outcome->id] = $program->attempted_outcome($outcome->id, $selected_semesters);
57
+      if ($outcomes_attempted[$outcome->id]) $outcomes_achieved[$outcome->id] = $program->achieved_outcome($outcome->id, $selected_semesters);
58
+    }
59
+
60
+    foreach ($outcomes as $outcome) {
61
+      $assessed_courses[$outcome->id] = DB::table('activity_criterion')
62
+        ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
63
+        ->join('courses', 'activities.course_id', '=', 'courses.id')
64
+        ->join('programs', 'programs.id', '=', 'courses.program_id')
65
+        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
66
+        ->where('criterion_objective_outcome.outcome_id', '=', $outcome->id)
67
+        ->where('programs.id', '=', $program->id)
68
+        ->where('courses.semester_id', '=', $semester)
69
+        ->count(DB::raw('DISTINCT courses.id'));
70
+    }
71
+    $assessed_courses_count = array_sum($assessed_courses);
82 72
     /**
83 73
      * List of grouped courses (grouped sections)
84 74
      */
85 75
 
86
-    $grouped_courses = Course::
87
-      select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
76
+    $grouped_courses = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
88 77
       ->with('semester')
89 78
       ->with('program')
90 79
       ->where('program_id', $program->id)
@@ -96,202 +85,199 @@ class ProgramsController extends \BaseController
96 85
       ->get();
97 86
 
98 87
     // Program contact information
99
-    $users = User::
100
-        select('users.*')
101
-        ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
102
-        ->where(function($query) use($program)
103
-        {
104
-            $query
105
-                ->where('school_id', $program->school_id)
106
-                ->where('role', 2);
107
-        })
108
-        ->orWhere(function($query) use($program)
109
-        {
110
-            $query
111
-                ->where('role', 3)
112
-                ->where('program_id', $program->id);
113
-        })
114
-        ->orWhere(function($query) use($program)
115
-        {
116
-            $query
117
-                ->where('role', 4)
118
-                ->where('program_id', $program->id);
119
-        })
120
-        ->get();
88
+    $users = User::select('users.*')
89
+      ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
90
+      ->where(function ($query) use ($program) {
91
+        $query
92
+          ->where('school_id', $program->school_id)
93
+          ->where('role', 2);
94
+      })
95
+      ->orWhere(function ($query) use ($program) {
96
+        $query
97
+          ->where('role', 3)
98
+          ->where('program_id', $program->id);
99
+      })
100
+      ->orWhere(function ($query) use ($program) {
101
+        $query
102
+          ->where('role', 4)
103
+          ->where('program_id', $program->id);
104
+      })
105
+      ->get();
121 106
 
122
-// 	var_dump($outcomes_attempted);
123
-// 	print "<br>";
124
-// 	var_dump($outcomes_achieved);
125
-// 	print "<br>";
107
+    // 	var_dump($outcomes_attempted);
108
+    // 	print "<br>";
109
+    // 	var_dump($outcomes_achieved);
110
+    // 	print "<br>";
126 111
     return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
112
+  }
127 113
 
128
-}
129 114
 
115
+  public function showReport()
116
+  {
130 117
 
131
-public function showReport()
132
-{
133 118
 
119
+    // create an array with the ID of Semesters selected in the form
120
+    $selected_semesters_id = array();
121
+    $semesters = Semester::all();
122
+    foreach ($semesters as $semester) {
123
+      if ($semester->is_visible) {
124
+        if (Input::get('semester' . $semester->id) != null) {
125
+          array_push($selected_semesters_id, $semester->id);
126
+        }
127
+      }
128
+    }
129
+    $selected_semesters = DB::table('semesters')
130
+      ->wherein('semesters.id', $selected_semesters_id)
131
+      ->get();
134 132
 
135
-  // create an array with the ID of Semesters selected in the form
136
-  $selected_semesters_id = array();
137
-  $semesters = Semester::all();
138
-  foreach ($semesters as $semester) {
139
-    if ($semester->is_visible){
140
-      if (Input::get('semester'.$semester->id)!=null){
141
-        array_push($selected_semesters_id, $semester->id);
133
+    // create a srting with the selected metodos de divulgfacion
134
+    $selected_divulgaciones = '';
135
+    $divulgaciones = array(
136
+      'profesores', 'comiteDepartamental', 'comiteFacultadEscuela',
137
+      'pleno', 'estudiantes', 'administrativos', 'senado', 'comunidadWeb',
138
+      'otros'
139
+    );
140
+    foreach ($divulgaciones as $divulgacion) {
141
+      if (Input::get($divulgacion) != null) {
142
+        $selected_divulgaciones = $selected_divulgaciones . '\n' . Input::get($divulgacion);
142 143
       }
143 144
     }
144
-  }
145
-  $selected_semesters = DB::table('semesters')
146
-                        ->wherein('semesters.id',$selected_semesters_id)
147
-                        ->get();
148
-
149
-  // create a srting with the selected metodos de divulgfacion
150
-  $selected_divulgaciones = '';
151
-  $divulgaciones = array('profesores','comiteDepartamental','comiteFacultadEscuela',
152
-                      'pleno','estudiantes','administrativos','senado','comunidadWeb',
153
-                      'otros');
154
-  foreach ($divulgaciones as $divulgacion) {
155
-    if (Input::get($divulgacion)!=null){
156
-      $selected_divulgaciones = $selected_divulgaciones.'\n'.Input::get($divulgacion);
145
+
146
+    //OUTCOMES Join criteria join program
147
+    $programs = DB::table('programs')
148
+      ->select('id', 'name')
149
+      ->orderBy('name', 'asc')
150
+      ->get();
151
+
152
+
153
+
154
+    // $program
155
+    $tables_names = '{';
156
+    foreach ($programs as $program) {
157
+      $tables_names = $tables_names . '"table' . $program->id . '" : "' . $program->name . '",'; // code...
157 158
     }
158
-  }
159
+    $tables_names = $tables_names . '}';
160
+
161
+    $title = "Programs Reports";
162
+    // $title = "Program Report: ".$program->name;
163
+
164
+    $programs_info = array();
165
+    //OUTCOMES Join criteria join program
166
+    foreach ($programs as $program) {
167
+      $info_by_id = Program::find($program->id);
168
+
169
+      $domains = DB::table('outcomes')
170
+        ->join('criteria', 'criteria.outcome_id', '=', 'outcomes.id')
171
+        ->join('programs', 'programs.id', '=', 'criteria.program_id')
172
+        ->join('courses', 'courses.program_id', '=', 'programs.id')
173
+        ->where('programs.id', $program->id)
174
+        ->select('outcomes.name', 'outcomes.activation_date')
175
+        ->distinct()
176
+        ->orderBy('outcomes.name', 'asc')
177
+        ->get();
159 178
 
160
-  //OUTCOMES Join criteria join program
161
-  $programs = DB::table('programs')
162
-                        ->select('id','name')
163
-                        ->orderBy('name', 'asc')
164
-                        ->get();
165
-
166
-
167
-
168
-   // $program
169
-   $tables_names = '{';
170
-   foreach ($programs as $program) {
171
-     $tables_names = $tables_names.'"table'.$program->id.'" : "'.$program->name.'",';// code...
172
-   }
173
-   $tables_names = $tables_names.'}';
174
-
175
-   $title = "Programs Reports";
176
-   // $title = "Program Report: ".$program->name;
177
-
178
-   $programs_info = array();
179
-   //OUTCOMES Join criteria join program
180
-   foreach ($programs as $program) {
181
-     $info_by_id = Program::find($program->id);
182
-
183
-     $domains = DB::table('outcomes')
184
-                           ->join('criteria','criteria.outcome_id','=','outcomes.id')
185
-                           ->join('programs','programs.id','=','criteria.program_id')
186
-                           ->join('courses','courses.program_id','=','programs.id')
187
-                           ->where('programs.id',$program->id)
188
-                           ->select('outcomes.name','outcomes.activation_date')
189
-                           ->distinct()
190
-                           ->orderBy('outcomes.name', 'asc')
191
-                           ->get();
192
-
193
-     $courses_used = DB::table('outcomes')
194
-                           ->join('criteria','criteria.outcome_id','=','outcomes.id')
195
-                           ->join('programs','programs.id','=','criteria.program_id')
196
-                           ->join('courses','courses.program_id','=','programs.id')
197
-                           ->where('programs.id',$program->id)
198
-                           ->select('courses.number', 'outcomes.name as domain_name', 'courses.code')
199
-                           ->distinct()
200
-                           ->orderBy('courses.name', 'asc')
201
-                           ->get();
202
-
203
-     $transformative_actions = DB::table('outcomes')
204
-                           ->join('criteria','criteria.outcome_id','=','outcomes.id')
205
-                           ->join('programs','programs.id','=','criteria.program_id')
206
-                           ->join('courses','courses.program_id','=','programs.id')
207
-                           ->join('activities','activities.course_id','=','courses.id')
208
-                           ->join('activity_criterion','activity_criterion.activity_id','=','activities.id')
209
-                           ->where('programs.id',$program->id)
210
-                           ->select('activity_criterion.transformative_actions', 'outcomes.name as domain_name')
211
-                           ->distinct()
212
-                           ->orderBy('activity_criterion.transformative_actions', 'asc')
213
-                           ->get();
214
-     $info = array($info_by_id, $domains, $courses_used, $transformative_actions);
215
-     array_push($programs_info, $info);
216
-   }
217
-
218
-
219
-   return View::make('local.managers.shared.program_report', compact('title','programs_info','selected_divulgaciones','selected_semesters','tables_names'));
220
-}
179
+      $courses_used = DB::table('outcomes')
180
+        ->join('criteria', 'criteria.outcome_id', '=', 'outcomes.id')
181
+        ->join('programs', 'programs.id', '=', 'criteria.program_id')
182
+        ->join('courses', 'courses.program_id', '=', 'programs.id')
183
+        ->where('programs.id', $program->id)
184
+        ->select('courses.number', 'outcomes.name as domain_name', 'courses.code')
185
+        ->distinct()
186
+        ->orderBy('courses.name', 'asc')
187
+        ->get();
221 188
 
222
-//   public function show($id)
223
-//   {
224
-//
225
-//     $program = Program::find($id);
226
-//     $title= $program->school->name.': '.$program->name;
227
-//     $program_courses = $program->courses;
228
-//     $outcomes = Outcome::orderBy('name', 'asc')->get();
229
-//     $schools = School::all();
230
-//     $outcomeCount = Outcome::all()->count();
231
-//
232
-//
233
-//     $outcomes_achieved = array_fill(1, $outcomeCount, 0);
234
-//     $outcomes_attempted = array_fill(1, $outcomeCount, 0);
235
-//
236
-//     $assessed_courses_count=0;
237
-//     foreach ($program_courses as $course)
238
-//     {
239
-//         if($course->outcomes_achieved!=NULL)
240
-//         {
241
-//             $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
242
-//             $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
243
-//             for($i=1; $i<=count($outcomes_attempted); $i++)
244
-//             {
245
-//                 $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
246
-//                 $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
247
-//             }
248
-//             $assessed_courses_count+=1;
249
-//         }
250
-//     }
251
-//
252
-//     /**
253
-//      * List of grouped courses (grouped sections)
254
-//      */
255
-//
256
-//     $grouped_courses = Course::
257
-//       select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
258
-//       ->with('semester')
259
-//       ->with('program')
260
-//       ->where('program_id', $program->id)
261
-//       ->whereIn('semester_id', Session::get('semesters_ids'))
262
-//       ->groupBy(array('code', 'number', 'semester_id'))
263
-//       ->orderBy('code')
264
-//       ->orderBy('number')
265
-//       ->orderBy('semester_id')
266
-//       ->get();
267
-//
268
-//     // Program contact information
269
-//     $users = User::
270
-//         select('users.*')
271
-//         ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
272
-//         ->where(function($query) use($program)
273
-//         {
274
-//             $query
275
-//                 ->where('school_id', $program->school_id)
276
-//                 ->where('role', 2);
277
-//         })
278
-//         ->orWhere(function($query) use($program)
279
-//         {
280
-//             $query
281
-//                 ->where('role', 3)
282
-//                 ->where('program_id', $program->id);
283
-//         })
284
-//         ->orWhere(function($query) use($program)
285
-//         {
286
-//             $query
287
-//                 ->where('role', 4)
288
-//                 ->where('program_id', $program->id);
289
-//         })
290
-//         ->get();
291
-//
292
-//     return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
293
-//
294
-// }
189
+      $transformative_actions = DB::table('outcomes')
190
+        ->join('criteria', 'criteria.outcome_id', '=', 'outcomes.id')
191
+        ->join('programs', 'programs.id', '=', 'criteria.program_id')
192
+        ->join('courses', 'courses.program_id', '=', 'programs.id')
193
+        ->join('activities', 'activities.course_id', '=', 'courses.id')
194
+        ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
195
+        ->where('programs.id', $program->id)
196
+        ->select('activity_criterion.transformative_actions', 'outcomes.name as domain_name')
197
+        ->distinct()
198
+        ->orderBy('activity_criterion.transformative_actions', 'asc')
199
+        ->get();
200
+      $info = array($info_by_id, $domains, $courses_used, $transformative_actions);
201
+      array_push($programs_info, $info);
202
+    }
203
+
204
+
205
+    return View::make('local.managers.shared.program_report', compact('title', 'programs_info', 'selected_divulgaciones', 'selected_semesters', 'tables_names'));
206
+  }
207
+
208
+  //   public function show($id)
209
+  //   {
210
+  //
211
+  //     $program = Program::find($id);
212
+  //     $title= $program->school->name.': '.$program->name;
213
+  //     $program_courses = $program->courses;
214
+  //     $outcomes = Outcome::orderBy('name', 'asc')->get();
215
+  //     $schools = School::all();
216
+  //     $outcomeCount = Outcome::all()->count();
217
+  //
218
+  //
219
+  //     $outcomes_achieved = array_fill(1, $outcomeCount, 0);
220
+  //     $outcomes_attempted = array_fill(1, $outcomeCount, 0);
221
+  //
222
+  //     $assessed_courses_count=0;
223
+  //     foreach ($program_courses as $course)
224
+  //     {
225
+  //         if($course->outcomes_achieved!=NULL)
226
+  //         {
227
+  //             $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
228
+  //             $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
229
+  //             for($i=1; $i<=count($outcomes_attempted); $i++)
230
+  //             {
231
+  //                 $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
232
+  //                 $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
233
+  //             }
234
+  //             $assessed_courses_count+=1;
235
+  //         }
236
+  //     }
237
+  //
238
+  //     /**
239
+  //      * List of grouped courses (grouped sections)
240
+  //      */
241
+  //
242
+  //     $grouped_courses = Course::
243
+  //       select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
244
+  //       ->with('semester')
245
+  //       ->with('program')
246
+  //       ->where('program_id', $program->id)
247
+  //       ->whereIn('semester_id', Session::get('semesters_ids'))
248
+  //       ->groupBy(array('code', 'number', 'semester_id'))
249
+  //       ->orderBy('code')
250
+  //       ->orderBy('number')
251
+  //       ->orderBy('semester_id')
252
+  //       ->get();
253
+  //
254
+  //     // Program contact information
255
+  //     $users = User::
256
+  //         select('users.*')
257
+  //         ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
258
+  //         ->where(function($query) use($program)
259
+  //         {
260
+  //             $query
261
+  //                 ->where('school_id', $program->school_id)
262
+  //                 ->where('role', 2);
263
+  //         })
264
+  //         ->orWhere(function($query) use($program)
265
+  //         {
266
+  //             $query
267
+  //                 ->where('role', 3)
268
+  //                 ->where('program_id', $program->id);
269
+  //         })
270
+  //         ->orWhere(function($query) use($program)
271
+  //         {
272
+  //             $query
273
+  //                 ->where('role', 4)
274
+  //                 ->where('program_id', $program->id);
275
+  //         })
276
+  //         ->get();
277
+  //
278
+  //     return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
279
+  //
280
+  // }
295 281
 
296 282
 
297 283
   /**
@@ -301,12 +287,18 @@ public function showReport()
301 287
   {
302 288
 
303 289
     $program = Program::find($id);
304
-    $title= $program->name.' Assessment Report - '.date('m/d/Y');
290
+    $title = $program->name . ' Assessment Report - ' . date('m/d/Y');
305 291
     $program_courses = $program->courses;
306
-    $outcomes = Outcome::orderBy('name', 'asc')->get();
292
+    /* //$outcomes = Outcome::orderBy('name', 'asc')->get();
307 293
     $schools = School::all();
308
-    $outcomeCount = Outcome::all()->count();
294
+   // $outcomeCount = Outcome::all()->count();
295
+    $semesters = Session::get('semesters_ids');
296
+    $semesters = DB::table('semesters')->where('id', $course->semester_id)->orderBy('start', 'ASC')->first();
309 297
 
298
+    $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
299
+        ->whereNull('deleted_at')
300
+        ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
301
+        ->orderBy('name', 'ASC')->get();
310 302
 
311 303
     $outcomes_achieved = array_fill(1, $outcomeCount, 0);
312 304
     $outcomes_attempted = array_fill(1, $outcomeCount, 0);
@@ -331,7 +323,7 @@ public function showReport()
331 323
      * List of grouped courses (grouped sections)
332 324
      */
333 325
 
334
-    $grouped_courses = Course::
326
+    /*    $grouped_courses = Course::
335 327
       select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
336 328
       ->with('semester')
337 329
       ->with('program')
@@ -342,6 +334,105 @@ public function showReport()
342 334
       ->orderBy('number')
343 335
       ->orderBy('semester_id')
344 336
       ->get();
337
+*/
338
+
339
+    $semesters = Session::get('semesters_ids');
340
+    $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
341
+    Log::info($semesters->start);
342
+    $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
343
+      ->whereNull('deleted_at')
344
+      ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
345
+      ->orderBy('name', 'ASC')->get();
346
+    $outcomeCount = count($outcomes);
347
+
348
+    $programs_array = array();
349
+    $programs_contact = array();
350
+
351
+
352
+
353
+    foreach ($programs as $program) {
354
+      $program_array = array();
355
+
356
+      $program_array['program'] = $program;
357
+
358
+      $program_array['outcomes_achieved'] = [];
359
+      $program_array['outcomes_attempted'] = [];
360
+
361
+      $program_array['program_courses'] = $program->courses;
362
+      $program_array['grouped_objectives'] = $program->objectives();
363
+
364
+      $program_array['assessed_courses_count'] = 0;
365
+      foreach ($program_array['program_courses'] as $course) {
366
+        if (!empty($course->outcomes_ach())) {
367
+          $program_array['course_outcomes_achieved'] = $course->outcomes_ach();
368
+          $program_array['course_outcomes_attempted'] = $course->outcomes_att();
369
+          Log::info($program_array['course_outcomes_achieved']);
370
+          foreach ($program_array['course_outcomes_achieved'] as $i => $score) {
371
+            if (array_key_exists($i, $program_array['outcomes_achieved']))  $program_array['outcomes_achieved'][$i] += $program_array['course_outcomes_achieved'][$i];
372
+            else $program_array['outcomes_achieved'][$i] = $program_array['course_outcomes_achieved'][$i];
373
+          }
374
+          foreach ($program_array['course_outcomes_attempted'] as $i => $score) {
375
+
376
+            if (array_key_exists($i, $program_array['outcomes_attempted']))  $program_array['outcomes_attempted'][$i] += $program_array['course_outcomes_attempted'][$i];
377
+            else $program_array['outcomes_attempted'][$i] = $program_array['course_outcomes_attempted'][$i];
378
+          }
379
+
380
+          $program_array['assessed_courses_count'] += 1;
381
+        }
382
+      }
383
+
384
+      /**
385
+       * List of grouped courses (grouped sections)
386
+       */
387
+
388
+      //old code
389
+      /* $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
390
+        ->with('semester')
391
+        ->with('program')
392
+        ->where('program_id', $program->id)
393
+        ->whereIn('semester_id', Session::get('semesters_ids'))
394
+        ->groupBy(array('code', 'number', 'semester_id'))
395
+        ->orderBy('code')
396
+        ->orderBy('number')
397
+        ->orderBy('semester_id')
398
+        ->get(); */
399
+      $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, semester_id, program_id'))
400
+        ->with('semester')
401
+        ->with('program')
402
+        ->where('program_id', $program->id)
403
+        ->whereIn('semester_id', Session::get('semesters_ids'))
404
+        ->groupBy(array('code', 'number', 'semester_id'))
405
+        ->orderBy('code')
406
+        ->orderBy('number')
407
+        ->orderBy('semester_id')
408
+        ->get();
409
+
410
+      $programs_array[] = $program_array;
411
+
412
+
413
+      // Program contact information
414
+      $users = User::select('users.*')
415
+        ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
416
+        ->where(function ($query) use ($program) {
417
+          $query
418
+            ->where('school_id', $program->school_id)
419
+            ->where('role', 2);
420
+        })
421
+        ->orWhere(function ($query) use ($program) {
422
+          $query
423
+            ->where('role', 3)
424
+            ->where('program_id', $program->id);
425
+        })
426
+        ->orWhere(function ($query) use ($program) {
427
+          $query
428
+            ->where('role', 4)
429
+            ->where('program_id', $program->id);
430
+        })
431
+        ->get();
432
+
433
+
434
+      $programs_contact[] = $users;
435
+    }
345 436
 
346 437
     return View::make('local.managers.shared.print_program', compact('title', 'program', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses'));
347 438
   }
@@ -361,11 +452,11 @@ public function showReport()
361 452
   }
362 453
 
363 454
   /**
364
-  * Fetch a program
365
-  */
455
+   * Fetch a program
456
+   */
366 457
   public function fetch()
367 458
   {
368
-    Log::info('id:'.Input::get('id'));
459
+    Log::info('id:' . Input::get('id'));
369 460
     return School::find(Input::get('id'))->programs;
370 461
   }
371 462
 }

+ 25
- 3
app/controllers/RubricsController.php View File

@@ -105,6 +105,8 @@ class RubricsController extends \BaseController
105 105
 
106 106
             DB::table('rubric_activity')->insert(array('activity_id' => Input::get('activity_id'), 'rubric_id' => $rubric->id));
107 107
             DB::commit();
108
+            $activity_id = Input::get("activity_id");
109
+
108 110
 
109 111
             $rubricId = $rubric->id;
110 112
             foreach ($criteria as $index => $criterion_id) {
@@ -115,7 +117,7 @@ class RubricsController extends \BaseController
115 117
 
116 118
 
117 119
 
118
-                $activity_id = Input::get("activity_id");
120
+
119 121
                 DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity_id}, {$criterion_id}, {$defaultWeight})");
120 122
                 DB::commit();
121 123
             }
@@ -263,7 +265,7 @@ class RubricsController extends \BaseController
263 265
         foreach ($criteria as $index => $criterion_id) {
264 266
 
265 267
 
266
-            $result =  DB::insert("insert into rubric_criterion (`rubric_id`, `criterion_id`) values ({$rubric->id}, {$criterion_id}) ");
268
+            $result =  DB::insert("insert into rubric_criterion (`rubric_id`, `criterion_id`, `position`) values ({$rubric->id}, {$criterion_id}, {$index}) ");
267 269
             $result2 = DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity->id}, {$criterion_id}, {$defaultWeight})");
268 270
             if (!($result || $result2)) {
269 271
                 DB::rollBack();
@@ -365,9 +367,29 @@ class RubricsController extends \BaseController
365 367
             App::abort('403', 'Access Forbidden');
366 368
 
367 369
         $rubric = Rubric::where('id', '=', $rubric_id)->firstOrFail();
370
+        $rubric_criterion = DB::table('criteria')
371
+            ->join('rubric_criterion', 'rubric_criterion.criterion_id', '=', 'criteria.id')
372
+            ->where('rubric_criterion.rubric_id', '=', $rubric->id)
373
+            ->get();
374
+        $rubric->titles = DB::table('titles')
375
+            ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
376
+            ->where('rubric_title.rubric_id', $rubric->id)
377
+            ->orderBy('position')
378
+            ->lists('text');
379
+
380
+        foreach ($rubric_criterion as $single_cr) {
381
+            $single_cr->scales = DB::table('scales')
382
+                ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
383
+                ->where('criterion_scale.criterion_id', '=', $single_cr->criterion_id)
384
+                ->orderBy('position')
385
+                ->lists('description');
386
+            $single_cr->outcomes = DB::table('outcomes')
387
+                ->join('criterion_objective_outcome', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
388
+                ->where('criterion_objective_outcome.criterion_id', '=', $single_cr->criterion_id)->lists('name');
389
+        }
368 390
         $title = $rubric->name;
369 391
         $role = Auth::user()->role;
370
-        return View::make('local.managers.shared.view_rubric_limited', compact('rubric', 'title', 'role'));
392
+        return View::make('local.managers.shared.view_rubric_limited', compact('rubric', 'rubric_criterion', 'title', 'role'));
371 393
     }
372 394
 
373 395
     public function download($activity_id, $rubric_id)

+ 284
- 230
app/controllers/SchoolCoordinatorsController.php View File

@@ -1,7 +1,8 @@
1 1
 <?php
2 2
 
3
-class SchoolCoordinatorsController extends \BaseController {
4
-    
3
+class SchoolCoordinatorsController extends \BaseController
4
+{
5
+
5 6
     private function participatingPrograms($school)
6 7
     {
7 8
         return DB::table('VIEW_participating_programs')
@@ -13,275 +14,328 @@ class SchoolCoordinatorsController extends \BaseController {
13 14
     public function overview()
14 15
     {
15 16
         DB::disableQueryLog();
16
-        Log::debug('user'.Auth::user()->id);
17
+        Log::debug('user' . Auth::user()->id);
17 18
 
18 19
         //TODO Find a better way to prevent non-scoords from reaching the page
19
-        switch(Auth::user()->role)
20
-        {
21
-        case 1:
22
-            return Redirect::to('administrator');
23
-            break;
24
-        case 3:
25
-            return Redirect::to('program-coordinator');
26
-            break;
20
+        switch (Auth::user()->role) {
21
+            case 1:
22
+                return Redirect::to('administrator');
23
+                break;
24
+            case 3:
25
+                return Redirect::to('program-coordinator');
26
+                break;
27 27
         }
28 28
 
29 29
         $schools = School::orderBy('name', 'asc')->get();
30 30
         $school = Auth::user()->school;
31
-        $title = $school->name.' '.'Overview';
31
+        $title = $school->name . ' ' . 'Overview';
32 32
         $id = $school->id;
33 33
 
34 34
         $outcomes = Outcome::orderBy('name', 'asc')->get();
35 35
         $outcomeCount = Outcome::all()->count();
36 36
 
37
-            /**
38
-             * List of grouped courses (grouped sections)
39
-             */
37
+        /** 
38
+         * List of grouped courses (grouped sections)
39
+         */
40 40
 
41
-            $program_ids= $school->programs->lists('id');
41
+        $program_ids = $school->programs->lists('id');
42 42
 
43
-            $undergrad_programs = DB::table('programs')
43
+        $undergrad_programs = DB::table('programs')
44 44
             ->select('id', 'name', 'school_id', 'is_graduate')
45 45
             ->where('is_graduate', '=', 0)
46 46
             ->where('school_id', '=', $id)
47 47
             ->orderBy('name', 'ASC')
48 48
             ->get();
49 49
 
50
-            $grad_programs = DB::table('programs')
50
+        $grad_programs = DB::table('programs')
51 51
             ->select('id', 'name', 'school_id', 'is_graduate')
52 52
             ->where('is_graduate', '=', 1)
53 53
             ->where('school_id', '=', $id)
54 54
             ->orderBy('name', 'ASC')
55 55
             ->get();
56
-    
57
-
58
-            $grad_grouped_courses = Course::
59
-                select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
60
-                ->with('semester')
61
-                ->with('program')
62
-                ->whereIn('courses.program_id', $program_ids)
63
-                ->whereIn('courses.semester_id', Session::get('semesters_ids'))
64
-                ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
65
-                ->where('programs.is_graduate', '=', 1)
66
-                ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
67
-                ->orderBy('courses.code')
68
-                ->orderBy('courses.number')
69
-                ->orderBy('courses.semester_id')
70
-                ->get();
71
-
72
-            $undergrad_grouped_courses = Course::
73
-                select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
74
-                ->with('semester')
75
-                ->with('program')
76
-                ->whereIn('courses.program_id', $program_ids)
77
-                ->whereIn('courses.semester_id', Session::get('semesters_ids'))
78
-                ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
79
-                ->where('programs.is_graduate', '=', 0)
80
-                ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
81
-                ->orderBy('courses.code')
82
-                ->orderBy('courses.number')
83
-                ->orderBy('courses.semester_id')
84
-                ->get();
85
-
86
-            // Fetch programs with participation
87
-            $participating_programs = $this->participatingPrograms($school);
88
-
89
-
90
-            /**
91
-             * Calculate how many sections are doing assessment
92
-             */
93
-
94
-            $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
95
-            $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
96
-            $undergrad_assessed_sections_count = 0;
97
-            $undergrad_school_sections_count = 0;
98
-
99
-            $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
100
-            $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
101
-            $grad_assessed_sections_count = 0;
102
-            $grad_school_sections_count = 0;
103
-
104
-            foreach($school->programs as $program)
105
-            {
106
-                foreach ($program->courses as $course)
107
-                {
108
-                    if(!$course->program->is_graduate)
109
-                    {
110
-                        if($course->outcomes_achieved != NULL)
111
-                        {
112
-                            $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
113
-                            $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
114
-                            for($i=1; $i<=count($undergrad_outcomes_attempted); $i++)
115
-                            {
116
-                                $undergrad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
117
-                                $undergrad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
118
-                            }
119
-                            $undergrad_assessed_sections_count+=1;
56
+
57
+
58
+        /*$grad_grouped_courses = Course::select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
59
+            ->with('semester')
60
+            ->with('program')
61
+            ->whereIn('courses.program_id', $program_ids)
62
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
63
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
64
+            ->where('programs.is_graduate', '=', 1)
65
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
66
+            ->orderBy('courses.code')
67
+            ->orderBy('courses.number')
68
+            ->orderBy('courses.semester_id')
69
+            ->get();*/
70
+
71
+        $grad_grouped_courses = Course::select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
72
+            ->with('semester')
73
+            ->with('program')
74
+            ->whereIn('courses.program_id', $program_ids)
75
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
76
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
77
+            ->where('programs.is_graduate', '=', 1)
78
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
79
+            ->orderBy('courses.code')
80
+            ->orderBy('courses.number')
81
+            ->orderBy('courses.semester_id')
82
+            ->get();
83
+
84
+
85
+        /*$undergrad_grouped_courses = Course::select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
86
+            ->with('semester')
87
+            ->with('program')
88
+            ->whereIn('courses.program_id', $program_ids)
89
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
90
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
91
+            ->where('programs.is_graduate', '=', 0)
92
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
93
+            ->orderBy('courses.code')
94
+            ->orderBy('courses.number')
95
+            ->orderBy('courses.semester_id')
96
+            ->get();*/
97
+
98
+        $undergrad_grouped_courses = Course::select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id'))
99
+            ->with('semester')
100
+            ->with('program')
101
+            ->whereIn('courses.program_id', $program_ids)
102
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
103
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
104
+            ->where('programs.is_graduate', '=', 0)
105
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
106
+            ->orderBy('courses.code')
107
+            ->orderBy('courses.number')
108
+            ->orderBy('courses.semester_id')
109
+            ->get();
110
+
111
+        // Fetch programs with participation
112
+        $participating_programs = $this->participatingPrograms($school);
113
+
114
+
115
+        /**
116
+         * Calculate how many sections are doing assessment
117
+         */
118
+
119
+        $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
120
+        $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
121
+        $undergrad_assessed_sections_count = 0;
122
+        $undergrad_school_sections_count = 0;
123
+
124
+        $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
125
+        $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
126
+        $grad_assessed_sections_count = 0;
127
+        $grad_school_sections_count = 0;
128
+        /*
129
+        foreach ($school->programs as $program) {
130
+            foreach ($program->courses as $course) {
131
+                if (!$course->program->is_graduate) {
132
+                    if ($course->outcomes_achieved != NULL) {
133
+                        $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
134
+                        $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
135
+                        for ($i = 1; $i <= count($undergrad_outcomes_attempted); $i++) {
136
+                            $undergrad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
137
+                            $undergrad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
120 138
                         }
121
-                        $undergrad_school_sections_count+=1;
139
+                        $undergrad_assessed_sections_count += 1;
122 140
                     }
123
-                    else
124
-                    {
125
-                        if($course->outcomes_achieved != NULL)
126
-                        {
127
-                            $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
128
-                            $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
129
-                            for($i=1; $i<=count($grad_outcomes_attempted); $i++)
130
-                            {
131
-                                $grad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
132
-                                $grad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
133
-                            }
134
-                            $grad_assessed_sections_count+=1;
141
+                    $undergrad_school_sections_count += 1;
142
+                } else {
143
+                    if ($course->outcomes_achieved != NULL) {
144
+                        $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
145
+                        $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
146
+                        for ($i = 1; $i <= count($grad_outcomes_attempted); $i++) {
147
+                            $grad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
148
+                            $grad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
135 149
                         }
136
-                        $grad_school_sections_count+=1;
150
+                        $grad_assessed_sections_count += 1;
137 151
                     }
138
-                }    
152
+                    $grad_school_sections_count += 1;
153
+                }
139 154
             }
155
+        }
156
+*/
140 157
 
141
-            /**
142
-             * Calculate how many programs achieved and attempted each outcome in this school
143
-             */
144
-
145
-            // Number of programs that achieved a particular learning outcome
146
-            $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
147
-
148
-            // Number of programs that attempted a particular learning outcome
149
-            $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
150
-
151
-            // Fetch programs with participation for the school
152
-            $participating_undergrad_programs = DB::table('VIEW_participating_programs')
153
-                ->whereIn('semester_id', Session::get('semesters_ids'))
154
-                ->where('is_graduate', 0)
155
-                ->where('school_id', $school->id)
156
-                ->groupBy('id')
157
-                ->get();
158
-
159
-            $output = array();
160
-
161
-
162
-            // For each outcome 
163
-            foreach ($outcomes as $outcome)
164
-            {
165
-                // For each program with courses that do assessment
166
-                $programs_with_courses = Program::with(array('courses' => function($query){
167
-                    $query->whereNotNull('outcomes_attempted');
168
-                    $query->whereIn('semester_id', Session::get('semesters_ids'));
169
-                }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
170
-
171
-                foreach ($programs_with_courses as $program)
172
-                {
173
-                    // To acummulate all criteria for one program
174
-                    $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
175
-                    $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
176
-
177
-                    //Flag for counting programs
178
-                    $flag =false;
179
-
180
-                    // For each course in the program
181
-                    foreach ($program->courses as $course)
182
-                    {
183
-                        // If the outcome in question is being evaluated
184
-                        $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
185
-                        $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
186
-                        if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
187
-                            && $course_outcomes_attempted2[$outcome->id]>0)
188
-                        {
189
-                            $achieved_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
190
-                            $attempted_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
191
-
192
-                            // Add one to the programs assessing, if it wasn't added before
193
-                            if(!$flag)
194
-                            {
195
-                                $attemptedUndergradProgramsPerOutcome[$outcome->id]+=1;
196
-                                $flag= true;
197
-                            }
198
-                        }
199
-
200
-                        // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
201
-                        // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
158
+        foreach ($school->programs as $program) {
159
+            foreach ($program->courses as $course) {
160
+                if (!$course->program->is_graduate) {
161
+                    if ($course->outcomes_achieved != NULL) {
162
+                        $course_outcomes_achieved = $course->outcomes_ach();
163
+                        $course_outcomes_attempted = $course->outcomes_att();
164
+                        foreach ($course_outcomes_attempted as $i => $score) {
202 165
 
166
+                            $undergrad_outcomes_attempted[$i] += $score;
167
+                        }
168
+                        foreach ($course_outcomes_achieved as $i => $score) {
169
+                            $undergrad_outcomes_achieved[$i] += $score;
170
+                        }
171
+                        $undergrad_assessed_sections_count += 1;
203 172
                     }
204
-                    //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
205
-                    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)
206
-                    {
207
-                        $achievedUndergradProgramsPerOutcome[$outcome->id]+=1;
208
-                        // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
173
+                    $undergrad_school_sections_count += 1;
174
+                } else {
175
+                    if ($course->outcomes_achieved != NULL) {
176
+                        $course_outcomes_achieved = $course->outcomes_ach();
177
+                        $course_outcomes_attempted = $course->outcomes_att();
178
+                        foreach ($course_outcomes_attempted as $i => $score) {
179
+
180
+                            $grad_outcomes_attempted[$i] += $score;
181
+                        }
182
+                        foreach ($course_outcomes_achieved as $i => $score) {
183
+                            $grad_outcomes_achieved[$i] += $score;
184
+                        }
185
+                        $grad_assessed_sections_count += 1;
209 186
                     }
187
+                    $grad_school_sections_count += 1;
210 188
                 }
211 189
             }
190
+        }
212 191
 
213
-            /**
214
-             * Calculate how many programs achieved and attempted each outcome in this school
215
-             */
216
-
217
-            // Number of programs that achieved a particular learning outcome
218
-            $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
219
-
220
-            // Number of programs that attempted a particular learning outcome
221
-            $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
222
-
223
-            // Fetch programs with participation for the school
224
-            $participating_grad_programs = DB::table('VIEW_participating_programs')
225
-                ->whereIn('semester_id', Session::get('semesters_ids'))
226
-                ->where('is_graduate', 1)
227
-                ->where('school_id', $school->id)
228
-                ->groupBy('id')
229
-                ->get();
230
-
231
-            $output = array();
232
-
233
-
234
-            // For each outcome 
235
-            foreach ($outcomes as $outcome)
236
-            {
237
-                // For each program with courses that do assessment
238
-                $programs_with_courses = Program::with(array('courses' => function($query){
239
-                    $query->whereNotNull('outcomes_attempted');
240
-                    $query->whereIn('semester_id', Session::get('semesters_ids'));
241
-                }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
242
-
243
-                foreach ($programs_with_courses as $program)
244
-                {
245
-                    // To acummulate all criteria for one program
246
-                    $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
247
-                    $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
248
-
249
-                    //Flag for counting programs
250
-                    $flag =false;
251
-
252
-                    // For each course in the program
253
-                    foreach ($program->courses as $course)
254
-                    {
255
-                        // If the outcome in question is being evaluated
256
-                        $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
257
-                        $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
258
-                        if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
259
-                            && $course_outcomes_attempted2[$outcome->id]>0)
260
-                        {
261
-                            $achieved_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
262
-                            $attempted_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
263
-
264
-                            // Add one to the programs assessing, if it wasn't added before
265
-                            if(!$flag)
266
-                            {
267
-                                $attemptedGradProgramsPerOutcome[$outcome->id]+=1;
268
-                                $flag= true;
269
-                            }
270
-                        }
192
+        /**
193
+         * Calculate how many programs achieved and attempted each outcome in this school
194
+         */
271 195
 
272
-                        // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
273
-                        // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
196
+        // Number of programs that achieved a particular learning outcome
197
+        $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
274 198
 
199
+        // Number of programs that attempted a particular learning outcome
200
+        $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
201
+
202
+        // Fetch programs with participation for the school
203
+        $participating_undergrad_programs = DB::table('VIEW_participating_programs')
204
+            ->whereIn('semester_id', Session::get('semesters_ids'))
205
+            ->where('is_graduate', 0)
206
+            ->where('school_id', $school->id)
207
+            ->groupBy('id')
208
+            ->get();
209
+
210
+        $output = array();
211
+
212
+
213
+        // For each outcome 
214
+        foreach ($outcomes as $outcome) {
215
+            // For each program with courses that do assessment
216
+            $programs_with_courses = Program::with(array('courses' => function ($query) {
217
+
218
+                // $query->whereNotNull('outcomes_attempted');
219
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
220
+                $query->join('activities', 'activities.course_id', '=', 'courses.id')
221
+                    ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
222
+                    ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
223
+                    ->where('activities.draft', 0)
224
+                    ->select('courses.*')->distinct();
225
+            }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
226
+
227
+            foreach ($programs_with_courses as $program) {
228
+                // To acummulate all criteria for one program
229
+                $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
230
+                $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
231
+
232
+                //Flag for counting programs
233
+                $flag = false;
234
+
235
+                // For each course in the program
236
+                foreach ($program->courses as $course) {
237
+                    // If the outcome in question is being evaluated
238
+                    $course_outcomes_attempted2 = $course->outcomes_att(); //json_decode($course->outcomes_attempted, true);
239
+                    $course_outcomes_achieved2 = $course->outcomes_ach(); //json_decode($course->outcomes_achieved, true);
240
+                    if (
241
+                        array_key_exists($outcome->id, $course_outcomes_attempted2)
242
+                        && $course_outcomes_attempted2[$outcome->id] > 0
243
+                    ) {
244
+                        $achieved_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
245
+                        $attempted_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
246
+
247
+                        // Add one to the programs assessing, if it wasn't added before
248
+                        if (!$flag) {
249
+                            $attemptedUndergradProgramsPerOutcome[$outcome->id] += 1;
250
+                            $flag = true;
251
+                        }
275 252
                     }
276
-                    //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
277
-                    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)
278
-                    {
279
-                        $achievedGradProgramsPerOutcome[$outcome->id]+=1;
280
-                        // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
281
-                    }
253
+
254
+                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
255
+                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
256
+
257
+                }
258
+                //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
259
+                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) {
260
+                    $achievedUndergradProgramsPerOutcome[$outcome->id] += 1;
261
+                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
282 262
                 }
283 263
             }
284
-            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'));
285 264
         }
286 265
 
266
+        /**
267
+         * Calculate how many programs achieved and attempted each outcome in this school
268
+         */
269
+
270
+        // Number of programs that achieved a particular learning outcome
271
+        $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
272
+
273
+        // Number of programs that attempted a particular learning outcome
274
+        $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
275
+
276
+        // Fetch programs with participation for the school
277
+        $participating_grad_programs = DB::table('VIEW_participating_programs')
278
+            ->whereIn('semester_id', Session::get('semesters_ids'))
279
+            ->where('is_graduate', 1)
280
+            ->where('school_id', $school->id)
281
+            ->groupBy('id')
282
+            ->get();
283
+
284
+        $output = array();
285
+
286
+
287
+        // For each outcome 
288
+        foreach ($outcomes as $outcome) {
289
+            // For each program with courses that do assessment
290
+            $programs_with_courses = Program::with(array('courses' => function ($query) {
291
+                //$query->whereNotNull('outcomes_attempted');
292
+
293
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
294
+                $query->join('activities', 'activities.course_id', '=', 'courses.id')
295
+                    ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
296
+                    ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
297
+                    ->where('activities.draft', 0)
298
+                    ->select('courses.*')->distinct();
299
+            }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
300
+
301
+            foreach ($programs_with_courses as $program) {
302
+                // To acummulate all criteria for one program
303
+                $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
304
+                $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
305
+
306
+                //Flag for counting programs
307
+                $flag = false;
308
+
309
+                // For each course in the program
310
+                foreach ($program->courses as $course) {
311
+                    // If the outcome in question is being evaluated
312
+                    $course_outcomes_attempted2 = $course->outcomes_att();  // json_decode($course->outcomes_attempted, true);
313
+                    $course_outcomes_achieved2 = $course->outcomes_ach(); //json_decode($course->outcomes_achieved, true);
314
+                    if (
315
+                        array_key_exists($outcome->id, $course_outcomes_attempted2)
316
+                        && $course_outcomes_attempted2[$outcome->id] > 0
317
+                    ) {
318
+                        $achieved_outcomes_per_grad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
319
+                        $attempted_outcomes_per_grad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
320
+
321
+                        // Add one to the programs assessing, if it wasn't added before
322
+                        if (!$flag) {
323
+                            $attemptedGradProgramsPerOutcome[$outcome->id] += 1;
324
+                            $flag = true;
325
+                        }
326
+                    }
327
+
328
+                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
329
+                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
330
+
331
+                }
332
+                //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
333
+                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) {
334
+                    $achievedGradProgramsPerOutcome[$outcome->id] += 1;
335
+                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
336
+                }
337
+            }
338
+        }
339
+        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'));
340
+    }
287 341
 }

+ 196
- 52
app/controllers/StudentsController.php View File

@@ -1,29 +1,94 @@
1 1
 <?php
2 2
 
3
-class StudentsController extends \BaseController {
3
+class StudentsController extends \BaseController
4
+{
4 5
 
5 6
   public function show($semester_id, $course_identifier, $number)
6 7
   {
7 8
 
8
-  	$student = Student::where('number', '=', $number)->first();
9
-  	$code = substr($course_identifier, 0, 4);
10
-  	$number = substr($course_identifier, 4, 4);
11
-  	$section = substr($course_identifier, 9, 4);
12
-  	$course = Course::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
13
-  	$title = $student->name;
9
+    $student = Student::where('number', '=', $number)->first();
10
+    $code = substr($course_identifier, 0, 4);
11
+    $number = substr($course_identifier, 4, 4);
12
+    $section = substr($course_identifier, 9, 4);
13
+    $course = Course::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
14
+    $title = $student->name;
14 15
 
15
-  	$activities = $course->assessedActivities;
16
-  	$activitiesArray = array();
17
-  	foreach ($activities as $activity)
18
-  	{
19
-  		$activitiesArray[]=$activity->id;
20
-  	}
16
+
17
+    $activities = $course->assessedActivities;
18
+    //$activitiesArray = array();
19
+    //	foreach ($activities as $activity)
20
+    //	{
21
+    //		$activitiesArray[]=$activity->id;
22
+    //	}
21 23
 
22 24
     // If the student has be assessed
23
-    if(!$activities->isEmpty())
24
-    {
25
+    if (!$activities->isEmpty()) {
26
+
25 27
       // Get the assessments
26
-      $assessments = DB::table('assessments')->whereIn('activity_id', $activitiesArray)->where('student_id', '=', $student->id)->orderBy('created_at')->get();
28
+      $assessments = [];
29
+
30
+      foreach ($activities as $activity) {
31
+
32
+        if ($activity->isStudentAssessed($student->id) == 0)
33
+          continue;
34
+        $assessments[$activity->id]['activity'] = $activity->name;
35
+        $activity_criterion = DB::table('activity_criterion')
36
+          ->join('criteria', 'criteria.id', '=', 'activity_criterion.criterion_id')
37
+          ->where('activity_id', $activity->id)
38
+          ->select('activity_criterion.id as ac_id', 'activity_criterion.weight')
39
+          ->addSelect('criteria.*')
40
+          ->get();
41
+
42
+
43
+        $activity_comments = DB::table('activity_student')
44
+          ->where('student_id', $student->id)
45
+          ->where('activity_id', $activity->id)
46
+          ->first()->comments;
47
+        $sum_of_score = 0;
48
+        $sum_of_weight = 0;
49
+        $max_score = $activity->rubric[0]->max_score;
50
+        foreach ($activity_criterion as $ac) {
51
+
52
+          $assessment_score = DB::table('assessments')
53
+            ->where('activity_criterion_id', $ac->ac_id)
54
+            ->where('student_id', $student->id)
55
+            ->first();
56
+
57
+
58
+          if ($assessment_score) {
59
+            Log::info($assessment_score->student_id);
60
+
61
+            $assessments[$activity->id]["criteria"][$ac->id] = $ac;
62
+            $sum_of_score += $ac->weight * $assessment_score->score;
63
+            $sum_of_weight += $ac->weight;
64
+
65
+            $assessments[$activity->id]["score"][$ac->id] = $assessment_score->score;
66
+            $assessments[$activity->id]['comments'] = $activity_comments;
67
+
68
+            $index_scale = ceil($assessment_score->score * $ac->num_scales / $ac->max_score) - 1;
69
+            if ($index_scale == -1) $index_scale = 0;
70
+
71
+            $assessments[$activity->id]["explication"][$ac->id] = DB::table('criterion_scale')
72
+              ->join('scales', 'scales.id', '=', 'criterion_scale.scale_id')
73
+              ->where("criterion_id", $ac->id)
74
+              ->where("position", $index_scale)
75
+              ->first()
76
+              ->description;
77
+          } else {
78
+            $assessments[$activity->id]["criteria"][$ac->id] = $ac;
79
+            $assessments[$activity->id]["score"][$ac->id] = "N/A";
80
+            $assessments[$activity->id]["explication"][$ac->id] = '';
81
+            $assessments[$activity->id]['comments'] = '';
82
+          }
83
+        }
84
+        if ($sum_of_weight != 0)
85
+          $assessments[$activity->id]['percentage'] = round((100 * ($sum_of_score / ($max_score * $sum_of_weight))), 2);
86
+        else
87
+          $assessments[$activity->id]['percentage'] = 0;
88
+      }
89
+
90
+
91
+      //$assessments = DB::table('assessments')->whereIn('activity_id', $activitiesArray)->where('student_id', '=', $student->id)->orderBy('created_at')->get();
27 92
 
28 93
       // foreach ($assessments as $assessed_activity)
29 94
       // {
@@ -63,9 +128,9 @@ class StudentsController extends \BaseController {
63 128
       //   //Save to activity array
64 129
       //   $activitiesArray[]=$outcomes_per_activity;
65 130
       // }
66
-    }
67
-    else
131
+    } else
68 132
       $assessments = NULL;
133
+    Log::info($assessments);
69 134
 
70 135
     return View::make('local.professors.student', compact('student', 'course', 'title', 'assessments'));
71 136
   }
@@ -73,7 +138,7 @@ class StudentsController extends \BaseController {
73 138
   public function printStudentReport($semester_id, $course_identifier, $number)
74 139
   {
75 140
 
76
-    $student = Student::where('number', '=', $number)->first();
141
+    /*$student = Student::where('number', '=', $number)->first();
77 142
     $code = substr($course_identifier, 0, 4);
78 143
     $number = substr($course_identifier, 4, 4);
79 144
     $section = substr($course_identifier, 9, 4);
@@ -82,57 +147,136 @@ class StudentsController extends \BaseController {
82 147
 
83 148
     $activities = $course->assessedActivities;
84 149
     $activitiesArray = array();
85
-    foreach ($activities as $activity)
86
-    {
87
-      $activitiesArray[]=$activity->id;
150
+    foreach ($activities as $activity) {
151
+      $activitiesArray[] = $activity->id;
88 152
     }
89 153
 
90
-    if(!$activities->isEmpty())
91
-    {
154
+    if (!$activities->isEmpty()) {
92 155
       $assessments = DB::table('assessments')->whereIn('activity_id', $activitiesArray)->where('student_id', '=', $student->id)->get();
93 156
 
94
-      foreach ($assessments as $assessed_activity)
95
-      {
157
+      foreach ($assessments as $assessed_activity) {
96 158
         $outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
97 159
         $outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
98 160
 
99 161
         $single_activity_scores = json_decode($assessed_activity->scores);
100
-        foreach($single_activity_scores as $criterion_id=>$criterion_score)
101
-        {
102
-            // Find corresponding learning outcome;
103
-            $criterion = Criterion::withTrashed()->find($criterion_id);
104
-            $outcome = Outcome::find($criterion->outcome_id);
105
-
106
-            // If criterion is achieved (1), add 1 to all arrays
107
-            if($criterion_score >= Rubric::find($activity->rubric_id)->expected_points)
108
-            {
109
-                $outcomes_attempted[$outcome->id]+=1;
110
-                $outcomes_achieved[$outcome->id]+=1;;
111
-            }
112
-            // Else, only add to the attempted outcomes array
113
-            else
114
-            {
115
-                $outcomes_attempted[$outcome->id]+=1;
116
-            }
162
+        foreach ($single_activity_scores as $criterion_id => $criterion_score) {
163
+          // Find corresponding learning outcome;
164
+          $criterion = Criterion::withTrashed()->find($criterion_id);
165
+          $outcome = Outcome::find($criterion->outcome_id);
166
+
167
+          // If criterion is achieved (1), add 1 to all arrays
168
+          if ($criterion_score >= Rubric::find($activity->rubric_id)->expected_points) {
169
+            $outcomes_attempted[$outcome->id] += 1;
170
+            $outcomes_achieved[$outcome->id] += 1;;
171
+          }
172
+          // Else, only add to the attempted outcomes array
173
+          else {
174
+            $outcomes_attempted[$outcome->id] += 1;
175
+          }
117 176
         }
118 177
 
119 178
         $outcomes_per_activity = array_fill(1, Outcome::all()->count(), 0);
120
-        foreach ($outcomes_attempted as $index=>$outcome_attempted)
121
-        {
122
-          if($outcomes_attempted[$index]!=0)
123
-          {
179
+        foreach ($outcomes_attempted as $index => $outcome_attempted) {
180
+          if ($outcomes_attempted[$index] != 0) {
124 181
             // For each outcome in the activity, calculate and save the percentage
125
-            $outcomes_per_activity[$index] = (float)$outcomes_achieved[$index]/$outcomes_attempted[$index]*100;
182
+            $outcomes_per_activity[$index] = (float)$outcomes_achieved[$index] / $outcomes_attempted[$index] * 100;
126 183
           }
127 184
         }
128 185
 
129 186
         //Save to activity array
130
-        $activitiesArray[]=$outcomes_per_activity;
187
+        $activitiesArray[] = $outcomes_per_activity;
131 188
       }
132
-    }
133
-    else
189
+    } else
190
+      $assessments = NULL;
191
+      */
192
+    $student = Student::where('number', '=', $number)->first();
193
+    $code = substr($course_identifier, 0, 4);
194
+    $number = substr($course_identifier, 4, 4);
195
+    $section = substr($course_identifier, 9, 4);
196
+    $course = Course::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
197
+    $title = $student->name;
198
+
199
+
200
+    $activities = $course->assessedActivities;
201
+    //$activitiesArray = array();
202
+    //	foreach ($activities as $activity)
203
+    //	{
204
+    //		$activitiesArray[]=$activity->id;
205
+    //	}
206
+
207
+    // If the student has be assessed
208
+    if (!$activities->isEmpty()) {
209
+
210
+      // Get the assessments
211
+      $assessments = [];
212
+
213
+      foreach ($activities as $activity) {
214
+
215
+        if ($activity->isStudentAssessed($student->id) == 0)
216
+          continue;
217
+        $assessments[$activity->id]['activity'] = $activity->name;
218
+        $activity_criterion = DB::table('activity_criterion')
219
+          ->join('criteria', 'criteria.id', '=', 'activity_criterion.criterion_id')
220
+          ->where('activity_id', $activity->id)
221
+          ->select('activity_criterion.id as ac_id', 'activity_criterion.weight')
222
+          ->addSelect('criteria.*')
223
+          ->get();
224
+
225
+
226
+        $activity_comments = DB::table('activity_student')
227
+          ->where('student_id', $student->id)
228
+          ->where('activity_id', $activity->id)
229
+          ->first()->comments;
230
+        $sum_of_score = 0;
231
+        $sum_of_weight = 0;
232
+        $max_score = $activity->rubric[0]->max_score;
233
+        foreach ($activity_criterion as $ac) {
234
+
235
+          $assessment_score = DB::table('assessments')
236
+            ->where('activity_criterion_id', $ac->ac_id)
237
+            ->where('student_id', $student->id)
238
+            ->first();
239
+
240
+
241
+          if ($assessment_score) {
242
+            Log::info($assessment_score->student_id);
243
+
244
+            $assessments[$activity->id]["criteria"][$ac->id] = $ac;
245
+            $sum_of_score += $ac->weight * $assessment_score->score;
246
+            $sum_of_weight += $ac->weight;
247
+
248
+            $assessments[$activity->id]["score"][$ac->id] = $assessment_score->score;
249
+            $assessments[$activity->id]['comments'] = $activity_comments;
250
+
251
+            $index_scale = ceil($assessment_score->score * $ac->num_scales / $ac->max_score) - 1;
252
+            if ($index_scale == -1) $index_scale = 0;
253
+
254
+            $assessments[$activity->id]["explication"][$ac->id] = DB::table('criterion_scale')
255
+              ->join('scales', 'scales.id', '=', 'criterion_scale.scale_id')
256
+              ->where("criterion_id", $ac->id)
257
+              ->where("position", $index_scale)
258
+              ->first()
259
+              ->description;
260
+          } else {
261
+            $assessments[$activity->id]["criteria"][$ac->id] = $ac;
262
+            $assessments[$activity->id]["score"][$ac->id] = "N/A";
263
+            $assessments[$activity->id]["explication"][$ac->id] = '';
264
+            $assessments[$activity->id]['comments'] = '';
265
+          }
266
+        }
267
+        if ($sum_of_weight != 0)
268
+          $assessments[$activity->id]['percentage'] = round((100 * ($sum_of_score / ($max_score * $sum_of_weight))), 2);
269
+        else
270
+          $assessments[$activity->id]['percentage'] = 0;
271
+      }
272
+    } else
134 273
       $assessments = NULL;
135 274
 
136
-    return View::make('local.professors.print_student_report', compact('student', 'course', 'title', 'assessments', 'activitiesArray'));
275
+
276
+    return View::make(
277
+      'local.professors.print_student_report',
278
+      // compact('student', 'course', 'title', 'assessments', 'activitiesArray'))
279
+      compact('student', 'course', 'title', 'assessments')
280
+    );
137 281
   }
138 282
 }

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

@@ -40,7 +40,7 @@ class ThreeYearPlanController extends \BaseController
40 40
     }
41 41
   }
42 42
   // load the Three year Plan page
43
-  public function threeYearsReport()
43
+  public function threeYearsReport($program_id)
44 44
   {
45 45
     $user_id = Auth::user()->id;
46 46
 
@@ -64,11 +64,11 @@ class ThreeYearPlanController extends \BaseController
64 64
       ->orderBy('year_start', 'asc')
65 65
       ->get();
66 66
     $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
67
-    $program_id = DB::table('program_user')
67
+    /*   $program_id = DB::table('program_user')
68 68
       ->where('user_id', $user_id)
69 69
       ->select('program_id')
70 70
       ->get();
71
-    $program_id = $program_id[0]->program_id;
71
+    $program_id = $program_id[0]->program_id;*/
72 72
     $outcomes = DB::table('outcomes')->where('deactivation_date', '=', null)->orderBy('name', 'ASC')->get();
73 73
     // se annadio la nueva variable
74 74
     return View::make('global.view-three-year-plan', compact('title', 'last_year', 'outcomes', 'typs', 'criteria', 'semesters', 'program_id'));

+ 37
- 1
app/controllers/TransformativeActionsController.php View File

@@ -1230,6 +1230,39 @@ class TransformativeActionsController extends \BaseController
1230 1230
       }
1231 1231
     }
1232 1232
 
1233
+    $typ_semester_outcome = DB::table('typ_semester_outcome')
1234
+      ->whereIn('semester_id', $semesters)
1235
+      ->where('outcome_id', $outcome_id)
1236
+      ->lists('id');
1237
+
1238
+
1239
+    //each row has objectives, repeated ta, but distinct activity_criterion_id
1240
+    $objective_ta = DB::table('typ_semester_objectives')
1241
+      ->join('transformative_objective as trob', 'trob.objective_id', '=', 'typ_semester_objectives.objective_id')
1242
+      ->join('objectives', 'trob.objective_id', '=', 'objective_id')
1243
+      ->join('transformative_actions', 'transformative_actions.id', 'trob.ta_id')
1244
+      ->whereIn('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome)
1245
+      ->select('transformative_actions.*')
1246
+      ->addSelect('objectives.*')
1247
+      ->distinct()
1248
+      ->get();
1249
+
1250
+    $objective_ta = DB::table('typ_semester_objectives')
1251
+      ->join('transformative_objective as trob', 'trob.objective_id', '=', 'typ_semester_objectives.objective_id')
1252
+      ->join('objectives', 'trob.objective_id', '=', 'objective_id')
1253
+      ->join('transformative_actions', 'transformative_actions.id', 'trob.ta_id')
1254
+      ->whereIn('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome)
1255
+      ->select('transformative_actions.*')
1256
+      ->addSelect('objectives.*')
1257
+      ->distinct()
1258
+      ->lists();
1259
+
1260
+
1261
+
1262
+
1263
+
1264
+
1265
+
1233 1266
     $grouped_courses = DB::table('courses')
1234 1267
       ->whereIn('program_id', $programs)
1235 1268
       ->whereIn('semester_id', $semesters)
@@ -1240,6 +1273,9 @@ class TransformativeActionsController extends \BaseController
1240 1273
 
1241 1274
 
1242 1275
 
1276
+
1277
+
1278
+
1243 1279
     foreach ($grouped_courses as $course_name) {
1244 1280
       $course_name->sections = DB::table('courses')
1245 1281
         ->where('code', $course_name->code)
@@ -1258,7 +1294,7 @@ class TransformativeActionsController extends \BaseController
1258 1294
           ->where('criterion_objective_outcome.outcome_id', $outcome_id)
1259 1295
           ->select('activities.id as activity_id', 'activities.name')
1260 1296
           ->addSelect('transformative_actions.*', 'transformative_activity_criterion.trans_action_id as trans_action_id')
1261
-          ->groupBy('transformative_actions.id')
1297
+          ->groupBy('transformative_actions.id_')
1262 1298
           ->get();
1263 1299
         foreach ($section->activities as $activity) {
1264 1300
           $activity->objectives = DB::table('transformative_objective')

+ 25
- 0
app/models/Activity.php View File

@@ -211,6 +211,31 @@ class Activity extends Eloquent
211 211
 
212 212
     return boolval(count($assessments));
213 213
   }
214
+
215
+  public function isStudentAssessed($student_id)
216
+  {
217
+    return DB::table('activities')
218
+      ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
219
+      ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
220
+      ->where('activity_id', $this->id)
221
+      ->where('student_id', $student_id)
222
+      ->count();
223
+  }
224
+  public function transforming_actions()
225
+  {
226
+    $transformative_action = DB::table('activities')
227
+      ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
228
+      ->join('transformative_activity_criterion as tac', 'tac.activity_criterion_id', '=', 'ac.id')
229
+      ->join('transformative_actions as ta', 'ta.id', '=', 'tac.trans_action_id')
230
+      ->where('activities.id', $this->id)
231
+      ->select('ta.*')
232
+      ->first();
233
+    if ($transformative_action)
234
+      return $transformative_action->description;
235
+    else return '';
236
+  }
237
+
238
+
214 239
   public function getOAttArrayAttribute()
215 240
   {
216 241
 

+ 42
- 2
app/models/Course.php View File

@@ -34,13 +34,32 @@ class Course extends Eloquent
34 34
   public function assessedActivities()
35 35
   {
36 36
     // return $this->hasMany('Activity')->whereNotNull('activities.outcomes_attempted')->orderBy('date', 'asc');
37
-    return $this->hasMany('Activity')->where('activities.draft', 0)->orderBy('date', 'asc');
37
+    $activitiesAssessed = DB::table('activities')
38
+      ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
39
+      ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
40
+      ->where('activities.course_id', $this->id)
41
+      ->select('activities.id')
42
+      ->distinct()
43
+      ->lists('activities.id');
44
+    Log::info($activitiesAssessed);
45
+
46
+    return $this->hasMany('Activity')->whereIn('activities.id', $activitiesAssessed)->orderBy('date', 'asc');
47
+
48
+    //    return $this->hasMany('Activity')->where('activities.draft', 0)->orderBy('date', 'asc');
38 49
   }
39 50
 
40 51
   public function publishedActivities()
41 52
   {
53
+    $activitiesAssessed = DB::table('activities')
54
+      ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
55
+      ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
56
+      ->where('activities.course_id', $this->id)
57
+      ->where('activities.draft', 0)
58
+      ->select('activities.id')
59
+      ->distinct()
60
+      ->lists('activities.id');
42 61
     //return $this->hasMany('Activity')->whereNotNull('activities.outcomes_attempted')->where('activities.draft', 0)->orderBy('date', 'asc');
43
-    return $this->hasMany('Activity')->where('activities.draft', 0)->orderBy('date', 'asc');
62
+    return  $this->hasMany('Activity')->whereIn('activities.id', $activitiesAssessed)->orderBy('date', 'asc');
44 63
   }
45 64
 
46 65
   public function outcomes_attempted()
@@ -136,6 +155,27 @@ class Course extends Eloquent
136 155
     return $outcomes_achieved;
137 156
   }
138 157
 
158
+  public function someSectionAssessed()
159
+  {
160
+    $all_sections = DB::table('courses')
161
+      ->join('activities', 'activities.course_id', '=', 'courses.id')
162
+      ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
163
+      ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
164
+      ->where('courses.name', $this->name)
165
+      ->where('code', $this->code)
166
+      ->where('number', $this->number)
167
+      ->where('semester_id', $this->semester_id)
168
+      ->where(
169
+        'program_id',
170
+        $this->program_id
171
+      )
172
+      ->where('activities.draft', 0)
173
+      ->groupBy('courses.id')
174
+      ->count();
175
+
176
+    return $all_sections;
177
+  }
178
+
139 179
 
140 180
 
141 181
   public function outcomes_achieved()

+ 175
- 187
app/models/Outcome.php View File

@@ -24,47 +24,47 @@ class Outcome extends Eloquent
24 24
 		return $this->hasMany('Objective');
25 25
 		//		return $this->belongsToMany('Objective', 'objective_outcome');
26 26
 	}
27
-// 	public function attempted($semester, $is_grad)
28
-// 	{
29
-// 		return DB::table('new_criteria')
30
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
31
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
32
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
33
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
34
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
35
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
36
-// 	    	->where('programs.is_graduate','=',$is_grad)
37
-// 	    	->where('courses.semester_id','=',$semester)
38
-// 	    	->count(DB::raw('DISTINCT new_criteria.id,activity_criterion.activity_id'))
39
-// 			;
40
-//
41
-// 	}
42
-// 	public function attempted($semester, $is_grad)
43
-// 	{
44
-// 		 $criteria=DB::table('new_criteria')
45
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
46
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
47
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
48
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
49
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
50
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
51
-// 	    	->where('programs.is_graduate','=',$is_grad)
52
-// 	    	->where('courses.semester_id','=',$semester)
53
-// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
54
-// 	    	->distinct()
55
-// 	    	->get()
56
-// 			;
57
-// 		$conteo=0;
58
-// 		foreach($criteria as $criterion)
59
-// 		{
60
-// 			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
61
-// 			if($students_attempted)
62
-// 			{
63
-// 				$conteo++;
64
-// 			}
65
-// 		}
66
-// 		return $conteo;
67
-// 	}
27
+	// 	public function attempted($semester, $is_grad)
28
+	// 	{
29
+	// 		return DB::table('new_criteria')
30
+	// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
31
+	// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
32
+	// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
33
+	// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
34
+	// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
35
+	// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
36
+	// 	    	->where('programs.is_graduate','=',$is_grad)
37
+	// 	    	->where('courses.semester_id','=',$semester)
38
+	// 	    	->count(DB::raw('DISTINCT new_criteria.id,activity_criterion.activity_id'))
39
+	// 			;
40
+	//
41
+	// 	}
42
+	// 	public function attempted($semester, $is_grad)
43
+	// 	{
44
+	// 		 $criteria=DB::table('new_criteria')
45
+	// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
46
+	// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
47
+	// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
48
+	// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
49
+	// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
50
+	// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
51
+	// 	    	->where('programs.is_graduate','=',$is_grad)
52
+	// 	    	->where('courses.semester_id','=',$semester)
53
+	// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
54
+	// 	    	->distinct()
55
+	// 	    	->get()
56
+	// 			;
57
+	// 		$conteo=0;
58
+	// 		foreach($criteria as $criterion)
59
+	// 		{
60
+	// 			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
61
+	// 			if($students_attempted)
62
+	// 			{
63
+	// 				$conteo++;
64
+	// 			}
65
+	// 		}
66
+	// 		return $conteo;
67
+	// 	}
68 68
 	public static function active_by_semesters($selected_semesters, $level)
69 69
 	{
70 70
 		$min_start = "9000-01-01 00:00:00";
@@ -99,30 +99,29 @@ class Outcome extends Eloquent
99 99
 		foreach ($semesters as $semester) {
100 100
 			$semesters_array[] = $semester->id;
101 101
 		}
102
-// 		 $programs=DB::table('programs')
103
-// 	    	->join('courses', 'programs.id', '=', 'courses.program_id')
104
-// 	    	->join('activities', 'activities.course_id', '=', 'courses.id')
105
-// 	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
106
-// 	    	->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
107
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
108
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
109
-// 	    	->whereIn('courses.semester_id',$semesters_array)
110
-// 	    	->distinct()
111
-// 	    	->select('programs.id')
112
-// 	    	->get()
113
-// 			;
114
-		 $programs=DB::table('programs')
115
-	    	->join('courses', 'programs.id', '=', 'courses.program_id')
116
-	    	->join('activities', 'activities.course_id', '=', 'courses.id')
117
-	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
118
-	    	->join('criteria', 'activity_criterion.criterion_id', '=', 'criteria.id')
119
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
120
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
121
-	    	->whereIn('courses.semester_id',$semesters_array)
122
-	    	->distinct()
123
-	    	->select('programs.id')
124
-	    	->get()
125
-			;
102
+		// 		 $programs=DB::table('programs')
103
+		// 	    	->join('courses', 'programs.id', '=', 'courses.program_id')
104
+		// 	    	->join('activities', 'activities.course_id', '=', 'courses.id')
105
+		// 	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
106
+		// 	    	->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
107
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
108
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
109
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
110
+		// 	    	->distinct()
111
+		// 	    	->select('programs.id')
112
+		// 	    	->get()
113
+		// 			;
114
+		$programs = DB::table('programs')
115
+			->join('courses', 'programs.id', '=', 'courses.program_id')
116
+			->join('activities', 'activities.course_id', '=', 'courses.id')
117
+			->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
118
+			->join('criteria', 'activity_criterion.criterion_id', '=', 'criteria.id')
119
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
120
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
121
+			->whereIn('courses.semester_id', $semesters_array)
122
+			->distinct()
123
+			->select('programs.id')
124
+			->get();
126 125
 
127 126
 		return $programs;
128 127
 	}
@@ -133,40 +132,37 @@ class Outcome extends Eloquent
133 132
 		foreach ($semesters as $semester) {
134 133
 			$semesters_array[] = $semester->id;
135 134
 		}
136
-// 		 $criteria=DB::table('new_criteria')
137
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
138
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
139
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
140
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
141
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
142
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
143
-// 	    	->where('programs.is_graduate','=',$is_grad)
144
-// 	    	->whereIn('courses.semester_id',$semesters_array)
145
-// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
146
-// 	    	->distinct()
147
-// 	    	->get()
148
-// 			;
149
-		 $criteria=DB::table('criteria')
150
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
151
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
152
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
153
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
154
-	    	->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
155
-	    	->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
156
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
157
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
158
-	    	->where('programs.is_graduate','=',$is_grad)
159
-	    	->whereIn('courses.semester_id',$semesters_array)
160
-	    	->select('criteria.id','expected_percentage','activity_criterion.activity_id')
161
-	    	->distinct()
162
-	    	->get()
163
-			;
164
-		$conteo=0;
165
-		foreach($criteria as $criterion)
166
-		{
167
-			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
168
-			if($students_attempted)
169
-			{
135
+		// 		 $criteria=DB::table('new_criteria')
136
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
137
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
138
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
139
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
140
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
141
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
142
+		// 	    	->where('programs.is_graduate','=',$is_grad)
143
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
144
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
145
+		// 	    	->distinct()
146
+		// 	    	->get()
147
+		// 			;
148
+		$criteria = DB::table('criteria')
149
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
150
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
151
+			->join('courses', 'activities.course_id', '=', 'courses.id')
152
+			->join('programs', 'programs.id', '=', 'courses.program_id')
153
+			->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
154
+			->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
155
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
156
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
157
+			->where('programs.is_graduate', '=', $is_grad)
158
+			->whereIn('courses.semester_id', $semesters_array)
159
+			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
160
+			->distinct()
161
+			->get();
162
+		$conteo = 0;
163
+		foreach ($criteria as $criterion) {
164
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
165
+			if ($students_attempted) {
170 166
 				$conteo++;
171 167
 			}
172 168
 		}
@@ -183,38 +179,35 @@ class Outcome extends Eloquent
183 179
 			// 		exit();
184 180
 			$courses_array[] = $course->id;
185 181
 		}
186
-// 		 $criteria=DB::table('new_criteria')
187
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
188
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
189
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
190
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
191
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
192
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
193
-// 	    	->whereIn('courses.id',$courses_array)
194
-// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
195
-// 	    	->distinct()
196
-// 	    	->get()
197
-// 			;
198
-		 $criteria=DB::table('criteria')
199
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
200
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
201
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
202
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
203
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
182
+		// 		 $criteria=DB::table('new_criteria')
183
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
184
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
185
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
186
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
187
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
188
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
189
+		// 	    	->whereIn('courses.id',$courses_array)
190
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
191
+		// 	    	->distinct()
192
+		// 	    	->get()
193
+		// 			;
194
+		$criteria = DB::table('criteria')
195
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
196
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
197
+			->join('courses', 'activities.course_id', '=', 'courses.id')
198
+			->join('programs', 'programs.id', '=', 'courses.program_id')
199
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
204 200
 			->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
205 201
 			->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
206
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
207
-	    	->whereIn('courses.id',$courses_array)
208
-	    	->select('criteria.id','expected_percentage','activity_criterion.activity_id')
209
-	    	->distinct()
210
-	    	->get()
211
-			;
212
-		$conteo=0;
213
-		foreach($criteria as $criterion)
214
-		{
215
-			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
216
-			if($students_attempted)
217
-			{
202
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
203
+			->whereIn('courses.id', $courses_array)
204
+			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
205
+			->distinct()
206
+			->get();
207
+		$conteo = 0;
208
+		foreach ($criteria as $criterion) {
209
+			$students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
210
+			if ($students_attempted) {
218 211
 				$conteo++;
219 212
 			}
220 213
 		}
@@ -230,32 +223,31 @@ class Outcome extends Eloquent
230 223
 			$courses_array[] = $course->id;
231 224
 		}
232 225
 
233
-// 		 $criteria=DB::table('new_criteria')
234
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
235
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
236
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
237
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
238
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
239
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
240
-// 	    	->whereIn('courses.id',$courses_array)
241
-// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
242
-// 	    	->distinct()
243
-// 	    	->get()
244
-// 			;
245
-		 $criteria=DB::table('criteria')
246
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
247
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
248
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
249
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
250
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
226
+		// 		 $criteria=DB::table('new_criteria')
227
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
228
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
229
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
230
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
231
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
232
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
233
+		// 	    	->whereIn('courses.id',$courses_array)
234
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
235
+		// 	    	->distinct()
236
+		// 	    	->get()
237
+		// 			;
238
+		$criteria = DB::table('criteria')
239
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
240
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
241
+			->join('courses', 'activities.course_id', '=', 'courses.id')
242
+			->join('programs', 'programs.id', '=', 'courses.program_id')
243
+			->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
251 244
 			->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
252 245
 			->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
253
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
254
-	    	->whereIn('courses.id',$courses_array)
255
-	    	->select('criteria.id','expected_percentage','activity_criterion.activity_id')
256
-	    	->distinct()
257
-	    	->get()
258
-			;
246
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
247
+			->whereIn('courses.id', $courses_array)
248
+			->select('criteria.id', 'expected_percentage as expected_percentage_students_achieving', 'activity_criterion.activity_id')
249
+			->distinct()
250
+			->get();
259 251
 
260 252
 		$conteo = 0;
261 253
 		foreach ($criteria as $criterion) {
@@ -281,36 +273,35 @@ class Outcome extends Eloquent
281 273
 			$semesters_array[] = $semester->id;
282 274
 		}
283 275
 
284
-//   DB::enableQueryLog();
285
-// 		 $criteria=DB::table('new_criteria')
286
-// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
287
-// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
288
-// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
289
-// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
290
-// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
291
-// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
292
-// 	    	->where('programs.is_graduate','=',$is_grad)
293
-// 	    	->whereIn('courses.semester_id',$semesters_array)
294
-// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
295
-// 	    	->distinct()
296
-// 	    	->get()
297
-// 			;
298
-		 $criteria=DB::table('criteria')
299
-	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
300
-	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
301
-	    	->join('courses', 'activities.course_id', '=', 'courses.id')
302
-	    	->join('programs', 'programs.id', '=', 'courses.program_id')
303
-	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
276
+		//   DB::enableQueryLog();
277
+		// 		 $criteria=DB::table('new_criteria')
278
+		// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
279
+		// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
280
+		// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
281
+		// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
282
+		// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
283
+		// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
284
+		// 	    	->where('programs.is_graduate','=',$is_grad)
285
+		// 	    	->whereIn('courses.semester_id',$semesters_array)
286
+		// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
287
+		// 	    	->distinct()
288
+		// 	    	->get()
289
+		// 			;
290
+		$criteria = DB::table('criteria')
291
+			->join('activity_criterion', 'activity_criterion.criterion_id', '=', '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', '=', 'criteria.id')
304 296
 			->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
305 297
 			->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
306
-	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
307
-	    	->where('programs.is_graduate','=',$is_grad)
308
-	    	->whereIn('courses.semester_id',$semesters_array)
309
-	    	->select('criteria.id','expected_percentage','activity_criterion.activity_id')
310
-	    	->distinct()
311
-	    	->get()
312
-			;
313
-// 		dd(DB::getQueryLog());
298
+			->where('criterion_objective_outcome.outcome_id', '=', $this->id)
299
+			->where('programs.is_graduate', '=', $is_grad)
300
+			->whereIn('courses.semester_id', $semesters_array)
301
+			->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
302
+			->distinct()
303
+			->get();
304
+		// 		dd(DB::getQueryLog());
314 305
 
315 306
 		$conteo = 0;
316 307
 		foreach ($criteria as $criterion) {
@@ -319,13 +310,10 @@ class Outcome extends Eloquent
319 310
 
320 311
 			if ($students_attempted) {
321 312
 				$percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
322
-			} 
323
-			else
324
-			{
325
-				$percentage_students_who_achieved=0;
313
+			} else {
314
+				$percentage_students_who_achieved = 0;
326 315
 			}
327
-			if($percentage_students_who_achieved>=$criterion->expected_percentage)
328
-			{
316
+			if ($percentage_students_who_achieved >= $criterion->expected_percentage) {
329 317
 				$conteo++;
330 318
 			}
331 319
 		}

+ 2
- 2
app/routes.php View File

@@ -375,7 +375,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
375 375
 
376 376
 
377 377
         // Show users plan de tres a~nos
378
-        Route::get('three-years-plan', 'ThreeYearPlanController@threeYearsReport');
378
+        Route::get('three-years-plan/{program_id}', 'ThreeYearPlanController@threeYearsReport');
379 379
         Route::post('fetchThreeYears', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@fetchThreeYears'));
380 380
         Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
381 381
         Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));
@@ -483,7 +483,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
483 483
         Route::post('transformativeAction/approveTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@approveTA'));
484 484
 
485 485
         // Show users plan de tres a~nos
486
-        Route::get('three-years-plan', 'ThreeYearPlanController@threeYearsReport');
486
+        Route::get('three-years-plan/{program_id}', 'ThreeYearPlanController@threeYearsReport');
487 487
         Route::post('fetchThreeYears', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@fetchThreeYears'));
488 488
         Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
489 489
         Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));

+ 2
- 0
app/views/local/managers/admins/assessment_report.blade.php View File

@@ -67,6 +67,8 @@
67 67
                                             ->where('code', $course->code)->where('number',$course->number)
68 68
                                             ->whereIn('semester_id', Session::get('semesters_ids'))
69 69
                                             ->get();
70
+
71
+                                            
70 72
                                         ?>
71 73
 
72 74
                                         @if(count($sections_evaluating_outcome))

+ 1
- 1
app/views/local/managers/pCoords/_navigation.blade.php View File

@@ -15,7 +15,7 @@
15 15
 
16 16
     
17 17
           <li><a href="{{ URL::action('AnnualPlansController@showPlan', Auth::user()->programs[0]->id)}}">Annual Plan</a><li>
18
-        <li>{{ HTML::linkAction('ThreeYearPlanController@threeYearsReport', 'Three Years Plan') }}</li>
18
+        <li><a href="{{ URL::action('ThreeYearPlanController@threeYearsReport', Auth::user()->programs[0]->id) }}">Three Years Plan</a></li>
19 19
       </ul>
20 20
       </li>
21 21
      

+ 1
- 1
app/views/local/managers/pCoords/overview.blade.php View File

@@ -75,7 +75,7 @@
75 75
                                                         <td class="col-md-3">{{{ $grouped_course->name}}}</td>
76 76
                                                         <td class="col-md-3">{{{ $grouped_course->program->name }}}</td>
77 77
                                                         <td class="col-md-2">
78
-                                                            @if($grouped_course->outcomes_attempted!=NULL)
78
+                                                            @if($grouped_course->someSectionAssessed()!=0)
79 79
                                                                 Yes
80 80
                                                             @else
81 81
                                                                 No

+ 7
- 1
app/views/local/managers/sCoords/_navigation.blade.php View File

@@ -43,7 +43,13 @@
43 43
           <li><a href ="{{ URL::action('AnnualPlansController@showPlan', array($program->id))}}" >{{$program->name}}</a></li>
44 44
           @endforeach
45 45
         </ul></li>
46
-
46
+        <li class='dropdown'>
47
+          <a href ='#' class ='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded="false"> Three year Plans<span class="caret"></span></a>
48
+          <ul class ='dropdown-menu' role='menu'>
49
+            @foreach (Auth::user()->school->programs as $program)
50
+            <li><a href ="{{ URL::action('ThreeYearPlanController@threeYearsReport', array($program->id))}}" >{{$program->name}}</a></li>
51
+            @endforeach
52
+          </ul></li>
47 53
       <li class="dropdown">
48 54
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
49 55
         <ul class="dropdown-menu" role="menu">

+ 4
- 4
app/views/local/managers/sCoords/criteria.blade.php View File

@@ -110,7 +110,7 @@
110 110
                 Edit
111 111
             </div>
112 112
             <div class="panel-body">
113
-                {{ Form::open(array('action' => 'CriteriaController@update')) }}
113
+                {{ Form::open(array('action' => 'CriteriaController@update','id'=>'update_criterion')) }}
114 114
                 <button class="btn btn-md btn-secondary filterButton">
115 115
                     <span class="glyphicon glyphicon-plus">
116 116
                     </span>
@@ -256,7 +256,7 @@
256 256
             </div>
257 257
         </div>
258 258
     </div>
259
-</div>
259
+</div> 
260 260
 <script>
261 261
 
262 262
     var selectOptions = document.getElementById('outcome0').innerHTML;
@@ -974,8 +974,8 @@ alert("The criterion is already used in assessments. Editting the criterion will
974 974
                         $('#status').val(0);
975 975
                     else
976 976
                         $('#status').val(1);
977
-                    $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
978
-                    var maximum = json.criteria[0].maximum_score;
977
+                    $('#assoc_maximum_score').val(json.criteria[0].max_score);
978
+                    var maximum = json.criteria[0].max_score;
979 979
 
980 980
                     addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales");
981 981
                     $('#Num_assoc_scale').val(json.criteria[0].num_scales)

+ 10
- 3
app/views/local/managers/shared/limited-course.blade.php View File

@@ -91,14 +91,21 @@
91 91
                     <tbody>
92 92
                         @foreach($course->activities as $activity)
93 93
                         <tr>
94
+                            <?php
95
+                                Log::info($activity);
96
+                                Log::info($activity->rubric);
97
+                                $bool = empty($activity->rubric);
98
+                                Log::info($bool);
99
+                                
100
+                                ?>
94 101
                             <td>{{{ $activity->name }}}</td>
95 102
                             <td>{{{ date('m/d/y', strtotime($activity->updated_at))  }}}</td>
96 103
                             <td>
97
-                                @if($activity->rubric !=NULL)
98
-                                    {{ HTML::linkAction('RubricsController@show_limited', $activity->rubric->name, array($activity->rubric->id)) }}
104
+                                @if(isset($activity->rubric[0]))
105
+                                    {{ HTML::linkAction('RubricsController@show_limited', $activity->rubric[0]->name, array($activity->rubric[0]->id)) }}
99 106
                                 @endif
100 107
                             </td>
101
-                            <td>{{{ $activity->transforming_actions }}}</td>
108
+                            <td>{{{ $activity->transforming_actions() }}}</td>
102 109
                         </tr>
103 110
                         @endforeach
104 111
                     </tbody>

+ 21
- 12
app/views/local/managers/shared/view_rubric_limited.blade.php View File

@@ -27,33 +27,42 @@
27 27
           <th></th>
28 28
           <th>Learning Outcome</th>
29 29
           <th>Criterion</th>
30
-          <th>Beginning (1-2)</th>
31
-          <th>In Progress (3-4)</th>
32
-          <th>Good (5-6)</th>
33
-          <th>Excellent (7-8)</th>
30
+          @foreach ($rubric->titles as $i=> $title)
31
+              <th>{{$title}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}} - {{(1+$i)*($rubric->max_score/$rubric->num_scales)}})
32
+          @endforeach
34 33
         </tr>
35 34
       </thead>
36 35
       <tbody>
37
-      @foreach(json_decode($rubric->contents) as $index => $criterion)
36
+      @foreach($rubric_criterion as $index => $criterion)
38 37
         <tr data-criterion-copyright="{{ $criterion->copyright }}" data-criterion-notes="{{ $criterion->notes }}">
39 38
           @if(isset($criterion->notes))
40 39
           <td>{{ $index + 1 }}.</td>
41
-          <td>{{ Outcome::find($criterion->outcome_id)->name }} </td>
40
+          <td>@foreach($criterion->outcomes as $index => $outcome)
41
+        
42
+            <li>{{$outcome}}</li>
43
+                    
44
+                    @endforeach
45
+                   </td>
42 46
           <td>
43 47
             <span><em data-toggle="tooltip" data-placement="top" title="{{ $criterion->notes }}">{{{ $criterion->name }}}</em></span>
44 48
             <sup></sup>
45 49
           </td>
46 50
           @else
47 51
           <td>{{ $index + 1 }}.</td>
48
-          <td>{{ Outcome::find($criterion->outcome_id)->name }} </td>
49
-          <td>
52
+          <td>@foreach($criterion->outcomes as $index => $outcome)
53
+        
54
+            <li>{{$outcome}}</li>
55
+                    
56
+                    @endforeach
57
+                   </td>
58
+                    <td>
50 59
             <span>{{{ $criterion->name }}}</span> <sup></sup>
51 60
           </td>
52 61
           @endif
53
-          <td>{{{ $criterion->description12 }}}</td>
54
-          <td>{{{ $criterion->description34 }}}</td>
55
-          <td>{{{ $criterion->description56 }}}</td>
56
-          <td>{{{ $criterion->description78 }}}</td>
62
+          @foreach($criterion->scales as $scale)
63
+            <td>{{ nl2br($scale) }}</td>
64
+
65
+            @endforeach
57 66
         </tr>
58 67
       @endforeach
59 68
       </tbody>

+ 25
- 30
app/views/local/professors/print_student_report.blade.php View File

@@ -119,17 +119,17 @@ echo
119 119
 
120 120
 
121 121
 @if($assessments!=NULL)
122
-  @foreach($assessments as $assessment)
122
+  @foreach($assessments as $activity_id => $activity)
123 123
     <?php
124
-      $activity = Activity::find($assessment->activity_id);
124
+      //$activity = Activity::find($assessment->activity_id);
125 125
 
126 126
       // Used to get custom rubric criterion indicators
127
-      $rubric_contents = json_decode(Rubric::find($activity->rubric_id)->contents, true);
127
+     // $rubric_contents = json_decode(Rubric::find($activity->rubric_id)->contents, true);
128 128
     ?>
129 129
 
130 130
     <div class="panel panel-default">
131 131
         <div class="panel-heading">
132
-            <h3 class="panel-title">{{ $activity->name }}</h3>
132
+            <h3 class="panel-title">{{ $assessments[$activity_id]['activity'] }}</h3>
133 133
         </div>
134 134
         <div class="panel-body">
135 135
             <table class="table table-striped table-condensed">
@@ -143,37 +143,32 @@ echo
143 143
                 <tbody>
144 144
                     <?php
145 145
 
146
-                    $scores = json_decode($assessment->scores, true);
146
+                    //$scores = json_decode($assessment->scores, true);
147 147
 
148 148
                     ?>
149 149
 
150
-                    @foreach($rubric_contents as $row)
151
-
152
-                    <?php $real_score = $scores[$row['id']]; ?>
153
-
154
-                    <tr>
155
-                        <td>{{{ $row['name'] }}}</td>
156
-                        <td>{{{ $real_score }}}</td>
157
-                        <td>
158
-                            @if($real_score == 1 || $real_score == 2)
159
-                                {{ nl2br($row['description12']) }}
160
-                            @elseif ($real_score == 3 || $real_score == 4)
161
-                                {{ nl2br($row['description34']) }}
162
-                            @elseif ($real_score == 5 || $real_score == 6)
163
-                                {{ nl2br($row['description56']) }}
164
-                            @elseif ($real_score == 7 || $real_score == 8)
165
-                                {{ nl2br($row['description78']) }}
166
-                            @else
167
-                                There is not enough information to assess this criterion, or the student did not complete the required work.
168
-                            @endif
169
-                        </td>
170
-                    </tr>
171
-                    @endforeach
150
+                    @foreach($assessments[$activity_id]["criteria"] as $activity_criterion_id => $criteria)
151
+
152
+                        
153
+
154
+                        <tr>
155
+                            <td>{{{ $criteria->name }}}</td>
156
+                            <td>{{{$assessments[$activity_id]["score"][$activity_criterion_id]}}}</td>
157
+                            <td>
158
+                                @if($assessments[$activity_id]['score'][$activity_criterion_id] != 0 || $assessments[$activity_id]['score'][$activity_criterion_id] !="N/A")
159
+                                    {{ $assessments[$activity_id]['explication'][$activity_criterion_id] }}
160
+  
161
+                                @else
162
+                                    There is not enough information to assess this criterion, or the student did not complete the required work.
163
+                                @endif
164
+                            </td>
165
+                        </tr>
166
+                        @endforeach
172 167
                 </tbody>
173 168
             </table>
174 169
 
175
-            <p class="lead"><strong>Percentage:</strong> {{ $assessment->percentage }}%</p>
176
-            <p class="lead"><strong>Comments:</strong> {{ $assessment->comments }}</p>
170
+            <p class="lead"><strong>Percentage:</strong> {{ $assessments[$activity_id]['percentage'] }}%</p>
171
+            <p class="lead"><strong>Comments:</strong> {{ $assessments[$activity_id]['comments']}}</p>
177 172
         </div>
178 173
     </div>
179 174
   @endforeach
@@ -182,7 +177,7 @@ echo
182 177
 @endif
183 178
 
184 179
 
185
-<?
180
+<?php
186 181
 
187 182
 echo '</body>';
188 183
 echo '</html>';

+ 15
- 20
app/views/local/professors/student.blade.php View File

@@ -29,23 +29,23 @@
29 29
 
30 30
 <!-- <div class="row">
31 31
   <div class="col-md-12" id="graph"></div>
32
-</div> -->
32
+</div> --> 
33 33
 
34 34
 @if($assessments!=NULL)
35 35
   <div class="row">
36 36
     <div class="col-md-12">
37 37
       <h3>Assessment Results </h3>
38
-      @foreach($assessments as $assessment)
38
+      @foreach($assessments as $activity_id => $activity)
39 39
         <?php
40
-          $activity = Activity::find($assessment->activity_id);
40
+          //$activity = Activity::find($assessment->activity_id);
41 41
 
42 42
           // Used to get custom rubric criterion indicators
43
-          $rubric_contents = json_decode(Rubric::find($activity->rubric_id)->contents, true);
43
+          //$rubric_contents = json_decode(Rubric::find($activity->rubric_id)->contents, true);
44 44
         ?>
45 45
 
46 46
         <div class="panel panel-default">
47 47
             <div class="panel-heading">
48
-                <h3 class="panel-title">{{ $activity->name }}</h3>
48
+                <h3 class="panel-title">{{ $assessments[$activity_id]['activity'] }}</h3>
49 49
             </div>
50 50
             <div class="panel-body">
51 51
                 <table class="table table-striped table-condensed">
@@ -59,26 +59,21 @@
59 59
                     <tbody>
60 60
                         <?php
61 61
 
62
-                        $scores = json_decode($assessment->scores, true);
62
+                       // $scores = json_decode($assessment->scores, true);
63 63
 
64 64
                         ?>
65 65
 
66
-                        @foreach($rubric_contents as $row)
66
+                        @foreach($assessments[$activity_id]["criteria"] as $activity_criterion_id => $criteria)
67 67
 
68
-                        <?php $real_score = $scores[$row['id']]; ?>
68
+                        
69 69
 
70 70
                         <tr>
71
-                            <td>{{{ $row['name'] }}}</td>
72
-                            <td>{{{ $real_score }}}</td>
71
+                            <td>{{{ $criteria->name }}}</td>
72
+                            <td>{{{$assessments[$activity_id]["score"][$activity_criterion_id]}}}</td>
73 73
                             <td>
74
-                                @if($real_score == 1 || $real_score == 2)
75
-                                    {{ nl2br($row['description12']) }}
76
-                                @elseif ($real_score == 3 || $real_score == 4)
77
-                                    {{ nl2br($row['description34']) }}
78
-                                @elseif ($real_score == 5 || $real_score == 6)
79
-                                    {{ nl2br($row['description56']) }}
80
-                                @elseif ($real_score == 7 || $real_score == 8)
81
-                                    {{ nl2br($row['description78']) }}
74
+                                @if($assessments[$activity_id]['score'][$activity_criterion_id] != 0 || $assessments[$activity_id]['score'][$activity_criterion_id] !="N/A")
75
+                                    {{ $assessments[$activity_id]['explication'][$activity_criterion_id] }}
76
+  
82 77
                                 @else
83 78
                                     There is not enough information to assess this criterion, or the student did not complete the required work.
84 79
                                 @endif
@@ -88,8 +83,8 @@
88 83
                     </tbody>
89 84
                 </table>
90 85
 
91
-                <p class="lead"><strong>Percentage:</strong> {{ $assessment->percentage }}%</p>
92
-                <p class="lead"><strong>Comments:</strong> {{ $assessment->comments }}</p>
86
+                <p class="lead"><strong>Percentage:</strong> {{ $assessments[$activity_id]['percentage'] }}%</p>
87
+                <p class="lead"><strong>Comments:</strong> {{ $assessments[$activity_id]['comments'] }}</p>
93 88
             </div>
94 89
         </div>
95 90
       @endforeach