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;
         }
     }
 }
 public function isApproved(CourseSubjectStudent $course_subject_student, $average, PropelPDO $con = null)
 {
     $sum = 0;
     foreach ($course_subject_student->getCourseSubjectStudentMarks(null, $con) as $cssm) {
         $sum += $cssm->getMark();
     }
     $first_integrator_mark = $course_subject_student->getMarkFor(self::FIRST_INTEGRATOR_MARK, $con);
     $last_integrator_mark = $course_subject_student->getMarkFor(self::LAST_INTEGRATOR_MARK, $con);
     return $sum > 26 && isset($first_integrator_mark) && $first_integrator_mark->getMark() >= $course_subject_student->getCourseMinimunMarkForCurrentSchoolYear($con) && isset($last_integrator_mark) && $course_subject_student->getMarkFor(self::LAST_INTEGRATOR_MARK, $con)->getMark() >= $course_subject_student->getCourseMinimunMarkForCurrentSchoolYear($con);
 }
 public function getCourseSubjectStudentResult(CourseSubjectStudent $course_subject_student, PropelPDO $con = null)
 {
     $average = $course_subject_student->getMarksAverage($con);
     if ($average >= $course_subject_student->getCourseSubject($con)->getCareerSubjectSchoolYear($con)->getConfiguration($con)->getCourseMinimunMark() && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks(null, false, $con), $con)->getMark() >= self::POSTPONED_NOTE) {
         $school_year = $course_subject_student->getCourseSubject($con)->getCourse($con)->getSchoolYear($con);
         $student_approved_course_subject = new StudentApprovedCourseSubject();
         $student_approved_course_subject->setCourseSubject($course_subject_student->getCourseSubject($con));
         $student_approved_course_subject->setStudent($course_subject_student->getStudent($con));
         $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);
         ##########################
         return $student_approved_course_subject;
     } else {
         $student_disapproved_course_subject = new StudentDisapprovedCourseSubject();
         $student_disapproved_course_subject->setCourseSubjectStudent($course_subject_student);
         if ($course_subject_student->hasSomeMarkFree()) {
             if (is_null(StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student))) {
                 $srcs = new StudentRepprovedCourseSubject();
                 $srcs->setCourseSubjectStudent($course_subject_student);
                 $srcs->save();
             }
         }
         $examination_number = $this->getExaminationNumberFor($average, $course_subject_student->hasSomeMarkFree());
         $student_disapproved_course_subject->setExaminationNumber($examination_number);
         unset($average);
         return $student_disapproved_course_subject;
     }
 }
 public function isApproved(CourseSubjectStudent $course_subject_student, $average, PropelPDO $con = null)
 {
     if (CourseType::BIMESTER == $course_subject_student->getCourseSubject()->getCourseType() && $course_subject_student->getCourseSubject()->getYear() > 4 && $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption()) {
         $last_mark_value = self::BIMESTER_POSTPONED_NOTE;
     } else {
         $last_mark_value = self::POSTPONED_NOTE;
     }
     $correct_last_note = $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks(null, false, $con), $con)->getMark() >= $last_mark_value;
     $minimum_mark = $course_subject_student->getCourseSubject($con)->getCareerSubjectSchoolYear($con)->getConfiguration($con)->getCourseMinimunMark();
     return $average >= $minimum_mark && $correct_last_note;
 }
 public function isApproved(CourseSubjectStudent $course_subject_student, $average, PropelPDO $con = null)
 {
     $minimum_mark = $course_subject_student->getCourseSubject($con)->getCareerSubjectSchoolYear($con)->getConfiguration($con)->getCourseMinimunMark();
     return $average >= $minimum_mark && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks(null, false, $con), $con)->getMark() > $this->getPosponedNote();
 }
 public function isApproved(CourseSubjectStudent $course_subject_student, $average, PropelPDO $con = null)
 {
     $minimum_mark = $course_subject_student->getCourseSubject($con)->getCareerSubjectSchoolYear($con)->getConfiguration($con)->getCourseMinimunMark();
     return $average >= $minimum_mark && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks(null, false, $con), $con)->getMark() > self::POSTPONED_NOTE && $course_subject_student->hasNotAbsense();
 }