123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
-
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Log;
-
- class ProgramCoordinatorsController extends \BaseController
- {
-
- public function overview()
- {
- //TODO Find a better way to prevent non-scoords from reaching the page
- switch (Auth::user()->role) {
- case 1:
- return Redirect::to('administrator');
- break;
- case 2:
- return Redirect::to('school-coordinator');
- break;
- }
- //Log::info(Auth::user()->programs);
- $title = 'Program Coordinator Overview';
-
- $programs = Auth::user()->programs;
- //Log::info($programs);
-
- //$outcomes = Outcome::orderBy('name', 'asc')->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);
-
- $programs_array = array();
- $programs_contact = array();
-
- // old code
- /*foreach ($programs as $program) {
- $program_array = array();
-
- $program_array['program'] = $program;
-
- $program_array['outcomes_achieved'] = array_fill(1, $outcomeCount, 0);
- $program_array['outcomes_attempted'] = array_fill(1, $outcomeCount, 0);
-
- $program_array['program_courses'] = $program->courses;
- $program_array['grouped_objectives'] = $program->objectives();
-
- $program_array['assessed_courses_count'] = 0;
- foreach ($program_array['program_courses'] as $course) {
- if ($course->outcomes_achieved != NULL) {
- $program_array['course_outcomes_achieved'] = json_decode($course->outcomes_achieved, true);
- $program_array['course_outcomes_attempted'] = json_decode($course->outcomes_attempted, true);
- for ($i = 1; $i <= count($program_array['outcomes_attempted']); $i++) {
- $program_array['outcomes_achieved'][$i] += $program_array['course_outcomes_achieved'][$i];
- $program_array['outcomes_attempted'][$i] += $program_array['course_outcomes_attempted'][$i];
- }
- $program_array['assessed_courses_count'] += 1;
- }
- }
- */
-
- foreach ($programs as $program) {
- //Log::info($program);
- $program_array = array();
- $program_object = new \stdClass();
- $program_object->name = $program->name;
- $program_object->school = $program->school->name;
- $program_object->id = $program->id;
- $program_array['program'] = $program_object;
- //Log::info($program_array);
-
- $program_array['outcomes_achieved'] = [];
- $program_array['outcomes_attempted'] = [];
- //Log::info($program_array);
-
- $program_array['program_courses'] = $program->courses;
- //Log::info($program_array);
- //Log::info('grouped_objectives, 1.variable, 2.array');
-
- ////Log::info(array($program->objectives()));
- // $program_array['grouped_objectives'] = $program->objectives();
- //Log::info($program_array);
- //Log::info("program_courses");
- //Log::info($program_array['program_courses']);
- //Log::info($program_array);
-
- $program_array['assessed_courses_count'] = 0;
- foreach ($program_array['program_courses'] as $course) {
- //Log::info($program_array);
-
- $program_array['course_outcomes_achieved'] = $course->outcomes_ach();
-
- //Log::info("course_outcomes_achieved");
- //Log::info($program_array['course_outcomes_achieved']);
- //Log::info($program_array);
- if (($program_array['course_outcomes_achieved'])) {
- $program_array['course_outcomes_achieved'] = $course->outcomes_ach();
- $program_array['course_outcomes_attempted'] = $course->outcomes_att();
- //Log::info('course_outcomes_achieved');
- //Log::info($program_array['course_outcomes_achieved']);
- //Log::info($program_array);
-
- foreach ($program_array['course_outcomes_achieved'] as $i => $score) {
- if (array_key_exists($i, $program_array['outcomes_achieved'])) $program_array['outcomes_achieved'][$i] += $program_array['course_outcomes_achieved'][$i];
- else $program_array['outcomes_achieved'][$i] = $program_array['course_outcomes_achieved'][$i];
- //Log::info('program["outcomes_achieved"]');
- //Log::info($program_array['outcomes_achieved'][$i]);
- //Log::info($program_array);
- Log::info("outcomes_achieved");
- Log::info($program_array['outcomes_achieved']);
- }
- foreach ($program_array['course_outcomes_attempted'] as $i => $score) {
-
- if (array_key_exists($i, $program_array['outcomes_attempted'])) $program_array['outcomes_attempted'][$i] += $program_array['course_outcomes_attempted'][$i];
- else $program_array['outcomes_attempted'][$i] = $program_array['course_outcomes_attempted'][$i];
- //Log::info('program["outcomes_achieved"]');
- //Log::info($program_array['outcomes_attempted'][$i]);
- //Log::info($program_array);
- }
-
- $program_array['assessed_courses_count'] += 1;
- }
- }
-
- /**
- * List of grouped courses (grouped sections)
- */
-
- //old code
- /* $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
- ->with('semester')
- ->with('program')
- ->where('program_id', $program->id)
- ->whereIn('semester_id', Session::get('semesters_ids'))
- ->groupBy(array('code', 'number', 'semester_id'))
- ->orderBy('code')
- ->orderBy('number')
- ->orderBy('semester_id')
- ->get(); */
- //Log::info($program_array);
- $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, semester_id, program_id'))
- ->with('semester')
- ->with('program')
- ->where('program_id', $program->id)
- ->whereIn('semester_id', Session::get('semesters_ids'))
- ->groupBy(array('code', 'number', 'semester_id'))
- ->orderBy('code')
- ->orderBy('number')
- ->orderBy('semester_id')
- ->get();
- //Log::info($program_array);
- $programs_array[] = $program_array;
-
-
-
-
- // Program contact information
- $users = User::select('users.*')
- ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
- ->where(function ($query) use ($program) {
- $query
- ->where('school_id', $program->school_id)
- ->where('role', 2);
- })
- ->orWhere(function ($query) use ($program) {
- $query
- ->where('role', 3)
- ->where('program_id', $program->id);
- })
- ->orWhere(function ($query) use ($program) {
- $query
- ->where('role', 4)
- ->where('program_id', $program->id);
- })
- ->get();
-
-
- $programs_contact[] = $users;
- }
-
-
- return View::make('local.managers.pCoords.overview', compact('title', 'programs', 'outcomes', 'programs_array', 'programs_contact'));
- }
- }
|