12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019 |
- <?php
-
- use Illuminate\Database\Eloquent\Collection;
-
- class ActivitiesController extends \BaseController
- {
-
-
-
- public function create($id)
- {
-
-
- $validator = Validator::make(
- array(
- 'name' => Input::get('name'),
- 'description' => Input::get('description')
- ),
- array(
- 'name' => 'required|unique:activities,course_id,' . $id,
- 'description' => 'required|min:10'
- )
- );
-
-
-
- if ($validator->fails()) {
-
- $message = 'Error(s) creating a new Activity<ul>';
-
- foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
- $message .= $validationError;
- }
-
- $message .= '</ul>';
-
-
- Session::flash('status', 'danger');
- Session::flash('message', $message);
- return Redirect::back()->withInput();
- } else {
-
- $activity = new Activity;
- $activity->name = Input::get('name');
- $activity->description = Input::get('description');
- $activity->course_id = $id;
-
-
- $activity->draft = 1;
- $activity->diagnostic = 0;
-
- $activity->date = date('Y-m-d');
-
-
- if ($activity->save()) {
- Session::flash('status', 'success');
- Session::flash('message', 'Activity created.');
- return Redirect::action('ActivitiesController@show', array($activity->id));
- }
-
-
- else {
- Session::flash('status', 'warning');
- Session::flash('message', 'Error adding Activity. Please try again later.');
- return Redirect::back()->withInput();
- }
- }
- }
-
- public function newCreate($course_id = null)
- {
- $title = 'Create Activity';
- $activity_types = [];
- $instruments = Rubric::all();
- $courses = Course::where('user_id', Auth::user()->id)->get();
- $outcomes = Outcome::with('objectives')->get();
-
- $objectives_by_outcome = Collection::make([]);
- $outcomes->each(function ($outcome) use (&$objectives_by_outcome) {
-
- $objectives_by_outcome->put($outcome->id, $outcome->objectives);
-
- });
- $criteria_by_objective = Collection::make([]);
- $objectives_by_outcome->each(function ($objectives) use (&$criteria_by_objective) {
- $objectives->each(function ($objective) use (&$criteria_by_objective) {
- $criteria_by_objective->put($objective->id, $objective->criteria);
- });
- });
- $transforming_actions = [];
- $course = Course::find($course_id);
-
-
- return View::make(
- 'local.managers.admins.new-activity-create',
- compact(
- 'title',
- 'course',
- 'activity_types',
- 'instruments',
- 'courses',
- 'outcomes',
- 'objectives_by_outcome',
- 'criteria_by_objective',
- 'transforming_actions'
- )
- );
- }
-
-
-
- public function show($id)
- {
- $activity = Activity::find($id);
-
-
-
- if (!$activity)
- App::abort('404');
-
-
- $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
-
-
- if ($course->user_id != Auth::id() and Auth::user()->role == 4)
- App::abort('403', 'Access Forbidden');
-
-
- $active_semesters = array();
- $active_semesters_collection = Semester::select('id')->where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get();
- foreach ($active_semesters_collection as $active_semester) {
- $active_semesters[] = $active_semester->id;
- }
-
- Log::info($active_semesters);
-
- $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
-
- $semesters = DB::table('semesters')->where('id', $course->semester_id)->orderBy('start', 'ASC')->first();
-
-
-
-
- $level = DB::table('courses')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->where('courses.id', $activity->course_id)
-
-
- ->select('programs.is_graduate')
- ->first();
- $outcomes = Outcome::active_by_semesters(array($course->semester), $level->is_graduate);
-
-
- $assessment = DB::table('assessments')
- ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
- ->where('activity_id', $activity->id)
- ->get();
-
-
-
-
-
-
-
-
-
-
-
- $outcomes_activity = $activity->getOutcomeReport();
-
-
-
- $activity_criterion = DB::table('criteria')
- ->join('activity_criterion', 'criteria.id', '=', 'activity_criterion.criterion_id')
- ->where('activity_id', $activity->id)
- ->select('activity_criterion.id', 'activity_criterion.criterion_id')
- ->addSelect('criteria.name')
- ->get();
-
-
- $transformative_actions = DB::table('transformative_activity_criterion')
- ->join('activity_criterion', 'transformative_activity_criterion.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('transformative_actions', 'transformative_activity_criterion.trans_action_id', '=', 'transformative_actions.id')
- ->where('activity_criterion.activity_id', $id)
- ->get();
- return View::make('local.professors.activity', compact('activity', 'outcomes_activity', 'transformative_actions', 'activity_criterion', 'title', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'course', 'student_count', 'active_semesters'));
- }
-
-
- public function assess($id)
- {
- $activity = Activity::find($id);
-
-
- if (!$activity)
- App::abort('404');
-
-
- $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
-
-
- if ($course->user_id != Auth::id())
- App::abort('403', 'Access Forbidden');
-
- $title = 'Assessment Sheet';
- $students = $course->students;
-
-
- $rubric = Rubric::find($activity->rubric[0]->id);
- $rubric->titles = DB::table('titles')
- ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
- ->where('rubric_title.rubric_id', '=', $rubric->id)
- ->lists('text');
-
- $rubric_criterion = DB::table('criteria')
- ->join("rubric_criterion", "rubric_criterion.criterion_id", "=", "criteria.id")
- ->join("activity_criterion", "criteria.id", '=', 'activity_criterion.criterion_id')
- ->where("activity_criterion.activity_id", '=', $activity->id)
- ->where('rubric_criterion.rubric_id', '=', $rubric->id)
- ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
- ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
- ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
- ->get();
- $total_weights = 0;
- foreach ($rubric_criterion as $index => $singleCR) {
- $singleCR->scales = json_encode(DB::table('scales')
- ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
- ->where('criterion_scale.criterion_id', '=', $singleCR->criterion_id)
- ->orderBy('position')
- ->lists('description'));
- $total_weights += $singleCR->weight;
- }
- $rubric_criterion_ids = DB::table('rubric_criterion')->where('rubric_id', '=', $rubric->id)->lists('id');
-
-
-
-
-
-
-
- $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
-
- $assessments = DB::table('assessments')
- ->join('students', 'assessments.student_id', '=', 'students.id')
- ->whereIn('activity_criterion_id', $activity_criterion_ids)
- ->orderBy('assessments.id', 'asc')->get();
-
-
- $scores_array = array();
-
- foreach ($assessments as $index => $assessment) {
- $scores_array[$assessment->student_id][$assessment->activity_criterion_id] = $assessment->score;
- $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
- ->where("activity_id", '=', $activity->id)
- ->select('comments')->first()->comments;
- }
-
-
- return View::make('local.professors.assessment', compact('total_weights', 'activity', 'title', 'students', 'course', 'rubric_criterion', 'assessments', 'scores_array', 'rubric'));
- }
-
- public function saveAssessment()
- {
- try {
- $exception = DB::transaction(function () {
- DB::transaction(function () {
-
-
- $activity_id = Input::get('activity_id');
- $student_data = json_decode(Input::get('student_info'));
- $weights = json_decode(Input::get('weights'));
- Log::info(json_encode($weights));
- Log::info(json_encode($student_data));
-
- foreach ($student_data as $index => $student_dict) {
- $student_id = $student_dict->studentId;
- foreach ($student_dict->activity_crit_id as $act_crit_id => $score) {
- Log::info(json_encode($score));
- if (DB::table('assessments')->where('student_id', '=', $student_id)
- ->where('activity_criterion_id', '=', $act_crit_id)
- ->first()
- ) {
- DB::table('assessments')->where('student_id', '=', $student_id)
- ->where('activity_criterion_id', '=', $act_crit_id)
- ->update(array('score' => $score));
- } else {
- if($score==null)
- {
- DB::insert("insert into assessments (`activity_criterion_id`, `student_id`) values ({$act_crit_id}, {$student_id})");
- }
- else
- {
- DB::insert("insert into assessments (`activity_criterion_id`, `student_id`, `score`) values ({$act_crit_id}, {$student_id}, {$score})");
- }
- }
- }
- if (DB::table('activity_student')
- ->where('student_id', '=', $student_id)->where('activity_id', '=', $activity_id)
- ->first()
- ) {
- DB::table('activity_student')
- ->where('student_id', '=', $student_id)->where('activity_id', '=', $activity_id)
- ->update(array('comments' => $student_dict->comments));
- } else {
- DB::insert("insert into activity_student (`activity_id`, `student_id`, `comments`) values ({$activity_id}, {$student_id}, '{$student_dict->comments}')");
- }
- }
- $activity_draft = Input::get('draft');
- $activity_diagnostic = Input::get('diagnostic');
- Log::info(json_encode($weights));
- foreach ($weights as $act_crit => $weigh) {
- DB::update("update activity_criterion set weight = {$weigh} where id = {$act_crit}");
- }
- DB::update("update activities set draft = {$activity_draft}, diagnostic = {$activity_diagnostic} where id = {$activity_id}");
-
- Session::flash('status', 'success');
- Session::flash('message', 'Assessment Saved. To add Formative actions click "Formative Actions".');
- return action('ActivitiesController@show', array(Input::get('activity_id')));
-
- $outcomeCount = Outcome::all()->count();
-
-
-
- $activity = Activity::find(Input::get('activity_id'));
-
-
-
- if ($activity->outcomes_attempted == NULL) {
-
- foreach ($student_data as $single_student_data) {
-
- $student = Student::find($single_student_data->student_id);
-
- $comments = trim($single_student_data->comments);
- if ($comments == '') {
- $comments = NULL;
- }
-
-
-
- $student->assessed_activities()->attach($activity->id, array(
- 'scores' => json_encode($single_student_data->scores),
- 'comments' => $single_student_data->comments
- ));
- }
- } else {
-
- foreach ($student_data as $single_student_data) {
-
- $student = Student::find($single_student_data->student_id);
-
- $comments = trim($single_student_data->comments);
- if ($comments == '') {
- $comments = NULL;
- }
-
-
- $student->assessed_activities()->updateExistingPivot($activity->id, array(
- 'scores' => json_encode($single_student_data->scores),
- 'percentage' => $single_student_data->percentage,
- 'comments' => $single_student_data->comments
- ));
- }
- }
-
-
-
- $criteria_achievement = json_decode(Input::get('criteria_achievement'));
- $outcomes_attempted = array_fill(1, $outcomeCount, 0);
- $outcomes_achieved = array_fill(1, $outcomeCount, 0);
-
-
- $course = $activity->course;
- $course_outcomes_attempted = NULL;
- $course_outcomes_achieved = NULL;
-
- if ($course->outcomes_attempted == NULL) {
- $course_outcomes_attempted = array_fill(1, $outcomeCount, 0);
- $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
- } else {
-
- $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
- $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
- }
-
-
- foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
-
- $criterion = Criterion::withTrashed()->find($criterion_id);
- $outcome = Outcome::find($criterion->outcome_id);
-
-
- if ($criterion_achieved === 1) {
- $outcomes_attempted[$outcome->id] += 1;
- $outcomes_achieved[$outcome->id] += 1;
- $course_outcomes_attempted[$outcome->id] += 1;
- $course_outcomes_achieved[$outcome->id] += 1;
- }
-
- elseif ($criterion_achieved === 0) {
- $outcomes_attempted[$outcome->id] += 1;
- $course_outcomes_attempted[$outcome->id] += 1;
- }
- }
-
-
- if (count(array_unique($outcomes_attempted)) == 1 && $outcomes_attempted[1] == 0)
- throw new Exception("Error Processing Request", 1);
-
-
-
-
- $activity->criteria_achieved = Input::get('criteria_achievement');
- $activity->criteria_achieved_percentage = Input::get('criteria_achieved_percentage');
- $activity->outcomes_attempted = json_encode($outcomes_attempted);
- $activity->outcomes_achieved = json_encode($outcomes_achieved);
-
-
-
- if (Input::get('draft') == false) {
-
- $course->outcomes_achieved = json_encode($course_outcomes_achieved);
- $course->outcomes_attempted = json_encode($course_outcomes_attempted);
- $course->save();
-
- $activity->draft = false;
- } else {
-
- $activity->draft = true;
- }
-
-
- $activity->save();
-
-
-
- $activities = DB::table('activities')
- ->where('course_id', $activity->course->id)
- ->where('draft', 0)
- ->get();
-
-
-
- $remainingAssessed = false;
- foreach ($activities as $activity1) {
- if ($activity1->outcomes_attempted != NULL) {
- $remainingAssessed = true;
- break;
- }
- }
-
-
- if (count($activities) && $remainingAssessed) {
- $outcomeCount = Outcome::all()->count();
-
-
- $course_outcomes_attempted = array_fill(1, $outcomeCount, 0);
- $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
-
-
- foreach ($activities as $activity2) {
-
- if ($activity2->outcomes_attempted != NULL) {
-
- $criteria_achievement = json_decode($activity2->criteria_achieved, true);
- foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
-
- $criterion = Criterion::withTrashed()->find($criterion_id);
- $outcome = Outcome::find($criterion->outcome_id);
-
-
- if ($criterion_achieved === 1) {
- $course_outcomes_attempted[$outcome->id] += 1;
- $course_outcomes_achieved[$outcome->id] += 1;
- }
-
- elseif ($criterion_achieved === 0) {
- $course_outcomes_attempted[$outcome->id] += 1;
- }
- }
- }
- }
-
-
- DB::table('courses')
- ->where('id', $course->id)
- ->update(array(
- 'outcomes_attempted' => json_encode($course_outcomes_attempted),
- 'outcomes_achieved' => json_encode($course_outcomes_achieved),
- 'updated_at' => date('Y-m-d H:i:s')
- ));
- }
-
- else {
- DB::table('courses')
- ->where('id', $course->id)
- ->update(array(
- 'outcomes_attempted' => NULL,
- 'outcomes_achieved' => NULL,
- 'updated_at' => date('Y-m-d H:i:s')
- ));
- }
- });
- });
-
- if (is_null($exception)) {
- Session::flash('status', 'success');
- Session::flash('message', 'Assessment Saved. To add Formative actions click "Formative Actions".');
- return action('ActivitiesController@show', array(Input::get('activity_id')));
- }
- } catch (Exception $e) {
- Log::info('e:' . $e);
- echo $e->getMessage();
- Session::flash('status', 'danger');
- Session::flash('message', 'Error saving assessment. Try again later.');
-
- return action('ActivitiesController@show', array(Input::get('activity_id')));
- }
- }
-
- public function deleteAssessment()
- {
-
- try {
- $exception = DB::transaction(function () {
- $activity = DB::table('activities')->where('id', Input::get('id'))->first();
-
- $course = DB::table('courses')->where('id', $activity->course_id)->first();
-
-
-
- DB::table('activities')
- ->where('id', Input::get('id'))
- ->update(array(
- 'draft' => 1,
- 'assessment_comments' => NULL,
-
-
-
- 'updated_at' => date('Y-m-d H:i:s')
- ));
-
-
-
- DB::table('assessments')
- ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->where('activity_id', $activity->id)->delete();
-
-
-
-
- });
-
- if (is_null($exception)) {
- Session::flash('status', 'success');
- Session::flash('message', 'Assessment deleted.');
- return Redirect::back();
- }
- } catch (Exception $e) {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error saving assessment. Try again later.');
-
- return Redirect::back();
- }
- }
-
- public function destroy($id)
- {
- $course = Activity::find($id)->course;
-
- if (Activity::destroy($id)) {
-
-
-
-
-
-
- Session::flash('status', 'success');
- Session::flash('message', 'Activity deleted.');
- return Redirect::action('CoursesController@show', array($course->id));
- } else {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error deleting activity. Try again later.');
- return Redirect::back();
- }
- }
-
- public function update($id)
- {
- try {
- $activity = Activity::find($id);
-
- if (Input::has('update_activity_information')) {
-
- $validator = Validator::make(
- array(
- 'name' => Input::get('name'),
- 'description' => Input::get('description'),
- 'date' => Input::get('date'),
- ),
- array(
- 'name' => 'required|unique:activities,course_id,' . $id,
- 'description' => 'required|min:10',
- 'date' => 'required|dateFormat:Y-m-d'
- ),
- array(
- 'date.dateFormat' => 'The date does not match the correct format: yyyy-mm-dd.'
- )
- );
-
-
- if ($validator->fails()) {
-
- $message = 'Error(s) updating the Activity<ul>';
-
- foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
- $message .= $validationError;
- }
-
- $message .= '</ul>';
-
-
- Session::flash('status', 'warning');
- Session::flash('message', $message);
- return Redirect::back()->withInput();
- }
-
-
- $activity->name = Input::get('name');
- $activity->description = Input::get('description');
- $activity->date = Input::get('date');
- }
- elseif (Input::has('update_assessment_comments')) {
- if (trim(Input::get('assessment_comments')) != "")
- $activity->assessment_comments = Input::get('assessment_comments');
- else
- $activity->assessment_comments = NULL;
- } else {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error updating Activity. Please try again later.');
- return Redirect::action('ActivitiesController@show', array($activity->id));
- }
-
- $activity->save();
-
-
- Session::flash('status', 'success');
- Session::flash('message', 'Activity succesfully updated.');
- return Redirect::action('ActivitiesController@show', array($activity->id));
- } catch (Exception $e) {
- Session::flash('status', 'warning');
- Session::flash('message', 'Error updating Activity. Please try again later.');
- return Redirect::action('ActivitiesController@show', array($activity->id));
- }
- }
-
-
-
- public function viewAssessment($id)
- {
- $activity = Activity::find($id);
-
-
- if (!$activity)
- App::abort('404');
-
-
- $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
-
-
- if ($course->user_id != Auth::id())
- App::abort('403', 'Access Forbidden');
-
- $students = $course->students;
-
-
- $rubric = Rubric::find($activity->rubric[0]->id);
-
-
- $rubric->titles = DB::table('titles')
- ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
- ->where('rubric_id', $rubric->id)
- ->orderBy("position", 'ASC')
- ->lists('text');
-
-
-
-
- $rubric_criterion = DB::table('criteria')
- ->join("rubric_criterion", "rubric_criterion.criterion_id", "=", "criteria.id")
- ->join("activity_criterion", "criteria.id", '=', 'activity_criterion.criterion_id')
- ->where("activity_criterion.activity_id", '=', $activity->id)
- ->where('rubric_criterion.rubric_id', '=', $rubric->id)
- ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
- ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
- ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
- ->get();
-
-
- foreach ($rubric_criterion as $index => $crit) {
- $crit->scales = DB::table('scales')
- ->join('criterion_scale', 'scales.id', '=', 'criterion_scale.scale_id')
- ->where('criterion_id', $crit->criterion_id)
- ->get();
- }
-
-
-
-
-
- $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
- Log::info($activity_criterion_ids);
- $assessments = DB::table('assessments')
- ->join('students', 'assessments.student_id', '=', 'students.id')
- ->whereIn('activity_criterion_id', $activity_criterion_ids)
- ->orderBy('assessments.id', 'asc')->get();
- Log::info($assessments);
-
- $scores_array = array();
-
- foreach ($assessments as $index => $assessment) {
- $scores_array[$assessment->student_id][$assessment->activity_criterion_id] = $assessment->score;
- $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
- ->where("activity_id", '=', $activity->id)
- ->select('comments')->first()->comments;
- }
- $title = 'Assessment Sheet';
-
- return View::make('local.professors.view_assessment', compact('activity', 'title', 'students', 'course', 'rubric_criterion', 'assessments', 'scores_array', 'rubric'));
- }
-
- public function printAssessment($id)
- {
- $activity = Activity::find($id);
-
-
- if (!$activity)
- App::abort('404');
-
-
- $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
-
-
- if ($course->user_id != Auth::id())
- App::abort('403', 'Access Forbidden');
-
- $title = 'Assessment Sheet';
- $students = $course->students;
-
-
- $rubric = Rubric::find($activity->rubric[0]->id);
- $rubric_contents = DB::table('criteria')
- ->join("rubric_criterion", "rubric_criterion.criterion_id", "=", "criteria.id")
- ->join("activity_criterion", "criteria.id", '=', 'activity_criterion.criterion_id')
- ->where("activity_criterion.activity_id", '=', $activity->id)
- ->where('rubric_criterion.rubric_id', '=', $rubric->id)
- ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
- ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
- ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
- ->get();
- $rubric->titles = DB::table('titles')
- ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
- ->where('rubric_id', $rubric->id)
- ->orderBy("position", 'ASC')
- ->lists('text');
-
-
- foreach ($rubric_contents as $index => $crit) {
- $crit->scales = DB::table('scales')
- ->join('criterion_scale', 'scales.id', '=', 'criterion_scale.scale_id')
- ->where('criterion_id', $crit->criterion_id)
- ->get();
- }
-
-
-
-
-
-
-
-
- $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
- Log::info($activity_criterion_ids);
- $assessments = DB::table('assessments')
- ->join('students', 'assessments.student_id', '=', 'students.id')
- ->whereIn('activity_criterion_id', $activity_criterion_ids)
- ->orderBy('assessments.id', 'asc')->get();
- Log::info($assessments);
-
- $scores_array = array();
-
- foreach ($assessments as $index => $assessment) {
-
- $scores_array[$assessment->student_id][$assessment->activity_criterion_id] = $assessment->score;
- $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
- ->where("activity_id", '=', $activity->id)
- ->select('comments')->first()->comments;
- }
-
-
- return View::make('local.professors.print_assessment', compact('activity', 'title', 'students', 'course', 'rubric_contents', 'assessments', 'scores_array', 'rubric'));
- }
-
- public function compareActivities($activity_1, $activity_2)
- {
- $activity_1 = Activity::find($activity_1);
- $activity_2 = Activity::find($activity_2);
-
-
-
- if (!$activity_1 || !$activity_2)
- App::abort('404');
-
-
- $course = Course::where('id', '=', $activity_1->course_id)->firstOrFail();
-
-
- if ($course->user_id != Auth::id() and Auth::user()->role == 4)
- App::abort('403', 'Access Forbidden');
-
-
- $active_semesters = array();
- $active_semesters_collection = Semester::select('id')->where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get();
- foreach ($active_semesters_collection as $active_semester) {
- $active_semesters[] = $active_semester->id;
- }
-
- $semesters = DB::table('semesters')->where('id', $course->semester_id)->orderBy('start', 'ASC')->first();
-
- Log::info($active_semesters);
-
- $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity_1->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
- $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
- ->whereNull('deleted_at')
- ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
- ->orderBy('name', 'ASC')->get();
- $assessment_1 = DB::table('assessments')
- ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
- ->where('activity_id', $activity_1->id)
- ->get();
-
-
-
- if ($assessment_1) {
- $results_1 = $activity_1->getOutcomeReport();
- $outcomes_achieved_1 = $activity_1->o_ach_array;
- $outcomes_attempted_1 = $activity_1->o_att_array;
- } else {
- $outcomes_achieved_1 = [];
- $outcomes_attempted_1 = [];
- }
-
- $assessment_2 = DB::table('assessments')
- ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
- ->where('activity_id', $activity_2->id)
- ->get();
-
- if ($assessment_2) {
- $results_2 = $activity_1->getOutcomeReport();
- $outcomes_achieved_2 = $activity_2->o_ach_array;
- $outcomes_attempted_2 = $activity_2->o_att_array;
- } else {
- $outcomes_achieved_2 = [];
- $outcomes_attempted_2 = [];
- }
-
-
-
- $activity_criterion_2 = DB::table('criteria')
- ->join('activity_criterion', 'criteria.id', '=', 'activity_criterion.criterion_id')
- ->where('activity_id', $activity_2->id)
- ->select('activity_criterion.id', 'activity_criterion.criterion_id')
- ->addSelect('criteria.name')
- ->get();
-
-
-
-
- return View::make('local.professors.compare_activities', compact('results_1', 'results_2', 'activity_1', 'activity_2', 'activity_criterion_1', 'activity_criterion_2', 'title', 'outcomes', 'outcomes_achieved_1', 'outcomes_attempted_1', 'outcomes_achieved_2', 'outcomes_attempted_2', 'course', 'student_count', 'active_semesters'));
- }
- }
|