You are here

function default_export_filename in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/questionlib.php \default_export_filename()

Create default export filename

Parameters

object $course:

object $category:

Return value

string default export filename

File

includes/moodle/lib/questionlib.php, line 2088

Code

function default_export_filename($course, $category) {

  //Take off some characters in the filename !!
  $takeoff = array(
    " ",
    ":",
    "/",
    "\\",
    "|",
  );
  $export_word = str_replace($takeoff, "_", moodle_strtolower(get_string("exportfilename", "quiz")));

  //If non-translated, use "export"
  if (substr($export_word, 0, 1) == "[") {
    $export_word = "export";
  }

  //Calculate the date format string
  $export_date_format = str_replace(" ", "_", get_string("exportnameformat", "quiz"));

  //If non-translated, use "%Y%m%d-%H%M"
  if (substr($export_date_format, 0, 1) == "[") {
    $export_date_format = "%%Y%%m%%d-%%H%%M";
  }

  //Calculate the shortname
  $export_shortname = clean_filename($course->shortname);
  if (empty($export_shortname) or $export_shortname == '_') {
    $export_shortname = $course->id;
  }

  //Calculate the category name
  $export_categoryname = clean_filename($category->name);

  //Calculate the final export filename

  //The export word
  $export_name = $export_word . "-";

  //The shortname
  $export_name .= moodle_strtolower($export_shortname) . "-";

  //The category name
  $export_name .= moodle_strtolower($export_categoryname) . "-";

  //The date format
  $export_name .= userdate(time(), $export_date_format, 99, false);

  //Extension is supplied by format later.
  return $export_name;
}