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 save($con = null) { if (is_null($con)) { $con = $this->getConnection(); } try { $con->beginTransaction(); $values = $this->getValues(); $any_change = false; //First check the marks if ($this->canEditMarks()) { foreach ($this->getObject()->getSortedCourseSubjectStudentMarks() as $cssm) { $mark = $values['mark_' . $cssm->getId()]; $configuration = $this->getObject()->getConfiguration(); if (!$configuration->isNumericalMark()) { $letter_mark = LetterMarkPeer::retrieveByPk($mark); if (is_null($letter_mark)) { $mark = null; } else { $mark = $letter_mark->getValue(); } } if ($cssm->getMark() !== $mark) { $cssm->setMark($mark); if ($mark == 0) { $cssm->setIsFree(true); } else { $cssm->setIsFree(false); } $cssm->save($con); $any_change = true; } } if ($any_change && $this->getObject()->areAllMarksClosed()) { //Creo de nuevo el result porque cambiaron las notas $course_result = SchoolBehaviourFactory::getEvaluatorInstance()->getCourseSubjectStudentResult($this->getObject(), $con); $course_result->save($con); if ($course_result instanceof StudentApprovedCourseSubject) { $this->getObject()->setStudentApprovedCourseSubject($course_result); $this->getObject()->save($con); } //Si ya fue procesado el año lectivo, entonces crea si corresponde la materia aprobada o la mesa de examen if ($this->getObject()->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getIsProcessed() && $this->getObject()->getCourseSubject()->getCourse()->getIsClosed()) { SchoolBehaviourFactory::getEvaluatorInstance()->closeCourseSubjectStudent($course_result, $con); } } } //if para la edición de notas en mesas de examen if ($this->canEditExaminationSubject()) { $course_subject_student_examination = $this->getObject()->getLastCourseSubjectStudentExamination(); if (isset($values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_mark']) || isset($values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_is_absent'])) { $mark = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_mark']; $is_absent = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_is_absent']; $date = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_date']; $folio = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_folio_number']; if ($mark !== $course_subject_student_examination->getMark() || $is_absent !== $course_subject_student_examination->getIsAbsent()) { $course_subject_student_examination->setExaminationSubject(ExaminationSubjectPeer::retrieveByCourseSubjectStudentExamination($course_subject_student_examination)); $course_subject_student_examination->setMark($mark); $course_subject_student_examination->setIsAbsent($is_absent); $course_subject_student_examination->setDate($date); $course_subject_student_examination->setFolioNumber($folio); $course_subject_student_examination->save($con); SchoolBehaviourFactory::getEvaluatorInstance()->closeCourseSubjectStudentExamination($course_subject_student_examination, $con); } } } /* Esto se habia creado para las previas, pero no tiene sentido editarlas. Lo dejo comentado por si sirve para mas adelante. if ($this->canEditStudentRepprovedCourseSubjects()) { $student_repproved_course_subject = $this->getObject()->getStudentRepprovedCourseSubject(); $student_examination_repproved_subject = $student_repproved_course_subject->getLastStudentExaminationRepprovedSubject(); $mark = $values['student_examination_repproved_subject_' . $student_examination_repproved_subject->getId() .'_mark']; $is_absence_name = 'student_examination_repproved_subject_' . $student_examination_repproved_subject->getId() .'_is_absent'; $is_absence = isset($values[$is_absence_name]) ? $values[$is_absence_name] : null; if ($mark !== $student_examination_repproved_subject->getMark() || $is_absence !== $student_examination_repproved_subject->getIsAbsent()) { $student_examination_repproved_subject->setMark($mark); $student_examination_repproved_subject->setIsAbsence($is_absence); } } */ $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } }