public function configureMarks() { $fields = array(); $i = 1; foreach ($this->getObject()->getSortedCourseSubjectStudentMarks() as $cssm) { $name = 'mark_' . $cssm->getId(); $fields[] = $name; $configuration = $this->getObject()->getConfiguration(); if ($this->canEditMarks()) { if ($configuration->isNumericalMark()) { $this->setWidget($name, new sfWidgetFormInput()); $this->setValidator($name, new sfValidatorInteger(array('required' => false))); $this->setDefault($name, $cssm->getMark()); $this->getWidgetSchema()->setHelp($name, 'Mark should de 0 (zero) if you want the student to be free at this period'); } else { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $cssm->getMark()); if (is_null($letter_mark)) { $letter = null; } else { $letter = $letter_mark->getId(); } $this->setWidget($name, new sfWidgetFormPropelChoice(array('model' => 'LetterMark', 'add_empty' => true, 'default' => $letter))); $this->setValidator($name, new sfValidatorPropelChoice(array('model' => 'LetterMark', 'required' => false))); } } else { $this->setWidget($name, new mtWidgetFormPlain(array('object' => $cssm, 'method' => 'getMarkByConfig', 'method_args' => $configuration, 'add_hidden_input' => true))); $this->setValidator($name, new sfValidatorInteger(array('required' => false))); $this->setDefault($name, $cssm->getMark()); } $this->getWidget($name)->setLabel(__('Mark %number%', array('%number%' => $i))); $i++; } return $fields; }
public function configure() { $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this); $this->getWidgetSchema()->addFormFormatter('Revisited', $sf_formatter_revisited); $this->getWidgetSchema()->setFormFormatterName('Revisited'); unset($this['student_repproved_course_subject_id'], $this["examination_repproved_subject_id"]); $configuration = $this->getObject()->getStudentRepprovedCourseSubject()->getCourseSubjectStudent()->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration(); if (!$this->getObject()->getExaminationRepprovedSubject()->canEditCalifications()) { unset($this["is_absent"]); $this->widgetSchema["mark"] = new mtWidgetFormPlain(array('object' => $this->getObject(), 'method' => 'getMarkStrByConfig', "empty_value" => "Is absent", 'method_args' => $configuration, 'add_hidden_input' => false), array('class' => 'mark')); } else { $this->widgetSchema->setHelp("mark", "Enter student's mark or mark him as absent."); if (!$configuration->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $this->getObject()->getMark()); $this->setWidget('mark', new sfWidgetFormPropelChoice(array('model' => 'LetterMark', 'add_empty' => true))); if (!is_null($letter_mark)) { $this->setDefault('mark', $letter_mark->getId()); } $this->setValidator('mark', new sfValidatorPropelChoice(array('model' => 'LetterMark', 'required' => false))); } else { $behavior = SchoolBehaviourFactory::getEvaluatorInstance(); $this->validatorSchema["mark"]->setOption("min", $behavior->getMinimumMark()); $this->validatorSchema["mark"]->setOption("max", $behavior->getMaximumMark()); $this->validatorSchema["mark"]->setMessage("min", "Mark should be at least %min%."); $this->validatorSchema["mark"]->setMessage("max", "Mark should be at most %max%."); } } $this->widgetSchema->setLabel("mark", $this->getObject()->getStudentRepprovedCourseSubject()->getStudent()); $this->validatorSchema->setPostValidator(new sfValidatorCallback(array("callback" => array($this, "validateAbsence")))); }
public function getResult($with_mark = true) { $career_subject = CareerSubjectSchoolYearPeer::retrieveByCareerSubject($this->getCareerSubject()); $config = $career_subject->getConfiguration(); if ($config != null && !$config->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $this->getMark()); $mark = $letter_mark->getLetter(); } else { $mark = $this->getMark(); } return $with_mark ? 'Aprobado ' . $mark : 'Aprobado'; }
public function getMarkStrByConfig($config = null) { if (is_null($config)) { $config = $this->getStudentRepprovedCourseSubject()->getCourseSubjectStudent()->getCourseSubject()->getCareerSubjectSchoolYear()->getSubjectConfiguration(); } if (!is_null($config) && !$config->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue($this->getMark()); return $letter_mark->getLetter(); } else { return $this->getMark(); } }
public function configure() { $widgets = array(); $validators = array(); $options = array('min' => $this->getMinimumMark(), 'max' => $this->getMaximumMark(), 'required' => false); $messages = array('min' => 'La calificación debe ser al menos %min%.', 'max' => 'La calificación debe ser a lo sumo %max%.', 'invalid' => 'El valor ingresado es inválido, solo se aceptan numeros enteros.'); $this->disableCSRFProtection(); $tmp_sum = 0; $configuration = $this->object->getCareerSubjectSchoolYear()->getConfiguration(); foreach ($this->object->getCourseSubjectStudents() as $course_subject_student) { foreach ($course_subject_student->getAvailableCourseSubjectStudentMarks() as $course_subject_student_mark) { $widget_name = $course_subject_student->getId() . '_' . $course_subject_student_mark->getMarkNumber(); if ($course_subject_student_mark->getIsClosed()) { $widgets[$widget_name] = new mtWidgetFormPlain(array('object' => $course_subject_student_mark, 'method' => 'getMarkByConfig', 'method_args' => $configuration, 'add_hidden_input' => false), array('class' => 'mark')); $widgets[$widget_name]->setAttribute('class', 'mark_note'); } else { if ($configuration->isNumericalMark()) { $widgets[$widget_name] = new sfWidgetFormInput(array('default' => $course_subject_student_mark->getMark()), array('class' => 'mark')); $validators[$widget_name] = new sfValidatorInteger($options, $messages); } else { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $course_subject_student_mark->getMark()); if (!is_null($letter_mark)) { $this->setDefault($widget_name, $letter_mark->getId()); } $widgets[$widget_name] = new sfWidgetFormPropelChoice(array('model' => 'LetterMark', 'add_empty' => true)); $validators[$widget_name] = new sfValidatorPropelChoice(array('model' => 'LetterMark', 'required' => false)); } //IS FREE $free_widget_name = $course_subject_student->getId() . '_free_' . $course_subject_student_mark->getMarkNumber(); $name = 'course_student_mark_' . $this->getObject()->getId() . '_' . $widget_name; $name_free_element = 'course_student_mark_' . $this->getObject()->getId() . '_' . $free_widget_name; $widgets[$free_widget_name] = new sfWidgetFormInputCheckbox(array('default' => $course_subject_student_mark->getIsFree()), array('onChange' => "free_mark('{$name_free_element}','{$name}');")); if ($course_subject_student_mark->getIsFree()) { $widgets[$widget_name]->setAttribute('style', 'display:none'); } $validators[$free_widget_name] = new sfValidatorBoolean(); } $tmp_sum = $this->evaluationFinalProm($course_subject_student, $course_subject_student_mark, $tmp_sum); } $tmp_sum = 0; } $this->setWidgets($widgets); $this->setValidators($validators); $this->widgetSchema->setNameFormat('course_student_mark[' . $this->object->getId() . '][%s]'); }
public function getMarkByConfig($config = null) { if (is_null($config)) { $config = $this->getCourseSubjectStudent()->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration(); } if ($this->getMark() != 0) { if (!is_null($config) && !$config->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $this->getMark()); return $letter_mark->getLetter(); } else { return $this->getMark(); } } elseif ($this->getIsFree()) { return "Libre"; } else { return $this->getMark(); } }
public static function getLetterMarkAverageByCourseSubjectStudent($course_subject_student) { for ($i = 1; $i <= $course_subject_student->getConfiguration()->getCourseMarks(); $i++) { $marks[$i] = LetterMarkPeer::getLetterMarkByValue($course_subject_student->getMarkFor($i)->getMark()); } $criteria = new Criteria(); if (array_key_exists(1, $marks) && !is_null($marks[1])) { $criteria->add(LetterMarkAveragePeer::LETTER_MARK_1, $marks[1]->getId()); } else { $criteria->add(LetterMarkAveragePeer::LETTER_MARK_1, null, Criteria::ISNULL); } if (array_key_exists(2, $marks) && !is_null($marks[2])) { $criteria->add(LetterMarkAveragePeer::LETTER_MARK_2, $marks[2]->getId()); } else { $criteria->add(LetterMarkAveragePeer::LETTER_MARK_2, null, Criteria::ISNULL); } if (array_key_exists(3, $marks) && !is_null($marks[3])) { $criteria->add(LetterMarkAveragePeer::LETTER_MARK_3, $marks[3]->getId()); } else { $criteria->add(LetterMarkAveragePeer::LETTER_MARK_3, null, Criteria::ISNULL); } $result = LetterMarkAveragePeer::doSelectOne($criteria); return $result; }
public function getMarkStrByConfig($config = null) { if ($this->getIsAbsent()) { return __('A'); } else { if (is_null($config)) { $config = $this->getExaminationSubject()->getCareerSubjectSchoolYear()->getConfiguration(); } if ($this->getMark() != SchoolBehaviourFactory::getEvaluatorInstance()->getMinimumMark()) { if (!is_null($config) && !$config->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue($this->getMark()); return $letter_mark->getLetter(); } else { return $this->getMark(); } } } }
public function getMarkByConfig($config = null) { if ($config != null && !$config->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $this->getMark()); if (!is_null($letter_mark)) { return $letter_mark->getLetter(); } } else { return sprintf("%01.2f", $this->getMark()); } }
public function getPromDef($course_result) { if (is_null($course_result)) { return ''; } $config = $course_result->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration(); if ($course_result instanceof StudentApprovedCourseSubject) { if ($course_result->getCareerSchoolYear()->getSubjectConfiguration()->getNecessaryStudentApprovedCareerSubjectToShowPromDef()) { if ($config != null && !$config->isNumericalMark()) { $mark = $course_result->getStudentApprovedCareerSubject() ? $course_result->getStudentApprovedCareerSubject()->getMark() : $course_result->getMark(); $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $mark); if (!is_null($letter_mark)) { return $letter_mark->getLetter(); } } else { return ($student_approved_career_subject = $course_result->getStudentApprovedCareerSubject()) ? number_format($student_approved_career_subject->getMark(), 2, '.', '') : ' '; } } else { if ($config != null && !$config->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $course_result->getMark()); if (!is_null($letter_mark)) { return $letter_mark->getLetter(); } } else { return number_format($course_result->getMark(), 2, '.', ''); } } } else { if ($config != null && !$config->isNumericalMark()) { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $course_result->getStudentApprovedCareerSubject()->getMark()); return $letter_mark->getLetter(); } else { return $course_result->getStudentApprovedCareerSubject() ? number_format($course_result->getStudentApprovedCareerSubject()->getMark(), 2, '.', '') : ' '; } } }
/** * Returns the final mark for this course subject student. * If the course subject student is approved, returns the student approved * career subject (final mark). If not, returns the marks average. * * @return integer */ public function getFinalMark() { if (!$this->areAllMarksClosed() || $this->getIsNotAverageable()) { return ''; } $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveByCourseSubjectStudent($this); $config = $this->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration(); if ($config != null && !$config->isNumericalMark()) { if (!is_null($student_approved_career_subject)) { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $student_approved_career_subject->getMark()); } else { $letter_mark = LetterMarkPeer::getLetterMarkByValue((int) $this->getMarksAverage()); } if (!is_null($letter_mark)) { return $letter_mark->getLetter(); } } else { return $student_approved_career_subject ? $student_approved_career_subject->getMark() : $this->getMarksAverage(); } }