/** * Adds the reference for the ExaminationSubject to the CourseSubjectStudentExaminations. * * @param ExaminationSubject $examination_subject * @param PropelPDO $con */ public function updateCourseSubjectStudentExaminations($examination_subject, PropelPDO $con) { //this is done for manual examinations if (!ExaminationSubjectBehavior::enabled()) { return; } $course_subject_student_examinations = CourseSubjectStudentExaminationPeer::retrieveForExaminationSubject($examination_subject); foreach ($course_subject_student_examinations as $course_subject_student_examination) { $examination_subject->addCourseSubjectStudentExamination($course_subject_student_examination); } }
protected function execute($arguments = array(), $options = array()) { $this->createContextInstance('backend'); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $c = new Criteria(); $c->add(CourseSubjectStudentExaminationPeer::EXAMINATION_SUBJECT_ID, null, Criteria::ISNULL); foreach (CourseSubjectStudentExaminationPeer::doSelect($c) as $csse) { $csse->setExaminationSubject(ExaminationSubjectPeer::retrieveByCourseSubjectStudentExamination($csse)); $csse->saveForTask(); } // add your code here }
public function saveForTask(PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(CourseSubjectStudentExaminationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $affectedRows = $this->doSave($con); $con->commit(); CourseSubjectStudentExaminationPeer::addInstanceToPool($this); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
public function executeComponent_marks_info() { $this->course_subject_student = $this->getVar('course_subject_student'); $this->marks = $this->course_subject_student->getAvailableCourseSubjectStudentMarks(); $c = new Criteria(); $c->add(CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID, $this->course_subject_student->getId()); $criterion = $c->getNewCriterion(CourseSubjectStudentExaminationPeer::MARK, null, Criteria::ISNOTNULL); $criterion->addOr($c->getNewCriterion(CourseSubjectStudentExaminationPeer::IS_ABSENT, true)); $c->add($criterion); $c->addAscendingOrderByColumn(CourseSubjectStudentExaminationPeer::EXAMINATION_NUMBER); $this->course_subject_student_examinations = CourseSubjectStudentExaminationPeer::doSelect($c); $c = new Criteria(); $c->add(StudentRepprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, $this->course_subject_student->getId() . Criteria::INNER_JOIN); $c->addJoin(StudentExaminationRepprovedSubjectPeer::STUDENT_REPPROVED_COURSE_SUBJECT_ID, StudentRepprovedCourseSubjectPeer::ID, Criteria::INNER_JOIN); $c->addJoin(StudentExaminationRepprovedSubjectPeer::EXAMINATION_REPPROVED_SUBJECT_ID, ExaminationRepprovedSubjectPeer::ID, Criteria::INNER_JOIN); $c->addJoin(ExaminationRepprovedSubjectPeer::EXAMINATION_REPPROVED_ID, ExaminationRepprovedPeer::ID, Criteria::INNER_JOIN); $c->addAscendingOrderByColumn(ExaminationRepprovedPeer::EXAMINATION_NUMBER); $criterion = $c->getNewCriterion(StudentExaminationRepprovedSubjectPeer::MARK, null, Criteria::ISNOTNULL); $criterion->addOr($c->getNewCriterion(StudentExaminationRepprovedSubjectPeer::IS_ABSENT, true)); $c->add($criterion); $this->student_examination_repproved_subjects = StudentExaminationRepprovedSubjectPeer::doSelect($c); //$this->pathway_mark = $this->course_subject_student->getCourseSubjectStudentPathwayMark()->getMark(); }
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(); $this->createContextInstance(); $criteria = new Criteria(); $criteria->addJoin(CourseSubjectStudentPeer::ID, CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID); $criteria->add(CourseSubjectStudentExaminationPeer::MARK, null, Criteria::ISNOTNULL); $criteria->addAnd(CourseSubjectStudentExaminationPeer::MARK, 6, Criteria::GREATER_EQUAL); $criteria->add(CourseSubjectStudentPeer::STUDENT_ID, 728); $array_csse = CourseSubjectStudentExaminationPeer::doSelect($criteria); $connection->beginTransaction(); try { /* @var $csse CourseSubjectStudentExamination */ foreach ($array_csse as $csse) { $sacs = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($csse->getCourseSubjectStudent()); if (is_null($sacs)) { $this->closeCourseSubjectStudentExamination($csse, $connection); } } $connection->commit(); } catch (Exception $e) { $connection->rollback(); throw $e; } }
public static function retrieveApprovationDate(StudentApprovedCareerSubject $studentApprovedCareerSubject) { $approvationInstance = $studentApprovedCareerSubject->getApprovationInstance(); switch (get_class($approvationInstance)) { case 'StudentApprovedCourseSubject': $period = $approvationInstance->getCourseSubject()->getLastCareerSchoolYearPeriod(); if (!is_null($period)) { return $period->getEndAt(); } break; case 'StudentDisapprovedCourseSubject': $cssid = $approvationInstance->getCourseSubjectStudentId(); $csse = CourseSubjectStudentExaminationPeer::retrieveLastByCourseSubjectStudentId($cssid); $exam = $csse->getExaminationSubject()->getExamination(); return $exam->getDateFrom(); case 'StudentRepprovedCourseSubject': $sers = StudentExaminationRepprovedSubjectPeer::retrieveByStudentRepprovedCourseSubject($approvationInstance); $exam = $sers->getExaminationRepprovedSubject()->getExaminationRepproved(); return $exam->getDateFrom(); } //couldn't find when was approved. return null ¿error? return; }
public function countAbsenceStudents() { $criteria = $this->getCriteriaForCourseSubjectExamination(); $criteria->add(CourseSubjectStudentExaminationPeer::IS_ABSENT, true); return CourseSubjectStudentExaminationPeer::doCount($criteria); }
public function closeCourseSubjectStudent($result, PropelPDO $con = null) { if ($result instanceof StudentApprovedCourseSubject) { if (is_null($student_approved_career_subject = $result->getStudentApprovedCareerSubject($con))) { $student_approved_career_subject = new StudentApprovedCareerSubject(); $student_approved_career_subject->setCareerSubject($result->getCourseSubject($con)->getCareerSubject($con)); $student_approved_career_subject->setStudent($result->getStudent($con)); $student_approved_career_subject->setSchoolYear($result->getSchoolYear($con)); $student_approved_career_subject->setMark($result->getMark()); $result->setStudentApprovedCareerSubject($student_approved_career_subject); $student_approved_career_subject->save($con); $result->save($con); $student_approved_career_subject->clearAllReferences(true); $result->clearAllReferences(true); } unset($result); unset($student_approved_career_subject); } else { $c = new Criteria(); $c->add(CourseSubjectStudentExaminationPeer::EXAMINATION_NUMBER, $result->getExaminationNumber()); $c->add(CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID, $result->getCourseSubjectStudent()->getId()); if (CourseSubjectStudentExaminationPeer::doCount($c) == 0) { $this->createCourseSubjectStudentExamination($result->getCourseSubjectStudent(null, $con), $con); } } }
public function countExaminationsForExaminationNumber($examination_number) { $es = ExaminationSubjectPeer::retrieveForCareerSubjectSchoolYearAndExaminationNumber($this->getCareerSubjectSchoolYear(), $examination_number); $total = 0; if ($es) { foreach (CourseSubjectStudentExaminationPeer::doSelectForExaminationSubjectAndNumber($es, $examination_number) as $csse) { // Could be improved a lot... if ($csse->getCourseSubjectStudent()->getCourseSubject()->getCourse()->getDivision() == $this->getCourse()->getDivision()) { $total++; } } } return $total; }
public function getLastCourseSubjectStudentExamination() { $c = new Criteria(); $c->addDescendingOrderByColumn(CourseSubjectStudentExaminationPeer::ID); $c->add(CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID, $this->getId()); return CourseSubjectStudentExaminationPeer::doSelectOne($c); }