Coding error for emmbedded h5p after upgrade to Moodle 4.1

Coding error for emmbedded h5p after upgrade to Moodle 4.1

ved P H -
Antal besvarelser: 17
Billede af Particularly helpful Moodlers

I have recently upgraded from Moodle 3.11 to 4.1 and the embedded h5p now do not function with the following error message:

Error
Coding error detected, it must be fixed by a programmer: The course you passed to $PAGE->set_cm does not correspond to the $cm.

I can view and run the h5p activities on the course "content bank" but the same activities throw the above error message when embedded in a page.

Gennemsnitsbedømmelse:Useful (2)
I svar til P H

Re: Coding error for emmbedded h5p after upgrade to Moodle 4.1

ved P H -
Billede af Particularly helpful Moodlers
I still haven't found a solution for this. Any ideas anyone?
I svar til P H

Re: Coding error for emmbedded h5p after upgrade to Moodle 4.1

ved Joseph Rézeau -
Billede af Core developers Billede af Particularly helpful Moodlers Billede af Plugin developers Billede af Testers Billede af Translators

On my moodle 4.1 installation I have no problem embedding an H5P activity from the Content bank into a Page.

Since I cannot reproduce your problem I cannot help. Maybe you could try to provide more information?

I svar til Joseph Rézeau

Re: Coding error for emmbedded h5p after upgrade to Moodle 4.1

ved P H -
Billede af Particularly helpful Moodlers
Thank you for following this up Joseph.

I have since noticed that the embedded h5p activities function correctly when logged in as student, but throw the error message when logged in as admin. Intriguing...



Also, when I turn on debugging, I get this in the h5p embed area:

Warning: Attempt to read property "id" on null in .../lib/navigationlib.php on line 1550

Error

Coding error detected, it must be fixed by a programmer: The course you passed to $PAGE->set_cm does not correspond to the $cm.
Debug info:
Error code: codingerror
Stack trace:
  • line 1226 of /lib/pagelib.php: coding_exception thrown
  • line 4806 of /lib/navigationlib.php: call to moodle_page->set_cm()
  • line 4342 of /lib/navigationlib.php: call to settings_navigation->load_module_settings()
  • line 833 of /lib/pagelib.php: call to settings_navigation->initialise()
  • line 962 of /lib/pagelib.php: call to moodle_page->magic_get_settingsnav()
  • line 135 of /blocks/settings/block_settings.php: call to moodle_page->__get()
  • line 337 of /blocks/moodleblock.class.php: call to block_settings->get_content()
  • line 231 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
  • line 1222 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1280 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 377 of /lib/blocklib.php: call to block_manager->ensure_content_created()
  • line 4085 of /lib/outputrenderers.php: call to block_manager->region_has_content()
  • line 27 of /theme/boost/layout/embedded.php: call to core_renderer->blocks()
  • line 1473 of /lib/outputrenderers.php: call to include()
  • line 1399 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 69 of /h5p/embed.php: call to core_renderer->header()
I svar til Joseph Rézeau

Re: Coding error for emmbedded h5p after upgrade to Moodle 4.1

ved P H -
Billede af Particularly helpful Moodlers
One more thing:

The problem goes away when I am logged in through a separate student account, but persists if I just switch role to student
I svar til P H

Coding error for embedded H5P after upgrade to Moodle 4.02

ved Serena Richardson -

I am having the same issue, but it occurred after upgrading to Moodle 4.02. When trying to view H5P content , an error message is displayed, but only when logged-in as Admin (although edit function for H5P content is still visible and accessible). When logged in as a student user, l can see the H5P content no problem (a good thing!), without generating this error message:
Coding error detected, it must be fixed by a programmer:The course you passed to $PAGE->set_cm does not correspond to the $cm

Debug info:
Error code: codingerror
Stack trace:
  • line 1221 of /lib/pagelib.php: coding_exception thrown
  • line 4806 of /lib/navigationlib.php: call to moodle_page->set_cm()
  • line 4342 of /lib/navigationlib.php: call to settings_navigation->load_module_settings()
  • line 833 of /lib/pagelib.php: call to settings_navigation->initialise()
  • line 957 of /lib/pagelib.php: call to moodle_page->magic_get_settingsnav()
  • line 135 of /blocks/settings/block_settings.php: call to moodle_page->__get()
  • line 341 of /blocks/moodleblock.class.php: call to block_settings->get_content()
  • line 235 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
  • line 1222 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1280 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 377 of /lib/blocklib.php: call to block_manager->ensure_content_created()
  • line 4086 of /lib/outputrenderers.php: call to block_manager->region_has_content()
  • line 28 of /theme/remui/layout/embedded.php: call to core_renderer->blocks()
  • line 1473 of /lib/outputrenderers.php: call to include()
  • line 1399 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 69 of /h5p/embed.php: call to core_renderer->header()
I would appreciate any help as well.

I svar til Serena Richardson

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved P H -
Billede af Particularly helpful Moodlers
Hello. I wonder if you have been able to find a solution for this.
I svar til P H

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved Jon Johnson -
Hi I had the same problem and by removing the Admin block the problem was resolved. I added the Admin block back and everything still worked OK.
Hope this resolves your problem
However, I am testing Moodle 4.1 with PHP 8.1 and now the H5P content does not display at all.
Gennemsnitsbedømmelse:Useful (2)
I svar til Jon Johnson

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved Sara Arjona Téllez -
Billede af Core developers Billede af Moodle HQ Billede af Particularly helpful Moodlers Billede af Peer reviewers Billede af Plugin developers Billede af Testers
Hi Jon!
Moodle 4.1 doesn't support yet PHP 8.1: https://moodledev.io/general/releases/4.1
In this epic (you'll need to be logged in to see the list of issues associated), you'll find the current status for Moodle supporting PHP 8.1: https://tracker.moodle.org/browse/MDL-73016
Kind regards,
Sara
I svar til Sara Arjona Téllez

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved P H -
Billede af Particularly helpful Moodlers
Hello Sara,
I have php 8.0 on Moodle 4.1, so the problem must be due to something other than the php version I think.
I svar til Sara Arjona Téllez

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved P H -
Billede af Particularly helpful Moodlers
Well, I am back with some bad news. smiler

Removing the Administration block does indeed resolve the problem but adding the block back brings the problem back!
I svar til Jon Johnson

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved P H -
Billede af Particularly helpful Moodlers
Hello,
By the "Admin" block, do you mean "Admin notes" or "Administration"?
Regards
I svar til Jon Johnson

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved P H -
Billede af Particularly helpful Moodlers

I can confirm that removing and readding the Administration block solves the problem.

Thanks you Jon! 

I svar til P H

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved P H -
Billede af Particularly helpful Moodlers
I have to correct the above.

Removing the Administration block does indeed resolve the problem but adding the block back brings the problem back!
I svar til P H

Re: Coding error for embedded H5P after upgrade to Moodle 4.02

ved Serena Richardson -

Great news! That worked for me as well for fixing the H5P error, but for some reason I cannot add a new block... I am getting an "Invalid Record" error.