MDL-67810 core_contentbank: contentype_h5p modified to support add menu
This commit is contained in:
@@ -25,7 +25,11 @@
|
||||
namespace contenttype_h5p;
|
||||
|
||||
use core\event\contentbank_content_viewed;
|
||||
use html_writer;
|
||||
use stdClass;
|
||||
use core_h5p\editor_ajax;
|
||||
use core_h5p\file_storage;
|
||||
use core_h5p\local\library\autoloader;
|
||||
use H5PCore;
|
||||
|
||||
/**
|
||||
* H5P content bank manager class
|
||||
@@ -65,8 +69,7 @@ class contenttype extends \core_contentbank\contenttype {
|
||||
$event->trigger();
|
||||
|
||||
$fileurl = $content->get_file_url();
|
||||
$html = html_writer::tag('h2', $content->get_name());
|
||||
$html .= \core_h5p\player::display($fileurl, new \stdClass(), true);
|
||||
$html = \core_h5p\player::display($fileurl, new \stdClass(), true);
|
||||
return $html;
|
||||
}
|
||||
|
||||
@@ -107,7 +110,7 @@ class contenttype extends \core_contentbank\contenttype {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_implemented_features(): array {
|
||||
return [self::CAN_UPLOAD];
|
||||
return [self::CAN_UPLOAD, self::CAN_EDIT];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,4 +130,42 @@ class contenttype extends \core_contentbank\contenttype {
|
||||
protected function is_access_allowed(): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of different H5P content types the user can create.
|
||||
*
|
||||
* @return array An object for each H5P content type:
|
||||
* - string typename: descriptive name of the H5P content type.
|
||||
* - string typeeditorparams: params required by the H5P editor.
|
||||
* - url typeicon: H5P content type icon.
|
||||
*/
|
||||
public function get_contenttype_types(): array {
|
||||
// Get the H5P content types available.
|
||||
autoloader::register();
|
||||
$editorajax = new editor_ajax();
|
||||
$h5pcontenttypes = $editorajax->getLatestLibraryVersions();
|
||||
|
||||
$types = [];
|
||||
$h5pfilestorage = new file_storage();
|
||||
foreach ($h5pcontenttypes as $h5pcontenttype) {
|
||||
$library = [
|
||||
'name' => $h5pcontenttype->machine_name,
|
||||
'majorVersion' => $h5pcontenttype->major_version,
|
||||
'minorVersion' => $h5pcontenttype->minor_version,
|
||||
];
|
||||
$key = H5PCore::libraryToString($library);
|
||||
$type = new stdClass();
|
||||
$type->key = $key;
|
||||
$type->typename = $h5pcontenttype->title;
|
||||
$type->typeeditorparams = 'library=' . $key;
|
||||
$type->typeicon = $h5pfilestorage->get_icon_url(
|
||||
$h5pcontenttype->id,
|
||||
$h5pcontenttype->machine_name,
|
||||
$h5pcontenttype->major_version,
|
||||
$h5pcontenttype->minor_version);
|
||||
$types[] = $type;
|
||||
}
|
||||
|
||||
return $types;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,14 @@ $capabilities = [
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
]
|
||||
],
|
||||
'contenttype/h5p:useeditor' => [
|
||||
'riskbitmask' => RISK_SPAM,
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['description'] = 'H5P Interactive Content';
|
||||
$string['pluginname'] = 'H5P';
|
||||
$string['pluginname_help'] = 'Content bank to upload and share H5P content';
|
||||
$string['privacy:metadata'] = 'The H5P content bank plugin does not store any personal data.';
|
||||
$string['h5p:access'] = 'Access H5P content in the content bank';
|
||||
$string['h5p:upload'] = 'Upload new H5P content';
|
||||
$string['h5p:useeditor'] = 'Create or edit content using the H5P editor';
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2020041500.00; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2020051500.01; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2020041500.00; // Requires this Moodle version
|
||||
$plugin->component = 'contenttype_h5p'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
Reference in New Issue
Block a user