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 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; } }