Previous state without plugin
Submitted by rlefort123 on Mon, 03/01/2021 - 18:19
Forums:
Hello H5P community,
I'm using https://github.com/h5p/h5p-drag-text/ content types, I'm trying to extend this library to handle a previous state without using Drupal or WordPress plugin. I want to retrieve data from Local Storage (actually) and pass it as a previous state to my content Drag the text. Is this something possible with xAPI or anything else ? Didn't find any informations about it ... thanks for helping.
Cheers.
Summary:
Pass previous state without using any plugins (Drupal, WordPress, ...)
Content types:
otacke
Tue, 03/02/2021 - 10:03
Permalink
Hi rlefort123!If you're able
Hi rlefort123!
If you're able to modify the parameters that the content types get from your solution: sure.
In order to retrieve the data, you only need to call getCurrentState() on content types (that implement it). Content types then expect the return value in the extras argument (as previousState) of their constructor function when they are instantiated.
Best,
Oliver
rlefort123
Tue, 03/02/2021 - 11:18
Permalink
Hello otacke, thanks
Hi otacke, thanks for your reply !
I'm new to H5P and I have to admit, I'm struggling to invoke the constructor with a previous state :(
Do you have any clues please ?
Best.
otacke
Tue, 03/02/2021 - 12:29
Permalink
Hi!That's a little hard
Hi!
That's a little hard without knowing anything about what you're doing, but the syntax basically is:
constructor(params, contentId, extras)
where
Essentially, wherever you call the constructor function of the content type, you need to pass something like
where foo is the value that was returned by getCurrentState().
Best,
Oliver