1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138 |
- <?php
-
- class SchoolsController extends \BaseController
- {
-
- private function participatingPrograms($school)
- {
- return DB::table('programs')
- ->join('courses', 'courses.program_id', '=', 'programs.id')
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
- ->addSelect('courses.semester_id')
- ->where('school_id', $school->id)
- ->whereIn('semester_id', Session::get('semesters_ids'))
- ->lists('id');
-
- // return DB::table('programs')
- // ->join('courses', 'courses.program_id', '=', 'programs.id')
- // ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
- // ->addSelect('courses.semester_id')
- // ->where('school_id', $school->id)
- // ->whereIn('semester_id', Session::get('semesters_ids'))
- // ->lists('id');
- }
-
- public function show($id)
- {
- ini_set('memory_limit', '256M');
- DB::connection()->disableQueryLog();
- $school = School::find($id);
- $title = $school->name;
- $schools = School::all();
-
- $semesters = Semester::whereIn('id', Session::get('semesters_ids'))->get();
-
- $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
- $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
-
- $undergrad_stu_outcome_attempted = [];
- $grad_stu_outcome_attempted = [];
- $undergrad_stu_outcome_achieved = [];
- $grad_stu_outcome_achieved = [];
-
- $attemptedUndergradProgramsPerOutcome = [];
- $achievedUndergradProgramsPerOutcome = [];
- $attemptedGradProgramsPerOutcome = [];
- $achievedGradProgramsPerOutcome = [];
-
- foreach ($outcomes_undergrad as $outcome) {
- $undergrad_stu_outcome_attempted[$outcome->id] = 0;
- $undergrad_stu_outcome_achieved[$outcome->id] = 0;
- $attemptedUndergradProgramsPerOutcome[$outcome->id] = [];
- $achievedUndergradProgramsPerOutcome[$outcome->id] = [];
- }
-
- foreach ($outcomes_grad as $outcome) {
- $grad_stu_outcome_attempted[$outcome->id] = 0;
- $grad_stu_outcome_achieved[$outcome->id] = 0;
- $attemptedGradProgramsPerOutcome[$outcome->id] = [];
- $achievedGradProgramsPerOutcome[$outcome->id] = [];
- }
-
- /**
- * List of grouped courses (grouped sections)
- */
-
- $program_ids = $school->programs->lists('id');
-
- $undergrad_programs = DB::table('programs')
- ->select('id', 'name', 'school_id', 'is_graduate')
- ->where('is_graduate', '=', 0)
- ->where('school_id', '=', $id)
- ->orderBy('name', 'ASC')
- ->get();
-
-
-
- $grad_programs = DB::table('programs')
- ->select('id', 'name', 'school_id', 'is_graduate')
- ->where('is_graduate', '=', 1)
- ->where('school_id', '=', $id)
- ->orderBy('name', 'ASC')
- ->get();
-
-
- //quiero ver si monto el query tm aqui
-
- $undergrad_programs_list = DB::table('programs')
- ->select('id', 'name', 'school_id', 'is_graduate')
- ->where('is_graduate', '=', 0)
- ->where('school_id', '=', $id)
- ->orderBy('name', 'ASC')
- ->lists('id');
-
- $grad_programs_list = DB::table('programs')
- ->select('id', 'name', 'school_id', 'is_graduate')
- ->where('is_graduate', '=', 1)
- ->where('school_id', '=', $id)
- ->orderBy('name', 'ASC')
- ->lists('id');
-
-
- $undergraduate_student_query = DB::table("courses")
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'activity_criterion.criterion_id')
- ->join('program_criterion_objective_outcome as poco', function ($q) {
- $q->on('courses.program_id', '=', 'poco.program_id')
- ->on('cobo.id', '=', 'poco.cri_obj_out_id');
- })
- ->join('students', 'students.id', '=', 'assessments.student_id')
- ->whereIn('poco.program_id', $undergrad_programs_list)
- ->whereIn("courses.semester_id", Session::get('semesters_ids'))
- ->whereIn('courses.program_id', $undergrad_programs_list)
- ->select('students.number as student_id')
- ->addSelect(DB::raw('count(assessments.activity_criterion_id) as criteria_attempted'))
- ->addSelect(DB::raw('count(case when assessments.score>=rubrics.expected_points then 1 else NULL end) as criteria_achieved'))
- ->addSelect('outcome_id')
- ->groupBy(array('students.id', 'outcome_id'))
- ->get();
-
-
- Log::info($undergraduate_student_query);
-
- $grad_student_query = DB::table("courses")
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'activity_criterion.criterion_id')
- ->join('program_criterion_objective_outcome as poco', function ($q) {
- $q->on('courses.program_id', '=', 'poco.program_id')
- ->on('cobo.id', '=', 'poco.cri_obj_out_id');
- })
- ->join('students', 'students.id', '=', 'assessments.student_id')
- ->whereIn('poco.program_id', $grad_programs_list)
- ->whereIn("courses.semester_id", Session::get('semesters_ids'))
- ->whereIn('courses.program_id', $grad_programs_list)
- ->select('students.number as student_id')
- ->addSelect(DB::raw('count(assessments.activity_criterion_id) as criteria_attempted'))
- ->addSelect(DB::raw('count(case when assessments.score>=rubrics.expected_points then 1 else NULL end) as criteria_achieved'))
- ->addSelect('outcome_id')
- ->groupBy(array('students.id', 'outcome_id'))
- ->get();
-
- //school
-
-
-
- /*
- student x, crit achieved, crit attempted, outcome 1
- student x, crit achieved, crit attempted, outcome 2
- student x, crit achieved, crit attempted, outcome 3
- student x, crit achieved, crit attempted, outcome 4
- student y, crit achieved, crit attempted, outcome 1
- student y, crit achieved, crit attempted, outcome 2
- student y, crit achieved, crit attempted, outcome 3
- ....
-
-
- */
-
- $grad_outcomes_attempted = [];
- $grad_outcomes_achieved = [];
- $undergrad_outcomes_attempted = [];
- $undergrad_outcomes_achieved = [];
-
- foreach ($outcomes_grad as $outcome) {
- $grad_outcomes_attempted[$outcome->id] = 0;
- $grad_outcomes_achieved[$outcome->id] = 0;
- }
-
- foreach ($outcomes_undergrad as $outcome) {
- $undergrad_outcomes_attempted[$outcome->id] = 0;
- $undergrad_outcomes_achieved[$outcome->id] = 0;
- }
-
- foreach ($grad_student_query as $result) {
- if ($result->criteria_attempted != 0) {
- if (!isset($grad_outcomes_attempted[$result->outcome_id]))
- continue;
-
- $grad_outcomes_attempted[$result->outcome_id]++;
-
- $percent = $result->criteria_achieved / $result->criteria_attempted * 100;
-
- if ($percent >= 66.66) {
-
-
- $grad_outcomes_achieved[$result->outcome_id]++;
- }
- }
- }
-
-
-
-
- foreach ($undergraduate_student_query as $result) {
- if ($result->criteria_attempted != 0) {
- if (!isset($undergrad_outcomes_attempted[$result->outcome_id]))
- continue;
-
- $undergrad_outcomes_attempted[$result->outcome_id]++;
-
- $percent = $result->criteria_achieved / $result->criteria_attempted * 100;
-
- if ($percent >= 66.66) {
-
-
- $undergrad_outcomes_achieved[$result->outcome_id]++;
- }
- }
- }
-
- $grad_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'))
- ->with('semester')
- ->with('program')
- ->whereIn('courses.program_id', $program_ids)
- ->whereIn('courses.semester_id', Session::get('semesters_ids'))
- ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
- ->where('programs.is_graduate', '=', 1)
- ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
- ->orderBy('courses.code')
- ->orderBy('courses.number')
- ->orderBy('courses.semester_id')
- ->get();
-
- $undergrad_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'))
- ->with('semester')
- ->with('program')
- ->whereIn('courses.program_id', $program_ids)
- ->whereIn('courses.semester_id', Session::get('semesters_ids'))
- ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
- ->where('programs.is_graduate', '=', 0)
- ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
- ->orderBy('courses.code')
- ->orderBy('courses.number')
- ->orderBy('courses.semester_id')
- ->get();
-
- foreach ($undergrad_grouped_courses as $key => $courses) {
- $undergrad_grouped_courses[$key]->outcomes_attempted = NULL;
- $coursesT = Course::where('courses.code', $courses->code)->where('courses.number', $courses->number)->where('courses.semester_id', $courses->semester_id)->get();
- foreach ($coursesT as $course) {
- if ($course->isAssessed()) {
- $undergrad_grouped_courses[$key]->outcomes_attempted = true;
- }
- }
- }
-
- foreach ($grad_grouped_courses as $key => $courses) {
- $grad_grouped_courses[$key]->outcomes_attempted = NULL;
- $coursesT = Course::where('courses.code', $courses->code)->where('courses.number', $courses->number)->where('courses.semester_id', $courses->semester_id)->get();
- foreach ($coursesT as $course) {
- if ($course->isAssessed()) {
- $grad_grouped_courses[$key]->outcomes_attempted = true;
- }
- }
- }
-
- // Fetch programs with participation
- $participating_programs = $this->participatingPrograms($school);
-
- /**
- * Calculate how many sections are doing assessment
- */
-
- $undergrad_assessed_sections_count = 0;
- $undergrad_school_sections_count = 0;
-
- $grad_assessed_sections_count = 0;
- $grad_school_sections_count = 0;
-
- foreach ($school->programs as $program) {
- foreach ($program->courses as $course) {
-
- if (!$course->program->is_graduate) {
- $undergrad_school_sections_count += 1;
- if ($course->isAssessed()) $undergrad_assessed_sections_count += 1;
- } else {
- $grad_school_sections_count += 1;
- if ($course->isAssessed()) $grad_assessed_sections_count += 1;
- }
- }
- }
-
-
- //como resuelvo programsAttempted y eso
-
-
- //El query es el mismo de students, lo unico que dividido con programas,
- //asi que lo que esta haciendo es, prog 1, y coge los dominios y estudiantes que evaluason
-
-
- $undergrad_prog_attempted = DB::table("courses")
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'activity_criterion.criterion_id')
- ->join('program_criterion_objective_outcome as poco', function ($q) {
- $q->on('courses.program_id', '=', 'poco.program_id')
- ->on('cobo.id', '=', 'poco.cri_obj_out_id');
- })
- ->join('students', 'students.id', '=', 'assessments.student_id')
- ->whereIn("courses.semester_id", Session::get('semesters_ids'))
- ->whereIn('poco.program_id', $undergrad_programs_list)
-
- ->whereIn('courses.program_id', $undergrad_programs_list)
- ->select('students.number as student_id')
- ->addSelect(DB::raw('count(assessments.activity_criterion_id) as criteria_attempted'))
- ->addSelect(DB::raw('count(case when assessments.score>=rubrics.expected_points then 1 else NULL end) as criteria_achieved'))
- ->addSelect('outcome_id')
- ->addSelect("courses.program_id")
- ->groupBy(array('students.id', 'outcome_id', 'program_id'))
- ->get();
-
- $grad_prog_attempted = DB::table("courses")
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'activity_criterion.criterion_id')
- ->join('program_criterion_objective_outcome as poco', function ($q) {
- $q->on('courses.program_id', '=', 'poco.program_id')
- ->on('cobo.id', '=', 'poco.cri_obj_out_id');
- })
- ->join('students', 'students.id', '=', 'assessments.student_id')
- ->whereIn("courses.semester_id", Session::get('semesters_ids'))
- ->whereIn('poco.program_id', $grad_programs_list)
-
- ->whereIn('courses.program_id', $grad_programs_list)
- ->select('students.number as student_id')
- ->addSelect(DB::raw('count(assessments.activity_criterion_id) as criteria_attempted'))
- ->addSelect(DB::raw('count(case when assessments.score>=rubrics.expected_points then 1 else NULL end) as criteria_achieved'))
- ->addSelect('outcome_id')
- ->addSelect("courses.program_id")
- ->groupBy(array('students.id', 'outcome_id', 'program_id'))
- ->get();
-
- //este arreglo va a tener attempted[outcome->id][program->id]
-
- //so la cardinalidad de attempted[outcome->id] dice cuantos programas intentaron, achieved[outcome->id], va
- //a decir cuantos pasaron y attempted[outcome->id][program->id] la suma de estudiantes que intentaron
- //
-
-
- foreach ($undergrad_prog_attempted as $row) {
- $program_id = $row->program_id;
- $outcome_id = $row->outcome_id;
- if (!isset($attemptedUndergradProgramsPerOutcome[$outcome_id][$program_id]))
- $attemptedUndergradProgramsPerOutcome[$outcome_id][$program_id] = 0;
-
-
- $attemptedUndergradProgramsPerOutcome[$outcome_id][$program_id]++;
-
- $criteria_attempted_by_stu = $row->criteria_attempted;
- $criteria_achieved_by_stu = $row->criteria_achieved;
- if ($criteria_attempted_by_stu != 0 && $criteria_achieved_by_stu / $criteria_attempted_by_stu * 100 >= 66.67) {
-
- if (!isset($achievedUndergradProgramsPerOutcome[$outcome_id][$program_id]))
- $achievedUndergradProgramsPerOutcome[$outcome_id][$program_id] = 0;
- $achievedUndergradProgramsPerOutcome[$outcome_id][$program_id]++;
- }
- }
-
- foreach ($grad_prog_attempted as $row) {
- $program_id = $row->program_id;
- $outcome_id = $row->outcome_id;
- if (!isset($attemptedGradProgramsPerOutcome[$outcome_id][$program_id]))
- $attemptedGradProgramsPerOutcome[$outcome_id][$program_id] = 0;
-
-
- $attemptedGradProgramsPerOutcome[$outcome_id][$program_id]++;
-
- $criteria_attempted_by_stu = $row->criteria_attempted;
- $criteria_achieved_by_stu = $row->criteria_achieved;
- if ($criteria_attempted_by_stu != 0 && $criteria_achieved_by_stu / $criteria_attempted_by_stu * 100 >= 66.67) {
- if (!isset($achievedGradProgramsPerOutcome[$outcome_id][$program_id]))
- $achievedGradProgramsPerOutcome[$outcome_id][$program_id] = 0;
- $achievedGradProgramsPerOutcome[$outcome_id][$program_id]++;
- }
- }
-
-
-
-
-
- /**
- * Calculate how many programs achieved and attempted each outcome in this school
- */
-
- // For each outcome
- /*
- foreach ($outcomes_undergrad as $outcome) {
- // $attempted_outcomes_per_undergrad_program[$outcome->id]=0;
- // $achieved_outcomes_per_undergrad_program[$outcome->id]=0;
- $attemptedUndergradProgramsPerOutcome[$outcome->id] = 0;
- $achievedUndergradProgramsPerOutcome[$outcome->id] = 0;
- $programs_attempted_in_school[$outcome->id] = $outcome->programs_attempted_in_school($semesters, $school->id);
- // var_dump($programs_attempted_in_school);exit();
- foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
- // var_dump($program_id->id);exit();
- $program = DB::table('programs')->where('id', '=', $program_id->id)->first();
-
- if (!$program->is_graduate) {
- $attemptedUndergradProgramsPerOutcome[$outcome->id]++;
- $programC = Program::where('id', '=', $program_id->id)->first();
- // var_dump($programC);exit();
- if ($programC->achieved_outcome($outcome->id, $semesters)) {
- $achievedUndergradProgramsPerOutcome[$outcome->id]++;
- }
- }
- }
- $undergrad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 0);
- $undergrad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 0);
-
- // For each program with courses that do assessment
- $programs_with_courses = Program::with(array('courses' => function ($query) {
- // $query->whereNotNull('outcomes_attempted');
- $query->whereIn('semester_id', Session::get('semesters_ids'));
- }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
- }*/
-
- /**
- * Calculate how many Graduate programs achieved and attempted each outcome in this school
- */
- /*
- // For each outcome
- foreach ($outcomes_grad as $outcome) {
- // $attempted_outcomes_per_grad_program[$outcome->id]=0;
- $achieved_outcomes_per_grad_program[$outcome->id] = 0;
- $attemptedGradProgramsPerOutcome[$outcome->id] = 0;
- $achievedGradProgramsPerOutcome[$outcome->id] = 0;
- $grad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 1);
- $grad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 1);
- // For each program with courses that do assessment
- foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
- // var_dump($program_id->id);exit();
- $program = DB::table('programs')
- ->where('id', '=', $program_id->id)
- ->first();
- // $program=Program::where('id', $program_id->id);
- // var_dump($program);exit();
- if ($program->is_graduate) {
- $attemptedGradProgramsPerOutcome[$outcome->id]++;
- $programC = Program::where('id', '=', $program_id->id)->first();
- // var_dump($programC);exit();
- if ($programC->achieved_outcome($outcome->id, $semesters)) {
- $achievedGradProgramsPerOutcome[$outcome->id]++;
- }
- }
- }
- $programs_with_courses = Program::with(array('courses' => function ($query) {
- // $query->whereNotNull('outcomes_attempted');
- $query->whereIn('semester_id', Session::get('semesters_ids'));
- }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
- }*/
- if ($school->id == 13) {
- // return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
- } else {
- // return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
- }
- }
-
- private function cmp($a, $b)
- {
- return strcmp($a->name, $b->name);
- }
-
- public function studentSchoolAssessmentReport($school_id)
- {
- $id = $school_id;
- ini_set('memory_limit', -1);
- ini_set('max_execution_time', 300);
-
- $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'))
- ->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];
- }
- }
-
-
- 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'));
- }
-
- public function showQuasiOri($id)
- {
- ini_set('memory_limit', '256M');
- DB::connection()->disableQueryLog();
- $school = School::find($id);
- $title = $school->name;
- $schools = School::all();
-
- // $outcomes = Outcome::orderBy('name', 'asc')->get();
- // $outcomeCount = Outcome::all()->count();
- $semesters = Semester::whereIn('id', Session::get('semesters_ids'))->get();
- // var_dump($semesters);
- // exit();
- $outcomes_grad = Outcome::active_by_semesters($semesters, 1);
- $outcomes_undergrad = Outcome::active_by_semesters($semesters, 0);
-
-
- /**
- * List of grouped courses (grouped sections)
- */
-
- $program_ids = $school->programs->lists('id');
-
- $undergrad_programs = DB::table('programs')
- ->select('id', 'name', 'school_id', 'is_graduate')
- ->where('is_graduate', '=', 0)
- ->where('school_id', '=', $id)
- ->orderBy('name', 'ASC')
- ->get();
-
- $grad_programs = DB::table('programs')
- ->select('id', 'name', 'school_id', 'is_graduate')
- ->where('is_graduate', '=', 1)
- ->where('school_id', '=', $id)
- ->orderBy('name', 'ASC')
- ->get();
-
-
- $grad_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'))
- ->with('semester')
- ->with('program')
- ->whereIn('courses.program_id', $program_ids)
- ->whereIn('courses.semester_id', Session::get('semesters_ids'))
- ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
- ->where('programs.is_graduate', '=', 1)
- ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
- ->orderBy('courses.code')
- ->orderBy('courses.number')
- ->orderBy('courses.semester_id')
- ->get();
-
- $undergrad_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'))
- ->with('semester')
- ->with('program')
- ->whereIn('courses.program_id', $program_ids)
- ->whereIn('courses.semester_id', Session::get('semesters_ids'))
- ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
- ->where('programs.is_graduate', '=', 0)
- ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
- ->orderBy('courses.code')
- ->orderBy('courses.number')
- ->orderBy('courses.semester_id')
- ->get();
-
- // Fetch programs with participation
- $participating_programs = $this->participatingPrograms($school);
-
-
- /**
- * Calculate how many sections are doing assessment
- */
-
- // $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
- // $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
- $undergrad_assessed_sections_count = 0;
- $undergrad_school_sections_count = 0;
-
- // $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
- // $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
- $grad_assessed_sections_count = 0;
- $grad_school_sections_count = 0;
-
- foreach ($school->programs as $program) {
- foreach ($program->courses as $course) {
- // Log::info("aqui".$course);
-
- if (!$course->program->is_graduate) {
- $undergrad_school_sections_count += 1;
- if ($course->isAssessed()) $undergrad_assessed_sections_count += 1;
- // Log::info("aqui".$course);
-
- } else {
- $grad_school_sections_count += 1;
- if ($course->isAssessed()) $grad_assessed_sections_count += 1;
- // Log::info("aqui".$course);
-
- }
-
- // if (!$course->program->is_graduate) {
- // 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($undergrad_outcomes_attempted); $i++) {
- // $undergrad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
- // $undergrad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
- // }
- // $undergrad_assessed_sections_count += 1;
- // }
- // $undergrad_school_sections_count += 1;
- // } else {
- // 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($grad_outcomes_attempted); $i++) {
- // $grad_outcomes_achieved[$i] += $course_outcomes_achieved[$i];
- // $grad_outcomes_attempted[$i] += $course_outcomes_attempted[$i];
- // }
- // $grad_assessed_sections_count += 1;
- // }
- // $grad_school_sections_count += 1;
- // }
-
- }
- }
-
- /**
- * Calculate how many programs achieved and attempted each outcome in this school
- */
-
- // Number of programs that achieved a particular learning outcome
- // $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
-
- // Number of programs that attempted a particular learning outcome
- // $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
-
- // Fetch programs with participation for the school
- // $participating_undergrad_programs = DB::table('programs')
- // ->join('courses', 'courses.program_id', '=', 'programs.id')
- // ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
- // ->addSelect('courses.semester_id')
- // ->whereIn('semester_id', Session::get('semesters_ids'))
- // ->where('is_graduate', 0)
- // ->where('school_id', $school->id)
- // ->groupBy('id')
- // ->get();
-
- $output = array();
-
-
- // For each outcome
- foreach ($outcomes_undergrad as $outcome) {
- // $attempted_outcomes_per_undergrad_program[$outcome->id]=0;
- $achieved_outcomes_per_undergrad_program[$outcome->id] = 0;
- $attemptedUndergradProgramsPerOutcome[$outcome->id] = 0;
- $achievedUndergradProgramsPerOutcome[$outcome->id] = 0;
- $programs_attempted_in_school[$outcome->id] = $outcome->programs_attempted_in_school($semesters, $school->id);
- // var_dump($programs_attempted_in_school);exit();
- foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
- // var_dump($program_id->id);exit();
- $program = DB::table('programs')
- ->where('id', '=', $program_id->id)
- ->first();
- // $program=Program::where('id', $program_id->id);
- // var_dump($program);exit();
- if (!$program->is_graduate) {
- $attemptedUndergradProgramsPerOutcome[$outcome->id]++;
- }
- }
- $undergrad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 0);
- $undergrad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 0);
-
- // For each program with courses that do assessment
- $programs_with_courses = Program::with(array('courses' => function ($query) {
- // $query->whereNotNull('outcomes_attempted');
- $query->whereIn('semester_id', Session::get('semesters_ids'));
- }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
-
- foreach ($programs_with_courses as $program) {
- if (in_array($program->id, $participating_programs)) {
- // To acummulate all criteria for one program
- // $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
- // $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
-
- //Flag for counting programs
- $flag = false;
-
- // For each course in the program
- // foreach ($program->courses as $course) {
- // if($course->isAssessed()){
- // // If the outcome in question is being evaluated
- // $course_outcomes_attempted2 = $course->outcomes_att();
- // // $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
- // // $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
- // $course_outcomes_achieved2 = $course->outcomes_ach();
- // if (
- // array_key_exists($outcome->id, $course_outcomes_attempted2) && array_key_exists($outcome->id, $course_outcomes_achieved2)
- // && $course_outcomes_attempted2[$outcome->id] > 0
- // ) {
- // $achieved_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
- // // $attempted_outcomes_per_undergrad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
- //
- // // Add one to the programs assessing, if it wasn't added before
- // if (!$flag) {
- // $attemptedUndergradProgramsPerOutcome[$outcome->id] += 1;
- // $flag = true;
- // }
- // }
- //
- // // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
- // // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
- // }
- // }
- //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
- // if ($attempted_outcomes_per_undergrad_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_undergrad_program[$outcome->id] / $attempted_outcomes_per_undergrad_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
- // $achievedUndergradProgramsPerOutcome[$outcome->id] += 1;
- // // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
- // }
- }
- }
- }
-
- /**
- * Calculate how many programs achieved and attempted each outcome in this school
- */
-
- // Number of programs that achieved a particular learning outcome
- // $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
-
- // Number of programs that attempted a particular learning outcome
- // $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
- //
- // Fetch programs with participation for the school
- // $participating_grad_programs = DB::table('programs')
- // ->join('courses', 'courses.program_id', '=', 'programs.id')
- // ->select('programs.id', 'programs.name', 'programs.is_graduate', 'programs.school_id')
- // ->addSelect('courses.semester_id')
- // ->whereIn('semester_id', Session::get('semesters_ids'))
- // ->where('is_graduate', 1)
- // ->where('school_id', $school->id)
- // ->groupBy('id')
- // ->get();
-
- $output = array();
-
-
- // For each outcome
- foreach ($outcomes_grad as $outcome) {
- // $attempted_outcomes_per_grad_program[$outcome->id]=0;
- $achieved_outcomes_per_grad_program[$outcome->id] = 0;
- $attemptedGradProgramsPerOutcome[$outcome->id] = 0;
- $achievedGradProgramsPerOutcome[$outcome->id] = 0;
- $grad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 1);
- $grad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 1);
- // For each program with courses that do assessment
- foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
- // var_dump($program_id->id);exit();
- $program = DB::table('programs')
- ->where('id', '=', $program_id->id)
- ->first();
- // $program=Program::where('id', $program_id->id);
- // var_dump($program);exit();
- if ($program->is_graduate) {
- $attemptedGradProgramsPerOutcome[$outcome->id]++;
- }
- }
- $programs_with_courses = Program::with(array('courses' => function ($query) {
- // $query->whereNotNull('outcomes_attempted');
- $query->whereIn('semester_id', Session::get('semesters_ids'));
- }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
-
- foreach ($programs_with_courses as $program) {
- if (in_array($program->id, $participating_programs)) {
- // To acummulate all criteria for one program
- // $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
- // $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
-
- //Flag for counting programs
- $flag = false;
-
- // For each course in the program
- foreach ($program->courses as $course) {
- if ($course->isAssessed()) {
- // If the outcome in question is being evaluated
- // $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
- $course_outcomes_attempted2 = ($course->outcomes_att());
- $course_outcomes_achieved2 = ($course->outcomes_ach());
- // $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
- if (
- array_key_exists($outcome->id, $course_outcomes_attempted2) && array_key_exists($outcome->id, $course_outcomes_achieved2)
- && $course_outcomes_attempted2[$outcome->id] > 0
- ) {
- $achieved_outcomes_per_grad_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
- $attempted_outcomes_per_grad_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
-
- // Add one to the programs assessing, if it wasn't added before
- if (!$flag) {
- $attemptedGradProgramsPerOutcome[$outcome->id] += 1;
- $flag = true;
- }
- }
-
- // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
- // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
- }
- }
- //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
- if ($attempted_outcomes_per_grad_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_grad_program[$outcome->id] / $attempted_outcomes_per_grad_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
- $achievedGradProgramsPerOutcome[$outcome->id] += 1;
- // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
- }
- }
- }
- }
- if ($school->id == 13) {
- // return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
- } else {
- // return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
- }
- }
-
- public function print_school($id)
- {
- ini_set('memory_limit', '256M');
- DB::connection()->disableQueryLog();
-
- $school = School::find($id);
- $title = $school->name . ' Assessment Report - ' . date('m/d/Y');
-
- $outcomes = Outcome::orderBy('name', 'asc')->get();
- $outcomeCount = Outcome::all()->count();
-
-
-
-
- /**
- * List of courses (grouped sections)
- */
-
- $program_ids = $school->programs->lists('id');
-
- $grouped_courses = Course::
- // select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
- select(DB::raw('name, code, number, semester_id, program_id'))
- ->with('semester')
- ->with('program')
- ->whereIn('program_id', $program_ids)
- ->whereIn('semester_id', Session::get('semesters_ids'))
- ->groupBy(array('code', 'number', 'semester_id'))
- ->orderBy('code')
- ->orderBy('number')
- ->orderBy('semester_id')
- ->get();
-
- // Fetch programs with participation
- $participating_programs = $this->participatingPrograms($school);
-
- /**
- * Calculate how many sections are doing assessment
- */
-
- $outcomes_achieved = array_fill(1, $outcomeCount, 0);
- $outcomes_attempted = array_fill(1, $outcomeCount, 0);
- $assessed_sections_count = 0;
- $school_sections_count = 0;
-
- foreach ($school->programs as $program) {
- 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_sections_count += 1;
- }
- $school_sections_count += 1;
- }
- }
-
- /**
- * Calculate how many programs achieved and attempted each outcome in this school
- */
-
- // Number of programs that achieved a particular learning outcome
- $achievedProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
-
- // Number of programs that attempted a particular learning outcome
- $attemptedProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
-
- $output = array();
-
-
- // For each outcome
- foreach ($outcomes as $outcome) {
- // For each program with courses that do assessment
- foreach (Program::with(array('courses' => function ($query) {
- // $query->whereNotNull('outcomes_attempted');
- $query->whereIn('semester_id', Session::get('semesters_ids'));
- }))->where('school_id', $school->id)->orderBy('name', 'asc')->get() as $program) {
- // To acummulate all criteria for one program
- $achieved_outcomes_per_program = array_fill(1, $outcomeCount, 0);
- $attempted_outcomes_per_program = array_fill(1, $outcomeCount, 0);
-
- //Flag for counting programs
- $flag = false;
-
- // For each course in the program
- foreach ($program->courses as $course) {
- // If the outcome in question is being evaluated
- $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
- $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
- if (
- array_key_exists($outcome->id, $course_outcomes_attempted2)
- && $course_outcomes_attempted2[$outcome->id] > 0
- ) {
- $achieved_outcomes_per_program[$outcome->id] += $course_outcomes_achieved2[$outcome->id];
- $attempted_outcomes_per_program[$outcome->id] += $course_outcomes_attempted2[$outcome->id];
-
- // Add one to the programs assessing, if it wasn't added before
- if (!$flag) {
- $attemptedProgramsPerOutcome[$outcome->id] += 1;
- $flag = true;
- }
- }
-
- // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_program);
- // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
-
- }
- //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
- if ($attempted_outcomes_per_program[$outcome->id] != 0 && (float)$achieved_outcomes_per_program[$outcome->id] / $attempted_outcomes_per_program[$outcome->id] * 100 >= $outcome->expected_outcome) {
- $achievedProgramsPerOutcome[$outcome->id] += 1;
- // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
- }
- }
- }
-
- return View::make('local.managers.shared.print_school', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'school', 'assessed_sections_count', 'school_sections_count', 'achievedProgramsPerOutcome', 'attemptedProgramsPerOutcome', 'grouped_courses', 'participating_programs'));
- }
- }
|