Results and contentUserData - Python

Forums: 

Good morning.

I have been spending the last few weeks deconstructing the wordpress plugin and have built an implementation in Python for a project we are working on.  I have run into some confusion around results and contentUserData.  I'm currently trying to get the content type to display the learner's prior answer when they navigate back to an activity.  I understand the contentUserData key/value in the json.  What I don't understand is the contentUserData under the ajax key.  I see the results table and that it's storing the max scores, etc and that the table for content_user_data is storing the answer from the learner.  My questions are:

  1. What does preload, invalidate and data_id have to do with the learner and the activity?
  2. I see that the ajax url for contentUserData is requested on page load and then when they answer the activity.  Why on page load?
  3. Why are results stored seperately from contentUserData?
  4. What is the sub id under the contentUserData key?

Thanks,

Greg

icc's picture

Hi Greg, it's cool to hear that you're digging into H5P so let me try to answer your questions as best as possible:

  1. The contentUserData doesn't just contain the previousState of the content, but it also provides the capability to store different data through the data_id, e.g. it can be used by the content to remember if a user has already taken the introduction wizard. Invalidate determine if the data should be reset when the content is changed, i.e. the data is sensitive to changes to the 'parameters'. Preload means that the data will automatically be loaded when the content is viewed, i.e. you don't have to wait for an AJAX to fetch it.
  2. This will happen if the 'preload' isn't working as expected – or data is being fetched that hasn't set 'preload'.
  3. I believe that they can be stored together – They're probably apart because they were created as two separate APIs.
  4. The sub id is used when data is stored by an interaction inside of another – not to mix the data with the parents data. I believe this is an uuid.

 

In the case where the userData is not preloaded, the content comes from an asynchronous AJAX call. How can the content type (in this case a custom one) be notified that the contentUserData has arrived?