public static function retrieveByStudentAndCareerSubject($student, $career_subject, $criteria = null) { if (is_null($criteria)) { $criteria = new Criteria(); } $criteria->add(StudentApprovedCareerSubjectPeer::CAREER_SUBJECT_ID, $career_subject->getId()); $criteria->add(StudentApprovedCareerSubjectPeer::STUDENT_ID, $student->getId()); return StudentApprovedCareerSubjectPeer::doSelectOne($criteria); }
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 process() { $this->student_career_school_years = $this->get_student()->getStudentCareerSchoolYears(); //Deberia recorrer todos los "scsy" y recuperar por c/año las materias $this->init(); $avg_mark_for_year = array(); foreach ($this->student_career_school_years as $scsy) { //Si no repitio el año lo muestro en el analitico - Ver que pasa cuando se cambia de escuela y repite el ultimo año //Siempre tomo el año "Aprobado" y "Cursando" if ($scsy->getStatus() == 1) { $year_in_career = $scsy->getYear(); $this->add_year_in_career($year_in_career); $career_school_year = $scsy->getCareerSchoolYear(); $school_year = $career_school_year->getSchoolYear(); $approved = StudentApprovedCareerSubjectPeer::retrieveByStudentAndSchoolYear($this->get_student(), $school_year); $csss = SchoolBehaviourFactory::getInstance()->getCourseSubjectStudentsForAnalytics($this->get_student(), $school_year); foreach ($csss as $css) { if (!isset($this->objects[$year_in_career])) { // Inicialización por año $this->set_year_status($year_in_career, self::YEAR_COMPLETE); $avg_mark_for_year[$year_in_career]['sum'] = 0; $avg_mark_for_year[$year_in_career]['count'] = 0; } if ($this->subject_is_averageable($css)) { $avg_mark_for_year[$year_in_career]['sum'] += $css->getMark(); $avg_mark_for_year[$year_in_career]['count'] += $css->getMark(false) ? 1 : 0; if (!$css->getMark(false)) { // No tiene nota -> el curso está incompleto $this->set_year_status($year_in_career, self::YEAR_INCOMPLETE); $this->add_missing_subject($css); } } $this->add_subject_to_year($year_in_career, $css); $this->check_last_exam_date($css->getApprovedDate(false)); } // Cálculo del promedio por año foreach ($this->objects as $year => $data) { $this->process_year_average($year, $avg_mark_for_year[$year]['sum'], $avg_mark_for_year[$year]['count']); } $this->process_total_average($avg_mark_for_year); } else { if ($scsy->getStatus() == 0) { //recupero en año en curso $year_in_career = $scsy->getYear(); $this->add_year_in_career($year_in_career); $career_school_year = $scsy->getCareerSchoolYear(); $school_year = $career_school_year->getSchoolYear(); $csss = SchoolBehaviourFactory::getInstance()->getCourseSubjectStudentsForAnalytics($this->get_student(), $school_year); foreach ($csss as $css) { // No tiene nota -> el curso está incompleto $this->set_year_status($year_in_career, self::YEAR_INCOMPLETE); $this->add_subject_to_year($year_in_career, $css); } } } } }
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 getAvailableStudentsForExaminationSubject(ExaminationSubject $examination_subject) { $c = new Criteria(); $c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $examination_subject->getCareerSubjectSchoolYearId()); $c->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID, Criteria::INNER_JOIN); $c->addJoin(CourseSubjectStudentPeer::ID, StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, Criteria::INNER_JOIN); $c->add(CourseSubjectStudentPeer::STUDENT_APPROVED_COURSE_SUBJECT_ID, null, Criteria::ISNULL); $c->addJoin(CourseSubjectStudentPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN); $c->addJoin(CourseSubjectStudentPeer::ID, CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID, Criteria::INNER_JOIN); $c->add(CourseSubjectStudentExaminationPeer::EXAMINATION_NUMBER, $examination_subject->getExamination()->getExaminationNumber()); $c->add(CourseSubjectStudentExaminationPeer::IS_ABSENT, false); $c->addAnd(CourseSubjectStudentExaminationPeer::MARK, null, Criteria::ISNULL); //Quito los que ya la aprobaron $approved_criteria = new Criteria(); $approved_criteria->addJoin(StudentApprovedCareerSubjectPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN); $approved_criteria->add(StudentApprovedCareerSubjectPeer::CAREER_SUBJECT_ID, $examination_subject->getCareerSubjectSchoolYear()->getCareerSubjectId()); $approved_criteria->clearSelectColumns(); $approved_criteria->addSelectColumn(StudentApprovedCareerSubjectPeer::STUDENT_ID); $stmt = StudentApprovedCareerSubjectPeer::doSelectStmt($approved_criteria); $not_in = $stmt->fetchAll(PDO::FETCH_COLUMN); $c->add(StudentPeer::ID, $not_in, Criteria::NOT_IN); return StudentPeer::doSelect($c); }
public function canEditExaminationSubject() { $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($this->getObject()); if (!is_null($student_approved_career_subject)) { return false; } return $this->getObject()->countCourseSubjectStudentExaminations() > 0; //return $this->getObject()->countStudentRepprovedCourseSubjects() == 0 && $this->getObject()->countCourseSubjectStudentExaminations() > 0 ; }
/** * If the student approves examination repproved, then it creates a student_approved_career_subject for this student * * @param StudentExaminationRepprovedSubject $student_examination_repproved_subject * @param PropelPDO $con */ public function closeStudentExaminationRepprovedSubject(StudentExaminationRepprovedSubject $student_examination_repproved_subject, PropelPDO $con) { if ($student_examination_repproved_subject->getMark() >= $this->getExaminationNote()) { $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($student_examination_repproved_subject->getStudentRepprovedCourseSubject()->getCourseSubjectStudent()); if (is_null($student_approved_career_subject)) { $student_approved_career_subject = new StudentApprovedCareerSubject(); } $student_approved_career_subject->setCareerSubject($student_examination_repproved_subject->getExaminationRepprovedSubject()->getCareerSubject()); $student_approved_career_subject->setStudent($student_examination_repproved_subject->getStudent()); $student_approved_career_subject->setSchoolYear($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getSchoolYear()); $examination_type = $student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getExaminationType(); if ($examination_type == ExaminationRepprovedType::REPPROVED) { //If it is a previous examination instance, final average is the average of the course_subject_student and the mark of student_examination_repproved_subject $average = (string) (($student_examination_repproved_subject->getStudentRepprovedCourseSubject()->getCourseSubjectStudent()->getMarksAverage() + $student_examination_repproved_subject->getMark()) / 2); $average = sprintf('%.4s', $average); if ($average < self::MIN_NOTE) { $average = self::MIN_NOTE; } } else { $average = $student_examination_repproved_subject->getMark(); } $student_approved_career_subject->setMark($average); $student_repproved_course_subject = $student_examination_repproved_subject->getStudentRepprovedCourseSubject(); $student_repproved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject); $student_repproved_course_subject->save($con); $career = $student_repproved_course_subject->getCourseSubjectStudent()->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getCareer(); ##se corrobora si la previa es la última y del último año, hay que egresarlo $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student_repproved_course_subject->getStudent(), $career); if ($student_repproved_course_subject->getStudent()->getCurrentOrLastStudentCareerSchoolYear()->getYear() >= CareerPeer::getMaxYear() && $previous == 0) { $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career->getId(), $student_repproved_course_subject->getStudent()->getId()); $career_student->setStatus(CareerStudentStatus::GRADUATE); //se guarda el school_year en que termino esta carrera $career_student->setGraduationSchoolYearId(SchoolYearPeer::retrieveCurrent()->getId()); $career_student->save($con); //se guarda el estado en el student_career_school_year $scsy = $student_repproved_course_subject->getCourseSubjectStudent()->getStudent()->getCurrentOrLastStudentCareerSchoolYear(); $scsy->setStatus(StudentCareerSchoolYearStatus::APPROVED); $scsy->save(); } ##se agrega el campo en student_disapproved_course_subject a el link del resultado final $student_repproved_course_subject->getCourseSubjectStudent()->getCourseResult()->setStudentApprovedCareerSubject($student_approved_career_subject)->save($con); $student_approved_career_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 getApprovedDate($as_label = true) { if ($this->approved_date) { return $this->approved_date; } if ($this->approved) { $approvation_date = StudentApprovedCareerSubjectPeer::retrieveApprovationDate($this->approved); if ($approvation_date) { return $this->approved ? $this->approved_date = new DateTime(StudentApprovedCareerSubjectPeer::retrieveApprovationDate($this->approved)) : ($as_label ? $this->getNullLabel() : null); } } return $as_label ? $this->getNullLabel() : null; }
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(); $criteria = new Criteria(); $criteria->addJoin(CourseSubjectStudentPeer::ID, CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID); $criteria->add(CourseSubjectStudentExaminationPeer::MARK, null, Criteria::ISNOTNULL); $criteria->addAnd(CourseSubjectStudentExaminationPeer::MARK, 6, Criteria::GREATER_EQUAL); $criteria->add(CourseSubjectStudentPeer::STUDENT_ID, 728); $array_csse = CourseSubjectStudentExaminationPeer::doSelect($criteria); $connection->beginTransaction(); try { /* @var $csse CourseSubjectStudentExamination */ foreach ($array_csse as $csse) { $sacs = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($csse->getCourseSubjectStudent()); if (is_null($sacs)) { $this->closeCourseSubjectStudentExamination($csse, $connection); } } $connection->commit(); } catch (Exception $e) { $connection->rollback(); throw $e; } }
public function getApprovationDate() { return StudentApprovedCareerSubjectPeer::retrieveApprovationDate($this); }
public function isApprovedCareerSubject(CareerSubject $career_subject, Student $student) { $c = new Criteria(); $c->add(StudentApprovedCareerSubjectPeer::STUDENT_ID, $student->getId()); $c->add(StudentApprovedCareerSubjectPeer::CAREER_SUBJECT_ID, $career_subject->getId()); return StudentApprovedCareerSubjectPeer::doSelectOne($c) ? true : false; }
public function getFinalMarkForCareerSubject($career_subject_school_year) { if ($career_subject_school_year instanceof CareerSubjectSchoolYear) { $c = new Criteria(); $c->add(StudentApprovedCareerSubjectPeer::STUDENT_ID, $this->getId()); $c->add(StudentApprovedCareerSubjectPeer::CAREER_SUBJECT_ID, $career_subject_school_year->getCareerSubjectId()); return StudentApprovedCareerSubjectPeer::doSelectOne($c); } elseif ($career_subject_school_year instanceof CareerSubject) { $c = new Criteria(); $c->add(StudentApprovedCareerSubjectPeer::STUDENT_ID, $this->getId()); $c->add(StudentApprovedCareerSubjectPeer::CAREER_SUBJECT_ID, $career_subject_school_year->getId()); return StudentApprovedCareerSubjectPeer::doSelectOne($c); } else { die('Student getFinalMarkForCareerSubject not instanceOf CareerSubjectSchoolYear or CareerSubject '); } }
echo $course_result instanceof StudentDisapprovedCourseSubject && ($course_subject_student_examination = $course_subject_student->getCourseSubjectStudentExaminationsForExaminationNumber(2)) ? $course_subject_student_examination->getMarkStr() : ''; ?> </td> <td> <?php if ($is_repproved) { ?> <?php echo $course_subject_student->getFinalAvg(); ?> <?php } else { ?> <?php echo !is_null($student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student)) ? $student_approved_career_subject->getMark() : ''; ?> <?php } ?> </td> <?php if ($has_attendance_for_subject) { ?> <?php foreach ($periods as $period) { ?> <td> <?php echo $period->getIsClosed() ? round($student->getTotalAbsences($division->getCareerSchoolYearId(), $period, $course_subject_student->getCourseSubjectId(), true), 2) : ' ';
public function process() { $this->student_career_school_years = $this->get_student()->getStudentCareerSchoolYears(); //recorrer todos los "scsy" y recuperar por c/año las materias $this->init(); $avg_mark_for_year = array(); foreach ($this->student_career_school_years as $scsy) { //chequeo que la carrera no sea el ciclo basico. $career_school_year = $scsy->getCareerSchoolYear(); $career = $career_school_year->getCareer(); $school_year = $career_school_year->getSchoolYear(); if ($career->getCareerName() != 'Ciclo Básico de Formación Estética') { if ($scsy->getStatus() == StudentCareerSchoolYearStatus::APPROVED) { //tomo el año $year_in_career = $scsy->getYear(); $this->add_year_in_career($year_in_career); $approved = StudentApprovedCareerSubjectPeer::retrieveByStudentAndSchoolYear($this->get_student(), $school_year); $csss = SchoolBehaviourFactory::getInstance()->getCourseSubjectStudentsForAnalytics($this->get_student(), $school_year); foreach ($csss as $css) { if (!isset($this->objects[$year_in_career])) { // Inicialización por año $this->set_year_status($year_in_career, self::YEAR_COMPLETE); $avg_mark_for_year[$year_in_career]['sum'] = 0; $avg_mark_for_year[$year_in_career]['count'] = 0; } if ($this->subject_is_averageable($css)) { $avg_mark_for_year[$year_in_career]['sum'] += $css->getMark(); $avg_mark_for_year[$year_in_career]['count'] += $css->getMark(false) ? 1 : 0; if (!$css->getMark(false)) { // No tiene nota -> el curso está incompleto $this->set_year_status($year_in_career, self::YEAR_INCOMPLETE); $this->add_missing_subject($css); } } //si la materia no tiene orientacion ni optativas es general. if (is_null($css->getOrientation()) && !$css->getOption()) { $this->add_general_subject_to_year($year_in_career, $css); } else { //chequeo si es una asignatura optativa if ($css->getOption()) { $this->add_optional_subject_to_year($year_in_career, $css); } else { //chequeo si es propia de la especialidad / suborientacion if (is_null($css->getSubOrientation())) { $this->add_specific_subject_to_year($year_in_career, $css); } else { $this->add_suborientation_subject_to_year($year_in_career, $css); } } } $this->check_last_exam_date($css->getApprovedDate(false)); } // Cálculo del promedio por año foreach ($this->objects as $year => $data) { $this->process_year_average($year, $avg_mark_for_year[$year]['sum'], $avg_mark_for_year[$year]['count']); } $this->process_total_average($avg_mark_for_year); } else { if ($scsy->getStatus() == StudentCareerSchoolYearStatus::IN_COURSE) { //recupero en año en curso $year_in_career = $scsy->getYear(); $this->add_year_in_career($year_in_career); $csss = SchoolBehaviourFactory::getInstance()->getCourseSubjectStudentsForAnalytics($this->get_student(), $school_year); foreach ($csss as $css) { // No tiene nota -> el curso está incompleto $this->set_year_status($year_in_career, self::YEAR_INCOMPLETE); //si la materia no tiene orientacion y optativas es general. if (is_null($css->getOrientation()) && !$css->getOption()) { $this->add_general_subject_to_year($year_in_career, $css); } else { //chequeo si es una asignatura optativa if ($css->getOption()) { $this->add_optional_subject_to_year($year_in_career, $css); } else { //chequeo si es propia de la especialidad / suborientacion if (is_null($css->getSubOrientation())) { $this->add_specific_subject_to_year($year_in_career, $css); } else { $this->add_suborientation_subject_to_year($year_in_career, $css); } } } } } } $this->add_school_year_to_year($year_in_career, $school_year); $divisions = $this->get_student()->getCurrentDivisions($career_school_year->getId()); foreach ($divisions as $d) { $this->add_division_to_year($year_in_career, $d->getName()); } } } }
public function getStudentApprovedCareerSubject() { $career_subject_id = $this->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubjectId(); $c = new Criteria(); $c->add(StudentApprovedCareerSubjectPeer::STUDENT_ID, $this->getStudentId()); $c->add(StudentApprovedCareerSubjectPeer::CAREER_SUBJECT_ID, $career_subject_id); return StudentApprovedCareerSubjectPeer::doSelectOne($c); }