Is it possible to store/restore contentUserData from an LRS
Submitted by rkraemer on Mon, 08/22/2022 - 10:59
What would be the approach to store and restore contentUserData from an LRS. It is actually straightforward to store the contentUserData to an xAPI State. However, re-populating the H5P content with contentUserData from the xAPI State does not seem to work. It appears that, even if the state in the H5PIntegration.contents array is in place with the restored contentUserData, the H5P content will not render the state. Any ideas? Please advise, thank you!
Mon, 08/22/2022 - 15:05
Hi rkraemer!If you're talking
If you're talking about one of the existing H5P integrations (e.g. WordPress, Drupal, etc.), you just need to activate the respective setting in the plugin options.
If you're trying to create a custom solution, you'd not use the xAPI state (it does not contain the content type's state, merely the score and potentially some of the user inputs).
Content types that support this feature have a `getCurrentState` function that will return the state that needs to be stored. So, in order to retrieve the current state, you'd call that function on a content type instance (if it has that function) and store the return value.
When instantiating H5P content, there's the 3rd argument (often called `extras` in code) which is an object and can hold a `previousState` property. That's where the value that you have stored before (the return value of `getCurrentState`) needs to go.
Wed, 08/24/2022 - 10:55
Hi Oliver, I am working on a
Hi Oliver, I am working on a custom solution with a CMS and I have been using the 'getCurrentState' function to store the data temporarily in browser sessionStorage. With that I can restore 'previousState' and/or 'preloadedData' in H5P.getUserData in H5P.js.
Objects in H5P.instances, like
and in H5PIntegration.contents, like
seem to get properly restored.
However the H5P content, like Multiple-choice, will not display or render the previous state - what am I mising? Thank you
Wed, 08/24/2022 - 14:23
Hi!Things that come to my
Things that come to my mind - I don't know your implementation:
Thu, 08/25/2022 - 07:32
The CMS I am working on is
The CMS I am working on is Typo3 with the "H5p" Extension installed. It appears that the values are passed in time to the 'H5P.newRunnable' function as shown in my previous post. Also H5PIntegration.saveFreq is set to 30. Is there a particular "trigger" that invokes the rendering for the previous state that I am missing?
Thu, 08/25/2022 - 08:23
Hello again!No, there's no
Maybe there's some encoding issue somewhere?
Fri, 08/26/2022 - 07:37
Hi Oliver,the issue was that
the issue was that 'previousState' expects an object and not a string. Now that the previous state may be restored, I was wondering why the previuos state is not fully restored. For example, on a multiple-choice interaction, you would submit a selection of answers and then receive the feedback. When the state of the multiple choice is restored I would expect that the selected answers and the feedback will be displayed. However currently only the selected answers are displayed without the feedback. Is that by design?
Anyway, many thanks for the quick support!
Fri, 08/26/2022 - 22:48
Hi Robert!I am not sure if
I am not sure if that's "by design" or rather "by omission", but yes. Most content types only re-create the answers but not what I call the "view state" (showing results, showing the solutions, possibly something else).