mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
Merge branch 'MDL-28364' of git://github.com/jonof/moodle
This commit is contained in:
commit
12c5685a50
3 changed files with 23 additions and 1 deletions
|
@ -103,6 +103,20 @@ class qformat_default {
|
||||||
return '.txt';
|
return '.txt';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given file is capable of being imported by this plugin.
|
||||||
|
*
|
||||||
|
* Note that expensive or detailed integrity checks on the file should
|
||||||
|
* not be performed by this method. Simple file type or magic-number tests
|
||||||
|
* would be suitable.
|
||||||
|
*
|
||||||
|
* @param stored_file $file the file to check
|
||||||
|
* @return bool whether this plugin can import the file
|
||||||
|
*/
|
||||||
|
public function can_import_file($file) {
|
||||||
|
return ($file->get_mimetype() == $this->mime_type());
|
||||||
|
}
|
||||||
|
|
||||||
// Accessor methods
|
// Accessor methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,6 +40,14 @@ class qformat_blackboard_six extends qformat_default {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function can_import_file($file) {
|
||||||
|
$mimetypes = array(
|
||||||
|
mimeinfo('type', '.dat'),
|
||||||
|
mimeinfo('type', '.zip')
|
||||||
|
);
|
||||||
|
return in_array($file->get_mimetype(), $mimetypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Function to check and create the needed dir to unzip file to
|
//Function to check and create the needed dir to unzip file to
|
||||||
function check_and_create_import_dir($unique_code) {
|
function check_and_create_import_dir($unique_code) {
|
||||||
|
|
|
@ -133,7 +133,7 @@ class question_import_form extends moodleform {
|
||||||
$qformat = new $classname();
|
$qformat = new $classname();
|
||||||
|
|
||||||
$file = reset($files);
|
$file = reset($files);
|
||||||
if ($file->get_mimetype() != $qformat->mime_type()) {
|
if (!$qformat->can_import_file($file)) {
|
||||||
$a = new stdClass();
|
$a = new stdClass();
|
||||||
$a->actualtype = $file->get_mimetype();
|
$a->actualtype = $file->get_mimetype();
|
||||||
$a->expectedtype = $qformat->mime_type();
|
$a->expectedtype = $qformat->mime_type();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue