Browse Source

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

parent
commit
f7071fb58c

+ 80
- 16
app/controllers/ActivitiesController.php View File

131
         foreach ($active_semesters_collection as $active_semester) {
131
         foreach ($active_semesters_collection as $active_semester) {
132
             $active_semesters[] = $active_semester->id;
132
             $active_semesters[] = $active_semester->id;
133
         }
133
         }
134
+
134
         Log::info($active_semesters);
135
         Log::info($active_semesters);
135
         // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
136
         // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
136
         $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
137
         $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
137
         $outcomes = Outcome::orderBy('name', 'asc')->get();
138
         $outcomes = Outcome::orderBy('name', 'asc')->get();
138
-        $outcomes_achieved = json_decode($activity->outcomes_achieved, true);
139
-        $outcomes_attempted = json_decode($activity->outcomes_attempted, true);
140
-        $tru = is_null($activity->rubric) ? "brr anuel"  : "ye ye ye";
141
-        Log::info($tru);
142
-        Log::info(count($activity->rubric));
139
+        $assessment = DB::table('assessments')
140
+            ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
141
+            ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
142
+            ->where('activity_id', $activity->id)
143
+            ->get();
144
+        if ($assessment) {
145
+            $outcomes_achieved = $activity->o_ach_array;
146
+            $outcomes_attempted = $activity->o_att_array;
147
+        } else {
148
+            $outcomes_achieved = [];
149
+            $outcomes_attempted = [];
150
+        }
151
+
152
+        Log::info($outcomes_achieved);
153
+        Log::info($outcomes_achieved);
154
+
155
+        $activity_criterion = DB::table('criteria')
156
+            ->join('activity_criterion', 'criteria.id', '=', 'activity_criterion.criterion_id')
157
+            ->where('activity_id', $activity->id)
158
+            ->select('activity_criterion.id', 'activity_criterion.criterion_id')
159
+            ->addSelect('criteria.name')
160
+            ->get();
161
+
143
 
162
 
144
-        return View::make('local.professors.activity', compact('activity', 'title', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'course', 'student_count', 'active_semesters'));
163
+        $transformative_actions = DB::table('transformative_activity_criterion')
164
+            ->join('activity_criterion', 'transformative_activity_criterion.activity_criterion_id', '=', 'activity_criterion.id')
165
+            ->join('transformative_actions', 'transformative_activity_criterion.trans_action_id', '=', 'transformative_actions.id')
166
+            ->where('activity_criterion.activity_id', $id)
167
+            ->get();
168
+        return View::make('local.professors.activity', compact('activity', 'transformative_actions', 'activity_criterion', 'title', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'course', 'student_count', 'active_semesters'));
145
     }
169
     }
146
 
170
 
147
 
171
 
165
 
189
 
166
         // Get rubric contents
190
         // Get rubric contents
167
         $rubric = Rubric::find($activity->rubric[0]->id);
191
         $rubric = Rubric::find($activity->rubric[0]->id);
192
+        $rubric->titles = DB::table('titles')
193
+            ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
194
+            ->where('rubric_title.rubric_id', '=', $rubric->id)
195
+            ->lists('text');
168
         Log::info($rubric);
196
         Log::info($rubric);
169
         Log::info($activity);
197
         Log::info($activity);
170
         $rubric_criterion = DB::table('criteria')
198
         $rubric_criterion = DB::table('criteria')
175
             ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
203
             ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
176
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
204
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
177
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
205
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
178
-            ->addSelect('rubric_criterion.copyright', 'rubric_criterion.notes')
179
             ->get();
206
             ->get();
180
         Log::info($rubric_criterion);
207
         Log::info($rubric_criterion);
181
         foreach ($rubric_criterion as $index => $singleCR) {
208
         foreach ($rubric_criterion as $index => $singleCR) {
182
-            $singleCR->scales = json_encode(DB::table('scales')->join('rubric_criteria_scale', 'rubric_criteria_scale.scale_id', '=', 'scales.id')
183
-                ->where('rubric_criteria_scale.rubric_criterion_id', '=', $singleCR->rubric_criterion_id)
209
+            $singleCR->scales = json_encode(DB::table('scales')
210
+                ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
211
+                ->where('criterion_scale.criterion_id', '=', $singleCR->criterion_id)
184
                 ->orderBy('position')
212
                 ->orderBy('position')
185
                 ->lists('description'));
213
                 ->lists('description'));
186
         }
214
         }
271
                     // Activity
299
                     // Activity
272
                     $activity = Activity::find(Input::get('activity_id'));
300
                     $activity = Activity::find(Input::get('activity_id'));
273
 
301
 
302
+
274
                     // Create or update student scores
303
                     // Create or update student scores
275
                     if ($activity->outcomes_attempted == NULL) {
304
                     if ($activity->outcomes_attempted == NULL) {
276
                         // For each student, save her/his assessment in the db
305
                         // For each student, save her/his assessment in the db
742
         $students = $course->students;
771
         $students = $course->students;
743
 
772
 
744
         // Get rubric contents
773
         // Get rubric contents
745
-        $rubric_contents = Rubric::select('contents')->where('id', '=', $activity->rubric_id)->get();
746
-        $rubric_contents = json_decode($rubric_contents['0']->contents);
747
-
748
         $rubric = Rubric::find($activity->rubric[0]->id);
774
         $rubric = Rubric::find($activity->rubric[0]->id);
749
 
775
 
750
-        // Get results
751
-        $assessments = DB::table('assessments')->where('activity_id', '=', $activity->id)->orderBy('id', 'asc')->get();
776
+        $rubric->titles = DB::table('titles')
777
+            ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
778
+            ->where('rubric_id', $rubric->id)
779
+            ->get();
780
+
781
+        //$rubric_contents = Rubric::select('contents')->where('id', '=', $activity->rubric_id)->get();
782
+        //$rubric_contents = json_decode($rubric_contents['0']->contents);
783
+
752
 
784
 
785
+        $rubric_criterion = DB::table('criteria')
786
+            ->join("rubric_criterion", "rubric_criterion.criterion_id", "=", "criteria.id")
787
+            ->join("activity_criterion", "criteria.id", '=', 'activity_criterion.criterion_id')
788
+            ->where("activity_criterion.activity_id", '=', $activity->id)
789
+            ->where('rubric_criterion.rubric_id', '=', $rubric->id)
790
+            ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
791
+            ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
792
+            ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
793
+            ->get();
794
+
795
+        foreach ($rubric_criterion as $index => $crit) {
796
+            $crit->scales = DB::table('scales')
797
+                ->join('criterion_scale', 'scales.id', '=', 'criterion_scale.scale_id')
798
+                ->where('criterion_id', $crit->criterion_id)
799
+                ->get();
800
+        }
801
+
802
+
803
+
804
+
805
+        // Get results
806
+        $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
807
+        Log::info($activity_criterion_ids);
808
+        $assessments = DB::table('assessments')
809
+            ->join('students', 'assessments.student_id', '=', 'students.id')
810
+            ->whereIn('activity_criterion_id', $activity_criterion_ids)
811
+            ->orderBy('assessments.id', 'asc')->get();
812
+        Log::info($assessments);
753
         // Decode the scores (blade workaround)
813
         // Decode the scores (blade workaround)
754
         $scores_array = array();
814
         $scores_array = array();
815
+
755
         foreach ($assessments as $index => $assessment) {
816
         foreach ($assessments as $index => $assessment) {
756
-            $scores_array[$assessment->id] = json_decode($assessment->scores, true);
817
+            $scores_array[$assessment->student_id][] = $assessment->score;
818
+            $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
819
+                ->where("activity_id", '=', $activity->id)
820
+                ->select('comments')->first()->comments;
757
         }
821
         }
758
 
822
 
759
-        return View::make('local.professors.view_assessment', compact('activity', 'title', 'students', 'course', 'rubric_contents', 'assessments', 'scores_array', 'rubric'));
823
+        return View::make('local.professors.view_assessment', compact('activity', 'title', 'students', 'course', 'rubric_criterion', 'assessments', 'scores_array', 'rubric'));
760
     }
824
     }
761
 
825
 
762
     public function printAssessment($id)
826
     public function printAssessment($id)

+ 7
- 6
app/controllers/CriteriaController.php View File

22
 
22
 
23
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
23
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
24
         $programs = Program::where("id", "=", $userProgram[0]->program_id)->get();
24
         $programs = Program::where("id", "=", $userProgram[0]->program_id)->get();
25
-        return View::make('local.managers.pCoords.new_criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
25
+        return View::make('local.managers.pCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
26
     }
26
     }
27
 
27
 
28
     public function editSchool()
28
     public function editSchool()
56
         $json_to_send['criterion'] = DB::table('criteria')->where('id', '=', Input::get('id'))->first();
56
         $json_to_send['criterion'] = DB::table('criteria')->where('id', '=', Input::get('id'))->first();
57
         $outcomeIDS = DB::table('criterion_objective_outcome')->where('criterion_id', '=', $json_to_send['criterion']->id)->lists('outcome_id');
57
         $outcomeIDS = DB::table('criterion_objective_outcome')->where('criterion_id', '=', $json_to_send['criterion']->id)->lists('outcome_id');
58
         Log::info($outcomeIDS);
58
         Log::info($outcomeIDS);
59
+
60
+        $json_to_send['scales'] = DB::table('criterion_scale')
61
+            ->join('scales', 'scales.id', '=', 'criterion_scale.scale_id')
62
+            ->where('criterion_id', Input::get('id'))
63
+            ->orderBy('position')
64
+            ->get();
59
         $json_to_send['outcomes'] = DB::table('outcomes')->whereIn('id', $outcomeIDS)->get();
65
         $json_to_send['outcomes'] = DB::table('outcomes')->whereIn('id', $outcomeIDS)->get();
60
         $outcomeStr = '';
66
         $outcomeStr = '';
61
         if (count($json_to_send['outcomes']) == 1) {
67
         if (count($json_to_send['outcomes']) == 1) {
68
             $outcomeStr = rtrim($outcomeStr, ',');
74
             $outcomeStr = rtrim($outcomeStr, ',');
69
         }
75
         }
70
         $json_to_send['outcomes'] = $outcomeStr;
76
         $json_to_send['outcomes'] = $outcomeStr;
71
-        $num_scales = Input::get('numberOfScale');
72
-        $criterionID = Input::get('id');
73
-
74
-        $json_to_send['scales'] = DB::select("select * from scales, template_criterion_scale where template_criterion_scale.template_criterion_id in (select id from template_criterion where template_criterion.template_id in (SELECT id FROM templates where num_scales = {$num_scales}) and template_criterion.criterion_id = {$criterionID}) and scales.id = template_criterion_scale.scale_id GROUP BY position order by position");
75
-        $json_to_send['crit_info'] = DB::select("select copyright, notes from template_criterion where id in (select template_criterion_id from scales, template_criterion_scale where template_criterion_scale.template_criterion_id in (select id from template_criterion where template_criterion.template_id in (SELECT id FROM templates where num_scales = {$num_scales}) and template_criterion.criterion_id = {$criterionID}) and scales.id = template_criterion_scale.scale_id  GROUP BY position  order by position) limit 1");
76
 
77
 
77
 
78
 
78
 
79
 

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

412
                 case 'all':
412
                 case 'all':
413
                     return DB::table('criteria')
413
                     return DB::table('criteria')
414
                         ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
414
                         ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
415
-                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
415
+                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
416
+                        ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
417
+                        ->where('criteria.num_scales', '=', Input::get('num_scales'))
418
+                        ->where('criteria.max_score', '=', Input::get('maximum'))
416
                         ->select('criterion_id as id', 'name')
419
                         ->select('criterion_id as id', 'name')
417
                         ->orderBy('name', 'ASC')
420
                         ->orderBy('name', 'ASC')
418
                         ->get();
421
                         ->get();
427
                         $criteria = DB::table('criteria')
430
                         $criteria = DB::table('criteria')
428
                             ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
431
                             ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
429
                             ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
432
                             ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
430
-                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
433
+                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
434
+                            ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
435
+                            ->where('criteria.num_scales', '=', Input::get('num_scales'))
436
+                            ->where('criteria.max_score', '=', Input::get('maximum'))
431
                             ->whereIn('program_criterion.program_id', $program_ids)
437
                             ->whereIn('program_criterion.program_id', $program_ids)
432
                             ->select('criterion_id as id', 'name')
438
                             ->select('criterion_id as id', 'name')
433
                             ->orderBy('name', 'ASC')
439
                             ->orderBy('name', 'ASC')
445
                         return DB::table('criteria')
451
                         return DB::table('criteria')
446
                             ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
452
                             ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
447
                             ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
453
                             ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
448
-                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
454
+                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
455
+                            ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
456
+                            ->where('criteria.num_scales', '=', Input::get('num_scales'))
457
+                            ->where('criteria.max_score', '=', Input::get('maximum'))
449
                             ->whereIn('program_criterion.program_id', $program_ids)
458
                             ->whereIn('program_criterion.program_id', $program_ids)
450
                             ->select('criterion_id as id', 'name')
459
                             ->select('criterion_id as id', 'name')
451
                             ->orderBy('name', 'ASC')
460
                             ->orderBy('name', 'ASC')
458
                     $criteria = DB::table('criteria')
467
                     $criteria = DB::table('criteria')
459
                         ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
468
                         ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
460
                         ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
469
                         ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
461
-                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
470
+                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
471
+                        ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
472
+                        ->where('criteria.num_scales', '=', Input::get('num_scales'))
473
+                        ->where('criteria.max_score', '=', Input::get('maximum'))
462
                         ->whereIn('program_criterion.program_id', Auth::user()->programs->lists('id'))
474
                         ->whereIn('program_criterion.program_id', Auth::user()->programs->lists('id'))
463
                         ->select('criterion_id as id', 'name')
475
                         ->select('criterion_id as id', 'name')
464
                         ->orderBy('name', 'ASC')
476
                         ->orderBy('name', 'ASC')
469
                 default:
481
                 default:
470
                     return DB::table('criteria')
482
                     return DB::table('criteria')
471
                         ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
483
                         ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
472
-                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
484
+                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
485
+                        ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
486
+                        ->where('criteria.num_scales', '=', Input::get('num_scales'))
487
+                        ->where('criteria.max_score', '=', Input::get('maximum'))
473
                         ->select('criterion_id as id', 'name')
488
                         ->select('criterion_id as id', 'name')
474
                         ->orderBy('name', 'ASC')
489
                         ->orderBy('name', 'ASC')
475
                         ->get();
490
                         ->get();
478
         } else {
493
         } else {
479
             return DB::table('criteria')
494
             return DB::table('criteria')
480
                 ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
495
                 ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
481
-                ->where('criterion_objective_outcome.outcome_id', '=', Input::get('id'))
496
+                ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
497
+                ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
498
+                ->where('criteria.num_scales', '=', Input::get('num_scales'))
499
+                ->where('criteria.max_score', '=', Input::get('maximum'))
482
                 ->select('criterion_id as id', 'name')
500
                 ->select('criterion_id as id', 'name')
483
                 ->orderBy('name', 'ASC')
501
                 ->orderBy('name', 'ASC')
484
                 ->get();
502
                 ->get();

+ 48
- 76
app/controllers/RubricsController.php View File

82
 
82
 
83
         // Get rubric contents
83
         // Get rubric contents
84
 
84
 
85
-        $scales = Input::get('scales');
85
+        $titles = Input::get('titles');
86
         $criteria = Input::get('criteria');
86
         $criteria = Input::get('criteria');
87
 
87
 
88
         // Process rubric
88
         // Process rubric
92
         $rubric->expected_percentage = Input::get('expected_percentage');
92
         $rubric->expected_percentage = Input::get('expected_percentage');
93
         $rubric->expected_points = Input::get('expected_points');
93
         $rubric->expected_points = Input::get('expected_points');
94
         $rubric->user_id = Auth::id();
94
         $rubric->user_id = Auth::id();
95
-        $rubric->num_scales = count($scales[0]);
95
+        $rubric->num_scales = count($titles);
96
         $rubric->max_score = Input::get('max_score');
96
         $rubric->max_score = Input::get('max_score');
97
         $defaultWeight = round(100 / count($criteria), 2);
97
         $defaultWeight = round(100 / count($criteria), 2);
98
 
98
 
108
 
108
 
109
             $rubricId = $rubric->id;
109
             $rubricId = $rubric->id;
110
             foreach ($criteria as $index => $criterion_id) {
110
             foreach ($criteria as $index => $criterion_id) {
111
-                DB::insert("insert into rubric_criterion (`rubric_id`,`criterion_id`) values ({$rubricId},{$criterion_id})");
111
+                DB::insert("insert into rubric_criterion (`rubric_id`,`criterion_id`, `position`) values ({$rubricId},{$criterion_id}, {$index})");
112
                 DB::commit();
112
                 DB::commit();
113
-                $rubric_criterion_id = DB::table('rubric_criterion')->where('rubric_id', '=', $rubricId)
114
-                    ->where('criterion_id', '=', $criterion_id)->first();
115
-
116
-
117
-
118
-                for ($i = 0; $i < count($scales[$index]); $i++) {
119
-                    $scale =  Scale::where('description', '=', $scales[$index][$i])->first();
120
-                    Log::info($scale);
121
-                    if ($scale) {
122
-                        DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$scale->id}, {$i})");
123
-                        DB::commit();
124
-                    } else {
125
-                        $scale = new Scale;
126
-                        $scale->description = $scales[$index][$i];
127
-
128
-                        if ($scale->save()) {
129
-                            DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$scale->id}, {$i})");
130
-                            DB::commit();
131
-                        } else {
132
-                            Session::flash('status', 'danger');
133
-                            Session::flash('message', 'Rubric could not be created.');
134
-                        }
135
-                    }
136
-                }
113
+
114
+
115
+
116
+
137
 
117
 
138
                 $activity_id = Input::get("activity_id");
118
                 $activity_id = Input::get("activity_id");
139
                 DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity_id}, {$criterion_id}, {$defaultWeight})");
119
                 DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity_id}, {$criterion_id}, {$defaultWeight})");
140
                 DB::commit();
120
                 DB::commit();
141
             }
121
             }
122
+
123
+            foreach ($titles as $index => $id) {
124
+                DB::insert("insert into `rubric_title` (`rubric_id`, `title_id`, `position`) values ({$rubricId}, {$id}, {$index} )");
125
+                DB::commit();
126
+            }
142
             Session::flash('status', 'success');
127
             Session::flash('status', 'success');
143
             Session::flash('message', 'Rubric assigned.');
128
             Session::flash('message', 'Rubric assigned.');
144
 
129
 
168
      */
153
      */
169
     public function update()
154
     public function update()
170
     {
155
     {
171
-        Log::info('entré???');
156
+
172
         $rubric = Rubric::find(Input::get('id'));
157
         $rubric = Rubric::find(Input::get('id'));
173
 
158
 
174
-        $scales = Input::get('scales');
159
+        $titles = Input::get('titles');
175
         $criteria = Input::get('criteria');
160
         $criteria = Input::get('criteria');
176
 
161
 
177
         // Process rubric
162
         // Process rubric
180
         $rubric->expected_percentage = Input::get('expected_percentage');
165
         $rubric->expected_percentage = Input::get('expected_percentage');
181
         $rubric->expected_points = Input::get('expected_points');
166
         $rubric->expected_points = Input::get('expected_points');
182
 
167
 
183
-        $rubric->num_scales = count($scales[0]);
168
+        $rubric->num_scales = count($titles);
184
         $rubric->max_score = Input::get('max_score');
169
         $rubric->max_score = Input::get('max_score');
185
         $defaultWeight = round(100 / count($criteria), 2);
170
         $defaultWeight = round(100 / count($criteria), 2);
186
 
171
 
201
 
186
 
202
 
187
 
203
         // If the associated activity has been assessed, delete the records
188
         // If the associated activity has been assessed, delete the records
204
-        if ($activity->outcomes_attempted != NULL) {
189
+        /* if ($activity->outcomes_attempted != NULL) {
205
             DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
190
             DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
206
             $activity->criteria_achieved_percentage = NULL;
191
             $activity->criteria_achieved_percentage = NULL;
207
             $activity->criteria_achieved = NULL;
192
             $activity->criteria_achieved = NULL;
208
             $activity->outcomes_achieved = NULL;
193
             $activity->outcomes_achieved = NULL;
209
             $activity->outcomes_attempted = NULL;
194
             $activity->outcomes_attempted = NULL;
210
-        }
211
-        Log::info('entré3???');
195
+        }*/
196
+
212
 
197
 
213
         $rubric->save();
198
         $rubric->save();
214
-        Log::info("????");
199
+
215
         $activity->save();
200
         $activity->save();
216
-        Log::info("????22");
201
+
217
         // Get all the course's activities
202
         // Get all the course's activities
218
         Log::info($activity->course);
203
         Log::info($activity->course);
219
         $course = Course::find($activity->course->id);
204
         $course = Course::find($activity->course->id);
230
         Log::info('entré4???');
215
         Log::info('entré4???');
231
 
216
 
232
         //If there are still evaluated activities in the course, recalculate course outcomes
217
         //If there are still evaluated activities in the course, recalculate course outcomes
218
+        /*
233
         if (!$activities->isEmpty() && $remainingAssessed) {
219
         if (!$activities->isEmpty() && $remainingAssessed) {
234
             // Variables to hold recalculated outcomes for the course
220
             // Variables to hold recalculated outcomes for the course
235
             $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
221
             $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
269
         }
255
         }
270
 
256
 
271
         $course->save();
257
         $course->save();
258
+        */
272
         Log::info('entré6???');
259
         Log::info('entré6???');
273
         DB::delete("delete from rubric_criterion where rubric_id ={$rubric->id}");
260
         DB::delete("delete from rubric_criterion where rubric_id ={$rubric->id}");
274
         DB::delete("delete from activity_criterion where activity_id = {$activity->id}");
261
         DB::delete("delete from activity_criterion where activity_id = {$activity->id}");
275
         foreach ($criteria as $index => $criterion_id) {
262
         foreach ($criteria as $index => $criterion_id) {
276
-            if (
277
-
278
-                DB::insert("insert into rubric_criterion (`rubric_id`, `criterion_id`) values ({$rubric->id}, {$criterion_id}) ")
279
-                &&  DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity->id}, {$criterion_id}, {$defaultWeight})")
280
-            ) {
281
-
282
-                $rubric_criterion_id =  DB::table('rubric_criterion')
283
-                    ->where('rubric_id', '=', $rubric->id)
284
-                    ->where('criterion_id', '=', $criterion_id)
285
-                    ->first();
286
-
287
-                foreach ($scales[$index] as $in => $scale) {
288
-                    Log::info("AH2");
289
-                    $new_scale =  Scale::where('description', '=', $scale)->first();
290
-
291
-                    if ($new_scale) {
292
-                        DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$new_scale->id}, {$in})");
293
-                        DB::commit();
294
-                    } else {
295
-                        $new_scale = new Scale;
296
-                        $new_scale->description = $scales[$index][$in];
297
-                        if ($new_scale->save()) {
298
-                            DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$new_scale->id}, {$in})");
299
-                            DB::commit();
300
-                        } else {
301
-                            DB::rollBack();
302
-                            Session::flash('status', 'danger');
303
-                            Session::flash('message', 'Rubric could not be created.');
304
-                            return action('ActivitiesController@show', array($activity->id));
305
-                        }
306
-                    }
307
-                }
308
-            } else {
263
+
264
+
265
+            $result =  DB::insert("insert into rubric_criterion (`rubric_id`, `criterion_id`) values ({$rubric->id}, {$criterion_id}) ");
266
+            $result2 = DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity->id}, {$criterion_id}, {$defaultWeight})");
267
+            if (!($result || $result2)) {
309
                 DB::rollBack();
268
                 DB::rollBack();
310
                 Session::flash('status', 'danger');
269
                 Session::flash('status', 'danger');
311
                 Session::flash('message', 'Rubric could not be created.');
270
                 Session::flash('message', 'Rubric could not be created.');
312
                 return action('ActivitiesController@show', array($activity->id));
271
                 return action('ActivitiesController@show', array($activity->id));
313
             }
272
             }
314
         }
273
         }
274
+
275
+        foreach ($titles as $index => $id) {
276
+            DB::insert("insert into rubric_title (`rubric_id`, `title_id`, `position`) values ({$rubric->id},{$id},{$index}) ");
277
+        }
315
         Log::info('entré7???');
278
         Log::info('entré7???');
316
 
279
 
317
         DB::commit();
280
         DB::commit();
366
             ->get();
329
             ->get();
367
         Log::info($rubric_criterion);
330
         Log::info($rubric_criterion);
368
 
331
 
332
+        $rubric->titles = DB::table('titles')
333
+            ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
334
+            ->where('rubric_title.rubric_id', $rubric->id)
335
+            ->lists('text');
336
+
369
         foreach ($rubric_criterion as $single_cr) {
337
         foreach ($rubric_criterion as $single_cr) {
370
             $single_cr->scales = json_encode(DB::table('scales')
338
             $single_cr->scales = json_encode(DB::table('scales')
371
-                ->join('rubric_criteria_scale', 'rubric_criteria_scale.scale_id', '=', 'scales.id')
372
-                ->where('rubric_criteria_scale.rubric_criterion_id', '=', $single_cr->id)
339
+                ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
340
+                ->where('criterion_scale.criterion_id', '=', $single_cr->criterion_id)
373
                 ->orderBy('position')
341
                 ->orderBy('position')
374
                 ->lists('description'));
342
                 ->lists('description'));
375
             $single_cr->outcomes = json_encode(DB::table('outcomes')
343
             $single_cr->outcomes = json_encode(DB::table('outcomes')
433
 
401
 
434
     public function fetchRubricCriterion()
402
     public function fetchRubricCriterion()
435
     {
403
     {
436
-        $rubric = DB::table("rubric_criteria_scale")
437
-            ->join('scales', 'scales.id', '=', 'rubric_criteria_scale.scale_id')
438
-            ->where("rubric_criterion_id", '=', Input::get('rubric_criterion_id'))->get();
404
+        $rubric = DB::table("criterion_scale")
405
+            ->join('scales', 'scales.id', '=', 'criterion_scale.scale_id')
406
+            ->where("criterion_id", '=', Input::get('criterion_id'))
407
+            ->orderBy('position')
408
+            ->get();
409
+
439
         Log::info($rubric);
410
         Log::info($rubric);
440
 
411
 
441
         $rubric["criteria"] = DB::table("criteria")
412
         $rubric["criteria"] = DB::table("criteria")
442
-            ->join("rubric_criterion", 'rubric_criterion.criterion_id', '=', 'criteria.id')
443
-            ->where("rubric_criterion.id", '=', Input::get('rubric_criterion_id'))
444
-            ->select('name', 'rubric_criterion.notes')
413
+
414
+            ->where("criteria.id", '=', Input::get('criterion_id'))
415
+
416
+            ->select('name', 'notes')
445
             ->first();
417
             ->first();
446
         return json_encode($rubric);
418
         return json_encode($rubric);
447
 
419
 

+ 114
- 75
app/controllers/TemplatesController.php View File

52
 			->get();
52
 			->get();
53
 		Log::info($json_to_send["criteria"]);
53
 		Log::info($json_to_send["criteria"]);
54
 		foreach ($json_to_send['criteria'] as $criteria) {
54
 		foreach ($json_to_send['criteria'] as $criteria) {
55
-			$json_to_send['scales'][$criteria->criterion_id] = DB::table("scales")->join('template_criterion_scale', 'template_criterion_scale.scale_id', '=', 'scales.id')
56
-				->where("template_criterion_scale.template_criterion_id", '=', $criteria->id)->orderBy('position', 'ASC')->get();
55
+			$json_to_send['scales'][$criteria->criterion_id] = DB::table("scales")
56
+				->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
57
+				->where("criterion_scale.criterion_id", '=', $criteria->criterion_id)->orderBy('position', 'ASC')->get();
57
 		}
58
 		}
58
 		return json_encode($json_to_send);
59
 		return json_encode($json_to_send);
59
 	}
60
 	}
96
 	 */
97
 	 */
97
 	public function create()
98
 	public function create()
98
 	{
99
 	{
99
-
100
+		DB::beginTransaction();
100
 		$template = new Template;
101
 		$template = new Template;
101
 
102
 
102
 		$template->name = Input::get('name');
103
 		$template->name = Input::get('name');
135
 				$template->program_id = Auth::user()->programs[0]->id;
136
 				$template->program_id = Auth::user()->programs[0]->id;
136
 				break;
137
 				break;
137
 		}
138
 		}
138
-		$scales = Input::get('scales');
139
+
139
 		$criteria = Input::get('criteria');
140
 		$criteria = Input::get('criteria');
140
 
141
 
141
 		$max_score = Input::get('max_score');
142
 		$max_score = Input::get('max_score');
142
-		$copyright = Input::get('copyright');
143
-		$notes = Input::get('notes');
144
-		Log::info($scales);
145
-		Log::info($criteria);
146
-		Log::info($copyright);
147
-		Log::info($notes);
143
+		$titles = Input::get('titles');
144
+
148
 
145
 
149
 
146
 
150
-		$template->num_scales = count($scales[0]);
147
+		$template->num_scales = count($titles);
151
 		$template->max_score = $max_score;
148
 		$template->max_score = $max_score;
152
 
149
 
153
 		if ($template->save()) {
150
 		if ($template->save()) {
151
+
154
 			$templateId = $template->id;
152
 			$templateId = $template->id;
155
 			foreach ($criteria as $index => $criterion_id) {
153
 			foreach ($criteria as $index => $criterion_id) {
156
-				$note = $notes[$index];
157
-				$copy = $copyright[$index];
158
-				if ($copy == "Empty") $copy = NULL;
159
-				if ($note == "Empty") $note = NULL;
160
-
161
-				DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `copyright`, `notes`) values ({$templateId},{$criterion_id}, '{$copy}', '{$note}')");
162
-				$template_criterion_id = DB::table('template_criterion')->where('template_id', '=', $templateId)
163
-					->where('criterion_id', '=', $criterion_id)->first();
164
-
165
-				for ($i = 0; $i < count($scales[$index]); $i++) {
166
-					$scale =  Scale::where('description', '=', $scales[$index][$i])->first();
167
-					Log::info($scale);
168
-					if ($scale) {
169
-						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
170
-						DB::commit();
171
-					} else {
172
-						$scale = new Scale;
173
-						$scale->description = $scales[$index][$i];
174
-
175
-						if ($scale->save()) {
176
-							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
177
-							DB::commit();
178
-						} else {
179
-							Session::flash('status', 'danger');
180
-							Session::flash('message', 'Rubric could not be created.');
181
-						}
154
+
155
+
156
+				if (!(DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `position`) values ({$templateId},{$criterion_id}, '{$index}')"))) {
157
+					Session::flash('status', 'danger');
158
+					Session::flash('message', 'Rubric could not be created.');
159
+					DB::rollback();
160
+					return;
161
+				}
162
+			}
163
+
164
+			foreach ($titles as $index => $text) {
165
+				$query = DB::table('titles')
166
+					->where('text', $text)->first();
167
+				if ($query) {
168
+					$result = DB::insert("insert into `template_title` (`template_id`, `title_id` `position`) values ({$templateId}, {$query->id}, {$index})");
169
+					if (!$result) {
170
+						Session::flash('status', 'danger');
171
+						Session::flash('message', 'Rubric could not be created.');
172
+						DB::rollback();
173
+						return;
174
+					}
175
+				} else {
176
+					$result1 = DB::insert("insert into `titles` (`text`) values ('{$text}')");
177
+					if (!$result1) {
178
+						Session::flash('status', 'danger');
179
+						Session::flash('message', 'Rubric could not be created.');
180
+						DB::rollback();
181
+						return;
182
+					}
183
+					$query = DB::table('titles')
184
+						->where('text', $text)->first();
185
+					$result = DB::insert("insert into `template_title` (`template_id`, `title_id`, `position`) values ({$templateId}, {$query->id}, {$index})");
186
+					if (!$result) {
187
+						Session::flash('status', 'danger');
188
+						Session::flash('message', 'Rubric could not be created.');
189
+						DB::rollback();
190
+						return;
182
 					}
191
 					}
183
 				}
192
 				}
184
 			}
193
 			}
194
+
195
+
185
 			Session::flash('status', 'success');
196
 			Session::flash('status', 'success');
186
 			Session::flash('message', 'Rubric created. You can now select it from the list.');
197
 			Session::flash('message', 'Rubric created. You can now select it from the list.');
198
+
199
+			DB::commit();
200
+
201
+
202
+			return;
187
 		} else {
203
 		} else {
188
 			Session::flash('status', 'danger');
204
 			Session::flash('status', 'danger');
189
 			Session::flash('message', 'Rubric could not be created.');
205
 			Session::flash('message', 'Rubric could not be created.');
206
+			DB::rollback();
207
+			return;
190
 		}
208
 		}
191
 	}
209
 	}
192
 
210
 
204
 			->where("template_criterion.template_id", '=', Input::get('id'))
222
 			->where("template_criterion.template_id", '=', Input::get('id'))
205
 			->get();
223
 			->get();
206
 		foreach ($template_info['criterion'] as $temp_crit) {
224
 		foreach ($template_info['criterion'] as $temp_crit) {
207
-			$template_info['scales'][$temp_crit->id] = DB::table('scales')
208
-				->join('template_criterion_scale', 'template_criterion_scale.scale_id', '=', 'scales.id')
209
-				->where('template_criterion_scale.template_criterion_id', '=', $temp_crit->id)
225
+			$temp_crit->scales = DB::table('scales')
226
+				->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
227
+				->where('criterion_scale.criterion_id', '=', $temp_crit->criterion_id)
210
 				->orderBy('position', 'ASC')
228
 				->orderBy('position', 'ASC')
211
 				->get();
229
 				->get();
212
 			$outcomeID = DB::table('criterion_objective_outcome')->where('criterion_id', '=', $temp_crit->criterion_id)
230
 			$outcomeID = DB::table('criterion_objective_outcome')->where('criterion_id', '=', $temp_crit->criterion_id)
220
 			$temp_crit->outcomes = $outcomeStr;
238
 			$temp_crit->outcomes = $outcomeStr;
221
 		}
239
 		}
222
 
240
 
241
+		$template_info['titles'] = DB::table('titles')
242
+			->join('template_title', 'template_title.title_id', '=', 'titles.id')
243
+			->where('template_id', Input::get('id'))
244
+			->orderBy('position')
245
+			->get();
246
+
223
 		Log::info($template_info);
247
 		Log::info($template_info);
224
 
248
 
225
 		return json_encode($template_info);
249
 		return json_encode($template_info);
232
 	 */
256
 	 */
233
 	public function update()
257
 	public function update()
234
 	{
258
 	{
259
+		DB::beginTransaction();
235
 		$template = Template::find(Input::get('id'));
260
 		$template = Template::find(Input::get('id'));
261
+		Log::info(Input::all());
236
 		$template->name = Input::get('name');
262
 		$template->name = Input::get('name');
237
 
263
 
238
 		$template->is_visible = Input::get('is_visible');
264
 		$template->is_visible = Input::get('is_visible');
269
 				break;
295
 				break;
270
 		}
296
 		}
271
 
297
 
272
-		$scales = Input::get('scales');
298
+
273
 		$criteria = Input::get('criteria');
299
 		$criteria = Input::get('criteria');
274
 
300
 
275
 		$max_score = Input::get('max_score');
301
 		$max_score = Input::get('max_score');
276
-		$copyright = Input::get('copyright');
277
-		$notes = Input::get('notes');
278
-		Log::info($scales);
279
-		Log::info(Input::all());
302
+		$titles = Input::get('titles');
280
 
303
 
281
-		$template->num_scales = count($scales[0]);
304
+
305
+
306
+		$template->num_scales = count($titles);
282
 		$template->max_score = $max_score;
307
 		$template->max_score = $max_score;
283
 		//$division = $max_score / count($scales[0]);
308
 		//$division = $max_score / count($scales[0]);
284
 
309
 
286
 			$templateId = $template->id;
311
 			$templateId = $template->id;
287
 			DB::delete("delete from template_criterion where template_id ={$template->id}");
312
 			DB::delete("delete from template_criterion where template_id ={$template->id}");
288
 			foreach ($criteria as $index => $criterion_id) {
313
 			foreach ($criteria as $index => $criterion_id) {
289
-				$copy = $copyright[$index];
290
-				$note = $notes[$index];
291
-				if ($copy == 'Empty') $copy = NULL;
292
-				if ($note == 'Empty') $note = NULL;
293
-				DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `copyright`, `notes`) values ({$templateId},{$criterion_id}, '{$copy}', '{$note}')");
294
-				$template_criterion_id = DB::table('template_criterion')->where('template_id', '=', $templateId)
295
-					->where('criterion_id', '=', $criterion_id)->first();
296
-				DB::delete("delete from template_criterion_scale where template_criterion_id ={$template_criterion_id->id}");
297
-				for ($i = 0; $i < count($scales[$index]); $i++) {
298
-					$scale =  Scale::where('description', '=', $scales[$index][$i])
299
-						//->where('max_score', '=', ($division * ($i + 1)))
300
-						//->where("min_score", '=', (1 + ($division * $i)))
301
-						->first();
302
-					Log::info($scale);
303
-					if ($scale) {
304
-						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
305
-						DB::commit();
306
-					} else {
307
-						$scale = new Scale;
308
-						$scale->description = $scales[$index][$i];
309
-						//$scale->min_score = 1 + ($division * $i);
310
-						//$scale->max_score = ($division * ($i + 1));
311
-						if ($scale->save()) {
312
-							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
313
-							DB::commit();
314
-						} else {
315
-							Session::flash('status', 'danger');
316
-							Session::flash('message', 'Rubric could not be created.');
317
-						}
314
+
315
+				if (!DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `position`) values ({$templateId},{$criterion_id}, {$index})")) {
316
+
317
+					Session::flash('status', 'danger');
318
+					Session::flash('message', 'Rubric could not be created.');
319
+					DB::rollback();
320
+					return;
321
+				}
322
+			}
323
+			DB::delete("delete from template_title where template_id = {$template->id}");
324
+			foreach ($titles as $index => $text) {
325
+				$query = DB::table('titles')
326
+					->where('text', $text)->first();
327
+				if ($query) {
328
+					$result = DB::insert("insert into `template_title` (`template_id`, `title_id`, `position`) values ({$templateId}, {$query->id}, {$index})");
329
+					if (!$result) {
330
+						Session::flash('status', 'danger');
331
+						Session::flash('message', 'Rubric could not be created.');
332
+						DB::rollback();
333
+						return;
334
+					}
335
+				} else {
336
+					$result1 = DB::insert("insert into `titles` (`text`) values ('{$text}')");
337
+					if (!$result1) {
338
+						Session::flash('status', 'danger');
339
+						Session::flash('message', 'Rubric could not be created.');
340
+						DB::rollback();
341
+						return;
342
+					}
343
+					$query = DB::table('titles')
344
+						->where('text', $text)->first();
345
+					$result = DB::insert("insert into `template_title` (`template_id`, `title_id`, `position`) values ({$templateId}, {$query->id}, {$index})");
346
+					if (!$result) {
347
+						Session::flash('status', 'danger');
348
+						Session::flash('message', 'Rubric could not be created.');
349
+						DB::rollback();
350
+						return;
318
 					}
351
 					}
319
 				}
352
 				}
320
 			}
353
 			}
354
+
355
+
356
+
321
 			Session::flash('status', 'success');
357
 			Session::flash('status', 'success');
358
+
322
 			Session::flash('message', 'Rubric updated (' . date('m/d/y, h:i:s a') . ').');
359
 			Session::flash('message', 'Rubric updated (' . date('m/d/y, h:i:s a') . ').');
360
+			DB::commit();
323
 		} else {
361
 		} else {
324
 			Session::flash('status', 'danger');
362
 			Session::flash('status', 'danger');
325
 			Session::flash('message', 'Rubric could not be updated (' . date('m/d/y, h:i:s a') . ').');
363
 			Session::flash('message', 'Rubric could not be updated (' . date('m/d/y, h:i:s a') . ').');
364
+			DB::commit();
326
 		}
365
 		}
327
 	}
366
 	}
328
 
367
 

+ 45
- 0
app/controllers/TransformativeActionsController.php View File

929
     }
929
     }
930
     return 'ilegal';
930
     return 'ilegal';
931
   }
931
   }
932
+
933
+  function postActivityCriterion($activity_id)
934
+  {
935
+    DB::beginTransaction();
936
+    $activity_criterion = Input::get('trans_act');
937
+
938
+    $trans = new TransformativeAction;
939
+
940
+    $trans->user_id = Auth::user()['id'];
941
+    $program_id = DB::table('activities')
942
+      ->join('courses', 'activities.course_id', '=', 'courses.id')
943
+      ->where('activities.id', $activity_id)
944
+      ->lists('program_id');
945
+    $trans->program_id = $program_id[0];
946
+    $trans->is_custom = 1;
947
+    $trans->by_professor = 1;
948
+
949
+    $trans->at_text = Input::get('name_trans');
950
+    $trans->description = Input::get('transforming_actions');
951
+
952
+    if ($trans->save()) {
953
+
954
+      foreach ($activity_criterion as $single_ac) {
955
+        $result = DB::insert("insert into `transformative_activity_criterion` (`trans_action_id`, `activity_criterion_id`) values ($trans->id, $single_ac)");
956
+        if (!$result) {
957
+          DB::rollback();
958
+          Session::flash('status', 'danger');
959
+          Session::flash('message', 'Error saving Transforming Action. Try again later.');
960
+
961
+          return Redirect::to("professor/activities/{$activity_id}");
962
+        }
963
+      }
964
+      DB::commit();
965
+      Session::flash('status', 'success');
966
+      Session::flash('message', 'Transformative Actions Saved.');
967
+
968
+      return Redirect::to("professor/activities/{$activity_id}");
969
+    } else {
970
+      DB::rollback();
971
+      Session::flash('status', 'danger');
972
+      Session::flash('message', 'Error saving Transforming Action. Try again later.');
973
+
974
+      return Redirect::to("professor/activities/{$activity_id}");
975
+    }
976
+  }
932
 }
977
 }

+ 2
- 2
app/database/migrations/2021_06_02_000507_create_rubrics_table.php View File

16
 			$table->integer('expected_points');
16
 			$table->integer('expected_points');
17
 			$table->integer('user_id')->unsigned();
17
 			$table->integer('user_id')->unsigned();
18
 			$table->timestamps();
18
 			$table->timestamps();
19
-			//$table->integer('num_scales')->unsigned();
20
-			//$table->integer('max_score')->unsigned();
19
+			$table->integer('num_scales')->unsigned();
20
+			$table->integer('max_score')->unsigned();
21
 		});
21
 		});
22
 
22
 
23
 		Schema::table('rubrics', function (Blueprint $table) {
23
 		Schema::table('rubrics', function (Blueprint $table) {

+ 2
- 2
app/database/migrations/2021_06_04_003810_create_activity_criterion_table.php View File

29
 				->on('criteria')
29
 				->on('criteria')
30
 				->onDelete('cascade')
30
 				->onDelete('cascade')
31
 				->onUpdate('cascade');
31
 				->onUpdate('cascade');
32
-			$table->text('transformative_actions')->nullable();
33
-			$table->text('assessment_comments')->nullable();
32
+			//$table->text('transformative_actions')->nullable();
33
+			//$table->text('assessment_comments')->nullable();
34
 
34
 
35
 
35
 
36
 			$table->decimal('weight', 6, 2)->default(1.0);
36
 			$table->decimal('weight', 6, 2)->default(1.0);

+ 6
- 0
app/models/TransformativeAction.php View File

1
+<?php
2
+
3
+class TransformativeAction extends Eloquent
4
+{
5
+    protected $table = 'transformative_actions';
6
+}

+ 4
- 1
app/routes.php View File

166
     /**
166
     /**
167
      * Shared Routes
167
      * Shared Routes
168
      */
168
      */
169
-
169
+    Route::post('postActivityCriterionTrans/{activity_id}', array(
170
+        'as' => 'postActivityCriterionTrans/{activity_id}',
171
+        'uses' => 'TransformativeActionsController@postActivityCriterion'
172
+    ));
170
     Route::post('changeStatusOfCriterion', array(
173
     Route::post('changeStatusOfCriterion', array(
171
         'as' => 'changeStatusOfCriterion',
174
         'as' => 'changeStatusOfCriterion',
172
         'uses' => 'CriteriaController@changeStatus'
175
         'uses' => 'CriteriaController@changeStatus'

+ 583
- 232
app/views/local/managers/admins/criteria.blade.php
File diff suppressed because it is too large
View File


+ 347
- 125
app/views/local/managers/pCoords/criteria.blade.php View File

13
                 Create
13
                 Create
14
             </div>
14
             </div>
15
             <div class="panel-body">
15
             <div class="panel-body">
16
-                {{ Form::open(array('action' => 'CriteriaController@create')) }}
17
-                <div id='outcomeGroup' data-value = "1">
16
+                {{ Form::open(array('action' => 'CriteriaController@create', 'id'=> 'create_criterion')) }}
17
+                <div id ='allOutcomes'>
18
+                <div id='outcomeGroup0' data-value = "1">
19
+                    <div class="form-group col-md-12">
20
+                        <label>Outcome 1</label>
21
+
22
+                        {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcome0", "objectiveGroupFor0")']) }}
23
+                    </div>
24
+                
25
+                <div id='objectiveGroupFor0' data-value = '1'>
18
                     <div class="form-group col-md-11">
26
                     <div class="form-group col-md-11">
19
-                        <label>Associated Outcomes</label>
27
+                        <label>Associated Objectives for Outcome 1</label>
28
+                        <select id="objective_0_counter_1" name="objective[]" class="form-control selectpicker">
29
+                        </select>
20
 
30
 
21
-                        {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")']) }}
31
+                    </div>
32
+                    <div class = "col-md-1">
22
                     </div>
33
                     </div>
23
                 </div>
34
                 </div>
24
-                <input type='hidden' name='counterOutcome' id='counterOutcome' value=1>
25
-                <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
35
+                <input type='hidden' name='counterObjective' id='counterObjective' value=1>
36
+                <button  class='btn btn-md btn-secondary button-add-objective' onclick='addObjectiveTest("objectiveGroupFor0", "objective_0")'>
26
                     <span class='glyphicon glyphicon-plus'>
37
                     <span class='glyphicon glyphicon-plus'>
27
 
38
 
28
                     </span>
39
                     </span>
29
-                    Add another Outcome
40
+                    Add another Objective
30
                 </button>
41
                 </button>
31
-                <div id='objectiveGroup' data-value = '1'>
32
-                    <div class="form-group">
33
-                        <label>Associated Objectives</label>
34
-                        <select id="objective_0" name="objective[]" class="form-control selectpicker">
35
-                        </select>
36
-
37
-                    </div>
42
+                
43
+                <br></div><hr>
38
                 </div>
44
                 </div>
39
-                <input type='hidden' name='counterObjective' id='counterObjective' value=1>
40
-                <button id='button-add-objective' class='btn btn-md btn-secondary' onclick='addObjectiveTest()'>
45
+                
46
+                <input type='hidden' name='counterOutcome' id='counterOutcome' value=1>
47
+                
48
+                <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
41
                     <span class='glyphicon glyphicon-plus'>
49
                     <span class='glyphicon glyphicon-plus'>
42
 
50
 
43
                     </span>
51
                     </span>
44
-                    Add another Objective
52
+                    Add another Outcome
45
                 </button>
53
                 </button>
46
 
54
 
47
                 <!-- Associated Program -->
55
                 <!-- Associated Program -->
92
                     {{ Form::textarea('notes', '', array('class' => 'form-control', 'rows'=>2, 'placeholder'=>'(optional)', 'aria-labelledby'=>'notes')) }}
100
                     {{ Form::textarea('notes', '', array('class' => 'form-control', 'rows'=>2, 'placeholder'=>'(optional)', 'aria-labelledby'=>'notes')) }}
93
                 </div>
101
                 </div>
94
 
102
 
95
-                {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
103
+                {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block', 'id'=>'create_the_criterion')) }}
96
                 {{ Form::close() }}
104
                 {{ Form::close() }}
97
             </div>
105
             </div>
98
         </div>
106
         </div>
104
                 Edit
112
                 Edit
105
             </div>
113
             </div>
106
             <div class="panel-body">
114
             <div class="panel-body">
107
-                {{ Form::open(array('action' => 'CriteriaController@update')) }}
115
+                {{ Form::open(array('action' => 'CriteriaController@update', 'id'=>'update_criterion')) }}
108
 
116
 
109
                 <button class="btn btn-md btn-secondary filterButton">
117
                 <button class="btn btn-md btn-secondary filterButton">
110
                     <span class="glyphicon glyphicon-plus">
118
                     <span class="glyphicon glyphicon-plus">
126
 
134
 
127
                 </div>
135
                 </div>
128
                 </div>
136
                 </div>
137
+                <hr>
129
 
138
 
130
                 <div class="form-group">
139
                 <div class="form-group">
131
                     {{ Form::label('criterion_id', 'Criterion') }}
140
                     {{ Form::label('criterion_id', 'Criterion') }}
144
                         @endforeach
153
                         @endforeach
145
                     </select>
154
                     </select>
146
                 </div>
155
                 </div>
147
-
156
+                <div id ='allAssocOutcomes'>
148
                 <!-- Associated Outcome -->
157
                 <!-- Associated Outcome -->
149
-                <div id='assocOutcomeGroup' data-value="1">
150
-                    <div class="form-group">
151
-                        <label>Associated Outcome</label>
152
-                        {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome_0', 'onchange'=>'fetchAssocObjective("assoc_outcome_0")']) }}
158
+                <div id='assocOutcomeGroup0' data-value="1">
159
+                    <div class="form-group col-md-12">
160
+                        <label>Outcome 1</label>
161
+                        {{ Form::select('outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome_0', 'onchange'=>'fetchAssocObjective("assoc_outcome_0")']) }}
153
 
162
 
154
                     </div>
163
                     </div>
155
-                </div>
156
-                <button id='button-add-objective-assoc' class='btn btn-md btn-secondary' onclick='addAssocOutcome()'>
157
-                    <span class='glyphicon glyphicon-plus'>
158
-
159
-                    </span>
160
-                    Add another Outcome
161
-                </button>
162
-
163
-                <div id='assoc_objectiveGroup' data-value="1">
164
-                    <div class="form-group">
165
-                        <label>Associated Objectives</label>
166
-                        <select id="assoc_objective_0" name="assoc_objective[]" class="form-control selectpicker">
164
+<div id='assoc_objectiveGroupFor0' data-value="1">
165
+                    <div class="form-group col-md-11">
166
+                        <label>Associated Objectives for Outcome 1</label>
167
+                        <select id="assoc_objective_0_counter_1" name="objective[]" class="form-control selectpicker">
167
                             <option value="0">No associated objectives</option>
168
                             <option value="0">No associated objectives</option>
168
                         </select>
169
                         </select>
169
 
170
 
170
-                    </div>
171
+                    </div> <div class ='col-md-1'></div>
171
                 </div>
172
                 </div>
172
-                <button id='button-add-outcome-assoc' class='btn btn-md btn-secondary' onclick='addAssocObjective()'>
173
+               
174
+
175
+               <button id='button-add-objective-assoc' class='btn btn-md btn-secondary' onclick='addAssocObjective("assoc_objectiveGroupFor0", "assoc_objective_0")'>
173
                     <span class='glyphicon glyphicon-plus'>
176
                     <span class='glyphicon glyphicon-plus'>
174
 
177
 
175
                     </span>
178
                     </span>
176
                     Add another Objective
179
                     Add another Objective
180
+                </button> </div><hr></div>
181
+                <button  class='btn btn-md btn-secondary button-add-outcome-assoc' onclick='addAssocOutcome()'>
182
+                    <span class='glyphicon glyphicon-plus'>
183
+
184
+                    </span>
185
+                    Add another Outcome
177
                 </button>
186
                 </button>
178
 
187
 
188
+                
189
+                
190
+
179
                 <!-- Associated Program -->
191
                 <!-- Associated Program -->
180
                 <div class="form-group">
192
                 <div class="form-group">
181
 
193
 
213
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'id' => 'criterion_subcriteria')) }}
225
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'id' => 'criterion_subcriteria')) }}
214
                 </div>
226
                 </div>
215
                 <div class="form-group">
227
                 <div class="form-group">
216
-                    {{ Form::label('assoc_maximum_score', 'Maximum Score') }}
217
-                    {{ Form::text('assoc_maximum_score', '', array('class' => 'form-control', 'id'=>'assoc_maximum_score', 'oninput'=>'addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales")')) }}
228
+                    {{ Form::label('maximum_score', 'Maximum Score') }}
229
+                    {{ Form::text('maximum_score', '', array('class' => 'form-control', 'id'=>'assoc_maximum_score', 'oninput'=>'addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales")')) }}
218
                 </div>
230
                 </div>
219
 
231
 
220
 
232
 
241
                     {{ Form::textarea('notes', Input::old('notes'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_notes', 'placeholder'=>'(optional)')) }}
253
                     {{ Form::textarea('notes', Input::old('notes'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_notes', 'placeholder'=>'(optional)')) }}
242
                 </div>
254
                 </div>
243
                
255
                
244
-                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
256
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block', 'id'=>'update_the_criterion')) }}
245
                 {{ Form::close() }}
257
                 {{ Form::close() }}
246
                 {{ Form::open(array('action' => 'CriteriaController@delete')) }}
258
                 {{ Form::open(array('action' => 'CriteriaController@delete')) }}
247
                 
259
                 
265
         numberOfScales('Num_scale', 'Scales');
277
         numberOfScales('Num_scale', 'Scales');
266
     });
278
     });
267
 
279
 
280
+    $(document).on('submit', '#create_criterion', function(e){
281
+
282
+        if(e.originalEvent.submitter.id != "create_the_criterion")
283
+        e.preventDefault();
284
+    })
285
+
286
+    $(document).on('submit', '#update_criterion', function(e){
287
+
288
+if(e.originalEvent.submitter.id != "update_the_criterion")
289
+e.preventDefault();
290
+})
291
+
292
+
268
     function addOptions(select, max, scaleDiv) {
293
     function addOptions(select, max, scaleDiv) {
269
 
294
 
270
         
295
         
297
 
322
 
298
             fullDiv = '';
323
             fullDiv = '';
299
         if(division ==1){
324
         if(division ==1){
300
-            for (var i = dataValue; i < amountOfScale; i++) {
325
+            for (var i = 0; i < amountOfScale; i++) {
301
                 div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
326
                 div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
302
                     '<div class ="form-group">' +
327
                     '<div class ="form-group">' +
303
                     '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(i+1)+')</label>' +
328
                     '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(i+1)+')</label>' +
304
-                    '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
329
+                    '<textarea id = "assoc_scale_'+i+'" class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="Scales[]" cols="50" ></textarea></div></div>';
305
                 fullDiv += div;
330
                 fullDiv += div;
306
 
331
 
307
 
332
 
311
             div = '<div id="assoc_eval' +0 + Scales + '">' +
336
             div = '<div id="assoc_eval' +0 + Scales + '">' +
312
                     '<div class ="form-group">' +
337
                     '<div class ="form-group">' +
313
                     '<label for ="assoc_descripcion' + 0 + '">Scale Description ('+1+' - '+maximum+') </label>' +
338
                     '<label for ="assoc_descripcion' + 0 + '">Scale Description ('+1+' - '+maximum+') </label>' +
314
-                    '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + 0 + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
339
+                    '<textarea id = "assoc_scale_'+0+'" class="form-control" rows="2" aria-labelledby="assoc_descripcion' + 0 + '" name="Scales[]" cols="50" ></textarea></div></div>';
315
                 fullDiv += div;
340
                 fullDiv += div;
316
         }
341
         }
317
         else{
342
         else{
320
             div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
345
             div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
321
                     '<div class ="form-group">' +
346
                     '<div class ="form-group">' +
322
                     '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(1+(i*division))+' - '+((1+i)*division)+')</label>' +
347
                     '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(1+(i*division))+' - '+((1+i)*division)+')</label>' +
323
-                    '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
348
+                    '<textarea  id = "assoc_scale_'+i+'" class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="Scales[]" cols="50" ></textarea></div></div>';
324
                 fullDiv += div;
349
                 fullDiv += div;
325
         }
350
         }
326
         }
351
         }
346
         var amountOfScale = parseInt($('#' + string).val());
371
         var amountOfScale = parseInt($('#' + string).val());
347
         var dataValue = parseInt($('#' + Scales).attr('data-value'));
372
         var dataValue = parseInt($('#' + Scales).attr('data-value'));
348
         var division = maximum/amountOfScale;
373
         var division = maximum/amountOfScale;
349
-        //add
350
-    
351
 
374
 
352
 
375
 
353
 
376
 
377
+        
378
+        //add
379
+    
380
+
354
             fullDiv = '';
381
             fullDiv = '';
355
             if(division ==1){
382
             if(division ==1){
356
                 for (var i = 0; i < amountOfScale; i++) {
383
                 for (var i = 0; i < amountOfScale; i++) {
403
 
430
 
404
     //Add outcome Button
431
     //Add outcome Button
405
     function addOutcomeTest() {
432
     function addOutcomeTest() {
406
-        counter = parseInt($('#outcomeGroup').data("value"));
433
+
434
+
435
+        counter = parseInt($('#outcomeGroup0').data("value"));
407
         var $select = $('<select/>', {
436
         var $select = $('<select/>', {
408
             'class': "selectpicker form-control",
437
             'class': "selectpicker form-control",
409
             'name': "outcome[]",
438
             'name': "outcome[]",
410
             'data-live-search': 'true',
439
             'data-live-search': 'true',
411
             'id': 'outcome' + counter.toString(),
440
             'id': 'outcome' + counter.toString(),
412
-            'onchange': 'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")'
441
+            'onchange': 'fetchObjectiveForSelect("outcome'+counter+'", "objectiveGroupFor'+counter+'")'
413
 
442
 
414
         });
443
         });
415
         var $div = $('<div/>', {
444
         var $div = $('<div/>', {
416
             'id': 'outcomeForm' + counter.toString(),
445
             'id': 'outcomeForm' + counter.toString(),
417
-            'class': 'form-group col-md-11'
446
+            'class': 'form-group col-md-11 '
418
         });
447
         });
419
 
448
 
420
         var $divForButton = $('<div/>', {
449
         var $divForButton = $('<div/>', {
425
         var $button = $('<button/>', {
454
         var $button = $('<button/>', {
426
             'type': 'button',
455
             'type': 'button',
427
             'class': 'btn btn-primary',
456
             'class': 'btn btn-primary',
428
-            'onclick': 'deleteLast("outcomeForm'+counter.toString()+'", "outcomeGroup", "close' + counter.toString() + '", "objectiveGroup")'
429
-   });
457
+            'onclick': '$(this).parent().parent().remove();'
458
+        });
459
+        var divForGroup = $('<div/>', {
460
+            'id' : 'outcomeGroup'+counter.toString(),
461
+        }).html("<label>Outcome "+(counter+1)+"</label>");
462
+        
463
+
464
+        var objectiveGroup = $('<div/>', {
465
+            'id' : 'objectiveGroupFor'+counter,
466
+            'data-value': '1'
467
+        });
468
+
469
+        var form_group_for_objective = $('<div/>', {
470
+            'class': 'form-group col-md-11'
471
+        }).html('<label>Associated Objectives for Outcome '+(counter+1)+'</label>'); 
472
+        
473
+        
474
+        var $select_objective = $('<select/>', {
475
+            'class': "selectpicker form-control",
476
+            'name': "objective[]",
477
+            'data-live-search': 'true',
478
+            'id': 'objective_'+counter +'_counter_1'  
479
+        });
480
+
481
+        var empty_div = $('<div/>',{
482
+            'class': 'col-md-1'
483
+        });
484
+
485
+        
486
+
487
+        var button_for_add = $('<button/>', {
488
+            'class': 'btn btn-md btn-secondary button-add-objective',
489
+            'onclick': 'addObjectiveTest("objectiveGroupFor'+counter+'", "objective_'+counter+'")'
490
+        }).html("<span class='glyphicon glyphicon-plus'></span>Add another Objective");
491
+        
492
+        
493
+        divForGroup.append($div)
430
 
494
 
431
         $button.append('X');
495
         $button.append('X');
432
         $divForButton.append($button);
496
         $divForButton.append($button);
433
-
434
-        $div.appendTo('#outcomeGroup')
497
+        
498
+       
499
+        $('#allOutcomes').append(divForGroup);
435
         $select.append(selectOptions);
500
         $select.append(selectOptions);
436
 
501
 
437
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
502
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
438
-        $('#outcomeGroup').data("value", (counter +1));
439
-        fetchObjectiveForSelect('outcomeGroup', "objectiveGroup");
440
-        counter += 1;
441
-        $divForButton.appendTo('#outcomeGroup');
503
+        $('#outcomeGroup0').data("value", (counter +1));
504
+        
505
+        
506
+        divForGroup.append($divForButton);
507
+
508
+        form_group_for_objective.append($select_objective)
509
+        objectiveGroup.append(form_group_for_objective);
510
+        objectiveGroup.append(empty_div);
511
+        //objectiveGroup.append(button_for_add);
512
+
513
+        divForGroup.append(objectiveGroup);
514
+        divForGroup.append(button_for_add);
515
+        divForGroup.append('<hr>');
516
+        fetchObjectiveForSelect('outcome'+counter, "objectiveGroupFor"+counter);
517
+        $select_objective.selectpicker('refresh');
518
+
442
 
519
 
443
         
520
         
444
 
521
 
466
         $div.remove();
543
         $div.remove();
467
         $div = document.getElementById(closeObj);
544
         $div = document.getElementById(closeObj);
468
         $div.remove();
545
         $div.remove();
469
-        counter = parseInt($('#'+objectiveGroup).data("value"));
470
-        $('#'+objectiveGroup).data("value", counter-1);
546
+        //counter = parseInt($('#'+objectiveGroup).data("value"));
547
+       // $('#'+objectiveGroup).data("value", counter-1);
471
 
548
 
472
 
549
 
473
     }
550
     }
474
 
551
 
475
     //Add objective when editing
552
     //Add objective when editing
476
 
553
 
477
-    function addAssocObjective() {
478
-        selectObj = document.getElementById('assoc_objective_0').innerHTML;
479
-        assocObjectiveCounter = parseInt($('#assoc_objectiveGroup').data('value'));
554
+    function addAssocObjective(objForGroup, originalObjective) {
555
+        counter = $("#"+objForGroup).data('value');
556
+
557
+        selectObj = document.getElementById(originalObjective+'_counter_1').innerHTML;
558
+        assocObjectiveCounter = parseInt($('#'+objForGroup).data('value'));
480
         var $select = $('<select/>', {
559
         var $select = $('<select/>', {
481
             'class': "selectpicker form-control",
560
             'class': "selectpicker form-control",
482
-            'name': "assoc_objective[]",
561
+            'name': "objective[]",
483
             'data-live-search': 'true',
562
             'data-live-search': 'true',
484
-            'id': 'assoc_objective_' + assocObjectiveCounter.toString(),
563
+            'id': originalObjective+'_counter_' + (assocObjectiveCounter+1).toString(),
485
 
564
 
486
 
565
 
487
         });
566
         });
488
         var $div = $('<div/>', {
567
         var $div = $('<div/>', {
489
-            'id': 'assoc_objectiveForm' + assocObjectiveCounter.toString(),
490
-            'class': 'form-group col-md-11'
568
+            'id': 'assoc_objectiveForm_'+objForGroup +'_' + assocObjectiveCounter.toString(),
569
+            'class': 'form-group col-md-10'
491
         });
570
         });
492
         var $divForButton = $('<div/>', {
571
         var $divForButton = $('<div/>', {
493
-            'class': 'col-md-1',
494
-            'id': 'assoc_closeObj' + assocObjectiveCounter.toString()
572
+            'class': 'col-md-2',
573
+            'id': 'assoc_closeObj_'+objForGroup+'_' + assocObjectiveCounter.toString()
495
 
574
 
496
         });
575
         });
497
         var $button = $('<button/>', {
576
         var $button = $('<button/>', {
498
             'type': 'button',
577
             'type': 'button',
499
             'class': 'btn btn-primary',
578
             'class': 'btn btn-primary',
500
-            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + ', "assoc_objectiveGroup")'
579
+            'onclick': 'deleteObjective("assoc_objectiveForm_'+objForGroup+'_' + assocObjectiveCounter.toString() + '", "assoc_closeObj_' +objForGroup+'_' + assocObjectiveCounter.toString() + '", "'+objForGroup+'")'
501
         });
580
         });
502
 
581
 
503
         $button.append('X');
582
         $button.append('X');
504
         $divForButton.append($button);
583
         $divForButton.append($button);
505
 
584
 
506
-        $div.appendTo('#assoc_objectiveGroup')
585
+        $div.appendTo('#'+objForGroup)
507
         $select.append(selectObj);
586
         $select.append(selectObj);
508
 
587
 
509
-        $select.appendTo('#assoc_objectiveForm' + assocObjectiveCounter.toString()).selectpicker('refresh');
510
-        $('#assoc_objectiveGroup').data("value", assocObjectiveCounter +1);
588
+        $select.appendTo($div).selectpicker('refresh');
589
+        //$('#assoc_objectiveGroup').data("value", assocObjectiveCounter +1);
511
 
590
 
512
-        $divForButton.appendTo('#assoc_objectiveGroup');
591
+        $divForButton.appendTo('#'+objForGroup);
592
+        $('#'+ objForGroup).data('value', counter +1);
513
 
593
 
514
     }
594
     }
515
 
595
 
516
 
596
 
517
     //Add objective when creating a criteria
597
     //Add objective when creating a criteria
518
-    function addObjectiveTest() {
519
-        selectObj = document.getElementById('objective_0').innerHTML;
520
-        counter = parseInt($("#objectiveGroup").data('value'));
598
+    function addObjectiveTest(objForGroup, originalObjective) {
599
+
600
+        counter  =$('#'+objForGroup).data('value');
601
+
602
+        selectObj = document.getElementById(originalObjective+'_counter_1').innerHTML;
603
+
521
         var $select = $('<select/>', {
604
         var $select = $('<select/>', {
522
             'class': "selectpicker form-control",
605
             'class': "selectpicker form-control",
523
             'name': "objective[]",
606
             'name': "objective[]",
524
             'data-live-search': 'true',
607
             'data-live-search': 'true',
525
-            'id': 'objective_' + counter.toString()
526
-
608
+            'id': originalObjective +'_counter_' + (counter+1).toString()
527
         });
609
         });
528
         var $div = $('<div/>', {
610
         var $div = $('<div/>', {
529
-            'id': 'objectiveForm' + counter.toString(),
530
-            'class': 'form-group col-md-11'
611
+            'id': 'objectiveForm_'+objForGroup + '_' + counter.toString(),
612
+            'class': 'form-group col-md-10'
531
         });
613
         });
532
         var $divForButton = $('<div/>', {
614
         var $divForButton = $('<div/>', {
533
-            'class': 'col-md-1',
534
-            'id': 'closeObj' + counter.toString()
615
+            'class': 'col-md-2',
616
+            'id': 'closeObj_'+objForGroup+'_' + counter.toString()
535
 
617
 
536
         });
618
         });
537
         var $button = $('<button/>', {
619
         var $button = $('<button/>', {
538
             'type': 'button',
620
             'type': 'button',
539
             'class': 'btn btn-primary',
621
             'class': 'btn btn-primary',
540
-            'onclick': 'deleteObjective("objectiveForm' + counter.toString() + '", "closeObj' + counter.toString() + '")'
622
+            'onclick': 'deleteObjective("objectiveForm_' +objForGroup +'_' + counter.toString() + '", "closeObj_'+objForGroup+'_' + counter.toString() + '", "'+objForGroup+'")'
541
         });
623
         });
542
 
624
 
543
         $button.append('X');
625
         $button.append('X');
544
         $divForButton.append($button);
626
         $divForButton.append($button);
545
 
627
 
546
-        $div.appendTo('#objectiveGroup')
628
+        $div.appendTo('#'+objForGroup)
547
         $select.append(selectObj);
629
         $select.append(selectObj);
548
 
630
 
549
-        $select.appendTo('#objectiveForm' + counter.toString()).selectpicker('refresh');
631
+        $select.appendTo($div).selectpicker('refresh');
550
         
632
         
551
 
633
 
552
-        $divForButton.appendTo('#objectiveGroup');
553
-        $('#objectiveGroup').data('value', counter +1);
634
+        $divForButton.appendTo('#'+objForGroup);
635
+        $('#'+ objForGroup).data('value', counter +1);
554
     }
636
     }
555
 
637
 
556
     //Create outcome for editing
638
     //Create outcome for editing
558
     var assocOutcomeCounter = 0;
640
     var assocOutcomeCounter = 0;
559
 
641
 
560
 
642
 
561
-    function addAssocOutcome() {
562
-        assocOutcomeCounter = parseInt($('#assocOutcomeGroup').data('value'));
643
+    function addAssocOutcome(depends= null) {
644
+        assocOutcomeCounter = parseInt($('#assocOutcomeGroup0').data('value'));
563
         var $select = $('<select/>', {
645
         var $select = $('<select/>', {
564
             'class': "selectpicker form-control",
646
             'class': "selectpicker form-control",
565
-            'name': "assoc_outcome[]",
647
+            'name': "outcome[]",
566
             'data-live-search': 'true',
648
             'data-live-search': 'true',
567
             'id': 'assoc_outcome_' + assocOutcomeCounter.toString(),
649
             'id': 'assoc_outcome_' + assocOutcomeCounter.toString(),
568
-            'onchange': 'fetchAssocObjective("assoc_outcome_' + assocOutcomeCounter.toString() + '")'
650
+            'onchange': 'fetchAssocObjective("assoc_outcome_' + assocOutcomeCounter.toString() + '", "assoc_objectiveGroupFor'+assocOutcomeCounter+'")'
569
 
651
 
570
         });
652
         });
571
         var $div = $('<div/>', {
653
         var $div = $('<div/>', {
581
         var $button = $('<button/>', {
663
         var $button = $('<button/>', {
582
             'type': 'button',
664
             'type': 'button',
583
             'class': 'btn btn-primary',
665
             'class': 'btn btn-primary',
584
-            'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "assocOutcomeGroup", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objectiveGroup")'
666
+            'id': 'assoc_close_button'+assocOutcomeCounter,
667
+            'onclick': '$(this).parent().parent().remove()'
585
          });
668
          });
586
 
669
 
670
+        var divForGroup = $('<div/>', {
671
+            'id' : 'assocOutcomeGroup'+assocOutcomeCounter.toString(),
672
+        }).html("<label>Outcome "+(assocOutcomeCounter+1)+"</label>");
673
+
674
+        var objectiveGroup = $('<div/>', {
675
+            'id' : 'assoc_objectiveGroupFor'+assocOutcomeCounter,
676
+            'data-value': '1'
677
+        });
678
+        var form_group_for_objective = $('<div/>', {
679
+            'class': 'form-group col-md-11'
680
+        }).html('<label>Associated Objectives for Outcome '+(assocOutcomeCounter+1)+'</label>'); 
681
+        
682
+        var $select_objective = $('<select/>', {
683
+            'class': "selectpicker form-control",
684
+            'name': "objective[]",
685
+            'data-live-search': 'true',
686
+            'id': 'assoc_objective_'+assocOutcomeCounter +'_counter_1'  
687
+        });
688
+
689
+        var empty_div = $('<div/>',{
690
+            'class': 'col-md-1'
691
+        });
692
+
693
+        var button_for_add = $('<button/>', {
694
+            'class': 'btn btn-md btn-secondary button-add-objective',
695
+            'onclick': 'addAssocObjective("assoc_objectiveGroupFor'+assocOutcomeCounter+'", "assoc_objective_'+assocOutcomeCounter+'")'
696
+        }).html("<span class='glyphicon glyphicon-plus'></span>Add another Objective");
697
+        
698
+        divForGroup.append($div)
587
         $button.append('X');
699
         $button.append('X');
588
         $divForButton.append($button);
700
         $divForButton.append($button);
589
 
701
 
590
-        $div.appendTo('#assocOutcomeGroup')
702
+        $('#allAssocOutcomes').append(divForGroup);
703
+        
704
+
705
+        //$div.appendTo('#assocOutcomeGroup')
591
         $select.append(selectOptions);
706
         $select.append(selectOptions);
592
 
707
 
593
         $select.appendTo('#assoc_outcomeForm' + assocOutcomeCounter.toString()).selectpicker('refresh');
708
         $select.appendTo('#assoc_outcomeForm' + assocOutcomeCounter.toString()).selectpicker('refresh');
594
-         assocOutcomeCounter += 1;
595
-        $divForButton.appendTo('#assocOutcomeGroup');
709
+        //assocOutcomeCounter += 1;
710
+        $('#assocOutcomeGroup0').data('value', assocOutcomeCounter+1);
711
+        //$divForButton.appendTo('#assocOutcomeGroup');
712
+        divForGroup.append($divForButton);
713
+
714
+        form_group_for_objective.append($select_objective)
715
+        objectiveGroup.append(form_group_for_objective);
716
+        objectiveGroup.append(empty_div);
717
+        //objectiveGroup.append(button_for_add);
718
+
719
+        divForGroup.append(objectiveGroup);
720
+        divForGroup.append(button_for_add);
721
+        divForGroup.append('<hr>');
722
+        if(!depends)fetchObjectiveForSelect('assoc_outcome_'+assocOutcomeCounter, 'assoc_objectiveGroupFor'+assocOutcomeCounter);
723
+        $select_objective.selectpicker('refresh');
724
+
596
 
725
 
597
-        $('#assocOutcomeGroup').data('value', assocOutcomeCounter);
726
+       
598
 
727
 
599
 
728
 
600
     }
729
     }
673
     //Fetch objective at creating criteria
802
     //Fetch objective at creating criteria
674
     counterForPost = 0;
803
     counterForPost = 0;
675
 
804
 
676
-    function fetchObjectiveForSelect(outcomeDiv, objectiveGroup) {
677
-        var count = $("#" + outcomeDiv).data('value');
678
-        var allOutcomes = [];
679
-        $("#" + outcomeDiv + ' select').each(function() {
680
-            allOutcomes.push( this.value);
805
+    
681
 
806
 
682
-        })
807
+    function fetchObjectiveForSelect(outcome, objectiveGroup) {
808
+        outcomeID = $('#'+outcome).val();
683
         var allObjectives = [];
809
         var allObjectives = [];
684
         $("#" + objectiveGroup + ' select').each(function() {
810
         $("#" + objectiveGroup + ' select').each(function() {
685
             var temp = {
811
             var temp = {
691
 
817
 
692
         $.post(
818
         $.post(
693
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
819
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
694
-                allOutcomes: allOutcomes
820
+                outcomeID: outcomeID
695
             },
821
             },
696
             function(varArray) {
822
             function(varArray) {
697
                 counterOutcome =0;
823
                 counterOutcome =0;
698
                 optionName = '<option value ="0">Nothing Selected</option>';
824
                 optionName = '<option value ="0">Nothing Selected</option>';
825
+                for(index in varArray){
826
+                    objectiveObject = varArray[index];
827
+                    optionName += '<option value ="('+objectiveObject.outcome_id+','+objectiveObject.objective_id+')">'+
828
+                        objectiveObject.text+'</option>';
829
+
830
+                }
831
+                /*
699
                 for(outcome in varArray.outcomes){
832
                 for(outcome in varArray.outcomes){
700
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
833
                     optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
701
                     var objectiveForOutcome = varArray.objectives;
834
                     var objectiveForOutcome = varArray.objectives;
708
                         optionName += (option);
841
                         optionName += (option);
709
                     }
842
                     }
710
                     optionName += "</optgroup>";
843
                     optionName += "</optgroup>";
711
-                }
844
+                }*/
712
                 
845
                 
713
-
846
+                for(index in allObjectives){
847
+                    
848
+                    id = allObjectives[index].id
849
+                    $('#'+id).html(optionName);
850
+                    $('#'+id).selectpicker('refresh');
851
+                }
714
                 
852
                 
715
 
853
 
716
-                $('#objective_0').html(optionName);
854
+                /*$('#objective_0').html(optionName);
717
                 $('#objective_0').selectpicker('refresh');
855
                 $('#objective_0').selectpicker('refresh');
718
                 if($("#objective_0 option[value='"+allObjectives[0].value+"']").length>0){
856
                 if($("#objective_0 option[value='"+allObjectives[0].value+"']").length>0){
719
                     $("#objective_0").val(allObjectives[0].value);
857
                     $("#objective_0").val(allObjectives[0].value);
731
                     $("#objective_"+i.toString()).val(allObjectives[i].value);
869
                     $("#objective_"+i.toString()).val(allObjectives[i].value);
732
                     $("#objective_"+i.toString()).selectpicker("refresh");
870
                     $("#objective_"+i.toString()).selectpicker("refresh");
733
                 }
871
                 }
734
-                }
872
+                }*/
735
 
873
 
736
                 
874
                 
737
 
875
 
794
 
932
 
795
                 if (!(json.activity_criterion.length)) {
933
                 if (!(json.activity_criterion.length)) {
796
 
934
 
797
-$('#DeleteButton').prop('enabled', true);
935
+                    $('#DeleteButton').prop('disabled', false);
936
+                    $("#update_the_criterion").val('Update');
937
+                    $("#update_criterion").attr('action', "{{ URL::action('CriteriaController@update')}}")
798
 
938
 
799
-} else {
800
-$('#DeleteButton').prop('disabled', true);
801
-}
939
+                } else {
940
+                    $('#DeleteButton').prop('disabled', true);
941
+                    $("#update_the_criterion").val("Create New")
942
+                    $("#update_criterion").attr('action', "{{ URL::action('CriteriaController@create')}}")
943
+                    alert("The criterion is already used in assessments. Editting the criterion will actually create a new criterion");
944
+
945
+                    }
802
 
946
 
803
                 if (!(json.criteria.length)) {
947
                 if (!(json.criteria.length)) {
804
                     name = ' ';
948
                     name = ' ';
832
                         $('#status').val(0);
976
                         $('#status').val(0);
833
                     else
977
                     else
834
                         $('#status').val(1);
978
                         $('#status').val(1);
835
-                    $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
836
-                    var maximum = json.criteria[0].maximum_score;
979
+                    $('#assoc_maximum_score').val(json.criteria[0].max_score);
980
+                    var maximum = json.criteria[0].max_score;
981
+
982
+                    addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales");
983
+                    $('#Num_assoc_scale').val(json.criteria[0].num_scales)
984
+                    $('#Num_assoc_scale').selectpicker('refresh');
985
+                    $('#Num_assoc_scale').trigger('change');
986
+
987
+                    for(i=0; i<json.criteria[0].num_scales;i++){
988
+                        $('#assoc_scale_'+i).val(json.scales[i].description);
989
+                    }
990
+
991
+
837
 
992
 
838
                     // If copyright or notes aren't empty, load them
993
                     // If copyright or notes aren't empty, load them
839
 
994
 
854
 
1009
 
855
                 // Select associated outcome
1010
                 // Select associated outcome
856
                 try {
1011
                 try {
857
-                    assocOutcomeCounter= parseInt($("#assocOutcomeGroup").data('value'));
1012
+                    assocOutcomeCounter= parseInt($("#assocOutcomeGroup0").data('value'));
858
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
1013
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
859
-                        deleteLast("assoc_outcomeForm" + i.toString() , "assocOutcomeGroup", "assoc_close" + i.toString() ,"assoc_objectiveGroup");
1014
+                        $('#assoc_close_button'+i).click();
860
                                }
1015
                                }
1016
+                    $('#assocOutcomeGroup0').data('value', 1);
861
                 } catch (err) {
1017
                 } catch (err) {
862
                     var Notran = true;
1018
                     var Notran = true;
863
                 }
1019
                 }
865
                 if (json.outcomes.length) {
1021
                 if (json.outcomes.length) {
866
                     $('#assoc_outcome_0').val(json.outcomes[0].id);
1022
                     $('#assoc_outcome_0').val(json.outcomes[0].id);
867
                     $('#assoc_outcome_0').selectpicker('refresh');
1023
                     $('#assoc_outcome_0').selectpicker('refresh');
1024
+
1025
+                    var first_outcome_id = json.outcomes[0].id;
1026
+                    options = "<option value ='0'>Nothing Selected</option>";
1027
+
1028
+                    for(objective_index  in json.objectives_assoc[first_outcome_id]){
1029
+                        objective = json.objectives_assoc[first_outcome_id][objective_index]
1030
+                        options += '<option value ="('+first_outcome_id+','+objective.objective_id+')">'+
1031
+                            objective.text+'</option>';
1032
+                    }
1033
+                    $('#assoc_objective_0_counter_1').html(options);
1034
+                    $('#assoc_objective_0_counter_1').selectpicker('refresh');
1035
+                    
1036
+                    if(json.objectives[first_outcome_id].length){
1037
+                        objective_id = json.objectives[first_outcome_id][0].objective_id;
1038
+                    value = '('+first_outcome_id+','+objective_id+')';
1039
+                    $('#assoc_objective_0_counter_1').val(value);
1040
+                    $('#assoc_objective_0_counter_1').selectpicker('refresh');
1041
+
1042
+                    }
1043
+                    
1044
+
1045
+                    for(var i =1; i<json.objectives[first_outcome_id].length; i++ ){
1046
+                        addAssocObjective("assoc_objectiveGroupFor0", "assoc_objective_0");
1047
+                        objective_id = json.objectives[first_outcome_id][i].objective_id;
1048
+                        value = "("+first_outcome_id+","+objective_id+")";
1049
+                        $('#assoc_objective_0_counter_'+(i+1)).val(value);
1050
+                        $('#assoc_objective_0_counter_'+(i+1)).selectpicker('refresh');
1051
+                        
1052
+
1053
+
1054
+                    }
1055
+                    
868
                 } else {
1056
                 } else {
869
                     $('#assoc_outcome_0').val($('#assoc_outcomes_fetch').find(':selected').val());
1057
                     $('#assoc_outcome_0').val($('#assoc_outcomes_fetch').find(':selected').val());
870
                     $('#assoc_outcome_0').selectpicker('refresh');
1058
                     $('#assoc_outcome_0').selectpicker('refresh');
1059
+
871
                 }
1060
                 }
872
 
1061
 
873
 
1062
 
874
 
1063
 
875
                 for (var i = 1; i < json.outcomes.length; i++) {
1064
                 for (var i = 1; i < json.outcomes.length; i++) {
876
-                    addAssocOutcome();
1065
+                    addAssocOutcome(true);
1066
+
1067
+
877
                     $('#assoc_outcome_' + i.toString()).val(json.outcomes[i].id);
1068
                     $('#assoc_outcome_' + i.toString()).val(json.outcomes[i].id);
878
                     $('#assoc_outcome_' + i.toString()).selectpicker('refresh');
1069
                     $('#assoc_outcome_' + i.toString()).selectpicker('refresh');
879
 
1070
 
1071
+                    var outcome_id = json.outcomes[i].id;
1072
+                    options = "<option value ='0'>Nothing Selected</option>";
1073
+
1074
+                    for(objective_index  in json.objectives_assoc[outcome_id]){
1075
+                        objective = json.objectives_assoc[outcome_id][objective_index]
1076
+                        options += '<option value ="('+outcome_id+','+objective.objective_id+')">'+
1077
+                            objective.text+'</option>';
1078
+                    }
1079
+                    $('#assoc_objective_'+i+'_counter_1').html(options);
1080
+                    $('#assoc_objective_'+i+'_counter_1').selectpicker('refresh');
1081
+                    if(json.objectives[outcome_id].length){
1082
+                        objective_id = json.objectives[outcome_id][0].objective_id;
1083
+                        value = "("+outcome_id+","+objective_id+")"
1084
+                    $('#assoc_objective_'+i+'_counter_1').val(value);
1085
+                    $('#assoc_objective_'+i+'_counter_1').selectpicker('refresh')
1086
+                    }
1087
+                    
1088
+
1089
+                    for(var j =1; i<json.objectives[outcome_id].length; i++ ){
1090
+                        addAssocObjective("assoc_objectiveGroupFor"+i, "assoc_objective_"+i);
1091
+                        objective_id = json.objectives[outcome_id][j].objective_id;
1092
+                        value = "("+outcome_id+","+objective_id+")";
1093
+                        $('#assoc_objective_'+i+'_counter_'+(j+1)).val(value);
1094
+                        $('#assoc_objective_'+i+'_counter_'+(j+1)).selectpicker('refresh');
1095
+                        
1096
+
1097
+                    }
1098
+
880
                 }
1099
                 }
881
 
1100
 
882
-                counterObj =$('#assoc_objectiveGroup').data('value');
1101
+                
883
 
1102
 
884
 
1103
 
885
-                try {
1104
+                /*try {
886
                     for (var i = counterObj - 1; i > 0; i--) {
1105
                     for (var i = counterObj - 1; i > 0; i--) {
887
                         deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup')
1106
                         deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup')
888
                     }
1107
                     }
889
                 } catch (err) {
1108
                 } catch (err) {
890
                     var noEntro = true;
1109
                     var noEntro = true;
891
-                }
892
-                $('#assoc_objectiveGroup').data('value', 1);
1110
+                }*/
893
 
1111
 
894
 
1112
 
1113
+                //$('#assoc_objectiveGroup').data('value', 1);
1114
+                //counterObj =$('#assoc_objectiveGroup').data('value');
895
 
1115
 
896
 
1116
 
897
 
1117
 
1118
+
1119
+        /*
898
                 assocOutcomeCounter = 0;
1120
                 assocOutcomeCounter = 0;
899
                 var i = 0;
1121
                 var i = 0;
900
                 optionName = '<option value ="0">Nothing Selected</option>';
1122
                 optionName = '<option value ="0">Nothing Selected</option>';
945
                 
1167
                 
946
 
1168
 
947
 
1169
 
948
-
1170
+        */
949
 
1171
 
950
 
1172
 
951
 
1173
 
977
 $('#outcome-display').parent().hide();
1199
 $('#outcome-display').parent().hide();
978
 
1200
 
979
 fetchCriterionForEditing();
1201
 fetchCriterionForEditing();
980
-fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
1202
+fetchObjectiveForSelect('outcome0', 'objectiveGroupFor0');
981
 // setCriterionStatus();
1203
 // setCriterionStatus();
982
 
1204
 
983
 
1205
 
1000
     
1222
     
1001
     return false;
1223
     return false;
1002
     });
1224
     });
1003
-$('#button-add-objective-assoc').on('click', function(e) {
1225
+$('.button-add-objective-assoc').on('click', function(e) {
1004
 // Prevent the default action of the clicked item. In this case that is submit
1226
 // Prevent the default action of the clicked item. In this case that is submit
1005
 e.preventDefault();
1227
 e.preventDefault();
1006
 
1228
 
1014
 
1236
 
1015
 return false;
1237
 return false;
1016
 });
1238
 });
1017
-$('#button-add-objective').on('click', function(e) {
1239
+$('.button-add-objective').on('click', function(e) {
1018
 // Prevent the default action of the clicked item. In this case that is submit
1240
 // Prevent the default action of the clicked item. In this case that is submit
1019
 e.preventDefault();
1241
 e.preventDefault();
1020
 
1242
 

+ 0
- 1275
app/views/local/managers/pCoords/new_criteria.blade.php
File diff suppressed because it is too large
View File


+ 573
- 220
app/views/local/managers/sCoords/criteria.blade.php
File diff suppressed because it is too large
View File


+ 68
- 60
app/views/local/managers/shared/rubrics.blade.php View File

203
                 </div>
203
                 </div>
204
                 <div class="form-group">
204
                 <div class="form-group">
205
                     <label>Select an Objective</label>
205
                     <label>Select an Objective</label>
206
-                    <select id="select-objective" class="form-control selectpicker" onchange="fetchCriteria($('#select-outcome'), this)">
206
+                    <select id="select-objective" class="form-control selectpicker" onchange="fetchCriteria($('#select-outcome'), $(this))">
207
                         
207
                         
208
                     </select>
208
                     </select>
209
                 </div>
209
                 </div>
224
                 </div>
224
                 </div>
225
                 <div class="form-group">
225
                 <div class="form-group">
226
                     <label>Select the Type of Rubric</label>
226
                     <label>Select the Type of Rubric</label>
227
-                <select id="number_of_scales" class="form-control selectpicker">
227
+                <select id="number_of_scales" class="form-control selectpicker" onchange ="fetchCriteria($('#select-outcome'), $('#select-objective'))">
228
                     @for($i = 1; $i <= 20; $i++)
228
                     @for($i = 1; $i <= 20; $i++)
229
                     @if(8%$i == 0)
229
                     @if(8%$i == 0)
230
                     @if($i==1)
230
                     @if($i==1)
275
     <div class="col-md-12">
275
     <div class="col-md-12">
276
         <table class="table table-striped table-condensed" style="table-layout: fixed">
276
         <table class="table table-striped table-condensed" style="table-layout: fixed">
277
             <thead id="theHead"><tr><th colspan="7 "><input id="rubric-name" type="text" class="form-control input-lg" placeholder="Rubric Name"></th></tr></thead>
277
             <thead id="theHead"><tr><th colspan="7 "><input id="rubric-name" type="text" class="form-control input-lg" placeholder="Rubric Name"></th></tr></thead>
278
+            <thead id = "theScaleTitles">
279
+
280
+            </thead>
278
             <thead>
281
             <thead>
279
                 <tr id ="criterion-header">
282
                 <tr id ="criterion-header">
280
                     <th></th>
283
                     <th></th>
287
 
290
 
288
         <div id="copyright-info">
291
         <div id="copyright-info">
289
             <hr>
292
             <hr>
290
-            <p class="small"><strong>Outcomes Evaluated</strong></p>
293
+            <p class="small"><strong>Copyright</strong></p>
291
             <ul id="copyright-list" class="list-unstyled small">
294
             <ul id="copyright-list" class="list-unstyled small">
292
             </ul>
295
             </ul>
293
             <hr>
296
             <hr>
340
 // Fetch criteria associated to a specific learning outcome
343
 // Fetch criteria associated to a specific learning outcome
341
 function fetchCriteria(outcome, objective)
344
 function fetchCriteria(outcome, objective)
342
 {
345
 {
346
+    amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
347
+            
348
+    maximum = parseInt($('#max_score').find(":selected").val());
343
     $.post
349
     $.post
344
     (
350
     (
345
         "{{ URL::route('fetchCriteria') }}",
351
         "{{ URL::route('fetchCriteria') }}",
346
         {
352
         {
347
-            id: outcome.find(':selected').data('outcome-id'),
353
+            outcome_id: outcome.find(':selected').data('outcome-id'),
354
+            objective_id: objective.find(':selected').val(),
355
+            num_scales: amount_of_scales,
356
+            maximum: maximum,
348
             filter: $('input[name=criteria-filter]:checked').val()
357
             filter: $('input[name=criteria-filter]:checked').val()
349
         },
358
         },
350
         function(data)
359
         function(data)
427
     (
436
     (
428
         "{{ URL::route('fetchCriterionWithTemplate') }}",
437
         "{{ URL::route('fetchCriterionWithTemplate') }}",
429
         { id: id,
438
         { id: id,
430
-        numberOfScale: numberOfScale },
439
+         },
431
         function(data)
440
         function(data)
432
         {
441
         {
433
             // Append the fetched data
442
             // Append the fetched data
434
             copyright = null;
443
             copyright = null;
435
             notes = null;
444
             notes = null;
436
-            if(data.crit_info.length){
437
-                copyright = data.crit_info[0].copyright;
438
-                notes = data.crit_info[0].notes;
445
+            if(data.criterion.copyright){
446
+                copyright = data.criterion.copyright;
447
+            }
448
+            if(data.criterion.notes){
449
+                notes = data.criterion.notes;
439
             }
450
             }
440
             
451
             
441
             
452
             
462
                 str+='<span>'+data.criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
473
                 str+='<span>'+data.criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
463
             }
474
             }
464
             numberOfScale = $('#number_of_scales').find(':selected').val();
475
             numberOfScale = $('#number_of_scales').find(':selected').val();
465
-            if(data.scales.length)
476
+            
466
             for(i=0; i<numberOfScale; i++){
477
             for(i=0; i<numberOfScale; i++){
467
-                str+='<td class="editable" data-type="textarea">'+data.scales[i].description+'</td>';
478
+                str+='<td>'+data.scales[i].description+'</td>';
468
                 
479
                 
469
           
480
           
470
             }
481
             }
471
-            else{
472
-                for(i=0; i<numberOfScale; i++){
473
-                str+='<td class="editable" data-type="textarea"></td>';
474
-            }
475
-        }
482
+           
483
+        
476
         str+= '<td>'+data.outcomes+'</td>'
484
         str+= '<td>'+data.outcomes+'</td>'
477
         
485
         
478
 
486
 
540
     {
548
     {
541
         var criterion = $(this);
549
         var criterion = $(this);
542
         // If there's copyright info
550
         // If there's copyright info
543
-        if(criterion.data('copyright')!=null){
544
-            var copyright = criterion.data('copyright');
551
+        if(criterion.data('criterion-copyright')!=null){
552
+            var copyright = criterion.data('criterion-copyright');
545
             if($('#copyright-list li').length>0)
553
             if($('#copyright-list li').length>0)
546
             {
554
             {
547
                 var found = false;
555
                 var found = false;
661
     $('#expected_percentage').selectpicker('refresh');
669
     $('#expected_percentage').selectpicker('refresh');
662
     $('#expected_points').selectpicker('refresh');
670
     $('#expected_points').selectpicker('refresh');
663
     $('#number_of_scales').selectpicker('refresh');
671
     $('#number_of_scales').selectpicker('refresh');
672
+    $('#select-objective').selectpicker('refresh');
664
 }
673
 }
665
 
674
 
666
 // Fetch programs associated to a specific school
675
 // Fetch programs associated to a specific school
774
                 }
783
                 }
775
                 str+= '</td>';
784
                 str+= '</td>';
776
                 
785
                 
777
-                for(scaleIndex in data.scales[current_criterion.id]){
786
+                for(scaleIndex in current_criterion.scales){
778
 
787
 
779
-                    scale = data.scales[current_criterion.id][scaleIndex];
788
+                    scale = current_criterion.scales[scaleIndex];
780
 
789
 
781
-                    str+='<td class="editable" data-id-value ="'+scale.scale_id+'" data-type="textarea">'+scale.description+'</td>';
790
+                    str+='<td>'+scale.description+'</td>';
782
 
791
 
783
                 }
792
                 }
784
-                copyright = temp_criterion[temp_c].copyright;
785
-                notes = temp_criterion[temp_c].notes;
786
-                if(copyright == null){
787
-                    copyright = '';
788
-                }
789
-                if(notes==null) notes ='';
790
-                str += '<td class = "editable" data-type = "textarea">'+copyright+'</td>';
791
-                str+= '<td class = "editable" data-type = "textarea">'+notes+'</td>';
793
+                str+= '<td>'+current_criterion.outcomes+'</td>'
794
+  
792
                 str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
795
                 str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
793
 
796
 
794
     $('table tbody').append(str);
797
     $('table tbody').append(str);
812
 
815
 
813
             
816
             
814
             }
817
             }
818
+
815
             /*
819
             /*
816
             var contents = JSON.parse(data.contents);
820
             var contents = JSON.parse(data.contents);
817
             contents.forEach(function (data)
821
             contents.forEach(function (data)
877
             // Build Copyright List
881
             // Build Copyright List
878
             buildCopyrightList();
882
             buildCopyrightList();
879
 
883
 
884
+            $('.editable').each(function (index){
885
+                $(this).text(data.titles[index].text);
886
+            })
887
+            
880
             var selected = $('#select-template').find(':selected');
888
             var selected = $('#select-template').find(':selected');
881
-        var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
889
+            var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
882
         
890
         
883
-        var template_program = selected.data('template-program-id');
884
-      
891
+            var template_program = selected.data('template-program-id');
885
         
892
         
886
-
887
         if(
893
         if(
888
             {{ Auth::user()->role }}==1
894
             {{ Auth::user()->role }}==1
889
             || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
895
             || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
948
 
954
 
949
 }
955
 }
950
 
956
 
957
+fetchObjective($('#select-outcome'));
951
 // --------------------------------------------------------------------------
958
 // --------------------------------------------------------------------------
952
 // Events
959
 // Events
953
 // --------------------------------------------------------------------------
960
 // --------------------------------------------------------------------------
1037
             
1044
             
1038
            
1045
            
1039
             newScaleHeaders = '<th></th><th>Criterion</th>';
1046
             newScaleHeaders = '<th></th><th>Criterion</th>';
1047
+            editableTitles = '<th></th><th></th>';
1040
             counter = 0;
1048
             counter = 0;
1041
             division = maximum/amount_of_scales;
1049
             division = maximum/amount_of_scales;
1042
             if(amount_of_scales==1){
1050
             if(amount_of_scales==1){
1043
-                newScaleHeaders+= "<th class = 'editable' data-type = 'textarea'>Score (1 - "+maximum+")</th>";
1051
+                newScaleHeaders+= "<th>Score (1 - "+maximum+")</th>";
1052
+                editableTitles += "<th  class = 'editable' data-type = 'textarea'>Click to edit Title </th>"
1044
             }
1053
             }
1045
             else if(maximum!= amount_of_scales){
1054
             else if(maximum!= amount_of_scales){
1046
             while(counter <amount_of_scales){
1055
             while(counter <amount_of_scales){
1047
                 
1056
                 
1048
                 minimumScore = 1+(counter*division);
1057
                 minimumScore = 1+(counter*division);
1049
                 maximumScore = (1+counter)*division;
1058
                 maximumScore = (1+counter)*division;
1050
-                newScaleHeaders+= "<th class = 'editable' data-type = 'textarea'>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
1059
+                newScaleHeaders+= "<th>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
1060
+                editableTitles+="<th  class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
1051
                 counter++;
1061
                 counter++;
1052
             }
1062
             }
1053
             }else{
1063
             }else{
1055
                 
1065
                 
1056
        
1066
        
1057
                 newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
1067
                 newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
1068
+                editableTitles+="<th  class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
1069
+              
1058
                 counter++;
1070
                 counter++;
1059
             }
1071
             }
1060
             }
1072
             }
1061
             newScaleHeaders += '<th>Outcomes</th><th></th>';
1073
             newScaleHeaders += '<th>Outcomes</th><th></th>';
1062
-            
1074
+            editableTitles += '<th></th><th></th>';
1075
+
1076
+
1077
+            $('#theScaleTitles').html(editableTitles);
1063
             $("#criterion-header").html(newScaleHeaders);
1078
             $("#criterion-header").html(newScaleHeaders);
1064
             $('#allCriteria').html(' ');
1079
             $('#allCriteria').html(' ');
1065
 }
1080
 }
1099
     $('#expected_points').val(expected_points);
1114
     $('#expected_points').val(expected_points);
1100
     refreshSelects();
1115
     refreshSelects();
1101
     changeTable();
1116
     changeTable();
1117
+    fetchCriteria($('#select-outcome'), $('#select-objective'))
1102
 })
1118
 })
1103
 $('#number_of_scales').on('change', function(){
1119
 $('#number_of_scales').on('change', function(){
1104
     changeTable();
1120
     changeTable();
1165
     var criteriaArray = new Array();
1181
     var criteriaArray = new Array();
1166
 
1182
 
1167
     var criteria = [];
1183
     var criteria = [];
1168
-    scales = [];
1169
-    scalesMaxArray =[];
1170
-    scalesMinArray =[];
1171
-    scales_id =[];
1172
-    copyright = [];
1173
-    notes = [];
1184
+    var titles = [];
1174
 
1185
 
1175
     
1186
     
1176
     var amount_of_scales =parseInt($('#number_of_scales').find(':selected').val())+2;
1187
     var amount_of_scales =parseInt($('#number_of_scales').find(':selected').val())+2;
1179
     $('tbody tr').each(function( index )
1190
     $('tbody tr').each(function( index )
1180
     {
1191
     {
1181
             criteria.push($(this).data('criterion-id'));
1192
             criteria.push($(this).data('criterion-id'));
1182
-            each_criterion_scale = [];
1183
-            for(i=2; i<amount_of_scales; i++){
1184
-               each_criterion_scale.push($(this.children[i]).text());
1185
-
1186
-            }
1187
-            copyright.push($(this.children[i]).text());
1188
-            i+=1;
1189
-            notes.push($(this.children[i]).text());
1190
-
1191
-            scales.push(each_criterion_scale);
1192
-
1193
+            
1193
             
1194
             
1194
             
1195
             
1195
 
1196
 
1196
             
1197
             
1197
 
1198
 
1198
-            // Clone the object and push it into the array
1199
+            
1199
            
1200
            
1200
 
1201
 
1201
     });
1202
     });
1202
 
1203
 
1204
+    $('.editable').each(function(index){
1205
+        titles.push($(this).text());
1206
+    })
1207
+
1208
+
1203
     //console.log('school', $('#select-school').find(':selected').data('school-id') );
1209
     //console.log('school', $('#select-school').find(':selected').data('school-id') );
1204
     //console.log('program', $('#select-program').find(':selected').data('program-id') );
1210
     //console.log('program', $('#select-program').find(':selected').data('program-id') );
1205
 
1211
 
1218
                 expected_points: $('#expected_points').find(':selected').val(),
1224
                 expected_points: $('#expected_points').find(':selected').val(),
1219
                 is_visible: $('input[name=is_visible]:checked').val(),
1225
                 is_visible: $('input[name=is_visible]:checked').val(),
1220
                 criteria : criteria,
1226
                 criteria : criteria,
1221
-                scales: scales,
1227
+                //scales: scales,
1222
                 max_score : max,
1228
                 max_score : max,
1223
-                copyright : copyright,
1224
-                notes :notes
1229
+                /*copyright : copyright,
1230
+                notes :notes*/
1231
+                titles: titles
1225
 
1232
 
1226
             },
1233
             },
1227
             function(data)
1234
             function(data)
1249
                 expected_points: $('#expected_points').find(':selected').val(),
1256
                 expected_points: $('#expected_points').find(':selected').val(),
1250
                 is_visible: $('input[name=is_visible]:checked').val(),
1257
                 is_visible: $('input[name=is_visible]:checked').val(),
1251
                 criteria : criteria,
1258
                 criteria : criteria,
1252
-                scales: scales,
1259
+                //scales: scales,
1253
                 max_score : max,
1260
                 max_score : max,
1254
-                copyright :copyright,
1255
-                notes:notes
1261
+                /*copyright : copyright,
1262
+                notes :notes*/
1263
+                titles: titles
1256
             },
1264
             },
1257
             function(data)
1265
             function(data)
1258
             {
1266
             {
1329
     toggleProgramSelect($('#select-school'));
1337
     toggleProgramSelect($('#select-school'));
1330
 
1338
 
1331
 // Fetch criteria of first outcome
1339
 // Fetch criteria of first outcome
1332
-fetchCriteria($('#select-outcome'));
1340
+fetchCriteria($('#select-outcome'), $('#select-objective'));
1333
 changeTable();
1341
 changeTable();
1334
 
1342
 
1335
 // Hide table
1343
 // Hide table

+ 121
- 12
app/views/local/professors/activity.blade.php View File

61
         <h4 class="modal-title">Edit Transforming Actions</h4>
61
         <h4 class="modal-title">Edit Transforming Actions</h4>
62
       </div>
62
       </div>
63
         <div class="modal-body">
63
         <div class="modal-body">
64
-            {{ Form::open(array('action' => array('ActivitiesController@update', $activity->id))) }}
64
+            {{ Form::open(array('action' => array('TransformativeActionsController@postActivityCriterion', $activity->id))) }}
65
+                                  
65
 
66
 
66
                 <p>A Transforming Action is the educational action to be taken to address the criteria of an unachieved Learning Outcome.</p>
67
                 <p>A Transforming Action is the educational action to be taken to address the criteria of an unachieved Learning Outcome.</p>
67
                 <p>Una acción transformadora es una acción educativa a tomarse para atender el o los criterios de un dominio dado que no se alcanzaron.</p>
68
                 <p>Una acción transformadora es una acción educativa a tomarse para atender el o los criterios de un dominio dado que no se alcanzaron.</p>
68
 
69
 
70
+                <h5>Choose criteria for the transforming action <br>
71
+                Escoge los criterion para la acción transformadora</h5>
72
+
73
+                <div class="form-group">
74
+
75
+                    {{ Form::label('select-activity-criterion', 'Criteria')}}
76
+                    
77
+                    <select id='select-activity-criterion' name = "trans_act[]"data-count = "1" class="form-control selectpicker" >
78
+                        @foreach ($activity_criterion as $ac)
79
+                       
80
+                        <option value='{{$ac->id}}' selected>{{$ac->name}}</option>
81
+
82
+                        @endforeach
83
+                    </select>
84
+                </div>
85
+
86
+
87
+                <button id='button-add-activity-criterion' class='btn btn-md btn-secondary'>
88
+                    <span class='glyphicon glyphicon-plus'>
89
+
90
+                    </span>
91
+                    Add another Criteria
92
+                </button>
93
+                <hr>
94
+                
95
+                <div class ="form-group">
96
+                    {{ Form::label('name_trans', 'Name of Transforming Actions')}}
97
+                    {{ Form::text('name_trans', '', array('class' => 'form-control')) }}
98
+                </div>
99
+                
69
                 <div class="form-group">
100
                 <div class="form-group">
70
                     {{ Form::label('transforming_actions', 'Transforming Actions') }}
101
                     {{ Form::label('transforming_actions', 'Transforming Actions') }}
71
                     {{ Form::textarea('transforming_actions', $activity->transforming_actions, array('class' => 'form-control', 'rows'=> 4, 'placeholder'=>'Actions to improve student performance after assessment (optional)')) }}
102
                     {{ Form::textarea('transforming_actions', $activity->transforming_actions, array('class' => 'form-control', 'rows'=> 4, 'placeholder'=>'Actions to improve student performance after assessment (optional)')) }}
177
                 @endif
208
                 @endif
178
 
209
 
179
                 <!-- If there is no assessment and the semester is active -->
210
                 <!-- If there is no assessment and the semester is active -->
180
-                @if($activity->outcomes_attempted == NULL && in_array($course->semester->id, $active_semesters))
211
+                @if($activity->o_att_array == NULL && in_array($course->semester->id, $active_semesters))
181
                     {{ HTML::linkAction('ActivitiesController@assess', 'Assess', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
212
                     {{ HTML::linkAction('ActivitiesController@assess', 'Assess', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
182
                 @else
213
                 @else
183
                     {{ HTML::linkAction('ActivitiesController@viewAssessment', 'View Assessment Sheet', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
214
                     {{ HTML::linkAction('ActivitiesController@viewAssessment', 'View Assessment Sheet', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
185
 
216
 
186
                     <!-- If semester is active, allow users to edit assessments -->
217
                     <!-- If semester is active, allow users to edit assessments -->
187
                     @if (in_array($course->semester->id, $active_semesters))
218
                     @if (in_array($course->semester->id, $active_semesters))
219
+                    
188
                         {{ HTML::linkAction('ActivitiesController@assess', 'Edit Assessment', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
220
                         {{ HTML::linkAction('ActivitiesController@assess', 'Edit Assessment', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
189
                         <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-confirm-delete-assessment">Delete Assessment</button>
221
                         <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-confirm-delete-assessment">Delete Assessment</button>
190
                         <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-edit-transforming-actions">Transforming Actions</button>
222
                         <button class="btn btn-primary btn-sm btn-block" btn-block data-toggle="modal" data-target="#modal-edit-transforming-actions">Transforming Actions</button>
221
 <div class="row">
253
 <div class="row">
222
     <div class="col-md-12" id="criteriaGraph"></div>
254
     <div class="col-md-12" id="criteriaGraph"></div>
223
 </div>
255
 </div>
256
+
257
+<script>
258
+
259
+
260
+$('#button-add-activity-criterion').on('click', function(e){
261
+    e.preventDefault();
262
+
263
+    options = $('#select-activity-criterion').html();
264
+    counter = $('#select-activity-criterion').data('count');
265
+
266
+    var div = $('<div/>', {
267
+        'id': "selectFor"+counter
268
+        
269
+    });
270
+    var divForSelect = $('<div/>', {
271
+        'class':'col-12 form-group'
272
+    });
273
+    var select = $('<select/>', {
274
+        'class':'selectpicker',
275
+        'name': 'trans_act[]',
276
+
277
+    })
278
+
279
+
280
+
281
+    var $button = $('<button/>', {
282
+            'type': 'button',
283
+            'class': 'btn btn-primary',
284
+            'onclick': '$(this).parent().parent().remove();$("#button-add-activity-criterion").show(); '
285
+        }).html('X');
286
+    
287
+    divForSelect.append(select);
288
+    divForSelect.append($button);
289
+    div.append(divForSelect);
290
+  
291
+    $('#select-activity-criterion').parent().parent().after(div);
292
+    select.html(options);
293
+
294
+    refreshSelects();
295
+
296
+    countSelects = $('.selectpicker').length;
297
+    countOptions = $('#select-activity-criterion option').length;
298
+    if(countOptions == countSelects){
299
+        $('#button-add-activity-criterion').hide();
300
+    }
301
+
302
+
303
+
304
+});
305
+
306
+function refreshSelects(){
307
+    $('.selectpicker').each(function(){
308
+        $(this).selectpicker('refresh');
309
+    });
310
+}
311
+$(document).ready(function(){
312
+
313
+if({{count($transformative_actions)}}){
314
+    var trans_actions = {{json_encode($transformative_actions)}};
315
+    //$('#select-activity-criterion').val(trans_actions[0].activity_id);
316
+    $('#name_trans').val(trans_actions[0].at_text);
317
+    $('#transforming_actions').val(trans_actions[0].description);
318
+    refreshSelects();
319
+
320
+    for(index in trans_actions){
321
+        if(index==0) continue;
322
+        $('#button-add-activity-criterion').click();
323
+    }
324
+    $('.selectpicker').each(function(index){
325
+        $(this).val(trans_actions[index].activity_criterion_id);
326
+    });
327
+    refreshSelects();
328
+}
329
+});
330
+
331
+
332
+</script>
224
 @stop
333
 @stop
225
 
334
 
226
 @section('included-js')
335
 @section('included-js')
244
     $('#criteriaGraph').highcharts({
353
     $('#criteriaGraph').highcharts({
245
         chart: {
354
         chart: {
246
             type: 'bar',
355
             type: 'bar',
247
-            height: {{{ count(json_decode($activity->criteria_achieved, true))*22+225 }}},
356
+            height: {{{ count($activity->criteria_achieved() )*22+225 }}},
248
         },
357
         },
249
         title: {
358
         title: {
250
             text: 'Criteria Achievement',
359
             text: 'Criteria Achievement',
251
         },
360
         },
252
         xAxis: {
361
         xAxis: {
253
             categories: [
362
             categories: [
254
-                @if($activity->criteria_achieved_percentage!=NULL)
255
-                    @foreach(json_decode($activity->criteria_achieved, true) as $id=>$value)
363
+                @if($activity->cap_array!=NULL)
364
+                    @foreach($activity->criteria_achieved() as $id=>$value)
256
                         "{{{ Criterion::withTrashed()->find($id)->name }}}",
365
                         "{{{ Criterion::withTrashed()->find($id)->name }}}",
257
                     @endforeach
366
                     @endforeach
258
                 @endif
367
                 @endif
274
             title: {
383
             title: {
275
                 text: 'Percentage'
384
                 text: 'Percentage'
276
             },
385
             },
277
-            @if(isset($activity->rubric->expected_percentage)  )
386
+            @if(isset($activity->rubric[0]->expected_percentage)  )
278
             plotLines:[{
387
             plotLines:[{
279
-                value:{{ $activity->rubric->expected_percentage }},
388
+                value:{{ $activity->rubric[0]->expected_percentage }},
280
                 color: '#000',
389
                 color: '#000',
281
                 width:3,
390
                 width:3,
282
                 zIndex:4,
391
                 zIndex:4,
283
                 label:{
392
                 label:{
284
-                    text: 'Goal ({{ $activity->rubric->expected_percentage }}%)',
393
+                    text: 'Goal ({{ $activity->rubric[0]->expected_percentage }}%)',
285
                     style: {
394
                     style: {
286
                         color: '#000',
395
                         color: '#000',
287
                         fontSize: '14px',
396
                         fontSize: '14px',
327
                 y:-1
436
                 y:-1
328
             },
437
             },
329
             data:[
438
             data:[
330
-                @if($activity->criteria_achieved_percentage!=NULL)
331
-                    @foreach(json_decode($activity->criteria_achieved_percentage, true) as $id=>$value)
439
+                @if($activity->cap_array!=NULL)
440
+                    @foreach($activity->cap_array as $id=>$crit)
332
 
441
 
333
                         //This conditional is to ignore criteria that weren't assessed. These would have a value of null.
442
                         //This conditional is to ignore criteria that weren't assessed. These would have a value of null.
334
-                        @if($value)
335
-                            {{{ $value }}},
443
+                        @if($crit->score_percentage)
444
+                            {{{ $crit->score_percentage }}},
336
                         @else
445
                         @else
337
                             0,
446
                             0,
338
                         @endif
447
                         @endif

+ 2
- 2
app/views/local/professors/assessment.blade.php View File

25
                 <table class="table table-bordered">
25
                 <table class="table table-bordered">
26
                     <thead id = "criteria-header">;
26
                     <thead id = "criteria-header">;
27
                         @for($i=0; $i<$rubric->num_scales; $i++)
27
                         @for($i=0; $i<$rubric->num_scales; $i++)
28
-                        <th>Scale {{$i+1}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}} - {{(1+$i)*($rubric->max_score/$rubric->num_scales)}})</th>
28
+                        <th>{{$rubric->titles[$i]}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}} - {{(1+$i)*($rubric->max_score/$rubric->num_scales)}})</th>
29
                         @endfor
29
                         @endfor
30
                         <th>Notes</th>
30
                         <th>Notes</th>
31
                     </thead>
31
                     </thead>
572
         type: 'POST',
572
         type: 'POST',
573
         url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
573
         url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
574
         data: {
574
         data: {
575
-            rubric_criterion_id: $(this).data('rubric-criterion-id')
575
+            criterion_id: $(this).data('criterion-id')
576
         },
576
         },
577
         success: function(data)
577
         success: function(data)
578
         {
578
         {

+ 41
- 47
app/views/local/professors/rubrics.blade.php View File

84
 <div id="rubric-container" class="row">
84
 <div id="rubric-container" class="row">
85
   <div class="col-md-12">
85
   <div class="col-md-12">
86
 
86
 
87
-    <table class="table">
87
+    <table class="table" style="table-layout: fixed">
88
       <thead><tr><th colspan="6 "><h3 id="rubric-name"></h3></th></tr></thead>
88
       <thead><tr><th colspan="6 "><h3 id="rubric-name"></h3></th></tr></thead>
89
       <thead><tr id ="criterion-header"><th>Criterion</th><th>Beginning (1-2)</th><th>In Progress (3-4)</th><th>Good (5-6)</th><th>Excellent (7-8)</th></tr></thead>
89
       <thead><tr id ="criterion-header"><th>Criterion</th><th>Beginning (1-2)</th><th>In Progress (3-4)</th><th>Good (5-6)</th><th>Excellent (7-8)</th></tr></thead>
90
       <tbody>
90
       <tbody>
96
       
96
       
97
 
97
 
98
       <hr>
98
       <hr>
99
-      <p class="small"><strong>Outcome Information</strong></p>
99
+      <p class="small"><strong>Copyright Information</strong></p>
100
       <ul id="copyright-list" class="list-unstyled small">
100
       <ul id="copyright-list" class="list-unstyled small">
101
       </ul>
101
       </ul>
102
       <hr>
102
       <hr>
114
 
114
 
115
 <script>
115
 <script>
116
   
116
   
117
-function changeTable(){
117
+function changeTable(data){
118
     
118
     
119
  
119
  
120
             amount_of_scales = parseInt($('#num_of_scales').val());
120
             amount_of_scales = parseInt($('#num_of_scales').val());
126
             counter = 0;
126
             counter = 0;
127
             division = maximum/amount_of_scales;
127
             division = maximum/amount_of_scales;
128
             if(amount_of_scales==1){
128
             if(amount_of_scales==1){
129
-                newScaleHeaders+= "<th>Score (1 - "+maximum+")</th>";
129
+                newScaleHeaders+= "<th class ='titles' data-title-id  ="+data.titles[counter].title_id+">"+data.titles[counter].text+" (1 - "+maximum+")</th>";
130
             }
130
             }
131
             else if(maximum!= amount_of_scales){
131
             else if(maximum!= amount_of_scales){
132
             while(counter <amount_of_scales){
132
             while(counter <amount_of_scales){
133
                 
133
                 
134
                 minimumScore = 1+(counter*division);
134
                 minimumScore = 1+(counter*division);
135
                 maximumScore = (1+counter)*division;
135
                 maximumScore = (1+counter)*division;
136
-                newScaleHeaders+= "<th>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
136
+                newScaleHeaders+= "<th class ='titles' data-title-id = "+data.titles[counter].title_id+">"+data.titles[counter].text+"  ("+minimumScore+" - "+maximumScore+")</th>";
137
                 counter++;
137
                 counter++;
138
             }
138
             }
139
             }else{
139
             }else{
140
                 while(counter <amount_of_scales){
140
                 while(counter <amount_of_scales){
141
                 
141
                 
142
        
142
        
143
-                newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
143
+                newScaleHeaders+= "<th class ='titles' data-title-id  ="+data.titles[counter].title_id+"> "+data.titles[counter].text+ " </th>";
144
                 counter++;
144
                 counter++;
145
             }
145
             }
146
             }
146
             }
147
-            newScaleHeaders += '<th>Copyright</th><th>Notes</th>';
147
+            newScaleHeaders += '<th>Outcomes</th>';
148
             
148
             
149
             $("#criterion-header").html(newScaleHeaders);
149
             $("#criterion-header").html(newScaleHeaders);
150
             
150
             
214
 }
214
 }
215
 
215
 
216
 // Build list from copyright info in rubric
216
 // Build list from copyright info in rubric
217
-function buildOutcomeList()
217
+function buildCopyrightList()
218
 {
218
 {
219
     // Empty the copyright list
219
     // Empty the copyright list
220
     $('#copyright-list').empty();
220
     $('#copyright-list').empty();
223
     {
223
     {
224
         var criterion = $(this);
224
         var criterion = $(this);
225
         // If there's copyright info
225
         // If there's copyright info
226
-        if(criterion.data('outcomes')!=null){
227
-            var outcomes = criterion.data('outcomes');
226
+        if(criterion.data('criterion-copyright')!=null){
227
+            var copyright = criterion.data('criterion-copyright');
228
             if($('#copyright-list li').length>0)
228
             if($('#copyright-list li').length>0)
229
             {
229
             {
230
                 var found = false;
230
                 var found = false;
231
                 $('#copyright-list li').each(function()
231
                 $('#copyright-list li').each(function()
232
                 {
232
                 {
233
                     // If found, give the string its number
233
                     // If found, give the string its number
234
-                    if(outcomes==$(this).find('span').text())
234
+                    if(copyright==$(this).find('span').text())
235
                     {
235
                     {
236
 
236
 
237
                         copyrightNumber = Number.parseInt($(this).find('sup').text());
237
                         copyrightNumber = Number.parseInt($(this).find('sup').text());
238
 
238
 
239
                         console.log('a: '+copyrightNumber);
239
                         console.log('a: '+copyrightNumber);
240
 
240
 
241
-                        criterion.children('td:nth-child(1)').find('sup').text(copyrightNumber);
241
+                        criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
242
                         found =true;
242
                         found =true;
243
 
243
 
244
                         //to break
244
                         //to break
253
                     var copyrightNumber = $('#copyright-list li').length+1;
253
                     var copyrightNumber = $('#copyright-list li').length+1;
254
 
254
 
255
                     console.log('b: '+copyrightNumber);
255
                     console.log('b: '+copyrightNumber);
256
-                    console.log(criterion.children('td:nth-child(1)').find('sup').length);
256
+                    console.log(criterion.children('td:nth-child(2)').find('sup').length);
257
 
257
 
258
-                    criterion.children('td:nth-child(1)').find('sup').text(copyrightNumber);
259
-                    $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+outcomes+'<span></li>');
258
+                    criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
259
+                    $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
260
                 }
260
                 }
261
             }
261
             }
262
             else
262
             else
263
             {
263
             {
264
-                criterion.children('td:nth-child(1)').find('sup').text('1');
265
-                $('#copyright-list').append('<li><sup>1 </sup><span>'+outcomes+'<span></li>');
264
+                criterion.children('td:nth-child(2)').find('sup').text('1');
265
+                $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
266
             }
266
             }
267
         }
267
         }
268
     });
268
     });
297
             $('#expected_points').text(data.template.expected_points)
297
             $('#expected_points').text(data.template.expected_points)
298
             $('#max').val(data.template.max_score);
298
             $('#max').val(data.template.max_score);
299
             $('#num_of_scales').val(data.template.num_scales);
299
             $('#num_of_scales').val(data.template.num_scales);
300
-            changeTable();
300
+            changeTable(data);
301
 
301
 
302
 
302
 
303
             // Set the contents of the rubric
303
             // Set the contents of the rubric
324
                 }
324
                 }
325
                 
325
                 
326
                 
326
                 
327
-                for(scaleIndex in data.scales[current_criterion.id]){
327
+                for(scaleIndex in current_criterion.scales){
328
 
328
 
329
-                    scale = data.scales[current_criterion.id][scaleIndex];
329
+                  scale = current_criterion.scales[scaleIndex];
330
 
330
 
331
-                    str+='<td data-scale-id ="'+scale.id+'">'+scale.description+'</td>';
331
+                  str+='<td>'+scale.description+'</td>';
332
 
332
 
333
-                }
334
-                copyright = temp_criterion[temp_c].copyright;
335
-                notes = temp_criterion[temp_c].notes;
336
-                if(copyright == null){
337
-                    copyright = '';
338
-                }
339
-                if(notes==null) notes ='';
340
-                str+= '<td >'+copyright+'</td>';
341
-                str+= '<td>'+notes+'</td>';
333
+              }
334
+ str+= '<td>'+current_criterion.outcomes+'</td>';
342
                 str+='</tr>';
335
                 str+='</tr>';
343
-
336
+               
344
     $('table tbody').append(str);
337
     $('table tbody').append(str);
345
 
338
 
346
-    buildOutcomeList();
339
+    buildCopyrightList();
347
 
340
 
348
                 
341
                 
349
 
342
 
394
                 $('table tbody').append(str);
387
                 $('table tbody').append(str);
395
 
388
 
396
                 // Build copyright list
389
                 // Build copyright list
397
-                buildOutcomeList();
390
+                buildCopyrightList();
398
 
391
 
399
                 // Enable X-Edtable on this new row
392
                 // Enable X-Edtable on this new row
400
                 $('.editable').editable({
393
                 $('.editable').editable({
412
           
405
           
413
 
406
 
414
             // Build Copyright List
407
             // Build Copyright List
415
-            buildOutcomeList();
408
+            buildCopyrightList();
416
         }, 
409
         }, 
417
         'json',
410
         'json',
418
     );
411
     );
473
       });
466
       });
474
 
467
 
475
       // Build Copyright List
468
       // Build Copyright List
476
-      buildOutcomeList();
469
+      buildCopyrightList();
477
     }
470
     }
478
   );
471
   );
479
 }
472
 }
502
   e.preventDefault();
495
   e.preventDefault();
503
 
496
 
504
   var criteria = [];
497
   var criteria = [];
505
-  scales = [];
498
+  var titles =  [];
506
   max_score = $('#max').val();
499
   max_score = $('#max').val();
507
 
500
 
508
   // For each criterion in the rubric, get its value and put it into an array
501
   // For each criterion in the rubric, get its value and put it into an array
510
   {
503
   {
511
 
504
 
512
     criteria.push($(this).data('criterion-id'));
505
     criteria.push($(this).data('criterion-id'));
513
-    each_criterion_scale =[];
514
-    $(this).children('td').each(function(index){
515
-      if(index!=0 )
516
-      each_criterion_scale.push($(this).text());
517
-      
518
-    })
519
-each_criterion_scale.pop();
520
-each_criterion_scale.pop();
521
-    scales.push(each_criterion_scale);
506
+
507
+    
522
     /*
508
     /*
523
       criterionObject.id = $(this).data('criterion-id');
509
       criterionObject.id = $(this).data('criterion-id');
524
       criterionObject.outcome_id = $(this).data('assoc-outcome-id');
510
       criterionObject.outcome_id = $(this).data('assoc-outcome-id');
542
       var clone = jQuery.extend({}, criterionObject);
528
       var clone = jQuery.extend({}, criterionObject);
543
       criteriaArray.push(clone);
529
       criteriaArray.push(clone);
544
 */
530
 */
531
+
532
+  });
533
+
534
+  $('.titles').each(function(index){
535
+    titles.push($(this).data('title-id'));
545
   });
536
   });
546
 
537
 
538
+
539
+  
540
+
547
   // If activity does not have a rubric, create it
541
   // If activity does not have a rubric, create it
548
   if($('#assigned_rubric').length === 0)
542
   if($('#assigned_rubric').length === 0)
549
   {
543
   {
560
         expected_percentage: $('#expected_percentage').text(),
554
         expected_percentage: $('#expected_percentage').text(),
561
         expected_points: $('#expected_points').text(),
555
         expected_points: $('#expected_points').text(),
562
         criteria: criteria,
556
         criteria: criteria,
563
-        scales: scales,
557
+        titles:titles,
564
         max_score:max_score
558
         max_score:max_score
565
 
559
 
566
 
560
 
586
         expected_percentage: $('#expected_percentage').text(),
580
         expected_percentage: $('#expected_percentage').text(),
587
         expected_points: $('#expected_points').text(),
581
         expected_points: $('#expected_points').text(),
588
         criteria: criteria,
582
         criteria: criteria,
589
-        scales: scales,
583
+        titles:titles,
590
         max_score:max_score
584
         max_score:max_score
591
       },
585
       },
592
       function(data)
586
       function(data)

+ 93
- 18
app/views/local/professors/view_assessment.blade.php View File

54
 
54
 
55
 
55
 
56
         <table id="assessment-table" class="table table-striped table-condensed table-bordered">
56
         <table id="assessment-table" class="table table-striped table-condensed table-bordered">
57
+            
57
             <thead>
58
             <thead>
59
+                <tr>
60
+
61
+                    <th>
62
+                        
63
+                    </th>
64
+                    @foreach ($rubric_criterion as $index => $criterion)
65
+                    
66
+                        
67
+                        <th data-criterion-id="{{{ $criterion->criterion_id }}}" id="weight-{{$index}}"  data-weight = " {{$criterion->weight}}" data-activity-criterion-id="{{$criterion->activity_criterion_id}}">
68
+                        Weight: {{$criterion->weight}}
69
+                        </th>
70
+                        
71
+                        
72
+                @endforeach
73
+                <th></th>
74
+                <th></th>
75
+                <th></th>
76
+                </tr>
58
                     <tr>
77
                     <tr>
59
                         <th>Student</th>
78
                         <th>Student</th>
60
-                        @foreach ($rubric_contents as $criterion)
61
-                            <th class="criterion-field" data-criterion-id="{{{ $criterion->id }}}"><div class="th-box">{{ $criterion->name}}</div></th>
79
+                        @foreach ($rubric_criterion as $criterion)
80
+                            <th class="criterion-field" data-criterion-id="{{{ $criterion->criterion_id }}}"><div class="th-box">{{ $criterion->name}}</div></th>
62
                         @endforeach
81
                         @endforeach
63
                         <th>Student Percentage</th>
82
                         <th>Student Percentage</th>
83
+                        <th>Student % Per Weight</th>
84
+                        <th>Comments</th>
64
                     </tr>
85
                     </tr>
65
             </thead>
86
             </thead>
66
             <tbody>
87
             <tbody>
68
             <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
89
             <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
69
             @if(sizeof($assessments)!=0)
90
             @if(sizeof($assessments)!=0)
70
                 <!-- For each assessment -->
91
                 <!-- For each assessment -->
71
-                @foreach ($assessments as $assessment)
72
-                    <tr class="student-row">
73
-                        <!-- Fetch student name -->
74
-                        <td class="student-field" data-student-id="{{ $assessment->student_id }}">
75
-                            {{{ Student::find($assessment->student_id)->name }}}
92
+                @foreach ($students as $student)
93
+                <tr class="student-row">
94
+                    <!-- Fetch student name -->
95
+                    <td class="student-field" data-student-id="{{ $student->id }}">
96
+                        {{{ $student->name }}}
97
+                    </td>
98
+
99
+                    <!-- For each criterion in the rubric, there's a score field -->
100
+                    @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
101
+                        <td class="score-field text-center">
102
+                            {{$scores_array[$student->id][$i]}}
76
                         </td>
103
                         </td>
104
+                            
105
+                    @endfor
106
+                    <td class="percentage text-center"></td>
107
+                    <td class="percentage-per-weight text-center"></td>
108
+                    <td class="">
109
+                        <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" disabled >{{ $scores_array[$student->id]["comments"] }}</textarea>
110
+                    </td>
111
+                 </tr>
112
+            @endforeach
77
 
113
 
78
-                        <!-- For each criterion in the rubric, there's a score field -->
79
-                        @for ($i = 0; $i<sizeof($rubric_contents); $i++)
80
-                            <td class="score-field text-center">
81
-                                {{ $scores_array[$assessment->id][$rubric_contents[$i]->id] }}
82
-                            </td>
83
-                        @endfor
84
-                        <td class="percentage text-center">{{{ $assessment->percentage }}}</td>
85
-                     </tr>
86
-                @endforeach
87
             @endif
114
             @endif
88
             </tbody>
115
             </tbody>
89
             <tfoot>
116
             <tfoot>
91
                     <td>
118
                     <td>
92
                         <strong>Passed Criteria Percentage </strong>
119
                         <strong>Passed Criteria Percentage </strong>
93
                     </td>
120
                     </td>
94
-                    @for ($i = 0; $i<sizeof($rubric_contents); $i++)
121
+                    @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
95
                         <td class="total text-center"><strong><span class="total-value"></span>%</strong>
122
                         <td class="total text-center"><strong><span class="total-value"></span>%</strong>
96
                         </td>
123
                         </td>
97
                     @endfor
124
                     @endfor
102
         </table>
129
         </table>
103
     </div>
130
     </div>
104
 </div>
131
 </div>
132
+<input type='hidden' value = {{$rubric->max_score}} id = "max">
133
+
134
+<script>
135
+
136
+
105
 
137
 
138
+    </script>
106
 @stop
139
 @stop
107
 
140
 
108
 @section('included-js')
141
 @section('included-js')
177
 // Calculate total for a specific student
210
 // Calculate total for a specific student
178
 function percentagePerStudentPlain(row)
211
 function percentagePerStudentPlain(row)
179
 {
212
 {
180
-    // Object to hold the score student's total score
213
+   /* // Object to hold the score student's total score
181
     var sum = 0 ;
214
     var sum = 0 ;
182
     var total = 0;
215
     var total = 0;
183
     var percentage = 0;
216
     var percentage = 0;
199
         percentage="0.00";
232
         percentage="0.00";
200
 
233
 
201
     row.find('.percentage').html('<strong>'+percentage+'%</strong>');
234
     row.find('.percentage').html('<strong>'+percentage+'%</strong>');
235
+*/
236
+
237
+    var sum = 0 ;
238
+    var total = 0;
239
+    var percentage = 0;
240
+    var max_score = parseInt($('#max').val());
241
+    sum_of_weight = 0;
242
+    per_of_weight =0;
243
+
244
+    row.find('td.score-field').each(function(index)
245
+    {
246
+        var val =  parseInt($(this).text());
247
+        if(val % 1 === 0) //If number is integer
248
+        {
249
+            sum += val;
250
+            total+=1;
251
+            per_of_weight += val * parseInt($('#weight-'+index).data("weight")); 
252
+            sum_of_weight += parseInt($('#weight-'+index).data("weight"));
253
+        }
254
+
255
+    });
256
+    percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
257
+    percentage =((sum/(total*max_score))*100).toFixed(2);
258
+
259
+    //If percentage is not a number, set it to 0.
260
+    if(isNaN(percentage))
261
+    {
262
+        percentage="N/A";
263
+        row.find('.percentage').html('<strong>'+percentage+'</strong>');
264
+    }
265
+    else
266
+    {
267
+        row.find('.percentage').html('<strong>'+percentage+'%</strong>');
268
+    }
269
+    if(isNaN(percentage_per_weight)){
270
+        percentage_per_weight="N/A";
271
+        row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'</strong>');
272
+    }
273
+    else{
274
+        row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'%</strong>');
275
+    }
276
+
202
 
277
 
203
 }
278
 }
204
 
279
 

+ 1
- 1
app/views/local/professors/viewrubric.blade.php View File

33
             <th></th>
33
             <th></th>
34
             <th>Criterion</th>
34
             <th>Criterion</th>
35
             @for($i = 0; $i<$rubric->num_scales; $i++)
35
             @for($i = 0; $i<$rubric->num_scales; $i++)
36
-            <th>Scale {{$i+1}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}} - {{(1+$i)*($rubric->max_score/$rubric->num_scales)}})</th>
36
+            <th> {{$rubric->titles[$i]}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}} - {{(1+$i)*($rubric->max_score/$rubric->num_scales)}})</th>
37
             @endfor
37
             @endfor
38
             <th>Learning Outcome</th>
38
             <th>Learning Outcome</th>
39
           </tr>
39
           </tr>