123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
-
- class ProfessorsController extends \BaseController
- {
-
- private $grouped_courses;
-
- public function __construct()
- {
- $this->courses = Auth::user()->courses;
- }
-
- public function overview()
- {
- $title = 'My Courses';
- $grouped_courses = Course::where('user_id', Auth::user()->id)->whereIn('semester_id', Session::get('semesters_ids'))->groupBy(array('code', 'number', 'semester_id'))->get();
- $semesters = Session::get('semesters_ids');
- $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
- Log::info($semesters->start);
- $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();
- $outcomeCount = count($outcomes);
-
-
- $grouped_outcomes_achieved_results = array();
- $grouped_outcomes_attempted_results = array();
- $grouped_sections = array();
-
- foreach ($grouped_courses as $index => $grouped_course) {
- // Blank outcomes for one course
-
- //$outcomes_achieved = array_fill(1, $outcomeCount, 0);
- //$outcomes_attempted = array_fill(1, $outcomeCount, 0);
-
- $outcomes_achieved = [];
- $outcomes_attempted = [];
-
- // Find sections belonging to user with identifier of one course
- $sections = Course::where('user_id', Auth::user()->id)
- ->where('code', $grouped_course->code)
- ->whereIn('semester_id', Session::get('semesters_ids'))
- ->where('number', $grouped_course->number)
- ->where('semester_id', $grouped_course->semester_id)
- ->get();
-
- // For each of the professor's course sections, add the attempted and achieved criteria per outcome
- foreach ($sections as $section) {
-
- $section_outcomes_achieved = $section->outcomes_ach();
- $section_outcomes_attempted = $section->outcomes_att();
-
- //if ($section->outcomes_achieved != NULL) {
- if (!empty($section_outcomes_achieved)) {
- //$section_outcomes_achieved = json_decode($section->outcomes_achieved, true);
- //$section_outcomes_attempted = json_decode($section->outcomes_attempted, true);
- foreach ($section_outcomes_attempted as $outcome_id => $score) {
-
- if (array_key_exists($outcome_id, $outcomes_achieved) && array_key_exists($outcome_id, $section_outcomes_achieved)) {
-
- $outcomes_achieved[$outcome_id] += $section_outcomes_achieved[$outcome_id];
- } elseif (array_key_exists($outcome_id, $outcomes_achieved)) {
-
- $outcomes_achieved[$outcome_id] += 0;
- } elseif (array_key_exists($outcome_id, $section_outcomes_achieved)) {
- $outcomes_achieved[$outcome_id] = $section_outcomes_achieved[$outcome_id];
- } else {
- $outcomes_achieved[$outcome_id] = 0;
- }
- if (array_key_exists($outcome_id, $outcomes_attempted)) {
- $outcomes_attempted[$outcome_id] += $section_outcomes_attempted[$outcome_id];
- } else {
- $outcomes_attempted[$outcome_id] = $section_outcomes_attempted[$outcome_id];
- }
- //$outcomes_achieved[$outcome_id] += $section_outcomes_achieved[$outcome_id];
- //$outcomes_attempted[$outcome_id] += $section_outcomes_attempted[$outcome_id];
- }
- }
- }
-
- $grouped_outcomes_achieved_results[] = $outcomes_achieved;
- $grouped_outcomes_attempted_results[] = $outcomes_attempted;
- $grouped_sections[] = $sections;
- }
-
- return View::make('local.professors.overview', compact('title', 'grouped_courses', 'outcomes', 'grouped_outcomes_attempted_results', 'grouped_outcomes_achieved_results', 'grouped_sections'));
- }
-
- public function program()
- {
- $program = Auth::user()->programs[0];
- $title = 'Your Program: ' . $program->name;
- $program_courses = Course::where('program_id', '=', $program->id)->whereIn('semester_id', Session::get('semesters_ids'))->get();
- $semesters = Session::get('semesters_ids');
- $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
-
- $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();
- $outcomeCount = count($outcomes);
- $outcomes_achieved = [];
- $outcomes_attempted = [];
-
- Log::info($program_courses);
-
-
- foreach ($program_courses as $course) {
-
-
- if ($course->outcomes_ach()) {
-
- $course_outcomes_achieved = $course->outcomes_ach();
- $course_outcomes_attempted = $course->outcomes_att();
- foreach ($course_outcomes_achieved as $outcome => $score) {
- if (array_key_exists($outcome, $outcomes_achieved))
- $outcomes_achieved[$outcome] += $score;
- else $outcomes_achieved[$outcome] = $score;
- }
- foreach ($course_outcomes_attempted as $outcome => $score) {
- if (array_key_exists($outcome, $outcomes_attempted))
- $outcomes_attempted[$outcome] += $score;
- else $outcomes_attempted[$outcome] = $score;
- }
- }
- }
-
-
- // Program contact information
- $scoords = User::where('school_id', $program->school_id)
- ->where('role', 2)
- ->get();
- $pcoords = User::select('users.*')
- ->join('program_user', 'users.id', '=', 'program_user.user_id')
- ->where('role', 3)
- ->where('program_id', $program->id)
- ->get();
-
- return View::make('local.professors.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'scoords', 'pcoords'));
- }
-
-
- public function generalStudiesOverview()
- {
-
- $title = 'General Component Assessment Overview';
-
- try {
- $programs = Program::generalComponentPrograms();
- } catch (Exception $e) {
- dd('Unable to find general component programs');
- }
-
- $outcomes = Outcome::orderBy('name', 'asc')->get();
- $schools = School::all();
- $program_packs = array();
- if (!$programs->isEmpty()) {
- foreach ($programs as $program) {
- $program_packs[] = $program->assessmentOverview();
- }
- }
-
- return View::make('local.managers.shared.general_studies_overview', compact('title', 'outcomes', 'schools', 'program_packs'));
- }
- }
|