original_string: private static function get_cached_grade_name($courseid, $gradeitemid) {
          global $DB, $CFG;
          require_once($CFG->libdir . '/gradelib.php');
  
          // Get all grade item names from cache, or using db query.
          $cache = \cache::make('availability_grade', 'items');
          if (($cacheditems = $cache->get($courseid)) === false) {
              // We cache the whole items table not the name; the format_string
              // call for the name might depend on current user (e.g. multilang)
              // and this is a shared cache.
              $cacheditems = $DB->get_records('grade_items', array('courseid' => $courseid));
              $cache->set($courseid, $cacheditems);
          }
  
          // Return name from cached item or a lang string.
          if (!array_key_exists($gradeitemid, $cacheditems)) {
              return get_string('missing', 'availability_grade');
          }
          $gradeitemobj = $cacheditems[$gradeitemid];
          $item = new \grade_item;
          \grade_object::set_properties($item, $gradeitemobj);
          return $item->get_name();
      }
code: private static function get_cached_grade_name($courseid, $gradeitemid) {
          global $DB, $CFG;
          require_once($CFG->libdir . '/gradelib.php');
  
          // Get all grade item names from cache, or using db query.
          $cache = \cache::make('availability_grade', 'items');
          if (($cacheditems = $cache->get($courseid)) === false) {
              // We cache the whole items table not the name; the format_string
              // call for the name might depend on current user (e.g. multilang)
              // and this is a shared cache.
              $cacheditems = $DB->get_records('grade_items', array('courseid' => $courseid));
              $cache->set($courseid, $cacheditems);
          }
  
          // Return name from cached item or a lang string.
          if (!array_key_exists($gradeitemid, $cacheditems)) {
              return get_string('missing', 'availability_grade');
          }
          $gradeitemobj = $cacheditems[$gradeitemid];
          $item = new \grade_item;
          \grade_object::set_properties($item, $gradeitemobj);
          return $item->get_name();
      }
code_tokens: private static function get_cached_grade_name ( $ courseid , $ gradeitemid ) { global $ DB , $ CFG ; require_once ( $ CFG -> libdir . '/gradelib.php' ) ; // Get all grade item names from cache, or using db query. $ cache = \ cache :: make ( 'availability_grade' , 'items' ) ; if ( ( $ cacheditems = $ cache -> get ( $ courseid ) ) === false ) { // We cache the whole items table not the name; the format_string // call for the name might depend on current user (e.g. multilang) // and this is a shared cache. $ cacheditems = $ DB -> get_records ( 'grade_items' , array ( 'courseid' => $ courseid ) ) ; $ cache -> set ( $ courseid , $ cacheditems ) ; } // Return name from cached item or a lang string. if ( ! array_key_exists ( $ gradeitemid , $ cacheditems ) ) { return get_string ( 'missing' , 'availability_grade' ) ; } $ gradeitemobj = $ cacheditems [ $ gradeitemid ] ; $ item = new \ grade_item ; \ grade_object :: set_properties ( $ item , $ gradeitemobj ) ; return $ item -> get_name ( ) ; }
docstring: Obtains the name of a grade item, also checking that it exists. Uses a
  cache. The name returned is suitable for display.
  
  @param int $courseid Course id
  @param int $gradeitemid Grade item id
  @return string Grade name or empty string if no grade with that id
docstring_tokens: Obtains the name of a grade item also checking that it exists . Uses a cache . The name returned is suitable for display .