OK, I will try what you suggested.
The only thing I'm unsure about now is WHEN to do it. Since the student can leave the lesson at any time and come back later to the same place, it would seem that I'd have to use the localStorage copy of the variables as the master copy of the values, reading them in to the user variables whenever the values of the user variables need to be examined, and writing them back out whenever the user variables change inside the lesson. And I'd have to find some way to have code executed on their very first entry (and never again) to set up the initial values of the localStorage variables, and code which is invariably executed on exit which always saves the user variables to localStorage. I read that there used to be a place for an advanced action on exit, or something like that. Does that still exist? Perhaps I could always save the user variables THEN. On entry I could have a dummy first slide that does nothing but quickly initialize all the variables and advance to slide 2, and ensure they can never back up from slide 2 to slide 1. I'd appreciate it if you would comment on this approach as to whether it seems sound or viable. Thanks!
It's best if you use an included js file to do this. You can create the file and put the include in the index.html
The 'moduleReadyEvent' is only triggered once, create a function initVariables to get the vars form localStorage or initialize the localStaorage if it doesn't yet exist.
In the initializeEventListeners function you add a 'CPAPI_SLIDEENTER' listener, set the storage everytime you enter a slide.
Add a window.onunload function to set it again when the page unloads.
window.addEventListener( 'moduleReadyEvent', function ( e )
{
interfaceObj = e.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initVariables();
initializeEventListeners();
});
function initVariables()
{
//set up the localStorage
}
function initializeEventListeners()
{
if ( interfaceObj )
{
if ( eventEmitterObj )
{
eventEmitterObj.addEventListener( 'CPAPI_SLIDEENTER', function ( e )
{
//call a function to set the storage here.
});
}
}
}
window.onunload = function()
{
//call a function to set the storage here.
}