public function getSubjectPrereqsJoinSubjectCurrRelatedBySubcurr($criteria = null, $con = null) { include_once 'lib/model/om/BaseSubjectPrereqPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collSubjectPrereqs === null) { if ($this->isNew()) { $this->collSubjectPrereqs = array(); } else { $criteria->add(SubjectPrereqPeer::GRADE_CONVERSION_ID, $this->getId()); $this->collSubjectPrereqs = SubjectPrereqPeer::doSelectJoinSubjectCurrRelatedBySubcurr($criteria, $con); } } else { $criteria->add(SubjectPrereqPeer::GRADE_CONVERSION_ID, $this->getId()); if (!isset($this->lastSubjectPrereqCriteria) || !$this->lastSubjectPrereqCriteria->equals($criteria)) { $this->collSubjectPrereqs = SubjectPrereqPeer::doSelectJoinSubjectCurrRelatedBySubcurr($criteria, $con); } } $this->lastSubjectPrereqCriteria = $criteria; return $this->collSubjectPrereqs; }
public function executeSelectByAccal() { $student_course_id = $this->getRequestParameter('student_course_id'); $student_course = StudentCoursePeer::retrieveByPK($student_course_id); if (!$student_course) { $student_course = new StudentCourse(); } $student_id = $this->getRequestParameter('student_id'); $student = StudentPeer::retrieveByPK($student_id); // $this->forward404Unless($student); $accal_id = $this->getRequestParameter('accal_id'); $accal = AcademicCalendarPeer::retrieveByPK($accal_id); $disabled = array(); if ($student) { $student_courses = $student->getStudentCoursesJoinSubjectAccal(); foreach ($student_courses as $sc) { if ($sc->getSubjectAccal()->getAcademicCalendarId() == $accal->getId() && $student_course->getSubjectAccalId() != $sc->getSubjectAccal()->getId()) { $disabled[] = $sc->getSubjectAccal()->getId(); } } } $content = array(); $objs = SubjectAccalPeer::doSelectByAccal(); if ($student) { foreach ($objs as $o) { $content[$o->getId()] = $o->toString(); $c = new Criteria(); $c->add(SubjectAccalPeer::ID, $o->getId()); $c->add(SubjectCurrPeer::SUBJECT_ID, $o->getSubjectId()); $c->addJoin(AcademicCalendarPeer::ID, SubjectAccalPeer::ACADEMIC_CALENDAR_ID); $c->addJoin(AcademicCalendarPeer::CURRICULUM_ID, SubjectCurrPeer::CURRICULUM_ID); $c->addJoin(SubjectCurrPeer::ID, SubjectPrereqPeer::SUBCURR); $sps = SubjectPrereqPeer::doSelect($c); foreach ($sps as $sp) { $s = $sp->getSubjectCurrRelatedBySubcurrPrereq()->getSubject(); // prereq subject must be in closed state $c = new Criteria(); $c->add(SubjectAccalPeer::SUBJECT_ID, $s->getId()); $c->add(StudentCoursePeer::STUDENT_ID, $student_id); $c->add(StudentCoursePeer::STATUS, StudentCourse::STATUS_CLOSED); $c->addJoin(StudentCoursePeer::SUBJECT_ACCAL_ID, SubjectAccalPeer::ID); $scs = StudentCoursePeer::doSelect($c); $isPassGrade = false; $isPassCredit = true; $isPassIndex = true; foreach ($scs as $sc) { $grade = $sc->getFinalGrade(); $gc = GradeConversionPeer::retrieveByName($grade[0]); // check prereq subject grade if ($gc && $gc->getGrade() >= $sp->getGradeConversion()->getGrade()) { $isPassGrade = true; } else { $isPassGrade = false; } // check credit requirement if ($sp->getTotalCredit() > 0) { if ($sc->getTotalCreditClosed() >= $sp->getTotalCredit()) { $isPassCredit = true; } else { $isPassCredit = false; } } // check index requirement if ($sp->getPerformanceIndex() > 0) { if ($sc->getPerformanceIndex() >= $sp->getPerformanceIndex()) { $isPassIndex = true; } else { $isPassIndex = false; } } } $s0 = $sp->getSubjectCurrRelatedBySubcurrPrereq()->getSubject()->toString(); $s1 = $sp->getSubjectCurrRelatedBySubcurr()->getSubject()->toString(); // echo "<div align=left><pre>"; // echo "$s1 -> $s0 | isPassGrade:$isPassGrade isPassCredit:$isPassCredit isPassIndex:$isPassIndex"; // echo "</pre></div>"; if (!$isPassGrade || !$isPassCredit || !$isPassIndex) { $disabled[] = $o->getId(); } } } } else { foreach ($objs as $o) { $content[$o->getId()] = $o->toString(); } } $this->content = $content; $this->disabled = $disabled; }
public function executeUpdatePackaged() { $student_id = $this->getRequestParameter('student_id'); $student = StudentPeer::retrieveByPK($student_id); $this->forward404Unless($student); $this->student = $student; $academic_calendar_id = $this->getRequestParameter('academic_calendar_id'); $academic_calendar = AcademicCalendarPeer::retrieveByPK($academic_calendar_id); $this->forward404Unless($academic_calendar); $class_group_id = $this->getRequestParameter('class_group_id'); $class_group = ClassGroupPeer::retrieveByPK($class_group_id); $this->forward404Unless($class_group); $status = $this->getRequestParameter('status'); $this->forward404Unless($status); $subject_accals = $academic_calendar->getSubjectAccals(); $sas = array(); foreach ($subject_accals as $sa) { if ($sa->getSubject()) { $sas[] = $sa->getId(); } } $saved_sas = array(); $saved_student_courses = $student->getStudentCourses(); foreach ($saved_student_courses as $ssc) { $saved_sas[] = $ssc->getSubjectAccalId(); } $disabled_sa = array_intersect($sas, $saved_sas); // calculate sc rules $objs = SubjectAccalPeer::doSelectByAccal(); foreach ($objs as $o) { $content[$o->getId()] = $o->toStringWithLector(); $c = new Criteria(); $c->add(SubjectAccalPeer::ID, $o->getId()); $c->add(SubjectCurrPeer::SUBJECT_ID, $o->getSubjectId()); $c->addJoin(AcademicCalendarPeer::ID, SubjectAccalPeer::ACADEMIC_CALENDAR_ID); $c->addJoin(AcademicCalendarPeer::CURRICULUM_ID, SubjectCurrPeer::CURRICULUM_ID); $c->addJoin(SubjectCurrPeer::ID, SubjectPrereqPeer::SUBCURR); $sps = SubjectPrereqPeer::doSelect($c); foreach ($sps as $sp) { $s = $sp->getSubjectCurrRelatedBySubcurrPrereq()->getSubject(); // prereq subject must be in closed state $c = new Criteria(); $c->add(SubjectAccalPeer::SUBJECT_ID, $s->getId()); $c->add(StudentCoursePeer::STUDENT_ID, $student_id); $c->add(StudentCoursePeer::STATUS, StudentCourse::STATUS_CLOSED); $c->addJoin(StudentCoursePeer::SUBJECT_ACCAL_ID, SubjectAccalPeer::ID); $scs = StudentCoursePeer::doSelect($c); $isPassGrade = false; $isPassCredit = true; $isPassIndex = true; foreach ($scs as $sc) { $grade = $sc->getFinalGrade(); $gc = GradeConversionPeer::retrieveByName($grade[0]); // check prereq subject grade if ($gc && $gc->getGrade() >= $sp->getGradeConversion()->getGrade()) { $isPassGrade = true; } else { $isPassGrade = false; } // check credit requirement if ($sp->getTotalCredit() > 0) { if ($sc->getTotalCreditClosed() >= $sp->getTotalCredit()) { $isPassCredit = true; } else { $isPassCredit = false; } } // check index requirement if ($sp->getPerformanceIndex() > 0) { if ($sc->getPerformanceIndex() >= $sp->getPerformanceIndex()) { $isPassIndex = true; } else { $isPassIndex = false; } } } $s0 = $sp->getSubjectCurrRelatedBySubcurrPrereq()->getSubject()->toString(); $s1 = $sp->getSubjectCurrRelatedBySubcurr()->getSubject()->toString(); if (!$isPassGrade || !$isPassCredit || !$isPassIndex) { $disabled_sa[] = $o->getId(); } } } $selected_sa = array_diff($sas, $disabled_sa); foreach ($selected_sa as $sa_id) { $student_course = new StudentCourse(); $student_course->setStudentId($student_id); $student_course->setSubjectAccalId($sa_id); $student_course->setStatus($status); $student_course->setClassGroupId($class_group_id); $student_course->save(); } return $this->redirect('student_course_s/list?student_id=' . $student->getId()); }
public function getSubjectPrereqsRelatedBySubaccalJoinGradeConversion($criteria = null, $con = null) { include_once 'lib/model/om/BaseSubjectPrereqPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collSubjectPrereqsRelatedBySubaccal === null) { if ($this->isNew()) { $this->collSubjectPrereqsRelatedBySubaccal = array(); } else { $criteria->add(SubjectPrereqPeer::SUBACCAL, $this->getId()); $this->collSubjectPrereqsRelatedBySubaccal = SubjectPrereqPeer::doSelectJoinGradeConversion($criteria, $con); } } else { $criteria->add(SubjectPrereqPeer::SUBACCAL, $this->getId()); if (!isset($this->lastSubjectPrereqRelatedBySubaccalCriteria) || !$this->lastSubjectPrereqRelatedBySubaccalCriteria->equals($criteria)) { $this->collSubjectPrereqsRelatedBySubaccal = SubjectPrereqPeer::doSelectJoinGradeConversion($criteria, $con); } } $this->lastSubjectPrereqRelatedBySubaccalCriteria = $criteria; return $this->collSubjectPrereqsRelatedBySubaccal; }
public function executeDelete() { $curr_id = $this->getRequestParameter('curr_id'); $this->forward404Unless($curr_id); $this->curr = CurriculumPeer::retrieveByPK($curr_id); $subject_prereq = SubjectPrereqPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($subject_prereq); $ref_error = 0; foreach ($subject_prereq->getRefCountMethods() as $ref) { $method = "count" . $ref['affix']; $count = $subject_prereq->{$method}(); if ($count > 0) { ++$ref_error; $this->getRequest()->setError('subject_prereq/delete/' . sfInflector::camelize($ref['table']), $count); } } if ($ref_error > 0) { $this->getRequest()->setError('subject_prereq/delete', '_ERR_DELETE_ (' . $subject_prereq->toString() . ' - id:' . $subject_prereq->getId() . ')'); } else { $subject_prereq->delete(); } $this->getRequest()->setParameter('curr_id', $this->curr->getId()); return $this->forward('subject_prereq', 'list'); }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = SubjectPrereqPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setSubcurrPrereq($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setSubcurr($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setSequence($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setGradeConversionId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setTotalCredit($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setPerformanceIndex($arr[$keys[6]]); } }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(SubjectPrereqPeer::ID, $pks, Criteria::IN); $objs = SubjectPrereqPeer::doSelect($criteria, $con); } return $objs; }
public function filter($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } $column = SubjectPrereqPeer::getTableMap()->getColumn($key); $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->add($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } } } } }