Javascript to send score to external program

Sep 18, 2012

Hi, Storyline Fans -

I'm assisting a colleague with a bit of coding in an effort to capture the score from a Storyline quiz, and save it in a database (along with employee name, ID, date/time stamp, etc.).  I do not use Storyline - but I have developed a series of ASP programs that did a similar function with Presenter and Quizmaker products.

From the discussions I've found here, it appears that you can attach Javascript code to triggers associated with controls that you define on your Storyline screens.  Assuming that a "Submit Results" button has been defined on the final slide of a Storyline quiz (so, results have been displayed to the user) - can the following code be attached to a trigger in order to successfully pass the score to an external program?

Here is the code:

// get Storyline player

var p.GetPlayer();

// get score

var score = p.GetVar("Results.ScorePercent");

// pass score to ASP program to eventual database update

var sHTML = "";

sHTML += '<form id="formScore" method="post" action="/PathToProgram/SL_Post_Scores.asp">';

sHTML += 'input type="hidden" id="Score" name="Score" value= ' " + score + " '>';

sHTML += '<br><input type="submit"><br>';

sHTML += '<form>';


The SL_Post_Scores.asp program will prompt the user to enter the network login ID and password; validate their credentials against our Company's Active Directory; and - if valid - retrieve their score (using Request.Form("Score") and other employee demographics and insert it into a database that stores all of our exam/quiz results (we're replacing this interim solution with the Cornerstone LMS soon - but not soon enough!).  Does anyone see any problems with this approach?

45 Replies
Dustin Andjelkovich

Hi Ramesh,I was trying to find out this same thing and found out the following information in the story.js file that is part of the published storyline output:
Testing on a two question true/false slide 1

strQuizId - hex value
strId - Scene1_Slide1_True_False_0_0
strLMSId - TrueFalse
strType - truefalse
strCorrectResponse - true //answer set to true
strUserResponse - true //answered true
nLatency - 0
strStatus - Correct
nPoints - 10
strCompletedTime - 10:23:09 //time set on comp clock
nWeight - 1
nQuestionNumber - 1
strDescription - true
strQuizName - Results
bTracked - true

Hope this may help in someway, I was having an issue getting question level data, and this looks like the place where I need to get it from.

Ketki Dave

Jeff Furumura said:

Hi, Stefano -

Hmmm, I've tried to get the Little Paperclip icon to work for me - but nothing seems to upload.

I will message you directly and provide you with the Word document that I put together to provide to our eLearning author. The document explains step-by-step how to prepare the variables to be sent to an external database...and includes the javascript to insert as well.

I also have the ASP programs that were written for our environment here, if you want to see how they're put together. But I think the document explains their function clearly enough.



Hello Jeff,

Can you please upload the zip file, as while trying to extract the contents it gives a message saying the file is damaged or corrupted.

Midi Prefix
Steve Flowers

I've gotten Storyline connected with a Google Spreadsheet. Scores and names from SL variables posted to rows in the spreadsheet. Have used a little trickery to get variables back out of the spreadsheet as well (shouldn't be common or necessary.)

There are two pieces to getting "send to spreadsheet" to work.

  • The first is setting up the spreadsheet to catch the values. Create your spreadsheet with your field names in the first row. The names are important but you can use whatever you want. Next you'll need to add some Apps Script to catch the values and place them in the spreadsheet. See the tutorial here for a description of how to do that:
  • The next piece is setting up Storyline to send. You have two options here. One is to add a library like Jquery and POST the data through an Ajax call. The other is to dynamically create an iFrame on the page and set the URL of the iFrame to your apps script address extended with name value pairs, using GET. The Ajax call is cleaner, the iFrame querystring version is simpler to implement.

The code you'd use depends a lot on your implementation.

Hi there.

I am one of those uncommon folk who wants to be able to read data back from the spreadsheet. Any chance of telling us about the 'trickery' you used to get variables back out of the spread sheet there Steve?

It would also be great if you could explain to us how to add jQuery and use POST through an Ajax call.

I would like to be able to grab variables from Storyline, send them to the database, and then pick them up from the database later on (or even from a different course)

This method should make that possible.

Steve Flowers

Grr... I added a response and the site errored and bombed it out. Essentially, it was this:

  • To get data back from a spreadsheet, it needs to be exposed publicly. If any of your data is private, or you wouldn't want other learners (or random internet folk) to access this data, probably should not use this method.
  • Getting data out isn't tough. There is a url method that returns JSONP. It's nasty looking data but still parseable. A fellow wrote a jquery plugin to make this easier:
  • If you want to retrieve sanitized data, for something like a leaderboard, you can use pivot tables, formulas, or app script to write to another sheet, then publish that sheet.
Barclay Vision

I know the original question is a few years old, and the topic has progressed to spreadsheet - but I have a question on the passing score to new page:

why does the score var need to be assigned to a new field before it can be sent to new page? it seems the print report button will send most of these variables to the canned report.html page - how can this be done to a different (non-canned) page like myScore.html?

Aaron Leary

Hi all,

This thread is a little old so I hope someone has some wisdom in it.

I am trying to execute JavaScript to send the following data:

Text entry variable

Results variable

Lesson (time to complete the lesson).

I have managed to send text entry variables to email, using JavaScript but not the rest.

Does anybody have a solution for the otherother two variables?

Any support is greatly welcomed!

Jeff Furumura

Hi, Ketki Dave - Sorry for not monitoring this thread...hope this doesn't come too late.  I've attached the WORD doc that I put together for our training users to help guide them in setting up variables to be passed to an external program for eventual capture in an online database.

Laura Brunning

Hi Steve

Thanks for your JavaScript help previously, hopefully you can help me with this  too? :)

Apologies for the length of the post/waffle below:

I've been looking at retrieving data from my Google Sheet and putting the info back into Storyline.  I've been looking today at the SheetRock plugin that you suggested in your post.  I can see how it works to query the sheet and retrieve the data you want and the HTML they've used to display the info all seems logical - but I can't see how I can get this back into Storyline?  Would I have to create a webpage and then add it as a webobject into storyline? 

I was hoping to be able to set the value of blank variables based on the data in the Sheet.  I've seen examples in the forum where SetVar has been used to set a variable's value, but not from Google, so I hope it's possible...

What I'm trying to achieve:
The user works through Scorm package A.  JavaScript records their name/ID number (taken from the LMS), it also records a true/false variable value depending on their quiz score (so whether they passed or not), the time they start/finish each section is also recorded so the time spent on each is calculated in the spreadsheet.  This is recorded via the Google Form method into a Google Sheet.  This all works (hurrah!).

This is what I can't do (don't know if it's even possible), - the user then accesses Scorm package B, a week later.  Their name/ID will be taken via JS again and set as a variable.  This will be the unique identifier to lookup the correct row on the spreadsheet (the one with their data in it) - but, I then want to set blank variables in Scorm package B using the info from the sheet (collected during scorm package A).

For example, using the data in the spreadsheet, if they spent less than 5 mins on the quiz, I want to set a variable in Scorm package B called "tooquick" to true when it starts - then have a trigger that if "tooquick" is true, jump to more questions on the topic.  Or, if they didn't pass the quiz on Scorm A, a new variable in Scorm B is turned false and the state of a sad face picture is triggered to turn from hidden to normal (or they get sent to more slides with recap info/further revision etc.).

So, in conclusion,  I'm not sure how you set a variable from the info stored in Google sheets.

I hope that made sense, and I really hope you (or another very kind soul) are able to help me out!

Cheers, Laura

This discussion is closed. You can start a new discussion or contact Articulate Support.