Response to the discussion of https://h5p.org/comment/3567#comment-3567

Summary: The h5p module will reset user data (user achievement for the h5p content) even h5p content itself NOT CHANGED.

Here I will provide a half-way solution:

  • Let content author to decide to reset user data (achievement results) or not when saving the node (h5p node).
  • If the content author decide NOT to reset the user data, he or she will have the responsibility for the risk of incorrect user data result if h5p content is CHANGED.

The content admin need to add a Boolean field "field_reset_h5p_userdata" to the h5p node content type to make this work. The field name must be "field_reset_h5p_userdata" (as attached image).

Comments

hosais created an issue. See original summary.

hosais’s picture

StatusFileSize
new1.48 KB

Attach a patch.

icc’s picture

Thank you, we will try to review this for the next sprint.

partdigital’s picture

This is an old issue but I was running into the same problem. I found that the content_id would always change on node save (regardless of if there were any changes to H5P or not). This would cause the user's data to become out of sync with H5P and thereby "reset" the user's data.

I created a patch which addresses this immediate issue.

It checks to see if the h5p form has changed.

  • If it has - Then reset the user's content data as the old data is invalid. (Current Behavior)
  • If it hasn't - Then update the content_id of the existing user data so that it is in sync.

Note: This is a relatively fundamental change so this could cause a regression. I also don't like adding the database query directly in H5PEditorWidget. This should be part of H5P Core. However, I understand this may be only appropriate in the context of Drupal. I'll leave it up to the maintainers to determine the best place to put that code.

I should add: this was in the Drupal 8 version of the module.

partdigital’s picture

Issue summary: View changes
partdigital’s picture

Issue summary: View changes
christophersmith262’s picture

Updated to include keeping scores when the content id changes. The rationale being that you shouldn't wipe out the results for somebody who has completed the h5p content, even if the quiz changes, authors should have to explicitly state that they want results wiped out. I believe that functionality is available as part of the h5p widget already (see "clear results").

It looks like this issue is for the 7.x branch but we are actually committing patches against 8.x, should we create a new ticket?

jdearie’s picture

I installed patch in #7 (running on a D8 site) and while it does not clear the results - it also does not listen to the reset field settings.

I added a boolean field with a machine name of field_reset_h5p_userdata, but whether the box is checked or not, the results for the quiz are never cleared.

Did I read the comment wrong? Does the patch prevent the resetting of user data UNLESS the author uses the Clear Results option within the h5p content? And therefore I don't need that reset field? Where is the Clear Results option you're referring to? I only see Clear content. (using quiz h5p content type)

antiorario’s picture

Here’s a reroll to make sure the proper translation is loaded for the original entity on D8.

antiorario’s picture

Status: Active » Needs review
partdigital’s picture

Re-rolled the patch to work with Drupal 9. I also added in a check to see if h5p_save_content_state was enabled. It doesn't make sense to attempt to update user data if we're not capturing it anyway.