Basic Boilerplate hello-world example from download to moodle-ready h5p package.
Hello. I am learning h5p but unfortunately a lot of branches on this forum are either incomplete, unclear or missing important details. I wanted to ask for help with the most basic example and at the same time provide a good starting point for someone who is also trying to learn basics of h5p.
Current goal I want to achieve is to simple create an h5p package that can be uploaded to moodle course and display a 'hello world message'.
Here is the sequence of actions I have taken so far for this attempt, following multiple tutorials and examples (I am working on Windows 11):
- Download & installed node.js
- Installed h5p and its command line interface via command "npm install -g h5p-cli".
- Downloaded a zipped example of the boilerplate 'hello world' from the official github (https://github.com/h5p/h5p-boilerplate) and unpacked it.
- Opened the folder in Visual Studio Code and ran the command 'npm install' via the terminal to install all the necessary libraries/packages.
- Within the same folder from the same terminal ran the command 'npm run build' to package the library for distribution.
- Via the same terminal went one folder up, to the folder containing the unzipped 'h5p-boilerplate-master' folder and packaged the library using the following command: 'h5p pack h5p-boilerplate-master test.h5p', in order to create the h5p package in the current folder.
- Renamed the 'test.h5p' to 'test.zip' to be able to open it like an archive.
- Following advice on this forum created an h5p.json file I am attaching to this post and manually added it to the 'test.zip' (via simple drag&drop)
- Renamed the 'test.zip' back to test.h5p
- Uploaded it to moodle via 'Add Activity/Resource -> H5P -> Upload'.
Unfortunately I am currently getting the error 'Validating h5p package failed. Missing main library @library'.
I suspect my issues start with step 7 or 8, and I would be very grateful if someone could explain what exactly my error is, so that I could both fix it and to leave a clear record of the most basic example for other novices to follow, because even getting to the current point has taken me days if not weeks.
otacke
Wed, 11/06/2024 - 19:41
Permalink
Hi!If you want to just use
Hi!
If you want to just use the library, you do not need to turn it into H5P content. You could just upload your packed library on the H5P library management page of moodle and then use it like any other content.
I am little curious if you're really running the latest version of the H5P CLI tool, becuase the pack command should now require `h5p utils pack`, but that should not interfere with the usage.
If you really want to create a content archive - your h5p.json looks fine at a glance - then you'll also need a file named content.json inside a folder named content. It needs to provide the parameters that the "author" entered. Please see the H5P file specification.
I am not sure that's what moodle wants to convey with the error message. My best guess here is that you're not uploading the file with administrative rights, hence the library cannot be installed from the H5P file. Please compare https://snordian.de/2022/12/31/why-cant-i-upload-h5p-content/ for what happens when you upload H5P content.
Also, if ensure that the zip tool that you're using does not alter the -X and -D flag on the archive. People often run into trouble if they manually zip files for H5P because they don't set these zip flags.
And one last note: Please consider using the H5P CLI tool's inbuilt server to develop H5P content types. You won't have much fun doing that on moodle.
Best,
Oliver
Tugeev
Thu, 11/07/2024 - 09:53
Permalink
Details
Thank you for the detailed feedback.
otacke
Thu, 11/07/2024 - 16:17
Permalink
You can run `npm list -g` in
Tugeev
Thu, 11/07/2024 - 13:43
Permalink
Another update
I tried using the CLI-server that you mentioned to test the permission issue. I have done the following:
If I understand correctly, libraries define activity type, while the 'content' folder and h5p.json define the specific form and content this activity type takes each time the new instance is created.
My question is, I think then, as follows:
When working with moodle, how do I add a new library (i.e. like the 'h5p-boilerplate-master' folder) to the appropriate place so that I can create new instances of that activity?
otacke
Thu, 11/07/2024 - 18:27
Permalink
Hi!------There's a tutorial
Hi!
You understood correctly.
Again: You will have to upload library files via the H5P library management page in the admin settings.