123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764 |
- <?php
-
- class SchoolCoordinatorsController 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 overview_test()
- {
- ini_set('memory_limit', '256M');
- DB::connection()->disableQueryLog();
- // $school = School::find($id);
- $school = Auth::user()->school;
- $id = $school->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);
-
- /**
- * 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();
-
- 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;
- }
- }
- }
-
- /**
- * 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 programs achieved and attempted each outcome in this school
- */
-
- // For each outcome
- foreach ($outcomes_grad as $outcome) {
- // $attempted_outcomes_per_grad_program[$outcome->id]=0;
- $achieved_outcomes_per_grad_program[$outcome->id] = 0;
- $attemptedGradProgramsPerOutcome[$outcome->id] = 0;
- $achievedGradProgramsPerOutcome[$outcome->id] = 0;
- $grad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 1);
- $grad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 1);
- // For each program with courses that do assessment
- foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
- // var_dump($program_id->id);exit();
- $program = DB::table('programs')
- ->where('id', '=', $program_id->id)
- ->first();
- // $program=Program::where('id', $program_id->id);
- // var_dump($program);exit();
- if ($program->is_graduate) {
- $attemptedGradProgramsPerOutcome[$outcome->id]++;
- $programC = Program::where('id', '=', $program_id->id)->first();
- // var_dump($programC);exit();
- if ($programC->achieved_outcome($outcome->id, $semesters)) {
- $achievedGradProgramsPerOutcome[$outcome->id]++;
- }
- }
- }
- $programs_with_courses = Program::with(array('courses' => function ($query) {
- // $query->whereNotNull('outcomes_attempted');
- $query->whereIn('semester_id', Session::get('semesters_ids'));
- }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
- }
- if ($school->id == 13) {
- // return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
- } else {
- // return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.schoolTest', 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 overview()
- {
- ini_set('memory_limit', '256M');
- DB::connection()->disableQueryLog();
- // $school = School::find($id);
- $school = Auth::user()->school;
- $id = $school->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);
-
- /**
- * 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();
-
- 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;
- }
- }
- }
-
- /**
- * 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 programs achieved and attempted each outcome in this school
- */
-
- // For each outcome
- foreach ($outcomes_grad as $outcome) {
- // $attempted_outcomes_per_grad_program[$outcome->id]=0;
- $achieved_outcomes_per_grad_program[$outcome->id] = 0;
- $attemptedGradProgramsPerOutcome[$outcome->id] = 0;
- $achievedGradProgramsPerOutcome[$outcome->id] = 0;
- $grad_outcomes_attempted[$outcome->id] = $outcome->attempted_by_school($semesters, $school->id, 1);
- $grad_outcomes_achieved[$outcome->id] = $outcome->achieved_by_school($semesters, $school->id, 1);
- // For each program with courses that do assessment
- foreach ($programs_attempted_in_school[$outcome->id] as $program_id) {
- // var_dump($program_id->id);exit();
- $program = DB::table('programs')
- ->where('id', '=', $program_id->id)
- ->first();
- // $program=Program::where('id', $program_id->id);
- // var_dump($program);exit();
- if ($program->is_graduate) {
- $attemptedGradProgramsPerOutcome[$outcome->id]++;
- $programC = Program::where('id', '=', $program_id->id)->first();
- // var_dump($programC);exit();
- if ($programC->achieved_outcome($outcome->id, $semesters)) {
- $achievedGradProgramsPerOutcome[$outcome->id]++;
- }
- }
- }
- $programs_with_courses = Program::with(array('courses' => function ($query) {
- // $query->whereNotNull('outcomes_attempted');
- $query->whereIn('semester_id', Session::get('semesters_ids'));
- }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
- }
- if ($school->id == 13) {
- // return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
- } else {
- // return View::make('local.managers.shared.school', compact('title', 'outcomes', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
- return View::make('local.managers.shared.school', compact('title', 'outcomes_grad', 'outcomes_undergrad', 'undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs'));
- }
- }
- public function overviewOri()
- {
- DB::disableQueryLog();
- Log::debug('user' . Auth::user()->id);
-
- //TODO Find a better way to prevent non-scoords from reaching the page
- switch (Auth::user()->role) {
- case 1:
- return Redirect::to('administrator');
- break;
- case 3:
- return Redirect::to('program-coordinator');
- break;
- }
-
- $schools = School::orderBy('name', 'asc')->get();
- $school = Auth::user()->school;
- $title = $school->name . ' ' . 'Overview';
- $id = $school->id;
-
- $outcomes = Outcome::orderBy('name', 'asc')->get();
- $outcomeCount = Outcome::all()->count();
-
- /**
- * 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'))
- ->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();*/
-
- $grad_grouped_courses = Course::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'))
- ->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();*/
-
- $undergrad_grouped_courses = Course::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) {
- 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;
- }
- }
- }
- */
-
- 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;
- // 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 = $course->outcomes_ach()) {
- // //$course_outcomes_achieved = $course->outcomes_ach();
- // $course_outcomes_attempted = $course->outcomes_att();
- // foreach ($course_outcomes_attempted as $i => $score) {
- //
- // $undergrad_outcomes_attempted[$i] += $score;
- // }
- // foreach ($course_outcomes_achieved as $i => $score) {
- // $undergrad_outcomes_achieved[$i] += $score;
- // }
- // $undergrad_assessed_sections_count += 1;
- // }
- // $undergrad_school_sections_count += 1;
- // } else {
- // if ($course_outcomes_achieved = $course->outcomes_ach()) {
- // //$course_outcomes_achieved = $course->outcomes_ach();
- // $course_outcomes_attempted = $course->outcomes_att();
- // foreach ($course_outcomes_attempted as $i => $score) {
- //
- // $grad_outcomes_attempted[$i] += $score;
- // }
- // foreach ($course_outcomes_achieved as $i => $score) {
- // $grad_outcomes_achieved[$i] += $score;
- // }
- // $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 as $outcome) {
- // 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'));
- $query->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
- ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
- ->where('activities.draft', 0)
- ->where('activities.diagnostic', 0)
- ->select('courses.*')->distinct();
- }))->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 the outcome in question is being evaluated
- $course_outcomes_attempted2 = $course->outcomes_att(); //json_decode($course->outcomes_attempted, true);
- $course_outcomes_achieved2 = $course->outcomes_ach(); //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_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 as $outcome) {
- // 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'));
- $query->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion as ac', 'ac.activity_id', '=', 'activities.id')
- ->join('assessments', 'assessments.activity_criterion_id', '=', 'ac.id')
- ->where('activities.draft', 0)
- ->where('activities.diagnostic', 0)
- ->select('courses.*')->distinct();
- }))->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 the outcome in question is being evaluated
- $course_outcomes_attempted2 = $course->outcomes_att(); // json_decode($course->outcomes_attempted, true);
- $course_outcomes_achieved2 = $course->outcomes_ach(); //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);
- }
- }
- }
- }
- // 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', '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'));
- }
- }
|