Moved import/export functions.

This commit is contained in:
thepurpleblob
2006-02-24 15:44:53 +00:00
parent 5ab6af1238
commit ff4b6492a0
+41
View File
@@ -1287,4 +1287,45 @@ function question_used($id) {
return $quizlist;
}
/**
* Get list of available import or export formats
* @param string $type 'import' if import list, otherwise export list assumed
* @return array sorted list of import/export formats available
**/
function get_import_export_formats( $type ) {
global $CFG;
$fileformats = get_list_of_plugins("mod/quiz/format");
$fileformatname=array();
require_once( "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 = "quiz_format_$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;
}
?>