original_string: protected function add_unit_fields($mform) {
          $mform->addElement('header', 'unithdr',
                      get_string('units', 'qtype_numerical'), '');
  
          $unitfields = array($mform->createElement('group', 'units',
                   get_string('unitx', 'qtype_numerical'), $this->unit_group($mform), null, false));
  
          $repeatedoptions['unit']['disabledif'] = array('unitrole', 'eq', qtype_numerical::UNITNONE);
          $repeatedoptions['unit']['type'] = PARAM_NOTAGS;
          $repeatedoptions['multiplier']['disabledif'] = array('unitrole', 'eq', qtype_numerical::UNITNONE);
  
          $mform->disabledIf('addunits', 'unitrole', 'eq', qtype_numerical::UNITNONE);
  
          if (isset($this->question->options->units)) {
              $repeatsatstart = max(count($this->question->options->units), self::UNITS_MIN_REPEATS);
          } else {
              $repeatsatstart = self::UNITS_MIN_REPEATS;
          }
  
          $this->repeat_elements($unitfields, $repeatsatstart, $repeatedoptions, 'nounits',
                  'addunits', self::UNITS_TO_ADD, get_string('addmoreunitblanks', 'qtype_numerical', '{no}'), true);
  
          // The following strange-looking if statement is to do with when the
          // form is used to move questions between categories. See MDL-15159.
          if ($mform->elementExists('units[0]')) {
              $firstunit = $mform->getElement('units[0]');
              $elements = $firstunit->getElements();
              foreach ($elements as $element) {
                  if ($element->getName() != 'multiplier[0]') {
                      continue;
                  }
                  $element->freeze();
                  $element->setValue('1.0');
                  $element->setPersistantFreeze(true);
              }
              $mform->addHelpButton('units[0]', 'numericalmultiplier', 'qtype_numerical');
          }
      }
code: protected function add_unit_fields($mform) {
          $mform->addElement('header', 'unithdr',
                      get_string('units', 'qtype_numerical'), '');
  
          $unitfields = array($mform->createElement('group', 'units',
                   get_string('unitx', 'qtype_numerical'), $this->unit_group($mform), null, false));
  
          $repeatedoptions['unit']['disabledif'] = array('unitrole', 'eq', qtype_numerical::UNITNONE);
          $repeatedoptions['unit']['type'] = PARAM_NOTAGS;
          $repeatedoptions['multiplier']['disabledif'] = array('unitrole', 'eq', qtype_numerical::UNITNONE);
  
          $mform->disabledIf('addunits', 'unitrole', 'eq', qtype_numerical::UNITNONE);
  
          if (isset($this->question->options->units)) {
              $repeatsatstart = max(count($this->question->options->units), self::UNITS_MIN_REPEATS);
          } else {
              $repeatsatstart = self::UNITS_MIN_REPEATS;
          }
  
          $this->repeat_elements($unitfields, $repeatsatstart, $repeatedoptions, 'nounits',
                  'addunits', self::UNITS_TO_ADD, get_string('addmoreunitblanks', 'qtype_numerical', '{no}'), true);
  
          // The following strange-looking if statement is to do with when the
          // form is used to move questions between categories. See MDL-15159.
          if ($mform->elementExists('units[0]')) {
              $firstunit = $mform->getElement('units[0]');
              $elements = $firstunit->getElements();
              foreach ($elements as $element) {
                  if ($element->getName() != 'multiplier[0]') {
                      continue;
                  }
                  $element->freeze();
                  $element->setValue('1.0');
                  $element->setPersistantFreeze(true);
              }
              $mform->addHelpButton('units[0]', 'numericalmultiplier', 'qtype_numerical');
          }
      }
code_tokens: protected function add_unit_fields ( $ mform ) { $ mform -> addElement ( 'header' , 'unithdr' , get_string ( 'units' , 'qtype_numerical' ) , '' ) ; $ unitfields = array ( $ mform -> createElement ( 'group' , 'units' , get_string ( 'unitx' , 'qtype_numerical' ) , $ this -> unit_group ( $ mform ) , null , false ) ) ; $ repeatedoptions [ 'unit' ] [ 'disabledif' ] = array ( 'unitrole' , 'eq' , qtype_numerical :: UNITNONE ) ; $ repeatedoptions [ 'unit' ] [ 'type' ] = PARAM_NOTAGS ; $ repeatedoptions [ 'multiplier' ] [ 'disabledif' ] = array ( 'unitrole' , 'eq' , qtype_numerical :: UNITNONE ) ; $ mform -> disabledIf ( 'addunits' , 'unitrole' , 'eq' , qtype_numerical :: UNITNONE ) ; if ( isset ( $ this -> question -> options -> units ) ) { $ repeatsatstart = max ( count ( $ this -> question -> options -> units ) , self :: UNITS_MIN_REPEATS ) ; } else { $ repeatsatstart = self :: UNITS_MIN_REPEATS ; } $ this -> repeat_elements ( $ unitfields , $ repeatsatstart , $ repeatedoptions , 'nounits' , 'addunits' , self :: UNITS_TO_ADD , get_string ( 'addmoreunitblanks' , 'qtype_numerical' , '{no}' ) , true ) ; // The following strange-looking if statement is to do with when the // form is used to move questions between categories. See MDL-15159. if ( $ mform -> elementExists ( 'units[0]' ) ) { $ firstunit = $ mform -> getElement ( 'units[0]' ) ; $ elements = $ firstunit -> getElements ( ) ; foreach ( $ elements as $ element ) { if ( $ element -> getName ( ) != 'multiplier[0]' ) { continue ; } $ element -> freeze ( ) ; $ element -> setValue ( '1.0' ) ; $ element -> setPersistantFreeze ( true ) ; } $ mform -> addHelpButton ( 'units[0]' , 'numericalmultiplier' , 'qtype_numerical' ) ; } }
docstring: Add the input areas for each unit.
  @param object $mform the form being built.
docstring_tokens: Add the input areas for each unit .