How to access quiz results from external JavaScript
Jun 08, 2015
I spent some time gathering info on this subject, and although there seems to be a lot written on the topic, none of the pages I read put it all together. This really is way simpler than people imagine.
Within Storyline, create a user variable NUMBER type called usrScorePoints - the data type must match the Results. For example, you can't set a usrScorePoints TEXT variable to the Results.ScorePoints. You can create a new user var for each of the scores/percents - all of which are NUMBER variables.
usrScorePercent for Results.ScorePercent
usrScorePoints for Results.ScorePoints
usrPassPercent for Results.PassPercent
usrPassPoints for Results.PassPoints
Create a trigger on the Results slide, and set the Action to Adjust variable usrScorePoints = Results.ScorePoints system var when Timeline starts. Do this for all the user vars.
Access the user vars in Javascript by using:
var player=GetPlayer();
var usrScorePoints=player.GetVar("usrScorePoints");
alert(usrScorePoints);
I created a custom Completion Certification that uses usrName and the pass/fail data to generate an HTML certificate as well as an encrypted code that includes the date, name, and score - I can use that to validate a learner's score in a CBT. I could just as well write a script to update an LMS if I needed to.
4 Replies
Hi, Kenneth, and welcome to the community!
Although we don't provide support for JavaScript coding, it may be helpful to take a look at this document on JavaScript Best Practices. Hopefully, some of our JS experts in the community can chime in with suggestions! :)
Awesome, great work!
Hello Kenneth,
Thank you for taking time to outline the procedures for passing quiz results via JS. Could you post/share an example storyline file and accompanying html file or a published storyline file that demonstrates how you created the completion certificate. you mentioned in your post.
Thank you!
Hi, Daniel -- In the event that Kenneth is no longer subscribed to this thread, you may want to reach out to him directly using the 'Contact Me' link on his profile page to see if he is able to share the file you'd like to review. :)