project: Moodle
summary: Tools to improve H5P content integration in Moodle 3.8
description: This project is intended to provide for Moodle one of the open-source solutions (H5P) to allow teachers to easily use engaging content in their activities. For Moodle 3.8 (this epic) we are integrating the following H5P functionality: H5P renderer Ability to add H5P content through an Atto editor button everywhere Atto can be used Filter to automatically convert p urls to embed code This functionality will be able to be used in conjunction with the existing H5P plugin| For Moodle 3.9 we are planning to integrate the full functionality of the existing H5P plugin: Integrate H5P content types as Moodle activities (but with improved integration and user experience) Connect the H5P content types to gradebook and activity completion

1.summary: Create a basic skeleton to storage p content
description: Create a basic skeleton for the H5P integration Create new core_component Entry in lib/components.json Added as a subsystem. Create DB tables Move H5P library module to core libraries Propose location be lib/p Create a readme_moodle.txt file with the version of the library that we have included and how to import a new version. Add the library details to thirdpartylibs.xml Add lang/en/p.php for language strings.
2.summary: Implement H5PFileStorage
description: Implement H5PFileStorage following Moodle core standards and APIs. Maybe not all the functions are needed, so research which are needed for the renderer without the editor. Add Unit tests when possible.
3.summary: Implement H5PFrameworkInterface
description: Implement H5PFrameworkInterface following Moodle core standards and APIs. Maybe not all the functions are needed, so research which are needed for the renderer without the editor. Add Unit tests when possible.
4.summary: Create a new button in Atto to add H5P content in anywhere from hp5.com and p.org external URLs
description: As a tool for content creators, to make it easier to use existing H5P content in Moodle, we have to create a new Atto button to add H5P content. The behavior of the new insert H5P content button allows to add a new URL to an external H5P content. For URLs like or the button should add the HTML code above: code:javacode or code:java code Tasks: - Create a basic skeleton H5P plugin for Atto - Create templates/icon/styles for JS tabs - Add TAB Pane for Embed URL H5P. Allow external URLs from p.com and hp5.org - Create new capability for using H5P atto button - Create callbacks - Privacy: No user data
5.summary: Create renderer for deploying and displaying H5P content
description: Create an embed.php page to load all libraries needed for rendering H5P content. Reuse existing view_assets class from mod_hvp external plugin, to ensure it follows Moodle core standards and add any function we need for the new H5P content renderer. Add Unit tests when possible. Tasks: Create a new capability to view H5P content
6.summary: Create embed.php renderer for H5P content
description: Create an embed.php page to load all libraries needed for rendering H5P content in an iframe. Based on existing mod_hvp external plugin and reviewed view_assets class in core. Tasks: Create a new capability to view H5P content
7.summary: Improve H5P Atto button to upload content
description: Tasks: Add TAB Pane for Upload H5P content Unzip uploaded file and save in the file system Fill p table with needed information Add the right embed code: code:java code Note: The requirements for this button have changed: The file upload is no longer shown in a separate tab as decided by the UX team The wording of Dialogue has changed The button does not interact with the p DB When a file is uploaded a placeholder image is shown with the p file url hidden inside. code:java code
8.summary: Create a new filter to convert p.com and p.org urls to embed code
description: As a tool for content creators, to make it easier to use existing H5P content in Moodle, we have to create a new filter that allows to display automatically the H5P links from p.org or p.com. For URLs like or the button should add the HTML code above: || or || || | | Tasks: Create a basic skeleton H5P filter Add/Edit filters settings: default width and weight. Default values for geolocation, microphone, camera, midi and encrypted-media permissions. Prepare filter to convert URLs into a player: URL from a domain (no package) - Use H5P.org/.com embed code to render Privacy: No user data
9.summary: Implement backup and restore process for H5P content
description: Using the new Atto button to upload and insert H5P content, we are creating content in the DB and spreading unzipped files in the file system. We need to check and be sure everything is ok once we backup and restore that content created using Atto editor. Once this issue was ready we have a new scenario when we need to implement the backup and restore regarding the embed.php URLs. We have URLs like localhost/moodle/p/embed.php?url= So, we are going to translate these URLs in the Backup/Restore in something like $
10.summary: Create the basic skeleton, library and interfaces for rendering H5P content
description: Create a basic skeleton for the H5P integration. It will include the minimum required for making work the H5P renderer.
11.summary: Create appropriate events for H5P content renderer
description: Create view event for H5P content renderer View Delete Create/Update events will be for 3.9 when we could create a H5P Content.
12.summary: Improve H5P filter to allow internal H5P content URLs
description: For URLs like or the button should add the HTML code above: code:javacode Tasks: Improve filter to convert internal H5P content from the content bank
13.summary: New behat tests for H5P tools
description: Create new behat tests for: H5P atto button H5P filter
14.summary: Privacy provider for new H5P core component
description: Create a new Privacy provider for H5P component.
15.summary: When clicking an H5P iframe overlay in Atto it should activate the H5P button
description: This is a follow up issue for : When an H5P is added as an externally embedded iframe and the overlay div is clicked in the Atto editor the p button should be activated and contain the iframe embed URL, as happens with the image or the media buttons: !edit_media_atto.png|thumbnail!
16.summary: Web service to enable H5P offline access in the Moodle app
description: We are going to need a WebService that does the following: It will receive the URL of an H5P package. The WS should check if that package can be played (check the trusted capability and so). Its the same check that the embed.php will do in Moodle, that way the app will know if the package can be downloaded for offline usage or not. If it cannot be played, the WS should return a warning or a flag that indicates this case. We could use a moodle exception too if you think its better. If the package can be played and hasnt been deployed before, the WS should deploy it now. Once deployed, the WS should build a new H5P file with the trusted content_type libraries (downloaded from p hub). The app cannot use the original p file because it contains content_type libraries that arent trusted. The WS should return the new p files URL, size and timemodified/hash. You can check the class _external_files_ to see the data thats usually returned for files in WebServices. The app needs to be able to know if the p file needs to be re-downloaded or not, so we need a hash or a timemodified that tells it. A file needs to be re-downloaded if the user uploaded a new p file or if any of the content_type libraries has been updated.
17.summary: Create a capability to update H5P content-type libraries
description: Whilst reviewing the H5P integration () an issue has been raised to control who can install/update the content-type libraries. There are 2 different approaches, one taking the libraries always from the H5P hub (api.p.org) or similar and another adding a capability to admin and managers (p:uploadlibraries) to let them upload/deploy the libraries in the .p file. The first looks nicer but, as for now the H5P hub is only returning the latest content-type libraries, well go for the second one for now (and will try to go for the first in the future). Requirements: Create a new capability: p:updatelibraries This capability would be enabled by default for managers and admins, but not for teachers To write/overwrite a new content type library, a user would need the new p:updatelibraries capability Users with p:deploy capability but without p:updatelibraries capability will be able to upload new H5P content that uses existing libraries in the site. In case any of the libraries they are trying to use in the uploaded content is not available, they would get an error asking them to contact their admin to make that library available, because they dont have p:updatelibraries permission
18.summary: Create a task to install H5P content-type libraries
description: Whilst reviewing the H5P integration () an issue has been raised to control who can install/update the content-type libraries. A capability will be added in , but then, in order to make easy for admins to download the latest content type libraries via p.org API, a new cron task should be created to automate it.
19.summary: Add Admin UI to manually upload H5P content-type libraries
description: Whilst reviewing the H5P integration () an issue has been raised to control who can install/update the content-type libraries. Thats why admins/managers need a simple UI to manually upload any content or content type library version.
20.summary: Let the embed.php redirect to login (requirement for the app)
description: Dani Palou has raised this issue: When the embed.php file is opened in a browser where the user is not logged in, an error is displayed, instead of redirecting the user to the login page. The mobile app wont have a Moodle web session in the iframe. It has a script to auto-login the user in the iframe, but it has some limitations (e.g. it only works in sites) so itd be nice if the user can authenticate manually inside the iframe if we cannot authenticate him automatically. A new parameter will be added to the embed to let the app to use it to redirect (instead of display the error).
21.summary: H5P PHPUnit test fixes
description: Some things which Ive come across and which need fixing. PHPUNIT_LONGTEST required in framework tests which call download_file_content: test_fetchExternalData_no_path_defined and friends runTestsInSeparateProcess required for all tests which include the H5P libraries. This is because they will load libraries which can conflict with a known third-party library and will either cause that plugins tests to fail, or will fail because of that plugin at some point in the future.
22.summary: Create an specific file type for p file extension
description: For now p files is not a known file type for Moodle. If p is added to known file types it will help in some scenarios: Currently, when selecting a local file with ATTO p button is not filtering by filetype and the user can select any kind of file (even not p compatible) When an admin uploads a new p library version the only filetype specified is Zip. This works because p file are compressed in zip format but can be more specific.
23.summary: List H5P content types and libraries in the H5P Admin UI
description: List the available H5P content types and libraries in the H5P Admin UI
24.summary: The performance decrease using new Atto H5P button
description: This is leading to an increase in DB reads: between before - 38 (e04a73c on-demand...) and after - 38 (d9285b7 Merge bra...) - increment: dbreads - All steps data combined -> 1.21 worst . Fill a forum to reply a forum discussion Before: 88 reads After: 92 reads
25.summary: H5P: ease-of-first-time fetch of H5P content-type libraries
description: H5P requires content-type libraries to run properly. As these libraries can content risky code, only trusted users can upload them (). So, H5P content uploaded by users wont work if previously the H5P content-type libraries have not been loaded. There is a scheduled task that fetches these content-type libraries directly from H5P and must be run before uploading any H5P content (). Additionally, administrators and managers can upload manually content-types using from Site administration > H5P > Manage H5P content types (). After a new installation or upgrade of a site, users have to wait until the scheduled task runs successfully for the first time, or until an administrator or manager manually loads the content-type libraries. To streamline this process, we are pondering several options: add a button in the administration interface to fetch the content-type libraries change the frequency at which the task is run run the task right after installation/upgrade

Below is an instruction that describes a task, paired with an input that provides an epic with this format: 
"project": "Name of the project" 
"summary": "Summary of the epic user story" 
"description": "Description of the epic user story". Write a response that appropriately completes the request.### Instruction:
Break this epic user story into smaller tasks to help the developers understand the epic better, you can divide this epic into as much as you want depending on the complexity of the epic.
### Input:
project: Moodle
summary: Tools to improve H5P content integration in Moodle 3.8
description: This project is intended to provide for Moodle one of the open-source solutions (H5P) to allow teachers to easily use engaging content in their activities. For Moodle 3.8 (this epic) we are integrating the following H5P functionality: H5P renderer Ability to add H5P content through an Atto editor button everywhere Atto can be used Filter to automatically convert p urls to embed code This functionality will be able to be used in conjunction with the existing H5P plugin| For Moodle 3.9 we are planning to integrate the full functionality of the existing H5P plugin: Integrate H5P content types as Moodle activities (but with improved integration and user experience) Connect the H5P content types to gradebook and activity completion

### Response:
1.summary: Create a basic skeleton to storage p content
description: Create a basic skeleton for the H5P integration Create new core_component Entry in lib/components.json Added as a subsystem. Create DB tables Move H5P library module to core libraries Propose location be lib/p Create a readme_moodle.txt file with the version of the library that we have included and how to import a new version. Add the library details to thirdpartylibs.xml Add lang/en/p.php for language strings.
2.summary: Implement H5PFileStorage
description: Implement H5PFileStorage following Moodle core standards and APIs. Maybe not all the functions are needed, so research which are needed for the renderer without the editor. Add Unit tests when possible.
3.summary: Implement H5PFrameworkInterface
description: Implement H5PFrameworkInterface following Moodle core standards and APIs. Maybe not all the functions are needed, so research which are needed for the renderer without the editor. Add Unit tests when possible.
4.summary: Create a new button in Atto to add H5P content in anywhere from hp5.com and p.org external URLs
description: As a tool for content creators, to make it easier to use existing H5P content in Moodle, we have to create a new Atto button to add H5P content. The behavior of the new insert H5P content button allows to add a new URL to an external H5P content. For URLs like or the button should add the HTML code above: code:javacode or code:java code Tasks: - Create a basic skeleton H5P plugin for Atto - Create templates/icon/styles for JS tabs - Add TAB Pane for Embed URL H5P. Allow external URLs from p.com and hp5.org - Create new capability for using H5P atto button - Create callbacks - Privacy: No user data
5.summary: Create renderer for deploying and displaying H5P content
description: Create an embed.php page to load all libraries needed for rendering H5P content. Reuse existing view_assets class from mod_hvp external plugin, to ensure it follows Moodle core standards and add any function we need for the new H5P content renderer. Add Unit tests when possible. Tasks: Create a new capability to view H5P content
6.summary: Create embed.php renderer for H5P content
description: Create an embed.php page to load all libraries needed for rendering H5P content in an iframe. Based on existing mod_hvp external plugin and reviewed view_assets class in core. Tasks: Create a new capability to view H5P content
7.summary: Improve H5P Atto button to upload content
description: Tasks: Add TAB Pane for Upload H5P content Unzip uploaded file and save in the file system Fill p table with needed information Add the right embed code: code:java code Note: The requirements for this button have changed: The file upload is no longer shown in a separate tab as decided by the UX team The wording of Dialogue has changed The button does not interact with the p DB When a file is uploaded a placeholder image is shown with the p file url hidden inside. code:java code
8.summary: Create a new filter to convert p.com and p.org urls to embed code
description: As a tool for content creators, to make it easier to use existing H5P content in Moodle, we have to create a new filter that allows to display automatically the H5P links from p.org or p.com. For URLs like or the button should add the HTML code above: || or || || | | Tasks: Create a basic skeleton H5P filter Add/Edit filters settings: default width and weight. Default values for geolocation, microphone, camera, midi and encrypted-media permissions. Prepare filter to convert URLs into a player: URL from a domain (no package) - Use H5P.org/.com embed code to render Privacy: No user data
9.summary: Implement backup and restore process for H5P content
description: Using the new Atto button to upload and insert H5P content, we are creating content in the DB and spreading unzipped files in the file system. We need to check and be sure everything is ok once we backup and restore that content created using Atto editor. Once this issue was ready we have a new scenario when we need to implement the backup and restore regarding the embed.php URLs. We have URLs like localhost/moodle/p/embed.php?url= So, we are going to translate these URLs in the Backup/Restore in something like $
10.summary: Create the basic skeleton, library and interfaces for rendering H5P content
description: Create a basic skeleton for the H5P integration. It will include the minimum required for making work the H5P renderer.
11.summary: Create appropriate events for H5P content renderer
description: Create view event for H5P content renderer View Delete Create/Update events will be for 3.9 when we could create a H5P Content.
12.summary: Improve H5P filter to allow internal H5P content URLs
description: For URLs like or the button should add the HTML code above: code:javacode Tasks: Improve filter to convert internal H5P content from the content bank
13.summary: New behat tests for H5P tools
description: Create new behat tests for: H5P atto button H5P filter
14.summary: Privacy provider for new H5P core component
description: Create a new Privacy provider for H5P component.
15.summary: When clicking an H5P iframe overlay in Atto it should activate the H5P button
description: This is a follow up issue for : When an H5P is added as an externally embedded iframe and the overlay div is clicked in the Atto editor the p button should be activated and contain the iframe embed URL, as happens with the image or the media buttons: !edit_media_atto.png|thumbnail!
16.summary: Web service to enable H5P offline access in the Moodle app
description: We are going to need a WebService that does the following: It will receive the URL of an H5P package. The WS should check if that package can be played (check the trusted capability and so). Its the same check that the embed.php will do in Moodle, that way the app will know if the package can be downloaded for offline usage or not. If it cannot be played, the WS should return a warning or a flag that indicates this case. We could use a moodle exception too if you think its better. If the package can be played and hasnt been deployed before, the WS should deploy it now. Once deployed, the WS should build a new H5P file with the trusted content_type libraries (downloaded from p hub). The app cannot use the original p file because it contains content_type libraries that arent trusted. The WS should return the new p files URL, size and timemodified/hash. You can check the class _external_files_ to see the data thats usually returned for files in WebServices. The app needs to be able to know if the p file needs to be re-downloaded or not, so we need a hash or a timemodified that tells it. A file needs to be re-downloaded if the user uploaded a new p file or if any of the content_type libraries has been updated.
17.summary: Create a capability to update H5P content-type libraries
description: Whilst reviewing the H5P integration () an issue has been raised to control who can install/update the content-type libraries. There are 2 different approaches, one taking the libraries always from the H5P hub (api.p.org) or similar and another adding a capability to admin and managers (p:uploadlibraries) to let them upload/deploy the libraries in the .p file. The first looks nicer but, as for now the H5P hub is only returning the latest content-type libraries, well go for the second one for now (and will try to go for the first in the future). Requirements: Create a new capability: p:updatelibraries This capability would be enabled by default for managers and admins, but not for teachers To write/overwrite a new content type library, a user would need the new p:updatelibraries capability Users with p:deploy capability but without p:updatelibraries capability will be able to upload new H5P content that uses existing libraries in the site. In case any of the libraries they are trying to use in the uploaded content is not available, they would get an error asking them to contact their admin to make that library available, because they dont have p:updatelibraries permission
18.summary: Create a task to install H5P content-type libraries
description: Whilst reviewing the H5P integration () an issue has been raised to control who can install/update the content-type libraries. A capability will be added in , but then, in order to make easy for admins to download the latest content type libraries via p.org API, a new cron task should be created to automate it.
19.summary: Add Admin UI to manually upload H5P content-type libraries
description: Whilst reviewing the H5P integration () an issue has been raised to control who can install/update the content-type libraries. Thats why admins/managers need a simple UI to manually upload any content or content type library version.
20.summary: Let the embed.php redirect to login (requirement for the app)
description: Dani Palou has raised this issue: When the embed.php file is opened in a browser where the user is not logged in, an error is displayed, instead of redirecting the user to the login page. The mobile app wont have a Moodle web session in the iframe. It has a script to auto-login the user in the iframe, but it has some limitations (e.g. it only works in sites) so itd be nice if the user can authenticate manually inside the iframe if we cannot authenticate him automatically. A new parameter will be added to the embed to let the app to use it to redirect (instead of display the error).
21.summary: H5P PHPUnit test fixes
description: Some things which Ive come across and which need fixing. PHPUNIT_LONGTEST required in framework tests which call download_file_content: test_fetchExternalData_no_path_defined and friends runTestsInSeparateProcess required for all tests which include the H5P libraries. This is because they will load libraries which can conflict with a known third-party library and will either cause that plugins tests to fail, or will fail because of that plugin at some point in the future.
22.summary: Create an specific file type for p file extension
description: For now p files is not a known file type for Moodle. If p is added to known file types it will help in some scenarios: Currently, when selecting a local file with ATTO p button is not filtering by filetype and the user can select any kind of file (even not p compatible) When an admin uploads a new p library version the only filetype specified is Zip. This works because p file are compressed in zip format but can be more specific.
23.summary: List H5P content types and libraries in the H5P Admin UI
description: List the available H5P content types and libraries in the H5P Admin UI
24.summary: The performance decrease using new Atto H5P button
description: This is leading to an increase in DB reads: between before - 38 (e04a73c on-demand...) and after - 38 (d9285b7 Merge bra...) - increment: dbreads - All steps data combined -> 1.21 worst . Fill a forum to reply a forum discussion Before: 88 reads After: 92 reads
25.summary: H5P: ease-of-first-time fetch of H5P content-type libraries
description: H5P requires content-type libraries to run properly. As these libraries can content risky code, only trusted users can upload them (). So, H5P content uploaded by users wont work if previously the H5P content-type libraries have not been loaded. There is a scheduled task that fetches these content-type libraries directly from H5P and must be run before uploading any H5P content (). Additionally, administrators and managers can upload manually content-types using from Site administration > H5P > Manage H5P content types (). After a new installation or upgrade of a site, users have to wait until the scheduled task runs successfully for the first time, or until an administrator or manager manually loads the content-type libraries. To streamline this process, we are pondering several options: add a button in the administration interface to fetch the content-type libraries change the frequency at which the task is run run the task right after installation/upgrade
