original_string: public static function get_policy_version($versionid, $policies = null) {
          if ($policies === null) {
              $policies = self::list_policies();
          }
          foreach ($policies as $policy) {
              if ($policy->currentversionid == $versionid) {
                  return $policy->currentversion;
  
              } else {
                  foreach ($policy->draftversions as $draft) {
                      if ($draft->id == $versionid) {
                          return $draft;
                      }
                  }
  
                  foreach ($policy->archivedversions as $archived) {
                      if ($archived->id == $versionid) {
                          return $archived;
                      }
                  }
              }
          }
  
          throw new \moodle_exception('errorpolicyversionnotfound', 'tool_policy');
      }
code: public static function get_policy_version($versionid, $policies = null) {
          if ($policies === null) {
              $policies = self::list_policies();
          }
          foreach ($policies as $policy) {
              if ($policy->currentversionid == $versionid) {
                  return $policy->currentversion;
  
              } else {
                  foreach ($policy->draftversions as $draft) {
                      if ($draft->id == $versionid) {
                          return $draft;
                      }
                  }
  
                  foreach ($policy->archivedversions as $archived) {
                      if ($archived->id == $versionid) {
                          return $archived;
                      }
                  }
              }
          }
  
          throw new \moodle_exception('errorpolicyversionnotfound', 'tool_policy');
      }
code_tokens: public static function get_policy_version ( $ versionid , $ policies = null ) { if ( $ policies === null ) { $ policies = self :: list_policies ( ) ; } foreach ( $ policies as $ policy ) { if ( $ policy -> currentversionid == $ versionid ) { return $ policy -> currentversion ; } else { foreach ( $ policy -> draftversions as $ draft ) { if ( $ draft -> id == $ versionid ) { return $ draft ; } } foreach ( $ policy -> archivedversions as $ archived ) { if ( $ archived -> id == $ versionid ) { return $ archived ; } } } } throw new \ moodle_exception ( 'errorpolicyversionnotfound' , 'tool_policy' ) ; }
docstring: Load a particular policy document version.
  
  @param int $versionid ID of the policy document version.
  @param array $policies cached result of self::list_policies() in case this function needs to be called in a loop
  @return stdClass - exported {@link tool_policy\policy_exporter} instance
docstring_tokens: Load a particular policy document version .