MDL-69143 contentbank: add import file method to content

This commit is contained in:
Ferran Recio 2020-06-26 19:56:29 +02:00
parent 94fdac9117
commit 3dfbd5a16f
8 changed files with 295 additions and 12 deletions

View file

@ -224,6 +224,8 @@ class contentbank {
/**
* Create content from a file information.
*
* @throws file_exception If file operations fail
* @throws dml_exception if the content creation fails
* @param \context $context Context where to upload the file and content.
* @param int $userid Id of the user uploading the file.
* @param stored_file $file The file to get information from
@ -243,7 +245,7 @@ class contentbank {
$record->name = $filename;
$record->usercreated = $userid;
$contentype = new $classname($context);
$content = $contentype->create_content($record);
$content = $contentype->upload_content($file, $record);
$event = \core\event\contentbank_content_uploaded::create_from_record($content->get_content());
$event->trigger();
return $content;