original_string: public function get_scale_id($scalevalues, $competencyname) {
          global $CFG, $USER;
  
          require_once($CFG->libdir . '/gradelib.php');
  
          if (empty($this->scalecache)) {
              $allscales = grade_scale::fetch_all_global();
              foreach ($allscales as $scale) {
                  $scale->load_items();
                  $this->scalecache[$scale->compact_items()] = $scale;
              }
          }
          $matchingscale = false;
          if (isset($this->scalecache[$scalevalues])) {
              $matchingscale = $this->scalecache[$scalevalues];
          }
          if (!$matchingscale) {
              // Create it.
              $newscale = new grade_scale();
              $newscale->name = get_string('competencyscale', 'tool_lpimportcsv', $competencyname);
              $newscale->courseid = 0;
              $newscale->userid = $USER->id;
              $newscale->scale = $scalevalues;
              $newscale->description = get_string('competencyscaledescription', 'tool_lpimportcsv');
              $newscale->insert();
              $this->scalecache[$scalevalues] = $newscale;
              return $newscale->id;
          }
          return $matchingscale->id;
      }
code: public function get_scale_id($scalevalues, $competencyname) {
          global $CFG, $USER;
  
          require_once($CFG->libdir . '/gradelib.php');
  
          if (empty($this->scalecache)) {
              $allscales = grade_scale::fetch_all_global();
              foreach ($allscales as $scale) {
                  $scale->load_items();
                  $this->scalecache[$scale->compact_items()] = $scale;
              }
          }
          $matchingscale = false;
          if (isset($this->scalecache[$scalevalues])) {
              $matchingscale = $this->scalecache[$scalevalues];
          }
          if (!$matchingscale) {
              // Create it.
              $newscale = new grade_scale();
              $newscale->name = get_string('competencyscale', 'tool_lpimportcsv', $competencyname);
              $newscale->courseid = 0;
              $newscale->userid = $USER->id;
              $newscale->scale = $scalevalues;
              $newscale->description = get_string('competencyscaledescription', 'tool_lpimportcsv');
              $newscale->insert();
              $this->scalecache[$scalevalues] = $newscale;
              return $newscale->id;
          }
          return $matchingscale->id;
      }
code_tokens: public function get_scale_id ( $ scalevalues , $ competencyname ) { global $ CFG , $ USER ; require_once ( $ CFG -> libdir . '/gradelib.php' ) ; if ( empty ( $ this -> scalecache ) ) { $ allscales = grade_scale :: fetch_all_global ( ) ; foreach ( $ allscales as $ scale ) { $ scale -> load_items ( ) ; $ this -> scalecache [ $ scale -> compact_items ( ) ] = $ scale ; } } $ matchingscale = false ; if ( isset ( $ this -> scalecache [ $ scalevalues ] ) ) { $ matchingscale = $ this -> scalecache [ $ scalevalues ] ; } if ( ! $ matchingscale ) { // Create it. $ newscale = new grade_scale ( ) ; $ newscale -> name = get_string ( 'competencyscale' , 'tool_lpimportcsv' , $ competencyname ) ; $ newscale -> courseid = 0 ; $ newscale -> userid = $ USER -> id ; $ newscale -> scale = $ scalevalues ; $ newscale -> description = get_string ( 'competencyscaledescription' , 'tool_lpimportcsv' ) ; $ newscale -> insert ( ) ; $ this -> scalecache [ $ scalevalues ] = $ newscale ; return $ newscale -> id ; } return $ matchingscale -> id ; }
docstring: Search for a global scale that matches this set of scalevalues.
  If one is not found it will be created.
  @param array $scalevalues
  @param string $competencyname (Used to create a new scale if required)
  @return int The id of the scale
docstring_tokens: Search for a global scale that matches this set of scalevalues . If one is not found it will be created .