belongsTo('School'); } public function courses() { return $this->hasMany('Course')->with('semester')->whereIn('semester_id', Session::get('semesters_ids'))->orderBy('code')->orderBy('number')->orderBy('section'); } public function coordinators() { return $this->hasMany('User'); } public function professors() { return $this->hasMany('Professor'); } public function students() { return $this->hasMany('Student'); } public function getProgramStudentsPerOutcomeAttribute() { $semesters = Semester::whereIn('id', Session::get('semesters_ids'))->get(); //if ($this->is_graduate == 1) { // $outcomes = Outcome::active_by_semesters($semesters, 1); //} else { // $outcomes = Outcome::active_by_semesters($semesters, 0); //} $outcomes = Outcome::orderBy('name', 'asc')->get(); $outcome_ids = DB::table("outcomes") ->whereNotNull('new_outcome_id') ->get(); $combined_outcomes = []; foreach ($outcome_ids as $outcome) { $combined_outcomes[$outcome->id] = $outcome->new_outcome_id; } $array_to_send = []; $students = 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') ->join('outcomes', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id') ->where('students.program_id', $this->id) ->whereIn('semester_id', Session::get('semesters_ids')) ->where('semesters.is_visible', '=', 1) ->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'outcomes.expected_outcome', 'criterion_objective_outcome.criterion_id', 'score', 'expected_points') ->addSelect(DB::raw("count(activity_criterion.criterion_id) as criteria_attempted")) ->addSelect(DB::raw("count(CASE WHEN score>= expected_points then 1 else null END) as criteria_achieved")) ->groupBy('students.id', 'outcome_id') ->get(); $array_to_send['program_info'] = []; $array_to_send['program_info']['outcomes_attempted'] = []; $out_att = []; $out_ach = []; foreach ($outcomes as $outcome) { $out_att[$outcome->id] = 0; $out_ach[$outcome->id] = 0; } //las filas son , estudiante, outcome que intentó, criterios_attempted, criterion_achieved, foreach ($students as $result) { $crit_att = $result->criteria_attempted; $crit_ach = $result->criteria_achieved; $expected_outcome = $result->expected_outcome; $out_att[$result->outcome_id] += 1; if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) { $out_ach[$result->outcome_id] += 1; } } $array_to_send['program_info']['outcomes_attempted_uncombined'] = $out_att; $array_to_send['program_info']['outcomes_achieved_uncombined'] = $out_ach; $the_processed_table = []; foreach ($students as $result) { $student_id = $result->student_id; $outcome_id = $result->outcome_id; $expected_outcome = $result->expected_outcome; if (isset($combined_outcomes[$outcome_id])) $outcome_id = $combined_outcomes[$outcome_id]; if (!isset($the_processed_table[$student_id])) { $the_processed_table[$student_id] = []; } //si en esta tabla, el estudiante no está pareado con este dominio, entonces registra // los criterios, achieved y attempted if (!isset($the_processed_table[$student_id][$outcome_id])) { $the_processed_table[$student_id][$outcome_id] = array( "criteria_attempted" => $result->criteria_attempted, "criteria_achieved" => $result->criteria_achieved, "expected_outcome" => $expected_outcome ); } //si este estudiante está pareado a este dominio, significa que ahora estoy en los //deprecated outcomes. else { $the_processed_table[$student_id][$outcome_id]['criteria_attempted'] += $result->criteria_attempted; $the_processed_table[$student_id][$outcome_id]['criteria_achieved'] += $result->criteria_achieved; } } //Log::info("ESTOY LOCO POR TI"); //Log::info($the_processed_table); $out_att = []; $out_ach = []; foreach ($outcomes as $outcome) { $out_att[$outcome->id] = 0; $out_ach[$outcome->id] = 0; } foreach ($the_processed_table as $student_id => $outcome_ids) { //Log::info("AQUI"); //Log::info($outcome_ids); foreach ($outcome_ids as $outcome_id => $crit_information) { //Log::info($crit_information); $crit_att = $crit_information['criteria_attempted']; $crit_ach = $crit_information['criteria_achieved']; $expected_outcome = $crit_information['expected_outcome']; $out_att[$outcome_id] += 1; if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) { $out_ach[$outcome_id] += 1; } } } $array_to_send['program_info']['outcomes_attempted_combined'] = $out_att; $array_to_send['program_info']['outcomes_achieved_combined'] = $out_ach; return $array_to_send; } public function getCriteriaAttribute() { if ($this->outcome_id) { return Criterion::join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'criteria.id') ->join('program_criterion_objective_outcome', 'program_criterion_objective_outcome.cri_obj_out_id', '=', 'cobo.id') ->select('criteria.*', 'cobo.id as cobo_id', 'cobo.objective_id', 'cobo.outcome_id', 'cobo.criterion_id') ->addSelect('program_criterion_objective_outcome.id as pcobo_id') ->where('program_id', $this->id) ->where('outcome_id', $this->outcome_id) ->get(); } else { return Criterion::join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'criteria.id') ->join('program_criterion_objective_outcome', 'program_criterion_objective_outcome.cri_obj_out_id', '=', 'cobo.id') ->select('criteria.*', 'cobo.id as cobo_id', 'cobo.objective_id', 'cobo.outcome_id', 'cobo.criterion_id') ->addSelect('program_criterion_objective_outcome.id as pcobo_id') ->where('program_id', $this->id) ->get(); } } public function getCoursesWithAssessmentCountAttribute() { return DB::table('courses') ->join(DB::raw("(SELECT distinct courses.* from courses join activities on activities.course_id = courses.id join activity_criterion on activity_criterion.activity_id = activities.id join assessments on activity_criterion.id = assessments.activity_criterion_id) as q"), function ($j) { $j->on('q.semester_id', '=', 'courses.semester_id') ->on('q.program_id', '=', 'courses.program_id'); }) ->where('courses.program_id', $this->id) ->whereIn('courses.semester_id', Session::get('semesters_ids')) ->select(DB::raw('count(DISTINCT courses.id) as courses_program, count(DISTINCT q.id) as courses_assessed')) ->first(); } public function getCoursesStudentsScorePerOutcomeAttribute() { $outcomes = Outcome::orderBy('name', 'asc')->get(); $outcome_ids = DB::table("outcomes") ->whereNotNull('new_outcome_id') ->get(); $combined_outcomes = []; foreach ($outcome_ids as $outcome) { $combined_outcomes[$outcome->id] = $outcome->new_outcome_id; } $array_to_send = []; $students = 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') ->join('outcomes', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id') ->where('courses.program_id', $this->id) ->whereIn('semester_id', Session::get('semesters_ids')) ->where('semesters.is_visible', '=', 1) ->select('student_id', 'students.program_id', 'semesters.code', 'outcome_id', 'outcomes.expected_outcome', 'criterion_objective_outcome.criterion_id', 'score', 'expected_points') ->addSelect(DB::raw("count(activity_criterion.criterion_id) as criteria_attempted")) ->addSelect(DB::raw("count(CASE WHEN score>= expected_points then 1 else null END) as criteria_achieved")) ->groupBy('students.id', 'outcome_id') ->get(); $array_to_send['program_info'] = []; $array_to_send['program_info']['outcomes_attempted'] = []; $out_att = []; $out_ach = []; foreach ($outcomes as $outcome) { $out_att[$outcome->id] = 0; $out_ach[$outcome->id] = 0; } //las filas son , estudiante, outcome que intentó, criterios_attempted, criterion_achieved, foreach ($students as $result) { $crit_att = $result->criteria_attempted; $crit_ach = $result->criteria_achieved; $expected_outcome = $result->expected_outcome; $out_att[$result->outcome_id] += 1; if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) { $out_ach[$result->outcome_id] += 1; } } $array_to_send['program_info']['outcomes_attempted_uncombined'] = $out_att; $array_to_send['program_info']['outcomes_achieved_uncombined'] = $out_ach; $the_processed_table = []; foreach ($students as $result) { $student_id = $result->student_id; $outcome_id = $result->outcome_id; if (isset($combined_outcomes[$outcome_id])) $outcome_id = $combined_outcomes[$outcome_id]; if (!isset($the_processed_table[$student_id])) { $the_processed_table[$student_id] = []; } //si en esta tabla, el estudiante no está pareado con este dominio, entonces registra // los criterios, achieved y attempted if (!isset($the_processed_table[$student_id][$outcome_id])) { $the_processed_table[$student_id][$outcome_id] = array( "criteria_attempted" => $result->criteria_attempted, "criteria_achieved" => $result->criteria_achieved, "expected_outcome" => $result->expected_outcome ); } //si este estudiante está pareado a este dominio, significa que ahora estoy en los //deprecated outcomes. else { $the_processed_table[$student_id][$outcome_id]['criteria_attempted'] += $result->criteria_attempted; $the_processed_table[$student_id][$outcome_id]['criteria_achieved'] += $result->criteria_achieved; } } //Log::info("ESTOY LOCO POR TI"); //Log::info($the_processed_table); $out_att = []; $out_ach = []; foreach ($outcomes as $outcome) { $out_att[$outcome->id] = 0; $out_ach[$outcome->id] = 0; } foreach ($the_processed_table as $student_id => $outcome_ids) { //Log::info("AQUI"); //Log::info($outcome_ids); foreach ($outcome_ids as $outcome_id => $crit_information) { //Log::info($crit_information); $crit_att = $crit_information['criteria_attempted']; $crit_ach = $crit_information['criteria_achieved']; $expected_outcome = $crit_information['expected_outcome']; $out_att[$outcome_id] += 1; if ($crit_att != 0 && ($crit_ach / $crit_att) * 100 >= $expected_outcome) { $out_ach[$outcome_id] += 1; } } } $array_to_send['program_info']['outcomes_attempted_combined'] = $out_att; $array_to_send['program_info']['outcomes_achieved_combined'] = $out_ach; return $array_to_send; } public function templates() { return $this->hasMany('Template'); } public function activities() { return $this->hasManyThrough('Activity', 'Course')->whereNotNull('activities.outcomes_attempted')->whereIn('semester_id', Session::get('semesters_ids')); } public function publishedActivities() { return $this->hasManyThrough('Activity', 'Course') //->whereNotNull('activities.outcomes_attempted') ->where('activities.draft', 0) ->where('activities.diagnostic', 0)->whereIn('semester_id', Session::get('semesters_ids')); } public function assessesOutcome($outcome_id) { foreach ($this->publishedActivities as $activity) { $assessed = DB::table('activity_criterion') ->join('assessments', 'assessments.activity_criterion_id', '=', 'activity_criterion.id') ->where('activity_id', $activity->id) ->first(); if (!$assessed) continue; $outcomes_attempted = (array)$activity->o_att_array; if (array_key_exists($outcome_id, $outcomes_attempted) && $outcomes_attempted[$outcome_id] != 0) { return true; } } return false; } // return the users that are pcoords for a program public function users() { return $this->belongsToMany('User'); } public function objectives() { return $this->hasMany('Objective'); } // Return learning objectives ordered by outcome public function objectivesByOutcome() { // Objective:: $objectives = DB::table('outcomes') ->select('outcomes.id as outcome_id', 'outcomes.name as outcome_name', 'objectives.id as objective_id', 'objectives.text', 'objectives.active') ->leftJoin('objectives', function ($join) { $join ->on('outcomes.id', '=', 'objectives.outcome_id') ->where('objectives.program_id', '=', $this->id); }) ->orderBy('outcome_name', 'ASC') ->orderBy('objectives.text', 'ASC') ->get(); return $objectives; } public function annualPlan() { return $this->hasMany("AnnualPlan"); } public function hasObjectivesInOutcome($outcome_id) { return Objective::where('program_id', $this->id) ->where('outcome_id', $outcome_id)->count(); } /** * Return all the criteria in/for the program, if any * * @return Illuminate\Database\Eloquent\Collection */ /* public function criteria() { Log::info("AQUI"); $lmao = Criterion::join('criterion_objective_outcome', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id') ->join('program_criterion_objective_outcome', 'cri_obj_out_id', '=', 'criterion_objective_outcome.id') ->where('program_id', $this->id)->get(); return $lmao; $l = Criterion::join('criterion_objective_outcome', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id') ->join('program_criterion_objective_outcome', 'cri_obj_out_id', '=', 'criterion_objective_outcome.id') ->where('program_id', $this->id)->get(); //get(); }*/ // public function attempted_outcome($outcome_id, $semester) // { // $conteo= DB::table('activity_criterion') // ->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', '=', 'activity_criterion.criterion_id') // ->where('criterion_objective_outcome.outcome_id','=',$outcome_id) // ->where('programs.id','=',$this->id) // ->where('courses.semester_id','=',$semester) // ->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id')) // ; // return $conteo; // } public function attempted_criteria_by_outcome($outcome_id, $semesters) { $semesters_array = []; foreach ($semesters as $semester) { $semesters_array[] = $semester->id; } $conteo = DB::table('activity_criterion') ->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', '=', 'activity_criterion.criterion_id') ->where('criterion_objective_outcome.outcome_id', '=', $outcome_id) ->where('programs.id', '=', $this->id) ->whereIn('courses.semester_id', $semesters_array) ->count(DB::raw('DISTINCT criterion_objective_outcome.criterion_id')); return $conteo; } public function attempted_outcome($outcome_id, $semesters) { $semesters_array = []; foreach ($semesters as $semester) { $semesters_array[] = $semester->id; } $conteo = DB::table('activity_criterion') ->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', '=', 'activity_criterion.criterion_id') ->where('criterion_objective_outcome.outcome_id', '=', $outcome_id) ->where('programs.id', '=', $this->id) ->whereIn('courses.semester_id', $semesters_array) ->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id')); /* Log::info(DB::table('activity_criterion') ->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', '=', 'activity_criterion.criterion_id') ->where('criterion_objective_outcome.outcome_id', '=', $outcome_id) ->where('programs.id', '=', $this->id) ->whereIn('courses.semester_id', $semesters_array) ->toSql()); */ return $conteo; } public function achieved_criteria_by_outcome($outcome_id, $semesters) { $semesters_array = []; foreach ($semesters as $semester) { $semesters_array[] = $semester->id; } // DB::enableQueryLog(); // dd(DB::getQueryLog()); // $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','=',$outcome_id) // ->where('programs.id','=',$this->id) // ->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', '=', $outcome_id) ->where('programs.id', '=', $this->id) ->whereIn('courses.semester_id', $semesters_array) ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id') ->distinct() ->get(); // dd(DB::getQueryLog()); $conteo = 0; $attempted_criteria_per_program_array = []; // $students_attempted=0; // $students_achieved=0; foreach ($criteria as $criterion) { if (!isset($students_attempted[$criterion->id])) $students_attempted[$criterion->id] = 0; if (!isset($students_achieved[$criterion->id])) $students_achieved[$criterion->id] = 0; $attempted_criteria_per_program_array[$criterion->id] = 1; $students_attempted[$criterion->id] += Criterion::students_attempted($criterion->id, $criterion->activity_id); $students_achieved[$criterion->id] += Criterion::students_achieved($criterion->id, $criterion->activity_id); } // var_dump($outcome_id); // var_dump($this->id); // if(isset($students_attempted))var_dump($students_attempted); // else{print "aqui hay algo";} // print "
"; // if(isset($students_achieved))var_dump($students_achieved); // print "
"; // print "
"; // exit(); if (isset($students_attempted)) { foreach ($students_attempted as $criteria_id => $students_attempted_n) { if ($students_attempted_n) { $percentage_students_who_achieved = 100.0 * $students_achieved[$criteria_id] / $students_attempted[$criteria_id]; } else { $percentage_students_who_achieved = 0; } if ($percentage_students_who_achieved >= $criterion->expected_percentage) { $conteo++; } } } $attempted_criteria_per_program = count($attempted_criteria_per_program_array); $achievedProgramOutcome = 0; $outcome = Outcome::where('id', $outcome_id)->select('expected_outcome')->first(); // var_dump($outcome->expected_outcome); // exit(); if ($attempted_criteria_per_program != 0 && 100.0 * $conteo / $attempted_criteria_per_program >= $outcome->expected_outcome) { $achievedProgramOutcome = 1; // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome); } return $conteo; } //get linea outcome public function getExpectedOutcomeTargetAttribute() { // $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') ->where('program_id', $this->id) ->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)) { $linea_undergrad = null; } elseif ($linea_undergrad->count_semester_id > 1) { $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') ->where('program_id', $this->id) ->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(); } return $linea_undergrad; } public function achieved_outcome($outcome_id, $semesters) { $semesters_array = []; foreach ($semesters as $semester) { $semesters_array[] = $semester->id; } // DB::enableQueryLog(); // dd(DB::getQueryLog()); // $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','=',$outcome_id) // ->where('programs.id','=',$this->id) // ->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', '=', $outcome_id) ->where('programs.id', '=', $this->id) ->whereIn('courses.semester_id', $semesters_array) ->select('criteria.id', 'expected_percentage', 'activity_criterion.activity_id') ->distinct() ->get(); // dd(DB::getQueryLog()); $conteo = 0; $attempted_criteria_per_program_array = []; // $students_attempted=0; // $students_achieved=0; foreach ($criteria as $criterion) { if (!isset($students_attempted[$criterion->id])) $students_attempted[$criterion->id] = 0; if (!isset($students_achieved[$criterion->id])) $students_achieved[$criterion->id] = 0; $attempted_criteria_per_program_array[$criterion->id] = 1; $students_attempted[$criterion->id] += Criterion::students_attempted($criterion->id, $criterion->activity_id); $students_achieved[$criterion->id] += Criterion::students_achieved($criterion->id, $criterion->activity_id); } // var_dump($this->id); // if(isset($students_attempted))var_dump($students_attempted); // else{print "aqui hay algo";} // print "
"; // if(isset($students_achieved))var_dump($students_achieved); // print "
"; // print "
"; // exit(); if (isset($students_attempted)) { foreach ($students_attempted as $criteria_id => $students_attempted_n) { if ($students_attempted_n) { $percentage_students_who_achieved = 100.0 * $students_achieved[$criteria_id] / $students_attempted[$criteria_id]; } else { $percentage_students_who_achieved = 0; } if ($percentage_students_who_achieved >= $criterion->expected_percentage) { $conteo++; } } } $attempted_criteria_per_program = count($attempted_criteria_per_program_array); $achievedProgramOutcome = 0; $outcome = Outcome::where('id', $outcome_id)->select('expected_outcome')->first(); // var_dump($outcome->expected_outcome); // exit(); if ($attempted_criteria_per_program != 0 && 100.0 * $conteo / $attempted_criteria_per_program >= $outcome->expected_outcome) { $achievedProgramOutcome = 1; // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome); } return $achievedProgramOutcome; } public static function generalComponentPrograms() { return self::whereIn('id', array(123, 124, 125, 126, 127, 128, 129))->get(); } public function assessmentOverview() { $assessment_overview = array(); $assessment_overview['program_courses'] = $this->courses; $outcomeCount = Outcome::all()->count(); $assessment_overview['outcomes_achieved'] = array_fill(1, $outcomeCount, 0); $assessment_overview['outcomes_attempted'] = array_fill(1, $outcomeCount, 0); $assessment_overview['assessed_courses_count'] = 0; foreach ($assessment_overview['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($assessment_overview['outcomes_attempted']); $i++) { $assessment_overview['outcomes_achieved'][$i] += $course_outcomes_achieved[$i]; $assessment_overview['outcomes_attempted'][$i] += $course_outcomes_attempted[$i]; } $assessment_overview['assessed_courses_count'] += 1; } } /** * List of grouped courses (grouped sections) */ $assessment_overview['grouped_courses'] = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id')) ->with('semester') ->with('program') ->where('program_id', $this->id) ->whereIn('semester_id', Session::get('semesters_ids')) ->groupBy(array('code', 'number', 'semester_id')) ->orderBy('code') ->orderBy('number') ->orderBy('semester_id') ->get(); Log::info(Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id')) ->with('semester') ->with('program') ->where('program_id', $this->id) ->whereIn('semester_id', Session::get('semesters_ids')) ->groupBy(array('code', 'number', 'semester_id')) ->orderBy('code') ->orderBy('number') ->orderBy('semester_id') ->toSql()); return $assessment_overview; } }