Browse Source

Pal de cosas

parent
commit
757ca9eb38

+ 97
- 4
app/controllers/AnnualPlansController.php View File

@@ -206,7 +206,7 @@ class AnnualPlansController extends \BaseController
206 206
     $an_plan = DB::table("annual_plans")
207 207
       ->join('annual_cycle', 'annual_cycle.id', '=', 'annual_plans.annual_cycle_id')
208 208
       ->where('annual_plans.id', '=', Input::get('id'))
209
-      ->select('annual_plans.id as id', 'program_id', 'academic_year', 'semester_start', 'semester_end')
209
+      ->select('annual_plans.id as id', 'program_id', 'academic_year', 'semester_start', 'semester_end', 'is_submitted')
210 210
       ->first();
211 211
 
212 212
     $years = explode('-', $an_plan->academic_year);
@@ -232,18 +232,26 @@ class AnnualPlansController extends \BaseController
232 232
 
233 233
     $json_to_send["outcomes"]["first"] = DB::table('outcomes')
234 234
       ->join('typ_semester_outcome', 'typ_semester_outcome.outcome_id', '=', 'outcomes.id')
235
+      ->join('typ_semester_objectives', 'typ_semester_outcome.id', '=', 'typ_semester_objectives.typ_semester_outcome_id')
236
+      ->join('typ_semester_courses', 'typ_semester_objectives.id', '=', 'typ_semester_courses.typ_semester_objective_id')
235 237
       ->where('semester_id', $an_plan->semester_start)
236 238
       ->where('typ_program_id', $current_typ_program->id)
239
+
237 240
       ->select('outcomes.*', 'typ_semester_outcome.id as typ_semester_outcome_id')
241
+      ->groupBy('typ_semester_outcome_id')
238 242
       ->get();
239 243
 
240 244
     //DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id = {$an_plan->semester_start} and typ_program_id = {$current_typ_program->id})");
241 245
     $json_to_send["allSemesterOrder"]["first"] = DB::select("select * from semesters where id = {$an_plan->semester_start}")[0];
242 246
     $json_to_send["outcomes"]["second"] = DB::table('outcomes')
243 247
       ->join('typ_semester_outcome', 'typ_semester_outcome.outcome_id', '=', 'outcomes.id')
248
+      ->join('typ_semester_objectives', 'typ_semester_outcome.id', '=', 'typ_semester_objectives.typ_semester_outcome_id')
249
+      ->join('typ_semester_courses', 'typ_semester_objectives.id', '=', 'typ_semester_courses.typ_semester_objective_id')
250
+
244 251
       ->where('semester_id', $an_plan->semester_end)
245 252
       ->where('typ_program_id', $current_typ_program->id)
246 253
       ->select('outcomes.*', 'typ_semester_outcome.id as typ_semester_outcome_id')
254
+      ->groupBy('typ_semester_outcome_id')
247 255
       ->get();
248 256
 
249 257
     //DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id ={$an_plan->semester_end} and typ_program_id  = {$current_typ_program->id})");
@@ -346,17 +354,34 @@ class AnnualPlansController extends \BaseController
346 354
     $typ_info['transformative_actions_for_outcome'] = DB::table('transformative_actions')
347 355
       ->join('transformative_typ_outcome', 'transformative_typ_outcome.trans_id', '=', 'transformative_actions.id')
348 356
       ->where('transformative_typ_outcome.typ_semester_outcome_id', $typ_semester_outcome_id)
357
+
349 358
       ->get();
350 359
     $typ_info['categories'] = "<option value='0'>Nothing Selected</option>";
351 360
 
352 361
     $types = DB::table('transformative_actions')
353
-      ->select('type_of_TA')
362
+      ->select('type_of_TA', 'is_custom')
354 363
       ->where('type_of_TA', '<>', '')
355
-      ->distinct()
364
+      ->where(function ($query) use (&$program_id) {
365
+        $query->whereNull('program_id')
366
+          ->orWhere('program_id', $program_id);
367
+      })
368
+      ->where('by_professor', 0)
369
+      ->groupBy('type_of_TA')
356 370
       ->get();
371
+    $optGroupGeneral = "<optgroup label='General Transformative Actions'>";
372
+    $optGroupCustom = "<optgroup label ='Program Custom Actions'>";
357 373
     foreach ($types as $type) {
358
-      $typ_info['categories'] .= "<option value = '" . $type->type_of_TA . "'>" . $type->type_of_TA . "</option>";
374
+
375
+      if ($type->is_custom) {
376
+        $optGroupCustom .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '1'>" . $type->type_of_TA . "</option>";
377
+      } else {
378
+        $optGroupGeneral .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '0'>" . $type->type_of_TA . "</option>";
379
+      }
359 380
     }
381
+    $typ_info['categories'] .= $optGroupGeneral . '</optgroup>';
382
+    $typ_info['categories'] .= $optGroupCustom . '</optgroup>';
383
+
384
+
360 385
     $typ_info['categories'] .= '<option value ="new"> New Type of Transformative Action</option>';
361 386
     return json_encode($typ_info);
362 387
   }
@@ -670,6 +695,7 @@ class AnnualPlansController extends \BaseController
670 695
     $semester_id = Input::get('semester_id');
671 696
     $annual_plan_id = Input::get('annual_plan_id');
672 697
     $outcome_id = Input::get('outcome_id');
698
+    $typ_semester_outcome_id = Input::get('typ_semester_outcome_id');
673 699
 
674 700
     $outcome = Outcome::where('id', $outcome_id)->first();
675 701
     $outcome->objectives = $outcome->fetchObjectivesReport($semester_id, $program_id);
@@ -677,6 +703,11 @@ class AnnualPlansController extends \BaseController
677 703
       ->where('program_id', $program_id)
678 704
       ->where('semester_id', $semester_id)
679 705
       ->first();
706
+    $outcome->transforming_actions = DB::table('transformative_typ_outcome')
707
+      ->join('transformative_actions', 'transformative_actions.id', '=', 'transformative_typ_outcome.trans_id')
708
+      ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
709
+      ->select('transformative_actions.*')
710
+      ->get();
680 711
 
681 712
     foreach ($outcome->objectives as $index => $objective) {
682 713
       $objective->courses = Objective::getPlanReport($objective);
@@ -721,4 +752,66 @@ class AnnualPlansController extends \BaseController
721 752
     }
722 753
     return $courses;
723 754
   }
755
+
756
+  public function submitAnnualPlan()
757
+  {
758
+    $annual_plan_id = Input::get('annual_plan_id');
759
+    DB::table('annual_plans')->where('id', $annual_plan_id)->update(array(
760
+      'is_submitted' => 1,
761
+      'submitted_on' => date('Y-m-d H:i:s')
762
+    ));
763
+    return;
764
+  }
765
+
766
+  public function fetchTheAnnualPlan()
767
+  {
768
+    $outcome_id = Input::get('id');
769
+    $semester_id = Input::get('semester');
770
+    $typ_semester_outcome_id = Input::get('typ_semester_outcome_id');
771
+    $program_id = Input::get('program_id');
772
+
773
+    $outcome = Outcome::find($outcome_id);
774
+
775
+    //El nombre es annual_plan_objective, fue cambiado como mil veces por Arlene y su combo
776
+    // Así que está mal escrito. Sorry future programmer
777
+
778
+    $array_to_send = [];
779
+    $array_to_send['typ_objectives'] = DB::table('typ_semester_objectives')
780
+      ->join('objectives', 'objectives.id', '=', 'typ_semester_objectives.objective_id')
781
+      ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
782
+      ->select('objectives.*', 'typ_semester_outcome_id', 'typ_semester_objectives.id as typ_semester_objective_id')
783
+      ->get();
784
+    $array_to_send['typ_courses'] = DB::table('typ_semester_objectives')
785
+      ->join('typ_semester_courses', 'typ_semester_courses.typ_semester_objective_id', '=', 'typ_semester_objectives.id')
786
+      ->join('courses', 'courses.id', '=', 'typ_semester_courses.course_id')
787
+      ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
788
+      ->select('courses.*', 'typ_semester_objective_id', 'typ_semester_courses.id as typ_semester_course_id')
789
+      ->get();
790
+    $array_to_send['courses_criteria'] = DB::table('typ_semester_objectives')
791
+      ->join('typ_semester_courses', 'typ_semester_courses.typ_semester_objective_id', '=', 'typ_semester_objectives.id')
792
+      ->join('annual_plan_objective', 'annual_plan_objective.typ_semester_course_id', '=', 'typ_semester_courses.id')
793
+      ->join('criteria', 'criteria.id', '=', 'annual_plan_objective.criteria_id')
794
+      ->select('typ_semester_course_id', 'annual_plan_objective.*', 'criteria.*')
795
+      ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
796
+      ->groupBy('typ_semester_course_id')
797
+      ->get();
798
+    $array_to_send['courses_transformative_actions'] = DB::table('typ_semester_objectives')
799
+      ->join('typ_semester_courses', 'typ_semester_courses.typ_semester_objective_id', '=', 'typ_semester_objectives.id')
800
+      ->join('annual_plan_transformative', 'annual_plan_transformative.typ_semester_course_id', '=', 'typ_semester_courses.id')
801
+      ->join('transformative_actions', 'transformative_actions.id', '=', 'annual_plan_transformative.trans_id')
802
+      ->select('typ_semester_course_id', 'annual_plan_transformative.*', 'transformative_actions.*')
803
+      ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
804
+      ->groupBy('typ_semester_course_id')
805
+      ->get();
806
+    $array_to_send['transformative_outcome'] = DB::table('transformative_actions')
807
+      ->join('transformative_typ_outcome', 'transformative_actions.id', '=', 'transformative_typ_outcome.trans_id')
808
+      ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
809
+      ->get();
810
+
811
+    $array_to_send['expected_target'] = DB::table('target_outcomes_program')
812
+      ->where('program_id', $program_id)
813
+      ->where('semester_id', $semester_id)
814
+      ->first();
815
+    return $array_to_send;
816
+  }
724 817
 }

+ 58
- 2
app/controllers/TransformativeActionsController.php View File

@@ -46,7 +46,7 @@ class TransformativeActionsController extends \BaseController
46 46
     $types = DB::table('transformative_actions')
47 47
       ->select('type_of_TA')
48 48
       ->where('type_of_TA', '<>', '')
49
-      ->distinct()
49
+      ->groupBy('type_of_TA')
50 50
       ->get();
51 51
     // if user is program coordinator
52 52
 
@@ -1404,4 +1404,60 @@ class TransformativeActionsController extends \BaseController
1404 1404
     }
1405 1405
     return $grouped_courses;
1406 1406
   }
1407
-}
1407
+  public function createTAForOutcome()
1408
+  {
1409
+    $is_custom = Input::get('is_custom');
1410
+    $category = Input::get('category');
1411
+    $is_new = Input::get('is_new');
1412
+    $name = Input::get('name');
1413
+    $description = Input::get('description');
1414
+    $edit_ta_id = Input::get('edit');
1415
+    if ($is_new || $is_custom)
1416
+      $program_id = Input::get('program_id');
1417
+    else $program_id = NULL;
1418
+    $typ_semester_outcome_id = Input::get('typ_semester_outcome_id');
1419
+
1420
+    if (!$edit_ta_id) {
1421
+      $ta_id = DB::table('transformative_actions')->insertGetId(array(
1422
+        'program_id' => $program_id,
1423
+        'type_of_TA' => $category,
1424
+        'at_text' => $name,
1425
+        'description' => $description,
1426
+        'user_id' => Auth::user()->id,
1427
+        'created_at' => date('Y-m-d H:i:s'),
1428
+        'updated_at' => date('Y-m-d H:i:s'),
1429
+        'by_professor' => 0,
1430
+        'is_custom' => $is_custom
1431
+      ));
1432
+      DB::table('transformative_typ_outcome')->insert(array(
1433
+        'trans_id' => $ta_id,
1434
+        'typ_semester_outcome_id' => $typ_semester_outcome_id,
1435
+        'proposing_coordinator_id' => Auth::user()->id,
1436
+
1437
+      ));
1438
+    } else {
1439
+      DB::table('transformative_actions')
1440
+        ->where('id', $edit_ta_id)
1441
+        ->update(array(
1442
+          'program_id' => $program_id,
1443
+          'type_of_TA' => $category,
1444
+          'at_text' => $name,
1445
+          'description' => $description,
1446
+          'user_id' => Auth::user()->id,
1447
+          'created_at' => date('Y-m-d H:i:s'),
1448
+          'updated_at' => date('Y-m-d H:i:s'),
1449
+          'by_professor' => 0,
1450
+          'is_custom' => $is_custom
1451
+        ));
1452
+      $ta_id = $edit_ta_id;
1453
+    }
1454
+    return $ta_id;
1455
+  }
1456
+  public function deleteTaFromOutcome()
1457
+  {
1458
+    DB::table('transformative_actions')
1459
+      ->where('id', Input::get('trans_id'))
1460
+      ->delete();
1461
+    return;
1462
+  }
1463
+}

+ 2
- 2
app/database/migrations/2022_02_04_040351_add_submit_in_typ_program.php View File

@@ -13,7 +13,7 @@ class AddSubmitInTypProgram extends Migration
13 13
 	 */
14 14
 	public function up()
15 15
 	{
16
-		Schema::table('courses', function (Blueprint $table) {
16
+		Schema::table('typ_program', function (Blueprint $table) {
17 17
 			$table->boolean('is_submitted');
18 18
 		});
19 19
 	}
@@ -25,7 +25,7 @@ class AddSubmitInTypProgram extends Migration
25 25
 	 */
26 26
 	public function down()
27 27
 	{
28
-		Schema::table('courses', function (Blueprint $table) {
28
+		Schema::table('typ_program', function (Blueprint $table) {
29 29
 			$table->dropColumn('is_submitted');
30 30
 		});
31 31
 	}

+ 32
- 0
app/database/migrations/2022_02_10_194719_add_time_limit_annual_cycle.php View File

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddTimeLimitAnnualCycle extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('annual_cycle', function (Blueprint $table) {
17
+			$table->timestamp('is_due_for')->nullable();
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		Schema::table('annual_cycle', function (Blueprint $table) {
29
+			$table->dropColumn('is_due_for');
30
+		});
31
+	}
32
+}

+ 32
- 0
app/database/migrations/2022_02_10_195154_add_time_limit_three_year_plan.php View File

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddTimeLimitThreeYearPlan extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('three_year_plan', function (Blueprint $table) {
17
+			$table->timestamp('is_due_for')->nullable();
18
+		});
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		Schema::table('three_year_plan', function (Blueprint $table) {
29
+			$table->dropColumn('is_due_for');
30
+		});
31
+	}
32
+}

+ 43
- 0
app/database/migrations/2022_02_13_122758_create_annual_report_comments.php View File

@@ -0,0 +1,43 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateAnnualReportComments extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('annual_report_comments', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('user_id')->unsigned();
19
+			$table->integer('annual_plan_id')->unsigned();
20
+			$table->text('comments');
21
+			$table->foreign('user_id')
22
+				->references('id')
23
+				->on('users')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table->foreign('annual_plan_id')
27
+				->references('id')
28
+				->on('annual_plans')
29
+				->onDelete('cascade')
30
+				->onUpdate('cascade');
31
+		});
32
+	}
33
+
34
+	/**
35
+	 * Reverse the migrations.
36
+	 *
37
+	 * @return void
38
+	 */
39
+	public function down()
40
+	{
41
+		Schema::drop('annual_report_comments');
42
+	}
43
+}

+ 28
- 0
app/database/migrations/2022_02_13_122842_add_results_to_transformative_status.php View File

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddResultsToTransformativeStatus extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		//
16
+	}
17
+
18
+	/**
19
+	 * Reverse the migrations.
20
+	 *
21
+	 * @return void
22
+	 */
23
+	public function down()
24
+	{
25
+		//
26
+	}
27
+
28
+}

+ 1
- 0
app/models/Objective.php View File

@@ -46,6 +46,7 @@ class Objective extends Eloquent
46 46
                 ->where('typ_semester_course_id', $course_code->typ_semester_course_id)
47 47
                 ->select('transformative_actions.*')
48 48
                 ->get();
49
+
49 50
             $course_code->students = Course::getStudentReportForOutcome($course_code);
50 51
             Log::info(array($course_code));
51 52
             $course_code->criteria = Course::getCriteriaPlanReport($course_code);

+ 18
- 0
app/routes.php View File

@@ -166,6 +166,19 @@ Route::group(array('before' => 'auth|has_access'), function () {
166 166
     /**
167 167
      * Shared Routes
168 168
      */
169
+
170
+    // Annual Plan routes
171
+
172
+    Route::post('fetchAnnualPlan', array('uses' => 'AnnualPlansController@fetchTheAnnualPlan'));
173
+
174
+    Route::post('deleteTaFromOutcome', array('uses' => 'TransformativeActionsController@deleteTaFromOutcome'));
175
+    Route::post(
176
+        'postTransformativeToOutcome',
177
+        array(
178
+            'as' => 'postTransformativeToOutcome',
179
+            'uses' => 'TransformativeActionsController@createTAForOutcome'
180
+        )
181
+    );
169 182
     Route::post('fetchObjectiveInfo', array(
170 183
         'as' => 'fetchObjectiveInfo',
171 184
         'uses' => 'AnnualPlansController@fetchObjectiveInfo'
@@ -188,6 +201,11 @@ Route::group(array('before' => 'auth|has_access'), function () {
188 201
         'as' => 'fetchAnnualReport',
189 202
         'uses' => 'AnnualPlansController@fetchAnnualReport'
190 203
     ));
204
+
205
+    Route::post('submitAnnualPlan', array('uses' => 'AnnualPlansController@submitAnnualPlan'));
206
+
207
+
208
+    //other stuff
191 209
     Route::post('postActivityCriterionTrans/{activity_id}', array(
192 210
         'as' => 'postActivityCriterionTrans/{activity_id}',
193 211
         'uses' => 'TransformativeActionsController@postActivityCriterion'

+ 4
- 4
app/views/global/view-three-year-plan.blade.php View File

@@ -103,10 +103,10 @@
103 103
           <li data-cycle-id="{{$typ->id}}" class="list-group-item">{{$typ->year_start}}-{{$typ->year_end}}</li>
104 104
         @endforeach
105 105
       </div>
106
-      <br>
106
+      <br> <!--<button type="button" class="btn btn-secondary" id = "three_year_button" data-toggle="modal" data-target="#three_year">Create Three Year Cycle</button>
107
+      -->
107 108
     </div>
108
-        <button type="button" class="btn btn-secondary" id = "three_year_button" data-toggle="modal" data-target="#three_year">Create Three Year Cycle</button>
109
-
109
+       
110 110
 <!-- Modal -->
111 111
 <div id="three_year" class="modal fade" role="dialog">
112 112
   <div class="modal-dialog">
@@ -138,7 +138,7 @@
138 138
 
139 139
   </div>
140 140
 </div>
141
-      </div>
141
+      
142 142
    
143 143
 
144 144
     <div class="col-md-9">

+ 745
- 314
app/views/local/managers/shared/annual-plans.blade.php
File diff suppressed because it is too large
View File


+ 55
- 45
app/views/local/managers/shared/annual_report.blade.php View File

@@ -25,7 +25,6 @@
25 25
                 <option value='0'> Nothing Selected</option>
26 26
                 @foreach ($annual_plans as $an_plan)
27 27
                     <option value={{ $an_plan->annual_id }}>Plan {{ $an_plan->academic_year }}</option>
28
-
29 28
                 @endforeach
30 29
             </select>
31 30
             <br>
@@ -59,14 +58,14 @@
59 58
 
60 59
                     </div>
61 60
                     <!-- <div class="table-responsive">
62
-                    <table class="table table-striped table-condensed datatable" style="table-layout: fixed ; width : 100%">
63
-                      <thead><tr><th>Objectives for courses</th><th>Criteria per Course</th><th>Transformative Actions</th></tr></thead>
64
-                      <tbody>
65
-                      </tbody>
61
+                        <table class="table table-striped table-condensed datatable" style="table-layout: fixed ; width : 100%">
62
+                          <thead><tr><th>Objectives for courses</th><th>Criteria per Course</th><th>Transformative Actions</th></tr></thead>
63
+                          <tbody>
64
+                          </tbody>
66 65
 
67
-                    </table>
68
-                    
69
-                </div>-->
66
+                        </table>
67
+                        
68
+                    </div>-->
70 69
 
71 70
                 </div>
72 71
             </div>
@@ -108,6 +107,8 @@
108 107
 
109 108
         });
110 109
 
110
+        // Create everything 
111
+
111 112
         function fetchEverything(li) {
112 113
             var outcome_id = $(li).data('outcome-id');
113 114
             var name = $(li).data('outcome-name');
@@ -131,11 +132,10 @@
131 132
                         $('#allLists').empty();
132 133
                         $('#levelTabs').empty();
133 134
                         $('.no-outcome').hide();
134
-                        if(outcome.outcome_program_goal){
135
+                        if (outcome.outcome_program_goal) {
135 136
                             outcome.outcome_program_goal = outcome.outcome_program_goal.expected_target;
136
-                        }
137
-                        else{
138
-                            outcome.outcome_program_goal ='It has not been defined';
137
+                        } else {
138
+                            outcome.outcome_program_goal = 'It has not been defined';
139 139
                         }
140 140
                         var outcomeHTML = "<h4>Performance of Students by Learning Outcome</h4>" +
141 141
                             '<h5 style = "display: inline; margin:30px;">Target learning by learning outcome: </h5>' +
@@ -203,22 +203,24 @@
203 203
 
204 204
                                             }
205 205
                                             wholeDict[student.student_id][
206
-                                                "criteria_attempted"] += student
206
+                                                    "criteria_attempted"
207
+                                                ] += student
207 208
                                                 .criteria_attempted;
208 209
                                             wholeDict[student.student_id][
209
-                                                "criteria_achieved"] += student
210
+                                                    "criteria_achieved"
211
+                                                ] += student
210 212
                                                 .criteria_achieved;
211 213
 
212 214
                                         });
213 215
                                         div.append(
214 216
                                             '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
215
-                                            );
217
+                                        );
216 218
                                         table = $('<table/>', {
217 219
                                             'class': 'table table-striped table-condensed datatable'
218 220
                                         }).html('<thead><th>Criterion</th><th>' +
219 221
                                             'Number of Students Assessed </th>' +
220 222
                                             '<th>Number of students that achieved the target</th></thead>'
221
-                                            );
223
+                                        );
222 224
                                         tbody = $('<tbody/>')
223 225
                                         $.each(course_code.criteria, function(index, criterion) {
224 226
 
@@ -526,39 +528,47 @@
526 528
                         'class': 'list-group',
527 529
                         'id': 'list'
528 530
                     });
529
-                    if(json.outcomes.first){
530
-                    header5 = $('<h5/>', {
531
-                        'style': "padding-left: 10px"
532
-                    }).html("First Semester");
533
-                    div.append(header5);
534
-                    list = '';
535
-                    for (outcome in json.outcomes.first) {
536
-                        list +=
537
-                            "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
538
-                            json.annual_plans.id + "' data-typ-semester-outcome-id ='"+json.outcomes.first[outcome].typ_semester_outcome_id+"' data-semester-id = '" + json.allSemesterOrder.first.id +
539
-                            "' data-outcome-id='" + json.outcomes.first[outcome].id + "' data-outcome-name ='" + json
540
-                            .outcomes.first[outcome].name + "' class='list-group-item' >" + json.outcomes.first[outcome]
541
-                            .name + " </li>";
531
+                    if (json.outcomes.first) {
532
+                        header5 = $('<h5/>', {
533
+                            'style': "padding-left: 10px"
534
+                        }).html("First Semester");
535
+                        div.append(header5);
536
+                        list = '';
537
+                        for (outcome in json.outcomes.first) {
538
+                            list +=
539
+                                "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
540
+                                json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.first[
541
+                                    outcome].typ_semester_outcome_id + "' data-semester-id = '" + json.allSemesterOrder
542
+                                .first.id +
543
+                                "' data-outcome-id='" + json.outcomes.first[outcome].id + "' data-outcome-name ='" +
544
+                                json
545
+                                .outcomes.first[outcome].name + "' class='list-group-item' >" + json.outcomes.first[
546
+                                    outcome]
547
+                                .name + " </li>";
542 548
 
549
+                        }
550
+                        div.append(list);
543 551
                     }
544
-                    div.append(list);
545
-                    }
546
-                    if(json.outcomes.second){
547
-                    header4 = $('<h5/>', {
548
-                        'style': "padding-left: 10px"
549
-                    }).html("Second Semester");
550
-                    div.append(header4);
551
-                    list = '';
552
-                    for (outcome in json.outcomes.second) {
553
-                        list +=
554
-                            "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
555
-                            json.annual_plans.id + "' data-typ-semester-outcome-id ='"+json.outcomes.first[outcome].typ_semester_outcome_id+"'data-semester-id = '" + json.allSemesterOrder.second.id +
556
-                            "' data-outcome-id='" + json.outcomes.second[outcome].id + "' data-outcome-name ='" + json
557
-                            .outcomes.second[outcome].name + "' class='list-group-item' >" + json.outcomes.second[
558
-                                outcome].name + " </li>";
552
+                    if (json.outcomes.second) {
553
+                        header4 = $('<h5/>', {
554
+                            'style': "padding-left: 10px"
555
+                        }).html("Second Semester");
556
+                        div.append(header4);
557
+                        list = '';
558
+                        for (outcome in json.outcomes.second) {
559
+                            list +=
560
+                                "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
561
+                                json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.second[
562
+                                    outcome].typ_semester_outcome_id + "'data-semester-id = '" + json.allSemesterOrder
563
+                                .second.id +
564
+                                "' data-outcome-id='" + json.outcomes.second[outcome].id + "' data-outcome-name ='" +
565
+                                json
566
+                                .outcomes.second[outcome].name + "' class='list-group-item' >" + json.outcomes.second[
567
+                                    outcome].name + " </li>";
559 568
 
569
+                        }
570
+                        div.append(list);
560 571
                     }
561
-                    div.append(list);}
562 572
                     html = div[0].innerHTML;
563 573
 
564 574
                     $("#allOutcomes").html(div[0].innerHTML);