You are here

function get_import_export_formats in Quiz 6.5

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

Get list of available import or export formats

Parameters

string $type 'import' if import list, otherwise export list assumed:

Return value

array sorted list of import/export formats available

File

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

Code

function get_import_export_formats($type) {
  global $CFG;
  $fileformats = get_list_of_plugins("question/format");
  $fileformatname = array();
  require_once "{$CFG->dirroot}/question/format.php";
  foreach ($fileformats as $key => $fileformat) {
    $format_file = $CFG->dirroot . "/question/format/{$fileformat}/format.php";
    if (file_exists($format_file)) {
      require_once $format_file;
    }
    else {
      continue;
    }
    $classname = "qformat_{$fileformat}";
    $format_class = new $classname();
    if ($type == 'import') {
      $provided = $format_class
        ->provide_import();
    }
    else {
      $provided = $format_class
        ->provide_export();
    }
    if ($provided) {
      $formatname = get_string($fileformat, 'quiz');
      if ($formatname == "[[{$fileformat}]]") {
        $formatname = $fileformat;

        // Just use the raw folder name
      }
      $fileformatnames[$fileformat] = $formatname;
    }
  }
  natcasesort($fileformatnames);
  return $fileformatnames;
}