123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <?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::with('program')
- ->where('user_id', Auth::user()->id)
- ->whereIn('semester_id', Session::get('semesters_ids'))
- ->select("courses.*") //, 'programs.*')
- ->addSelect(DB::raw("1 as grouped"))
- ->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', 'level'))
- ->whereNull('deleted_at')
- ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
- ->orderBy('name', 'ASC')->get();
- $outcomeCount = count($outcomes);
-
-
-
-
-
-
-
-
- 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 = [];
-
- foreach ($outcomes as $outcome) {
- $outcomes_achieved[$outcome->id] = 0;
- $outcomes_attempted[$outcome->id] = 0;
- }
-
- // Find sections belonging to user with identifier of one course
- $sections = Course::with('program')
- ->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();
-
- $results = $grouped_course->student_report_for_outcome;
- Log::info($results);
- foreach ($outcomes as $outcome) {
- $outcomes_attempted[$outcome->id] += isset($results[$outcome->id]) ? $results[$outcome->id]['calculations']['student_attempted'] : 0;
- $outcomes_achieved[$outcome->id] += isset($results[$outcome->id]) ? $results[$outcome->id]['calculations']['student_achieved'] : 0;
- }
-
- // Log::info($sections);
-
- // 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();
- $semesters2 = Semester::whereIn('id', Session::get('semesters_ids'))->get();
-
- // $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
- // ->where('level','=',)
- // ->whereNull('deleted_at')
- // ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
- // ->orderBy('name', 'ASC')->get();
- $outcomes = Outcome::active_by_semesters($semesters2, $program->is_graduate);
- $outcomeCount = count($outcomes);
- $outcomes_achieved = [];
- $outcomes_attempted = [];
- $program_outcomes_achieved = [];
- $program_outcomes_attempted = [];
-
- //Log::info($program_courses);
-
- foreach ($outcomes as $outcome) {
- $outcomes_achieved[$outcome->id] = 0;
- $outcomes_attempted[$outcome->id] = 0;
- $program_outcomes_achieved[$outcome->id] = 0;
- $program_outcomes_attempted[$outcome->id] = 0;
- }
-
- $program_outcomes_attempted = $program->program_students_per_outcome['program_info']['outcomes_attempted_combined'];
- $program_outcomes_achieved = $program->program_students_per_outcome['program_info']['outcomes_achieved_combined'];
-
- /*
- 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;
- }
- }
- }*/
-
- foreach ($program_courses as $course) {
-
- $stu_ach = $course->student_report_for_outcome;
-
-
- foreach ($stu_ach as $outcome => $outcome_score) {
- if (array_key_exists($outcome, $outcomes_achieved))
- $outcomes_achieved[$outcome] += $outcome_score['calculations']['student_achieved'];
- else $outcomes_achieved[$outcome] = $outcome_score['calculations']['student_achieved'];
-
- if (array_key_exists($outcome, $outcomes_attempted))
- $outcomes_attempted[$outcome] += $outcome_score['calculations']['student_attempted'];
- else $outcomes_attempted[$outcome] = $outcome_score['calculations']['student_attempted'];
- }
- /*
- $course->with_program_report = 1;
-
- $stu_ach = $course->student_report_for_outcome;
-
-
- foreach ($stu_ach as $outcome => $outcome_score) {
- if (array_key_exists($outcome, $program_outcomes_achieved))
- $program_outcomes_achieved[$outcome] += $outcome_score['calculations']['student_achieved'];
- else $program_outcomes_achieved[$outcome] = $outcome_score['calculations']['student_achieved'];
-
- if (array_key_exists($outcome, $program_outcomes_attempted))
- $program_outcomes_attempted[$outcome] += $outcome_score['calculations']['student_attempted'];
- else $program_outcomes_attempted[$outcome] = $outcome_score['calculations']['student_attempted'];
- }*/
- }
-
-
-
-
-
- // 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', 'program_outcomes_achieved', 'program_outcomes_attempted', 'outcomes_attempted', 'program', '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'));
- }
- }
|