/**
  * This method check the conditions of repetition of a year.
  *
  * @param Student $student
  * @param StudentCareerSchoolYear $student_career_school_year
  * @return boolean
  */
 public function checkRepeationCondition(Student $student, StudentCareerSchoolYear $student_career_school_year)
 {
     //IF the current year is the last year of the career, the students not repeat. OR if the year  = 1
     if ($student_career_school_year->isLastYear() || $student_career_school_year->getYear() == 1) {
         return false;
     }
     return parent::checkRepeationCondition($student, $student_career_school_year);
 }
예제 #2
0
 public static function retrieveByStudentCareerSchoolYear(StudentCareerSchoolYear $student_career_school_year)
 {
     $c = new Criteria();
     $c->add(self::CAREER_SCHOOL_YEAR_ID, $student_career_school_year->getCareerSchoolYearId());
     $c->addJoin(DivisionStudentPeer::DIVISION_ID, self::ID);
     $c->add(DivisionStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
     return self::doSelectOne($c);
 }
예제 #3
0
 /**
  * This method retrieves one Student free if exists, filtering by parameters
  *
  * @param Student $student
  * @param CareerSchoolYearPeriod $career_school_year_period
  * @param type $course_subject
  *
  * return StudentFree
  */
 public static function retrieveByStudentCareerSchoolYearCareerSchoolYearPeriodAndCourse(StudentCareerSchoolYear $student_career_school_year, CareerSchoolYearPeriod $career_school_year_period = null, $course_subject = null)
 {
     $c = new Criteria();
     $c->add(self::STUDENT_ID, $student_career_school_year->getStudentId());
     $c->add(self::IS_FREE, true);
     $c->add(self::CAREER_SCHOOL_YEAR_ID, $student_career_school_year->getCareerSchoolYearId());
     if (!is_null($career_school_year_period) && !is_null($career_school_year_period->getMaxAbsences())) {
         $c->add(self::CAREER_SCHOOL_YEAR_PERIOD_ID, $career_school_year_period->getId());
     }
     if (!is_null($course_subject)) {
         $c->add(self::COURSE_SUBJECT_ID, $course_subject->getId());
     }
     return self::doSelectOne($c);
 }
 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');
     $c = new Criteria();
     $student_career_school_years = StudentCareerSchoolYearPeer::doSelect($c);
     try {
         $school_year = SchoolYearPeer::retrieveByPk(3);
         foreach ($student_career_school_years as $student_career_school_year) {
             $year = $student_career_school_year->getYear();
             $c = new Criteria();
             $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $student_career_school_year->getStudentId());
             StudentCareerSubjectAllowedPeer::doDelete($c);
             if ($year < 7) {
                 $year++;
                 if ($year == 1 || $year == 4) {
                     $career = CareerPeer::retrieveByPk(8);
                 } else {
                     $career = CareerPeer::retrieveByPk(4);
                 }
                 $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($career, $school_year);
                 $c = new Criteria();
                 $c->add(CareerStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
                 $career_student = CareerStudentPeer::doSelectOne($c);
                 $career_student->setCareer($career);
                 $career_student->setFileNumber($career_student->getFileNumber() + rand());
                 $career_student->save($con);
                 $career_student->createStudentsCareerSubjectAlloweds($year, $con);
                 $new_student_career_school_year = new StudentCareerSchoolYear();
                 $new_student_career_school_year->setStudent($student_career_school_year->getStudent());
                 $new_student_career_school_year->setCareerSchoolYear($career_school_year);
                 $new_student_career_school_year->setYear($year);
                 $new_student_career_school_year->save($con);
             } else {
                 $student_career_school_year->delete($con);
             }
         }
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     // add your code here
 }
예제 #5
0
 public function createStudentCareerSchoolYear($con)
 {
     $c = new Criteria();
     $c->add(CareerStudentPeer::STUDENT_ID, $this->getStudentId());
     foreach (CareerStudentPeer::doSelect($c) as $career_student) {
         /*
          * @CareerStudent $career_student
          */
         $career_school_year = $career_student->getCareer()->getCareerSchoolYear($this->getSchoolYear());
         if ($career_school_year && StudentCareerSchoolYearPeer::countByCareerAndStudent($career_student->getCareerId(), $career_student->getStudentId(), $this->getSchoolYearId()) == 0) {
             $last_student_career_school_year = $career_student->getCurrentStudentCareerSchoolYear();
             $year = is_null($last_student_career_school_year) ? $career_student->getStartYear() : $last_student_career_school_year->suggestYear();
             if ($year <= $career_school_year->getCareer()->getQuantityYears()) {
                 $student_career_school_year = new StudentCareerSchoolYear();
                 $student_career_school_year->setCareerSchoolYear($career_school_year);
                 $student_career_school_year->setStudentId($this->getStudentId());
                 //SI REPITIO
                 if (!is_null($last_student_career_school_year) && $last_student_career_school_year->getStatus() == StudentCareerSchoolYearStatus::REPPROVED) {
                     $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::LAST_YEAR_REPPROVED);
                 }
                 $student_career_school_year->setYear($year);
                 $student_career_school_year->save($con);
             }
         }
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     // add your code here
     $this->createContextInstance();
     $i = 0;
     $students = StudentPeer::doSelect(new Criteria());
     $career_school_year = CareerSchoolYearPeer::retrieveByPK(4);
     foreach ($students as $student) {
         $this->logSection("Evaluando student ID = ", $student->getId());
         $career_student = $student->getCareerStudent();
         if ($career_student == null) {
             $this->logSection("ceando CarrerStudent", $student->getId());
             $career_student = new CareerStudent();
             $career_student->setStudent($student);
             $career_student->setCareerId(1);
             $career_student->setStartYear(1);
             $career_student->setFileNumber($student->getGlobalFileNumber());
             $career_student->save($connection);
             #$career_student->createStudentsCareerSubjectAlloweds(1, $connection);
             $this->logSection("Fin creacion careerStudent", $career_student->getId());
         }
         $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year);
         if ($student_career_school_year == null) {
             $i++;
             $this->logSection("Creando studentCareerSchoolYear", $student->getId());
             $student_career_school_year = new StudentCareerSchoolYear();
             $student_career_school_year->setCareerSchoolYear($career_school_year);
             $student_career_school_year->setStudent($student);
             $student_career_school_year->setYear($student->getCareerStudent()->getStartYear());
             $student_career_school_year->save($connection);
             $this->logSection("Fin creacion studentCareerSchoolYear", $career_student->getId());
             $this->logSection("Guardando", $student);
             echo $i;
         }
     }
 }
 /**
  * This method check the conditions of repetition of a year.
  *
  * @param Student $student
  * @param StudentCareerSchoolYear $student_career_school_year
  * @return boolean
  */
 public function checkRepeationCondition(Student $student, StudentCareerSchoolYear $student_career_school_year)
 {
     //IF the current year is the last year of the career.
     if ($student_career_school_year->isLastYear()) {
         return false;
     }
     $career_school_year = $student_career_school_year->getCareerSchoolYear();
     //If previous count > than max count of previous allowed, then the student repeats
     $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student, $student_career_school_year->getCareerSchoolYear()->getCareer());
     return $previous > $career_school_year->getSubjectConfiguration()->getMaxPrevious();
 }
예제 #8
0
 public function createStudentCareerSchoolYear(PropelPDO $con)
 {
     $c = new Criteria();
     $c->addJoin(SchoolYearPeer::ID, SchoolYearStudentPeer::SCHOOL_YEAR_ID);
     $c->add(SchoolYearPeer::IS_ACTIVE, true);
     $c->add(SchoolYearStudentPeer::STUDENT_ID, $this->getStudentId());
     $school_year_student = SchoolYearStudentPeer::doSelectOne($c, $con);
     if ($school_year_student) {
         $career_school_year = $this->getCareer()->getCareerSchoolYear($school_year_student->getSchoolYear($con));
         if ($career_school_year && StudentCareerSchoolYearPeer::countByCareerAndStudent($this->getCareerId(), $this->getStudentId(), $school_year_student->getSchoolYearId(), $con) == 0) {
             $student_career_school_year = new StudentCareerSchoolYear();
             $student_career_school_year->setCareerSchoolYearId($career_school_year->getId());
             $student_career_school_year->setStudentId($this->getStudentId());
             $student_career_school_year->setYear($this->suggestYear());
             $student_career_school_year->save($con);
         }
     }
 }
 /**
  * This method checks conditions of repetition.
  *
  * @param Student $student
  * @param StudentCareerSchoolYear $student_career_school_year
  * @return boolean
  */
 public function checkRepeationCondition(Student $student, StudentCareerSchoolYear $student_career_school_year)
 {
     //If current year is the last year of the career.
     if ($student_career_school_year->isLastYear()) {
         return false;
     }
     $career_school_year = $student_career_school_year->getCareerSchoolYear();
     $last_year_previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareerAndYear($student, $career_school_year->getCareer(), $student_career_school_year->getYear() - 1);
     if ($last_year_previous > 0) {
         return true;
     }
     //If Previous count > max count of repproved subject allowed, then the student will repeat or go to pathways programs
     $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student, $student_career_school_year->getCareerSchoolYear()->getCareer());
     return $previous > $career_school_year->getSubjectConfiguration()->getMaxPrevious();
 }