123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
-
- class ProgramsController extends \BaseController
- {
-
- /**
- * Shows a particular program
- */
- public function show($id)
- {
-
- $program = Program::find($id);
- $title= $program->school->name.': '.$program->name;
- $program_courses = $program->courses;
- $outcomes = Outcome::orderBy('name', 'asc')->get();
- $schools = School::all();
- $outcomeCount = Outcome::all()->count();
-
-
- $outcomes_achieved = array_fill(1, $outcomeCount, 0);
- $outcomes_attempted = array_fill(1, $outcomeCount, 0);
-
- $assessed_courses_count=0;
- foreach ($program_courses as $course)
- {
- if($course->outcomes_achieved!=NULL)
- {
- $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
- $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
- for($i=1; $i<=count($outcomes_attempted); $i++)
- {
- $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
- $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
- }
- $assessed_courses_count+=1;
- }
- }
-
- /**
- * List of grouped courses (grouped sections)
- */
-
- $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();
-
- // 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();
-
- return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
-
- }
-
- /**
- * Info to print a program
- */
- public function print_program($id)
- {
-
- $program = Program::find($id);
- $title= $program->name.' Assessment Report - '.date('m/d/Y');
- $program_courses = $program->courses;
- $outcomes = Outcome::orderBy('name', 'asc')->get();
- $schools = School::all();
- $outcomeCount = Outcome::all()->count();
-
-
- $outcomes_achieved = array_fill(1, $outcomeCount, 0);
- $outcomes_attempted = array_fill(1, $outcomeCount, 0);
-
- $assessed_courses_count=0;
- foreach ($program_courses as $course)
- {
- if($course->outcomes_achieved!=NULL)
- {
- $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
- $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
- for($i=1; $i<=count($outcomes_attempted); $i++)
- {
- $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
- $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
- }
- $assessed_courses_count+=1;
- }
- }
-
- /**
- * List of grouped courses (grouped sections)
- */
-
- $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();
-
- return View::make('local.managers.shared.print_program', compact('title', 'program', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses'));
- }
-
-
- /**
- * A list of all programs
- */
- public function index()
- {
- $title = "Programs by School";
- $programs = Program::orderBy('name')->get();
- $schools = School::all();
-
- return View::make('local.managers.shared.programs', compact('programs', 'schools', 'title'));
- }
-
- /**
- * Fetch a program
- */
- public function fetch()
- {
- Log::info('id:'.Input::get('id'));
- return School::find(Input::get('id'))->programs;
- }
- }
|