/**
  * Check if a student has approved all career_subjects of the career, then graduates the student.
  *
  * @param StudentApprovedCareerSubject $student_approved_career_subject
  * @param PropelPDO $con
  */
 public function graduateStudent(StudentApprovedCareerSubject $student_approved_career_subject, PropelPDO $con = null)
 {
     //habria que chequear que este en el ultimo año del plan, que tenga todas aprobadas las materias del ultimo año y que no tenga previas.
     $student = $student_approved_career_subject->getStudent();
     $career = $student_approved_career_subject->getCareerSubject()->getCareer();
     $school_year = $student_approved_career_subject->getSchoolYear();
     $last_year_subjects = $career->getMaxYearSubject();
     //$approved_career_subjects = StudentApprovedCareerSubjectPeer::getByStudentAndSchoolYear($student, $school_year);
     return;
 }
 public static function retrieveApprovationDate(StudentApprovedCareerSubject $studentApprovedCareerSubject)
 {
     $approvationInstance = $studentApprovedCareerSubject->getApprovationInstance();
     switch (get_class($approvationInstance)) {
         case 'StudentApprovedCourseSubject':
             $period = $approvationInstance->getCourseSubject()->getLastCareerSchoolYearPeriod();
             if (!is_null($period)) {
                 return $period->getEndAt();
             }
             break;
         case 'StudentDisapprovedCourseSubject':
             $cssid = $approvationInstance->getCourseSubjectStudentId();
             $csse = CourseSubjectStudentExaminationPeer::retrieveLastByCourseSubjectStudentId($cssid);
             $exam = $csse->getExaminationSubject()->getExamination();
             return $exam->getDateFrom();
         case 'StudentRepprovedCourseSubject':
             $sers = StudentExaminationRepprovedSubjectPeer::retrieveByStudentRepprovedCourseSubject($approvationInstance);
             $exam = $sers->getExaminationRepprovedSubject()->getExaminationRepproved();
             return $exam->getDateFrom();
     }
     //couldn't find when was approved. return null ¿error?
     return;
 }
 public function closeStudentExaminationRepprovedSubject(StudentExaminationRepprovedSubject $student_examination_repproved_subject, PropelPDO $con)
 {
     if ($student_examination_repproved_subject->getMark() >= $this->getExaminationNote()) {
         $student_approved_career_subject = new StudentApprovedCareerSubject();
         $student_approved_career_subject->setCareerSubject($student_examination_repproved_subject->getExaminationRepprovedSubject()->getCareerSubject());
         $student_approved_career_subject->setStudent($student_examination_repproved_subject->getStudent());
         $student_approved_career_subject->setSchoolYear($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getSchoolYear());
         if ($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getExaminationType() == ExaminationRepprovedType::REPPROVED) {
             //Final average is the average of the course_subject_student and the mark of student_examination_repproved_subject
             $average = (string) (($student_examination_repproved_subject->getStudentRepprovedCourseSubject()->getCourseSubjectStudent()->getMarksAverage() + $student_examination_repproved_subject->getMark()) / 2);
             $average = sprintf('%.4s', $average);
             if ($average < self::MIN_NOTE) {
                 $average = self::MIN_NOTE;
             }
             $student_approved_career_subject->setMark($average);
         } else {
             //Final calification is the mark of student_examination_repproved_subject
             $student_approved_career_subject->setMark($student_examination_repproved_subject->getMark());
         }
         $student_repproved_course_subject = $student_examination_repproved_subject->getStudentRepprovedCourseSubject();
         $student_repproved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
         $student_repproved_course_subject->save($con);
         $career = $student_repproved_course_subject->getCourseSubjectStudent()->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getCareer();
         ##se corrobora si la previa es la última y del último año, hay que egresarlo
         $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student_repproved_course_subject->getStudent(), $career);
         if ($student_repproved_course_subject->getStudent()->getCurrentOrLastStudentCareerSchoolYear()->getYear() >= CareerPeer::getMaxYear() && $previous == 0) {
             $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career->getId(), $student_repproved_course_subject->getStudent()->getId());
             $career_student->setStatus(CareerStudentStatus::GRADUATE);
             //se guarda el school_year en que termino esta carrera
             $career_student->setGraduationSchoolYearId(SchoolYearPeer::retrieveCurrent()->getId());
             $career_student->save($con);
             //se guarda el estado en el student_career_school_year
             $scsy = $student_repproved_course_subject->getCourseSubjectStudent()->getStudent()->getCurrentOrLastStudentCareerSchoolYear();
             $scsy->setStatus(StudentCareerSchoolYearStatus::APPROVED);
             $scsy->save();
         }
         ##se agrega el campo en student_disapproved_course_subject a el link del resultado final
         $student_repproved_course_subject->getCourseSubjectStudent()->getCourseResult()->setStudentApprovedCareerSubject($student_approved_career_subject)->save($con);
         $student_approved_career_subject->save($con);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $this->createContextInstance('backend');
     $criteria = new Criteria();
     $criteria->add(CoursePeer::IS_CLOSED, false);
     $criteria->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID, Criteria::INNER_JOIN);
     $criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID, Criteria::INNER_JOIN);
     $course_subject_students = CourseSubjectStudentPeer::doSelect($criteria);
     $this->log('Cant. Course Subject Students a procesar:');
     $this->log(count($course_subject_students));
     foreach ($course_subject_students as $course_subject_student) {
         $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId());
         $this->log('Id del course subject student Actual:');
         $this->log($course_subject_student->getId());
         foreach ($course_subject_student_marks as $mark) {
             $mark->setIsClosed(true);
             $mark->save($con);
         }
         $student_approved_course_subject = new StudentApprovedCourseSubject();
         $student_approved_course_subject->setCourseSubject($course_subject_student->getCourseSubject());
         $student_approved_course_subject->setStudentId($course_subject_student->getStudentId());
         $student_approved_course_subject->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
         $student_approved_career_subject = new StudentApprovedCareerSubject();
         $student_approved_career_subject->setStudentId($course_subject_student->getStudentId());
         $student_approved_career_subject->setCareerSubject($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject());
         $student_approved_career_subject->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
         $student_approved_career_subject->save($con);
         $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
         $student_approved_course_subject->save($con);
         $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject);
         $course_subject_student->save($con);
     }
     $criteria = new Criteria();
     $criteria->add(CoursePeer::IS_CLOSED, false);
     $courses = CoursePeer::doSelect($criteria);
     foreach ($courses as $c) {
         $c->setIsClosed(true);
         $c->save($con);
     }
 }
 /**
  * If the student approves the previous, then it creates a student_approved_career_subject for this student
  *
  * @param StudentExaminationRepprovedSubject $student_examination_repproved_subject
  * @param PropelPDO $con
  */
 public function closeStudentExaminationRepprovedSubject(StudentExaminationRepprovedSubject $student_examination_repproved_subject, PropelPDO $con)
 {
     if ($student_examination_repproved_subject->getMark() >= self::EXAMINATION_NOTE) {
         $student_approved_career_subject = new StudentApprovedCareerSubject();
         $student_approved_career_subject->setCareerSubject($student_examination_repproved_subject->getExaminationRepprovedSubject()->getCareerSubject());
         $student_approved_career_subject->setStudent($student_examination_repproved_subject->getStudent());
         $student_approved_career_subject->setSchoolYear($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getSchoolYear());
         //Final average is directly student_examination_repproved_subject mark
         $mark = (string) $student_examination_repproved_subject->getMark();
         $mark = sprintf('%.4s', $mark);
         if ($mark < self::MIN_NOTE) {
             $mark = self::MIN_NOTE;
         }
         $student_approved_career_subject->setMark($mark);
         $student_repproved_course_subject = $student_examination_repproved_subject->getStudentRepprovedCourseSubject();
         $student_repproved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
         $student_repproved_course_subject->save($con);
         $student_repproved_course_subject->getCourseSubjectStudent()->getCourseResult()->setStudentApprovedCareerSubject($student_approved_career_subject)->save($con);
         $student_approved_career_subject->save($con);
     }
 }
 protected function doSave($con = null)
 {
     $values = $this->getValues();
     $course_subject = CourseSubjectPeer::retrieveByPk($values['course_subject_id']);
     $course = $course_subject->getCourse();
     $con = is_null($con) ? $this->getConnection() : $con;
     try {
         $con->beginTransaction();
         if ($values['set_all_course_subject_non_numerical_califications'] == 1) {
             //tomo todos los alumnos que No tienen seteado el flag is_not_averageable
             $course_subject_students = $course->getIsAverageableCourseSubjectStudent();
             foreach ($course_subject_students as $course_subject_student) {
                 $course_subject_student->setIsNotAverageable(true);
                 $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId());
                 foreach ($course_subject_student_marks as $mark) {
                     $mark->setIsClosed(true);
                     $mark->save($con);
                 }
                 $student_id = $course_subject_student->getStudentId();
                 $student_approved_course_subject = new StudentApprovedCourseSubject();
                 $student_approved_course_subject->setCourseSubject($course_subject);
                 $student_approved_course_subject->setStudentId($student_id);
                 $student_approved_course_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject = new StudentApprovedCareerSubject();
                 $student_approved_career_subject->setStudentId($student_id);
                 $student_approved_career_subject->setCareerSubject($course_subject->getCareerSubjectSchoolYear()->getCareerSubject());
                 $student_approved_career_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject->save($con);
                 $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
                 $student_approved_course_subject->save($con);
                 $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject);
                 $course_subject_student->save($con);
             }
         } else {
             foreach ($values['student_list'] as $student_id) {
                 $course_subject_student = CourseSubjectStudentPeer::retrievebyCourseSubjectAndStudent($course_subject->getid(), $student_id);
                 $course_subject_student->setIsNotAverageable(true);
                 $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId());
                 foreach ($course_subject_student_marks as $mark) {
                     $mark->setIsClosed(true);
                     $mark->save($con);
                 }
                 $student_approved_course_subject = new StudentApprovedCourseSubject();
                 $student_approved_course_subject->setCourseSubject($course_subject);
                 $student_approved_course_subject->setStudentId($student_id);
                 $student_approved_course_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject = new StudentApprovedCareerSubject();
                 $student_approved_career_subject->setStudentId($student_id);
                 $student_approved_career_subject->setCareerSubject($course_subject->getCareerSubjectSchoolYear()->getCareerSubject());
                 $student_approved_career_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear());
                 $student_approved_career_subject->save($con);
                 $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
                 $student_approved_course_subject->save($con);
                 $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject);
                 $course_subject_student->save($con);
             }
         }
         //chequeo si la cantidad de alumnos eximidos es igual a la cantidad de alumnos inscriptos en el curso y el curso esta abierto .
         if (count($course->getIsNotAverageableCourseSubjectStudent()) == $course->countStudents() && !$course->getIsClosed()) {
             //cierro el curso.
             $course->setIsClosed(true);
             $course->save($con);
         }
         $con->commit();
     } catch (Exception $e) {
         throw $e;
         $con->rollBack();
     }
 }
 public function closeCourseSubjectStudentExamination(CourseSubjectStudentExamination $course_subject_student_examination, PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $course_subject_student = $course_subject_student_examination->getCourseSubjectStudent();
     // si aprueba la mesa de examen
     if ($course_subject_student_examination->getMark() >= $this->getExaminationNote()) {
         $result = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student, $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear());
         if (is_null($result)) {
             $result = new StudentApprovedCareerSubject();
             $result->setCareerSubject($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject());
             $result->setStudent($course_subject_student->getStudent());
             $result->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear());
         }
         $examination_subject = $course_subject_student_examination->getExaminationSubject();
         // IF is null, is because the course_subject_student_examination has been created editing student history
         $school_year = is_null($examination_subject) ? $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear() : $examination_subject->getExamination()->getSchoolYear();
         $result->setSchoolYearId($school_year->getId());
         $average = $this->getAverage($course_subject_student, $course_subject_student_examination);
         $average = sprintf('%.4s', $average);
         if ($average < 4) {
             $average = 4;
         }
         // se guarda la NOTA FINAL de la materia
         if ($course_subject_student_examination->getExaminationNumber() == self::FEBRUARY) {
             $this->setFebruaryApprovedResult($result, $average, $course_subject_student_examination->getMark());
         } else {
             $result->setMark($average);
         }
         ##se agrega en la tupla student_disapproved_course_subject el link a al resultado final
         $course_subject_student->getCourseResult()->setStudentApprovedCareerSubject($result)->save($con);
         $result->save($con);
         // verifica si hay creada una tupla de previa de esta materia que no corresponde porque el alumno aprobo en mesas regulares.
         // Si la encuentra la borra ya que no corresponde que exista
         $srcs = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student);
         if ($srcs && is_null($srcs->getStudentApprovedCareerSubject())) {
             $srcs->delete($con);
         }
     } else {
         // TODO: arreglar esto: pedir a la configuración
         // Pasa de diciembre a febrero (se copia el course_subject_student_examination con examination_number + 1)
         if ($course_subject_student_examination->getExaminationNumber() < count($this->_examination_number)) {
             $this->nextCourseSubjectStudentExamination($course_subject_student_examination, $con);
         } else {
             // se crea una previa
             $srcs = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student);
             if (!$srcs && is_null($srcs->getStudentApprovedCareerSubject())) {
                 $student_repproved_course_subject = new StudentRepprovedCourseSubject();
                 $student_repproved_course_subject->setCourseSubjectStudentId($course_subject_student->getId());
                 $student_repproved_course_subject->save($con);
             }
         }
     }
 }
 public function closeCourseSubjectStudent($result, PropelPDO $con = null, $course_subject_student)
 {
     if ($result instanceof StudentApprovedCourseSubject) {
         $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student);
         if (is_null($student_approved_career_subject)) {
             $student_approved_career_subject = new StudentApprovedCareerSubject();
             $student_approved_career_subject->setCareerSubject($result->getCourseSubject($con)->getCareerSubject($con));
             $student_approved_career_subject->setStudent($result->getStudent($con));
             $student_approved_career_subject->setSchoolYear($result->getSchoolYear($con));
             $student_approved_career_subject->setMark($result->getMark());
             $result->setStudentApprovedCareerSubject($student_approved_career_subject);
             /* para el caso de que se aprueba por mesa de examen, se debe asociar el student_approved_career_subject
              * con el student_disapproved_course_subject
              */
             $disapproved = StudentDisapprovedCourseSubjectPeer::retrieveByStudentApprovedCourseSubject($result, $con);
             if (!is_null($disapproved)) {
                 $disapproved->setStudentApprovedCareerSubject($student_approved_career_subject);
                 $disapproved->save($con);
             }
             $student_approved_career_subject->save($con);
             $result->save($con);
         }
     } else {
         $this->createCourseSubjectStudentExamination($result->getCourseSubjectStudent(null, $con), $con);
     }
 }
 public function setFebruaryApprovedResult(StudentApprovedCareerSubject $result, $average, $examination_mark)
 {
     $result->setMark($average);
 }
Example #10
0
 public function pathwayClose(PropelPDO $con)
 {
     foreach ($this->getCourseSubjectStudentPathways() as $course_subject_student_pathway) {
         $evaluator_instance = SchoolBehaviourFactory::getEvaluatorInstance();
         if ($course_subject_student_pathway->getMark() >= $evaluator_instance->getPathwayPromotionNote()) {
             $original_course_subject_student = $course_subject_student_pathway->getRelatedCourseSubjectStudent();
             //$final_mark = $course_subject_student_pathway->getMark();
             $course_marks_avg = SchoolBehaviourFactory::getEvaluatorInstance()->getMarksAverage($original_course_subject_student, $con);
             $final_mark = bcdiv($course_subject_student_pathway->getMark() + $course_marks_avg, 2, 2);
             $sacs = new StudentApprovedCareerSubject();
             $sacs->setCareerSubject($this->getCareerSubjectSchoolYear()->getCareerSubject());
             $sacs->setMark($final_mark);
             $sacs->setStudent($course_subject_student_pathway->getStudent());
             $sacs->setSchoolYear($this->getCourse()->getSchoolYear());
             $original_course_subject_student->getCourseResult()->setStudentApprovedCareerSubject($sacs);
             $original_course_subject_student->save($con);
             $srcs = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($original_course_subject_student);
             if (is_null($srcs)) {
                 $srcs = new StudentRepprovedCourseSubject();
                 $srcs->setCourseSubjectStudent($original_course_subject_student);
             }
             $srcs->setStudentApprovedCareerSubject($sacs);
             $srcs->save($con);
             $sers = StudentExaminationRepprovedSubjectPeer::retrieveByStudentRepprovedCourseSubject($srcs);
             // TODO: pongo en blanco la referencia a una mesa de previa??
             if (is_null($sers)) {
                 $sers = new StudentExaminationRepprovedSubject();
                 $sers->setStudentRepprovedCourseSubject($srcs);
             }
             $sers->setMark($course_subject_student_pathway->getMark());
             $sers->setExaminationRepprovedSubject(null);
             $sers->save($con);
         }
     }
 }