Content Type Development
H5P has a modular architecture and the building blocks of H5P are called libraries. A library may be a content type, an application or an api for other libraries. Typically a content type consists of multiple H5P libraries with dependencies between each other.
Most of the libraries used on H5P.org are shared on GitHub. If you want to contribute to a library, coordinate with the maintainers and create pull requests. If you want to create your own content type, make sure to share it on H5P.org.
H5P has very few requirements that needs to be fulfilled by H5P libraries. The following example illustrates all that is needed to create a H5P library.
Hello world
A "Hello world" H5P library typically would need the following js. For a more in depth tutorial see our Hello world tutorial.
H5P.MyLib = (function ($) { /** * @class H5P.MyLib * @param {Object} params */ function MyLib(params) { var $wrapper; this.attach = function ($container) { if ($wrapper === undefined) { $wrapper = $('<div/>', { html: 'Hello ' + params.name }); } $container.html('').addClass('h5p-mylib').append($wrapper); }; } return MyLib; })(H5P.jQuery);
semantics.json
The following semantics.json is needed to describe its datastructure allowing the content to be edited and validated:
[ { "name": "name", "type": "text", "label": "What is your name?" } ]
library.json
And the following library data telling H5P what the name of the library is, which files it needs to preload etc.
{ "title": "My Lib", "machineName": "MyLib", "majorVersion": 1, "minorVersion": 0, "patchVersion": 0, "runnable": 1, "preloadedJs": [ {"path": "mylib.js"} ] }
With these tree files placed in an "H5P.MyLib" folder in Drupal's H5P development folder you should be able to create "MyLib" content.
In the following pages you'll learn everything you need to know to develop new H5P content types and customize existing ones:
Comments
tazkro
Tue, 06/09/2020 - 06:44
Permalink
Funcionalidad de H5P
hola amigos de H5P, estoy fascinado con la página. no soy desarrollador y estoy en busca de elementos y herramientas de apoyo para la creación de una página elearning.
después de tanto buscar tan intensamente encontré esta pagina y me gusto... después, encontré en un foro una respuesta sobre el código abierto para importar H5P a mi página y encontré finalmente la solución a los requerimientos que tengo para mi trabajo.
estoy fascinado y estoy esperando poder visitar más la página y poder llegar al propósito que busco.
gracias, muchas gracias por este aporte a la comunicad cibernauta. estoy seguro de que para las personas con mis intereses, esta página es lo mejor que pude haber encontrado y que estoy seguro que otras personas con el mismo propósito encontrarán.
John Billingsley
Tue, 11/03/2020 - 23:55
Permalink
Simulation
My eyes lit up when I saw that HTML5 was involved. But will it really do what I want?
For a dynamics course I needed to embed Javascript simulations to animate various demonstrations. You can see some more general examples at www.jollies.com. I found that I was able to park connected code pages in the 'file' resource of Moodle, but this was not really approved of. The Equella contents repository was clumsy to edit.
For another task I needed to use a .php script and there was no approved way to put that into Moodle.
So is H5P the answer to my hopes, or is it dedicated to applications similar to the examples?
Best wishes
John