public function configure()
 {
     $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this);
     $this->getWidgetSchema()->addFormFormatter('Revisited', $sf_formatter_revisited);
     $this->getWidgetSchema()->setFormFormatterName('Revisited');
     unset($this['created_at'], $this['evaluation_method'], $this['course_required'], $this['final_examination_required'], $this['course_type']);
     //Widget schema
     $this->getWidgetSchema()->setLabels(array('course_marks' => 'Cantidad de Notas', 'final_examination_required' => 'Examen final requerido', 'course_required' => 'Cursada requerida', 'course_minimun_mark' => 'Nota mínima de aprobacion', 'course_examination_count' => 'Numero de mesas', 'max_disciplinary_sanctions' => 'Cantidad máxima de sanciones'));
     $choices = SchoolBehaviourFactory::getInstance()->getAttendanceTypeChoices();
     $this->setWidget('attendance_type', new sfWidgetFormChoice(array('choices' => $choices, 'expanded' => true)));
     $this->setValidator('attendance_type', new sfValidatorChoice(array('choices' => array_keys($choices))));
     $course_type_choices = SchoolBehaviourFactory::getInstance()->getCourseTypeChoices();
     $this->setWidget('course_type', new sfWidgetFormChoice(array('choices' => $course_type_choices)));
     $this->setValidator('course_type', new sfValidatorChoice(array('choices' => array_keys($course_type_choices), 'required' => true)));
     $choice = array('1' => 'Numerica', '0' => 'Con letras');
     //SchoolBehaviourFactory::getInstance()->getAttendanceTypeChoices();
     $this->setWidget('numerical_mark', new sfWidgetFormChoice(array('choices' => $choice)));
     $this->setValidator('numerical_mark', new sfValidatorChoice(array('choices' => array_keys($choice), 'required' => true)));
     $this->widgetSchema->setLabel('numerical_mark', 'Tipo de Nota');
     $this->setWidget('when_disapprove_show_string', new sfWidgetFormChoice(array('choices' => array(0 => 'Muestra texto', 1 => 'Muestra numero'), 'multiple' => false, 'expanded' => true)));
     $this->getWidget('when_disapprove_show_string')->setDefault($this->getObject()->getWhenDisapproveShowString());
     $this->setValidator('when_disapprove_show_string', new sfValidatorChoice(array('required' => true, 'choices' => array(0, 1))));
     $this->setWidget('necessary_student_approved_career_subject_to_show_prom_def', new sfWidgetFormChoice(array('choices' => array(0 => 'Muestra', 1 => 'No muestra'), 'multiple' => false, 'expanded' => true)));
     $this->getWidget('necessary_student_approved_career_subject_to_show_prom_def')->setDefault($this->getObject()->getNecessaryStudentApprovedCareerSubjectToShowPromDef());
     $this->setValidator('necessary_student_approved_career_subject_to_show_prom_def', new sfValidatorChoice(array('required' => true, 'choices' => array(0, 1))));
     $this->widgetSchema->setHelp('attendance_type', 'Se define el tipo de asistencia que tendran las materias.');
     $this->widgetSchema->setHelp('course_marks', 'Cantidad de notas de un alumno dentro de la cursada.');
     $this->widgetSchema->setHelp('final_examination_required', 'Indica si un alumno necesita un examen final luego de aprobar la cursada para tener aprobada la materia.');
     $this->widgetSchema->setHelp('course_required', 'Indica si la cursada es requerida o en caso negativo se puede rendir el final sin tener la cursada previamente aprobada.');
     $this->widgetSchema->setHelp('course_minimun_mark', 'Nota minima de aprobacion del curso.');
     $this->widgetSchema->setHelp('course_examination_count', 'Cantidad de mesas para que un alumno pueda aprobar la cursada.');
     $this->widgetSchema->setHelp('max_previous', 'Superado este número, el alumno debe repetir el año.');
     $this->widgetSchema->setHelp('max_disciplinary_sanctions', 'Superado este número, el alumno debe quedar libre.');
     $this->widgetSchema->setHelp('numerical_mark', 'Indica si las notas seran asignadas con números o letras.');
     $max_course_minimun_mark = SubjectConfigurationPeer::getMaxCourseMinimunMark();
     $min_course_minimun_mark = SubjectConfigurationPeer::getMinCourseMinuminMark();
     $this->validatorSchema["course_marks"]->setOption("min", 1);
     $this->validatorSchema["course_marks"]->setOption("max", 10);
     $this->validatorSchema["course_marks"]->setMessage("min", "La cantidad de calificaciones debe ser mayor que %min%");
     $this->validatorSchema["course_marks"]->setMessage("max", "La cantidad de calificaciones debe ser menor que %max%");
     $this->validatorSchema["course_minimun_mark"]->setOption("min", $min_course_minimun_mark);
     $this->validatorSchema["course_minimun_mark"]->setOption("max", $max_course_minimun_mark);
     $this->validatorSchema["course_minimun_mark"]->setMessage("min", "La nota mínima de aprobación de cursada debe ser mayor que %min%");
     $this->validatorSchema["course_minimun_mark"]->setMessage("max", "La nota maxima de aprobación de cursada debe ser menor que %max%");
     $this->configureCareerYearConfigurations();
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'checkYearConfiguration'))));
 }
Пример #2
0
 /**
  * Returns the maximum course examination count. This is given by the configuration.
  *
  * @return integer
  */
 public function getMaxCourseExaminationCount()
 {
     $c = new Criteria();
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $this->getId());
     $c->addJoin(CareerSchoolYearPeer::SUBJECT_CONFIGURATION_ID, SubjectConfigurationPeer::ID);
     $c->addDescendingOrderByColumn(SubjectConfigurationPeer::COURSE_EXAMINATION_COUNT);
     $career_conf = SubjectConfigurationPeer::doSelectOne($c);
     if (is_null($career_conf)) {
         return 0;
     }
     $c = new Criteria();
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $this->getId());
     $c->addJoin(CareerSchoolYearPeer::ID, CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID);
     $c->addJoin(CareerSubjectSchoolYearPeer::SUBJECT_CONFIGURATION_ID, SubjectConfigurationPeer::ID);
     $c->addDescendingOrderByColumn(SubjectConfigurationPeer::COURSE_EXAMINATION_COUNT);
     $subject_conf = SubjectConfigurationPeer::doSelectOne($c);
     if (is_null($subject_conf)) {
         return $career_conf->getCourseExaminationCount();
     } else {
         return max($career_conf->getCourseExaminationCount(), $subject_conf->getCourseExaminationCount());
     }
 }