public static function retrieveByStudentId($student_id)
 {
     $c = new Criteria();
     $student = StudentPeer::retrieveByPK($student_id);
     $scsy = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, SchoolYearPeer::retrieveCurrent());
     $c->add(self::STUDENT_CAREER_SCHOOL_YEAR_ID, $scsy[0]->getId());
     $c->add(self::IS_DELETED, true, Criteria::EQUAL);
     return self::doSelectOne($c);
 }
 /**
  * Adds the reference for the ExaminationRepprovedSubject to StudentExaminationRepprovedSubjects.
  * If student is withdrawn then it does not add the reference.
  *
  * @param ExaminationRepprovedSubject $examination_repproved_subject
  * @param PropelPDO $con
  */
 public function updateStudentExaminationRepprovedSubjects($examination_repproved_subject, PropelPDO $con)
 {
     if ($examination_repproved_subject->isNew()) {
         $student_repproved_course_subjects = SchoolBehaviourFactory::getInstance()->getAvailableStudentsForExaminationRepprovedSubject($examination_repproved_subject);
         foreach ($student_repproved_course_subjects as $student_repproved_course_subject) {
             $student = $student_repproved_course_subject->getCourseSubjectStudent()->getStudent();
             $scsys = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, SchoolYearPeer::retrieveCurrent());
             if (!empty($scsys) && $scsys[0]->getStatus() != StudentCareerSchoolYearStatus::WITHDRAWN) {
                 $student_examination_repproved_subject = new StudentExaminationRepprovedSubject();
                 $student_examination_repproved_subject->setStudentRepprovedCourseSubjectId($student_repproved_course_subject->getId());
                 $examination_repproved_subject->addStudentExaminationRepprovedSubject($student_examination_repproved_subject);
             }
         }
     }
 }
 public function verify($student, $new_career_school_year_2014, $connection)
 {
     //este metodo verifica si se creo mas de una tupla studentcareerschoolyear para el alumno en este
     //año lectivo, borra la que no es de la career que se recibio como parametro. Es un método parche que
     //hice porque se disparaban los hooks y quedaban inscriptos 2 veces si no.
     $scsys = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, $new_career_school_year_2014->getSchoolYear());
     foreach ($scsys as $scsy) {
         if ($scsy->getCareerSchoolYear()->getCareerId() != $new_career_school_year_2014->getCareerId()) {
             $scsy->delete($connection);
         }
     }
 }
 protected function doSave($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     // Delete only the subjects off the selected career
     $c = new Criteria();
     $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $this->object->getPrimaryKey());
     // added:
     $subc = new Criteria();
     $subc->clearSelectColumns();
     $subc->addSelectColumn(CareerSubjectPeer::ID);
     $subc->add(CareerSubjectPeer::CAREER_ID, $this->getValue("career_id"));
     $stmt = CareerSubjectPeer::doSelectStmt($subc);
     $ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
     $c->add(StudentCareerSubjectAllowedPeer::CAREER_SUBJECT_ID, $ids, Criteria::IN);
     $allowed = StudentCareerSubjectAllowedPeer::doSelectOne($c, $con);
     if ($allowed) {
         // Se consulta si el alumno esta en trayectorias antes de eliminarlo
         $student_id = $this->object->getPrimaryKey();
         $criteria = new Criteria();
         $criteria->add(PathwayStudentPeer::STUDENT_ID, $student_id);
         $pathway = PathwayStudentPeer::doSelectOne($criteria, $con);
         if (!$pathway) {
             StudentCareerSubjectAllowedPeer::doDelete($c, $con);
         }
     }
     $year = $this->getValue('year');
     $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK($this->getValue('career_id')), SchoolYearPeer::retrieveCurrent());
     //First update the year at student_career_school_year
     //    var_dump($career_school_year);die();
     $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($this->getObject(), $career_school_year);
     //    if (!$student_career_school_year)
     //    {
     //      $student_career_school_year = new StudentCareerSchoolYear();
     //      $student_career_school_year->setCareerSchoolYear($career_school_year);
     //      $student_career_school_year->setStudent($this->getObject());
     //      $student_career_school_year->save();
     //    }
     $career_student = CareerStudentPeer::retrieveByCareerAndStudent($this->getValue('career_id'), $this->getObject()->getId());
     try {
         $con->beginTransaction();
         $student_career_school_year->setYear($year);
         $student_career_school_year->save($con);
         $c = new Criteria();
         $c->add(CareerSubjectPeer::CAREER_ID, $this->getValue('career_id'));
         $c->add(CareerSubjectPeer::YEAR, $year);
         foreach (CareerSubjectPeer::doSelect($c) as $career_subject) {
             $obj = new StudentCareerSubjectAllowed();
             $obj->setStudentId($this->object->getPrimaryKey());
             $obj->setCareerSubject($career_subject);
             $obj->save($con);
         }
         $prev_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($career_school_year->getSchoolYear());
         if ($prev_school_year) {
             $prev_student_career_school_year = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($this->getObject(), $prev_school_year);
         }
         if (!empty($prev_student_career_school_year)) {
             $prev_student_career_school_year = array_shift($prev_student_career_school_year);
             if ($year <= $prev_student_career_school_year->getYear()) {
                 $prev_student_career_school_year->setStatus(StudentCareerSchoolYearStatus::REPPROVED);
                 $prev_student_career_school_year->save($con);
             }
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
 public function stepToNextYear(Student $student, SchoolYear $school_year, PropelPDO $con = null)
 {
     $student_career_school_years = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, $school_year);
     foreach ($student_career_school_years as $student_career_school_year) {
         $career_school_year = $student_career_school_year->getCareerSchoolYear();
         if ($this->checkRepeationCondition($student, $student_career_school_year)) {
             $this->saveTentativeRepprovedStudent($student_career_school_year);
         } else {
             $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career_school_year->getCareerId(), $student->getId());
             // solo se chequea si existe esto, por que cuando viene desde una mesa de previa no tiene por que existir el student_career_school_year
             $next_year = $student_career_school_year->getYear() + 1;
             $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student, $student_career_school_year->getCareerSchoolYear()->getCareer());
             if ($next_year > $career_student->getCareer()->getMaxYear()) {
                 //EGRESADO
                 if ($previous == 0) {
                     $career_student->setStatus(CareerStudentStatus::GRADUATE);
                     //se guarda el school_year en que termino esta carrera
                     $career_student->setGraduationSchoolYearId($school_year->getId());
                     $career_student->save($con);
                     $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::APPROVED);
                     $student_career_school_year->save($con);
                 } else {
                     //LIBRE
                     $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::FREE);
                     $student_career_school_year->save($con);
                 }
             } elseif ($student_career_school_year->getStatus() != StudentCareerSchoolYearStatus::APPROVED) {
                 // Elimina los Allowed y Allowed Pathway del alumno.
                 $student->deleteAllCareerSubjectAlloweds($con);
                 $student->deleteAllCareerSubjectAllowedPathways($con);
                 //Se agregan las materias que puede cursar el alumno.
                 $career_student->createStudentsCareerSubjectAlloweds($next_year, $con);
                 // y decimos que aprobó
                 $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::APPROVED);
                 $student_career_school_year->save($con);
             }
         }
     }
     return true;
 }
Ejemplo n.º 6
0
 public function getCourseSubjectStudentsForBimesterSecondQuaterly($student_career_school_year = null)
 {
     if (is_null($student_career_school_year)) {
         $career_school_years = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($this, SchoolYearPeer::retrieveCurrent());
         $student_career_school_year = array_shift($career_school_years);
     }
     $career_school_year = $student_career_school_year->getCareerSchoolYear();
     $second_quaterly = CareerSchoolYearPeriodPeer::retrieveSecondQuaterlyForCareerSchoolYear($career_school_year);
     return $this->getCourseSubjectStudentsForBimesterQuaterly($second_quaterly, $student_career_school_year);
 }