mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
MDL-69143 contentbank: add import file method to content
This commit is contained in:
parent
94fdac9117
commit
3dfbd5a16f
8 changed files with 295 additions and 12 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue