You are here

function make_unique_id_code in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle_support.php \make_unique_id_code()
6 calls to make_unique_id_code()
qformat_coursetestmanager::importprocess in includes/moodle/question/format/coursetestmanager/format.php
Process the file This method should not normally be overidden
qformat_default::create_category_path in includes/moodle/question/format.php
find and/or create the category described by a delimited list e.g. $course$/tom/dick/harry or tom/dick/harry
qformat_default::importprocess in includes/moodle/question/format.php
Process the file This method should not normally be overidden
question_hash in includes/moodle/lib/questionlib.php
Creates a stamp that uniquely identifies this version of the question
question_make_default_categories in includes/moodle/lib/questionlib.php
Gets the default category in the most specific context. If no categories exist yet then default ones are created in all contexts.

... See full list

File

includes/moodle_support.php, line 148

Code

function make_unique_id_code($extra = '') {
  $hostname = 'unknownhost';
  if (!empty($_SERVER['HTTP_HOST'])) {
    $hostname = $_SERVER['HTTP_HOST'];
  }
  else {
    if (!empty($_ENV['HTTP_HOST'])) {
      $hostname = $_ENV['HTTP_HOST'];
    }
    else {
      if (!empty($_SERVER['SERVER_NAME'])) {
        $hostname = $_SERVER['SERVER_NAME'];
      }
      else {
        if (!empty($_ENV['SERVER_NAME'])) {
          $hostname = $_ENV['SERVER_NAME'];
        }
      }
    }
  }
  $date = gmdate("ymdHis");
  $random = random_string(6);
  if ($extra) {
    return $hostname . '+' . $date . '+' . $random . '+' . $extra;
  }
  else {
    return $hostname . '+' . $date . '+' . $random;
  }
}