123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- <?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();
-
- $selected_semesters = Semester::find(Session::get('semesters_ids'));
-
- $level=$program->is_graduate;
- $min_start="9000-01-01 00:00:00";
- $max_end="1000-01-01 00:00:00";
- foreach($selected_semesters as $semester)
- {
- if($min_start>$semester->start)
- {
- $min_start=$semester->start;
- }
- if($max_end<$semester->end)
- {
- $max_end=$semester->end;
- }
- }
- $outcomes = Outcome::where(function($query) use ($min_start)
- {
- $query->where('deactivation_date', '>=', $min_start)
- ->orWhere('deactivation_date', null);
- })
- ->where('activation_date', '<=', $max_end)
- ->where(function($query2) use ($level)
- {
- $query2->where("level", $level+1)
- ->orWhere("level",3);
- })
- ->orderBy('name', 'ASC')
- ->get();
- $outcomeCount = Outcome::where(function($query) use ($min_start)
- {
- $query->where('deactivation_date', '>=', $min_start)
- ->orWhere('deactivation_date', null);
- })
- ->where('activation_date', '<=', $max_end)
- ->where(function($query2) use ($level)
- {
- $query2->where("level",$level+1)
- ->orWhere("level",3);
- })
- ->count();
-
- foreach($outcomes as $outcome)
- {
- $outcomes_attempted[$outcome->id]=$program->attempted_outcome($outcome->id, $selected_semesters);
- if($outcomes_attempted[$outcome->id])$outcomes_achieved[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semesters);
- }
-
- foreach($outcomes as $outcome)
- {
- $assessed_courses[$outcome->id]=DB::table('activity_criterion')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
- ->where('criterion_objective_outcome.outcome_id','=',$outcome->id)
- ->where('programs.id','=',$program->id)
- ->where('courses.semester_id','=',$semester)
- ->count(DB::raw('DISTINCT courses.id'))
- ;
- }
- $assessed_courses_count=array_sum($assessed_courses);
- /**
- * 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();
-
- // var_dump($outcomes_attempted);
- // print "<br>";
- // var_dump($outcomes_achieved);
- // print "<br>";
- return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
-
- }
-
- public function showReport()
- {
-
-
- // create an array with the ID of Semesters selected in the form
- $selected_semesters_id = array();
- $semesters = Semester::all();
- foreach ($semesters as $semester) {
- if ($semester->is_visible){
- if (Input::get('semester'.$semester->id)!=null){
- array_push($selected_semesters_id, $semester->id);
- }
- }
- }
- $selected_semesters = DB::table('semesters')
- ->wherein('semesters.id',$selected_semesters_id)
- ->get();
-
- // create a srting with the selected metodos de divulgfacion
- $selected_divulgaciones = '';
- $divulgaciones = array('profesores','comiteDepartamental','comiteFacultadEscuela',
- 'pleno','estudiantes','administrativos','senado','comunidadWeb',
- 'otros');
- foreach ($divulgaciones as $divulgacion) {
- if (Input::get($divulgacion)!=null){
- $selected_divulgaciones = $selected_divulgaciones.'\n'.Input::get($divulgacion);
- }
- }
-
- //OUTCOMES Join criteria join program
- $programs = DB::table('programs')
- ->select('id','name')
- ->orderBy('name', 'asc')
- ->get();
-
-
-
- // $program
- $tables_names = '{';
- foreach ($programs as $program) {
- $tables_names = $tables_names.'"table'.$program->id.'" : "'.$program->name.'",';// code...
- }
- $tables_names = $tables_names.'}';
-
- $title = "Programs Reports";
- // $title = "Program Report: ".$program->name;
-
- $programs_info = array();
- //OUTCOMES Join criteria join program
- foreach ($programs as $program) {
- $info_by_id = Program::find($program->id);
-
- $domains = DB::table('outcomes')
- ->join('criteria','criteria.outcome_id','=','outcomes.id')
- ->join('programs','programs.id','=','criteria.program_id')
- ->join('courses','courses.program_id','=','programs.id')
- ->where('programs.id',$program->id)
- ->select('outcomes.name','outcomes.activation_date')
- ->distinct()
- ->orderBy('outcomes.name', 'asc')
- ->get();
-
- $courses_used = DB::table('outcomes')
- ->join('criteria','criteria.outcome_id','=','outcomes.id')
- ->join('programs','programs.id','=','criteria.program_id')
- ->join('courses','courses.program_id','=','programs.id')
- ->where('programs.id',$program->id)
- ->select('courses.number', 'outcomes.name as domain_name', 'courses.code')
- ->distinct()
- ->orderBy('courses.name', 'asc')
- ->get();
-
- $transformative_actions = DB::table('outcomes')
- ->join('criteria','criteria.outcome_id','=','outcomes.id')
- ->join('programs','programs.id','=','criteria.program_id')
- ->join('courses','courses.program_id','=','programs.id')
- ->join('activities','activities.course_id','=','courses.id')
- ->join('activity_criterion','activity_criterion.activity_id','=','activities.id')
- ->where('programs.id',$program->id)
- ->select('activity_criterion.transformative_actions', 'outcomes.name as domain_name')
- ->distinct()
- ->orderBy('activity_criterion.transformative_actions', 'asc')
- ->get();
- $info = array($info_by_id, $domains, $courses_used, $transformative_actions);
- array_push($programs_info, $info);
- }
-
-
- return View::make('local.managers.shared.program_report', compact('title','programs_info','selected_divulgaciones','selected_semesters','tables_names'));
- }
-
- // 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();
- $semesters = Semester::all();
-
- return View::make('local.managers.shared.programs', compact('programs', 'schools', 'semesters', 'title'));
- }
-
- /**
- * Fetch a program
- */
- public function fetch()
- {
- Log::info('id:'.Input::get('id'));
- return School::find(Input::get('id'))->programs;
- }
- }
|