123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764 |
- <?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.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();
- }*/
-
-
- //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();
-
- $resultados_todos=array();
- 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.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]++;
- }
- }*/
- //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'));
- }
- }
|