Exemplo n.º 1
0
 /**
  * Called by HTML_QuickForm whenever form event is made on this element
  *
  * @param     string    $event  Name of event
  * @param     mixed     $arg    event arguments
  * @param     object    &$caller calling object
  * @since     1.0
  * @access    public
  * @return    void
  */
 function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'updateValue':
             // constant values override both default and submitted ones
             // default values are overriden by submitted
             $value = $this->_findValue($caller->_constantValues);
             if (null === $value) {
                 // if no boxes were checked, then there is no value in the array
                 // yet we don't want to display default value in this case
                 if ($caller->isSubmitted()) {
                     $value = $this->_findValue($caller->_submitValues);
                 } else {
                     $value = $this->_findValue($caller->_defaultValues);
                 }
             }
             if (null !== $value || $caller->isSubmitted()) {
                 $this->setChecked($value);
             }
             break;
         case 'setGroupValue':
             $this->setChecked($arg);
             break;
         default:
             parent::onQuickFormEvent($event, $arg, $caller);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Called by HTML_QuickForm whenever form event is made on this element
  *
  * @param     string    $event  Name of event
  * @param     mixed     $arg    event arguments
  * @param     object    $caller calling object
  * @since     1.0
  * @access    public
  * @return    void
  */
 function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'updateValue':
             // constant values override both default and submitted ones
             // default values are overriden by submitted
             $value = $this->_findValue($caller->_constantValues);
             if (null === $value) {
                 $value = $this->_findValue($caller->_submitValues);
                 if (null === $value) {
                     $value = $this->_findValue($caller->_defaultValues);
                 }
             }
             if (!is_null($value) && $value == $this->getValue()) {
                 $this->setChecked(true);
             } else {
                 $this->setChecked(false);
             }
             break;
         case 'setGroupValue':
             if ($arg == $this->getValue()) {
                 $this->setChecked(true);
             } else {
                 $this->setChecked(false);
             }
             break;
         default:
             parent::onQuickFormEvent($event, $arg, $caller);
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Called by HTML_QuickForm whenever form event is made on this element.
  * Adds necessary rules to the element and checks that coorenct instance of gradingform_instance
  * is passed in attributes
  *
  * @param string $event Name of event
  * @param mixed $arg event arguments
  * @param object $caller calling object
  * @return bool
  * @throws moodle_exception
  */
 public function onQuickFormEvent($event, $arg, &$caller)
 {
     if ($event == 'createElement') {
         $attributes = $arg[2];
         if (!is_array($attributes) || !array_key_exists('gradinginstance', $attributes) || !$attributes['gradinginstance'] instanceof gradingform_instance) {
             throw new moodle_exception('exc_gradingformelement', 'grading');
         }
     }
     $name = $this->getName();
     if ($name && $caller->elementExists($name)) {
         $caller->addRule($name, $this->get_gradinginstance()->default_validation_error_message(), 'gradingvalidated', $this->gradingattributes);
     }
     return parent::onQuickFormEvent($event, $arg, $caller);
 }
Exemplo n.º 4
0
 /**
  * Called by HTML_QuickForm whenever form event is made on this element
  *
  * @param     string    $event  Name of event
  * @param     mixed     $arg    event arguments
  * @param     object    &$caller calling object
  * @since     1.0
  * @access    public
  * @return    void
  */
 function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'updateValue':
             // constant values override both default and submitted ones
             $value = $this->_findValue($caller->_constantValues);
             if (null === $value) {
                 // we should retrieve value from submitted values when form is submitted,
                 // else set value from defaults values
                 if ($caller->isSubmitted()) {
                     $value = $this->_findValue($caller->_submitValues);
                 } else {
                     $value = $this->_findValue($caller->_defaultValues);
                 }
             }
             if (!is_null($value) && $value == $this->getValue()) {
                 $this->setChecked(true);
             } else {
                 $this->setChecked(false);
             }
             break;
         case 'setGroupValue':
             if ($arg == $this->getValue()) {
                 $this->setChecked(true);
             } else {
                 $this->setChecked(false);
             }
             break;
         default:
             parent::onQuickFormEvent($event, $arg, $caller);
     }
     return true;
 }
Exemplo n.º 5
0
 function onQuickFormEvent($event, $arg, &$caller)
 {
     if ($event == 'updateValue' && is_callable(array($caller, 'applyFilter'))) {
         $caller->applyFilter($this->getName(), array($this, 'reg2time'));
     }
     return parent::onQuickFormEvent($event, $arg, $caller);
 }