|
@@ -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
|
}
|
|
@@ -166,94 +169,160 @@ class RubricsController extends \BaseController
|
166
|
169
|
*/
|
167
|
170
|
public function update()
|
168
|
171
|
{
|
|
172
|
+ Log::info('entré???');
|
169
|
173
|
$rubric = Rubric::find(Input::get('id'));
|
|
174
|
+
|
|
175
|
+ $scales = Input::get('scales');
|
|
176
|
+ $criteria = Input::get('criteria');
|
|
177
|
+
|
|
178
|
+ // Process rubric
|
170
|
179
|
$rubric->name = Input::get('name');
|
171
|
180
|
|
172
|
181
|
$rubric->expected_percentage = Input::get('expected_percentage');
|
173
|
182
|
$rubric->expected_points = Input::get('expected_points');
|
174
|
183
|
|
|
184
|
+ $rubric->num_scales = count($scales[0]);
|
|
185
|
+ $rubric->max_score = Input::get('max_score');
|
|
186
|
+ $division = $rubric->max_score / count($scales[0]);
|
|
187
|
+
|
175
|
188
|
DB::beginTransaction();
|
176
|
189
|
|
177
|
|
- try {
|
178
|
|
- // Get associated activity
|
179
|
|
- $activity = Activity::where('rubric_id', '=', $rubric->id)->first();
|
180
|
190
|
|
181
|
|
- // 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) {
|
182
|
225
|
if ($activity->outcomes_attempted != NULL) {
|
183
|
|
- DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
|
184
|
|
- $activity->criteria_achieved_percentage = NULL;
|
185
|
|
- $activity->criteria_achieved = NULL;
|
186
|
|
- $activity->outcomes_achieved = NULL;
|
187
|
|
- $activity->outcomes_attempted = NULL;
|
|
226
|
+ $remainingAssessed = true;
|
|
227
|
+ break;
|
188
|
228
|
}
|
|
229
|
+ }
|
|
230
|
+ Log::info('entré4???');
|
189
|
231
|
|
190
|
|
- $rubric->save();
|
191
|
|
- $activity->save();
|
192
|
|
-
|
193
|
|
- // Get all the course's activities
|
194
|
|
- $course = Course::find($activity->course->id);
|
195
|
|
- $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);
|
196
|
237
|
|
197
|
|
- // Check if any assessed activities remain
|
198
|
|
- $remainingAssessed = false;
|
199
|
|
- foreach ($course->activities as $activity) {
|
|
238
|
+ // For each activity
|
|
239
|
+ foreach ($activities as $activity) {
|
|
240
|
+ // If activity has been assessed
|
200
|
241
|
if ($activity->outcomes_attempted != NULL) {
|
201
|
|
- $remainingAssessed = true;
|
202
|
|
- 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
|
+ }
|
203
|
259
|
}
|
204
|
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
|
+ }
|
205
|
270
|
|
206
|
|
- //If there are still evaluated activities in the course, recalculate course outcomes
|
207
|
|
- if (!$activities->isEmpty() && $remainingAssessed) {
|
208
|
|
- // Variables to hold recalculated outcomes for the course
|
209
|
|
- $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
|
210
|
|
- $course_outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
|
211
|
|
-
|
212
|
|
- // For each activity
|
213
|
|
- foreach ($activities as $activity) {
|
214
|
|
- // If activity has been assessed
|
215
|
|
- if ($activity->outcomes_attempted != NULL) {
|
216
|
|
- // Get the achieved criteria
|
217
|
|
- $criteria_achievement = json_decode($activity->criteria_achieved, true);
|
218
|
|
- foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
|
219
|
|
- // Find corresponding learning outcome;
|
220
|
|
- $criterion = Criterion::find($criterion_id);
|
221
|
|
- $outcome = Outcome::find($criterion->outcome_id);
|
222
|
|
-
|
223
|
|
- // If criterion is achieved (1), add 1 to both arrays
|
224
|
|
- if ($criterion_achieved === 1) {
|
225
|
|
- $course_outcomes_attempted[$outcome->id] += 1;
|
226
|
|
- $course_outcomes_achieved[$outcome->id] += 1;
|
227
|
|
- }
|
228
|
|
- // Else, only add to the attempted outcomes arrays
|
229
|
|
- elseif ($criterion_achieved === 0) {
|
230
|
|
- $course_outcomes_attempted[$outcome->id] += 1;
|
231
|
|
- }
|
|
271
|
+ $course->save();
|
|
272
|
+ Log::info('entré6???');
|
|
273
|
+ DB::delete("delete from criterion_rubric where rubric_id ={$rubric->id}");
|
|
274
|
+ foreach ($criteria as $index => $criterion_id) {
|
|
275
|
+ if (
|
|
276
|
+
|
|
277
|
+ DB::insert("insert into criterion_rubric (`rubric_id`, `criterion_id`) values ({$rubric->id}, {$criterion_id}) ")
|
|
278
|
+ ) {
|
|
279
|
+ Log::info("AHH");
|
|
280
|
+ $rubric_criterion_id = DB::table('criterion_rubric')
|
|
281
|
+ ->where('rubric_id', '=', $rubric->id)
|
|
282
|
+ ->where('criterion_id', '=', $criterion_id)
|
|
283
|
+ ->first();
|
|
284
|
+
|
|
285
|
+ foreach ($scales[$index] as $in => $scale) {
|
|
286
|
+ 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();
|
|
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
|
+ $new_scale->min_score = 1 + ($division * $in);
|
|
298
|
+ $new_scale->max_score = ($division * ($in + 1));
|
|
299
|
+ 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})");
|
|
301
|
+ DB::commit();
|
|
302
|
+ } else {
|
|
303
|
+ DB::rollBack();
|
|
304
|
+ Session::flash('status', 'danger');
|
|
305
|
+ Session::flash('message', 'Rubric could not be created.');
|
|
306
|
+ return action('ActivitiesController@show', array($activity->id));
|
232
|
307
|
}
|
233
|
308
|
}
|
234
|
309
|
}
|
235
|
|
-
|
236
|
|
- // Update course
|
237
|
|
- $course->outcomes_achieved = json_encode($course_outcomes_achieved);
|
238
|
|
- $course->outcomes_attempted = json_encode($course_outcomes_attempted);
|
239
|
310
|
} else {
|
240
|
|
- // Update course
|
241
|
|
- $course->outcomes_achieved = NULL;
|
242
|
|
- $course->outcomes_attempted = NULL;
|
|
311
|
+ DB::rollBack();
|
|
312
|
+ Session::flash('status', 'danger');
|
|
313
|
+ Session::flash('message', 'Rubric could not be created.');
|
|
314
|
+ return action('ActivitiesController@show', array($activity->id));
|
243
|
315
|
}
|
|
316
|
+ }
|
|
317
|
+ Log::info('entré7???');
|
244
|
318
|
|
245
|
|
- $course->save();
|
246
|
|
- DB::commit();
|
|
319
|
+ DB::commit();
|
247
|
320
|
|
248
|
|
- Session::flash('status', 'success');
|
249
|
|
- Session::flash('message', 'Rubric updated.');
|
250
|
321
|
|
251
|
|
- return action('ActivitiesController@show', array($activity->id));
|
252
|
|
- } catch (Exception $e) {
|
253
|
|
- DB::rollBack();
|
254
|
|
- Session::flash('status', 'danger');
|
255
|
|
- Session::flash('message', 'Error: The rubric could not be updated. Try again later.');
|
256
|
|
- }
|
|
322
|
+ Session::flash('status', 'success');
|
|
323
|
+ Session::flash('message', 'Rubric updated.');
|
|
324
|
+
|
|
325
|
+ return action('ActivitiesController@show', array($activity->id));
|
257
|
326
|
}
|
258
|
327
|
|
259
|
328
|
/**
|
|
@@ -293,8 +362,27 @@ class RubricsController extends \BaseController
|
293
|
362
|
Log::info($activity->rubric[0]->id);
|
294
|
363
|
|
295
|
364
|
$rubric = Rubric::where('id', '=', $activity->rubric[0]->id)->firstOrFail();
|
|
365
|
+ $criterion_rubric = DB::table('criteria')
|
|
366
|
+ ->join('criterion_rubric', 'criterion_rubric.criterion_id', '=', 'criteria.id')
|
|
367
|
+ ->where('criterion_rubric.rubric_id', '=', $activity->rubric[0]->id)
|
|
368
|
+ ->get();
|
|
369
|
+
|
|
370
|
+ foreach ($criterion_rubric as $single_cr) {
|
|
371
|
+ $single_cr->scales = json_encode(DB::table('scales')
|
|
372
|
+ ->join('rubric_criteria_scale', 'rubric_criteria_scale.scale_id', '=', 'scales.id')
|
|
373
|
+ ->where('rubric_criteria_scale.rubric_criterion_id', '=', $single_cr->id)
|
|
374
|
+ ->orderBy('position')
|
|
375
|
+ ->lists('description'));
|
|
376
|
+ $single_cr->outcomes = json_encode(DB::table('outcomes')
|
|
377
|
+ ->join('criterion_objective_outcome', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
|
|
378
|
+ ->where('criterion_objective_outcome.criterion_id', '=', $single_cr->criterion_id)->lists('name'));
|
|
379
|
+ }
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+ Log::info($criterion_rubric);
|
|
383
|
+
|
296
|
384
|
$title = $activity->name . ': ' . $rubric->name;
|
297
|
|
- return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'title', 'course'));
|
|
385
|
+ return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'criterion_rubric', 'title', 'course'));
|
298
|
386
|
}
|
299
|
387
|
|
300
|
388
|
/**
|