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);
         }
     }
 }
コード例 #2
0
 public function closeStudentExaminationRepprovedSubject(StudentExaminationRepprovedSubject $student_examination_repproved_subject, PropelPDO $con)
 {
     if ($student_examination_repproved_subject->getMark() >= $this->getExaminationNote()) {
         $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());
         if ($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getExaminationType() == ExaminationRepprovedType::REPPROVED) {
             //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;
             }
             $student_approved_career_subject->setMark($average);
         } else {
             //Final calification is the mark of student_examination_repproved_subject
             $student_approved_career_subject->setMark($student_examination_repproved_subject->getMark());
         }
         $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 saveStudentList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['student_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     foreach ($this->getObject()->getStudentExaminationRepprovedSubjects() as $sr) {
         $sr->delete($con);
     }
     $values = $this->getValue('student_list');
     if (is_array($values)) {
         $con->beginTransaction();
         try {
             foreach ($values as $value) {
                 $student_repproved = StudentRepprovedCourseSubjectPeer::retrieveByCareerSubjectIdAndStudentId($this->getObject()->getCareerSubjectId(), $value);
                 $student_examination_repproved_subject = new StudentExaminationRepprovedSubject();
                 $student_examination_repproved_subject->setStudentRepprovedCourseSubject($student_repproved);
                 $student_examination_repproved_subject->setExaminationRepprovedSubject($this->getObject());
                 $student_examination_repproved_subject->save($con);
             }
             $con->commit();
         } catch (Exception $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }
コード例 #4
0
 public function getAvailableForExaminationRepprovedSubject(ExaminationRepprovedSubject $examination_repproved_subject)
 {
     return StudentRepprovedCourseSubjectPeer::doSelect(self::getAvailableForExaminationRepprovedSubjectCriteria($examination_repproved_subject));
 }
コード例 #5
0
 /**
  * Returns the available students for the given examination repproved subject.
  *
  * @param ExaminationRepprovedSubject $examination_repproved_subject
  * @return array
  */
 public function getAvailableStudentsForExaminationRepprovedSubject(ExaminationRepprovedSubject $examination_repproved_subject)
 {
     $c = new Criteria();
     $c->add(StudentRepprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL);
     $c->addJoin(StudentRepprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID);
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
     $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, $examination_repproved_subject->getCareerSubjectId());
     return StudentRepprovedCourseSubjectPeer::doSelect($c);
 }
コード例 #6
0
ファイル: myUser.class.php プロジェクト: nvidela/kimkelen
 public function canCreateExaminationRepprovedSubject()
 {
     $school_year = SchoolYearPeer::retrieveByPK($this->getReferenceFor("schoolyear"));
     return $school_year->getIsActive() && StudentRepprovedCourseSubjectPeer::doCount(new Criteria()) > 0;
 }
コード例 #7
0
 /**
  * This method check the conditions of repetition of a year.
  *
  * @param Student $student
  * @param StudentCareerSchoolYear $student_career_school_year
  * @return boolean
  */
 public function checkRepeationCondition(Student $student, StudentCareerSchoolYear $student_career_school_year)
 {
     //IF the current year is the last year of the career.
     if ($student_career_school_year->isLastYear()) {
         return false;
     }
     $career_school_year = $student_career_school_year->getCareerSchoolYear();
     //If previous count > than max count of previous allowed, then the student repeats
     $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student, $student_career_school_year->getCareerSchoolYear()->getCareer());
     return $previous > $career_school_year->getSubjectConfiguration()->getMaxPrevious();
 }
コード例 #8
0
 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;
 }
コード例 #9
0
ファイル: SchoolYear.php プロジェクト: nvidela/kimkelen
 public function getMessageCantExaminationRepproved()
 {
     if (!$this->getIsActive()) {
         return "The school year is not active";
     } elseif (StudentRepprovedCourseSubjectPeer::doCount(new Criteria()) <= 0) {
         return "No students to take examination repproved";
     }
 }
コード例 #10
0
 public function getExaminationNoteForStudent($student)
 {
     $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveByCareerSubjectIdAndStudentId($this->getCareerSubject()->getId(), $student->getId());
     $c = new Criteria();
     $c->add(StudentExaminationRepprovedSubjectPeer::STUDENT_REPPROVED_COURSE_SUBJECT_ID, $student_repproved_course_subject->getId());
     $c->add(StudentExaminationRepprovedSubjectPeer::EXAMINATION_REPPROVED_SUBJECT_ID, $this->getId());
     return StudentExaminationRepprovedSubjectPeer::doSelectOne($c);
 }
コード例 #11
0
ファイル: CourseSubject.php プロジェクト: nvidela/kimkelen
 public function pathwayClose(PropelPDO $con)
 {
     foreach ($this->getCourseSubjectStudentPathways() as $course_subject_student_pathway) {
         $evaluator_instance = SchoolBehaviourFactory::getEvaluatorInstance();
         if ($course_subject_student_pathway->getMark() >= $evaluator_instance->getPathwayPromotionNote()) {
             $original_course_subject_student = $course_subject_student_pathway->getRelatedCourseSubjectStudent();
             //$final_mark = $course_subject_student_pathway->getMark();
             $course_marks_avg = SchoolBehaviourFactory::getEvaluatorInstance()->getMarksAverage($original_course_subject_student, $con);
             $final_mark = bcdiv($course_subject_student_pathway->getMark() + $course_marks_avg, 2, 2);
             $sacs = new StudentApprovedCareerSubject();
             $sacs->setCareerSubject($this->getCareerSubjectSchoolYear()->getCareerSubject());
             $sacs->setMark($final_mark);
             $sacs->setStudent($course_subject_student_pathway->getStudent());
             $sacs->setSchoolYear($this->getCourse()->getSchoolYear());
             $original_course_subject_student->getCourseResult()->setStudentApprovedCareerSubject($sacs);
             $original_course_subject_student->save($con);
             $srcs = StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($original_course_subject_student);
             if (is_null($srcs)) {
                 $srcs = new StudentRepprovedCourseSubject();
                 $srcs->setCourseSubjectStudent($original_course_subject_student);
             }
             $srcs->setStudentApprovedCareerSubject($sacs);
             $srcs->save($con);
             $sers = StudentExaminationRepprovedSubjectPeer::retrieveByStudentRepprovedCourseSubject($srcs);
             // TODO: pongo en blanco la referencia a una mesa de previa??
             if (is_null($sers)) {
                 $sers = new StudentExaminationRepprovedSubject();
                 $sers->setStudentRepprovedCourseSubject($srcs);
             }
             $sers->setMark($course_subject_student_pathway->getMark());
             $sers->setExaminationRepprovedSubject(null);
             $sers->save($con);
         }
     }
 }
コード例 #12
0
 public function saveExaminationRepprovedSubjectStudentList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['examination_repproved_subject_student_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     $con->beginTransaction();
     try {
         $values = $this->getValue('examination_repproved_subject_student_list');
         foreach ($this->getObject()->getStudentExaminationRepprovedSubjects() as $sers) {
             if (!is_array($values)) {
                 $values = array();
             }
             if (!in_array($sers->getStudent()->getId(), $values)) {
                 $sers->delete($con);
             } else {
                 unset($values[array_search($sers->getStudent()->getId(), $values)]);
             }
         }
         $career_subject_id = $this->getObject()->getCareerSubjectId();
         if (is_array($values)) {
             foreach ($values as $student_id) {
                 $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveByCareerSubjectIdAndStudentId($career_subject_id, $student_id);
                 $student_examination_repproved_subject = new StudentExaminationRepprovedSubject();
                 $student_examination_repproved_subject->setExaminationRepprovedSubject($this->getObject());
                 $student_examination_repproved_subject->setStudentRepprovedCourseSubject($student_repproved_course_subject);
                 $student_repproved_course_subject->save($con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #13
0
ファイル: Student.php プロジェクト: nvidela/kimkelen
 public function getCountStudentRepprovedCourseSubject()
 {
     $c = new Criteria();
     $c->addJoin(StudentRepprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID);
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getId());
     $c->add(StudentRepprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL);
     return StudentRepprovedCourseSubjectPeer::doCount($c);
 }
コード例 #14
0
 public function repprovedCourseSubjectHasBeenApproved()
 {
     $c = new Criteria();
     $c->add(StudentRepprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, $this->getId());
     $c->add(StudentRepprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNOTNULL);
     $c->addJoin(StudentRepprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, StudentApprovedCareerSubjectPeer::ID);
     return StudentRepprovedCourseSubjectPeer::doSelectOne($c);
 }