original_string: public static function convert_flat_displaytypes_to_array($displaytypes) {
          $types = array();
  
          // We have a single grade display type constant.
          if (is_int($displaytypes)) {
              $displaytype = clean_param($displaytypes, PARAM_INT);
  
              // Let's set a default value, will be replaced below by the grade display type constant.
              $display[$displaytype] = 1;
          } else {
              // Multiple grade display types constants.
              $display = array_flip(explode(',', $displaytypes));
          }
  
          // Now, create the array in the required format by grade exporting class.
          foreach ($display as $type => $value) {
              $type = clean_param($type, PARAM_INT);
              if ($type == GRADE_DISPLAY_TYPE_LETTER) {
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
              } else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE) {
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
              } else if ($type == GRADE_DISPLAY_TYPE_REAL) {
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
              } else if ($type == GRADE_DISPLAY_TYPE_REAL_PERCENTAGE) {
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
              } else if ($type == GRADE_DISPLAY_TYPE_REAL_LETTER) {
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
              } else if ($type == GRADE_DISPLAY_TYPE_LETTER_REAL) {
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
              } else if ($type == GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE) {
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
              } else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER) {
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
              } else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE_REAL) {
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
              }
          }
          return $types;
      }
code: public static function convert_flat_displaytypes_to_array($displaytypes) {
          $types = array();
  
          // We have a single grade display type constant.
          if (is_int($displaytypes)) {
              $displaytype = clean_param($displaytypes, PARAM_INT);
  
              // Let's set a default value, will be replaced below by the grade display type constant.
              $display[$displaytype] = 1;
          } else {
              // Multiple grade display types constants.
              $display = array_flip(explode(',', $displaytypes));
          }
  
          // Now, create the array in the required format by grade exporting class.
          foreach ($display as $type => $value) {
              $type = clean_param($type, PARAM_INT);
              if ($type == GRADE_DISPLAY_TYPE_LETTER) {
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
              } else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE) {
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
              } else if ($type == GRADE_DISPLAY_TYPE_REAL) {
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
              } else if ($type == GRADE_DISPLAY_TYPE_REAL_PERCENTAGE) {
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
              } else if ($type == GRADE_DISPLAY_TYPE_REAL_LETTER) {
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
              } else if ($type == GRADE_DISPLAY_TYPE_LETTER_REAL) {
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
              } else if ($type == GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE) {
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
              } else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER) {
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
                  $types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
              } else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE_REAL) {
                  $types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
                  $types['real'] = GRADE_DISPLAY_TYPE_REAL;
              }
          }
          return $types;
      }
code_tokens: public static function convert_flat_displaytypes_to_array ( $ displaytypes ) { $ types = array ( ) ; // We have a single grade display type constant. if ( is_int ( $ displaytypes ) ) { $ displaytype = clean_param ( $ displaytypes , PARAM_INT ) ; // Let's set a default value, will be replaced below by the grade display type constant. $ display [ $ displaytype ] = 1 ; } else { // Multiple grade display types constants. $ display = array_flip ( explode ( ',' , $ displaytypes ) ) ; } // Now, create the array in the required format by grade exporting class. foreach ( $ display as $ type => $ value ) { $ type = clean_param ( $ type , PARAM_INT ) ; if ( $ type == GRADE_DISPLAY_TYPE_LETTER ) { $ types [ 'letter' ] = GRADE_DISPLAY_TYPE_LETTER ; } else if ( $ type == GRADE_DISPLAY_TYPE_PERCENTAGE ) { $ types [ 'percentage' ] = GRADE_DISPLAY_TYPE_PERCENTAGE ; } else if ( $ type == GRADE_DISPLAY_TYPE_REAL ) { $ types [ 'real' ] = GRADE_DISPLAY_TYPE_REAL ; } else if ( $ type == GRADE_DISPLAY_TYPE_REAL_PERCENTAGE ) { $ types [ 'real' ] = GRADE_DISPLAY_TYPE_REAL ; $ types [ 'percentage' ] = GRADE_DISPLAY_TYPE_PERCENTAGE ; } else if ( $ type == GRADE_DISPLAY_TYPE_REAL_LETTER ) { $ types [ 'real' ] = GRADE_DISPLAY_TYPE_REAL ; $ types [ 'letter' ] = GRADE_DISPLAY_TYPE_LETTER ; } else if ( $ type == GRADE_DISPLAY_TYPE_LETTER_REAL ) { $ types [ 'letter' ] = GRADE_DISPLAY_TYPE_LETTER ; $ types [ 'real' ] = GRADE_DISPLAY_TYPE_REAL ; } else if ( $ type == GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE ) { $ types [ 'letter' ] = GRADE_DISPLAY_TYPE_LETTER ; $ types [ 'percentage' ] = GRADE_DISPLAY_TYPE_PERCENTAGE ; } else if ( $ type == GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER ) { $ types [ 'percentage' ] = GRADE_DISPLAY_TYPE_PERCENTAGE ; $ types [ 'letter' ] = GRADE_DISPLAY_TYPE_LETTER ; } else if ( $ type == GRADE_DISPLAY_TYPE_PERCENTAGE_REAL ) { $ types [ 'percentage' ] = GRADE_DISPLAY_TYPE_PERCENTAGE ; $ types [ 'real' ] = GRADE_DISPLAY_TYPE_REAL ; } } return $ types ; }
docstring: Convert the grade display types parameter into the required array to grade exporting class.
  
  In order to export, the array key must be the display type name and the value must be the grade display type
  constant.
  
  Note: Added support for combined display types constants like the (GRADE_DISPLAY_TYPE_PERCENTAGE_REAL) as
  the $CFG->grade_export_displaytype config is still used on 2.7 in case of missing displaytype url param.
  In these cases, the file will be exported with a column for each display type.
  
  @param string $displaytypes can be a single or multiple display type constants comma separated.
  @return array $types
docstring_tokens: Convert the grade display types parameter into the required array to grade exporting class .