original_string: public static function get_proficiency_of_grade_from_scale_configuration($config, $grade) {
          $config = json_decode($config);
          if (!is_array($config)) {
              throw new coding_exception('Unexpected scale configuration.');
          }
  
          // Remove the scale ID from the config.
          array_shift($config);
  
          foreach ($config as $part) {
              if ($part->id == $grade) {
                  return (int) $part->proficient;
              }
          }
  
          return 0;
      }
code: public static function get_proficiency_of_grade_from_scale_configuration($config, $grade) {
          $config = json_decode($config);
          if (!is_array($config)) {
              throw new coding_exception('Unexpected scale configuration.');
          }
  
          // Remove the scale ID from the config.
          array_shift($config);
  
          foreach ($config as $part) {
              if ($part->id == $grade) {
                  return (int) $part->proficient;
              }
          }
  
          return 0;
      }
code_tokens: public static function get_proficiency_of_grade_from_scale_configuration ( $ config , $ grade ) { $ config = json_decode ( $ config ) ; if ( ! is_array ( $ config ) ) { throw new coding_exception ( 'Unexpected scale configuration.' ) ; } // Remove the scale ID from the config. array_shift ( $ config ) ; foreach ( $ config as $ part ) { if ( $ part -> id == $ grade ) { return ( int ) $ part -> proficient ; } } return 0 ; }
docstring: Extract the proficiency of a grade from a scale configuration.
  
  @param  string $config JSON encoded config.
  @param  int $grade The grade.
  @return int Representing a boolean
docstring_tokens: Extract the proficiency of a grade from a scale configuration .