소스 검색

a subir los migrations con casi todo

부모
커밋
99fa1cb283

+ 80
- 16
app/controllers/ActivitiesController.php 파일 보기

@@ -131,17 +131,41 @@ class ActivitiesController extends \BaseController
131 131
         foreach ($active_semesters_collection as $active_semester) {
132 132
             $active_semesters[] = $active_semester->id;
133 133
         }
134
+
134 135
         Log::info($active_semesters);
135 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 137
         $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
137 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,6 +189,10 @@ class ActivitiesController extends \BaseController
165 189
 
166 190
         // Get rubric contents
167 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 196
         Log::info($rubric);
169 197
         Log::info($activity);
170 198
         $rubric_criterion = DB::table('criteria')
@@ -175,12 +203,12 @@ class ActivitiesController extends \BaseController
175 203
             ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
176 204
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
177 205
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
178
-            ->addSelect('rubric_criterion.copyright', 'rubric_criterion.notes')
179 206
             ->get();
180 207
         Log::info($rubric_criterion);
181 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 212
                 ->orderBy('position')
185 213
                 ->lists('description'));
186 214
         }
@@ -271,6 +299,7 @@ class ActivitiesController extends \BaseController
271 299
                     // Activity
272 300
                     $activity = Activity::find(Input::get('activity_id'));
273 301
 
302
+
274 303
                     // Create or update student scores
275 304
                     if ($activity->outcomes_attempted == NULL) {
276 305
                         // For each student, save her/his assessment in the db
@@ -742,21 +771,56 @@ class ActivitiesController extends \BaseController
742 771
         $students = $course->students;
743 772
 
744 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 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 813
         // Decode the scores (blade workaround)
754 814
         $scores_array = array();
815
+
755 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 826
     public function printAssessment($id)

+ 48
- 76
app/controllers/RubricsController.php 파일 보기

@@ -82,7 +82,7 @@ class RubricsController extends \BaseController
82 82
 
83 83
         // Get rubric contents
84 84
 
85
-        $scales = Input::get('scales');
85
+        $titles = Input::get('titles');
86 86
         $criteria = Input::get('criteria');
87 87
 
88 88
         // Process rubric
@@ -92,7 +92,7 @@ class RubricsController extends \BaseController
92 92
         $rubric->expected_percentage = Input::get('expected_percentage');
93 93
         $rubric->expected_points = Input::get('expected_points');
94 94
         $rubric->user_id = Auth::id();
95
-        $rubric->num_scales = count($scales[0]);
95
+        $rubric->num_scales = count($titles);
96 96
         $rubric->max_score = Input::get('max_score');
97 97
         $defaultWeight = round(100 / count($criteria), 2);
98 98
 
@@ -108,37 +108,22 @@ class RubricsController extends \BaseController
108 108
 
109 109
             $rubricId = $rubric->id;
110 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 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 118
                 $activity_id = Input::get("activity_id");
139 119
                 DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity_id}, {$criterion_id}, {$defaultWeight})");
140 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 127
             Session::flash('status', 'success');
143 128
             Session::flash('message', 'Rubric assigned.');
144 129
 
@@ -168,10 +153,10 @@ class RubricsController extends \BaseController
168 153
      */
169 154
     public function update()
170 155
     {
171
-        Log::info('entré???');
156
+
172 157
         $rubric = Rubric::find(Input::get('id'));
173 158
 
174
-        $scales = Input::get('scales');
159
+        $titles = Input::get('titles');
175 160
         $criteria = Input::get('criteria');
176 161
 
177 162
         // Process rubric
@@ -180,7 +165,7 @@ class RubricsController extends \BaseController
180 165
         $rubric->expected_percentage = Input::get('expected_percentage');
181 166
         $rubric->expected_points = Input::get('expected_points');
182 167
 
183
-        $rubric->num_scales = count($scales[0]);
168
+        $rubric->num_scales = count($titles);
184 169
         $rubric->max_score = Input::get('max_score');
185 170
         $defaultWeight = round(100 / count($criteria), 2);
186 171
 
@@ -201,19 +186,19 @@ class RubricsController extends \BaseController
201 186
 
202 187
 
203 188
         // If the associated activity has been assessed, delete the records
204
-        if ($activity->outcomes_attempted != NULL) {
189
+        /* if ($activity->outcomes_attempted != NULL) {
205 190
             DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
206 191
             $activity->criteria_achieved_percentage = NULL;
207 192
             $activity->criteria_achieved = NULL;
208 193
             $activity->outcomes_achieved = NULL;
209 194
             $activity->outcomes_attempted = NULL;
210
-        }
211
-        Log::info('entré3???');
195
+        }*/
196
+
212 197
 
213 198
         $rubric->save();
214
-        Log::info("????");
199
+
215 200
         $activity->save();
216
-        Log::info("????22");
201
+
217 202
         // Get all the course's activities
218 203
         Log::info($activity->course);
219 204
         $course = Course::find($activity->course->id);
@@ -230,6 +215,7 @@ class RubricsController extends \BaseController
230 215
         Log::info('entré4???');
231 216
 
232 217
         //If there are still evaluated activities in the course, recalculate course outcomes
218
+        /*
233 219
         if (!$activities->isEmpty() && $remainingAssessed) {
234 220
             // Variables to hold recalculated outcomes for the course
235 221
             $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
@@ -269,49 +255,26 @@ class RubricsController extends \BaseController
269 255
         }
270 256
 
271 257
         $course->save();
258
+        */
272 259
         Log::info('entré6???');
273 260
         DB::delete("delete from rubric_criterion where rubric_id ={$rubric->id}");
274 261
         DB::delete("delete from activity_criterion where activity_id = {$activity->id}");
275 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 268
                 DB::rollBack();
310 269
                 Session::flash('status', 'danger');
311 270
                 Session::flash('message', 'Rubric could not be created.');
312 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 278
         Log::info('entré7???');
316 279
 
317 280
         DB::commit();
@@ -366,10 +329,15 @@ class RubricsController extends \BaseController
366 329
             ->get();
367 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 337
         foreach ($rubric_criterion as $single_cr) {
370 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 341
                 ->orderBy('position')
374 342
                 ->lists('description'));
375 343
             $single_cr->outcomes = json_encode(DB::table('outcomes')
@@ -433,15 +401,19 @@ class RubricsController extends \BaseController
433 401
 
434 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 410
         Log::info($rubric);
440 411
 
441 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 417
             ->first();
446 418
         return json_encode($rubric);
447 419
 

+ 108
- 62
app/controllers/TemplatesController.php 파일 보기

@@ -52,8 +52,9 @@ class TemplatesController extends \BaseController
52 52
 			->get();
53 53
 		Log::info($json_to_send["criteria"]);
54 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 59
 		return json_encode($json_to_send);
59 60
 	}
@@ -96,7 +97,7 @@ class TemplatesController extends \BaseController
96 97
 	 */
97 98
 	public function create()
98 99
 	{
99
-
100
+		DB::beginTransaction();
100 101
 		$template = new Template;
101 102
 
102 103
 		$template->name = Input::get('name');
@@ -147,39 +148,63 @@ class TemplatesController extends \BaseController
147 148
 		$template->max_score = $max_score;
148 149
 
149 150
 		if ($template->save()) {
151
+
150 152
 			$templateId = $template->id;
151 153
 			foreach ($criteria as $index => $criterion_id) {
152 154
 
153 155
 
154
-				DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `position`) values ({$templateId},{$criterion_id}, '{$index}')");
155
-				$template_criterion_id = DB::table('template_criterion')->where('template_id', '=', $templateId)
156
-					->where('criterion_id', '=', $criterion_id)->first();
157
-
158
-				for ($i = 0; $i < count($scales[$index]); $i++) {
159
-					$scale =  Scale::where('description', '=', $scales[$index][$i])->first();
160
-					Log::info($scale);
161
-					if ($scale) {
162
-						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
163
-						DB::commit();
164
-					} else {
165
-						$scale = new Scale;
166
-						$scale->description = $scales[$index][$i];
167
-
168
-						if ($scale->save()) {
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
-							Session::flash('status', 'danger');
173
-							Session::flash('message', 'Rubric could not be created.');
174
-						}
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;
175 191
 					}
176 192
 				}
177 193
 			}
194
+
195
+
178 196
 			Session::flash('status', 'success');
179 197
 			Session::flash('message', 'Rubric created. You can now select it from the list.');
198
+
199
+			DB::commit();
200
+
201
+
202
+			return;
180 203
 		} else {
181 204
 			Session::flash('status', 'danger');
182 205
 			Session::flash('message', 'Rubric could not be created.');
206
+			DB::rollback();
207
+			return;
183 208
 		}
184 209
 	}
185 210
 
@@ -197,9 +222,9 @@ class TemplatesController extends \BaseController
197 222
 			->where("template_criterion.template_id", '=', Input::get('id'))
198 223
 			->get();
199 224
 		foreach ($template_info['criterion'] as $temp_crit) {
200
-			$template_info['scales'][$temp_crit->id] = DB::table('scales')
201
-				->join('template_criterion_scale', 'template_criterion_scale.scale_id', '=', 'scales.id')
202
-				->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)
203 228
 				->orderBy('position', 'ASC')
204 229
 				->get();
205 230
 			$outcomeID = DB::table('criterion_objective_outcome')->where('criterion_id', '=', $temp_crit->criterion_id)
@@ -213,6 +238,12 @@ class TemplatesController extends \BaseController
213 238
 			$temp_crit->outcomes = $outcomeStr;
214 239
 		}
215 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
+
216 247
 		Log::info($template_info);
217 248
 
218 249
 		return json_encode($template_info);
@@ -225,7 +256,9 @@ class TemplatesController extends \BaseController
225 256
 	 */
226 257
 	public function update()
227 258
 	{
259
+		DB::beginTransaction();
228 260
 		$template = Template::find(Input::get('id'));
261
+		Log::info(Input::all());
229 262
 		$template->name = Input::get('name');
230 263
 
231 264
 		$template->is_visible = Input::get('is_visible');
@@ -262,16 +295,15 @@ class TemplatesController extends \BaseController
262 295
 				break;
263 296
 		}
264 297
 
265
-		$scales = Input::get('scales');
298
+
266 299
 		$criteria = Input::get('criteria');
267 300
 
268 301
 		$max_score = Input::get('max_score');
269
-		$copyright = Input::get('copyright');
270
-		$notes = Input::get('notes');
271
-		Log::info($scales);
272
-		Log::info(Input::all());
302
+		$titles = Input::get('titles');
303
+
304
+
273 305
 
274
-		$template->num_scales = count($scales[0]);
306
+		$template->num_scales = count($titles);
275 307
 		$template->max_score = $max_score;
276 308
 		//$division = $max_score / count($scales[0]);
277 309
 
@@ -279,43 +311,57 @@ class TemplatesController extends \BaseController
279 311
 			$templateId = $template->id;
280 312
 			DB::delete("delete from template_criterion where template_id ={$template->id}");
281 313
 			foreach ($criteria as $index => $criterion_id) {
282
-				$copy = $copyright[$index];
283
-				$note = $notes[$index];
284
-				if ($copy == 'Empty') $copy = NULL;
285
-				if ($note == 'Empty') $note = NULL;
286
-				DB::insert("insert into template_criterion (`template_id`,`criterion_id`, `copyright`, `notes`) values ({$templateId},{$criterion_id}, '{$copy}', '{$note}')");
287
-				$template_criterion_id = DB::table('template_criterion')->where('template_id', '=', $templateId)
288
-					->where('criterion_id', '=', $criterion_id)->first();
289
-				DB::delete("delete from template_criterion_scale where template_criterion_id ={$template_criterion_id->id}");
290
-				for ($i = 0; $i < count($scales[$index]); $i++) {
291
-					$scale =  Scale::where('description', '=', $scales[$index][$i])
292
-						//->where('max_score', '=', ($division * ($i + 1)))
293
-						//->where("min_score", '=', (1 + ($division * $i)))
294
-						->first();
295
-					Log::info($scale);
296
-					if ($scale) {
297
-						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
298
-						DB::commit();
299
-					} else {
300
-						$scale = new Scale;
301
-						$scale->description = $scales[$index][$i];
302
-						//$scale->min_score = 1 + ($division * $i);
303
-						//$scale->max_score = ($division * ($i + 1));
304
-						if ($scale->save()) {
305
-							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
306
-							DB::commit();
307
-						} else {
308
-							Session::flash('status', 'danger');
309
-							Session::flash('message', 'Rubric could not be created.');
310
-						}
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;
311 351
 					}
312 352
 				}
313 353
 			}
354
+
355
+
356
+
314 357
 			Session::flash('status', 'success');
358
+
315 359
 			Session::flash('message', 'Rubric updated (' . date('m/d/y, h:i:s a') . ').');
360
+			DB::commit();
316 361
 		} else {
317 362
 			Session::flash('status', 'danger');
318 363
 			Session::flash('message', 'Rubric could not be updated (' . date('m/d/y, h:i:s a') . ').');
364
+			DB::commit();
319 365
 		}
320 366
 	}
321 367
 

+ 45
- 0
app/controllers/TransformativeActionsController.php 파일 보기

@@ -929,4 +929,49 @@ class TransformativeActionsController extends \BaseController
929 929
     }
930 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
 }

+ 1
- 1
app/database/migrations/2021_06_04_003757_create_activities_table.php 파일 보기

@@ -20,7 +20,7 @@ class CreateActivitiesTable extends Migration
20 20
 			//$table->text('outcomes_achieved')->nullable();
21 21
 			//$table->text('outcomes_attempted')->nullable();
22 22
 
23
-			//$table->text('assessment_comments')->nullable();
23
+			$table->text('assessment_comments')->nullable();
24 24
 			//$table->text('transforming_actions')->nullable();
25 25
 			//$table->text('criteria_achieved_percentage')->nullable();
26 26
 

+ 0
- 8
app/models/Title.php 파일 보기

@@ -1,8 +0,0 @@
1
-<?php
2
-
3
-use Illuminate\Database\Eloquent\SoftDeletingTrait;
4
-
5
-class Title extends Eloquent
6
-{
7
-    protected $table = 'titles';
8
-}

+ 6
- 0
app/models/TransformativeAction.php 파일 보기

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

+ 4
- 1
app/routes.php 파일 보기

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

+ 16
- 18
app/views/local/managers/shared/rubrics.blade.php 파일 보기

@@ -783,21 +783,15 @@ function loadTemplate()
783 783
                 }
784 784
                 str+= '</td>';
785 785
                 
786
-                for(scaleIndex in data.scales[current_criterion.id]){
786
+                for(scaleIndex in current_criterion.scales){
787 787
 
788
-                    scale = data.scales[current_criterion.id][scaleIndex];
788
+                    scale = current_criterion.scales[scaleIndex];
789 789
 
790
-                    str+='<td class="editable" data-id-value ="'+scale.scale_id+'" data-type="textarea">'+scale.description+'</td>';
790
+                    str+='<td>'+scale.description+'</td>';
791 791
 
792 792
                 }
793
-                copyright = temp_criterion[temp_c].copyright;
794
-                notes = temp_criterion[temp_c].notes;
795
-                if(copyright == null){
796
-                    copyright = '';
797
-                }
798
-                if(notes==null) notes ='';
799
-                str += '<td class = "editable" data-type = "textarea">'+copyright+'</td>';
800
-                str+= '<td class = "editable" data-type = "textarea">'+notes+'</td>';
793
+                str+= '<td>'+current_criterion.outcomes+'</td>'
794
+  
801 795
                 str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
802 796
 
803 797
     $('table tbody').append(str);
@@ -821,6 +815,7 @@ function loadTemplate()
821 815
 
822 816
             
823 817
             }
818
+
824 819
             /*
825 820
             var contents = JSON.parse(data.contents);
826 821
             contents.forEach(function (data)
@@ -886,13 +881,15 @@ function loadTemplate()
886 881
             // Build Copyright List
887 882
             buildCopyrightList();
888 883
 
884
+            $('.editable').each(function (index){
885
+                $(this).text(data.titles[index].text);
886
+            })
887
+            
889 888
             var selected = $('#select-template').find(':selected');
890
-        var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
889
+            var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
891 890
         
892
-        var template_program = selected.data('template-program-id');
893
-      
891
+            var template_program = selected.data('template-program-id');
894 892
         
895
-
896 893
         if(
897 894
             {{ Auth::user()->role }}==1
898 895
             || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
@@ -1259,10 +1256,11 @@ $('.save').on('click', function(e)
1259 1256
                 expected_points: $('#expected_points').find(':selected').val(),
1260 1257
                 is_visible: $('input[name=is_visible]:checked').val(),
1261 1258
                 criteria : criteria,
1262
-                scales: scales,
1259
+                //scales: scales,
1263 1260
                 max_score : max,
1264
-                copyright :copyright,
1265
-                notes:notes
1261
+                /*copyright : copyright,
1262
+                notes :notes*/
1263
+                titles: titles
1266 1264
             },
1267 1265
             function(data)
1268 1266
             {

+ 121
- 12
app/views/local/professors/activity.blade.php 파일 보기

@@ -61,11 +61,42 @@
61 61
         <h4 class="modal-title">Edit Transforming Actions</h4>
62 62
       </div>
63 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 67
                 <p>A Transforming Action is the educational action to be taken to address the criteria of an unachieved Learning Outcome.</p>
67 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 100
                 <div class="form-group">
70 101
                     {{ Form::label('transforming_actions', 'Transforming Actions') }}
71 102
                     {{ Form::textarea('transforming_actions', $activity->transforming_actions, array('class' => 'form-control', 'rows'=> 4, 'placeholder'=>'Actions to improve student performance after assessment (optional)')) }}
@@ -177,7 +208,7 @@
177 208
                 @endif
178 209
 
179 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 212
                     {{ HTML::linkAction('ActivitiesController@assess', 'Assess', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
182 213
                 @else
183 214
                     {{ HTML::linkAction('ActivitiesController@viewAssessment', 'View Assessment Sheet', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
@@ -185,6 +216,7 @@
185 216
 
186 217
                     <!-- If semester is active, allow users to edit assessments -->
187 218
                     @if (in_array($course->semester->id, $active_semesters))
219
+                    
188 220
                         {{ HTML::linkAction('ActivitiesController@assess', 'Edit Assessment', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
189 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 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,6 +253,83 @@
221 253
 <div class="row">
222 254
     <div class="col-md-12" id="criteriaGraph"></div>
223 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 333
 @stop
225 334
 
226 335
 @section('included-js')
@@ -244,15 +353,15 @@ $(function () {
244 353
     $('#criteriaGraph').highcharts({
245 354
         chart: {
246 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 358
         title: {
250 359
             text: 'Criteria Achievement',
251 360
         },
252 361
         xAxis: {
253 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 365
                         "{{{ Criterion::withTrashed()->find($id)->name }}}",
257 366
                     @endforeach
258 367
                 @endif
@@ -274,14 +383,14 @@ $(function () {
274 383
             title: {
275 384
                 text: 'Percentage'
276 385
             },
277
-            @if(isset($activity->rubric->expected_percentage)  )
386
+            @if(isset($activity->rubric[0]->expected_percentage)  )
278 387
             plotLines:[{
279
-                value:{{ $activity->rubric->expected_percentage }},
388
+                value:{{ $activity->rubric[0]->expected_percentage }},
280 389
                 color: '#000',
281 390
                 width:3,
282 391
                 zIndex:4,
283 392
                 label:{
284
-                    text: 'Goal ({{ $activity->rubric->expected_percentage }}%)',
393
+                    text: 'Goal ({{ $activity->rubric[0]->expected_percentage }}%)',
285 394
                     style: {
286 395
                         color: '#000',
287 396
                         fontSize: '14px',
@@ -327,12 +436,12 @@ $(function () {
327 436
                 y:-1
328 437
             },
329 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 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 445
                         @else
337 446
                             0,
338 447
                         @endif

+ 2
- 2
app/views/local/professors/assessment.blade.php 파일 보기

@@ -25,7 +25,7 @@
25 25
                 <table class="table table-bordered">
26 26
                     <thead id = "criteria-header">;
27 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 29
                         @endfor
30 30
                         <th>Notes</th>
31 31
                     </thead>
@@ -572,7 +572,7 @@ $('.criterion-field').on('click', function()
572 572
         type: 'POST',
573 573
         url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
574 574
         data: {
575
-            rubric_criterion_id: $(this).data('rubric-criterion-id')
575
+            criterion_id: $(this).data('criterion-id')
576 576
         },
577 577
         success: function(data)
578 578
         {

+ 41
- 47
app/views/local/professors/rubrics.blade.php 파일 보기

@@ -84,7 +84,7 @@
84 84
 <div id="rubric-container" class="row">
85 85
   <div class="col-md-12">
86 86
 
87
-    <table class="table">
87
+    <table class="table" style="table-layout: fixed">
88 88
       <thead><tr><th colspan="6 "><h3 id="rubric-name"></h3></th></tr></thead>
89 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 90
       <tbody>
@@ -96,7 +96,7 @@
96 96
       
97 97
 
98 98
       <hr>
99
-      <p class="small"><strong>Outcome Information</strong></p>
99
+      <p class="small"><strong>Copyright Information</strong></p>
100 100
       <ul id="copyright-list" class="list-unstyled small">
101 101
       </ul>
102 102
       <hr>
@@ -114,7 +114,7 @@
114 114
 
115 115
 <script>
116 116
   
117
-function changeTable(){
117
+function changeTable(data){
118 118
     
119 119
  
120 120
             amount_of_scales = parseInt($('#num_of_scales').val());
@@ -126,25 +126,25 @@ function changeTable(){
126 126
             counter = 0;
127 127
             division = maximum/amount_of_scales;
128 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 131
             else if(maximum!= amount_of_scales){
132 132
             while(counter <amount_of_scales){
133 133
                 
134 134
                 minimumScore = 1+(counter*division);
135 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 137
                 counter++;
138 138
             }
139 139
             }else{
140 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 144
                 counter++;
145 145
             }
146 146
             }
147
-            newScaleHeaders += '<th>Copyright</th><th>Notes</th>';
147
+            newScaleHeaders += '<th>Outcomes</th>';
148 148
             
149 149
             $("#criterion-header").html(newScaleHeaders);
150 150
             
@@ -214,7 +214,7 @@ function fetchCriteria(outcome)
214 214
 }
215 215
 
216 216
 // Build list from copyright info in rubric
217
-function buildOutcomeList()
217
+function buildCopyrightList()
218 218
 {
219 219
     // Empty the copyright list
220 220
     $('#copyright-list').empty();
@@ -223,22 +223,22 @@ function buildOutcomeList()
223 223
     {
224 224
         var criterion = $(this);
225 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 228
             if($('#copyright-list li').length>0)
229 229
             {
230 230
                 var found = false;
231 231
                 $('#copyright-list li').each(function()
232 232
                 {
233 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 237
                         copyrightNumber = Number.parseInt($(this).find('sup').text());
238 238
 
239 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 242
                         found =true;
243 243
 
244 244
                         //to break
@@ -253,16 +253,16 @@ function buildOutcomeList()
253 253
                     var copyrightNumber = $('#copyright-list li').length+1;
254 254
 
255 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 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,7 +297,7 @@ function loadTemplate()
297 297
             $('#expected_points').text(data.template.expected_points)
298 298
             $('#max').val(data.template.max_score);
299 299
             $('#num_of_scales').val(data.template.num_scales);
300
-            changeTable();
300
+            changeTable(data);
301 301
 
302 302
 
303 303
             // Set the contents of the rubric
@@ -324,26 +324,19 @@ function loadTemplate()
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 335
                 str+='</tr>';
343
-
336
+               
344 337
     $('table tbody').append(str);
345 338
 
346
-    buildOutcomeList();
339
+    buildCopyrightList();
347 340
 
348 341
                 
349 342
 
@@ -394,7 +387,7 @@ function loadTemplate()
394 387
                 $('table tbody').append(str);
395 388
 
396 389
                 // Build copyright list
397
-                buildOutcomeList();
390
+                buildCopyrightList();
398 391
 
399 392
                 // Enable X-Edtable on this new row
400 393
                 $('.editable').editable({
@@ -412,7 +405,7 @@ function loadTemplate()
412 405
           
413 406
 
414 407
             // Build Copyright List
415
-            buildOutcomeList();
408
+            buildCopyrightList();
416 409
         }, 
417 410
         'json',
418 411
     );
@@ -473,7 +466,7 @@ function loadTemplate()
473 466
       });
474 467
 
475 468
       // Build Copyright List
476
-      buildOutcomeList();
469
+      buildCopyrightList();
477 470
     }
478 471
   );
479 472
 }
@@ -502,7 +495,7 @@ $('#button-save-rubric').on('click', function(e)
502 495
   e.preventDefault();
503 496
 
504 497
   var criteria = [];
505
-  scales = [];
498
+  var titles =  [];
506 499
   max_score = $('#max').val();
507 500
 
508 501
   // For each criterion in the rubric, get its value and put it into an array
@@ -510,15 +503,8 @@ $('#button-save-rubric').on('click', function(e)
510 503
   {
511 504
 
512 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 509
       criterionObject.id = $(this).data('criterion-id');
524 510
       criterionObject.outcome_id = $(this).data('assoc-outcome-id');
@@ -542,8 +528,16 @@ each_criterion_scale.pop();
542 528
       var clone = jQuery.extend({}, criterionObject);
543 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 541
   // If activity does not have a rubric, create it
548 542
   if($('#assigned_rubric').length === 0)
549 543
   {
@@ -560,7 +554,7 @@ each_criterion_scale.pop();
560 554
         expected_percentage: $('#expected_percentage').text(),
561 555
         expected_points: $('#expected_points').text(),
562 556
         criteria: criteria,
563
-        scales: scales,
557
+        titles:titles,
564 558
         max_score:max_score
565 559
 
566 560
 
@@ -586,7 +580,7 @@ each_criterion_scale.pop();
586 580
         expected_percentage: $('#expected_percentage').text(),
587 581
         expected_points: $('#expected_points').text(),
588 582
         criteria: criteria,
589
-        scales: scales,
583
+        titles:titles,
590 584
         max_score:max_score
591 585
       },
592 586
       function(data)

+ 93
- 18
app/views/local/professors/view_assessment.blade.php 파일 보기

@@ -54,13 +54,34 @@
54 54
 
55 55
 
56 56
         <table id="assessment-table" class="table table-striped table-condensed table-bordered">
57
+            
57 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 77
                     <tr>
59 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 81
                         @endforeach
63 82
                         <th>Student Percentage</th>
83
+                        <th>Student % Per Weight</th>
84
+                        <th>Comments</th>
64 85
                     </tr>
65 86
             </thead>
66 87
             <tbody>
@@ -68,22 +89,28 @@
68 89
             <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
69 90
             @if(sizeof($assessments)!=0)
70 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 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 114
             @endif
88 115
             </tbody>
89 116
             <tfoot>
@@ -91,7 +118,7 @@
91 118
                     <td>
92 119
                         <strong>Passed Criteria Percentage </strong>
93 120
                     </td>
94
-                    @for ($i = 0; $i<sizeof($rubric_contents); $i++)
121
+                    @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
95 122
                         <td class="total text-center"><strong><span class="total-value"></span>%</strong>
96 123
                         </td>
97 124
                     @endfor
@@ -102,7 +129,13 @@
102 129
         </table>
103 130
     </div>
104 131
 </div>
132
+<input type='hidden' value = {{$rubric->max_score}} id = "max">
133
+
134
+<script>
135
+
136
+
105 137
 
138
+    </script>
106 139
 @stop
107 140
 
108 141
 @section('included-js')
@@ -177,7 +210,7 @@ function percentagePerCriterionPlain(columnIndex)
177 210
 // Calculate total for a specific student
178 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 214
     var sum = 0 ;
182 215
     var total = 0;
183 216
     var percentage = 0;
@@ -199,6 +232,48 @@ function percentagePerStudentPlain(row)
199 232
         percentage="0.00";
200 233
 
201 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 파일 보기

@@ -33,7 +33,7 @@
33 33
             <th></th>
34 34
             <th>Criterion</th>
35 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 37
             @endfor
38 38
             <th>Learning Outcome</th>
39 39
           </tr>