2

I tried to find the solution to my question everywhere without a result.

Let me explain the problem. I have a moodle docker. We can install H5P there by following these steps in: https://github.com/h5p/moodle-mod_hvp

Now we can manually install the H5P libraries like Interactive Video, Quiz, etc. from the moodle running. We just have to Create a new course>H5p Interactive Content>Get and Install any library.

There are separate GitHub repos for these libraries. Now, for my own work, I have made some forked and made some changes to some of these repos of these libraries. Now I want to install my H5P libraries in my moodle without making to Pull request to the original H5P interactive video GitHub page.

I found that we can make some changes in the renderer.php as stated in: https://github.com/h5p/h5pmods-moodle-plugin

I have git cloned H5P along with my x.js file in moodle/mod. So the folder structure is moodle/mod/hvp/{all the files from H5P Interactive Video + my x.js}

Following the steps from https://github.com/h5p/h5pmods-moodle-plugin, I am doing:

 /**
     * Add scripts when an H5P is displayed.
     *
     * @param object $scripts Scripts that will be applied.
     * @param array $libraries Libraries that will be displayed.
     * @param string $embedType How the H5P is displayed.
     */
    public function hvp_alter_scripts(&$scripts, $libraries, $embedType) {
        console.log(process.cwd());
        global $CFG;
        $scripts[] = (object) array(
            'path'    => 'x.js',
            'version' => '?ver=0.0.1',
        );
    }

However, it is not working. I have already checked (without docker exec) that all the files are in the moodle/mod/hvp. I wonder if this strategy at all will work for something other than some styling css.

Can someone help me out here?

  • hi, might be of interest https://teaching-resources.delta.ncsu.edu/h5p-interactive-content/ – jspcal Feb 01 '23 at 20:51
  • I found this link: https://h5p.org/node/561980 ... which makes even less sense – Khabbab Zakaria Feb 01 '23 at 21:38
  • The `alter_scripts` hook does not expect original content type files. It is merely a way to add your own custom JavaScript files to the H5P iframe content that can then interact with the JavaScript code. You could, for instance, listen for H5P events, override exposed variables and functions, etc. – Oliver Tacke Feb 02 '23 at 08:25
  • If you want to modify the original code you need to build, pack and upload your modifications. The post at https://peter.baumgartner.name/2021/04/12/h5p-library-installation/ essentially describes the process. Keep in mind that your changes will be overridden once you install updates to official libraries. You'd need to fork including changing the content types machine name - more on that in the H5P specification documentation at https://h5p.org/documentation/developers/h5p-specification – Oliver Tacke Feb 02 '23 at 08:29
  • Hi @OliverTacke, thank you. I am checking the link. Just 1 question. Does this strategy also work for if I want make changes not in a library but let's say h5p-video? I want to make some changes in h5p-video/scripts. – Khabbab Zakaria Feb 02 '23 at 08:37
  • @KhabbabZakaria H5P.Video is a library, it's just not a _runnable_ content type. You can use both approaches, but the right one depends on what you're trying to achieve. – Oliver Tacke Feb 02 '23 at 11:21
  • @OliverTacke, I am trying to make some changes in the h5p-video/scripts so that it runs mpeg-dash. I think I missed something. I cloned the repo, made changes, used h5p cli to make a .h5p file, and uploaded it in Site Administration>Manage H5P content types of my moodle instance. Although I had increased the video player versions from 1.6.9 to 1.7, when I try h5p-interactiveVideo and 'inspect element', I only see the 1.6.9 versions of video.js, Vimeo.js, YouTube.js, etc. Am I missing something? – Khabbab Zakaria Feb 02 '23 at 11:50
  • 1
    a) Yes, for such a change, the `alter_scripts` will probably not suffice. b) You have uploaded that library to moodle's custom H5P integration, but not to the H5P plugin for moodle that you're using. They don't share libraries. The H5P plugin has its own library settings page. c) You should NOT increase the version numbers unless you fork content types. This will cause you and potentially others trouble ultimately. d) Please use the H5P forum for those kind of discussions, not stack overflow. – Oliver Tacke Feb 02 '23 at 13:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/251570/discussion-between-khabbab-zakaria-and-oliver-tacke). – Khabbab Zakaria Feb 02 '23 at 14:56

0 Answers0