public static function countStudentInscriptionsForCareerSubjectSchoolYear($course_subject_id, $student_id) { $course_subject = CourseSubjectPeer::retrieveByPk($course_subject_id); $c = new Criteria(); $c->addJoin(CourseSubjectStudentPathwayPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID); $c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $course_subject->getCareerSubjectSchoolYearId()); $c->add(CourseSubjectStudentPathwayPeer::STUDENT_ID, $student_id); $c->addAnd(CourseSubjectPeer::ID, $course_subject_id, Criteria::NOT_EQUAL); return CourseSubjectStudentPathwayPeer::doCount($c); }
public function doSave($con = null) { parent::doSave($con); $student = StudentPeer::retrieveByPk($this->getValue('student_id')); $career_school_year_period = CareerSchoolYearPeriodPeer::retrieveByPk($this->getValue('career_school_year_period_id')); $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year_period->getCareerSchoolYear()); $course_subject = CourseSubjectPeer::retrieveByPk($this->getValue('course_subject_id')); $student_free = StudentFreePeer::retrieveByStudentCareerSchoolYearCareerSchoolYearPeriodAndCourse($student_career_school_year, $career_school_year_period, $course_subject); $student_free->setIsFree(false); $student_free->save($con); }
protected function doSave($con = null) { $values = $this->getValues(); $course_subject = CourseSubjectPeer::retrieveByPk($values['course_subject_id']); $course = $course_subject->getCourse(); $con = is_null($con) ? $this->getConnection() : $con; try { $con->beginTransaction(); foreach ($values['student_list'] as $student_id) { $course_subject_student = CourseSubjectStudentPeer::retrievebyCourseSubjectAndStudent($course_subject->getid(), $student_id); $course_subject_student->setIsNotAverageable(true); $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId()); foreach ($course_subject_student_marks as $mark) { if ($mark->getMarkNumber() < $course->getCurrentPeriod()) { $mark->setIsClosed(true); } else { if ($mark->getMarkNumber() >= $course->getCurrentPeriod() && !$course->getIsClosed()) { $mark->setIsClosed(false); } } $mark->save($con); } //elimino el student_approved_course_subject y el student_approved_career_subject $student_approved_course_subject = $course_subject_student->getStudentApprovedCourseSubject(); $student_approved_career_subject = $student_approved_course_subject->getStudentApprovedCareerSubject(); $student_approved_course_subject->delete($con); $student_approved_career_subject->delete($con); $course_subject_student->setStudentApprovedCourseSubject(null); $course_subject_student->setIsNotAverageable(false); $course_subject_student->save($con); } //chequeo si la cantidad de alumnos deseximidos es mayor a cero y le curso esta cerrado. if (count($course->getIsAverageableCourseSubjectStudent()) > 0 && $course->getIsClosed()) { //abro el curso. $course->setIsClosed(false); $course->save($con); } $con->commit(); } catch (Exception $e) { throw $e; $con->rollBack(); } }
protected function doSave($con = null) { $values = $this->getValues(); $course_subject = CourseSubjectPeer::retrieveByPk($values['course_subject_id']); $course = $course_subject->getCourse(); $con = is_null($con) ? $this->getConnection() : $con; try { $con->beginTransaction(); if ($values['set_all_course_subject_non_numerical_califications'] == 1) { //tomo todos los alumnos que No tienen seteado el flag is_not_averageable $course_subject_students = $course->getIsAverageableCourseSubjectStudent(); foreach ($course_subject_students as $course_subject_student) { $course_subject_student->setIsNotAverageable(true); $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId()); foreach ($course_subject_student_marks as $mark) { $mark->setIsClosed(true); $mark->save($con); } $student_id = $course_subject_student->getStudentId(); $student_approved_course_subject = new StudentApprovedCourseSubject(); $student_approved_course_subject->setCourseSubject($course_subject); $student_approved_course_subject->setStudentId($student_id); $student_approved_course_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear()); $student_approved_career_subject = new StudentApprovedCareerSubject(); $student_approved_career_subject->setStudentId($student_id); $student_approved_career_subject->setCareerSubject($course_subject->getCareerSubjectSchoolYear()->getCareerSubject()); $student_approved_career_subject->setSchoolYear($course_subject->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); } } else { foreach ($values['student_list'] as $student_id) { $course_subject_student = CourseSubjectStudentPeer::retrievebyCourseSubjectAndStudent($course_subject->getid(), $student_id); $course_subject_student->setIsNotAverageable(true); $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($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_approved_course_subject->setStudentId($student_id); $student_approved_course_subject->setSchoolYear($course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear()); $student_approved_career_subject = new StudentApprovedCareerSubject(); $student_approved_career_subject->setStudentId($student_id); $student_approved_career_subject->setCareerSubject($course_subject->getCareerSubjectSchoolYear()->getCareerSubject()); $student_approved_career_subject->setSchoolYear($course_subject->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); } } //chequeo si la cantidad de alumnos eximidos es igual a la cantidad de alumnos inscriptos en el curso y el curso esta abierto . if (count($course->getIsNotAverageableCourseSubjectStudent()) == $course->countStudents() && !$course->getIsClosed()) { //cierro el curso. $course->setIsClosed(true); $course->save($con); } $con->commit(); } catch (Exception $e) { throw $e; $con->rollBack(); } }
public function executeSubject(sfWebRequest $request) { $params = $request->getParameter('subject_rating_report'); $this->course_subject = CourseSubjectPeer::retrieveByPk($params['course_subject_id']); $this->getUser()->setReferenceFor($this, 'rating_report'); }
public function executeSaveRevertCalificateNonNumericalMark(sfWebRequest $request) { if ($request->isMethod('POST')) { $params = $request->getParameter('revert_course_subject_non_numerical_califications'); $this->course_subject = CourseSubjectPeer::retrieveByPk($params['course_subject_id']); $this->form = new RevertCourseSubjectNonNumericalCalificationsForm($this->course_subject); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->form->save(); $this->getUser()->setFlash('notice', 'Se han deseximido a los alumnos seleccionados satisfactoriamente.'); return $this->redirect(sprintf('@%s', $this->getUser()->getAttribute('referer_module', 'homepage'))); } else { $this->getUser()->setFlash('error', 'Ocurrieron errores al intentar deseximir a los alumnos. Por favor, intente nuevamente la operación.'); $this->course = $this->course_subject->getCourse(); $this->back_url = $this->getUser()->getAttribute('referer_module'); } $this->setTemplate('revertCalificateNonNumericalMark'); } }