Ejemplo n.º 1
0
 public function deleteStudentFromCourses($id, $con)
 {
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID, Criteria::INNER_JOIN);
     $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID, Criteria::INNER_JOIN);
     $c->addAnd(CoursePeer::DIVISION_ID, $this->getId());
     $c->addAnd(CourseSubjectStudentPeer::STUDENT_ID, $id);
     foreach (CourseSubjectStudentPeer::doSelect($c) as $css) {
         if ($css->countValidCourseSubjectStudentMarks() > 0) {
             throw new Exception('Los alumnos seleccionados poseen datos que le impiden ser borrados de esta division y sus cursos.');
         }
         $css->delete($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);
     }
 }
 public function fixCourseSubjectStudents($con)
 {
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID);
     $c->add(CoursePeer::SCHOOL_YEAR_ID, 1);
     $c->add(CoursePeer::DIVISION_ID, null, Criteria::ISNULL);
     //die(var_dump(count(CourseSubjectStudentPeer::doSelect($c))));
     foreach (CourseSubjectStudentPeer::doSelect($c) as $course_subject_student) {
         $result = $course_subject_student->getCourseResult();
         if (is_null($result->getId())) {
             $result->save($con);
         }
         if ($result instanceof StudentApprovedCourseSubject) {
             $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($course_subject_student->getCourseSubject()->getCareerSubject()->getId(), $course_subject_student->getStudentId());
             $student_approved_career_subject->setSchoolYearId(1);
             $result->setStudentApprovedCareerSubject($student_approved_career_subject);
             $result->save($con);
             $student_approved_career_subject->save($con);
         }
         unset($result);
     }
 }
 public function getHistoriaDelArteMark($student, $school_year)
 {
     $historia = array(self::HISTORIA_DEL_ARTE, 261, 262);
     $c = new Criteria();
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $student->getId());
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
     $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
     $c->add(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, $historia, Criteria::IN);
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId());
     $avg = 0;
     foreach (CourseSubjectStudentPeer::doSelect($c) as $course_subject_student) {
         $course_result = $course_subject_student->getCourseResult();
         if (is_null($course_result) || $course_result instanceof StudentDisapprovedCourseSubject) {
             return '';
         }
         $avg += $course_result->getMark();
     }
     $avg = $avg / 2;
     return sprintf('%.4s', $avg);
 }
Ejemplo n.º 5
0
 public function deleteCourseSubjectStudent()
 {
     $con = Propel::getConnection();
     try {
         $con->beginTransaction();
         $criteria = new Criteria();
         $criteria->add(CareerPeer::ID, $this->getCareerId());
         $criteria->addJoin(CareerPeer::ID, CareerSchoolYearPeer::CAREER_ID);
         $criteria->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
         $criteria->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
         $criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID);
         $criteria->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getStudentId());
         foreach (CourseSubjectStudentPeer::doSelect($criteria) as $course_subject_student) {
             $course_subject_student->delete($con);
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
 public function hasApprovedAllCourseSubjects($student_career_school_year)
 {
     #Counts the subjects the student did
     $c = new Criteria();
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
     $c->add(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $student_career_school_year->getCareerSchoolYearId());
     #Counts the subjects approved by the student during this year
     $course_subject_students = CourseSubjectStudentPeer::doSelect($c);
     /* @var $course_subject_student CourseSubjectStudent */
     foreach ($course_subject_students as $course_subject_student) {
         if (!$course_subject_student->getIsNotAverageable()) {
             $course_result = $course_subject_student->getCourseResult();
             if (is_null($course_result)) {
                 return false;
             }
             if (!$course_result->isApproved()) {
                 return false;
             }
         }
     }
     return true;
 }
Ejemplo n.º 7
0
 public function getIsAverageableCourseSubjectStudent()
 {
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::COURSE_ID, $this->getId());
     $c->add(CourseSubjectStudentPeer::IS_NOT_AVERAGEABLE, false);
     return CourseSubjectStudentPeer::doSelect($c);
 }
Ejemplo n.º 8
0
 /**
  * Returns the number of disapproved for the given school year.
  *
  * @param SchoolYear $school_year
  * @return integer the disapproved count
  */
 public function countDisapprovedForSchoolYear(SchoolYear $school_year, PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $c = new Criteria();
     $c->addJoin(StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID);
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getId());
     $previous_ids = array_map(create_function('$c', 'return $c->getId();'), CourseSubjectStudentPeer::doSelect($c));
     $c = new Criteria();
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getId());
     $c->add(CoursePeer::SCHOOL_YEAR_ID, $school_year->getId());
     $c->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID);
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectStudentPeer::ID, StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID);
     $c->add(StudentDisapprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL);
     $c->add(StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, $previous_ids, Criteria::NOT_IN);
     return StudentDisapprovedCourseSubjectPeer::doCount($c, $con);
 }