This PR fixes the error when grading using an H5P component with the User content state save frequency enabled.
To Reproduce Error
Adds to a unit a H5P component.
Configure the H5P component: Adds a H5P content, e.g. Interactive Video, set Is Scorable = True, and User content state save frequency = 1 (or higher)
Configure the subsection of the unit as grading.
Solve some questions of the aggregated component from the LMS (not all of them need to be solved) and submit the answers.
In the logs of the container we can see this error:
2023-08-22 22:10:22,680 ERROR 320 [h5pxblock.h5pxblock] [user 4] [ip 172.20.0.1] h5pxblock.py:293 - Error while
publishing score float() argument must be a string or a number, not 'NoneType'
This error happens because the first time the answers are uploaded, the previous_score variable should be set to None, but for some reason, having the User content state save frequency field enabled does not happen. As the variable is not set to None, certain actions are executed ending in a TyperError in the compare_scores method, since the parameters earned1 and possible1 are set to None.
Description
This PR fixes the error when grading using an H5P component with the
User content state save frequency
enabled.To Reproduce Error
Is Scorable = True
, andUser content state save frequency = 1
(or higher)This error happens because the first time the answers are uploaded, the
previous_score
variable should be set toNone
, but for some reason, having theUser content state save frequency
field enabled does not happen. As the variable is not set toNone
, certain actions are executed ending in aTyperError
in thecompare_scores
method, since the parametersearned1
andpossible1
are set toNone
.Before
https://github.com/edly-io/h5pxblock/assets/64033729/933f90a1-4680-42f3-a961-9648afbeb231
After
https://github.com/edly-io/h5pxblock/assets/64033729/d766ad86-d539-4b76-bf58-c833562b2170