protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $this->createContextInstance(); $c1 = new Criteria(); $career_school_year = CareerSchoolYearPeer::retrieveBySchoolYear(); $c1->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year[0]->getId()); $c1->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::LAST_YEAR_REPPROVED); $students_career_school_year = StudentCareerSchoolYearPeer::doSelectJoinCareerSchoolYear($c1); foreach ($students_career_school_year as $student_career_school_year) { $this->logSection('STUDENT CAREER SCHOOL YEAR ID', $student_career_school_year->getId()); $previous_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($student_career_school_year->getCareerSchoolYear()->getSchoolYear()); if (is_null($previous_school_year)) { $this->logSection('action', 'continue'); continue; } $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::STUDENT_ID, $student_career_school_year->getStudent()->getId()); $c->addJoin(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID, Criteria::INNER_JOIN); $c->addJoin(CareerSchoolYearPeer::CAREER_ID, CareerPeer::ID, Criteria::INNER_JOIN); $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $previous_school_year->getId()); $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED); if (StudentCareerSchoolYearPeer::doCount($c)) { $this->logSection('action', 'fix'); $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::IN_COURSE); $student_career_school_year->save(); } } }
public function getCourseSubjectStudentResult(CourseSubjectStudent $course_subject_student, PropelPDO $con = null) { $average = $course_subject_student->getMarksAverage($con); $sum_marks = 0; $year = $course_subject_student->getCourseSubject()->getCourse()->getYear(); foreach ($course_subject_student->getCourseSubjectStudentMarks() as $cssm) { $sum_marks += $cssm->getMark(); } if ($average >= $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration()->getCourseMinimunMark() && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks())->getMark() >= self::POSTPONED_NOTE || $year > 1 && $year < 5 && $sum_marks >= 21 && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks())->getMark() >= 4) { $school_year = $course_subject_student->getCourseSubject()->getCourse()->getSchoolYear(); $student_approved_course_subject = new StudentApprovedCourseSubject(); $student_approved_course_subject->setCourseSubject($course_subject_student->getCourseSubject()); $student_approved_course_subject->setStudent($course_subject_student->getStudent()); $student_approved_course_subject->setSchoolYear($school_year); $student_approved_course_subject->setMark($average); $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject); ###Liberando memoria #### $school_year->clearAllReferences(true); unset($school_year); SchoolYearPeer::clearInstancePool(); unset($average); unset($sum_marks); ########################## //$student_approved_course_subject->save(); return $student_approved_course_subject; } else { $school_year = $course_subject_student->getCourseSubject()->getCourse()->getSchoolYear(); $career_school_year = CareerSchoolYearPeer::retrieveBySchoolYear(null, $school_year); if ($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption() && $year == 6) { $student_disapproved_course_subject = new StudentDisapprovedCourseSubject(); $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); $student_disapproved_course_subject->setCourseSubjectStudent($course_subject_student); unset($average); unset($sum_marks); return $student_disapproved_course_subject; } else { $student_disapproved_course_subject = new StudentDisapprovedCourseSubject(); $student_disapproved_course_subject->setCourseSubjectStudent($course_subject_student); // si un alumno es de primer año, no puede ir a febrero siempre va a diciembre. if ($year == 1) { $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); } elseif ($year > 1 && $year < 5 && $course_subject_student->countCourseSubjectStudentMarks() == 3) { //Suma menor a 21 pero mayor o igual que 12: mesa de diciembre (examen regular) if ($sum_marks < 21 && $sum_marks >= 12) { $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); } elseif ($sum_marks >= 21 && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks())->getMark() < 4) { $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); } elseif ($sum_marks < 12) { $student_disapproved_course_subject->setExaminationNumber(self::FEBRUARY); } } else { $student_disapproved_course_subject->setExaminationNumber($this->getExaminationNumberFor($average)); } unset($average); unset($sum_marks); //$student_disapproved_course_subject->save(); return $student_disapproved_course_subject; } } }
private function generateStructureReports($params) { if ($params['career_school_year_id'] != "") { $career_school_years = array(CareerSchoolYearPeer::retrieveByPK($params['career_school_year_id'])); } else { $career_school_years = CareerSchoolYearPeer::retrieveBySchoolYear(); } $this->shift = isset($params['shift_id']) ? $params['shift_id'] : ""; $this->division = isset($params['division_id']) ? $params['division_id'] : ""; $this->year = isset($params['year']) ? $params['year'] : ""; $this->stats_table = array(); $this->school_year = $career_school_years[0]->getSchoolYear(); if (count($career_school_years) == 1) { $this->career_school_year = $career_school_years[0]; } $this->stats_table['structure_reports'] = $this->generateGeneralReports($career_school_years); $this->stats_table['shift_reports'] = $this->generateShiftReports($career_school_years, $this->shift); $this->stats_table['shift_division_reports'] = $this->generateShiftDivisionReports($career_school_years, $this->shift, $this->division); $this->stats_table['year_reports'] = $this->generateYearReports($career_school_years, $this->year); $this->stats_table['year_shift_reports'] = $this->generateYearShiftReports($career_school_years, $this->year, $this->shift); $this->stats_table['year_shift_division_reports'] = $this->generateYearShiftDivisionReports($career_school_years, $this->year, $this->shift, $this->division); }
public function getCareerFromStudentStatsFilters() { $user = sfContext::getInstance()->getUser(); $filters = $user->getAttribute('student_stats.filters', null, 'admin_module'); if (!isset($filters['career_school_year']) || is_null($filters['career_school_year'])) { $school_year = SchoolYearPeer::retrieveByPK($filters['school_year']); $result = implode(', ', CareerSchoolYearPeer::retrieveBySchoolYear(null, $school_year)); } else { $result = CareerSchoolYearPeer::retrieveByPK($filters['career_school_year']); } return $result; }