public static function retrieveByCourseSubjectStudentExamination(CourseSubjectStudentExamination $course_subject_student_examination, $con = null) { $criteria = new Criteria(); $criteria->add(self::CAREER_SUBJECT_SCHOOL_YEAR_ID, $course_subject_student_examination->getCourseSubject()->getCareerSubjectSchoolYearId()); $criteria->addJoin(self::EXAMINATION_ID, ExaminationPeer::ID); $criteria->add(ExaminationPeer::EXAMINATION_NUMBER, $course_subject_student_examination->getExaminationNumber()); $criteria->add(ExaminationPeer::SCHOOL_YEAR_ID, $course_subject_student_examination->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear()->getId()); return self::doSelectOne($criteria, $con); }
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); } } }
public function saveExaminationSubjectStudentList($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (!isset($this->widgetSchema['examination_subject_student_list'])) { // somebody has unset this widget return; } if (is_null($con)) { $con = Propel::getConnection(); } $con->beginTransaction(); try { $values = $this->getValue('examination_subject_student_list'); foreach ($this->getObject()->getCourseSubjectStudentExaminations() as $csse) { if (!is_array($values)) { $values = array(); } if (!in_array($csse->getStudent()->getId(), $values)) { $csse->delete($con); } else { unset($values[array_search($csse->getStudent()->getId(), $values)]); } } if (is_array($values)) { foreach ($values as $student_id) { $course_subject_student_examination = new CourseSubjectStudentExamination(); $course_subject_student_examination->setExaminationSubject($this->getObject()); $course_subject_student_examination->setExaminationNumber($this->getObject()->getExamination()->getExaminationNumber()); $course_subject_student = CourseSubjectStudentPeer::retrieveByCareerSubjectSchoolYearAndStudent($this->getObject()->getCareerSubjectSchoolYear(), $student_id); $course_subject_student_examination->setCourseSubjectStudent($course_subject_student); $course_subject_student_examination->save($con); } } $con->commit(); } catch (Exception $e) { $con->rollBack(); throw $e; } }
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); } } }
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() >= $this->getExaminationNote()) { $result = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student, $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear()); if (is_null($result)) { $result = new StudentApprovedCareerSubject(); $result->setCareerSubject($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject()); $result->setStudent($course_subject_student->getStudent()); $result->setSchoolYear($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear()); } $examination_subject = $course_subject_student_examination->getExaminationSubject(); // IF is null, is because the course_subject_student_examination has been created editing student history $school_year = is_null($examination_subject) ? $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear() : $examination_subject->getExamination()->getSchoolYear(); $result->setSchoolYearId($school_year->getId()); $average = $this->getAverage($course_subject_student, $course_subject_student_examination); $average = sprintf('%.4s', $average); if ($average < 4) { $average = 4; } // se guarda la NOTA FINAL de la materia if ($course_subject_student_examination->getExaminationNumber() == self::FEBRUARY) { $this->setFebruaryApprovedResult($result, $average, $course_subject_student_examination->getMark()); } else { $result->setMark($average); } ##se agrega en la tupla student_disapproved_course_subject el link a al resultado final $course_subject_student->getCourseResult()->setStudentApprovedCareerSubject($result)->save($con); $result->save($con); // verifica si hay creada una tupla de previa de esta materia que no corresponde porque el alumno aprobo en mesas regulares. // Si la encuentra la borra ya que no corresponde que exista $srcs = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student); if ($srcs && is_null($srcs->getStudentApprovedCareerSubject())) { $srcs->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)) { $this->nextCourseSubjectStudentExamination($course_subject_student_examination, $con); } else { // se crea una previa $srcs = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student); if (!$srcs && is_null($srcs->getStudentApprovedCareerSubject())) { $student_repproved_course_subject = new StudentRepprovedCourseSubject(); $student_repproved_course_subject->setCourseSubjectStudentId($course_subject_student->getId()); $student_repproved_course_subject->save($con); } } } }
public function getExaminationResult(CourseSubjectStudentExamination $css_examination) { if ($css_examination->getMark()) { if ($css_examination->getMark() < self::EXAMINATION_NOTE) { if ($css_examination->getExaminationNumber() < count($this->_examination_number)) { if ($css_examination->getMark() < self::MIN_NOTE && $css_examination->getExaminationNumber() == self::NOVEMBER) { $current = $this->_examination_number[$css_examination->getExaminationNumber()]; $next = $this->_examination_number[$css_examination->getExaminationNumber() + 2]; return array(strtolower($current), $next); } else { $current = $this->_examination_number[$css_examination->getExaminationNumber()]; $next = $this->_examination_number[$css_examination->getExaminationNumber() + 1]; return array(strtolower($current), $next); } } else { return array(strtolower($this->_examination_number[$css_examination->getExaminationNumber()]), "Previous"); } } else { return array("approved", "Approved"); } } else { return array("absent", $css_examination->getExaminationNumber() < count($this->_examination_number) ? $this->_examination_number[$css_examination->getExaminationNumber() + 1] : "Previous"); } }
public function getExaminationResult(CourseSubjectStudentExamination $css_examination) { if ($css_examination->getMark()) { if ($css_examination->getMark() < $this->getExaminationNote()) { if ($css_examination->getExaminationNumber() < count($this->_examination_number)) { $current = $this->_examination_number[$css_examination->getExaminationNumber()]; $next = $this->_examination_number[$css_examination->getExaminationNumber() + 1]; return array(strtolower($current), $next); } else { return array(strtolower($this->_examination_number[$css_examination->getExaminationNumber()]), "Previous"); } } else { return array("approved", "Approved"); } } else { return array("absent", $css_examination->getExaminationNumber() < count($this->_examination_number) ? $this->_examination_number[$css_examination->getExaminationNumber() + 1] : "Previous"); } }