Browse Source

Submit los views de Crit y Obj

parent
commit
a3728c34bb

+ 140
- 0
app/controllers/CriteriaController.php View File

@@ -1258,4 +1258,144 @@ class CriteriaController extends \BaseController
1258 1258
 
1259 1259
         return $json;
1260 1260
     }
1261
+
1262
+    public function fetchObjectiveCriteria()
1263
+    {
1264
+        $array_to_send = [];
1265
+        $program_id =  Input::get('program_id');
1266
+        $objective_id = Input::get('objective_id');
1267
+
1268
+        Log::info(Input::all());
1269
+
1270
+        $array_to_send['objective'] = Objective::find($objective_id);
1271
+
1272
+        $outcomes = DB::table('outcomes')
1273
+            ->join('objective_outcome', 'outcomes.id', '=', 'objective_outcome.outcome_id')
1274
+            ->join('objective_program', 'objective_program.objective_id', '=', 'objective_outcome.objective_id')
1275
+            ->where('program_id', $program_id)
1276
+            ->where('objective_outcome.objective_id', $objective_id)
1277
+            ->select('outcomes.*')
1278
+            ->distinct()
1279
+            ->get();
1280
+
1281
+        foreach ($outcomes as $out) {
1282
+
1283
+            $out->criteria = DB::table("program_criterion_objective_outcome as poco")
1284
+                ->join('criterion_objective_outcome as cobo', 'cobo.id', '=', 'poco.cri_obj_out_id')
1285
+                ->join('criteria', 'criteria.id', '=', 'cobo.criterion_id')
1286
+                ->where('outcome_id', $out->id)
1287
+                ->where('program_id', $program_id)
1288
+                ->where('objective_id', $objective_id)
1289
+                ->select("criteria.*")
1290
+                ->groupBy('criteria.id')
1291
+                ->get();
1292
+            Log::info("outcome_id: " . $out->id);
1293
+        }
1294
+
1295
+
1296
+        $array_to_send['outcomes'] = $outcomes;
1297
+
1298
+        return $array_to_send;
1299
+    }
1300
+
1301
+    function viewCriteriaOutcome()
1302
+    {
1303
+        $title = "Learning Criteria and Outcomes";
1304
+
1305
+        $role = Auth::user()->role;
1306
+
1307
+        switch ($role) {
1308
+            case 1:
1309
+                $programs = Program::select('programs.*')->get();
1310
+                break;
1311
+
1312
+            case 2:
1313
+                $programs = Auth::user()->school->programs;
1314
+                break;
1315
+            case 3:
1316
+                # code...
1317
+
1318
+            case 4:
1319
+
1320
+                $programs = Auth::user()->programs;
1321
+
1322
+                break;
1323
+        }
1324
+
1325
+        return View::make('local.managers.shared.view-criteria-outcome', compact('title', 'programs'));
1326
+    }
1327
+
1328
+    public function fetchCriteriaOutcomes()
1329
+    {
1330
+        $program = Program::find(Input::get('program_id'));
1331
+        $outcomes = Outcome::active_by_semesters(Semester::whereIn('id', Session::get('semesters_ids'))->get(), $program->is_graduate);
1332
+        $outcome_ids = [];
1333
+        foreach ($outcomes as $o) {
1334
+            $outcome_ids[] = $o->id;
1335
+        }
1336
+
1337
+        $criteria = DB::table('criteria')
1338
+            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
1339
+            ->join('program_criterion_objective_outcome', 'program_criterion_objective_outcome.cri_obj_out_id', '=', 'criterion_objective_outcome.id')
1340
+            ->whereIn('outcome_id', $outcome_ids)
1341
+            ->where('program_id', $program->id)
1342
+            //->where('criteria.id', '<>', '0')
1343
+            ->select('criteria.*')
1344
+            ->groupBy('criteria.id')
1345
+            ->get();
1346
+
1347
+        foreach ($criteria as $criterion)
1348
+            $criterion->outcome_ids = DB::table('criterion_objective_outcome as cobo')
1349
+                ->join('program_criterion_objective_outcome as poco', 'poco.cri_obj_out_id', '=', 'cobo.id')
1350
+                ->where('program_id', $program->id)
1351
+                ->where('criterion_id', $criterion->id)
1352
+                ->lists('outcome_id');
1353
+        //Log::info($objectives->outcomes);
1354
+        $array_to_send = [
1355
+            'outcomes' => $outcomes,
1356
+            'criteria' => $criteria
1357
+
1358
+        ];
1359
+
1360
+        return $array_to_send;
1361
+    }
1362
+
1363
+    public function fetchCriteriaObjectiveOutcomes()
1364
+    {
1365
+        $array_to_send = [];
1366
+        $program_id =  Input::get('program_id');
1367
+        $criterion_id = Input::get('criterion_id');
1368
+
1369
+        Log::info(Input::all());
1370
+
1371
+        $array_to_send['criterion'] = Criterion::find($criterion_id);
1372
+
1373
+        $outcomes = DB::table('outcomes')
1374
+            ->join('criterion_objective_outcome', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
1375
+            ->join('program_criterion_objective_outcome', 'program_criterion_objective_outcome.cri_obj_out_id', '=', 'criterion_objective_outcome.id')
1376
+            ->where('program_id', $program_id)
1377
+            ->where('criterion_id', $criterion_id)
1378
+            ->select('outcomes.*')
1379
+            ->distinct()
1380
+            ->get();
1381
+
1382
+        foreach ($outcomes as $out) {
1383
+
1384
+            $out->objectives = DB::table("program_criterion_objective_outcome as poco")
1385
+                ->join('criterion_objective_outcome as cobo', 'cobo.id', '=', 'poco.cri_obj_out_id')
1386
+                ->join('objectives', 'objectives.id', '=', 'cobo.objective_id')
1387
+                ->where('outcome_id', $out->id)
1388
+                ->where('program_id', $program_id)
1389
+                ->where('criterion_id', $criterion_id)
1390
+                ->select("objectives.*")
1391
+                ->groupBy('objectives.id')
1392
+                ->get();
1393
+            //Log::info("outcome_id: " . $out->id);
1394
+        }
1395
+
1396
+
1397
+        $array_to_send['outcomes'] = $outcomes;
1398
+
1399
+        return $array_to_send;
1400
+    }
1261 1401
 }

+ 62
- 0
app/controllers/Objective2Controller.php View File

@@ -1266,4 +1266,66 @@ class Objective2Controller extends \BaseController
1266 1266
 			}
1267 1267
 		}*/
1268 1268
 	}
1269
+
1270
+	function viewObjectiveOutcome()
1271
+	{
1272
+		$title = "Learning Objectives and Outcomes";
1273
+
1274
+		$role = Auth::user()->role;
1275
+
1276
+		switch ($role) {
1277
+			case 1:
1278
+				$programs = Program::select('programs.*')->get();
1279
+				break;
1280
+
1281
+			case 2:
1282
+				$programs = Auth::user()->school->programs;
1283
+				break;
1284
+			case 3:
1285
+				# code...
1286
+
1287
+			case 4:
1288
+
1289
+				$programs = Auth::user()->programs;
1290
+
1291
+				break;
1292
+		}
1293
+
1294
+		return View::make('local.managers.shared.view-objectives-outcome', compact('title', 'programs'));
1295
+	}
1296
+
1297
+	public function fetchObjectiveOutcome()
1298
+	{
1299
+		$program = Program::find(Input::get('program_id'));
1300
+		$outcomes = Outcome::active_by_semesters(Semester::whereIn('id', Session::get('semesters_ids'))->get(), $program->is_graduate);
1301
+		$outcome_ids = [];
1302
+		foreach ($outcomes as $o) {
1303
+			$outcome_ids[] = $o->id;
1304
+		}
1305
+
1306
+		$objectives = DB::table('objectives')
1307
+			->join('objective_outcome', 'objective_outcome.objective_id', '=', 'objectives.id')
1308
+			->join('objective_program', 'objective_program.objective_id', '=', 'objectives.id')
1309
+			->whereIn('outcome_id', $outcome_ids)
1310
+			->where('program_id', $program->id)
1311
+			->where('objectives.id', '<>', '0')
1312
+			->select('objectives.*')
1313
+			->groupBy('objectives.id')
1314
+			->get();
1315
+
1316
+		foreach ($objectives as $objective)
1317
+			$objective->outcome_ids = DB::table("objective_outcome")
1318
+				->join('objective_program', 'objective_outcome.objective_id', '=', 'objective_program.objective_id')
1319
+				->where('program_id', $program->id)
1320
+				->where('objective_id', $objective->id)
1321
+				->lists('outcome_id');
1322
+		//Log::info($objectives->outcomes);
1323
+		$array_to_send = [
1324
+			'outcomes' => $outcomes,
1325
+			'objectives' => $objectives
1326
+
1327
+		];
1328
+
1329
+		return $array_to_send;
1330
+	}
1269 1331
 }

+ 10
- 3
app/models/Outcome.php View File

@@ -257,7 +257,7 @@ class Outcome extends Eloquent
257 257
 				->get();
258 258
 			//return $objectives;
259 259
 		}
260
-		Log::info("Lol");
260
+		//Log::info("Lol");
261 261
 		return null;
262 262
 	}
263 263
 	/**
@@ -265,10 +265,17 @@ class Outcome extends Eloquent
265 265
 	 *
266 266
 	 * @return Illuminate\Database\Eloquent\Model
267 267
 	 */
268
-	public function objectives()
268
+	public function getObjectivesAttribute()
269 269
 	{
270
-		return $this->hasMany('Objective');
270
+		//return $this->hasManyThrough('Objective', "Objective_Outcome", 'outcome_id', 'id');
271 271
 		//		return $this->belongsToMany('Objective', 'objective_outcome');
272
+		$objectives = Objective::join('objective_outcome', 'objectives.id', '=', 'objective_outcome.objective_id')
273
+			->where('outcome_id', $this->id);
274
+		if (isset($this->program_id)) {
275
+			$objectives = $objectives->join('objective_program', 'objective_program.objective_id', '=', 'objectives.id')
276
+				->where('program_id', $this->program_id);
277
+		}
278
+		return $objectives->get();
272 279
 	}
273 280
 
274 281
 	public function scopeObjectivesFromProgram($query, $programs)

+ 23
- 3
app/routes.php View File

@@ -349,8 +349,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
349 349
 
350 350
     Export criteria from annual plans, rubrics
351 351
 
352
-    */ ////////////////
353
-
352
+     ////////////////*/
354 353
     Route::post('fetchOutcomesFromPlan', "AnnualPlansController@fetchOutcomesFromPlan");
355 354
     Route::post('fetchObjectivesFromPlan', 'AnnualPlansController@fetchObjectivesFromPlan');
356 355
     Route::post("fetchSemestersFromPlan", 'AnnualPlansController@fetchSemestersFromPlan');
@@ -358,7 +357,28 @@ Route::group(array('before' => 'auth|has_access'), function () {
358 357
     Route::post('fetchCriteriaFromPlan', 'AnnualPlansController@fetchCriteriaFromPlan');
359 358
 
360 359
 
361
-    ///////////////////////////////////////////////////////
360
+    /*////////////////////////
361
+    //
362
+    //  Routes: view for objective_outcome
363
+    //
364
+    */ ////////////////////////
365
+
366
+    Route::get('view-objective-outcome', 'Objective2Controller@viewObjectiveOutcome');
367
+    Route::post('fetchObjectiveOutcome', 'Objective2Controller@fetchObjectiveOutcome');
368
+    Route::post('fetchObjectiveCriteria', 'CriteriaController@fetchObjectiveCriteria');
369
+
370
+    /*////////////////////////
371
+    //
372
+    //  Routes view for criteria_outcome
373
+    //
374
+    */ ////////////////////////
375
+
376
+    Route::get("view-criteria-outcome", "CriteriaController@viewCriteriaOutcome");
377
+    Route::post('fetchCriteriaOutcomes', 'CriteriaController@fetchCriteriaOutcomes');
378
+    Route::post('fetchCriteriaObjectiveOutcomes', 'CriteriaController@fetchCriteriaObjectiveOutcomes');
379
+
380
+
381
+
362 382
 
363 383
     Route::get('viewFormative', array(
364 384
         'as' => 'viewFormative',

+ 3
- 0
app/views/local/managers/admins/_new_navigation.blade.php View File

@@ -14,6 +14,8 @@
14 14
                     <li>{{ HTML::linkAction('Objective2Controller@edit', 'Create/Edit Objectives') }}</li>
15 15
                     <li>{{ HTML::linkAction('Objective2Controller@viewObjectives', 'View Objectives and Criteria') }}
16 16
                     </li>
17
+                    <li>{{HTML::linkAction('Objective2Controller@viewObjectiveOutcome', 'View Objectives and Outcome')}}</li>
18
+
17 19
                 </ul>
18 20
             </li>
19 21
             <li class='dropdown'>
@@ -23,6 +25,7 @@
23 25
 
24 26
                     <li>{{ HTML::linkAction('CriteriaController@edit', 'Create/Edit Criteria') }}</li>
25 27
                     <li>{{ HTML::linkAction('CriteriaController@index', 'View Criteria') }}</li>
28
+                    <li>{{HTML::linkAction('CriteriaController@viewCriteriaOutcome', 'View Criteria with Outcome')}}</li>
26 29
 
27 30
                 </ul>
28 31
             </li>

+ 3
- 0
app/views/local/managers/pCoords/_new_navigation.blade.php View File

@@ -13,6 +13,8 @@
13 13
                     <li>{{ HTML::linkAction('Objective2Controller@edit', 'Create/Edit Objectives') }}</li>
14 14
                     <li>{{ HTML::linkAction('Objective2Controller@viewObjectives', 'View Objectives and Criteria') }}
15 15
                     </li>
16
+                    <li>{{HTML::linkAction('Objective2Controller@viewObjectiveOutcome', 'View Objectives and Outcome')}}</li>
17
+
16 18
                 </ul>
17 19
             </li>
18 20
 
@@ -46,6 +48,7 @@
46 48
 
47 49
                     <li>{{ HTML::linkAction('CriteriaController@edit', 'Create/Edit Criteria') }}</li>
48 50
                     <li>{{ HTML::linkAction('CriteriaController@index', 'View Criteria') }}</li>
51
+                    <li>{{HTML::linkAction('CriteriaController@viewCriteriaOutcome', 'View Criteria with Outcome')}}</li>
49 52
 
50 53
                 </ul>
51 54
             </li>

+ 3
- 1
app/views/local/managers/sCoords/_new_navigation.blade.php View File

@@ -11,8 +11,9 @@
11 11
                     aria-expanded="false">Objectives<span class="caret"></span></a>
12 12
                 <ul class="dropdown-menu dropdown-menu-left" role="menu">
13 13
                     <li>{{ HTML::linkAction('Objective2Controller@edit', 'Create/Edit Objectives') }}</li>
14
-                    <li>{{ HTML::linkAction('Objective2Controller@viewObjectives', 'View Objectives and Criteria') }}
14
+                    <li>{{ HTML::linkAction('Objective2Controller@viewObjectives', 'View/Pair Objectives and Criteria') }}
15 15
                     </li>
16
+                    <li>{{HTML::linkAction('Objective2Controller@viewObjectiveOutcome', 'View Objectives and Outcome')}}</li>
16 17
                 </ul>
17 18
             </li>
18 19
 
@@ -46,6 +47,7 @@
46 47
 
47 48
                     <li>{{ HTML::linkAction('CriteriaController@edit', 'Create/Edit Criteria') }}</li>
48 49
                     <li>{{ HTML::linkAction('CriteriaController@index', 'View Criteria') }}</li>
50
+                    <li>{{HTML::linkAction('CriteriaController@viewCriteriaOutcome', 'View Criteria with Outcome')}}</li>
49 51
 
50 52
                 </ul>
51 53
             </li>

+ 243
- 0
app/views/local/managers/shared/view-criteria-outcome.blade.php View File

@@ -0,0 +1,243 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if (Auth::user()->role == 1)
5
+        @include('local.managers.admins._new_navigation')
6
+    @elseif(Auth::user()->role == 2)
7
+        @include('local.managers.sCoords._new_navigation')
8
+    @elseif(Auth::user()->role == 3)
9
+        @include('local.managers.pCoords._new_navigation')
10
+    @elseif(Auth::user()->role == 4)
11
+        @include('local.professors._navigation')
12
+    @endif
13
+@stop
14
+
15
+
16
+@section('main')
17
+    <div class ='row'>
18
+        <div  class ='col-md-3'>
19
+            <div class="form-group">
20
+                {{ Form::label('program_id2', 'Select Program') }}
21
+                <select id='select-program' class="form-control selectpicker"
22
+                    onchange='fetchAllObjectives("#select-program")'>
23
+                    @foreach ($programs as $program)
24
+                        <option value='{{ $program->id }}' data-is-graduate = "{{$program->is_graduate}}" data-subtext="{{ $program->code }}">
25
+                            {{ $program->name }}</option>
26
+                    @endforeach
27
+                </select>
28
+            </div>
29
+        </div>
30
+    </div>
31
+
32
+    <div class = 'row'>
33
+        <div class = 'col-md-12' id ='div_table'>
34
+        
35
+        </div>
36
+
37
+
38
+    </div>
39
+
40
+            <!-- Modal -->
41
+            <div id="criteria-modal" class="modal fade" role="dialog">
42
+                <div class="modal-dialog">
43
+                    <!-- Modal content-->
44
+                    <div class="modal-content">
45
+                        <div class="modal-header">
46
+                            <button type="button" class="close" data-dismiss="modal">&times;</button>
47
+                            <h4 class="modal-title"></h4>
48
+                        </div>
49
+                        <div class="modal-body">
50
+                           
51
+                        </div>
52
+                        <div class="modal-footer">
53
+                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
54
+
55
+                        </div>
56
+                    </div>
57
+    
58
+                </div>
59
+            </div>
60
+
61
+    
62
+
63
+    <script>
64
+
65
+        $(document).ready(function(){
66
+            onLoad();
67
+        });
68
+
69
+        function onLoad(){
70
+
71
+            fetchAllObjectives('#select-program');
72
+
73
+        }
74
+
75
+        function fetchAllObjectives(select){
76
+            program_id =$(select).val();
77
+            is_graduate = $(select).find(':selected').data('is-graduate');
78
+
79
+
80
+            $.post(
81
+                "{{URL::action('CriteriaController@fetchCriteriaOutcomes')}}", 
82
+                {
83
+                    program_id:program_id
84
+                },
85
+                function(criteria_outcomes){
86
+
87
+                    
88
+                    drawTable(criteria_outcomes.criteria, criteria_outcomes.outcomes, is_graduate);
89
+
90
+                }
91
+            )
92
+        }
93
+
94
+        function drawTable(criteria, outcomes, is_graduate){
95
+            
96
+            
97
+            table = $('<table>',{
98
+                'id': 'theMainTable',
99
+                'class': 'table table-striped table-condensed datatable'
100
+            });
101
+
102
+            thead = $("<thead>");
103
+                thead_row = $('<tr>');
104
+            
105
+            th= $('<th>').html('Criteria');
106
+            thead_row.append(th);
107
+
108
+            
109
+
110
+            outcomes_th = [];
111
+            $.each(outcomes, function(ind, outcomes){
112
+
113
+                th = $('<th>', {
114
+                    'class':'th-outcomes th-out-id',
115
+                    'data-outcome-id':outcomes.id
116
+                }).html(outcomes.name);
117
+
118
+                outcomes_th.push(th);
119
+
120
+                thead_row.append(th);
121
+                        
122
+                    
123
+            })
124
+            th = $('<th>', {
125
+                    'class':'th-outcomes'
126
+                }).html('Objectives');
127
+
128
+            thead_row.append(th);
129
+
130
+            thead.append(thead_row);
131
+
132
+            tbody = $('<tbody>');
133
+            
134
+            
135
+            $.each(criteria, function(ind, criterion){
136
+
137
+                tr = $("<tr>", {
138
+                    'class':'criteria',
139
+                    'data-criterion-id':criterion.id,
140
+                })
141
+
142
+                td = $("<td>", {
143
+                    'class': 'objective',
144
+                    'data-criterion-id':criterion.id,
145
+                }).html(criterion.name);
146
+
147
+                tr.append(td);
148
+                
149
+                $(outcomes_th).each(function(id, th){
150
+
151
+                    var td = $('<td>');
152
+                    outcome_id = $(th).data('outcome-id');
153
+                    //console.log(outcome_id);
154
+                    if(criterion.outcome_ids.includes(outcome_id)){
155
+                        var span = $("<span>", {
156
+                            'class':'glyphicon glyphicon-ok'
157
+                        })
158
+                        td.append(span);
159
+                    }
160
+                    tr.append(td);
161
+
162
+                });
163
+
164
+                td_link = $('<td>');
165
+                a = $("<a>",{
166
+                    'onclick':'fetchObjectiveCriteria("'+criterion.id+'", "#select-program")'
167
+                }).html('View Objectives');
168
+
169
+                td_link.append(a);
170
+                tr.append(td_link);
171
+
172
+                tbody.append(tr);
173
+
174
+
175
+            });
176
+
177
+            table.append(thead)
178
+            table.append(tbody);
179
+            $('#div_table').html(table);
180
+
181
+            table = $("#theMainTable").DataTable();
182
+            table.draw();
183
+        }
184
+
185
+
186
+        function fetchObjectiveCriteria(criterion_id,program_select){
187
+            program_id = $(program_select).val();
188
+            $.post(
189
+                "{{URL::action('CriteriaController@fetchCriteriaObjectiveOutcomes')}}",
190
+                {
191
+                    program_id:program_id,
192
+                    criterion_id:criterion_id
193
+                },
194
+                function(data){
195
+                    modal = "#criteria-modal";
196
+
197
+
198
+                    $(modal).find('.modal-body').html(createModalContent(data.outcomes));
199
+                    
200
+                    $(modal).find('.modal-title').html("Objectives for <strong>"+data.criterion.name+"</strong>")
201
+                    $(modal).modal('show');
202
+                }
203
+            )
204
+        }
205
+
206
+        function createModalContent(outcomes){
207
+            ol_out = $("<ol>")
208
+            $.each(outcomes, function(ind, out){
209
+                //ol_out = $("<ol>")
210
+                if(out.objectives.length == 0)
211
+                return;
212
+                li = $('<li>').html("<p><strong>"+out.name+"</strong></p>");
213
+                
214
+                ul = $('<ul>');
215
+                
216
+
217
+                $.each(out.objectives, function(ind, obj){
218
+                    li2 = $("<li>").html(obj.text);
219
+                    ul.append(li2);    
220
+                });
221
+                li.append(ul);
222
+                ol_out.append(li)
223
+
224
+                //div.append(ol_out)
225
+                
226
+                
227
+                
228
+            })
229
+
230
+            return ol_out;
231
+        }
232
+
233
+    </script>
234
+
235
+@stop
236
+
237
+
238
+@section('included-js')
239
+    @include('global._datatables_js')
240
+@stop
241
+
242
+@section('javascript')
243
+@stop

+ 255
- 0
app/views/local/managers/shared/view-objectives-outcome.blade.php View File

@@ -0,0 +1,255 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if (Auth::user()->role == 1)
5
+        @include('local.managers.admins._new_navigation')
6
+    @elseif(Auth::user()->role == 2)
7
+        @include('local.managers.sCoords._new_navigation')
8
+    @elseif(Auth::user()->role == 3)
9
+        @include('local.managers.pCoords._new_navigation')
10
+    @elseif(Auth::user()->role == 4)
11
+        @include('local.professors._navigation')
12
+    @endif
13
+@stop
14
+
15
+
16
+@section('main')
17
+    <div class ='row'>
18
+        <div  class ='col-md-3'>
19
+            <div class="form-group">
20
+                {{ Form::label('program_id2', 'Select Program') }}
21
+                <select id='select-program' class="form-control selectpicker"
22
+                    onchange='fetchAllObjectives("#select-program")'>
23
+                    @foreach ($programs as $program)
24
+                        <option value='{{ $program->id }}' data-is-graduate = "{{$program->is_graduate}}" data-subtext="{{ $program->code }}">
25
+                            {{ $program->name }}</option>
26
+                    @endforeach
27
+                </select>
28
+            </div>
29
+        </div>
30
+    </div>
31
+
32
+    <div class = 'row'>
33
+        <div class = 'col-md-12' id ='div_table'>
34
+        <table id = 'theMainTable' class ='table table-striped table-condensed datatable'>
35
+        <thead>
36
+            <tr id = 'outcomes-thead'>
37
+                <th>Objectives</th>
38
+            </tr>
39
+            
40
+            
41
+            
42
+        </thead>
43
+        <tbody id = 'objectves-outcomes'>
44
+
45
+        </tbody>
46
+        </table>
47
+        </div>
48
+
49
+
50
+    </div>
51
+
52
+            <!-- Modal -->
53
+            <div id="criteria-modal" class="modal fade" role="dialog">
54
+                <div class="modal-dialog">
55
+                    <!-- Modal content-->
56
+                    <div class="modal-content">
57
+                        <div class="modal-header">
58
+                            <button type="button" class="close" data-dismiss="modal">&times;</button>
59
+                            <h4 class="modal-title"></h4>
60
+                        </div>
61
+                        <div class="modal-body">
62
+                           
63
+                        </div>
64
+                        <div class="modal-footer">
65
+                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
66
+
67
+                        </div>
68
+                    </div>
69
+    
70
+                </div>
71
+            </div>
72
+
73
+    
74
+
75
+    <script>
76
+
77
+        $(document).ready(function(){
78
+            onLoad();
79
+        });
80
+
81
+        function onLoad(){
82
+
83
+            fetchAllObjectives('#select-program');
84
+
85
+        }
86
+
87
+        function fetchAllObjectives(select){
88
+            program_id =$(select).val();
89
+            is_graduate = $(select).find(':selected').data('is-graduate');
90
+
91
+
92
+            $.post(
93
+                "{{URL::action('Objective2Controller@fetchObjectiveOutcome')}}", 
94
+                {
95
+                    program_id:program_id
96
+                },
97
+                function(objectives_outcomes){
98
+
99
+                    
100
+                    drawTable(objectives_outcomes.objectives, objectives_outcomes.outcomes, is_graduate);
101
+
102
+                }
103
+            )
104
+        }
105
+
106
+        function drawTable(objectives, outcomes, is_graduate){
107
+            
108
+            
109
+            table = $('<table>',{
110
+                'id': 'theMainTable',
111
+                'class': 'table table-striped table-condensed datatable'
112
+            });
113
+
114
+            thead = $("<thead>");
115
+                thead_row = $('<tr>');
116
+            
117
+            th= $('<th>').html('Objectives');
118
+            thead_row.append(th);
119
+
120
+            
121
+
122
+            outcomes_th = [];
123
+            $.each(outcomes, function(ind, outcomes){
124
+
125
+                th = $('<th>', {
126
+                    'class':'th-outcomes th-out-id',
127
+                    'data-outcome-id':outcomes.id
128
+                }).html(outcomes.name);
129
+
130
+                outcomes_th.push(th);
131
+
132
+                thead_row.append(th);
133
+                        
134
+                    
135
+            })
136
+            th = $('<th>', {
137
+                    'class':'th-outcomes'
138
+                }).html('Criteria');
139
+
140
+            thead_row.append(th);
141
+
142
+            thead.append(thead_row);
143
+
144
+            tbody = $('<tbody>');
145
+            
146
+            
147
+            $.each(objectives, function(ind, objective){
148
+
149
+                tr = $("<tr>", {
150
+                    'class':'objectives',
151
+                    'data-objective-id':objective.id,
152
+                })
153
+
154
+                td = $("<td>", {
155
+                    'class': 'objective',
156
+                    'data-objective-id':objective.id,
157
+                }).html(objective.text);
158
+
159
+                tr.append(td);
160
+                
161
+                $(outcomes_th).each(function(id, th){
162
+
163
+                    var td = $('<td>');
164
+                    outcome_id = $(th).data('outcome-id');
165
+                    //console.log(outcome_id);
166
+                    if(objective.outcome_ids.includes(outcome_id)){
167
+                        var span = $("<span>", {
168
+                            'class':'glyphicon glyphicon-ok'
169
+                        })
170
+                        td.append(span);
171
+                    }
172
+                    tr.append(td);
173
+
174
+                });
175
+
176
+                td_link = $('<td>');
177
+                a = $("<a>",{
178
+                    'onclick':'fetchObjectiveCriteria("'+objective.id+'", "#select-program")'
179
+                }).html('View Criteria');
180
+
181
+                td_link.append(a);
182
+                tr.append(td_link);
183
+
184
+                tbody.append(tr);
185
+
186
+
187
+            });
188
+
189
+            table.append(thead)
190
+            table.append(tbody);
191
+            $('#div_table').html(table);
192
+
193
+            table = $("#theMainTable").DataTable();
194
+            table.draw();
195
+        }
196
+
197
+
198
+        function fetchObjectiveCriteria(objective_id,program_select){
199
+            program_id = $(program_select).val();
200
+            $.post(
201
+                "{{URL::action('CriteriaController@fetchObjectiveCriteria')}}",
202
+                {
203
+                    program_id:program_id,
204
+                    objective_id:objective_id
205
+                },
206
+                function(data){
207
+                    modal = "#criteria-modal";
208
+
209
+
210
+                    $(modal).find('.modal-body').html(createModalContent(data.outcomes));
211
+                    
212
+                    $(modal).find('.modal-title').html("Criteria for <strong>"+data.objective.text+"</strong>")
213
+                    $(modal).modal('show');
214
+                }
215
+            )
216
+        }
217
+
218
+        function createModalContent(outcomes){
219
+            ol_out = $("<ol>")
220
+            $.each(outcomes, function(ind, out){
221
+                //ol_out = $("<ol>")
222
+                if(out.criteria.length == 0)
223
+                return;
224
+                li = $('<li>').html("<p><strong>"+out.name+"</strong></p>");
225
+                
226
+                ul = $('<ul>');
227
+                
228
+
229
+                $.each(out.criteria, function(ind, crit){
230
+                    li2 = $("<li>").html(crit.name);
231
+                    ul.append(li2);    
232
+                });
233
+                li.append(ul);
234
+                ol_out.append(li)
235
+
236
+                //div.append(ol_out)
237
+                
238
+                
239
+                
240
+            })
241
+
242
+            return ol_out;
243
+        }
244
+
245
+    </script>
246
+
247
+@stop
248
+
249
+
250
+@section('included-js')
251
+    @include('global._datatables_js')
252
+@stop
253
+
254
+@section('javascript')
255
+@stop

+ 5
- 0
app/views/local/professors/_navigation.blade.php View File

@@ -16,7 +16,12 @@
16 16
                 <ul class="dropdown-menu" role="menu">
17 17
                     <li>{{ HTML::linkAction('CriteriaController@index', 'Outcomes and Criteria') }}</li>
18 18
                     <li>{{ HTML::linkAction('Objective2Controller@viewObjectives', 'Objectives and Criteria') }}
19
+
19 20
                     </li>
21
+                    <li>{{HTML::linkAction('Objective2Controller@viewObjectiveOutcome', 'View Objectives and Outcome')}}</li>
22
+                    <li>{{HTML::linkAction('CriteriaController@viewCriteriaOutcome', 'View Criteria with Outcome')}}</li>
23
+
24
+
20 25
                 </ul>
21 26
             </li>
22 27
             @if (count(Auth::user()->courses))