Exemplo n.º 1
0
 public static function countNotClosedExaminationSubjectsFor(SchoolYear $school_year, PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $c = new Criteria();
     $c->add(ExaminationPeer::SCHOOL_YEAR_ID, $school_year->getId());
     $c->addJoin(ExaminationSubjectPeer::EXAMINATION_ID, ExaminationPeer::ID);
     $c->add(ExaminationSubjectPeer::IS_CLOSED, false);
     return ExaminationSubjectPeer::doCount($c, $con);
 }
 protected function execute($arguments = array(), $options = array())
 {
     $this->createContextInstance('backend');
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $c = new Criteria();
     $c->add(CourseSubjectStudentExaminationPeer::EXAMINATION_SUBJECT_ID, null, Criteria::ISNULL);
     foreach (CourseSubjectStudentExaminationPeer::doSelect($c) as $csse) {
         $csse->setExaminationSubject(ExaminationSubjectPeer::retrieveByCourseSubjectStudentExamination($csse));
         $csse->saveForTask();
     }
     // add your code here
 }
 public function save($con = null)
 {
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     try {
         $con->beginTransaction();
         $values = $this->getValues();
         $any_change = false;
         //First check the marks
         if ($this->canEditMarks()) {
             foreach ($this->getObject()->getSortedCourseSubjectStudentMarks() as $cssm) {
                 $mark = $values['mark_' . $cssm->getId()];
                 $configuration = $this->getObject()->getConfiguration();
                 if (!$configuration->isNumericalMark()) {
                     $letter_mark = LetterMarkPeer::retrieveByPk($mark);
                     if (is_null($letter_mark)) {
                         $mark = null;
                     } else {
                         $mark = $letter_mark->getValue();
                     }
                 }
                 if ($cssm->getMark() !== $mark) {
                     $cssm->setMark($mark);
                     if ($mark == 0) {
                         $cssm->setIsFree(true);
                     } else {
                         $cssm->setIsFree(false);
                     }
                     $cssm->save($con);
                     $any_change = true;
                 }
             }
             if ($any_change && $this->getObject()->areAllMarksClosed()) {
                 //Creo de nuevo el result porque cambiaron las notas
                 $course_result = SchoolBehaviourFactory::getEvaluatorInstance()->getCourseSubjectStudentResult($this->getObject(), $con);
                 $course_result->save($con);
                 if ($course_result instanceof StudentApprovedCourseSubject) {
                     $this->getObject()->setStudentApprovedCourseSubject($course_result);
                     $this->getObject()->save($con);
                 }
                 //Si ya fue procesado el año lectivo, entonces crea si corresponde la materia aprobada o la mesa de examen
                 if ($this->getObject()->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getIsProcessed() && $this->getObject()->getCourseSubject()->getCourse()->getIsClosed()) {
                     SchoolBehaviourFactory::getEvaluatorInstance()->closeCourseSubjectStudent($course_result, $con);
                 }
             }
         }
         //if para la edición de notas en mesas de examen
         if ($this->canEditExaminationSubject()) {
             $course_subject_student_examination = $this->getObject()->getLastCourseSubjectStudentExamination();
             if (isset($values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_mark']) || isset($values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_is_absent'])) {
                 $mark = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_mark'];
                 $is_absent = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_is_absent'];
                 $date = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_date'];
                 $folio = $values['course_subject_student_examination_id_' . $course_subject_student_examination->getId() . '_folio_number'];
                 if ($mark !== $course_subject_student_examination->getMark() || $is_absent !== $course_subject_student_examination->getIsAbsent()) {
                     $course_subject_student_examination->setExaminationSubject(ExaminationSubjectPeer::retrieveByCourseSubjectStudentExamination($course_subject_student_examination));
                     $course_subject_student_examination->setMark($mark);
                     $course_subject_student_examination->setIsAbsent($is_absent);
                     $course_subject_student_examination->setDate($date);
                     $course_subject_student_examination->setFolioNumber($folio);
                     $course_subject_student_examination->save($con);
                     SchoolBehaviourFactory::getEvaluatorInstance()->closeCourseSubjectStudentExamination($course_subject_student_examination, $con);
                 }
             }
         }
         /* Esto se habia creado para las previas, pero no tiene sentido editarlas. Lo dejo comentado por si sirve para mas adelante.
               if ($this->canEditStudentRepprovedCourseSubjects())
               {
         
                 $student_repproved_course_subject = $this->getObject()->getStudentRepprovedCourseSubject();
         
                 $student_examination_repproved_subject = $student_repproved_course_subject->getLastStudentExaminationRepprovedSubject();
         
                 $mark = $values['student_examination_repproved_subject_' . $student_examination_repproved_subject->getId() .'_mark'];
                 $is_absence_name = 'student_examination_repproved_subject_' . $student_examination_repproved_subject->getId() .'_is_absent';
                 $is_absence = isset($values[$is_absence_name]) ? $values[$is_absence_name] : null;
         
                 if ($mark !== $student_examination_repproved_subject->getMark() || $is_absence !== $student_examination_repproved_subject->getIsAbsent())
                 {
                   $student_examination_repproved_subject->setMark($mark);
                   $student_examination_repproved_subject->setIsAbsence($is_absence);
                 }
               }
               */
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Exemplo n.º 4
0
 public function canCreateExamination()
 {
     $school_year = SchoolYearPeer::retrieveByPK($this->getReferenceFor("schoolyear"));
     $not_closed_examination_subjects_count = ExaminationSubjectPeer::countNotClosedExaminationSubjectsFor($school_year);
     // return $school_year->countExaminations() < $school_year->getMaxCourseExaminationCount() && $not_closed_examination_subjects_count == 0;
     return $not_closed_examination_subjects_count == 0;
 }
Exemplo n.º 5
0
 public function countExaminationsForExaminationNumber($examination_number)
 {
     $es = ExaminationSubjectPeer::retrieveForCareerSubjectSchoolYearAndExaminationNumber($this->getCareerSubjectSchoolYear(), $examination_number);
     $total = 0;
     if ($es) {
         foreach (CourseSubjectStudentExaminationPeer::doSelectForExaminationSubjectAndNumber($es, $examination_number) as $csse) {
             // Could be improved a lot...
             if ($csse->getCourseSubjectStudent()->getCourseSubject()->getCourse()->getDivision() == $this->getCourse()->getDivision()) {
                 $total++;
             }
         }
     }
     return $total;
 }
Exemplo n.º 6
0
 public function executeManageStudents(sfWebRequest $request)
 {
     $this->examination_subject = ExaminationSubjectPeer::retrieveByPk($request->getParameter('examination_subject[id]'));
     if (null === $this->examination_subject) {
         $this->examination_subject = $this->getRoute()->getObject();
         if (null === $this->examination_subject) {
             $this->getUser()->setFlash('error', 'Debe seleccionar una mesa de examen para inscribir a los estudiantes');
             $this->redirect('@manual_examination_subject');
         }
     }
     $this->form = new ManualExaminationSubjectStudentForm($this->examination_subject);
     if ($request->isMethod("post")) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $this->form->save();
             $this->getUser()->setFlash('notice', 'Los alumnos seleccionados han sido correctamente inscriptos a la mesa de examen.');
         }
     }
 }