How does saving progress work?
Submitted by otacke on Fri, 08/18/2017 - 00:42
Forums:
I glanced at some of the content types in order to identify the way that the progress or state is saved, but so far I have only found the code for retrieving those two from contentData. How does storing work?
tomaj
Mon, 08/21/2017 - 09:49
Permalink
Implement getCurrentState
Hi Oliver,
The content type needs to implement the getCurrentState method, which enables saving objects, that are returned later as contentData.
The getCurrentState function is called in regular intervalls, as well as being triggered on most xapi statements.
- Tom
otacke
Mon, 08/21/2017 - 12:59
Permalink
Thanks, Tom!
Thanks, Tom!
otacke
Tue, 08/22/2017 - 07:41
Permalink
I had a look at it. Very
I had a look at it. Very simple if you stay within your own content type. Nice! But it seems to be a little more tricky if you build upon other libraries (which in turn may build upon other libraries) as "Document Tool" does. Is there any recommended approach to tackle this problem? Would implementing a serialize/deserialize methods for each library that could be called by other libraries be a clean solution?
tomaj
Tue, 08/22/2017 - 09:04
Permalink
State handling
I don't think there are that many cases where the libraries has a state, so I've not encountered this problem myself.
But yea, I think letting a library keep the code for serializing/deserializing (maybe trough a getCurrentState-method) would be the easiest way.
- Tom
otacke
Tue, 08/22/2017 - 09:33
Permalink
I encountered that problem
I encountered that problem yesterday when having a brief look at the documentation tool, but maybe I simply don't see the obvious. It references several "page" libraries that in turn use a variable number of TextInputFields, etc. If I wanted to store the content state of the documentation tool, I'd have to collect all the current values of fields and parsing the DOM seemed to be a little weird to me.
tomaj
Wed, 08/23/2017 - 08:59
Permalink
Depends
I think it depends a bit on what you are trying to do.
For most content types some user input is stored as a member variable when submitted, so it's easy to access from getCurrentState. But in other cases (like Documentation tool), it needs to grab fresh data the dom.
Do you have some code to share, maybe I can provide some better feedback?
- Tom
otacke
Wed, 08/23/2017 - 09:24
Permalink
I was actually looking at
I was actually looking at Documentation Tool for a colleague who would love it to save the content state. I figured that I couldn't do it in a couple of hours, but maybe I missed something.
tomaj
Thu, 08/24/2017 - 08:54
Permalink
Doc tool
Ah ok.
I've not worked on Documentation Tool myself, so I don't know alot about it. But good luck, if you're going to try to sort it out! :)
- Tom
otacke
Thu, 08/24/2017 - 09:09
Permalink
I guess I will, but my list
I guess I will, but my list of stuff I could do for H5P is growing longer every day and there's this nasty thing called job that takes quite some time ;-)
tomaj
Thu, 08/24/2017 - 09:09
Permalink
Hehe
Hehe
otacke
Thu, 08/24/2017 - 23:50
Permalink
What about this code? It
What about this code? It could be used to build something like a "getCurrentState cascade" from "Document Tool" over "standard page" (and the other three page libraries) down to "text input field" (and the other basic libraries).
I tested it with my demo of Essay that also uses "text input field" and now can store the user's text. Works fine.
tomaj
Fri, 08/25/2017 - 09:10
Permalink
Pull request
I just glanced over the pull request, and it looks pretty straight forward.
We are just finishing up a release here now, so I created a task for reviewing your pull request, and assigned it to the next upcoming release (Thrud).
- Tom
otacke
Fri, 08/25/2017 - 09:15
Permalink
Thanks! Enjoy you day of
Thanks! Enjoy you day of awesomeness when the release is done :-) You will have earned it.
tomaj
Fri, 08/25/2017 - 09:57
Permalink
Thanks!
Thanks! Sure I'll enjoy my "day of coolness", and I'll work on my new combine the pairs content type.
- Tom
otacke
Fri, 08/25/2017 - 12:18
Permalink
Gee, nice. It's often used
Gee, nice. It's often used when teaching languages AFAIK. It will probably be pretty useful to a lot of people.
serettig
Thu, 08/31/2017 - 14:30
Permalink
Hi tomaj,is having a
Hi tomaj,
is having a getCurrentState() method all that is necessary to store the state or do I also have to implement xAPI? So far, I've put in getCurrentState() but not implemented xAPI besides calling triggerXAPI('interacted') when the user does something of relevance. However, getCurrentState() is never called. In h5p-blanks it seems that it is called when creating the xAPI template for the event 'answered'. So must it be called manuelle after all or can getCurrentState() be considered a virtual method that I can override and is called by parent code?
Thanks
Sebastian
otacke
Thu, 08/31/2017 - 14:47
Permalink
If implemented in your
If implemented in your content type, getCurrentState() is called by the h5p-php-library automatically in regular intervals, given that you activated the Save Content State option in your plugin's settings. You don't need xAPI statements here, although those containing the verb completed or progressed also trigger saving the current content state if the Save content State option is set.
serettig
Thu, 08/31/2017 - 17:28
Permalink
Thanks, I didn't have Save
Thanks, I didn't have Save content State enabled in Drupal. Now it works!
otacke
Mon, 09/04/2017 - 19:04
Permalink
Just a question that crossed
Just a question that crossed my mind: In order to store a user's input within the host system, he/she needs to be logged in. This makes sense in course-like settings, but there may be scenarios where users are not required to log in somewhere but you still want to give them the opportunity to interrupt their work and continue later on. In that case would it be feasible to store the data in a cookie and to retrieve it from there? Storing the data within the host system should still be prioritized because this way users are more flexible with using different devices. However, having a cookie as a fallback solution might be nice. What do you think?
thomasmars
Tue, 09/05/2017 - 14:00
Permalink
Yes, this might be useful.
Yes, this might be useful. Perhaps it should be stored using the web storage API though, since it does not really need to be sent to the server.
otacke
Tue, 09/05/2017 - 14:02
Permalink
I'll put it on my list ... :
I'll put it on my list ... :-D
otacke
Wed, 07/31/2019 - 13:21
Permalink
Hi Thomas!This is a thread
Hi Thomas!
This is a thread well aged now :-D Do you think there's any reason (security in particular) for not pursuing this?
Keeping it at 1 and 2, maybe also 3 could be a reasonalbe step already. I just wonder if the local storage should be an extra option in the host system settings or if it should be automatically included in the save content state option (thus ruling out 3). And which storage (database vs. local storage) should take precedence if someone has two states, one from not being logged in (local storage) and one from being logged in (database)? Could be solved by comparing timestamps, just needs to be done ...
Cheers,
Ollie
thomasmars
Wed, 07/31/2019 - 13:30
Permalink
Yes, I see no problems having
Yes, I see no problems having local storage in addition to save content state.
otacke
Wed, 07/31/2019 - 13:43
Permalink
Cool! I guess I might
Cool! I guess I might implement that very soon then.
otacke
Fri, 03/27/2020 - 21:06
Permalink
The university of Freiburg,
The university of Freiburg, Germany decided to fund the required changes for the H5P core and for the WordPress plugin.
There you go:
Details can be found in the pull request descriptions. Let me know if I should create a JIRA ticket based on those.
Cheers,
Oliver
p. s.: For user questions: Latest changes by Apple to webkit will erase localStorage entries after not using them for one week in Safari/on iOS, cmp. https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/
camille miozzo
Fri, 04/24/2020 - 14:15
Permalink
i am sorry, i don't understand your work
Hello, I am not a developper and I don't really understand how this works. Should I count on this feature implemented in the next update of H5P wordpress plugin ?
otacke
Fri, 04/24/2020 - 18:53
Permalink
Hi!I don't know if the H5P
Hi!
I don't know if the H5P core team is going to include this (ever). If they do, then yes, it'll be in one of the updates to the WordPress plugin.
Best,
Oliver
BV52
Fri, 04/24/2020 - 18:54
Permalink
Hi Camille,Pull requests are
Hi Camille,
Pull requests are changes that were made to the code and waiting for approval from the person that manages a specific code repository. Once the pull request is approved it will be merged into the official version and will be released as an update. Right now this specific pull request has not been reviewed, tested and merged yet. I won't be able to provide any timelines when this may be released.
-BV