protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $this->createContextInstance('backend'); try { $connection->beginTransaction(); $c = new Criteria(); $c->add(StudentApprovedCareerSubjectPeer::SCHOOL_YEAR_ID, 1); $student_approved_career_subjects = StudentApprovedCareerSubjectPeer::doSelect($c); $arreglados = 0; foreach ($student_approved_career_subjects as $student_approved_career_subject) { if (!($student_approved_career_subject->hasStudentApprovedCourseSubject() || $student_approved_career_subject->hasStudentDisapprovedCourseSubject() || $student_approved_career_subject->hasStudentRepprovedCourseSubject())) { $evaluetor = new LvmEvaluatorBehaviour(); $c = new Criteria(); $course_subject_student = CourseSubjectStudentPeer::retrieveByStudentApprovedCareerSubject($student_approved_career_subject, SchoolYearPeer::retrieveByPK(1)); if ($course_subject_student) { $instanceResult = $evaluetor->getCourseSubjectStudentResult($course_subject_student, $connection); if ($instanceResult instanceof StudentApprovedCourseSubject) { $criteria = new Criteria(); $criteria->add(StudentApprovedCourseSubjectPeer::STUDENT_ID, $instanceResult->getStudentId()); $criteria->add(StudentApprovedCourseSubjectPeer::SCHOOL_YEAR_ID, $instanceResult->getSchoolYearId()); $criteria->add(StudentApprovedCourseSubjectPeer::COURSE_SUBJECT_ID, $instanceResult->getCourseSubjectId()); if (StudentApprovedCourseSubjectPeer::doCount($criteria)) { $instanceResult = StudentApprovedCourseSubjectPeer::doSelectOne($criteria); } $instanceResult->setStudentApprovedCareerSubject($student_approved_career_subject); $instanceResult->setStudentApprovedCareerSubjectId($student_approved_career_subject->getId()); $instanceResult->save(); $this->logSection("arreglado", $arreglados); $this->logSection("alumno", $instanceResult->getStudent()); $this->logSection("careerSubject", $instanceResult->getCareerSubject()); $this->logSection("StudentApprovedCourseSubject", $instanceResult); $this->logSection("StudentApprovedCareerSubject ID: ", $student_approved_career_subject->getId()); //var_dump($instanceResult);die(); $arreglados++; } } else { $this->logSection("No se pudieron ubicar", $student_approved_career_subject->getStudent() . '- ' . $student_approved_career_subject->getCareerSubject() . '' . $student_approved_career_subject->getId()); } } } $this->logSection("arreglados", $arreglados); $connection->commit(); $connection->beginTransaction(); $c = new Criteria(); $c->add(StudentApprovedCourseSubjectPeer::SCHOOL_YEAR_ID, 1); $c->add(StudentApprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL); //Se actualizan los cursos aprobados con la materia aprobada, esto existe por que hubo una version que no lo hacia de forma correcta y esto corrige dicho error. $update = 0; $news = 0; $student_approved_course_subjects_null = StudentApprovedCourseSubjectPeer::doSelect($c); foreach ($student_approved_course_subjects_null as $student_approved_course_subject) { $course_subject_student = $student_approved_course_subject->getCourseSubjectStudent(); if ($course_subject_student) { $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($course_subject_student->getCourseSubject()->getCareerSubject()->getId(), $student_approved_course_subject->getCourseSubjectStudent()->getStudentId()); } else { $this->logSection("Cuak!", $student_approved_course_subject->getId(), $student_approved_course_subject); } $student_approved_career_subject->setSchoolYearId(1); $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject); $student_approved_career_subject->isNew() ? $news++ : $update++; $student_approved_course_subject->save($connection); $student_approved_career_subject->save($connection); } $this->logSection("Actualizados", $update); $this->logSection("Nuevos", $news); //Este foreach corrige el error de una version, que creaba tambien el student_approved_course_subject, cuando no es real. $c = new Criteria(); $student_dissapproved_course_subjects = StudentDisapprovedCourseSubjectPeer::doSelect($c); $delete = 0; foreach ($student_dissapproved_course_subjects as $student_dissapproved_course_subject) { $course_subject_student = $student_dissapproved_course_subject->getCourseSubjectStudent(); $c = new Criteria(); $c->add(StudentApprovedCourseSubjectPeer::STUDENT_ID, $course_subject_student->getStudentId()); $c->add(StudentApprovedCourseSubjectPeer::COURSE_SUBJECT_ID, $course_subject_student->getCourseSubjectId()); $student_approved_course_subject = StudentApprovedCourseSubjectPeer::doSelectOne($c); if (!is_null($student_approved_course_subject)) { $student_approved_course_subject->delete($connection); $delete++; } } $this->logSection("Borrados", $delete); $connection->commit(); /* $c = new Criteria(); $c->add(StudentDisapprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL); $student_dissapproved_course_subjects = StudentDisapprovedCourseSubjectPeer::doSelect($c); foreach ($student_dissapproved_course_subjects as $student_dissapproved_course_subject) { $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent( $student_dissapproved_course_subject->getCourseSubjectStudent()->getCourseSubject()->getCareerSubject()->getId(), $student_dissapproved_course_subject->getCourseSubjectStudent()->getStudentId()); if (!is_null($student_approved_career_subject) && !$student_approved_career_subject->isNew()) { $student_dissapproved_course_subject->setStudentApprovedCareerSubjectId($student_approved_career_subject->getId()); $student_dissapproved_course_subject->save($connection); } else { $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveCourseSubjectStudent($student_dissapproved_course_subject->getCourseSubjectStudent()); if (is_null($student_repproved_course_subject)) { die(var_dump($student_dissapproved_course_subject->getId())); } } } */ //$this->fixComissions($connection); //$this->fixCourseSubjectStudents($connection); //$this->fixStudentCareerSchoolYearStatus($connection); //$this->fixRepetidores($connection); //$this->fixApproved($connection); } catch (PropelException $e) { $connection->rollback(); throw $e; } // add your code here }
public function closeCourseSubjectStudent($result, PropelPDO $con = null, $course_subject_student) { if ($result instanceof StudentApprovedCourseSubject) { $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student); if (is_null($student_approved_career_subject)) { $student_approved_career_subject = new StudentApprovedCareerSubject(); $student_approved_career_subject->setCareerSubject($result->getCourseSubject($con)->getCareerSubject($con)); $student_approved_career_subject->setStudent($result->getStudent($con)); $student_approved_career_subject->setSchoolYear($result->getSchoolYear($con)); $student_approved_career_subject->setMark($result->getMark()); $result->setStudentApprovedCareerSubject($student_approved_career_subject); /* para el caso de que se aprueba por mesa de examen, se debe asociar el student_approved_career_subject * con el student_disapproved_course_subject */ $disapproved = StudentDisapprovedCourseSubjectPeer::retrieveByStudentApprovedCourseSubject($result, $con); if (!is_null($disapproved)) { $disapproved->setStudentApprovedCareerSubject($student_approved_career_subject); $disapproved->save($con); } $student_approved_career_subject->save($con); $result->save($con); } } else { $this->createCourseSubjectStudentExamination($result->getCourseSubjectStudent(null, $con), $con); } }
public function evaluateCareerSchoolYearStudent(CareerSchoolYear $career_school_year, Student $student, PropelPDO $con = null) { $con = is_null($con) ? Propel::getConnection() : $con; // obtenemos mas materias de este año #$course_subject_students = CourseSubjectStudentPeer::retrieveByCareerSchoolYearAndStudent($career_school_year, $student, $con); //$c = CourseSubjectStudentPeer::retrieveCriteriaByCareerSchoolYearAndStudent($career_school_year, $student, $con); //$c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID, Criteria::INNER_JOIN); //$c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $this->getCurrentHistoriaDelArte()->getId(), Criteria::NOT_EQUAL); // para todas las materias cursadas este año //$course_subject_students = CourseSubjectStudentPeer::doSelect($c); $school_year = SchoolYearPeer::retrieveCurrent(); $course_subject_students = $student->getCourseSubjectStudentsForSchoolYear($school_year); CourseSubjectStudentPeer::clearInstancePool(); unset($school_year); foreach ($course_subject_students as $course_subject_student) { // obtenemos el resultado (aprobada o desaprobada) y la cerramos. // para el caso de las aprobadas, se crea la mesa de examen final (StudentApprovedCareerSubject) // de lo contrario, la inscripción a la mesa de examen (TODO) $result = $course_subject_student->getCourseResult($con); if (!is_null($result)) { $result->close($con); ###Liberando memoria ### $result->clearAllReferences(true); unset($result); } $course_subject_student->clearAllReferences(true); unset($course_subject_student); ########################### } ###Liberando memoria ### unset($course_subject_students); StudentApprovedCourseSubjectPeer::clearInstancePool(); StudentDisapprovedCourseSubjectPeer::clearInstancePool(); ################################ if ($this->getCurrentHistoriaDelArte()) { $this->evaluateHistoriaDelArteCareerSchoolYearStudent($career_school_year, $student, $con); } }
public function getApprovationInstance() { // Caso Regular: aprueba en primer instancia $instance = StudentApprovedCourseSubjectPeer::retrieveByStudentApprovedCareerSubject($this); if (!is_null($instance)) { return $instance; } // Caso Mesa de Diciembre, Marzo $instance = StudentDisapprovedCourseSubjectPeer::retrieveByStudentApprovedCareerSubject($this); if (!is_null($instance)) { return $instance; } // Caso de previa $instance = StudentRepprovedCourseSubjectPeer::retrieveByStudentApprovedCareerSubject($this); if (!is_null($instance)) { return $instance; } return null; }
public function evaluateCareerSchoolYearStudent(CareerSchoolYear $career_school_year, Student $student, PropelPDO $con = null) { $con = is_null($con) ? Propel::getConnection() : $con; // obtenemos las materias de este año #$course_subject_students = CourseSubjectStudentPeer::retrieveByCareerSchoolYearAndStudent($career_school_year, $student, $con); $c = CourseSubjectStudentPeer::retrieveCriteriaByCareerSchoolYearAndStudent($career_school_year, $student, $con); $pager = new sfPropelPager('CourseSubjectStudent', 100); $pager->setCriteria($c); $pager->init(); for ($i = 1; $i < $pager->getLastPage() + 1; $i++) { $course_subject_students = $pager->getResults(); // para todas las materias cursadas este año foreach ($course_subject_students as $course_subject_student) { // obtenemos el resultado (aprobada o desaprobada) y la cerramos. // para el caso de las aprobadas, se crea la mesa de examen final (StudentApprovedCareerSubject) // de lo contrario, la inscripción a la mesa de examen (TODO) $result = $course_subject_student->getCourseResult($con); if (!is_null($result)) { $result->close($con); } } ###Liberando memoria ### CourseSubjectStudentPeer::clearInstancePool(); StudentApprovedCourseSubjectPeer::clearInstancePool(); StudentDisapprovedCourseSubjectPeer::clearInstancePool(); ################################ $pager->setPage($pager->getPage() + 1); $pager->init(); } unset($pager); unset($c); }
/** * This method back the period to last one. */ public function backPeriod() { if ($this->getCurrentPeriod() == 1) { return null; } $con = Propel::getConnection(); $con->beginTransaction(); try { $c = new Criteria(); $c->add(CourseSubjectStudentMarkPeer::MARK_NUMBER, $this->getCurrentPeriod() - 1); $c->addJoin(CourseSubjectStudentMarkPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID); $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID); $c->add(CourseSubjectPeer::COURSE_ID, $this->getId()); $course_subject_students_marks = CourseSubjectStudentMarkPeer::doSelect($c); foreach ($course_subject_students_marks as $course_subject_student_mark) { $course_subject_student_mark->setIsClosed(false); $course_subject_student_mark->save($con); //Seleccionamos todos los StudentDisapprovedCourseSubjec y StudentApprovedCourseSubject si es que tiene y los borramos $c = new Criteria(); $c->add(StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, $course_subject_student_mark->getCourseSubjectStudentId()); StudentDisapprovedCourseSubjectPeer::doDelete($c); //eliminando StudentApprovedCourseSubject $c = new Criteria(); $course_subject_student = CourseSubjectStudentPeer::retrieveByPK($course_subject_student_mark->getCourseSubjectStudentId()); $c->add(StudentApprovedCourseSubjectPeer::STUDENT_ID, $course_subject_student->getStudentId()); $c->add(StudentApprovedCourseSubjectPeer::COURSE_SUBJECT_ID, $course_subject_student->getCourseSubjectId()); StudentApprovedCourseSubjectPeer::doDelete($c); } $this->setCurrentPeriod($this->getCurrentPeriod() - 1); $this->setIsClosed(false); $this->save($con); $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } }
public function getStudentDisapprovedCourseSubject() { $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear(SchoolYearPeer::retrieveCurrent()); if (!is_null($last_year_school_year)) { $criteria = new Criteria(); $criteria->addJoin(CourseSubjectStudentPeer::STUDENT_ID, $this->getId()); $criteria->addJoin(StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID); $criteria->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID); $criteria->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID); $criteria->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID); $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $last_year_school_year->getId()); return StudentDisapprovedCourseSubjectPeer::doSelect($criteria); } }
public function getLastStudentDisapprovedCourseSubject() { $c = new Criteria(); $c->add(StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, $this->getId()); $c->addDescendingOrderByColumn(StudentDisapprovedCourseSubjectPeer::EXAMINATION_NUMBER); return StudentDisapprovedCourseSubjectPeer::doSelectOne($c); }