Przeglądaj źródła

Squashed commit of the following:

commit f75627ee58
Author: Gabriel A. Santiago Plaza <gabriel.santiago21@upr.edu>
Date:   Fri Jun 25 17:13:57 2021 -0400

    Antes de volver al merge

commit 025103dc98
Author: Gabriel A. Santiago Plaza <gabriel.santiago21@upr.edu>
Date:   Tue Jun 22 15:58:10 2021 -0400

    sE ACAbo ese juego

commit 996d4d8f12
Merge: 6592b0a 02d188a
Author: Gabriel A. Santiago Plaza <gabriel.santiago21@upr.edu>
Date:   Tue Jun 22 14:51:04 2021 -0400

    Merge branch 'Merge_gabriel_mayo' into ANTES-DE-MEZCLAR

commit 6592b0a485
Author: Gabriel A. Santiago Plaza <gabriel.santiago21@upr.edu>
Date:   Tue Jun 22 11:12:34 2021 -0400

    ANtes de terminar assessment

commit 25016ca2d3
Author: Gabriel A. Santiago Plaza <gabriel.santiago21@upr.edu>
Date:   Sun Jun 20 13:41:34 2021 -0400

    Cambioos a rubrics, y poco de assessment
rodzic
commit
2c2cc2494e

+ 1
- 0
.gitignore Wyświetl plik

@@ -12,3 +12,4 @@ app/config/app.php
12 12
 app/config/database.php
13 13
 node_modules/
14 14
 app/config/
15
+app/controllers/AuthController.php

+ 75
- 9
app/controllers/ActivitiesController.php Wyświetl plik

@@ -169,22 +169,48 @@ class ActivitiesController extends \BaseController
169 169
         Log::info($activity);
170 170
         $criterion_rubric = DB::table('criteria')
171 171
             ->join("criterion_rubric", "criterion_rubric.criterion_id", "=", "criteria.id")
172
-            ->where('criterion_rubric.rubric_id', '=', $rubric->id)->get();
172
+            ->join("activity_criterion", "criteria.id", '=', 'activity_criterion.criterion_id')
173
+            ->where("activity_criterion.activity_id", '=', $activity->id)
174
+            ->where('criterion_rubric.rubric_id', '=', $rubric->id)
175
+            ->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')
177
+            ->addSelect('criterion_rubric.rubric_id', 'criterion_rubric.id as rubric_criterion_id')
178
+            ->addSelect('criterion_rubric.copyright', 'criterion_rubric.notes')
179
+            ->get();
180
+        Log::info($criterion_rubric);
181
+        foreach ($criterion_rubric 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)
184
+                ->orderBy('position')
185
+                ->lists('description'));
186
+        }
187
+        $criterion_rubric_ids = DB::table('criterion_rubric')->where('rubric_id', '=', $rubric->id)->lists('id');
173 188
         Log::info($rubric);
174 189
         Log::info($criterion_rubric);
175 190
 
176
-        $rubric_contents = json_decode($rubric->contents);
177 191
 
178
-        // Get results
179
-        $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
180 192
 
193
+
194
+
195
+        // Get results
196
+        $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
197
+        Log::info($activity_criterion_ids);
198
+        $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->whereIn('activity_criterion_id', $activity_criterion_ids)->orderBy('assessments.id', 'asc')->get();
199
+        Log::info($assessments);
181 200
         // Decode the scores (blade workaround)
182 201
         $scores_array = array();
202
+
183 203
         foreach ($assessments as $index => $assessment) {
184
-            $scores_array[$assessment->id] = json_decode($assessment->scores, true);
204
+            $scores_array[$assessment->student_id][$index] = $assessment->score;
205
+            $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
206
+                ->where("activity_id", '=', $activity->id)
207
+                ->select('comments')->first()->comments;
185 208
         }
186 209
 
187
-        return View::make('local.professors.assessment', compact('activity', 'title', 'students', 'course', 'rubric_contents', 'assessments', 'scores_array', 'rubric'));
210
+        Log::info($scores_array);
211
+
212
+
213
+        return View::make('local.professors.assessment', compact('activity', 'title', 'students', 'course', 'criterion_rubric', 'assessments', 'scores_array', 'rubric'));
188 214
     }
189 215
 
190 216
     public function saveAssessment()
@@ -193,9 +219,49 @@ class ActivitiesController extends \BaseController
193 219
             $exception = DB::transaction(function () {
194 220
                 DB::transaction(function () {
195 221
                     // Student assessment data
196
-                    $student_data = json_decode(Input::get('student_scores'));
197 222
 
223
+                    $activity_id = Input::get('activity_id');
224
+                    $student_data = json_decode(Input::get('student_info'));
225
+                    $weights = json_decode(Input::get('weights'));
226
+                    Log::info(json_encode($weights));
227
+                    Log::info(json_encode($student_data));
228
+
229
+                    foreach ($student_data as $index => $student_dict) {
230
+                        $student_id = $student_dict->studentId;
231
+                        foreach ($student_dict->activity_crit_id as $act_crit_id => $score) {
232
+                            if (DB::table('assessments')->where('student_id', '=', $student_id)
233
+                                ->where('activity_criterion_id', '=', $act_crit_id)
234
+                                ->first()
235
+                            ) {
236
+                                DB::table('assessments')->where('student_id', '=', $student_id)
237
+                                    ->where('activity_criterion_id', '=', $act_crit_id)
238
+                                    ->update(array('score' => $score));
239
+                            } else {
240
+                                DB::insert("insert into assessments (`activity_criterion_id`, `student_id`, `score`) values ({$act_crit_id}, {$student_id}, {$score})");
241
+                            }
242
+                        }
243
+                        if (DB::table('activity_student')
244
+                            ->where('student_id', '=', $student_id)->where('activity_id', '=', $activity_id)
245
+                            ->first()
246
+                        ) {
247
+                            DB::table('activity_student')
248
+                                ->where('student_id', '=', $student_id)->where('activity_id', '=', $activity_id)
249
+                                ->update(array('comments' => $student_dict->comments));
250
+                        } else {
251
+                            DB::insert("insert into activity_student (`activity_id`, `student_id`, `comments`) values ({$activity_id}, {$student_id}, '{$student_dict->comments}')");
252
+                        }
253
+                    }
254
+                    $activity_draft = Input::get('draft');
255
+
256
+                    foreach ($weights as $act_crit => $weigh) {
257
+                        DB::update("update activity_criterion set weight = {$weigh} where id = {$act_crit}");
258
+                    }
259
+                    DB::update("update activities set draft = {$activity_draft} where id = {$activity_id}");
198 260
                     // Outcome count
261
+                    Session::flash('status', 'success');
262
+                    Session::flash('message', 'Assessment Saved. To add transforming actions click "Transforming Actions".');
263
+                    return action('ActivitiesController@show', array(Input::get('activity_id')));
264
+
199 265
                     $outcomeCount = Outcome::all()->count();
200 266
 
201 267
 
@@ -215,9 +281,9 @@ class ActivitiesController extends \BaseController
215 281
                             }
216 282
 
217 283
                             // Add the assessment to the pivot table
284
+
218 285
                             $student->assessed_activities()->attach($activity->id, array(
219 286
                                 'scores' => json_encode($single_student_data->scores),
220
-                                'percentage' => $single_student_data->percentage,
221 287
                                 'comments' => $single_student_data->comments
222 288
                             ));
223 289
                         }
@@ -676,7 +742,7 @@ class ActivitiesController extends \BaseController
676 742
         $rubric_contents = Rubric::select('contents')->where('id', '=', $activity->rubric_id)->get();
677 743
         $rubric_contents = json_decode($rubric_contents['0']->contents);
678 744
 
679
-        $rubric = Rubric::find($activity->rubric_id);
745
+        $rubric = Rubric::find($activity->rubric[0]->id);
680 746
 
681 747
         // Get results
682 748
         $assessments = DB::table('assessments')->where('activity_id', '=', $activity->id)->orderBy('id', 'asc')->get();

+ 5
- 1
app/controllers/CriteriaController.php Wyświetl plik

@@ -54,6 +54,10 @@ class CriteriaController extends \BaseController
54 54
     {
55 55
         $json_to_send = array();
56 56
         $json_to_send['criterion'] = DB::table('criteria')->where('id', '=', Input::get('id'))->first();
57
+        $num_scales = Input::get('numberOfScale');
58
+        $criterionID = Input::get('id');
59
+        $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");
60
+        Log::info("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");
57 61
 
58 62
 
59 63
 
@@ -63,8 +67,8 @@ class CriteriaController extends \BaseController
63 67
     public function fetchCriterion()
64 68
     {
65 69
         $json_to_send = array();
66
-        $json_to_send['criterion'] = DB::table('criteria')->where('id', '=', Input::get('id'))->first();
67 70
 
71
+        $json_to_send['criterion'] = DB::table('criteria')->where('id', '=', Input::get('id'))->first();
68 72
 
69 73
 
70 74
 

+ 193
- 82
app/controllers/RubricsController.php Wyświetl plik

@@ -33,6 +33,9 @@ class RubricsController extends \BaseController
33 33
         $outcomes = Outcome::orderBy('name', 'ASC')->get();
34 34
         $criteria = Criterion::orderBy('name', 'ASC')->get();
35 35
         $rubric = $activity->rubric;
36
+        Log::info($rubric);
37
+        Log::info($activity->rubric_id);
38
+        Log::info($activity->rubric[0]->id);
36 39
 
37 40
         return View::make('local.professors.rubrics', compact('title', 'templates', 'outcomes', 'criteria', 'rubrics', 'activity', 'rubric'));
38 41
     }
@@ -91,7 +94,8 @@ class RubricsController extends \BaseController
91 94
         $rubric->user_id = Auth::id();
92 95
         $rubric->num_scales = count($scales[0]);
93 96
         $rubric->max_score = Input::get('max_score');
94
-        $division = $rubric->max_score / count($scales[0]);
97
+        $defaultWeight = round(100 / $rubric->num_scales, 2);
98
+
95 99
         if ($rubric->save()) {
96 100
 
97 101
             // Process activity
@@ -105,21 +109,35 @@ class RubricsController extends \BaseController
105 109
             $rubricId = $rubric->id;
106 110
             foreach ($criteria as $index => $criterion_id) {
107 111
                 DB::insert("insert into criterion_rubric (`rubric_id`,`criterion_id`) values ({$rubricId},{$criterion_id})");
112
+                DB::commit();
108 113
                 $rubric_criterion_id = DB::table('criterion_rubric')->where('rubric_id', '=', $rubricId)
109 114
                     ->where('criterion_id', '=', $criterion_id)->first();
110 115
 
116
+
117
+
111 118
                 for ($i = 0; $i < count($scales[$index]); $i++) {
112
-                    $scale = new Scale;
113
-                    $scale->description = $scales[$index][$i];
114
-                    $scale->min_score = 1 + ($division * $i);
115
-                    $scale->max_score = ($division * ($i + 1));
116
-                    if ($scale->save()) {
119
+                    $scale =  Scale::where('description', '=', $scales[$index][$i])->first();
120
+                    Log::info($scale);
121
+                    if ($scale) {
117 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();
118 124
                     } else {
119
-                        Session::flash('status', 'danger');
120
-                        Session::flash('message', 'Rubric could not be created.');
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
+                        }
121 135
                     }
122 136
                 }
137
+
138
+                $activity_id = Input::get("activity_id");
139
+                DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity_id}, {$criterion_id}, {$defaultWeight})");
140
+                DB::commit();
123 141
             }
124 142
             Session::flash('status', 'success');
125 143
             Session::flash('message', 'Rubric assigned.');
@@ -150,94 +168,159 @@ class RubricsController extends \BaseController
150 168
      */
151 169
     public function update()
152 170
     {
171
+        Log::info('entré???');
153 172
         $rubric = Rubric::find(Input::get('id'));
173
+
174
+        $scales = Input::get('scales');
175
+        $criteria = Input::get('criteria');
176
+
177
+        // Process rubric
154 178
         $rubric->name = Input::get('name');
155 179
 
156 180
         $rubric->expected_percentage = Input::get('expected_percentage');
157 181
         $rubric->expected_points = Input::get('expected_points');
158 182
 
183
+        $rubric->num_scales = count($scales[0]);
184
+        $rubric->max_score = Input::get('max_score');
185
+        $defaultWeight = round(100 / $rubric->num_scales, 2);
186
+
187
+
159 188
         DB::beginTransaction();
160 189
 
161
-        try {
162
-            // Get associated activity
163
-            $activity = Activity::where('rubric_id', '=', $rubric->id)->first();
164 190
 
165
-            // If the associated activity has been assessed, delete the records
191
+        // Get associated activity
192
+        //$activity = Activity::where('rubric_id', '=', $rubric->id)->first();
193
+
194
+        $activity_id = DB::table('activities')
195
+            ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
196
+            ->where('rubric_id', '=', $rubric->id)
197
+            ->first();
198
+
199
+        $activity = Activity::where('id', '=', $activity_id->activity_id)->first();
200
+
201
+
202
+
203
+        // If the associated activity has been assessed, delete the records
204
+        if ($activity->outcomes_attempted != NULL) {
205
+            DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
206
+            $activity->criteria_achieved_percentage = NULL;
207
+            $activity->criteria_achieved = NULL;
208
+            $activity->outcomes_achieved = NULL;
209
+            $activity->outcomes_attempted = NULL;
210
+        }
211
+        Log::info('entré3???');
212
+
213
+        $rubric->save();
214
+        Log::info("????");
215
+        $activity->save();
216
+        Log::info("????22");
217
+        // Get all the course's activities
218
+        Log::info($activity->course);
219
+        $course = Course::find($activity->course->id);
220
+        $activities = $course->activities;
221
+
222
+        // Check if any assessed activities remain
223
+        $remainingAssessed = false;
224
+        foreach ($course->activities as $activity) {
166 225
             if ($activity->outcomes_attempted != NULL) {
167
-                DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
168
-                $activity->criteria_achieved_percentage = NULL;
169
-                $activity->criteria_achieved = NULL;
170
-                $activity->outcomes_achieved = NULL;
171
-                $activity->outcomes_attempted = NULL;
226
+                $remainingAssessed = true;
227
+                break;
172 228
             }
229
+        }
230
+        Log::info('entré4???');
173 231
 
174
-            $rubric->save();
175
-            $activity->save();
176
-
177
-            // Get all the course's activities
178
-            $course = Course::find($activity->course->id);
179
-            $activities = $course->activities;
232
+        //If there are still evaluated activities in the course, recalculate course outcomes
233
+        if (!$activities->isEmpty() && $remainingAssessed) {
234
+            // Variables to hold recalculated outcomes for the course
235
+            $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
236
+            $course_outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
180 237
 
181
-            // Check if any assessed activities remain
182
-            $remainingAssessed = false;
183
-            foreach ($course->activities as $activity) {
238
+            // For each activity
239
+            foreach ($activities as $activity) {
240
+                // If activity has been assessed
184 241
                 if ($activity->outcomes_attempted != NULL) {
185
-                    $remainingAssessed = true;
186
-                    break;
242
+                    // Get the achieved criteria
243
+                    $criteria_achievement = json_decode($activity->criteria_achieved, true);
244
+                    foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
245
+                        // Find corresponding learning outcome;
246
+                        $criterion = Criterion::find($criterion_id);
247
+                        $outcome = Outcome::find($criterion->outcome_id);
248
+
249
+                        // If criterion is achieved (1), add 1 to both arrays
250
+                        if ($criterion_achieved === 1) {
251
+                            $course_outcomes_attempted[$outcome->id] += 1;
252
+                            $course_outcomes_achieved[$outcome->id] += 1;
253
+                        }
254
+                        // Else, only add to the attempted outcomes arrays
255
+                        elseif ($criterion_achieved === 0) {
256
+                            $course_outcomes_attempted[$outcome->id] += 1;
257
+                        }
258
+                    }
187 259
                 }
188 260
             }
261
+            Log::info('entré5???');
262
+            // Update course
263
+            $course->outcomes_achieved = json_encode($course_outcomes_achieved);
264
+            $course->outcomes_attempted = json_encode($course_outcomes_attempted);
265
+        } else {
266
+            // Update course
267
+            $course->outcomes_achieved = NULL;
268
+            $course->outcomes_attempted = NULL;
269
+        }
189 270
 
190
-            //If there are still evaluated activities in the course, recalculate course outcomes
191
-            if (!$activities->isEmpty() && $remainingAssessed) {
192
-                // Variables to hold recalculated outcomes for the course
193
-                $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
194
-                $course_outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
195
-
196
-                // For each activity
197
-                foreach ($activities as $activity) {
198
-                    // If activity has been assessed
199
-                    if ($activity->outcomes_attempted != NULL) {
200
-                        // Get the achieved criteria
201
-                        $criteria_achievement = json_decode($activity->criteria_achieved, true);
202
-                        foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
203
-                            // Find corresponding learning outcome;
204
-                            $criterion = Criterion::find($criterion_id);
205
-                            $outcome = Outcome::find($criterion->outcome_id);
206
-
207
-                            // If criterion is achieved (1), add 1 to both arrays
208
-                            if ($criterion_achieved === 1) {
209
-                                $course_outcomes_attempted[$outcome->id] += 1;
210
-                                $course_outcomes_achieved[$outcome->id] += 1;
211
-                            }
212
-                            // Else, only add to the attempted outcomes arrays
213
-                            elseif ($criterion_achieved === 0) {
214
-                                $course_outcomes_attempted[$outcome->id] += 1;
215
-                            }
271
+        $course->save();
272
+        Log::info('entré6???');
273
+        DB::delete("delete from criterion_rubric where rubric_id ={$rubric->id}");
274
+        DB::delete("delete from activity_criterion where activity_id = {$activity->id}");
275
+        foreach ($criteria as $index => $criterion_id) {
276
+            if (
277
+
278
+                DB::insert("insert into criterion_rubric (`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('criterion_rubric')
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));
216 305
                         }
217 306
                     }
218 307
                 }
219
-
220
-                // Update course
221
-                $course->outcomes_achieved = json_encode($course_outcomes_achieved);
222
-                $course->outcomes_attempted = json_encode($course_outcomes_attempted);
223 308
             } else {
224
-                // Update course
225
-                $course->outcomes_achieved = NULL;
226
-                $course->outcomes_attempted = NULL;
309
+                DB::rollBack();
310
+                Session::flash('status', 'danger');
311
+                Session::flash('message', 'Rubric could not be created.');
312
+                return action('ActivitiesController@show', array($activity->id));
227 313
             }
314
+        }
315
+        Log::info('entré7???');
228 316
 
229
-            $course->save();
230
-            DB::commit();
317
+        DB::commit();
231 318
 
232
-            Session::flash('status', 'success');
233
-            Session::flash('message', 'Rubric updated.');
234 319
 
235
-            return action('ActivitiesController@show', array($activity->id));
236
-        } catch (Exception $e) {
237
-            DB::rollBack();
238
-            Session::flash('status', 'danger');
239
-            Session::flash('message', 'Error: The rubric could not be updated. Try again later.');
240
-        }
320
+        Session::flash('status', 'success');
321
+        Session::flash('message', 'Rubric updated.');
322
+
323
+        return action('ActivitiesController@show', array($activity->id));
241 324
     }
242 325
 
243 326
     /**
@@ -277,8 +360,28 @@ class RubricsController extends \BaseController
277 360
         Log::info($activity->rubric[0]->id);
278 361
 
279 362
         $rubric = Rubric::where('id', '=', $activity->rubric[0]->id)->firstOrFail();
363
+        $criterion_rubric = DB::table('criteria')
364
+            ->join('criterion_rubric', 'criterion_rubric.criterion_id', '=', 'criteria.id')
365
+            ->where('criterion_rubric.rubric_id', '=', $activity->rubric[0]->id)
366
+            ->get();
367
+        Log::info($criterion_rubric);
368
+
369
+        foreach ($criterion_rubric as $single_cr) {
370
+            $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)
373
+                ->orderBy('position')
374
+                ->lists('description'));
375
+            $single_cr->outcomes = json_encode(DB::table('outcomes')
376
+                ->join('criterion_objective_outcome', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
377
+                ->where('criterion_objective_outcome.criterion_id', '=', $single_cr->criterion_id)->lists('name'));
378
+        }
379
+
380
+
381
+        Log::info($criterion_rubric);
382
+
280 383
         $title = $activity->name . ': ' . $rubric->name;
281
-        return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'title', 'course'));
384
+        return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'criterion_rubric', 'title', 'course'));
282 385
     }
283 386
 
284 387
     /**
@@ -330,15 +433,23 @@ class RubricsController extends \BaseController
330 433
 
331 434
     public function fetchRubricCriterion()
332 435
     {
333
-        $rubric = Rubric::findOrFail(Input::get('rubric_id'));
334
-        $criterion_id = Input::get('criterion_id');
335
-
336
-        $rubric_contents = json_decode($rubric->contents);
337
-
338
-        foreach ($rubric_contents as $key => $criterion) {
339
-            if ($criterion->id == $criterion_id) {
340
-                return json_encode($criterion);
341
-            }
342
-        }
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();
439
+        Log::info($rubric);
440
+
441
+        $rubric["criteria"] = DB::table("criteria")
442
+            ->join("criterion_rubric", 'criterion_rubric.criterion_id', '=', 'criteria.id')
443
+            ->where("criterion_rubric.id", '=', Input::get('rubric_criterion_id'))
444
+            ->select('name', 'criterion_rubric.notes')
445
+            ->first();
446
+        return json_encode($rubric);
447
+
448
+        //$rubric_contents = json_decode($rubric->contents);
449
+
450
+        //foreach ($rubric_contents as $key => $criterion) {
451
+        //    if ($criterion->id == $criterion_id) {
452
+        //        return json_encode($criterion);
453
+        //    }
343 454
     }
344 455
 }

+ 34
- 16
app/controllers/TemplatesController.php Wyświetl plik

@@ -145,7 +145,7 @@ class TemplatesController extends \BaseController
145 145
 
146 146
 		$template->num_scales = count($scales[0]);
147 147
 		$template->max_score = $max_score;
148
-		$division = $max_score / count($scales[0]);
148
+
149 149
 		if ($template->save()) {
150 150
 			$templateId = $template->id;
151 151
 			foreach ($criteria as $index => $criterion_id) {
@@ -154,15 +154,22 @@ class TemplatesController extends \BaseController
154 154
 					->where('criterion_id', '=', $criterion_id)->first();
155 155
 
156 156
 				for ($i = 0; $i < count($scales[$index]); $i++) {
157
-					$scale = new Scale;
158
-					$scale->description = $scales[$index][$i];
159
-					$scale->min_score = 1 + ($division * $i);
160
-					$scale->max_score = ($division * ($i + 1));
161
-					if ($scale->save()) {
157
+					$scale =  Scale::where('description', '=', $scales[$index][$i])->first();
158
+					Log::info($scale);
159
+					if ($scale) {
162 160
 						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
161
+						DB::commit();
163 162
 					} else {
164
-						Session::flash('status', 'danger');
165
-						Session::flash('message', 'Rubric could not be created.');
163
+						$scale = new Scale;
164
+						$scale->description = $scales[$index][$i];
165
+
166
+						if ($scale->save()) {
167
+							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
168
+							DB::commit();
169
+						} else {
170
+							Session::flash('status', 'danger');
171
+							Session::flash('message', 'Rubric could not be created.');
172
+						}
166 173
 					}
167 174
 				}
168 175
 			}
@@ -251,7 +258,7 @@ class TemplatesController extends \BaseController
251 258
 		Log::info(Input::all());
252 259
 		$template->num_scales = count($scales[0]);
253 260
 		$template->max_score = $max_score;
254
-		$division = $max_score / count($scales[0]);
261
+		//$division = $max_score / count($scales[0]);
255 262
 
256 263
 		if ($template->save()) {
257 264
 			$templateId = $template->id;
@@ -263,15 +270,26 @@ class TemplatesController extends \BaseController
263 270
 					->where('criterion_id', '=', $criterion_id)->first();
264 271
 				DB::delete("delete from template_criterion_scale where template_criterion_id ={$template_criterion_id->id}");
265 272
 				for ($i = 0; $i < count($scales[$index]); $i++) {
266
-					$scale = new Scale;
267
-					$scale->description = $scales[$index][$i];
268
-					$scale->min_score = 1 + ($division * $i);
269
-					$scale->max_score = ($division * ($i + 1));
270
-					if ($scale->save()) {
273
+					$scale =  Scale::where('description', '=', $scales[$index][$i])
274
+						//->where('max_score', '=', ($division * ($i + 1)))
275
+						//->where("min_score", '=', (1 + ($division * $i)))
276
+						->first();
277
+					Log::info($scale);
278
+					if ($scale) {
271 279
 						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
280
+						DB::commit();
272 281
 					} else {
273
-						Session::flash('status', 'danger');
274
-						Session::flash('message', 'Rubric could not be created.');
282
+						$scale = new Scale;
283
+						$scale->description = $scales[$index][$i];
284
+						//$scale->min_score = 1 + ($division * $i);
285
+						//$scale->max_score = ($division * ($i + 1));
286
+						if ($scale->save()) {
287
+							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
288
+							DB::commit();
289
+						} else {
290
+							Session::flash('status', 'danger');
291
+							Session::flash('message', 'Rubric could not be created.');
292
+						}
275 293
 					}
276 294
 				}
277 295
 			}

+ 34
- 0
app/database/migrations/2021_06_22_150017_delete_min_max_scales.php Wyświetl plik

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

+ 41
- 0
app/database/migrations/2021_06_22_150108_add_copyright_notes_rubric_criterion.php Wyświetl plik

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class AddCopyrightNotesRubricCriterion extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('criterion_rubric', function (Blueprint $table) {
18
+			$table->text('copyright')->nullable();
19
+			$table->text('notes')->nullable();
20
+		});
21
+		Schema::table('template_criterion', function (Blueprint $table) {
22
+			$table->text('copyright')->nullable();
23
+			$table->text('notes')->nullable();
24
+		});
25
+	}
26
+
27
+	/**
28
+	 * Reverse the migrations.
29
+	 *
30
+	 * @return void
31
+	 */
32
+	public function down()
33
+	{
34
+		Schema::table('criterion_rubric', function (Blueprint $table) {
35
+			$table->dropColumn(array('copyright', 'notes'));
36
+		});
37
+		Schema::table('template_criterion', function (Blueprint $table) {
38
+			$table->dropColumn(array('copyright', 'notes'));
39
+		});
40
+	}
41
+}

+ 34
- 0
app/database/migrations/2021_06_22_150135_change_weight_float.php Wyświetl plik

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class ChangeWeightFloat extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('activity_criterion', function (Blueprint $table) {
17
+
18
+			DB::statement("ALTER TABLE `activity_criterion` MODIFY COLUMN `weight` decimal(6,2)");
19
+		});
20
+	}
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::table('activity_criterion', function (Blueprint $table) {
30
+
31
+			DB::statement("ALTER TABLE `activity_criterion` MODIFY COLUMN `weight` decimal(3,2)");
32
+		});
33
+	}
34
+}

+ 0
- 3
app/models/Scale.php Wyświetl plik

@@ -4,9 +4,6 @@ use Illuminate\Database\Eloquent\SoftDeletingTrait;
4 4
 
5 5
 class Scale extends Eloquent
6 6
 {
7
-    use SoftDeletingTrait;
8
-    protected $dates = ['deleted_at'];
9
-
10 7
     protected $table = 'scales';
11 8
 
12 9
     public function outcomes()

+ 2
- 1
app/models/Student.php Wyświetl plik

@@ -16,6 +16,7 @@ class Student extends Eloquent
16 16
 
17 17
   public function assessed_activities()
18 18
   {
19
-  	return $this->belongsToMany('Activity', 'assessments')->withPivot('scores', 'percentage')->withTimestamps();
19
+    //return $this->belongsToMany('Activity', 'assessments')->withPivot('scores', 'percentage')->withTimestamps();
20
+    return $this->belongsToMany('Activity', 'assessments')->withPivot('scores')->withTimestamps();
20 21
   }
21 22
 }

+ 11
- 2
app/views/local/managers/shared/rubrics.blade.php Wyświetl plik

@@ -371,6 +371,7 @@ function addCriterion()
371 371
 
372 372
     // Check for duplicates
373 373
     var duplicates=false;
374
+    numberOfScale = $('#number_of_scales').find(':selected').val();
374 375
     $('tbody tr').each(function()
375 376
     {
376 377
         if ($(this).data('criterion-id') == id)
@@ -398,7 +399,8 @@ function addCriterion()
398 399
     $.post
399 400
     (
400 401
         "{{ URL::route('fetchCriterionWithTemplate') }}",
401
-        { id: id},
402
+        { id: id,
403
+        numberOfScale: numberOfScale },
402 404
         function(data)
403 405
         {
404 406
             // Append the fetched data
@@ -425,10 +427,17 @@ function addCriterion()
425 427
                 str+='<span>'+data.criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
426 428
             }
427 429
             numberOfScale = $('#number_of_scales').find(':selected').val();
430
+            if(data.scales.length)
428 431
             for(i=0; i<numberOfScale; i++){
429
-                str+='<td class="editable" data-type="textarea"></td>';
432
+                str+='<td class="editable" data-type="textarea">'+data.scales[i].description+'</td>';
433
+                
430 434
           
431 435
             }
436
+            else{
437
+                for(i=0; i<numberOfScale; i++){
438
+                str+='<td class="editable" data-type="textarea"></td>';
439
+            }
440
+        }
432 441
 
433 442
             str +='<th><span class="glyphicon glyphicon-remove icon-btn" aria-hidden="true"></span></th></tr>';
434 443
 

+ 210
- 170
app/views/local/professors/assessment.blade.php Wyświetl plik

@@ -23,15 +23,17 @@
23 23
             </div>
24 24
             <div class="modal-body">
25 25
                 <table class="table table-bordered">
26
-                    <thead>
27
-                        <th>Beginning (1-2)</th>
28
-                        <th>In Progress (3-4)</th>
29
-                        <th>Good (5-6)</th>
30
-                        <th>Excellent (7-8)</th>
26
+                    <thead id = "criteria-header">;
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>
29
+                        @endfor
31 30
                         <th>Notes</th>
32 31
                     </thead>
33 32
                     <tbody>
34
-                        <tr></tr>
33
+                        <tr>
34
+                            
35
+                            
36
+                        </tr>
35 37
                     </tbody>
36 38
                 </table>
37 39
             </div>
@@ -59,8 +61,8 @@
59 61
                     <li>If a particular criterion was assessed but the student did not complete the necessary work, you must select "0". This <strong>will</strong> affect the student's score.</li>
60 62
                     <li>If a student did not complete any work for this activity, select "0" for all columns in that student's row.</li>
61 63
                     <li>If a student dropped the class, select "N/A" (Not Applicable) for all columns in that student's row.</li>
62
-                    <li>Cells with "N/A" <strong>will not</strong> be used to determine whether a criterion is achieved. Only scores from 0 to 8 will be considered for this purpose.</li>
63
-                    <li><strong>At least one score must be from 1-8.</strong> Otherwise, the 'Publish Assessment' and 'Save as Draft' buttons will be <strong>disabled</strong>. If you want to delete previously saved scores, go back to the activity and click the "Delete Assessment" button.</li>
64
+                    <li>Cells with "N/A" <strong>will not</strong> be used to determine whether a criterion is achieved. Only scores from 0 to {{$rubric->max_score}} will be considered for this purpose.</li>
65
+                    <li>For this activity, <strong>at least one score must be from 1-{{$rubric->max_score}}.</strong> Otherwise, the 'Publish Assessment' and 'Save as Draft' buttons will be <strong>disabled</strong>. If you want to delete previously saved scores, go back to the activity and click the "Delete Assessment" button.</li>
64 66
 
65 67
                 </ul>
66 68
             </div>
@@ -80,15 +82,16 @@
80 82
                     <li>Si un criterio particular fue evaluado, pero el estudiante no completó el trabajo necesario, debe seleccionar "0". Esto <strong>sí</strong> afectará la puntuación final del estudiante.</li>
81 83
                     <li>Si un estudiante no completó el trabajo para esta actividad, seleccione "0" en todas las columnas de la fila de ese estudiante.</li>
82 84
                     <li>Si un estudiante se dio de baja, seleccione "N/A" (No Aplica) en todas las columnas de la fila de ese estudiante.</li>
83
-                    <li>Las celdas con "N/A" <strong>no</strong> serán utilizadas para determinar si un criterio se alcanzó o no. Solamente las puntuaciones del 0 al 8 serán consideradas.</li>
84
-                    <li><strong>Al menos una puntuación deber ser del 1 al 8.</strong> De otra manera, el botón para guardar <strong>se desactivará</strong>. Si quiere borrar los resultados del avalúo, vuelva a la actividad y oprima el botón que dice "Delete Assessment".</li>
85
+                    <li>Las celdas con "N/A" <strong>no</strong> serán utilizadas para determinar si un criterio se alcanzó o no. Solamente las puntuaciones del 0 al {{$rubric->max_score}} serán consideradas.</li>
86
+                    <li>Para esta actividad, <strong>al menos una puntuación deber ser del 1 al {{$rubric->max_score}}.</strong> De otra manera, el botón para guardar <strong>se desactivará</strong>. Si quiere borrar los resultados del avalúo, vuelva a la actividad y oprima el botón que dice "Delete Assessment".</li>
85 87
 
86 88
 
87 89
                 </ul>
88 90
             </div>
89 91
 
90 92
         </div>
91
-
93
+        <input type='hidden' id='max' name= 'max' value='{{$rubric->max_score}}'>
94
+        <input type ='hidden' id='num_of_scales' name ='num_of_scales' value ='{{$rubric->num_scales}}'>
92 95
         <p id="course">Course: {{{ $course->code }}} {{{ $course->number }}}</p>
93 96
         <p id="section">Section: {{{ $course->section }}}</p>
94 97
         {{ HTML::linkAction('ActivitiesController@show', 'Back to Activity', array($activity->id), array('class'=>'btn btn-default btn-sm pull-right')) }}
@@ -97,16 +100,27 @@
97 100
 
98 101
         <table data-rubric-id="{{{ $rubric->id }}}" id="assessment-table" class="table table-striped table-condensed table-bordered">
99 102
             <thead>
103
+                <tr>
104
+                    <th>
105
+                    </th>
106
+                    @foreach ($criterion_rubric as $index => $criterion)
107
+                    <th  data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">
108
+                        
109
+                        Weight<input class="form-control" id="weight-{{$index}}" name='weight[]' type="text"  value="{{$criterion->weight}}" data-activity-criterion-id="{{$criterion->activity_criterion_id}}">
110
+                        </div></th>
111
+                @endforeach
112
+                </tr>
100 113
                     <tr>
101 114
                         <th>
102 115
                             <div class="th-box">
103 116
                                 Student
104 117
                             </div>
105 118
                         </th>
106
-                        @foreach ($rubric_contents as $criterion)
107
-                            <th class="criterion-field" data-criterion-id="{{{ $criterion->id }}}"><div class="th-box">{{ $criterion->name}}</div></th>
119
+                        @foreach ($criterion_rubric as $criterion)
120
+                            <th class="criterion-field" data-activity-criterion-id = "{{$criterion->activity_criterion_id}}"data-rubric-criterion-id = "{{$criterion->rubric_criterion_id}}" data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">{{ $criterion->name}}</div></th>
108 121
                         @endforeach
109 122
                         <th>Student Percentage</th>
123
+                        <th>Student % per Weight</th>
110 124
                         <th>Comments</th>
111 125
                     </tr>
112 126
             </thead>
@@ -115,21 +129,21 @@
115 129
             <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
116 130
             @if(sizeof($assessments)!=0)
117 131
                 <!-- For each assessment -->
118
-                @foreach ($assessments as $assessment)
132
+                @foreach ($students as $student)
119 133
                     <tr class="student-row">
120 134
                         <!-- Fetch student name -->
121
-                        <td class="student-field" data-student-id="{{ $assessment->student_id }}">
122
-                            {{{ $assessment->name }}}
135
+                        <td class="student-field" data-student-id="{{ $student->id }}">
136
+                            {{{ $student->name }}}
123 137
                         </td>
124 138
 
125 139
                         <!-- For each criterion in the rubric, there's a score field -->
126
-                        @for ($i = 0; $i<sizeof($rubric_contents); $i++)
140
+                        @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
127 141
                             <td class="score-field">
128
-                                <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $assessment->name }}}">
142
+                                <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
129 143
                                 <!-- Option from 0-8 -->
130
-                                @for ($j=0; $j<=8; $j++)
144
+                                @for ($j=0; $j<=$rubric->max_score; $j++)
131 145
                                     <!-- If the decoded scores with index as the assessment id and second index as criterion id equals the loop index, mark it as selected -->
132
-                                    @if( $j ==  $scores_array[$assessment->id][$rubric_contents[$i]->id])
146
+                                    @if( $j ==  $scores_array[$student->id][$i])
133 147
                                         <option value="{{$j}}" selected="selected">{{ $j }}</option>
134 148
                                     @else
135 149
                                         <option value="{{$j}}">{{ $j }}</option>
@@ -137,7 +151,7 @@
137 151
                                 @endfor
138 152
 
139 153
                                 <!-- N/A option -->
140
-                                @if( $scores_array[$assessment->id][$rubric_contents[$i]->id]=="N/A")
154
+                                @if( $scores_array[$student->id][$i]=="N/A")
141 155
                                     <option value="N/A" selected="selected">N/A</option>
142 156
                                 @else
143 157
                                     <option value="N/A">N/A</option>
@@ -145,9 +159,10 @@
145 159
                                 </select>
146 160
                             </td>
147 161
                         @endfor
148
-                        <td class="percentage">{{{ $assessment->percentage }}}</td>
162
+                        <td class="percentage"></td>
163
+                        <td class="percentage-per-weight"></td>
149 164
                         <td class="">
150
-                            <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" >{{ $assessment->comments }}</textarea>
165
+                            <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" >{{ $scores_array[$student->id]["comments"] }}</textarea>
151 166
                         </td>
152 167
                      </tr>
153 168
                 @endforeach
@@ -155,23 +170,18 @@
155 170
                 @foreach ($students as $student)
156 171
                     <tr class="student-row">
157 172
                         <td class="student-field" data-student-id={{ $student->id }}>{{{ $student->name }}}</td>
158
-                        @for ($i = 0; $i<sizeof($rubric_contents); $i++)
159
-                            <td class="score-field">
173
+                        @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
174
+                            <td class="score-field" data-weight = '1'>
160 175
                                 <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
161
-                                    <option value="0">0</option>
162
-                                    <option value="1">1</option>
163
-                                    <option value="2">2</option>
164
-                                    <option value="3">3</option>
165
-                                    <option value="4">4</option>
166
-                                    <option value="5">5</option>
167
-                                    <option value="6">6</option>
168
-                                    <option value="7">7</option>
169
-                                    <option value="8">8</option>
176
+                                    @for($j=0; $j<=$rubric->max_score; $j++)
177
+                                    <option value ='{{$j}}'>{{$j}}</option>
178
+                                    @endfor
170 179
                                     <option selected="selected" value="N/A">N/A</option>
171 180
                                 </select>
172 181
                             </td>
173 182
                         @endfor
174 183
                         <td class="percentage"></td>
184
+                        <td class="percentage-per-weight"></td>
175 185
                         <td class="comments"><textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" ></textarea></td>
176 186
                      </tr>
177 187
                 @endforeach
@@ -182,7 +192,7 @@
182 192
                     <td>
183 193
                         <strong>Passed Criteria Percentage </strong>
184 194
                     </td>
185
-                    @for ($i = 0; $i<sizeof($rubric_contents); $i++)
195
+                    @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
186 196
                         <td class="total"><strong><span class="total-value"></span><span class="percent-sign">%</span></strong>
187 197
                         </td>
188 198
                     @endfor
@@ -198,7 +208,147 @@
198 208
         </div>
199 209
     </div>
200 210
 </div>
211
+<script>
212
+$('#button-submit-assessment, #button-draft-assessment').on('click', function(e)
213
+{
214
+
215
+    var draft = 0;
216
+
217
+    if($(this).hasClass('draft'))
218
+        draft = 1;
219
+
220
+    var expected_points = parseInt($('#expected_points').text());
221
+    var expected_percentage = parseInt($('#expected_percentage').text());
222
+
223
+    //Prevent page refresh
224
+    e.preventDefault();
225
+
226
+    // Row in the database
227
+    var activity_id   =  $('#activity').data('activity-id');
228
+
229
+    var student_info = new Object();
230
+
231
+    // Object to hold the score sum of each criterion
232
+    var criteriaSumObject = new Object();
233
+
234
+    // Object to hold % of students that passed each criterion
235
+    var CriteriaAchievedPercentage = new Object();
236
+
237
+    // Object to hold all student evaluations
238
+    var studentAssessments = new Array();
239
+
240
+    var weights = new Object();
241
+
242
+    $('input[name="weight[]"]').each(function (index){
243
+        activity_criterion_id = $(this).data('activity-criterion-id');
244
+        weights[activity_criterion_id] = $(this).val();
245
+    });
246
+
247
+    // Iterate through all students
248
+    $('#assessment-table tbody tr').each(function( index )
249
+    {   
250
+
251
+        student_info[index] = new Object()
252
+        student_info[index].studentId = $(this).find('.student-field').data('student-id');
253
+        student_info[index].activity_crit_id = new Object();
254
+
255
+       /* var ScoresObject     = new Object();        // Scores column in database
256
+        var CriterionObject = new Object();     // Objects inside ScoresObject
257
+        var SingleStudentAssessment = new Object();
258
+        SingleStudentAssessment.student_id = $(this).find('.student-field').data('student-id');
259
+        */
260
+        // For each criterion, store the score in array
261
+        $(this).children('td.score-field').each(function(index2)
262
+        {
263
+            // Table cell with a score
264
+            var scoreField = $(this);
265
+
266
+            // Criterion being evaluated in current iteration
267
+            activity_criterion_id = $('.criterion-field').eq(index2).data('activity-criterion-id');
268
+            student_info[index].activity_crit_id[activity_criterion_id] = scoreField.children('select').find(':selected').val();
269
+
270
+            // Score in the cell
271
+            //var score = scoreField.children('select').find(':selected').val();
272
+
273
+            // Store the score in the scores Object
274
+            //ScoresObject[criterion_id]=score;
275
+
276
+            // Initialize the index for the sum object, if it's undefined
277
+            //if(typeof(criteriaSumObject[criterion_id]) == 'undefined')
278
+            //{
279
+            //    criteriaSumObject[criterion_id]=0;
280
+            //}
281
+
282
+            // Add to this criterion's total
283
+            //criteriaSumObject[criterion_id]+=parseInt(score);
284
+        });
285
+        student_info[index].comments = $.trim($(this).find('.comments').val());
286
+
287
+        //SingleStudentAssessment.scores = ScoresObject;
288
+        //SingleStudentAssessment.percentage = $(this).find('.percentage').text();
289
+        //SingleStudentAssessment.comments = $.trim($(this).find('.comments').val());
290
+        // console.log('comment '+index+': '+SingleStudentAssessment.comments);
291
+        // console.log('student object: '+JSON.stringify(SingleStudentAssessment));
292
+
293
+        //var clone = jQuery.extend({}, SingleStudentAssessment);
294
+        //studentAssessments.push(clone);
295
+
296
+
297
+    });
298
+
299
+    // console.log('students: '+JSON.stringify(studentAssessments));
300
+    // console.log('total points per criteria: '+JSON.stringify(criteriaSumObject));
301
+
302
+    // Iterate through all evaluated criteria, determining which were achieved
303
+    // by comparing the completion percentage to the expected percentage
304
+    /*var CriteriaAchievedResults = new Object();
305
+
306
+
307
+    $('.total').each(function(index)
308
+    {
309
+        var id = $('.criterion-field').eq(index).data('criterion-id');
310
+
311
+        CriteriaAchievedPercentage[id] = parseFloat($(this).find('span').text());
312
+
313
+        //Set whether criterion was achieved (1) or not (0)
314
+        if(CriteriaAchievedPercentage[id] >= expected_percentage)
315
+        {
316
+            CriteriaAchievedResults[id]=1;
317
+        }
318
+        else if (CriteriaAchievedPercentage[id] < expected_percentage)
319
+        {
320
+            CriteriaAchievedResults[id]=0;
321
+        }
322
+        else
323
+        {
324
+            CriteriaAchievedResults[id]=null;
325
+        }
326
+
327
+    });
328
+*/
329
+    // console.log('criteria percentages: '+JSON.stringify(CriteriaAchievedPercentage));
330
+    // console.log('criteria achieved results: '+JSON.stringify(CriteriaAchievedResults));
331
+
332
+
333
+    // Save activity to the database
334
+    $.post
335
+    (
336
+        "{{ URL::action('ActivitiesController@saveAssessment') }}",
337
+        {
338
+            activity_id: activity_id,
339
+            draft: draft,
340
+            weights: JSON.stringify(weights),
341
+        
342
+            student_info: JSON.stringify(student_info)
343
+        },
344
+        function(data)
345
+        {
346
+            location.replace(data);
347
+        }
348
+    );
201 349
 
350
+});
351
+    </script>
202 352
 @stop
203 353
 
204 354
 @section('included-js')
@@ -306,6 +456,9 @@ function percentagePerStudent(row)
306 456
     var sum = 0 ;
307 457
     var total = 0;
308 458
     var percentage = 0;
459
+    var max_score = parseInt($('#max').val());
460
+    sum_of_weight = 0;
461
+    per_of_weight =0;
309 462
 
310 463
     row.find('td.score-field').each(function(index)
311 464
     {
@@ -314,10 +467,13 @@ function percentagePerStudent(row)
314 467
         {
315 468
             sum += val;
316 469
             total+=1;
470
+            per_of_weight += val * parseInt($('#weight-'+index).val()); 
471
+            sum_of_weight += parseInt($('#weight-'+index).val());
317 472
         }
318
-    });
319 473
 
320
-    percentage =((sum/(total*8))*100).toFixed(2);
474
+    });
475
+    percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
476
+    percentage =((sum/(total*max_score))*100).toFixed(2);
321 477
 
322 478
     //If percentage is not a number, set it to 0.
323 479
     if(isNaN(percentage))
@@ -329,6 +485,13 @@ function percentagePerStudent(row)
329 485
     {
330 486
         row.find('.percentage').html('<strong>'+percentage+'%</strong>');
331 487
     }
488
+    if(isNaN(percentage_per_weight)){
489
+        percentage_per_weight="N/A";
490
+        row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'</strong>');
491
+    }
492
+    else{
493
+        row.find('.percentage-per-weight').html('<strong>'+percentage_per_weight+'%</strong>');
494
+    }
332 495
 
333 496
 
334 497
 }
@@ -382,131 +545,9 @@ $('select').on('change', function(e)
382 545
     percentagePerStudent($(this).closest('tr'));
383 546
     toggleSaveButton();
384 547
 });
385
-
548
+//LA LINEA DONDE VA, 410
386 549
 // Submit button is clicked
387
-$('#button-submit-assessment, #button-draft-assessment').on('click', function(e)
388
-{
389 550
 
390
-    var draft = 0;
391
-
392
-    if($(this).hasClass('draft'))
393
-        draft = 1;
394
-
395
-    var expected_points = parseInt($('#expected_points').text());
396
-    var expected_percentage = parseInt($('#expected_percentage').text());
397
-
398
-    //Prevent page refresh
399
-    e.preventDefault();
400
-
401
-    // Row in the database
402
-    var activity_id   =  $('#activity').data('activity-id');
403
-
404
-    // Object to hold the score sum of each criterion
405
-    var criteriaSumObject = new Object();
406
-
407
-    // Object to hold % of students that passed each criterion
408
-    var CriteriaAchievedPercentage = new Object();
409
-
410
-    // Object to hold all student evaluations
411
-    var studentAssessments = new Array();
412
-
413
-    // Iterate through all students
414
-    $('#assessment-table tbody tr').each(function( index )
415
-    {
416
-        var ScoresObject     = new Object();        // Scores column in database
417
-        var CriterionObject = new Object();     // Objects inside ScoresObject
418
-        var SingleStudentAssessment = new Object();
419
-        SingleStudentAssessment.student_id = $(this).find('.student-field').data('student-id');
420
-
421
-        // For each criterion, store the score in array
422
-        $(this).children('td.score-field').each(function(index)
423
-        {
424
-            // Table cell with a score
425
-            var scoreField = $(this);
426
-
427
-            // Criterion being evaluated in current iteration
428
-            var criterion_id = $('.criterion-field').eq(index).data('criterion-id');
429
-
430
-            // Score in the cell
431
-            var score = scoreField.children('select').find(':selected').val();
432
-
433
-            // Store the score in the scores Object
434
-            ScoresObject[criterion_id]=score;
435
-
436
-            // Initialize the index for the sum object, if it's undefined
437
-            if(typeof(criteriaSumObject[criterion_id]) == 'undefined')
438
-            {
439
-                criteriaSumObject[criterion_id]=0;
440
-            }
441
-
442
-            // Add to this criterion's total
443
-            criteriaSumObject[criterion_id]+=parseInt(score);
444
-        });
445
-
446
-        SingleStudentAssessment.scores = ScoresObject;
447
-        SingleStudentAssessment.percentage = $(this).find('.percentage').text();
448
-        SingleStudentAssessment.comments = $.trim($(this).find('.comments').val());
449
-        // console.log('comment '+index+': '+SingleStudentAssessment.comments);
450
-        // console.log('student object: '+JSON.stringify(SingleStudentAssessment));
451
-
452
-        var clone = jQuery.extend({}, SingleStudentAssessment);
453
-        studentAssessments.push(clone);
454
-
455
-
456
-    });
457
-
458
-    // console.log('students: '+JSON.stringify(studentAssessments));
459
-    // console.log('total points per criteria: '+JSON.stringify(criteriaSumObject));
460
-
461
-    // Iterate through all evaluated criteria, determining which were achieved
462
-    // by comparing the completion percentage to the expected percentage
463
-    var CriteriaAchievedResults = new Object();
464
-
465
-
466
-    $('.total').each(function(index)
467
-    {
468
-        var id = $('.criterion-field').eq(index).data('criterion-id');
469
-
470
-        CriteriaAchievedPercentage[id] = parseFloat($(this).find('span').text());
471
-
472
-        //Set whether criterion was achieved (1) or not (0)
473
-        if(CriteriaAchievedPercentage[id] >= expected_percentage)
474
-        {
475
-            CriteriaAchievedResults[id]=1;
476
-        }
477
-        else if (CriteriaAchievedPercentage[id] < expected_percentage)
478
-        {
479
-            CriteriaAchievedResults[id]=0;
480
-        }
481
-        else
482
-        {
483
-            CriteriaAchievedResults[id]=null;
484
-        }
485
-
486
-    });
487
-
488
-    // console.log('criteria percentages: '+JSON.stringify(CriteriaAchievedPercentage));
489
-    // console.log('criteria achieved results: '+JSON.stringify(CriteriaAchievedResults));
490
-
491
-
492
-    // Save activity to the database
493
-    $.post
494
-    (
495
-        "{{ URL::action('ActivitiesController@saveAssessment') }}",
496
-        {
497
-            activity_id: activity_id,
498
-            draft: draft,
499
-            criteria_achieved_percentage: JSON.stringify(CriteriaAchievedPercentage),
500
-            criteria_achievement: JSON.stringify(CriteriaAchievedResults),
501
-            student_scores: JSON.stringify(studentAssessments),
502
-        },
503
-        function(data)
504
-        {
505
-            location.replace(data);
506
-        }
507
-    );
508
-
509
-});
510 551
 
511 552
 // Language button is clicked
512 553
 $('#button-language').on('click', function(e)
@@ -523,25 +564,24 @@ $('.criterion-field').on('click', function()
523 564
         type: 'POST',
524 565
         url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
525 566
         data: {
526
-            rubric_id: $(this).closest('table').data('rubric-id'),
527
-            criterion_id: $(this).data('criterion-id'),
567
+            rubric_criterion_id: $(this).data('rubric-criterion-id')
528 568
         },
529 569
         success: function(data)
530 570
         {
531 571
             data = JSON.parse(data);
532
-            $('.modal-title').html(data.name);
533
-
572
+            $('.modal-title').html(data.criteria.name);
573
+            descriptions = '';
534 574
             $('.modal-body tbody tr').empty();
575
+            for(i =0; i<{{$rubric->num_scales}}; i++){
576
+                descriptions += '<td>'+data[i].description+'</td>'
577
+            }
535 578
             $('.modal-body tbody tr').append
536 579
             (
537
-                '<td>'+data.description12+'</td>'
538
-                +'<td>'+data.description34+'</td>'
539
-                +'<td>'+data.description56+'</td>'
540
-                +'<td>'+data.description78+'</td>'
580
+                descriptions
541 581
             );
542 582
 
543
-            if(data.notes!=null)
544
-                $('.modal-body tbody tr').append('<td>'+data.notes+'</td>');
583
+            if(data.criteria.notes!=null)
584
+                $('.modal-body tbody tr').append('<td>'+data.criteria.notes+'</td>');
545 585
             else
546 586
                 $('.modal-body tbody tr').append('<td></td>');
547 587
 

+ 10
- 6
app/views/local/professors/rubrics.blade.php Wyświetl plik

@@ -42,8 +42,8 @@
42 42
 
43 43
 
44 44
     <div class="well">
45
-      @if($activity->rubric_id!=NULL)
46
-        <span id="assigned_rubric" class="hidden" data-assigned-rubric="{{{ $activity->rubric_id }}}"></span>
45
+      @if(count($activity->rubric)!=0)
46
+        <span id="assigned_rubric" class="hidden" data-assigned-rubric="{{{ $activity->rubric[0]->id }}}"></span>
47 47
       @endif
48 48
       <input id="activity_id" type="hidden" value="{{{ $activity->id}}}">
49 49
 
@@ -51,7 +51,7 @@
51 51
         <label>Select a Rubric:</label>
52 52
         <select id="select-template" class="form-control selectpicker">
53 53
           @foreach ($templates as $template)
54
-            @if($activity->rubric_id!=NULL && $template->name == Rubric::find($activity->rubric_id)->name)
54
+            @if(count($activity->rubric)!=0 && $template->name == Rubric::find($activity->rubric[0]->id)->name)
55 55
               <option data-template-id="{{ $template->id }}" class="template" selected="selected">{{ $template->name }}</option>
56 56
             @else
57 57
               <option data-template-id="{{ $template->id }}" class="template">{{ $template->name }}</option>
@@ -541,7 +541,7 @@ $('#button-save-rubric').on('click', function(e)
541 541
       {
542 542
         name: $('#select-template').find(':selected').text(),
543 543
         activity_id: parseInt($('#activity_id').val()),
544
-        contents: " ",
544
+        
545 545
         expected_percentage: $('#expected_percentage').text(),
546 546
         expected_points: $('#expected_points').text(),
547 547
         criteria: criteria,
@@ -566,9 +566,13 @@ $('#button-save-rubric').on('click', function(e)
566 566
       {
567 567
         id: $('#assigned_rubric').data('assigned-rubric'),
568 568
         name: $('#select-template').find(':selected').text(),
569
-        contents: JSON.stringify(criteriaArray),
569
+        activity_id: parseInt($('#activity_id').val()),
570
+        
570 571
         expected_percentage: $('#expected_percentage').text(),
571
-        expected_points: $('#expected_points').text()
572
+        expected_points: $('#expected_points').text(),
573
+        criteria: criteria,
574
+        scales: scales,
575
+        max_score:max_score
572 576
       },
573 577
       function(data)
574 578
       {

+ 17
- 12
app/views/local/professors/viewrubric.blade.php Wyświetl plik

@@ -32,15 +32,14 @@
32 32
           <tr>
33 33
             <th></th>
34 34
             <th>Criterion</th>
35
-            <th>Beginning (1-2)</th>
36
-            <th>In Progress (3-4)</th>
37
-            <th>Good (5-6)</th>
38
-            <th>Excellent (7-8)</th>
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>
37
+            @endfor
39 38
             <th>Learning Outcome</th>
40 39
           </tr>
41 40
         </thead>
42 41
         <tbody>
43
-        @foreach(json_decode($rubric->contents) as $index => $criterion)
42
+        @foreach($criterion_rubric as $index => $criterion)
44 43
           <tr data-criterion-copyright="{{ $criterion->copyright }}" data-criterion-notes="{{ $criterion->notes }}">
45 44
             <td>{{ $index + 1 }}.</td>
46 45
             @if(isset($criterion->notes))
@@ -49,7 +48,7 @@
49 48
               <sup></sup>
50 49
               @if(property_exists($criterion, 'subcriteria'))
51 50
                 <ul class="list-unstyled">
52
-                  @foreach($criterion->subcriteria as $subcriterion)
51
+                  @foreach(json_decode($criterion->subcriteria) as $subcriterion)
53 52
                       <li>{{ $subcriterion }}</li>
54 53
                   @endforeach
55 54
                 </ul>
@@ -60,18 +59,24 @@
60 59
               <span>{{{ $criterion->name }}}</span><sup></sup>
61 60
               @if(property_exists($criterion, 'subcriteria'))
62 61
                 <ul class="list-unstyled">
63
-                  @foreach($criterion->subcriteria as $subcriterion)
62
+                  @foreach(json_decode($criterion->subcriteria) as $subcriterion)
64 63
                       <li>{{ $subcriterion }}</li>
65 64
                   @endforeach
66 65
                 </ul>
67 66
               @endif
68 67
             </td>
69 68
             @endif
70
-            <td>{{ nl2br($criterion->description12) }}</td>
71
-            <td>{{ nl2br($criterion->description34) }}</td>
72
-            <td>{{ nl2br($criterion->description56) }}</td>
73
-            <td>{{ nl2br($criterion->description78) }}</td>
74
-            <td>{{ Outcome::where('id', $criterion->outcome_id)->first()->name }}</td>
69
+            @foreach(json_decode($criterion->scales) as $scale)
70
+            <td>{{ nl2br($scale) }}</td>
71
+
72
+            @endforeach
73
+
74
+            <td>
75
+            
76
+            @foreach (json_decode($criterion->outcomes) as $index => $outcome)
77
+            {{$index+1}}. {{$outcome}}<br>                 
78
+            @endforeach  
79
+            </td>
75 80
           </tr>
76 81
         @endforeach
77 82
         </tbody>