public function closeCourseSubjectStudentExamination(CourseSubjectStudentExamination $course_subject_student_examination, PropelPDO $con = null) { $con = is_null($con) ? Propel::getConnection() : $con; $course_subject_student = $course_subject_student_examination->getCourseSubjectStudent(); // si aprueba la mesa de examen if ($course_subject_student_examination->getMark() >= 6) { // se crea el approved course subject $sacs = StudentApprovedCourseSubjectPeer::retrieveForCourseSujectStudent($course_subject_student_examination->getCourseSubjectStudent()); if (is_null($sacs)) { $result = new StudentApprovedCourseSubject(); $result->setCourseSubjectId($course_subject_student->getCourseSubjectId()); $result->setStudentId($course_subject_student->getStudentId()); $result->setSchoolYearId($course_subject_student_examination->getExaminationSubject()->getExamination()->getSchoolYearId()); $average = (string) (($course_subject_student->getMarksAverage() + $course_subject_student_examination->getMark()) / 2); $average = sprintf('%.4s', $average); // se guarda la NOTA FINAL de la materia if ($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYearId() == $this->getCurrentHistoriaDelArte()->getId()) { $average = $course_subject_student_examination->getMark(); } $result->setMark($average); $result->save($con); $this->closeCourseSubjectStudent($result, $con, $course_subject_student); } } else { // TODO: arreglar esto: pedir a la configuración // Pasa de diciembre a febrero (se copia el course_subject_student_examination con examination_number + 1) $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveCourseSubjectStudent($course_subject_student); if (is_null($student_repproved_course_subject)) { // se crea una previa $student_repproved_course_subject = new StudentRepprovedCourseSubject(); $student_repproved_course_subject->setCourseSubjectStudentId($course_subject_student->getId()); $student_repproved_course_subject->save($con); } } }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $con = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $this->createContextInstance('backend'); $criteria = new Criteria(); $criteria->add(CoursePeer::IS_CLOSED, false); $criteria->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID, Criteria::INNER_JOIN); $criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID, Criteria::INNER_JOIN); $course_subject_students = CourseSubjectStudentPeer::doSelect($criteria); $this->log('Cant. Course Subject Students a procesar:'); $this->log(count($course_subject_students)); foreach ($course_subject_students as $course_subject_student) { $course_subject_student_marks = CourseSubjectStudentMarkPeer::retrieveByCourseSubjectStudent($course_subject_student->getId()); $this->log('Id del course subject student Actual:'); $this->log($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->getCourseSubject()); $student_approved_course_subject->setStudentId($course_subject_student->getStudentId()); $student_approved_course_subject->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getSchoolYear()); $student_approved_career_subject = new StudentApprovedCareerSubject(); $student_approved_career_subject->setStudentId($course_subject_student->getStudentId()); $student_approved_career_subject->setCareerSubject($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject()); $student_approved_career_subject->setSchoolYear($course_subject_student->getCourseSubject()->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); } $criteria = new Criteria(); $criteria->add(CoursePeer::IS_CLOSED, false); $courses = CoursePeer::doSelect($criteria); foreach ($courses as $c) { $c->setIsClosed(true); $c->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(); 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(); } }