Coding error for emmbedded h5p after upgrade to Moodle 4.1

Coding error for emmbedded h5p after upgrade to Moodle 4.1

P H -
回帖数:17
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.

平均分:Useful (2)
回复P H

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

P H -
Particularly helpful Moodlers的头像
I still haven't found a solution for this. Any ideas anyone?
回复P H

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

Joseph Rézeau -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像 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?

回复Joseph Rézeau

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

P H -
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()
回复Joseph Rézeau

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

P H -
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
回复P H

Coding error for embedded H5P after upgrade to Moodle 4.02

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.

回复Serena Richardson

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

P H -
Particularly helpful Moodlers的头像
Hello. I wonder if you have been able to find a solution for this.
回复P H

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

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.
回复Jon Johnson

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

Sara Arjona Téllez -
Core developers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像 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
回复Sara Arjona Téllez

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

P H -
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.
回复Sara Arjona Téllez

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

P H -
Particularly helpful Moodlers的头像
Well, I am back with some bad news. 微笑

Removing the Administration block does indeed resolve the problem but adding the block back brings the problem back!
回复Jon Johnson

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

P H -
Particularly helpful Moodlers的头像
Hello,
By the "Admin" block, do you mean "Admin notes" or "Administration"?
Regards
回复Jon Johnson

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

P H -
Particularly helpful Moodlers的头像

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

Thanks you Jon! 

回复P H

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

P H -
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!
回复P H

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

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.