How can I make H5P save answers for items
Submitted by dnote on Sat, 11/28/2020 - 18:37
Forums:
Take for example a multiple choice question.
The first time I display the item I want the student to select a choice and press "Check".
My backend will then store the score via LTI.
The next time I display the item I want the student not to be able to select a choice, but instead I want H5P to display the choice the student selected previously.
Is this possbile?
I'm accessing H5P through my website with its own LTI connection but when testing this from Canvas I see the same behaviour.
Dave
BV52
Mon, 11/30/2020 - 17:23
Permalink
Hi Dave,The "save content
Hi Dave,
The "save content state" provides one half of what you are looking for which is it saves the answers of the students but it does not "lock" them. Also this is only available if you use one of the plugins created for Moodle, Wordpress or Drupal.
-BV
dnote
Mon, 11/30/2020 - 17:40
Permalink
Thats what I figured
Hi BV52, thanks for responding. I will move away from LTI for now then and create my own H5P player for .net. That way I can keep control over all aspects.
dnote
Sun, 12/06/2020 - 22:33
Permalink
One step further
Hi again. I gotten a little bit further and am now able to show answers previously records by filling the H5PIntegration.contents[x].contentUserData when rendering the page the second time.
The previously filled in answers are selected, but the problem is, they can still by modified by the user. Is it possible to show the content in "solution mode"?
So this:
Instead of this:
Thanks a lot!
Dave
otacke
Mon, 12/07/2020 - 07:09
Permalink
Hi Dave!I think that most
Hi Dave!
I think that most question-like content types implement the question type contract (https://h5p.org/documentation/developers/contracts), so you should be able to check for the showSolutions function and call it.
Best,
Oliver
dnote
Mon, 12/07/2020 - 11:08
Permalink
And how do I get the instance to do that?
Hi Oliver, thanks. Seems simple enough. But how do I get the instance of the content right after it's being displayed? The first xAPI event (which passes the instance) is too early to do anything with it.
otacke
Mon, 12/07/2020 - 20:38
Permalink
Hi Dave!You can add your own
Hi Dave!
You can add your own script to accompany content types using the alter-scripts hook (cmp. https://h5p.org/node/2692). That script will run right away, can wait for content to be initialized (you can e.g. pick up the "initialized" event from H5P.externalDispatcher), add listeners, etc.
Best,
Oliver
dnote
Fri, 12/11/2020 - 12:16
Permalink
on initialized
Thanks for your input. I ended up using the initialized event of the external dispatcher which seemed simpler than using the alter-scripts hook:
// After initialization, put the content items that are previously finished in "solution mode". H5P.externalDispatcher.on('initialized', function (_event) { for (var i = 0; i < instances.length; i++) { const instance = instances[i]; if (window.H5PCompleted[instance.contentId]) { if (instance.showSolutions) { instance.showSolutions(); } } } });