Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H5P resources are not resized when included in labels #83

Open
institut-agro-ead opened this issue Sep 18, 2023 · 0 comments
Open

H5P resources are not resized when included in labels #83

institut-agro-ead opened this issue Sep 18, 2023 · 0 comments

Comments

@institut-agro-ead
Copy link

Hello,

For some time now, it is possible to include external H5P activities in Moodle via the text editor (H5P button). You just have to upload your H5P file and Moodle handles the rest. Moodle uses a filter to transform the H5P file URL to an iframe when loading the course. In order to adjust the height of the iframe, the filter when building the HTML that generates the iframe, also adds a script tag with its own resizer javacript code (resizer.js). To avoid loading the JS file multiple times when there are several H5P iframes, the filter checks if the script has already been loaded once (via a static prop in the filter_displayh5p class).

Here is what it looks like in a course. You have to scroll in the label, not very practical.

image

Why is this happening for this course format and not the others?

It took me some time to understand it but it has to do with the way the content for a card is generated in this plugin. In the card_one_section_renderable.php file, more specifically in the get_activities_details method which is responsible to get the content that will be displayed in the card, either as a summary or the full content for labels and folders, the content is generated twice, once for the summary prop and once for the fullcontent prop. By calling $this->courseformatdatacommontrait->course_section_cm_text($mod, $displayoptions) twice, the H5P iframe is generated twice, once with the resizer script and the second time without. The problem is, it’s the second call which will be set as fullcontent (for labels and folders), resulting in a lack of resizer script when displayed in the template.

To solve this, $this->courseformatdatacommontrait->course_section_cm_text($mod, $displayoptions) should only be called once and stored in a temporary variable which will then be used to set the summary and the fullcontent props.

Not knowing how this plugin fully works, there might be others places where this change needs to be done, not only the card_one_section_renderable.php file ?

Thank you

@institut-agro-ead institut-agro-ead changed the title H5P resources are not resize when included in labels H5P resources are not resized when included in labels Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant