original_string: private static function create_definition_object($definition) {
          global $CFG;
  
          $method = $definition['method'];
          $definitionobject = new stdClass();
          foreach ($definition as $key => $value) {
              if (!is_array($value)) {
                  $definitionobject->$key = $value;
              }
          }
          $text = '';
          $format = FORMAT_MOODLE;
          if (isset($definition['description'])) {
              $text = $definition['description'];
              if (isset($definition['descriptionformat'])) {
                  $format = $definition['descriptionformat'];
              }
          }
          $definitionobject->description_editor = array('text' => $text, 'format' => $format);
  
          require_once("$CFG->libdir/filelib.php");
          require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php');
          $details  = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details');
          $methodarray = array();
          foreach (array_keys($details) as $definitionkey) {
              $items = array();
              $idnumber = 1;
              foreach ($definition[$method][$definitionkey] as $item) {
                  $processeditem = self::set_new_ids($item, $idnumber);
                  $items[$processeditem['id']] = $processeditem;
                  $idnumber++;
              }
              $definitionobjectkey = substr($definitionkey, strlen($method.'_'));
              $methodarray[$definitionobjectkey] = $items;
              $definitionobject->$method = $methodarray;
          }
  
          return $definitionobject;
      }
code: private static function create_definition_object($definition) {
          global $CFG;
  
          $method = $definition['method'];
          $definitionobject = new stdClass();
          foreach ($definition as $key => $value) {
              if (!is_array($value)) {
                  $definitionobject->$key = $value;
              }
          }
          $text = '';
          $format = FORMAT_MOODLE;
          if (isset($definition['description'])) {
              $text = $definition['description'];
              if (isset($definition['descriptionformat'])) {
                  $format = $definition['descriptionformat'];
              }
          }
          $definitionobject->description_editor = array('text' => $text, 'format' => $format);
  
          require_once("$CFG->libdir/filelib.php");
          require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php');
          $details  = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details');
          $methodarray = array();
          foreach (array_keys($details) as $definitionkey) {
              $items = array();
              $idnumber = 1;
              foreach ($definition[$method][$definitionkey] as $item) {
                  $processeditem = self::set_new_ids($item, $idnumber);
                  $items[$processeditem['id']] = $processeditem;
                  $idnumber++;
              }
              $definitionobjectkey = substr($definitionkey, strlen($method.'_'));
              $methodarray[$definitionobjectkey] = $items;
              $definitionobject->$method = $methodarray;
          }
  
          return $definitionobject;
      }
code_tokens: private static function create_definition_object ( $ definition ) { global $ CFG ; $ method = $ definition [ 'method' ] ; $ definitionobject = new stdClass ( ) ; foreach ( $ definition as $ key => $ value ) { if ( ! is_array ( $ value ) ) { $ definitionobject -> $ key = $ value ; } } $ text = '' ; $ format = FORMAT_MOODLE ; if ( isset ( $ definition [ 'description' ] ) ) { $ text = $ definition [ 'description' ] ; if ( isset ( $ definition [ 'descriptionformat' ] ) ) { $ format = $ definition [ 'descriptionformat' ] ; } } $ definitionobject -> description_editor = array ( 'text' => $ text , 'format' => $ format ) ; require_once ( "$CFG->libdir/filelib.php" ) ; require_once ( $ CFG -> dirroot . '/grade/grading/form/' . $ method . '/lib.php' ) ; $ details = call_user_func ( 'gradingform_' . $ method . '_controller::get_external_definition_details' ) ; $ methodarray = array ( ) ; foreach ( array_keys ( $ details ) as $ definitionkey ) { $ items = array ( ) ; $ idnumber = 1 ; foreach ( $ definition [ $ method ] [ $ definitionkey ] as $ item ) { $ processeditem = self :: set_new_ids ( $ item , $ idnumber ) ; $ items [ $ processeditem [ 'id' ] ] = $ processeditem ; $ idnumber ++ ; } $ definitionobjectkey = substr ( $ definitionkey , strlen ( $ method . '_' ) ) ; $ methodarray [ $ definitionobjectkey ] = $ items ; $ definitionobject -> $ method = $ methodarray ; } return $ definitionobject ; }
docstring: Creates a definition stdClass object using the values from the definition
  array that is passed in as a parameter
  
  @param array $definition
  @return stdClass definition object
  @since Moodle 2.8
docstring_tokens: Creates a definition stdClass object using the values from the definition array that is passed in as a parameter