Example #1
0
 public function canBeClosed(PropelPDO $con = null)
 {
     if ($this->getIsClosed()) {
         return false;
     }
     if ($this->countStudents() == 0) {
         return false;
     }
     //busco los retirados o con reserva de banco
     $criteria = new Criteria();
     $criteria->addJoin(StudentCareerSchoolYearPeer::STUDENT_ID, StudentPeer::ID);
     $criterion = $criteria->getNewCriterion(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::WITHDRAWN, Criteria::EQUAL);
     $criterion->addOr($criteria->getNewCriterion(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::WITHDRAWN_WITH_RESERVE, Criteria::EQUAL));
     $criteria->add($criterion);
     $criteria->clearSelectColumns();
     $criteria->addSelectColumn(StudentPeer::ID);
     $stmt = StudentPeer::doSelectStmt($criteria);
     $ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
     $c = new Criteria();
     $c->addJoin(CourseSubjectStudentMarkPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID);
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectStudentPeer::STUDENT_ID, StudentPeer::ID);
     $c->add(CourseSubjectStudentPeer::IS_NOT_AVERAGEABLE, false);
     $c->addJoin(StudentPeer::PERSON_ID, PersonPeer::ID);
     $c->addJoin(PersonPeer::IS_ACTIVE, true);
     $c->addJoin(CourseSubjectPeer::COURSE_ID, $this->getId());
     $c->add(CourseSubjectStudentMarkPeer::MARK_NUMBER, $this->getCurrentPeriod());
     $c->add(CourseSubjectStudentMarkPeer::MARK, null, Criteria::ISNULL);
     $c->add(StudentPeer::ID, $ids, Criteria::NOT_IN);
     return CourseSubjectStudentMarkPeer::doCount($c) == 0 && $this->isCurrentSchoolYear();
 }
Example #2
0
 public function getAverageForMarkNumber($mark_number = null)
 {
     if ($mark_number < $this->getCourse()->getCurrentPeriod() || is_null($mark_number) && $this->getCourse()->getIsClosed()) {
         $c = new Criteria();
         $c->add(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, $this->getId());
         $c->addJoin(CourseSubjectStudentMarkPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID);
         if (!is_null($mark_number)) {
             $c->add(CourseSubjectStudentMarkPeer::MARK_NUMBER, $mark_number);
         }
         $c->clearSelectColumns();
         $c->addSelectColumn("SUM(" . CourseSubjectStudentMarkPeer::MARK . ") as sum");
         $stmt = CourseSubjectStudentMarkPeer::doSelectStmt($c);
         $sum = $stmt->fetchAll(PDO::FETCH_COLUMN);
         return sprintf('%.4s', $sum[0] / CourseSubjectStudentMarkPeer::doCount($c));
     }
 }