12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037 |
- <?php
-
- class ProgramsController extends \BaseController
- {
-
- /**
- * Shows a particular program
- */
-
- public function show($id)
- {
-
- $program = Program::find($id);
- //Log::info(debug_backtrace()[1]['function']);
- // Log::info($program);
- $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();
-
-
- $outcomes_attempted = [];
- $outcomes_achieved = [];
-
- $program_info = $program->courses_students_score_per_outcome;
-
- $outcomes_attempted = $program_info['program_info']['outcomes_attempted_combined'];
- $outcomes_achieved = $program_info['program_info']['outcomes_achieved_combined'];
- /*
- foreach ($outcomes as $outcome) {
- $outcomes_attempted[$outcome->id] = 0;
- $outcomes_achieved[$outcome->id] = 0;
- }
-
-
- //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 ($program->courses as $course) {
- $results = $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;
- }
- }
- */
-
- 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'))
- $grouped_courses = Course::select(DB::raw('courses.name, code, number, semester_id, program_id, activities.id as activity_assessed'))
- ->leftJoin('activities', function ($query) {
- $query->on('activities.course_id', '=', 'courses.id');
- $query->on('activities.draft', '=', DB::raw('0'));
- $query->on('activities.diagnostic', '=', DB::raw('0'));
- })
- ->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'));
- }
-
-
- // manage course index
-
- public function assignOtherProgramIndex()
- {
-
- $title = 'Assign courses to other Programs';
- $programs = Program::orderBy("name")->get();
-
- return View::make('local.managers.admins.assign_other_programs', compact('title', 'programs'));
- }
-
- //create other course pairing
-
- public function addToOtherProgramTYP()
- {
- $clean_input = Input::all();
- Log::info($clean_input);
- DB::beginTransaction();
- foreach ($clean_input['other_program'] as $index => $program_id) {
- $id = DB::table('other_programs_courses_typ')->insertGetId(array(
- 'program_id' => $clean_input['program'],
- 'other_program_id' => $program_id
- ));
-
- if (!isset($id)) {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error saving Program. Try again later.');
-
- return Redirect::back();
- }
- }
- DB::commit();
-
- Session::flash('status', 'success');
- Session::flash('message', 'Pairing created.');
-
- return Redirect::action('ProgramsController@assignOtherProgramIndex');
- }
-
- public function updatePairingInfo()
- {
- $clean_input = Input::all();
- Log::info($clean_input);
- DB::beginTransaction();
- DB::table("other_programs_courses_typ")->where('program_id', $clean_input['program'])
- ->delete();
- foreach ($clean_input['other_program'] as $index => $program_id) {
- $id = DB::table('other_programs_courses_typ')->insertGetId(array(
- 'program_id' => $clean_input['program'],
- 'other_program_id' => $program_id
- ));
-
- if (!isset($id)) {
- Session::flash('status', 'danger');
- Session::flash('message', 'Error saving Program. Try again later.');
-
- return Redirect::back();
- }
- }
- DB::commit();
-
- Session::flash('status', 'success');
- Session::flash('message', 'Pairing created.');
-
- return Redirect::action('ProgramsController@assignOtherProgramIndex');
- }
-
- public function fetchPairingInfo()
- {
-
- return DB::table("other_programs_courses_typ")->where('program_id', Input::get('program_id'))
- ->lists("other_program_id");
- }
-
-
-
-
- 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('criterion_objective_outcome as cobo', 'cobo.outcome_id', '=', 'outcomes.id')
- ->join('criteria', 'criteria.id', '=', 'cobo.criterion_id')
- ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
- ->join('courses', 'courses.program_id', '=', 'program_criterion.program_id')
- ->where('program_criterion.program_id', $program->id)
- ->select('outcomes.name', 'outcomes.activation_date')
- ->distinct()
- ->orderBy('outcomes.name', 'asc')
- ->get();
-
- /*
-
- $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('criterion_objective_outcome as cobo', 'cobo.outcome_id', '=', 'outcomes.id')
- ->join('criteria', 'criteria.id', '=', 'cobo.criterion_id')
- ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
- ->join('courses', 'courses.program_id', '=', 'program_criterion.program_id')
- ->where('program_criterion.program_id', $program->id)
- ->select('courses.number', 'outcomes.name as domain_name', 'courses.code')
- ->distinct()
- ->orderBy('courses.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('criterion_objective_outcome as cobo', 'cobo.outcome_id', '=', 'outcomes.id')
- ->join('criteria', 'criteria.id', '=', 'cobo.criterion_id')
- ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
- ->join('courses', 'courses.program_id', '=', 'program_criterion.program_id')
-
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('transformative_activity_criterion as taa', 'taa.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('transformative_actions', 'transformative_actions.id', '=', 'taa.trans_action_id')
- ->where('program_criterion.program_id', $program->id)
- ->select('transformative_actions.description', 'outcomes.name as domain_name')
- ->distinct()
- ->orderBy('transformative_actions.description', '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'));
- }
-
- private function cmp($a, $b)
- {
- return strcmp($a->name, $b->name);
- }
- public function studentsProgramAssessmentReportForProfessors($program_id)
- {
- return $this->studentProgramAssessmentReport($program_id);
- }
-
- public function studentProgramAssessmentReport($program_id)
- {
- $id = $program_id;
- ini_set('memory_limit', -1);
- ini_set('max_execution_time', 300);
-
-
- $program = Program::find($program_id);
- $title = $program->school->name . ': ' . $program->name;
- $outcomes = Outcome::orderBy('name', 'asc')->get();
- $schools = School::all();
- $outcomeCount = Outcome::all()->count();
-
- // var_dump(json_encode($outcomes));
- $role = Auth::user()->role;
-
- $programs_ids = array($program->id);
-
- $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();
-
- // $outcomes = Outcome::orderBy('name', 'asc')->get();
- // $school = School::find($school_id);
- // $title= $school->name;
- // $outcomeCount = Outcome::all()->count();
- // $programs=Program::where('school_id','=',$school_id)->get();
- // $programs_ids=array();
- // // var_dump($programs);exit();
- // $programs_name=array();
- // foreach($programs as $program)
- // {
- // // var_dump($program);
- // $programs_ids[]=$program->id;
- // $programs_name[$program->id]=$program->name;
- // }
-
- $grouped_courses = Course::
- // select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
- select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id, 1 as grouped'))
- ->with('semester')
- ->with('program')
- ->whereIn('courses.program_id', $programs_ids)
- ->whereIn('courses.semester_id', Session::get('semesters_ids'))
- ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
- ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
- ->orderBy('courses.code')
- ->orderBy('courses.number')
- ->orderBy('courses.semester_id')
- ->get();
-
-
- $role = Auth::user()->role;
-
- $users = array();
- /*
-
-
- $resultados_todos_obj = DB::table('assessments')
- ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
- ->join('activities', 'activities.id', '=', 'activity_criterion.activity_id')
- ->join('courses', 'courses.id', '=', 'activities.course_id')
- ->join('students', 'students.id', '=', 'assessments.student_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('semesters', 'semesters.id', '=', 'courses.semester_id')
- ->whereIn('students.program_id', $programs_ids)
- ->whereIn('semester_id', Session::get('semesters_ids'))
- ->where('semesters.is_visible', '=', 1)
- ->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'criterion_objective_outcome.criterion_id', 'score', 'expected_points')
- ->distinct()
- ->get();
-
- foreach ($resultados_todos_obj as $resultado) {
- if (!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters'])) {
- $resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters'] = array();
- }
- $resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters'][] = $resultado->code;
- $resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters'] = array_unique($resultados_todos[$resultado->program_id][$resultado->outcome_id]['semesters']);
- if (!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted'])) {
- $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted'] = 0;
- }
- $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['attempted']++;
-
- if (!isset($resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved'])) {
- $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved'] = 0;
- }
- if ($resultado->score >= $resultado->expected_points) {
- $resultados_todos[$resultado->program_id][$resultado->outcome_id][$resultado->student_id]['achieved']++;
- }
- }*//*
-
- $outcomes_colap = array();
- $programs = array();
- // $outcomes_colap=array();
- $i = 0;
- $outcomes_attempted = array();
- $outcomes_attempted_colap = array();
- $outcomes_achieved_colap = array();
- $outcomes_attempted_semesters = array();
- foreach ($resultados_todos as $program_id => $resultados_prog) {
- $outcomes_attempted_semesters[$program_id] = array();
- foreach ($resultados_prog as $out => $datos_out) {
- $outcomes_achieved[$program_id][$out] = 0;
- $outcomes_attempted[$program_id][$out] = 0;
- // var_dump($datos_out);outcomes_attempted_semesters
- $outcomes_attempted_semesters[$program_id][$out] = $datos_out['semesters'];
- unset($datos_out['semesters']);
- // var_dump($outcomes_attempted_semesters[$program_id][$out]);
- // var_dump($datos_out);
- // exit();
- foreach ($datos_out as $res) {
- $outcomes_attempted[$program_id][$out]++;
- if (3 * $res['achieved'] >= 2 * $res['attempted'])
- $outcomes_achieved[$program_id][$out]++;
- }
- }
- $programs[] = Program::find($program_id);
- if (Program::find($program_id)->is_graduate) {
- $colapso = array(1 => array(), 3 => array(), 2 => array(11), 12 => array(7, 14), 10 => array(), 4 => array(6, 15));
- } else {
- $colapso = array(10 => array(), 1 => array(), 12 => array(7), 3 => array(9, 8, 14), 2 => array(11), 5 => array(), 4 => array(6, 13), 16 => array());
- }
-
- $resultados_todos_colap[$program_id] = array();
- foreach ($colapso as $out => $pares) {
- $resultados_todos_colap[$program_id][$out]["semesters"] = array();
- if (isset($resultados_todos[$program_id][$out]))
- $resultados_todos_colap[$program_id][$out] = $resultados_todos[$program_id][$out];
- else $resultados_todos_colap[$program_id][$out] = array();
- foreach ($pares as $par) {
- if (isset($resultados_todos[$program_id][$par])) {
- // unset($resultados_todos[$program_id][$par]['semesters']);
-
- foreach ($resultados_todos[$program_id][$par] as $estu => $resus) {
- if ($estu != "semesters") {
- if (!isset($resultados_todos_colap[$program_id][$out][$estu])) {
- $resultados_todos_colap[$program_id][$out][$estu]['attempted'] = 0;
- $resultados_todos_colap[$program_id][$out][$estu]['achieved'] = 0;
- }
- // print $program_id." ".$par." ".$estu."<br>";
- // var_dump($resultados_todos[$program_id][$par][$estu]);
- $resultados_todos_colap[$program_id][$out][$estu]['attempted'] += $resultados_todos[$program_id][$par][$estu]['attempted'];
- $resultados_todos_colap[$program_id][$out][$estu]['achieved'] += $resultados_todos[$program_id][$par][$estu]['achieved'];
- } else if (isset($resultados_todos[$program_id][$par]["semesters"])) {
- if (isset($resultados_todos_colap[$program_id][$out]["semesters"])) {
- $tmp = array_merge($resultados_todos_colap[$program_id][$out]["semesters"], $resultados_todos[$program_id][$par]["semesters"]);
- // var_dump(($tmp));
- // var_dump(array_unique($tmp));
- // exit();
-
- $resultados_todos_colap[$program_id][$out]["semesters"] = array_unique($tmp);
- } else
- $resultados_todos_colap[$program_id][$out]["semesters"] = array_unique($resultados_todos[$program_id][$par]["semesters"]);
- }
- }
- }
- }
- }
- // var_dump($resultados_todos_colap);
-
- $outcomes_attempted_colap[$program_id] = array();
- $outcomes_achieved_colap[$program_id] = array();
- $outcomes_attempted_colap_semesters[$program_id] = array();
- // print $program_id."<br>";
- // var_dump($resultados_todos_colap[$program_id]);
- // print "<br>";
- foreach ($resultados_todos_colap[$program_id] as $out => $datos_out) {
- if (!$i) $outcomes_colap[] = Outcome::find($out);
- // $outcomes_attempted_colap_semesters[$program_id][$out]=array();
- if (isset($datos_out['semesters'])) {
- $outcomes_attempted_colap_semesters[$program_id][$out] = $datos_out['semesters'];
- unset($datos_out['semesters']);
- }
- foreach ($datos_out as $res) {
- if (!isset($outcomes_attempted_colap[$program_id][$out])) {
- $outcomes_attempted_colap[$program_id][$out] = 0;
- $outcomes_achieved_colap[$program_id][$out] = 0;
- }
- $outcomes_attempted_colap[$program_id][$out]++;
- if (3 * $res['achieved'] >= 2 * $res['attempted'])
- $outcomes_achieved_colap[$program_id][$out]++;
- }
- if (empty($datos_out)) {
- $outcomes_attempted_colap[$program_id][$out] = 0;
- $outcomes_achieved_colap[$program_id][$out] = 0;
- }
- }
- $i++;
- }/*
- usort($outcomes_colap, array($this, "cmp"));
- // var_dump($outcomes_attempted_colap); print "<br>";
- // var_dump($outcomes_achieved_colap); print "<br>";
- // exit();
- $outcomes_attempted_colap_todo = array();
- $outcomes_achieved_colap_todo = array();
- foreach ($outcomes_attempted_colap as $program_id => $out_res) {
- foreach ($out_res as $out => $res) {
- if (!isset($outcomes_attempted_colap_todo[$out])) {
- $outcomes_attempted_colap_todo[$out] = 0;
- $outcomes_achieved_colap_todo[$out] = 0;
- }
- $outcomes_attempted_colap_todo[$out] += $outcomes_attempted_colap[$program_id][$out];
- $outcomes_achieved_colap_todo[$out] += $outcomes_achieved_colap[$program_id][$out];
- }
- }
- /*
- $outcomes_attempted_todo = array();
- $outcomes_achieved_todo = array();
- foreach ($outcomes_attempted as $program_id => $out_res) {
- foreach ($out_res as $out => $res) {
- if (!isset($outcomes_attempted_todo[$out])) {
- $outcomes_attempted_todo[$out] = 0;
- $outcomes_achieved_todo[$out] = 0;
- }
- $outcomes_attempted_todo[$out] += $outcomes_attempted[$program_id][$out];
- $outcomes_achieved_todo[$out] += $outcomes_achieved[$program_id][$out];
- }
- }*/
- $program_info = $program->program_students_per_outcome['program_info'];
-
- $outcomes_attempted_colap = $program_info['outcomes_attempted_combined']; // $outcomes_attempted_colap_todo;
- $outcomes_achieved_colap = $program_info['outcomes_achieved_combined']; //$outcomes_achieved_colap_todo;
- $outcomes_attempted = $program_info['outcomes_attempted_uncombined'];
- //$outcomes_attempted_todo;
- $outcomes_achieved = $program_info['outcomes_achieved_uncombined'];
- $outcomes_colap = Outcome::whereNull('new_outcome_id')->get();
- //$outcomes_achieved_todo;
- // var_dump($outcomes_attempted_colap);
- // var_dump($outcomes_attempted_colap);
- // return View::make('local.managers.shared.school_student_result', compact('title','outcomes_attempted_colap_semesters','outcomes_attempted_semesters','outcomes_attempted_colap_todo','outcomes_achieved_colap_todo','outcomes_attempted_todo','outcomes_achieved_todo','school','programs_name','role','outcomes','outcomes_colap', 'outcomes_attempted', 'outcomes_achieved', 'outcomes_attempted_colap', 'outcomes_achieved_colap', 'programs', 'users','program_courses','grouped_courses'));
-
- return View::make('local.managers.shared.program_student_result', compact('title', 'role', 'outcomes', 'outcomes_colap', 'outcomes_attempted', 'outcomes_achieved', 'outcomes_attempted_colap', 'outcomes_achieved_colap', 'program', 'users', 'program_courses', 'grouped_courses'));
- }
-
- // 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'));
- //
- // }
-
- public function print_program_students($program_id)
- {
- $id = $program_id;
- ini_set('memory_limit', -1);
- ini_set('max_execution_time', 300);
-
-
- $program = Program::find($program_id);
- $title = $program->school->name . ': ' . $program->name;
- $outcomes = Outcome::orderBy('name', 'asc')->get();
- $schools = School::all();
- $outcomeCount = Outcome::all()->count();
-
- // var_dump(json_encode($outcomes));
- $role = Auth::user()->role;
-
- $programs_ids = array($program->id);
-
- $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();
-
-
- $grouped_courses = Course::
- // select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
- select(DB::raw('courses.name, courses.code, courses.number, courses.semester_id, courses.program_id, 1 as grouped'))
- ->with('semester')
- ->with('program')
- ->whereIn('courses.program_id', $programs_ids)
- ->whereIn('courses.semester_id', Session::get('semesters_ids'))
- ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
- ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
- ->orderBy('courses.code')
- ->orderBy('courses.number')
- ->orderBy('courses.semester_id')
- ->get();
-
-
- $role = Auth::user()->role;
-
- $users = array();
-
- $program_info = $program->program_students_per_outcome['program_info'];
-
- $outcomes_attempted_colap = $program_info['outcomes_attempted_combined']; // $outcomes_attempted_colap_todo;
- $outcomes_achieved_colap = $program_info['outcomes_achieved_combined']; //$outcomes_achieved_colap_todo;
- $outcomes_attempted = $program_info['outcomes_attempted_uncombined'];
- //$outcomes_attempted_todo;
- $outcomes_achieved = $program_info['outcomes_achieved_uncombined'];
- $outcomes_colap = Outcome::whereNull('new_outcome_id')->get();
- //$outcomes_achieved_todo;
- // var_dump($outcomes_attempted_colap);
- // var_dump($outcomes_attempted_colap);
- // return View::make('local.managers.shared.school_student_result', compact('title','outcomes_attempted_colap_semesters','outcomes_attempted_semesters','outcomes_attempted_colap_todo','outcomes_achieved_colap_todo','outcomes_attempted_todo','outcomes_achieved_todo','school','programs_name','role','outcomes','outcomes_colap', 'outcomes_attempted', 'outcomes_achieved', 'outcomes_attempted_colap', 'outcomes_achieved_colap', 'programs', 'users','program_courses','grouped_courses'));
-
- return View::make('local.managers.shared.print_program_students', compact('title', 'role', 'outcomes', 'outcomes_colap', 'outcomes_attempted', 'outcomes_achieved', 'outcomes_attempted_colap', 'outcomes_achieved_colap', 'program', 'users', 'program_courses', 'grouped_courses'));
- }
-
- /**
- * Info to print a program
- */
- public function print_program($id)
- {
-
- $program = Program::find($id);
- $title = $program->name . ' Assessment Report - ' . date('m/d/Y');
- $schools = School::all();
- // $outcomeCount = Outcome::all()->count();
- $semesters = Session::get('semesters_ids');
- // $semesters = DB::table('semesters')->where('id', $course->semester_id)->orderBy('start', 'ASC')->first();
- $semesters2 = Semester::whereIn('id', Session::get('semesters_ids'))->get();
-
- $program_courses = $program->courses;
- //$outcomes = Outcome::orderBy('name', 'asc')->get();
- $outcomes = Outcome::active_by_semesters($semesters2, $program->is_graduate);
- $outcomeCount = count($outcomes);
- $outcomes_achieved = [];
- $outcomes_attempted = [];
-
- $program_outcomes_attempted = [];
- $program_outcomes_achieved = [];
-
- // Log::info($program_courses);
- foreach ($outcomes as $outcome) {
- $outcomes_attempted[$outcome->id] = 0;
- $outcomes_achieved[$outcome->id] = 0;
- $program_outcomes_attempted[$outcome->id] = 0;
- $program_outcomes_achieved[$outcome->id] = 0;
- }
-
- $assessed_courses_count = 0;
-
- //Log::info("Aqui");
- //Log::info($program->program_students_per_outcomes);
- //$program_info = $program->program_students_per_outcome['program_info'];
-
- //$program_outcomes_attempted = $program_info['outcomes_attempted_combined'];
- //$program_outcomes_achieved = $program_info['outcomes_achieved_combined'];
-
- $course_info = $program->courses_students_score_per_outcome['program_info'];
-
-
- $outcomes_attempted = $course_info['outcomes_attempted_combined'];
- $outcomes_achieved = $course_info['outcomes_achieved_combined'];
- $assessed_courses_count = $program->courses_with_assessment_count->courses_assessed;
- /*
- foreach ($program_courses as $course) {
-
-
- $student_report = $course->student_report_for_outcome;
-
- if ($student_report) {
-
- foreach ($student_report as $outcome_id => $score) {
- if (array_key_exists($outcome_id, $outcomes_attempted)) $outcomes_attempted[$outcome_id] += $student_report[$outcome_id]['calculations']['student_attempted'];
- else $outcomes_attempted[$outcome_id] = $student_report[$outcome_id]['calculations']['student_attempted'];
-
- if (array_key_exists($outcome_id, $outcomes_achieved)) $outcomes_achieved[$outcome_id] += $student_report[$outcome_id]['calculations']['student_achieved'];
- else $outcomes_achieved[$outcome_id] = $student_report[$outcome_id]['calculations']['student_achieved'];
- }
- }
- /*
- $course->with_program_report = 1;
- $student_report = $course->student_report_for_outcome;
-
- if ($student_report) {
-
- foreach ($student_report as $outcome_id => $score) {
- if (array_key_exists($outcome_id, $program_outcomes_attempted)) $program_outcomes_attempted[$outcome_id] += $student_report[$outcome_id]['calculations']['student_attempted'];
- else $program_outcomes_attempted[$outcome_id] = $student_report[$outcome_id]['calculations']['student_attempted'];
-
- if (array_key_exists($outcome_id, $program_outcomes_achieved)) $program_outcomes_achieved[$outcome_id] += $student_report[$outcome_id]['calculations']['student_achieved'];
- else $program_outcomes_achieved[$outcome_id] = $student_report[$outcome_id]['calculations']['student_achieved'];
- }
- }
-
- */
-
- /*
- if ($course->outcomes_att()) {
- $course_outcomes_attempted = $course->outcomes_att();
- foreach ($course_outcomes_attempted as $outcome => $score) {
- if (array_key_exists($outcome, $outcomes_attempted))
- $outcomes_attempted[$outcome] += $score;
- else $outcomes_attempted[$outcome] = $score;
- }
- $assessed_courses_count += 1;
- }
-
- if ($course->outcomes_ach()) {
-
- $course_outcomes_achieved = $course->outcomes_ach();
- foreach ($course_outcomes_achieved as $outcome => $score) {
- if (array_key_exists($outcome, $outcomes_achieved))
- $outcomes_achieved[$outcome] += $score;
- else $outcomes_achieved[$outcome] = $score;
- }
- }
-
- }
- */
-
-
-
-
- // $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();
- //
- // $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)
- */
-
- // select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
- $grouped_courses = Course::select(DB::raw('id, 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();
-
- foreach ($grouped_courses as &$course) {
- $course->outcomes_attempted = null;
- if (count($course->assessedActivities) and count($course->publishedActivities)) {
- $course->outcomes_attempted = true;
- }
- }
-
- // Log::info($grouped_courses);
- // exit();
- $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();
-
-
-
-
- $program_array = array();
-
- $program_array['program'] = $program;
-
- $program_array['outcomes_achieved'] = [];
- $program_array['outcomes_attempted'] = [];
-
- $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 (!$program_array['course_outcomes_achieved'] = $course->outcomes_ach()) {
- // $program_array['course_outcomes_achieved'] = $course->outcomes_ach();
- $program_array['course_outcomes_attempted'] = $course->outcomes_att();
- Log::info($program_array['course_outcomes_achieved']);
- 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];
- }
- 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];
- }
-
- $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(); */
- $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();
-
- $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.shared.print_program', compact('title', 'program_outcomes_achieved', 'program_outcomes_attempted', '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;
- }
- }
|