h5p / moodle-mod_hvp

H5P Plugin for Moodle
GNU General Public License v3.0
131 stars 169 forks source link

Totara - Exception -round(): Argument #1 ($num) must be of type int|float, string given #563

Open maria-saarnilearning opened 1 week ago

maria-saarnilearning commented 1 week ago

Our customer is trying to update (add content) already existing H5P course presentation content in Totara course. They are getting an error message when trying to save the changes.



Debug info:
Error code: generalexceptionmessage

Stack trace:
• line 1630 of /lib/gradelib.php: TypeError thrown
• line 1630 of /lib/gradelib.php: call to round()
• line 341 of /mod/hvp/mod_form.php: call to grade_floatval()
• line 643 of /lib/formslib.php: call to mod_hvp_mod_form->validation()
• line 579 of /lib/formslib.php: call to moodleform->validate_defined_fields()
• line 689 of /lib/formslib.php: call to moodleform->is_validated()
• line 413 of /mod/hvp/mod_form.php: call to moodleform->get_data()
line 171 of /course/modedit.php: call to mod_hvp_mod_form->get_data() ```

I looked this problem is coming up  with PHP 8.0 and later versions
We have tried updating  the plugin to 1.23.1 version
Other info:

PHP Version 8.1.29

Interactive Content – H5P 1.23.1 
2023052600
  (1.22.0 was the old one)

Totara [Versio 17.21 (Build: 20240806.00)](https://www.totaralearning.com/)

[Moodle](http://moodle.org/) [3.4.9 (Build: 20190513)](http://docs.moodle.org/dev/Releases)

We can work around this issue by copying the H5P content and adding it as a new activity with the same H5P content. We will make the necessary modifications to the content and set all the activity completion conditions at the same time. This is because trying to edit it again leads to an error, and it cannot be saved.

What might be the problem, and can it be fixed?
Thank you for your help, I appreciate it.
maria-saarnilearning commented 1 week ago

From Totara Support " Given that the problem is related to the Moodle H5P plugin, our best advice would be to raise an issue with the plugin maintainer via their GitHub page because we don’t provide support for issues that arise as a result of third-party plugin.

As a best guess at the moment, the error suggests that the round() function in PHP is receiving a string as its first argument but it expects an integer or a float. Looking at the line in the stack trace before the round(), it would appear that grade_floatval() in H5P might be the cause, which is causing some conflict.

Given that the PHP version for the Totara site is 8.1, there is a strong possibility that enforcement of strict types could be at play and if you do raise this with the plugin maintainer, I’d recommend letting them know the PHP version."