On Resume, how to use JavaScript to load record stored externally

Mar 17, 2023

I'm adding JavaScript triggers to my client's assessment to send data to an external database. We aren't using an LMS. We want users to be able to quit the assessment at any point and then resume later. Articulate's built-in  resume works okay for that (as long as localStorage isn't cleared).

But if a user resumes the assessment, I also need to retrieve from our database the record we saved for that user's assessment. I have an external JavaScript file inserted in story.html, and this JS file has functions to work with Articulate player and our own API. I have a function called GetAssessment to be called from JS triggers in SL. If GetAssessment doesn't find our assessment data already loaded, I have it send an HTTP GET to the API to retrieve the assessment record from the database. It can do this, but because there's a delay, the next line of JavaScript in the trigger fires before my API's response is resolved. So I wind up with an "undefined" assessment in Articulate player in the browser. What I want of course is my assessment object.

Originally I had hoped I could set an 'onload' trigger on the Resume button of the Prompt to Resume slide. But can't figure out how to do that.

So instead, I'm inferring that the user is resuming, and then trying to get and load my saved assessment record from the database. But the timing is off. Is there a way to make the player wait until my API has responded to the GET request?

2 Replies