h5p / h5p-wordpress-plugin

Adds support for H5P Content in WordPress.
https://wordpress.org/plugins/h5p/
71 stars 74 forks source link

No suspendData string? #113

Open alexjalex opened 4 years ago

alexjalex commented 4 years ago

Regarding the state saving capabilities, is there anyway when creating custom components to allow suspend data to save.

In SCORM, this is implemented with a single large string that is saved per user.

When creating custom SCORM interactives, it's up to the developer to fill this string with whatever custom key/value system they make.

I want to replace our custom SCORM interactives with H5P, but the docs only say (Start and End Time, Scores) are saved. That is not useful.

otacke commented 4 years ago

Hi @alexjalex !

At first I thought I understood your question, but then your last paragraph confused me.

Are you asking for storing the state of interactions - the students progress - so students can leave, return later and continue where they left off? Many H5P content types allow this if you activate the save content state feature in the plugins settings. If turned on, the state is saved to database for users that are logged in. There's also a pull request that would retrofit storing/retrieving the state in/from local storage for users that are not logged in. The state is not put into the H5P file that you may download however. If that's what you are looking for, then you could create a feature request.

If you're developing your own content type, you just need to implement a function named getCurrentState that would be called by H5P and return the current state (usually as a JSON object).

Or are you asking for scores etc? H5P uses xAPI to report all kinds of user experiences, but it's up to site owners to forward all the data to a separate Learning Record Store. If you are developing your own content types and want to use xAPI to document user experience, possibly some state values, there are extensive xAPI specs.

Best, Oliver

alexjalex commented 4 years ago

Looks like contentUserData is what i'm looking for.

Kinda hard to find details about it. There's a tiny bit here, https://h5p.org/creating-your-own-h5p-plugin.

I can't find any of the following on the API, maybe i'm derping.

Any tips for where to get me started would be greatly appreciated. The tutorials are a bit light on complexity.

otacke commented 4 years ago

Hi @alexjalex ! I agree. The documentation might need some love. I believe the H5P core team knows and I hope that they will find someone to maintain it soon, or that some people from with the H5P community get in touch with them in order to help out.

As a content type developer, you can implement a function getCurrentState in your content type which is called by the core of H5P in regular intervals (definable in the host system's settings) and when an xAPI call with the verb completed or progressed is triggered by the content type. H5P expects the return value of getCurrentState to be an object that defines the state that the content is in. You as a content type developer decide what's best to model the state here. The state will then be passed to the host system using setUserData (the counterpart is getUserData).

The state will then be stored inside (retrieved from) a database table in the host system that essentially links a user id with a content id and the stringified state object retrieved from getCurrentState.

When a content type is started by a user, H5P will try to fetch a previous state for this content type and user and pass it to the content type's constructor in the third parameter. A constructor usually reads something like constructor(params, contentId, contentData) where contentData.previousState will either be undefined or hold the previous state that was returned by getCurrentState.