Browse Source

Antes de volver al merge

parent
commit
f75627ee58

+ 1
- 0
.gitignore View File

12
 app/config/database.php
12
 app/config/database.php
13
 node_modules/
13
 node_modules/
14
 app/config/
14
 app/config/
15
+app/controllers/AuthController.php

+ 60
- 9
app/controllers/ActivitiesController.php View File

169
         Log::info($activity);
169
         Log::info($activity);
170
         $criterion_rubric = DB::table('criteria')
170
         $criterion_rubric = DB::table('criteria')
171
             ->join("criterion_rubric", "criterion_rubric.criterion_id", "=", "criteria.id")
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();
173
         Log::info($criterion_rubric);
180
         Log::info($criterion_rubric);
174
         foreach ($criterion_rubric as $index => $singleCR) {
181
         foreach ($criterion_rubric as $index => $singleCR) {
175
             $singleCR->scales = json_encode(DB::table('scales')->join('rubric_criteria_scale', 'rubric_criteria_scale.scale_id', '=', 'scales.id')
182
             $singleCR->scales = json_encode(DB::table('scales')->join('rubric_criteria_scale', 'rubric_criteria_scale.scale_id', '=', 'scales.id')
176
-                ->where('rubric_criteria_scale.rubric_criterion_id', '=', $singleCR->id)
183
+                ->where('rubric_criteria_scale.rubric_criterion_id', '=', $singleCR->rubric_criterion_id)
177
                 ->orderBy('position')
184
                 ->orderBy('position')
178
                 ->lists('description'));
185
                 ->lists('description'));
179
         }
186
         }
180
         $criterion_rubric_ids = DB::table('criterion_rubric')->where('rubric_id', '=', $rubric->id)->lists('id');
187
         $criterion_rubric_ids = DB::table('criterion_rubric')->where('rubric_id', '=', $rubric->id)->lists('id');
181
         Log::info($rubric);
188
         Log::info($rubric);
182
         Log::info($criterion_rubric);
189
         Log::info($criterion_rubric);
183
-        $scales = DB::table('scales')->join('rubric_criteria_scale', 'rubric_criteria_scale.scale_id', '=', 'scales.id')
184
-            ->whereIn('rubric_criteria_scale.rubric_criterion_id', $criterion_rubric_ids)->get();
190
+
185
 
191
 
186
 
192
 
187
 
193
 
190
         $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
196
         $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
191
         Log::info($activity_criterion_ids);
197
         Log::info($activity_criterion_ids);
192
         $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->whereIn('activity_criterion_id', $activity_criterion_ids)->orderBy('assessments.id', 'asc')->get();
198
         $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->whereIn('activity_criterion_id', $activity_criterion_ids)->orderBy('assessments.id', 'asc')->get();
193
-
199
+        Log::info($assessments);
194
         // Decode the scores (blade workaround)
200
         // Decode the scores (blade workaround)
195
         $scores_array = array();
201
         $scores_array = array();
202
+
196
         foreach ($assessments as $index => $assessment) {
203
         foreach ($assessments as $index => $assessment) {
197
-            $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;
198
         }
208
         }
199
-        Log::info(sizeof($criterion_rubric));
209
+
210
+        Log::info($scores_array);
200
 
211
 
201
 
212
 
202
-        return View::make('local.professors.assessment', compact('activity', 'title', 'students', 'course', 'criterion_rubric', 'assessments', 'scores_array', 'rubric', 'scales'));
213
+        return View::make('local.professors.assessment', compact('activity', 'title', 'students', 'course', 'criterion_rubric', 'assessments', 'scores_array', 'rubric'));
203
     }
214
     }
204
 
215
 
205
     public function saveAssessment()
216
     public function saveAssessment()
208
             $exception = DB::transaction(function () {
219
             $exception = DB::transaction(function () {
209
                 DB::transaction(function () {
220
                 DB::transaction(function () {
210
                     // Student assessment data
221
                     // Student assessment data
211
-                    $student_data = json_decode(Input::get('student_scores'));
212
 
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}");
213
                     // Outcome count
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
+
214
                     $outcomeCount = Outcome::all()->count();
265
                     $outcomeCount = Outcome::all()->count();
215
 
266
 
216
 
267
 

+ 29
- 22
app/controllers/RubricsController.php View File

94
         $rubric->user_id = Auth::id();
94
         $rubric->user_id = Auth::id();
95
         $rubric->num_scales = count($scales[0]);
95
         $rubric->num_scales = count($scales[0]);
96
         $rubric->max_score = Input::get('max_score');
96
         $rubric->max_score = Input::get('max_score');
97
-        $division = $rubric->max_score / count($scales[0]);
97
+        $defaultWeight = round(100 / $rubric->num_scales, 2);
98
+
98
         if ($rubric->save()) {
99
         if ($rubric->save()) {
99
 
100
 
100
             // Process activity
101
             // Process activity
115
 
116
 
116
 
117
 
117
                 for ($i = 0; $i < count($scales[$index]); $i++) {
118
                 for ($i = 0; $i < count($scales[$index]); $i++) {
118
-                    $scale =  Scale::where('description', '=', $scales[$index][$i])
119
-                        ->where('max_score', '=', ($division * ($i + 1)))
120
-                        ->where("min_score", '=', (1 + ($division * $i)))->first();
119
+                    $scale =  Scale::where('description', '=', $scales[$index][$i])->first();
121
                     Log::info($scale);
120
                     Log::info($scale);
122
                     if ($scale) {
121
                     if ($scale) {
123
                         DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$scale->id}, {$i})");
122
                         DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$scale->id}, {$i})");
125
                     } else {
124
                     } else {
126
                         $scale = new Scale;
125
                         $scale = new Scale;
127
                         $scale->description = $scales[$index][$i];
126
                         $scale->description = $scales[$index][$i];
128
-                        $scale->min_score = 1 + ($division * $i);
129
-                        $scale->max_score = ($division * ($i + 1));
127
+
130
                         if ($scale->save()) {
128
                         if ($scale->save()) {
131
                             DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$scale->id}, {$i})");
129
                             DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$scale->id}, {$i})");
132
                             DB::commit();
130
                             DB::commit();
136
                         }
134
                         }
137
                     }
135
                     }
138
                 }
136
                 }
137
+
139
                 $activity_id = Input::get("activity_id");
138
                 $activity_id = Input::get("activity_id");
140
-                DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`) values ({$activity_id}, {$criterion_id})");
139
+                DB::insert("insert into `activity_criterion` (`activity_id`,`criterion_id`, `weight`) values ({$activity_id}, {$criterion_id}, {$defaultWeight})");
141
                 DB::commit();
140
                 DB::commit();
142
             }
141
             }
143
             Session::flash('status', 'success');
142
             Session::flash('status', 'success');
183
 
182
 
184
         $rubric->num_scales = count($scales[0]);
183
         $rubric->num_scales = count($scales[0]);
185
         $rubric->max_score = Input::get('max_score');
184
         $rubric->max_score = Input::get('max_score');
186
-        $division = $rubric->max_score / count($scales[0]);
185
+        $defaultWeight = round(100 / $rubric->num_scales, 2);
186
+
187
 
187
 
188
         DB::beginTransaction();
188
         DB::beginTransaction();
189
 
189
 
271
         $course->save();
271
         $course->save();
272
         Log::info('entré6???');
272
         Log::info('entré6???');
273
         DB::delete("delete from criterion_rubric where rubric_id ={$rubric->id}");
273
         DB::delete("delete from criterion_rubric where rubric_id ={$rubric->id}");
274
+        DB::delete("delete from activity_criterion where activity_id = {$activity->id}");
274
         foreach ($criteria as $index => $criterion_id) {
275
         foreach ($criteria as $index => $criterion_id) {
275
             if (
276
             if (
276
 
277
 
277
                 DB::insert("insert into criterion_rubric (`rubric_id`, `criterion_id`) values ({$rubric->id}, {$criterion_id}) ")
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})")
278
             ) {
280
             ) {
279
-                Log::info("AHH");
281
+
280
                 $rubric_criterion_id =  DB::table('criterion_rubric')
282
                 $rubric_criterion_id =  DB::table('criterion_rubric')
281
                     ->where('rubric_id', '=', $rubric->id)
283
                     ->where('rubric_id', '=', $rubric->id)
282
                     ->where('criterion_id', '=', $criterion_id)
284
                     ->where('criterion_id', '=', $criterion_id)
284
 
286
 
285
                 foreach ($scales[$index] as $in => $scale) {
287
                 foreach ($scales[$index] as $in => $scale) {
286
                     Log::info("AH2");
288
                     Log::info("AH2");
287
-                    $new_scale =  Scale::where('description', '=', $scale)
288
-                        ->where('max_score', '=', ($division * ($in + 1)))
289
-                        ->where("min_score", '=', (1 + ($division * $in)))->first();
289
+                    $new_scale =  Scale::where('description', '=', $scale)->first();
290
 
290
 
291
                     if ($new_scale) {
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})");
292
                         DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$new_scale->id}, {$in})");
294
                     } else {
294
                     } else {
295
                         $new_scale = new Scale;
295
                         $new_scale = new Scale;
296
                         $new_scale->description = $scales[$index][$in];
296
                         $new_scale->description = $scales[$index][$in];
297
-                        $new_scale->min_score = 1 + ($division * $in);
298
-                        $new_scale->max_score = ($division * ($in + 1));
299
                         if ($new_scale->save()) {
297
                         if ($new_scale->save()) {
300
                             DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$new_scale->id}, {$in})");
298
                             DB::insert("insert into `rubric_criteria_scale` (`rubric_criterion_id`, `scale_id`, `position`) values ({$rubric_criterion_id->id},{$new_scale->id}, {$in})");
301
                             DB::commit();
299
                             DB::commit();
366
             ->join('criterion_rubric', 'criterion_rubric.criterion_id', '=', 'criteria.id')
364
             ->join('criterion_rubric', 'criterion_rubric.criterion_id', '=', 'criteria.id')
367
             ->where('criterion_rubric.rubric_id', '=', $activity->rubric[0]->id)
365
             ->where('criterion_rubric.rubric_id', '=', $activity->rubric[0]->id)
368
             ->get();
366
             ->get();
367
+        Log::info($criterion_rubric);
369
 
368
 
370
         foreach ($criterion_rubric as $single_cr) {
369
         foreach ($criterion_rubric as $single_cr) {
371
             $single_cr->scales = json_encode(DB::table('scales')
370
             $single_cr->scales = json_encode(DB::table('scales')
434
 
433
 
435
     public function fetchRubricCriterion()
434
     public function fetchRubricCriterion()
436
     {
435
     {
437
-        $rubric = Rubric::findOrFail(Input::get('rubric_id'));
438
-        $criterion_id = Input::get('criterion_id');
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);
439
 
440
 
440
-        $rubric_contents = json_decode($rubric->contents);
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);
441
 
447
 
442
-        foreach ($rubric_contents as $key => $criterion) {
443
-            if ($criterion->id == $criterion_id) {
444
-                return json_encode($criterion);
445
-            }
446
-        }
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
+        //    }
447
     }
454
     }
448
 }
455
 }

+ 9
- 11
app/controllers/TemplatesController.php View File

145
 
145
 
146
 		$template->num_scales = count($scales[0]);
146
 		$template->num_scales = count($scales[0]);
147
 		$template->max_score = $max_score;
147
 		$template->max_score = $max_score;
148
-		$division = $max_score / count($scales[0]);
148
+
149
 		if ($template->save()) {
149
 		if ($template->save()) {
150
 			$templateId = $template->id;
150
 			$templateId = $template->id;
151
 			foreach ($criteria as $index => $criterion_id) {
151
 			foreach ($criteria as $index => $criterion_id) {
154
 					->where('criterion_id', '=', $criterion_id)->first();
154
 					->where('criterion_id', '=', $criterion_id)->first();
155
 
155
 
156
 				for ($i = 0; $i < count($scales[$index]); $i++) {
156
 				for ($i = 0; $i < count($scales[$index]); $i++) {
157
-					$scale =  Scale::where('description', '=', $scales[$index][$i])
158
-						->where('max_score', '=', ($division * ($i + 1)))
159
-						->where("min_score", '=', (1 + ($division * $i)))->first();
157
+					$scale =  Scale::where('description', '=', $scales[$index][$i])->first();
160
 					Log::info($scale);
158
 					Log::info($scale);
161
 					if ($scale) {
159
 					if ($scale) {
162
 						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
160
 						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
164
 					} else {
162
 					} else {
165
 						$scale = new Scale;
163
 						$scale = new Scale;
166
 						$scale->description = $scales[$index][$i];
164
 						$scale->description = $scales[$index][$i];
167
-						$scale->min_score = 1 + ($division * $i);
168
-						$scale->max_score = ($division * ($i + 1));
165
+
169
 						if ($scale->save()) {
166
 						if ($scale->save()) {
170
 							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
167
 							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
171
 							DB::commit();
168
 							DB::commit();
261
 		Log::info(Input::all());
258
 		Log::info(Input::all());
262
 		$template->num_scales = count($scales[0]);
259
 		$template->num_scales = count($scales[0]);
263
 		$template->max_score = $max_score;
260
 		$template->max_score = $max_score;
264
-		$division = $max_score / count($scales[0]);
261
+		//$division = $max_score / count($scales[0]);
265
 
262
 
266
 		if ($template->save()) {
263
 		if ($template->save()) {
267
 			$templateId = $template->id;
264
 			$templateId = $template->id;
274
 				DB::delete("delete from template_criterion_scale where template_criterion_id ={$template_criterion_id->id}");
271
 				DB::delete("delete from template_criterion_scale where template_criterion_id ={$template_criterion_id->id}");
275
 				for ($i = 0; $i < count($scales[$index]); $i++) {
272
 				for ($i = 0; $i < count($scales[$index]); $i++) {
276
 					$scale =  Scale::where('description', '=', $scales[$index][$i])
273
 					$scale =  Scale::where('description', '=', $scales[$index][$i])
277
-						->where('max_score', '=', ($division * ($i + 1)))
278
-						->where("min_score", '=', (1 + ($division * $i)))->first();
274
+						//->where('max_score', '=', ($division * ($i + 1)))
275
+						//->where("min_score", '=', (1 + ($division * $i)))
276
+						->first();
279
 					Log::info($scale);
277
 					Log::info($scale);
280
 					if ($scale) {
278
 					if ($scale) {
281
 						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
279
 						DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
283
 					} else {
281
 					} else {
284
 						$scale = new Scale;
282
 						$scale = new Scale;
285
 						$scale->description = $scales[$index][$i];
283
 						$scale->description = $scales[$index][$i];
286
-						$scale->min_score = 1 + ($division * $i);
287
-						$scale->max_score = ($division * ($i + 1));
284
+						//$scale->min_score = 1 + ($division * $i);
285
+						//$scale->max_score = ($division * ($i + 1));
288
 						if ($scale->save()) {
286
 						if ($scale->save()) {
289
 							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
287
 							DB::insert("insert into `template_criterion_scale` (`template_criterion_id`, `scale_id`, `position`) values ({$template_criterion_id->id},{$scale->id}, {$i})");
290
 							DB::commit();
288
 							DB::commit();

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

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>
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>
62
                     <li>If a student did not complete any work for this activity, select "0" for all columns in that student's row.</li>
62
                     <li>If a student did not complete any work for this activity, select "0" for all columns in that student's row.</li>
63
                     <li>If a student dropped the class, select "N/A" (Not Applicable) for all columns in that student's row.</li>
63
                     <li>If a student dropped the class, select "N/A" (Not Applicable) for all columns in that student's row.</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 8 will be considered for this purpose.</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>
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>
66
 
66
 
67
                 </ul>
67
                 </ul>
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>
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>
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>
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>
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>
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>
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 8 serán consideradas.</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>
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>
87
 
87
 
88
 
88
 
105
                     </th>
105
                     </th>
106
                     @foreach ($criterion_rubric as $index => $criterion)
106
                     @foreach ($criterion_rubric as $index => $criterion)
107
                     <th  data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">
107
                     <th  data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">
108
-                        <!--<div class="form-group row">
109
-                            <div class="col-xs-1">
110
-                                <label for="weight-{{$index}}">Weight</label>
111
-                            <input class="form-control" id="weight-{{$index}}" name='weight[]' type="text">
112
-                            </div>
113
-                        </div>-->
114
-                        Weight<input class="form-control" id="weight-{{$index}}" name='weight[]' type="text" style = "width: 50%">
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}}">
115
                         </div></th>
110
                         </div></th>
116
                 @endforeach
111
                 @endforeach
117
                 </tr>
112
                 </tr>
122
                             </div>
117
                             </div>
123
                         </th>
118
                         </th>
124
                         @foreach ($criterion_rubric as $criterion)
119
                         @foreach ($criterion_rubric as $criterion)
125
-                            <th class="criterion-field" data-criterion-id="{{{ $criterion->criterion_id }}}" ><div class="th-box">{{ $criterion->name}}</div></th>
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>
126
                         @endforeach
121
                         @endforeach
127
                         <th>Student Percentage</th>
122
                         <th>Student Percentage</th>
128
                         <th>Student % per Weight</th>
123
                         <th>Student % per Weight</th>
134
             <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
129
             <!-- If the activity was assessed, load the assessment. Otherwise load empty sheet -->
135
             @if(sizeof($assessments)!=0)
130
             @if(sizeof($assessments)!=0)
136
                 <!-- For each assessment -->
131
                 <!-- For each assessment -->
137
-                @foreach ($assessments as $assessment)
132
+                @foreach ($students as $student)
138
                     <tr class="student-row">
133
                     <tr class="student-row">
139
                         <!-- Fetch student name -->
134
                         <!-- Fetch student name -->
140
-                        <td class="student-field" data-student-id="{{ $assessment->student_id }}">
141
-                            {{{ $assessment->name }}}
135
+                        <td class="student-field" data-student-id="{{ $student->id }}">
136
+                            {{{ $student->name }}}
142
                         </td>
137
                         </td>
143
 
138
 
144
                         <!-- For each criterion in the rubric, there's a score field -->
139
                         <!-- For each criterion in the rubric, there's a score field -->
145
                         @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
140
                         @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
146
                             <td class="score-field">
141
                             <td class="score-field">
147
-                                <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 }}}">
148
                                 <!-- Option from 0-8 -->
143
                                 <!-- Option from 0-8 -->
149
-                                @for ($j=0; $j<=8; $j++)
144
+                                @for ($j=0; $j<=$rubric->max_score; $j++)
150
                                     <!-- If the decoded scores with index as the assessment id and second index as criterion id equals the loop index, mark it as selected -->
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 -->
151
-                                    @if( $j ==  $scores_array[$assessment->id][$criterion_rubric[$i]->criterion_id])
146
+                                    @if( $j ==  $scores_array[$student->id][$i])
152
                                         <option value="{{$j}}" selected="selected">{{ $j }}</option>
147
                                         <option value="{{$j}}" selected="selected">{{ $j }}</option>
153
                                     @else
148
                                     @else
154
                                         <option value="{{$j}}">{{ $j }}</option>
149
                                         <option value="{{$j}}">{{ $j }}</option>
156
                                 @endfor
151
                                 @endfor
157
 
152
 
158
                                 <!-- N/A option -->
153
                                 <!-- N/A option -->
159
-                                @if( $scores_array[$assessment->id][$criterion_rubric[$i]->criterion_id]=="N/A")
154
+                                @if( $scores_array[$student->id][$i]=="N/A")
160
                                     <option value="N/A" selected="selected">N/A</option>
155
                                     <option value="N/A" selected="selected">N/A</option>
161
                                 @else
156
                                 @else
162
                                     <option value="N/A">N/A</option>
157
                                     <option value="N/A">N/A</option>
164
                                 </select>
159
                                 </select>
165
                             </td>
160
                             </td>
166
                         @endfor
161
                         @endfor
167
-                        <td class="percentage">{{{ $assessment->percentage }}}</td>
162
+                        <td class="percentage"></td>
163
+                        <td class="percentage-per-weight"></td>
168
                         <td class="">
164
                         <td class="">
169
-                            <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>
170
                         </td>
166
                         </td>
171
                      </tr>
167
                      </tr>
172
                 @endforeach
168
                 @endforeach
175
                     <tr class="student-row">
171
                     <tr class="student-row">
176
                         <td class="student-field" data-student-id={{ $student->id }}>{{{ $student->name }}}</td>
172
                         <td class="student-field" data-student-id={{ $student->id }}>{{{ $student->name }}}</td>
177
                         @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
173
                         @for ($i = 0; $i<sizeof($criterion_rubric); $i++)
178
-                            <td class="score-field">
174
+                            <td class="score-field" data-weight = '1'>
179
                                 <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
175
                                 <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
180
                                     @for($j=0; $j<=$rubric->max_score; $j++)
176
                                     @for($j=0; $j<=$rubric->max_score; $j++)
181
                                     <option value ='{{$j}}'>{{$j}}</option>
177
                                     <option value ='{{$j}}'>{{$j}}</option>
185
                             </td>
181
                             </td>
186
                         @endfor
182
                         @endfor
187
                         <td class="percentage"></td>
183
                         <td class="percentage"></td>
188
-                        <td class="percentage-per-w"></td>
184
+                        <td class="percentage-per-weight"></td>
189
                         <td class="comments"><textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" ></textarea></td>
185
                         <td class="comments"><textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" ></textarea></td>
190
                      </tr>
186
                      </tr>
191
                 @endforeach
187
                 @endforeach
212
         </div>
208
         </div>
213
     </div>
209
     </div>
214
 </div>
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
+    );
215
 
349
 
216
-    
350
+});
351
+    </script>
217
 @stop
352
 @stop
218
 
353
 
219
 @section('included-js')
354
 @section('included-js')
230
 // Page load
365
 // Page load
231
 // --------------------------------------------------------------------------
366
 // --------------------------------------------------------------------------
232
 
367
 
233
-changeTable();
368
+
234
 // Enable fixed headers
369
 // Enable fixed headers
235
 $('#assessment-table').stickyTableHeaders();
370
 $('#assessment-table').stickyTableHeaders();
236
 
371
 
322
     var total = 0;
457
     var total = 0;
323
     var percentage = 0;
458
     var percentage = 0;
324
     var max_score = parseInt($('#max').val());
459
     var max_score = parseInt($('#max').val());
460
+    sum_of_weight = 0;
461
+    per_of_weight =0;
325
 
462
 
326
     row.find('td.score-field').each(function(index)
463
     row.find('td.score-field').each(function(index)
327
     {
464
     {
330
         {
467
         {
331
             sum += val;
468
             sum += val;
332
             total+=1;
469
             total+=1;
470
+            per_of_weight += val * parseInt($('#weight-'+index).val()); 
471
+            sum_of_weight += parseInt($('#weight-'+index).val());
333
         }
472
         }
334
-    });
335
 
473
 
474
+    });
475
+    percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
336
     percentage =((sum/(total*max_score))*100).toFixed(2);
476
     percentage =((sum/(total*max_score))*100).toFixed(2);
337
 
477
 
338
     //If percentage is not a number, set it to 0.
478
     //If percentage is not a number, set it to 0.
345
     {
485
     {
346
         row.find('.percentage').html('<strong>'+percentage+'%</strong>');
486
         row.find('.percentage').html('<strong>'+percentage+'%</strong>');
347
     }
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
+    }
348
 
495
 
349
 
496
 
350
 }
497
 }
398
     percentagePerStudent($(this).closest('tr'));
545
     percentagePerStudent($(this).closest('tr'));
399
     toggleSaveButton();
546
     toggleSaveButton();
400
 });
547
 });
401
-
548
+//LA LINEA DONDE VA, 410
402
 // Submit button is clicked
549
 // Submit button is clicked
403
-$('#button-submit-assessment, #button-draft-assessment').on('click', function(e)
404
-{
405
-
406
-    var draft = 0;
407
-
408
-    if($(this).hasClass('draft'))
409
-        draft = 1;
410
-
411
-    var expected_points = parseInt($('#expected_points').text());
412
-    var expected_percentage = parseInt($('#expected_percentage').text());
413
-
414
-    //Prevent page refresh
415
-    e.preventDefault();
416
-
417
-    // Row in the database
418
-    var activity_id   =  $('#activity').data('activity-id');
419
-
420
-    // Object to hold the score sum of each criterion
421
-    var criteriaSumObject = new Object();
422
-
423
-    // Object to hold % of students that passed each criterion
424
-    var CriteriaAchievedPercentage = new Object();
425
-
426
-    // Object to hold all student evaluations
427
-    var studentAssessments = new Array();
428
-
429
-    // Iterate through all students
430
-    $('#assessment-table tbody tr').each(function( index )
431
-    {
432
-        var ScoresObject     = new Object();        // Scores column in database
433
-        var CriterionObject = new Object();     // Objects inside ScoresObject
434
-        var SingleStudentAssessment = new Object();
435
-        SingleStudentAssessment.student_id = $(this).find('.student-field').data('student-id');
436
-
437
-        // For each criterion, store the score in array
438
-        $(this).children('td.score-field').each(function(index)
439
-        {
440
-            // Table cell with a score
441
-            var scoreField = $(this);
442
-
443
-            // Criterion being evaluated in current iteration
444
-            var criterion_id = $('.criterion-field').eq(index).data('criterion-id');
445
-
446
-            // Score in the cell
447
-            var score = scoreField.children('select').find(':selected').val();
448
-
449
-            // Store the score in the scores Object
450
-            ScoresObject[criterion_id]=score;
451
-
452
-            // Initialize the index for the sum object, if it's undefined
453
-            if(typeof(criteriaSumObject[criterion_id]) == 'undefined')
454
-            {
455
-                criteriaSumObject[criterion_id]=0;
456
-            }
457
-
458
-            // Add to this criterion's total
459
-            criteriaSumObject[criterion_id]+=parseInt(score);
460
-        });
461
-
462
-        SingleStudentAssessment.scores = ScoresObject;
463
-        SingleStudentAssessment.percentage = $(this).find('.percentage').text();
464
-        SingleStudentAssessment.comments = $.trim($(this).find('.comments').val());
465
-        // console.log('comment '+index+': '+SingleStudentAssessment.comments);
466
-        // console.log('student object: '+JSON.stringify(SingleStudentAssessment));
467
-
468
-        var clone = jQuery.extend({}, SingleStudentAssessment);
469
-        studentAssessments.push(clone);
470
-
471
-
472
-    });
473
-
474
-    // console.log('students: '+JSON.stringify(studentAssessments));
475
-    // console.log('total points per criteria: '+JSON.stringify(criteriaSumObject));
476
-
477
-    // Iterate through all evaluated criteria, determining which were achieved
478
-    // by comparing the completion percentage to the expected percentage
479
-    var CriteriaAchievedResults = new Object();
480
-
481
-
482
-    $('.total').each(function(index)
483
-    {
484
-        var id = $('.criterion-field').eq(index).data('criterion-id');
485
-
486
-        CriteriaAchievedPercentage[id] = parseFloat($(this).find('span').text());
487
-
488
-        //Set whether criterion was achieved (1) or not (0)
489
-        if(CriteriaAchievedPercentage[id] >= expected_percentage)
490
-        {
491
-            CriteriaAchievedResults[id]=1;
492
-        }
493
-        else if (CriteriaAchievedPercentage[id] < expected_percentage)
494
-        {
495
-            CriteriaAchievedResults[id]=0;
496
-        }
497
-        else
498
-        {
499
-            CriteriaAchievedResults[id]=null;
500
-        }
501
-
502
-    });
503
-
504
-    // console.log('criteria percentages: '+JSON.stringify(CriteriaAchievedPercentage));
505
-    // console.log('criteria achieved results: '+JSON.stringify(CriteriaAchievedResults));
506
-
507
-
508
-    // Save activity to the database
509
-    $.post
510
-    (
511
-        "{{ URL::action('ActivitiesController@saveAssessment') }}",
512
-        {
513
-            activity_id: activity_id,
514
-            draft: draft,
515
-            criteria_achieved_percentage: JSON.stringify(CriteriaAchievedPercentage),
516
-            criteria_achievement: JSON.stringify(CriteriaAchievedResults),
517
-            student_scores: JSON.stringify(studentAssessments),
518
-        },
519
-        function(data)
520
-        {
521
-            location.replace(data);
522
-        }
523
-    );
524
 
550
 
525
-});
526
 
551
 
527
 // Language button is clicked
552
 // Language button is clicked
528
 $('#button-language').on('click', function(e)
553
 $('#button-language').on('click', function(e)
539
         type: 'POST',
564
         type: 'POST',
540
         url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
565
         url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
541
         data: {
566
         data: {
542
-            rubric_id: $(this).closest('table').data('rubric-id'),
543
-            criterion_id: $(this).data('criterion-id'),
567
+            rubric_criterion_id: $(this).data('rubric-criterion-id')
544
         },
568
         },
545
         success: function(data)
569
         success: function(data)
546
         {
570
         {
547
             data = JSON.parse(data);
571
             data = JSON.parse(data);
548
-            $('.modal-title').html(data.name);
549
-
572
+            $('.modal-title').html(data.criteria.name);
573
+            descriptions = '';
550
             $('.modal-body tbody tr').empty();
574
             $('.modal-body tbody tr').empty();
575
+            for(i =0; i<{{$rubric->num_scales}}; i++){
576
+                descriptions += '<td>'+data[i].description+'</td>'
577
+            }
551
             $('.modal-body tbody tr').append
578
             $('.modal-body tbody tr').append
552
             (
579
             (
553
-                '<td>'+data.description12+'</td>'
554
-                +'<td>'+data.description34+'</td>'
555
-                +'<td>'+data.description56+'</td>'
556
-                +'<td>'+data.description78+'</td>'
580
+                descriptions
557
             );
581
             );
558
 
582
 
559
-            if(data.notes!=null)
560
-                $('.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>');
561
             else
585
             else
562
                 $('.modal-body tbody tr').append('<td></td>');
586
                 $('.modal-body tbody tr').append('<td></td>');
563
 
587
 

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

59
               <span>{{{ $criterion->name }}}</span><sup></sup>
59
               <span>{{{ $criterion->name }}}</span><sup></sup>
60
               @if(property_exists($criterion, 'subcriteria'))
60
               @if(property_exists($criterion, 'subcriteria'))
61
                 <ul class="list-unstyled">
61
                 <ul class="list-unstyled">
62
-                  @foreach($criterion->subcriteria as $subcriterion)
62
+                  @foreach(json_decode($criterion->subcriteria) as $subcriterion)
63
                       <li>{{ $subcriterion }}</li>
63
                       <li>{{ $subcriterion }}</li>
64
                   @endforeach
64
                   @endforeach
65
                 </ul>
65
                 </ul>