123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873 |
- <?php
-
- use Illuminate\Database\Eloquent\SoftDeletingTrait;
-
- class Outcome extends Eloquent
- {
- use SoftDeletingTrait;
- protected $dates = ['deleted_at'];
-
- protected $fillable = array('name', 'definition');
-
- protected $appends = array("annual_objectives");
-
- //dirty code, this belongs to annual plan, but outcome has the important data
- public function getExpectedTargetAttribute()
- {
- if (isset($this->semester_id) && isset($this->program_id)) {
- $expected_target = DB::table("target_outcomes_program")
- ->where('program_id', $this->program_id)
- ->where('semester_id', $this->semester_id)
- ->first();
- Log::info("PApi que hayy chabau");
- Log::info(array($expected_target));
- if ($expected_target != null) {
- Log::info("PApi no chabau");
- return $expected_target->expected_target;
- } else return "Go to Annual Plan and define a target for learning outcome";
- }
- Log::info("PApi rip chabau");
- return null;
- }
-
- //Dirty code sort of, la accion transformadora es para el programa, ppero esta bajo el dominio
- //tecnicamente esto es hasta del annual plan, pero na, outcomes bajo el annual plan van a tener
- // este atributo
-
- //program_transformative_actions
- public function getProgramTransformativeActionsAttribute()
- {
- /*$transformative_actions = DB::table('transformative_typ_outcome')
- ->where('typ_semester_outcome_id', $this->typ_semester_outcome_id)
- ->get();
- $trans_actions = [];
- foreach ($transformative_actions as $trans) {
- $ta = TransformativeAction::where('id', $trans->trans_id)->first();
- $ta->setAttribute('semester_id', $this->semester_id);
- $trans_actions[] = $ta;
- }
- return $trans_actions;*/
-
- return TransformativeAction::join('transformative_typ_outcome', 'transformative_typ_outcome.trans_id', '=', 'transformative_actions.id')
- ->where('typ_semester_outcome_id', $this->typ_semester_outcome_id)
- ->select('transformative_actions.*', DB::raw("{$this->semester_id} as semester_id"))
- ->get();
- }
-
- public function getCommentsAttribute()
- {
- return DB::table('typ_outcome_report_comments')
- ->where('typ_semester_outcome_id', $this->typ_semester_outcome_id)
- ->get();
- }
- // Son los resultados de los estudiantes por dominio, devuelve el percent.
- public function getStudentPerformanceAttribute()
- {
-
- //create Counter for students
-
- $whole_dict = [];
- foreach ($this->annual_objectives as $objective) {
- foreach ($objective->grouped_annual_course as $course_code) {
- Log::info("Existen los cursos");
- Log::info(json_encode($course_code));
- foreach ($course_code->student_report_for_outcome as $student) {
-
- //If is not defined, define
- if (!isset($whole_dict[$student->student_id])) {
- $whole_dict[$student->student_id] = array(
- 'student' => $student->student_id,
- 'criteria_attempted' => 0,
- 'criteria_achieved' => 0
- );
- }
- $whole_dict[$student->student_id]["criteria_attempted"] += $student->criteria_attempted;
- $whole_dict[$student->student_id]["criteria_achieved"] += $student->criteria_achieved;
- }
- }
- }
-
- $students_achieved = 0;
- $students_attempted = 0;
-
- Log::info('Outcome_content');
- Log::info($whole_dict);
-
- foreach ($whole_dict as $student) {
- if ($student['criteria_attempted']) {
-
- $students_attempted += 1;
- $percentage = (($student['criteria_achieved'] / $student['criteria_attempted']) * 100);
- if ($percentage >= $this->expected_outcome) {
-
- $students_achieved += 1;
- }
- }
- }
-
- if ($students_attempted != 0)
- return round(($students_achieved / $students_attempted) * 100, 2);
- else
- return "N/A";
- /*
- if (course_code.criteria.length) {
-
- $.each(course_code.students, function(index, student) {
- if (wholeDict[student.student_id] === undefined) {
- wholeDict[student.student_id] = {
- 'student': student.student_id,
- 'criteria_attempted': 0,
- 'criteria_achieved': 0
- }
-
- }
- wholeDict[student.student_id][
- "criteria_attempted"
- ] += student
- .criteria_attempted;
- wholeDict[student.student_id][
- "criteria_achieved"
- ] += student
- .criteria_achieved;
-
- });
-
- $.each(wholeDict, function(key, dict) {
-
-
- if (dict.criteria_attempted) {
- students_attempted += 1;
- percentage = ((dict.criteria_achieved / dict.criteria_attempted) * 100).toFixed(
- 2);
- if (parseFloat(percentage) >= parseFloat(outcome.expected_outcome)) {
- achieved = "Yes"
- students_achieved += 1;
- } else achieved = "No"
- } else {
- percentage = "N/A"
- achieved = "N/A"
- }
- tableStudent.row.add([
- dict.student,
- dict.criteria_attempted,
- dict.criteria_achieved,
- percentage,
- achieved
-
- ]);
- })
- */
- }
-
- public function criteria()
- {
- return $this->hasManyThrough('Criterion', 'Objective')->orderBy('name');
- }
-
-
- public function fetchObjectivesReport($semester_id, $program_id, $with_model = false)
- {
- /*$objectives = DB::table('typ_semester_outcome')
- ->join('typ_semester_objectives', 'typ_semester_objectives.typ_semester_outcome_id', '=', 'typ_semester_outcome.id')
- ->join('objectives', 'objectives.id', '=', 'typ_semester_objectives.objective_id')
- ->join("typ_program", 'typ_program.id', '=', 'typ_semester_outcome.typ_program_id')
- ->where('typ_semester_outcome.semester_id', $semester_id)
- ->where('typ_program.program_id', $program_id)
- ->where('typ_semester_outcome.outcome_id', $this->id)
- ->select('objectives.*')
- ->get();*/
-
- $objectives = DB::table('objectives')
- ->join('typ_semester_objectives', 'typ_semester_objectives.objective_id', '=', 'objectives.id')
- ->join('typ_semester_outcome', 'typ_semester_outcome.id', '=', 'typ_semester_objectives.typ_semester_outcome_id')
- ->join('typ_program', 'typ_program.id', '=', 'typ_semester_outcome.typ_program_id')
- ->where('semester_id', $semester_id)
- ->where('program_id', $program_id)
- ->where('outcome_id', $this->id)
- ->select('objectives.id as objective_id', 'objectives.text', 'typ_semester_objectives.id as typ_semester_objective_id', 'program_id', 'semester_id')
- ->distinct();
-
- Log::info('agooooo me');
- ////Log::info($objectives->toSql());
- //Log::info('semester_program_outcome' . $semester_id . ',' . $program_id . ',' . $this->id);
-
- if ($with_model) {
- Log::info("Acho aqui estamos en with_model");
- $objective_id = $objectives->lists('objective_id');
- $typ_semester_objective_ids = $objectives->lists('typ_semester_objective_id');
- //$program_id = $objectives->lists('program_id');
- //$semester_id = $objectives ->lists('semester_id');
-
- $objectives = Objective::whereIn("objectives.id", $objective_id);
- Log::info($objective_id);
- //Log::info(array($objectives));
-
- foreach ($objectives as $i => $o) {
- Log::info("entramos aqui tambien?");
- $o->setAttribute("typ_semester_objective_id", $typ_semester_objective_ids[$i]);
- $o->setAttribute("program_id", $program_id);
- $o->setAttribute("semester_id", $semester_id);
- }
- return $objectives;
- }
-
-
- return $objectives->get();
- }
-
- //Intento de get objectives pareados en un plan
-
- public function getAnnualObjectivesAttribute()
- {
- if (isset($this->typ_semester_outcome_id)) {
- /*Log::info('estamos aqui');
- $objectives = DB::table("typ_semester_objectives")
- ->join('objectives', 'objectives.id', '=', 'typ_semester_objectives.objective_id')
- ->where('typ_semester_outcome_id', $this->typ_semester_outcome_id)
- ->select('typ_semester_objectives.id as typ_semester_objective_id', 'objectives.id as objective_id')
- ->get();
- //$objectives_id = $objectives->lists('objective_id');
- //$typ_semester_objective_ids = $objectives->lists('typ_semester_objective_id');
- //$program_id = $objectives->lists('program_id');
- //$semester_id = $objectives ->lists('semester_id');
- //Log::info($this->typ_semester_outcome_id);
- //Log::info($objectives_id);
-
- $objectives_list = []; // Objective::whereIn("id", $objectives_id)->get();
-
- foreach ($objectives as $i => $ob) {
- $o = Objective::find($ob->objective_id);
- //Log::info("entramos aqui tambien?");
- $o->setAttribute("typ_semester_objective_id", $ob->typ_semester_objective_id); //$typ_semester_objective_ids[$i]);
- $o->setAttribute("semester_id", $this->semester_id);
- $o->setAttribute('program_id', $this->program_id);
- $objectives_list[] = $o;
- }
-
- return $objectives_list;*/
-
- return Objective::join("typ_semester_objectives", 'objectives.id', '=', 'typ_semester_objectives.objective_id')
- ->where('typ_semester_outcome_id', $this->typ_semester_outcome_id)
- ->select(
- 'typ_semester_objectives.id as typ_semester_objective_id',
- 'objectives.id as objective_id',
- 'objectives.*',
- DB::raw("{$this->semester_id} as semester_id"),
- DB::raw("{$this->program_id} as program_id")
- )
- ->get();
- //return $objectives;
- }
- Log::info("Lol");
- return null;
- }
- /**
- * Return the objectives that the outcome belongs to
- *
- * @return Illuminate\Database\Eloquent\Model
- */
- public function objectives()
- {
- return $this->hasMany('Objective');
- // return $this->belongsToMany('Objective', 'objective_outcome');
- }
- // public function attempted($semester, $is_grad)
- // {
- // return DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->where('courses.semester_id','=',$semester)
- // ->count(DB::raw('DISTINCT new_criteria.id,activity_criterion.activity_id'))
- // ;
- //
- // }
- // public function attempted($semester, $is_grad)
- // {
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->where('courses.semester_id','=',$semester)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- // $conteo=0;
- // foreach($criteria as $criterion)
- // {
- // $students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
- // if($students_attempted)
- // {
- // $conteo++;
- // }
- // }
- // return $conteo;
- // }
- public static function active_by_semesters($selected_semesters, $level)
- {
- $min_start = "9000-01-01 00:00:00";
- $max_end = "1000-01-01 00:00:00";
- foreach ($selected_semesters as $semester) {
- if ($min_start > $semester->start) {
- $min_start = $semester->start;
- }
- if ($max_end < $semester->end) {
- $max_end = $semester->end;
- }
- }
- $outcomes = Outcome::where(function ($query) use ($min_start) {
- $query->where('deactivation_date', '>=', $min_start)
- ->orWhere('deactivation_date', null);
- })
- ->where('activation_date', '<=', $max_end)
- ->where(function ($query2) use ($level) {
- $query2->where("level", $level + 1)
- ->orWhere("level", 3);
- })
- ->orderBy('name', 'ASC')
- ->get();
-
- // return array('outcomes'=>$outcomes,'outcomes_attempted'=>$outcomes_attempted, 'outcomes_achieved'=>$outcomes_achieved, 'attemptedProgramsPerOutcome'=>$attemptedProgramsPerOutcome, 'achievedProgramsPerOutcome'=>$achievedProgramsPerOutcome,'participating_programs'=>$participating_programs);
- return $outcomes;
- }
-
- public function programs_attempted($semesters)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
- // $programs=DB::table('programs')
- // ->join('courses', 'programs.id', '=', 'courses.program_id')
- // ->join('activities', 'activities.course_id', '=', 'courses.id')
- // ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->distinct()
- // ->select('programs.id')
- // ->get()
- // ;
- $programs = DB::table('programs')
- ->join('courses', 'programs.id', '=', 'courses.program_id')
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('criteria', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->whereIn('courses.semester_id', $semesters_array)
- ->distinct()
- ->select('programs.id')
- ->get();
-
- return $programs;
- }
-
- public function programs_attempted_in_school($semesters, $school_id)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
- // $programs=DB::table('programs')
- // ->join('courses', 'programs.id', '=', 'courses.program_id')
- // ->join('activities', 'activities.course_id', '=', 'courses.id')
- // ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->distinct()
- // ->select('programs.id')
- // ->get()
- // ;
- $programs = DB::table('programs')
- ->join('courses', 'programs.id', '=', 'courses.program_id')
- ->join('activities', 'activities.course_id', '=', 'courses.id')
- ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('criteria', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->where('programs.school_id', '=', $school_id)
- ->whereIn('courses.semester_id', $semesters_array)
- ->distinct()
- ->select('programs.id')
- ->get();
-
- return $programs;
- }
-
- public function attempted($semesters, $is_grad)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->where('programs.is_graduate', '=', $is_grad)
- ->whereIn('courses.semester_id', $semesters_array)
- ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
-
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- if ($students_attempted) {
- $conteo++;
- }
- }
- // var_dump($conteo);
- // exit();
- return $conteo;
- }
-
- public function attempted_by_school($semesters, $school_id, $is_grad)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->where('programs.is_graduate', '=', $is_grad)
- ->where('programs.school_id', '=', $school_id)
- ->whereIn('courses.semester_id', $semesters_array)
- ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
-
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- if ($students_attempted) {
- $conteo++;
- }
- }
- // var_dump($conteo);
- // exit();
- return $conteo;
- }
-
- public function attempted_by_program($semesters, $program_id, $is_grad)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('rubric_activity', 'activities.id', '=', 'rubric_activity.activity_id')
- ->join('rubrics', 'rubrics.id', '=', 'rubric_activity.rubric_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->where('programs.is_graduate', '=', $is_grad)
- ->where('programs.id', '=', $program_id)
- ->whereIn('courses.semester_id', $semesters_array)
- ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
-
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- if ($students_attempted) {
- $conteo++;
- }
- }
- // var_dump($conteo);
- // exit();
- return $conteo;
- }
-
- public function courses_attempted($courses)
- {
- $courses_array = [];
- foreach ($courses as $course) {
- // var_dump($course);
- // exit();
- $courses_array[] = $course->id;
- }
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->whereIn('courses.id',$courses_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->whereIn('courses.id', $courses_array)
- ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- if ($students_attempted) {
- $conteo++;
- }
- }
- // var_dump($conteo);
- // exit();
- return $conteo;
- }
-
- public function courses_achieved($courses)
- {
- $courses_array = [];
- foreach ($courses as $course) {
- $courses_array[] = $course->id;
- }
-
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->whereIn('courses.id',$courses_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->whereIn('courses.id', $courses_array)
- ->select('criteria.id', 'expected_percentage as expected_percentage_students_achieving', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
-
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- $students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
-
- if ($students_attempted) {
- $percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
- } else {
- $percentage_students_who_achieved = 0;
- }
- if ($percentage_students_who_achieved >= $criterion->expected_percentage_students_achieving) {
- $conteo++;
- }
- }
- return $conteo;
- }
-
- public function achieved($semesters, $is_grad)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
-
- // DB::enableQueryLog();
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->where('programs.is_graduate', '=', $is_grad)
- ->whereIn('courses.semester_id', $semesters_array)
- ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
- // dd(DB::getQueryLog());
-
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- $students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
-
- if ($students_attempted) {
- $percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
- } else {
- $percentage_students_who_achieved = 0;
- }
- if ($percentage_students_who_achieved >= $criterion->expected_percentage) {
- $conteo++;
- }
- }
- return $conteo;
- }
-
- public function achieved_by_school($semesters, $school_id, $is_grad)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
-
- // DB::enableQueryLog();
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->where('programs.is_graduate', '=', $is_grad)
- ->where('programs.school_id', '=', $school_id)
- ->whereIn('courses.semester_id', $semesters_array)
- ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
- // dd(DB::getQueryLog());
-
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- $students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
-
- if ($students_attempted) {
- $percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
- } else {
- $percentage_students_who_achieved = 0;
- }
- if ($percentage_students_who_achieved >= $criterion->expected_percentage) {
- $conteo++;
- }
- }
- return $conteo;
- }
-
- public function achieved_by_program($semesters, $program_id, $is_grad)
- {
- $semesters_array = [];
- foreach ($semesters as $semester) {
- $semesters_array[] = $semester->id;
- }
-
- // DB::enableQueryLog();
- // $criteria=DB::table('new_criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->whereIn('courses.semester_id',$semesters_array)
- // ->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- $criteria = DB::table('criteria')
- ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- ->join('courses', 'activities.course_id', '=', 'courses.id')
- ->join('programs', 'programs.id', '=', 'courses.program_id')
- ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- ->join('rubric_activity', 'rubric_activity.activity_id', '=', 'activities.id')
- ->join('rubrics', 'rubric_activity.rubric_id', '=', 'rubrics.id')
- ->where('criterion_objective_outcome.outcome_id', '=', $this->id)
- ->where('programs.is_graduate', '=', $is_grad)
- ->where('programs.school_.semester_id', $semesters_array)
- ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id')
- ->distinct()
- ->get();
- // dd(DB::getQueryLog());
-
- $conteo = 0;
- foreach ($criteria as $criterion) {
- $students_attempted = Criterion::students_attempted($criterion->id, $criterion->activity_id);
- $students_achieved = Criterion::students_achieved($criterion->id, $criterion->activity_id);
-
- if ($students_attempted) {
- $percentage_students_who_achieved = 100.0 * $students_achieved / $students_attempted;
- } else {
- $percentage_students_who_achieved = 0;
- }
- if ($percentage_students_who_achieved >= $criterion->expected_percentage) {
- $conteo++;
- }
- }
- return $conteo;
- }
-
-
- // public function achieved($semester, $is_grad)
- // {
- //
- // // DB::enableQueryLog();
- // $criteria=DB::table('criteria')
- // ->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'criteria.id')
- // ->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
- // ->join('courses', 'activities.course_id', '=', 'courses.id')
- // ->join('programs', 'programs.id', '=', 'courses.program_id')
- // ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
- // ->where('criterion_objective_outcome.outcome_id','=',$this->id)
- // ->where('programs.is_graduate','=',$is_grad)
- // ->where('courses.semester_id','=',$semester)
- // ->select('criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
- // ->distinct()
- // ->get()
- // ;
- // // dd(DB::getQueryLog());
- //
- // $conteo=0;
- // foreach($criteria as $criterion)
- // {
- // $outcome_performance=DB::table('outcome_performance')
- // ->where('outcome_performance.outcome_id','=',$this->id)
- // ->where('outcome_performance.criterion_id','=',$criterion->id)
- // ->where('outcome_performance.semester_id','=',$semester)
- // ->where('outcome_performance.level','=',$is_grad)
- // ->select('students_attempted','students_achieved')
- // ->first();
- // if(!empty($outcome_performance) and $outcome_performance->students_attempted)
- // {
- // $percentage_students_who_achieved=100.0*$outcome_performance->students_achieved/$outcome_performance->students_attempted;
- // }
- // else
- // {
- // $students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
- // $students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
- //
- // if($students_attempted)
- // {
- // $percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
- // DB::table('outcome_performance')->insert(array('criterion_id'=>$criterion->id,'outcome_id'=>$this->id,'semester_id'=>$semester,
- // 'students_attempted' => $students_attempted,'students_achieved' => $students_achieved,'level'=>$is_grad));
- // }
- // else
- // {
- // $percentage_students_who_achieved=0;
- // }
- // }
- // if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
- // {
- // $conteo++;
- // }
- // }
- // return $conteo;
- // }
- //
-
- public static function active()
- {
- //TODO: Check when semester doesnt exist or session is empty
- $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
- return Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
- }
- }
|