12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763 |
- <?php
-
- use PhpOffice\PhpWord\Element\Object;
-
- 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);
- //$school->school_courses_per_outcome;
-
-
-
- //$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
-
-
-
-
-
- $school_info = $school->school_courses_per_outcome;
- $grad_outcomes_attempted = $school_info['graduate_info']['outcomes_attempted_combined'];
- $grad_outcomes_achieved = $school_info['graduate_info']['outcomes_achieved_combined'];
-
- $undergrad_outcomes_attempted = $school_info['undergraduate_info']['outcomes_attempted_combined'];
- $undergrad_outcomes_achieved = $school_info['undergraduate_info']['outcomes_achieved_combined'];
-
- $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, 1 as grouped'))
- ->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, 1 as grouped'))
- ->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;
- }
- }
- }
-
-
- //Aqui estan los resultados divididos en outcomes y programs
-
-
-
- $attemptedUndergradProgramsPerOutcome = $school_info['undergraduate_info']['programs_attempted_combined'];
- $achievedUndergradProgramsPerOutcome = $school_info['undergraduate_info']['programs_achieved_combined'];
- $attemptedGradProgramsPerOutcome = $school_info['graduate_info']['programs_attempted_combined'];
- $achievedGradProgramsPerOutcome = $school_info['graduate_info']['programs_achieved_combined'];
-
-
-
-
-
- //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.66) {
-
- 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.66) {
- 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();
- }*/
-
-
- //La linea negra de proposed.
-
- //
- //
- $linea_undergrad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $undergrad_programs_list)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- ->addSelect(DB::raw("count(target_outcomes_program.semester_id) as count_semester_id"))
- ->groupBy("expected_target")
- ->orderBy("expected_target", "DESC")
- ->first();
- if (!isset($linea_undergrad)) {
- $default_undergrad = 70;
- } elseif ($linea_undergrad->count_semester_id > 1) {
-
- $default_undergrad = null;
-
- $linea_undergrad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $undergrad_programs_list)
- ->where('expected_target', $linea_undergrad->expected_target)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- //->addSelect("count(semester_id) as count_semester_id")
- //->groupBy("expected_target")
- ->orderBy("semester_id", "DESC")
- ->first();
- }
-
- $linea_grad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $grad_programs_list)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- ->addSelect(DB::raw("count(target_outcomes_program.semester_id) as count_semester_id"))
- ->groupBy("expected_target")
- ->orderBy("expected_target", "DESC")
- ->first();
- //Log::info($linea_grad);
- if (!isset($linea_grad)) {
- $default_grad = 70;
- } elseif ($linea_grad->count_semester_id > 1) {
-
- $default_grad = null;
-
- $linea_grad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $grad_programs_list)
- ->where('expected_target', $linea_grad->expected_target)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- ->orderBy("semester_id", "DESC")
- ->first();
- }
-
- $expected_target_for_undergradprograms = !isset($linea_undergrad) ? $default_undergrad : $linea_undergrad->expected_target;
- $expected_target_for_gradprograms = !isset($linea_grad) ? $default_grad : $linea_grad->expected_target;
-
-
- //Log::info($default_grad);
-
- $undergrad_programs = $school->undergraduate_programs->get();
- $grad_programs = $school->graduate_programs->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', 'expected_target_for_undergradprograms', 'expected_target_for_gradprograms', 'undergrad_programs', 'grad_programs', 'default_undergrad', 'default_grad', 'linea_undergrad', 'linea_grad', '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', 'expected_target_for_undergradprograms', 'expected_target_for_gradprograms', 'undergrad_programs', 'grad_programs', 'default_undergrad', 'default_grad', 'linea_undergrad', 'linea_grad', '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 print_school_students_report($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 . ' Assessment Report - ' . date('m/d/Y');
- $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();
- $outcomes_colap = Outcome::whereNull("new_outcome_id")->get();
-
- $info = $school->school_students_per_outcome;
-
- $outcomes_undergraduate_achieved_colap_todo = $info['undergraduate_info']['outcomes_achieved_combined'];
- $outcomes_undergraduate_attempted_colap_todo = $info['undergraduate_info']['outcomes_attempted_combined'];
-
- $outcomes_graduate_achieved_colap_todo = $info['graduate_info']['outcomes_achieved_combined'];
- $outcomes_graduate_attempted_colap_todo = $info['graduate_info']['outcomes_attempted_combined'];
-
-
- $outcomes_undergrad_program_attempted_colap = $info['undergraduate_info']['programs_attempted_combined'];
- $outcomes_undergrad_program_achieved_colap = $info['undergraduate_info']['programs_achieved_combined'];
- $outcomes_grad_program_attempted_colap = $info['graduate_info']['programs_attempted_combined'];
- $outcomes_grad_program_achieved_colap = $info['graduate_info']['programs_achieved_combined'];
-
-
- $undergraduate_programs = $school->undergraduate_programs->get();
- $graduate_programs = $school->graduate_programs->get();
-
-
-
-
-
-
-
- return View::make('local.managers.shared.print_school_students_report', compact(
- 'title', #'outcomes_attempted_colap_semesters', 'outcomes_attempted_semesters',
- 'outcomes_undergraduate_attempted_colap_todo',
- 'outcomes_undergraduate_achieved_colap_todo',
-
- 'outcomes_graduate_attempted_colap_todo',
- 'outcomes_graduate_achieved_colap_todo',
-
- 'outcomes_undergrad_program_attempted_colap',
- 'outcomes_undergrad_program_achieved_colap',
- 'outcomes_grad_program_attempted_colap',
- 'outcomes_grad_program_achieved_colap',
-
- 'undergraduate_programs',
- 'graduate_programs',
- '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 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, 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();
- $outcomes_colap = Outcome::whereNull("new_outcome_id")->get();
- /*
-
-
- $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];
- }
- }*/
-
- $info = $school->school_students_per_outcome;
- Log::info("BRR");
- Log::info($info);
-
- $outcomes_undergraduate_achieved_colap_todo = $info['undergraduate_info']['outcomes_achieved_combined'];
- $outcomes_undergraduate_attempted_colap_todo = $info['undergraduate_info']['outcomes_attempted_combined'];
- $outcomes_undergraduate_achieved_todo = $info['undergraduate_info']['outcomes_achieved_uncombined'];
- $outcomes_undergraduate_attempted_todo = $info['undergraduate_info']['outcomes_attempted_uncombined'];
-
- $outcomes_graduate_achieved_colap_todo = $info['graduate_info']['outcomes_achieved_combined'];
- $outcomes_graduate_attempted_colap_todo = $info['graduate_info']['outcomes_attempted_combined'];
- $outcomes_graduate_achieved_todo = $info['graduate_info']['outcomes_achieved_uncombined'];
- $outcomes_graduate_attempted_todo = $info['graduate_info']['outcomes_attempted_uncombined'];
-
- $outcomes_undergrad_program_attempted_colap = $info['undergraduate_info']['programs_attempted_combined'];
- $outcomes_undergrad_program_achieved_colap = $info['undergraduate_info']['programs_achieved_combined'];
- $outcomes_grad_program_attempted_colap = $info['graduate_info']['programs_attempted_combined'];
- $outcomes_grad_program_achieved_colap = $info['graduate_info']['programs_achieved_combined'];
- Log::info("mera");
- Log::info($outcomes_grad_program_attempted_colap);
- $outcomes_undergrad_program_attempted_todo = $info['undergraduate_info']['programs_attempted_uncombined'];
-
- $outcomes_undergrad_program_achieved_todo = $info['undergraduate_info']['programs_achieved_uncombined'];
-
-
- $outcomes_grad_program_attempted_todo = $info['graduate_info']['programs_attempted_uncombined'];
- $outcomes_grad_program_achieved_todo = $info['graduate_info']['programs_achieved_uncombined'];
-
- $undergraduate_programs = $school->undergraduate_programs->get();
- $graduate_programs = $school->graduate_programs->get();
-
-
-
-
-
-
-
- return View::make('local.managers.shared.school_student_result', compact(
- 'title', #'outcomes_attempted_colap_semesters', 'outcomes_attempted_semesters',
- 'outcomes_undergraduate_attempted_colap_todo',
- 'outcomes_undergraduate_achieved_colap_todo',
- 'outcomes_undergraduate_attempted_todo',
- 'outcomes_undergraduate_achieved_todo',
- 'outcomes_graduate_attempted_colap_todo',
- 'outcomes_graduate_achieved_colap_todo',
- 'outcomes_graduate_attempted_todo',
- 'outcomes_graduate_achieved_todo',
- 'outcomes_undergrad_program_attempted_colap',
- 'outcomes_undergrad_program_achieved_colap',
- 'outcomes_grad_program_attempted_colap',
- 'outcomes_grad_program_achieved_colap',
- 'outcomes_undergrad_program_attempted_todo',
- 'outcomes_undergrad_program_achieved_todo',
- 'outcomes_grad_program_attempted_todo',
- 'outcomes_grad_program_achieved_todo',
- 'undergraduate_programs',
- 'graduate_programs',
- '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();
-
- $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 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 = [];
-
-
- $school_info = $school->school_courses_per_outcome;
- $grad_outcomes_attempted = $school_info['graduate_info']['outcomes_attempted_combined'];
- $grad_outcomes_achieved = $school_info['graduate_info']['outcomes_achieved_combined'];
-
- $undergrad_outcomes_attempted = $school_info['undergraduate_info']['outcomes_attempted_combined'];
- $undergrad_outcomes_achieved = $school_info['undergraduate_info']['outcomes_achieved_combined'];
-
-
-
-
-
-
-
- $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;
- }
- }
- }
-
- $attemptedUndergradProgramsPerOutcome = $school_info['undergraduate_info']['programs_attempted_combined'];
- $achievedUndergradProgramsPerOutcome = $school_info['undergraduate_info']['programs_achieved_combined'];
- $attemptedGradProgramsPerOutcome = $school_info['graduate_info']['programs_attempted_combined'];
- $achievedGradProgramsPerOutcome = $school_info['graduate_info']['programs_achieved_combined'];
-
-
-
-
-
-
- //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.66) {
-
- 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.66) {
- if (!isset($achievedGradProgramsPerOutcome[$outcome_id][$program_id]))
- $achievedGradProgramsPerOutcome[$outcome_id][$program_id] = 0;
- $achievedGradProgramsPerOutcome[$outcome_id][$program_id]++;
- }
- }*/
- //La linea negra de proposed.
-
- //
- $linea_undergrad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $undergrad_programs_list)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- ->addSelect(DB::raw("count(target_outcomes_program.semester_id) as count_semester_id"))
- ->groupBy("expected_target")
- ->orderBy("expected_target", "DESC")
- ->first();
- if (!isset($linea_undergrad)) {
- $default_undergrad = 70;
- } elseif ($linea_undergrad->count_semester_id > 1) {
-
- $default_undergrad = null;
-
- $linea_undergrad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $undergrad_programs_list)
- ->where('expected_target', $linea_undergrad->expected_target)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- //->addSelect("count(semester_id) as count_semester_id")
- //->groupBy("expected_target")
- ->orderBy("semester_id", "DESC")
- ->first();
- }
-
- $linea_grad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $grad_programs_list)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- ->addSelect(DB::raw("count(target_outcomes_program.semester_id) as count_semester_id"))
- ->groupBy("expected_target")
- ->orderBy("expected_target", "DESC")
- ->first();
- if (!isset($linea_grad)) {
- $default_grad = 70;
- } elseif ($linea_grad->count_semester_id > 1) {
-
- $default_grad = null;
-
- $linea_grad = DB::table('target_outcomes_program')
- ->join('programs', 'programs.id', '=', 'target_outcomes_program.program_id')
- ->join('semesters', 'semesters.id', '=', 'target_outcomes_program.semester_id')
- ->whereIn('program_id', $grad_programs_list)
- ->where('expected_target', $linea_grad->expected_target)
- ->whereIn("semester_id", Session::get('semesters_ids'))
- ->select("target_outcomes_program.*", 'programs.name as program_name', 'semesters.name as semester_name')
- ->orderBy("semester_id", "DESC")
- ->first();
- }
-
- $expected_target_for_undergradprograms = !isset($linea_undergrad) ? $default_undergrad : $linea_undergrad->expected_target;
- $expected_target_for_gradprograms = !isset($linea_grad) ? $default_grad : $linea_grad->expected_target;
-
-
- //Log::info($default_grad);
-
- $undergrad_programs = $school->undergraduate_programs->get();
- $grad_programs = $school->graduate_programs->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.print_school', compact('title', 'expected_target_for_undergradprograms', 'expected_target_for_gradprograms', 'undergrad_programs', 'grad_programs', 'default_undergrad', 'default_grad', 'linea_undergrad', 'linea_grad', '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.print_school', compact('title', 'expected_target_for_undergradprograms', 'expected_target_for_gradprograms', 'undergrad_programs', 'grad_programs', 'default_undergrad', 'default_grad', 'linea_undergrad', 'linea_grad', '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'));
- }
-
-
- $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'));
- }
- }
|