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 static function retrieveByCourseSubjectStudent(CourseSubjectStudent $course_subject_student, $school_year = null)
 {
     $c = new Criteria();
     $c->add(self::CAREER_SUBJECT_ID, $course_subject_student->getCourseSubject()->getCareerSubject()->getId());
     $c->add(self::STUDENT_ID, $course_subject_student->getStudentId());
     if ($school_year) {
         $c->add(self::SCHOOL_YEAR_ID, $school_year->getId());
     }
     return self::doSelectOne($c);
 }
 /**
  * This method returns the marks average of a student in a course_subject_student given.
  *
  * @param CourseSubjectStudent $course_subject_student
  * @return <type>
  */
 public function getMarksAverage($course_subject_student, PropelPDO $con = null)
 {
     if (!is_null($course_subject_student->getStudentApprovedCourseSubject())) {
         $average = $course_subject_student->getStudentApprovedCourseSubject()->getMark();
     } else {
         $sum = 0;
         foreach ($course_subject_student->getCourseSubjectStudentMarks() as $cssm) {
             $sum += $cssm->getMark();
         }
         $average = (string) ($sum / $course_subject_student->countCourseSubjectStudentMarks(null, false, $con));
     }
     $average = sprintf('%.4s', $average);
     return $average;
 }
 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);
 }
 protected function doSave($con = null)
 {
     $con = is_null($con) ? $this->getConnection() : $con;
     $course = $this->getObject();
     $from_course = CoursePeer::retrieveByPK($this->values['course_id']);
     try {
         $con->beginTransaction();
         foreach ($from_course->getStudents() as $student) {
             foreach ($course->getCourseSubjects() as $course_subject) {
                 $course_subject_student = new CourseSubjectStudent();
                 $course_subject_student->setCourseSubjectId($course_subject->getId());
                 $course_subject_student->setStudentId($student->getId());
                 $course_subject_student->save($con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         throw $e;
         $con->rollBack();
     }
 }
 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 createCourseSubject($course, PropelPDO $con = null)
 {
     if ($this->hasChoices()) {
         foreach ($this->getChoices() as $choice) {
             $course_subject = new CourseSubject();
             $course_subject->setCourse($course);
             $course_subject->setCareerSubjectSchoolYear($choice->getCareerSubjectSchoolYearRelatedByChoiceCareerSubjectSchoolYearId());
             $course_subject->save($con);
         }
     } else {
         $course_subject = new CourseSubject();
         $course_subject->setCourse($course);
         $course_subject->setCareerSubjectSchoolYear($this);
         $course_subject->save($con);
         if ($course->getDivision()) {
             foreach ($course->getDivision()->getDivisionStudents() as $ds) {
                 $course_subject_student = new CourseSubjectStudent();
                 $course_subject_student->setCourseSubject($course_subject);
                 $course_subject_student->setStudent($ds->getStudent());
                 $course_subject_student->save($con);
             }
         }
     }
 }
 public function saveCourseSubjectStudentList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['course_subject_student_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     $this->values = $this->getValue('course_subject_student_list');
     foreach ($this->getObject()->getCourseSubjectStudents() as $course_subject_student) {
         //if student has marks it can't be deleted from course
         if (!in_array($course_subject_student->getStudentId(), $this->values)) {
             if ($this->canDeleteCourseSubjectStudent($course_subject_student->getStudentId()) && $course_subject_student->countValidCourseSubjectStudentMarks() == 0) {
                 $course_subject_student->delete($con);
             } else {
                 throw new Exception('El/Los alumno/s seleccionado/s poseen calificaciones cargadas que le/s impide/n ser borrado/s de este curso.');
             }
         }
     }
     $already_ids = array_map(create_function('$c', 'return $c->getStudentId();'), $this->getObject()->getCourseSubjectStudents());
     $this->filterValues($already_ids);
     if (is_array($this->values)) {
         $con->beginTransaction();
         try {
             foreach ($this->values as $value) {
                 $course_subject_student = new CourseSubjectStudent();
                 $course_subject_student->setCourseSubject($this->getObject());
                 $course_subject_student->setStudentId($value);
                 $course_subject_student->save($con);
             }
             $con->commit();
         } catch (Exception $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }
 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;
         }
     }
 }
示例#10
0
 public function createFor($student, PropelPDO $con = null)
 {
     $course_student = new CourseSubjectStudent();
     $course_student->setCourseSubject($this);
     $course_student->setStudent($student);
     $course_student->save($con);
     $course_student->clearAllReferences();
     unset($course_student);
 }
 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;
 }
 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();
 }