/** * This method updates the actual period of the course. * * @param PropelPDO $con */ public function updatePeriod(PropelPDO $con = null) { $c = new Criteria(); $c->add(CourseSubjectStudentMarkPeer::IS_CLOSED, true); $c->add(CourseSubjectStudentMarkPeer::MARK, null, Criteria::ISNOTNULL); $c->addJoin(CourseSubjectStudentMarkPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID); $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID); $c->add(CourseSubjectStudentPeer::IS_NOT_AVERAGEABLE, false); $c->add(CourseSubjectPeer::COURSE_ID, $this->getId()); $c->addDescendingOrderByColumn(CourseSubjectStudentMarkPeer::MARK_NUMBER); $course_subject_student_mark = CourseSubjectStudentMarkPeer::doSelectOne($c); $period = is_null($course_subject_student_mark) ? 1 : $course_subject_student_mark->getMarkNumber(); $this->setCurrentPeriod($period + 1); }