/**
  * Add appropriate form elements to the critieria form
  *
  * @param moodle_form $mform Moodle forms object
  * @param stdClass $data containing default values to be set in the form
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
     $mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
     $mform->disabledIf('criteria_grade_value', 'criteria_grade');
     $mform->setType('criteria_grade_value', PARAM_RAW);
     // Uses unformat_float.
     $mform->setDefault('criteria_grade_value', format_float($data));
     if ($this->id) {
         $mform->setDefault('criteria_grade', 1);
         $mform->setDefault('criteria_grade_value', format_float($this->gradepass));
     }
 }
Exemplo n.º 2
0
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodle_form $mform Moodle forms object
  * @param stdClass $data containing default values to be set in the form
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
     $mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
     $mform->disabledIf('criteria_grade_value', 'criteria_grade');
     $mform->setType('criteria_grade_value', PARAM_RAW);
     // Uses unformat_float.
     // Grades are stored in Moodle with 5 decimal points, make sure we do not accidentally round them
     // when setting the form value.
     $mform->setDefault('criteria_grade_value', format_float($data, 5));
     if ($this->id) {
         $mform->setDefault('criteria_grade', 1);
         $mform->setDefault('criteria_grade_value', format_float($this->gradepass, 5));
     }
 }