Open clpetersonucf opened 6 years ago
To test locally, you'll have to check out branches on 3 different repos:
Materia: hackday/resume-support-for-widgets materia-client-assets: issue/1075-state-persistence Hospital Sim: issue/74-state-persistence-prototype
Refer to the steps posted in #1074 to update materia-client-assets in your local Materia install.
For Hospital Sim, a long-requested feature is to be able to "save" your work in case you lose it. As it is, if you navigate away or close your tab, the work you've done is gone.
As a possible solution, we've worked on a "state persistence" prototype - that is, temporarily storing state information about what the student has done in the widget player, and being able to recall that information if the student reloads the player.
Currently, the prototype uses
sessionStorage
, with most of the logic inmateria-client-assets
as it's mostly contained within the enginecore and Materia'splayer.js
. This is so the logic is agnostic and optional for widgets.The current implementation is as follows:
Materia.Engine.saveGameData()
and passing the state information as an object.player.js
via postMessage.sessionStorage
, as well as the Play ID and current URL (this could potentially be replaced with the context ID? Which would be far better)When a user reloads the page or navigates away and back to the player,
Widget.Engine.start()
function, viaMateria.Engine.resumeGameData()
player.js
via postMessage.sendToWidget
postMessage.Widget.Engine.resume
and passes along the instance, qset, and version parameters, along with the state object.Widget.Engine.resume
basically functions the same asstart
, except it applies the state information to return the player to the state the user last had it.