├── README.md ├── config.php ├── js ├── custom.js └── customEditor.js ├── lang └── en │ └── theme_h5pmod.php ├── renderers.php ├── style └── custom.css └── version.php /README.md: -------------------------------------------------------------------------------- 1 | H5P Mods 2 | ========== 3 | 4 | This H5PMod theme is provided as an example of how you can use renderer provided by the H5P plugin. The renderer overrides are used for altering or adding H5P content or library resources. 5 | 6 | ## Getting started 7 | 8 | 1. Clone the repository to your theme folder 9 | 2. Make sure to rename the project folder to the same name as your theme, as found in config.php. 10 | 3. Enable the theme in your Moodle server under the appearance settings 11 | 12 | ## Usage 13 | 14 | Feel free to fork this project or simply use it as a template for doing your 15 | own custom modifications to H5P. 16 | 17 | You should be aware that the hooks you add on your site will not follow 18 | the content if it's exported. 19 | 20 | ## License 21 | 22 | (The MIT License) 23 | 24 | Copyright (c) 2017 Joubel AS 25 | 26 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | name = 'h5pmod'; 4 | 5 | ///////////////////////////////// 6 | // The only thing you need to change in this file when copying it to 7 | // create a new theme is the name above. You also need to change the name 8 | // in version.php and lang/en/theme_clean.php as well. 9 | ////////////////////////////////// 10 | // 11 | $THEME->doctype = 'html5'; 12 | $THEME->parents = array('boost'); 13 | $THEME->sheets = array('custom'); 14 | $THEME->supportscssoptimisation = false; 15 | $THEME->yuicssmodules = array(); 16 | $THEME->enable_dock = true; 17 | $THEME->editor_sheets = array(); 18 | 19 | $THEME->rendererfactory = 'theme_overridden_renderer_factory'; 20 | $THEME->csspostprocess = 'theme_h5pmod_process_css'; 21 | -------------------------------------------------------------------------------- /js/custom.js: -------------------------------------------------------------------------------- 1 | console.log("Hello, this is custom.js!"); 2 | (function ($) { 3 | $(document).ready(function () { 4 | 5 | setTimeout(function () { 6 | $('.h5p-control.h5p-playbackRate').css('background', 'green'); 7 | 8 | }, 5000) 9 | }) 10 | 11 | })(H5P.jQuery); 12 | -------------------------------------------------------------------------------- /js/customEditor.js: -------------------------------------------------------------------------------- 1 | console.log("Hello, this is customEditor.js!"); 2 | (function ($) { 3 | $(document).ready(function () { 4 | 5 | setTimeout(function () { 6 | $('.h5peditor-label').css('background', 'pink'); 7 | 8 | }, 5000) 9 | }) 10 | 11 | })(H5P.jQuery); 12 | -------------------------------------------------------------------------------- /lang/en/theme_h5pmod.php: -------------------------------------------------------------------------------- 1 | dirroot . '/mod/hvp/renderer.php'); 5 | 6 | /** 7 | * Class theme_h5pmod_mod_hvp_renderer 8 | * 9 | * Extends the H5P renderer so that we are able to override the relevant 10 | * functions declared there 11 | */ 12 | class theme_h5pmod_mod_hvp_renderer extends mod_hvp_renderer { 13 | 14 | /** 15 | * Add styles when an H5P is displayed. 16 | * 17 | * @param array $styles Styles that will be applied. 18 | * @param array $libraries Libraries that wil be shown. 19 | * @param string $embedType How the H5P is displayed. 20 | */ 21 | public function hvp_alter_styles(&$styles, $libraries, $embedType) { 22 | global $CFG; 23 | if ( 24 | isset($libraries['H5P.InteractiveVideo']) && 25 | $libraries['H5P.InteractiveVideo']['majorVersion'] == '1' 26 | ) { 27 | $styles[] = (object) array( 28 | 'path' => $CFG->httpswwwroot . '/theme/h5pmod/style/custom.css', 29 | 'version' => '?ver=0.0.1', 30 | ); 31 | } 32 | } 33 | 34 | /** 35 | * Add scripts when an H5P is displayed. 36 | * 37 | * @param object $scripts Scripts that will be applied. 38 | * @param array $libraries Libraries that will be displayed. 39 | * @param string $embedType How the H5P is displayed. 40 | */ 41 | public function hvp_alter_scripts(&$scripts, $libraries, $embedType) { 42 | global $CFG; 43 | if ( 44 | isset($libraries['H5P.InteractiveVideo']) && 45 | $libraries['H5P.InteractiveVideo']['majorVersion'] == '1' 46 | ) { 47 | $include_file = ($embedType === 'editor' ? 'customEditor.js' : 'custom.js'); 48 | $scripts[] = (object) array( 49 | 'path' => $CFG->httpswwwroot . '/theme/h5pmod/js/' . $include_file, 50 | 'version' => '?ver=0.0.1', 51 | ); 52 | } 53 | } 54 | 55 | /** 56 | * Alter a library's semantics 57 | * 58 | * May be used to ad more fields to a library, change a widget, allow more 59 | * html tags, etc. 60 | * 61 | * @param object $semantics Library semantics 62 | * @param string $name Name of library 63 | * @param int $majorVersion Major version of library 64 | * @param int $minorVersion Minor version of library 65 | */ 66 | public function hvp_alter_semantics(&$semantics, $name, $majorVersion, $minorVersion) { 67 | if ( 68 | $name === 'H5P.MultiChoice' && 69 | $majorVersion == 1 70 | ) { 71 | array_shift($semantics); 72 | } 73 | } 74 | 75 | /** 76 | * Alter an H5Ps parameters. 77 | * 78 | * May be used to alter the content itself or the behaviour of an H5 79 | * 80 | * @param object $parameters Parameters of library as json object 81 | * @param string $name Name of library 82 | * @param int $majorVersion Major version of library 83 | * @param int $minorVersion Minor version of library 84 | */ 85 | public function hvp_alter_filtered_parameters(&$parameters, $name, $majorVersion, $minorVersion) { 86 | if ( 87 | $name === 'H5P.MultiChoice' && 88 | $majorVersion == 1 89 | ) { 90 | $parameters->question .= '

Generated at ' . time() . '

'; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /style/custom.css: -------------------------------------------------------------------------------- 1 | .h5p-slider { 2 | background: red; 3 | } 4 | 5 | .h5p-joubelui-button { 6 | background: deeppink !important; 7 | } 8 | -------------------------------------------------------------------------------- /version.php: -------------------------------------------------------------------------------- 1 | version = 2016052500; 6 | $plugin->requires = 2016051900; 7 | $plugin->component = 'theme_h5pmod'; 8 | $plugin->dependencies = array( 9 | 'theme_boost' => 2020110900, 10 | ); 11 | --------------------------------------------------------------------------------