original_string: public function get_contextid($level, $instance = 0) {
  
          $stashname = 'context' . $level;
  
          if ($level == CONTEXT_SYSTEM or $level == CONTEXT_COURSE) {
              $instance = 0;
          }
  
          try {
              // try the previously stashed id
              return $this->get_stash($stashname, $instance);
  
          } catch (moodle1_convert_empty_storage_exception $e) {
              // this context level + instance is required for the first time
              $newid = $this->get_nextid();
              $this->set_stash($stashname, $newid, $instance);
              return $newid;
          }
      }
code: public function get_contextid($level, $instance = 0) {
  
          $stashname = 'context' . $level;
  
          if ($level == CONTEXT_SYSTEM or $level == CONTEXT_COURSE) {
              $instance = 0;
          }
  
          try {
              // try the previously stashed id
              return $this->get_stash($stashname, $instance);
  
          } catch (moodle1_convert_empty_storage_exception $e) {
              // this context level + instance is required for the first time
              $newid = $this->get_nextid();
              $this->set_stash($stashname, $newid, $instance);
              return $newid;
          }
      }
code_tokens: public function get_contextid ( $ level , $ instance = 0 ) { $ stashname = 'context' . $ level ; if ( $ level == CONTEXT_SYSTEM or $ level == CONTEXT_COURSE ) { $ instance = 0 ; } try { // try the previously stashed id return $ this -> get_stash ( $ stashname , $ instance ) ; } catch ( moodle1_convert_empty_storage_exception $ e ) { // this context level + instance is required for the first time $ newid = $ this -> get_nextid ( ) ; $ this -> set_stash ( $ stashname , $ newid , $ instance ) ; return $ newid ; } }
docstring: Generates an artificial context id
  
  Moodle 1.9 backups do not contain any context information. But we need them
  in Moodle 2.x format so here we generate fictive context id for every given
  context level + instance combo.
  
  CONTEXT_SYSTEM and CONTEXT_COURSE ignore the $instance as they represent a
  single system or the course being restored.
  
  @see context_system::instance()
  @see context_course::instance()
  @param int $level the context level, like CONTEXT_COURSE or CONTEXT_MODULE
  @param int $instance the instance id, for example $course->id for courses or $cm->id for activity modules
  @return int the context id
docstring_tokens: Generates an artificial context id