public function executeUpdateEquivalence(sfWebRequest $request) { $parametrs = $request->getPostParameters(); $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($parametrs['career_school_year_id']); $this->career = $this->career_school_year->getCareer(); $this->career_subject_school_years = array(); $this->years = array(); $this->forms = array(); for ($y = 1; $y <= $this->career->getQuantityYears(); $y++) { $this->years[] = $y; $this->career_subject_school_years[$y] = $this->career->getCareerSubjectsForYear($y, true); } unset($parametrs['_save']); unset($parametrs['career_school_year_id']); $valid = true; foreach ($parametrs as $parameter) { $career_subject_id = $parameter['career_subject_id']; $student_id = $parameter['student_id']; $school_year_id = $parameter['school_year']; $career_subject = CareerSubjectPeer::retrieveByPK($career_subject_id); $student = StudentPeer::retrieveByPK($student_id); $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($career_subject->getId(), $student->getId()); $student_approved_career_subject->setSchoolYearId($school_year_id); $parameter['career_subject_id'] = $student_approved_career_subject->getCareerSubjectId(); $this->form = new EquivalenceForm($student_approved_career_subject); $this->form->setCareerSubjectAndStudent($career_subject, $student); if (isset($parameter['mark']) && $parameter['mark'] != "") { $this->form->bind($parameter); if ($this->form->isValid()) { $this->form->save(); } else { $valid = false; } } $this->form = new EquivalenceForm($student_approved_career_subject); $this->form->setCareerSubjectAndStudent($career_subject, $student); $this->forms[$career_subject->getId()] = $this->form; $parameter['career_subject_id'] = $career_subject_id; } if ($valid) { $this->getUser()->setFlash('notice', 'subjects are updated correctly'); } else { $this->setProcessFormErrorFlash(); } $this->module = $this->getModuleName(); $this->setTemplate('makeUpEquivalence'); }
public function fixComissions($connection) { $c = new Criteria(); //$c->add(CoursePeer::DIVISION_ID, null, Criteria::ISNULL); $c->add(CoursePeer::SCHOOL_YEAR_ID, 1); foreach (CoursePeer::doSelect($c) as $course) { $course_subjects = $course->getCourseSubjects(); foreach ($course->getCourseSubjects() as $course_subject) { foreach ($course_subject->getCourseSubjectStudents() as $course_subject_student) { $result = $course_subject_student->getCourseResult(); if (is_null($result->getStudentApprovedCareerSubjectId())) { if (is_null($result->getId())) { $result->save($connection); if ($result instanceof StudentApprovedCourseSubject) { $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($course_subject_student->getCourseSubject()->getCareerSubject()->getId(), $course_subject_student->getStudentId()); $student_approved_career_subject->setSchoolYearId(1); $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject); $student_approved_course_subject->save($connection); $student_approved_career_subject->save($connection); } } } } } } }
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() >= self::EXAMINATION_NOTE) { $result = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject()->getId(), $course_subject_student->getStudent()->getId()); $result->setCareerSubject($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject()); $result->setStudent($course_subject_student->getStudent()); $result->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear()); if (in_array($course_subject_student->getCourseSubject()->getSubject()->getId(), $this->_introduccion)) { $average = (string) $course_subject_student_examination->getMark(); } else { $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 ($this->getCurrentHistoriaDelArte() && $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYearId() == $this->getCurrentHistoriaDelArte()->getId()) { $average = $course_subject_student_examination->getMark(); } if ($average < 4) { $average = 4; } $result->setMark($average); ##se agrega en la tupla student_disapproved_course_subject el link a al resultado final $student_disapproved_course_subject = $course_subject_student->getCourseResult(); $student_disapproved_course_subject->setStudentApprovedCareerSubject($result); $student_disapproved_course_subject->save($con); $result->save($con); //Se busca si había una previa creada para esta materia, se debe eliminar if ($student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student)) { $student_repproved_course_subject->delete($con); } } 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) if ($course_subject_student_examination->getExaminationNumber() < count($this->_examination_number)) { $new_course_subject_student_examination = $course_subject_student_examination->copy(); $new_course_subject_student_examination->setExaminationNumber($course_subject_student_examination->getExaminationNumber() + 1); $new_course_subject_student_examination->setMark(null); $new_course_subject_student_examination->setExaminationSubjectId(null); $new_course_subject_student_examination->setIsAbsent(false); $new_course_subject_student_examination->save($con); } else { // se crea una previa $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student); if (is_null($student_repproved_course_subject)) { $student_repproved_course_subject = new StudentRepprovedCourseSubject(); } $student_repproved_course_subject->setCourseSubjectStudentId($course_subject_student->getId()); $student_repproved_course_subject->save($con); } } }