public function __construct($css)
 {
     $this->css = $css;
     $this->approved = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($this->css);
     $this->school_year = $this->css->getCourseSubject()->getCareerSubjectSchoolYear()->getSchoolYear();
     $this->approvationInstance = null;
     $this->orientation = $this->css->getCourseSubject()->getCareerSubject()->getOrientation();
     $this->sub_orientation = $this->css->getCourseSubject()->getCareerSubject()->getSubOrientation();
     $this->option = $this->css->getCourseSubject()->getCareerSubject()->getIsOption();
 }
 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);
             }
         }
     }
 }
 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;
     }
 }
Beispiel #6
0
    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) : '&nbsp';
 /**
  * This method back the prev status, ONE of this:
  *
  * IF the student has approved the career subject. This method then is going to delete the StudentApprovedCareerSubject    * For this student and course_subject.
  *
  * IF the student has repproved the course_subject, this method is going to delete the last                                * student_examination_repproved_subject
  *
  * If the student has course_subject_student_examination, this method is going to delete the last one
  *
  * If the student has the course_result (Approved or disapproved), this method is going to delete this
  */
 public function backToPreviousCourseSubjectStatus(PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     try {
         $con->beginTransaction();
         $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($this);
         if (!is_null($student_approved_career_subject)) {
             $student_approved_career_subject->delete($con);
         }
         //IF exists course_subject_student_examination
         if ($this->countCourseSubjectStudentExaminations()) {
             $course_subject_student_examination = $this->getLastCourseSubjectStudentExamination();
             $course_subject_student_examination->delete($con);
         } else {
             //IF Exist course result
             $course_result = $this->getCourseResult();
             if (!is_null($course_result)) {
                 $course_result->delete($con);
             }
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }