mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-67786 contenttype_h5p: New H5P content type plugin for content bank
This commit is contained in:
parent
33b8ca26f9
commit
2867550e39
38
contentbank/contenttype/h5p/classes/content.php
Normal file
38
contentbank/contenttype/h5p/classes/content.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* H5P Content manager class
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace contenttype_h5p;
|
||||
|
||||
use stdClass;
|
||||
use html_writer;
|
||||
|
||||
/**
|
||||
* H5P Content manager class
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class content extends \core_contentbank\content {
|
||||
}
|
90
contentbank/contenttype/h5p/classes/contenttype.php
Normal file
90
contentbank/contenttype/h5p/classes/contenttype.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* H5P content type manager class
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace contenttype_h5p;
|
||||
|
||||
use stdClass;
|
||||
use html_writer;
|
||||
|
||||
/**
|
||||
* H5P content bank manager class
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class contenttype extends \core_contentbank\contenttype {
|
||||
|
||||
/**
|
||||
* Returns the HTML content to add to view.php visualizer.
|
||||
*
|
||||
* @param stdClass $record Th content to be displayed.
|
||||
* @return string HTML code to include in view.php.
|
||||
*/
|
||||
public function get_view_content(\stdClass $record): string {
|
||||
$content = new content($record);
|
||||
$fileurl = $content->get_file_url();
|
||||
$html = html_writer::tag('h2', $content->get_name());
|
||||
$html .= \core_h5p\player::display($fileurl, new \stdClass(), true);
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML code to render the icon for H5P content types.
|
||||
*
|
||||
* @param string $contentname The contentname to add as alt value to the icon.
|
||||
* @return string HTML code to render the icon
|
||||
*/
|
||||
public function get_icon(string $contentname): string {
|
||||
global $OUTPUT;
|
||||
return $OUTPUT->pix_icon('f/h5p-64', $contentname, 'moodle', ['class' => 'iconsize-big']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of implemented features by this plugin.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_implemented_features(): array {
|
||||
return [self::CAN_UPLOAD];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of extensions this contenttype could manage.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_manageable_extensions(): array {
|
||||
return ['.h5p'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns user has access capability for the content itself.
|
||||
*
|
||||
* @return bool True if content could be accessed. False otherwise.
|
||||
*/
|
||||
protected function is_access_allowed(): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
44
contentbank/contenttype/h5p/classes/privacy/provider.php
Normal file
44
contentbank/contenttype/h5p/classes/privacy/provider.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Privacy provider implementation for core_contentbank.
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace contenttype_h5p\privacy;
|
||||
|
||||
/**
|
||||
* Privacy provider implementation for contenttype_h5p.
|
||||
*
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider implements \core_privacy\local\metadata\null_provider {
|
||||
|
||||
/**
|
||||
* Get the language string identifier with the component's language
|
||||
* file to explain why this plugin stores no data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_reason() : string {
|
||||
return 'privacy:metadata';
|
||||
}
|
||||
}
|
47
contentbank/contenttype/h5p/db/access.php
Normal file
47
contentbank/contenttype/h5p/db/access.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* H5P content bank contenttype capabilities.
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = [
|
||||
'contenttype/h5p:access' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
'contenttype/h5p:upload' => [
|
||||
'riskbitmask' => RISK_SPAM,
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => [
|
||||
'manager' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
]
|
||||
],
|
||||
];
|
29
contentbank/contenttype/h5p/lang/en/contenttype_h5p.php
Normal file
29
contentbank/contenttype/h5p/lang/en/contenttype_h5p.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for plugin 'contenttype_h5p'
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$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 to H5P content in the content bank';
|
||||
$string['h5p:upload'] = 'Upload a new H5P content';
|
29
contentbank/contenttype/h5p/version.php
Normal file
29
contentbank/contenttype/h5p/version.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Version details
|
||||
*
|
||||
* @package contenttype_h5p
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2020041500.00; // 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).
|
Loading…
x
Reference in New Issue
Block a user