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>';
document.getElementById("formScore").submit();
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
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.
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.
this does not work for me im afraid. trying to assignResults3.ScorePoints to varQuiz1ScorePoints and export to a Google Spreadsheet. The Google bit works for another variable. Maybe its the timeline trigger, did anyone have any bother with that?
thanks
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.
Grr... I added a response and the site errored and bombed it out. Essentially, it was this:
Thanks Steve, that's somewhat helpful. If I manage to get this whole thing sorted out, I'll try my best to make a full post detailing the steps involved. I am probably going to -try- and use something other than google docs though, in case I need to store something I have more control of the security for in the future.
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?
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!
Well, what are your variables stored as, and where are they from/how are they generated/recorded?
If you can send a text entry, then you can send anything so I'm not sure what the problem is here?
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.
Hi Jeff,
Thank you for this. I will check it out and let you know how I get on.
Many thanks,
Aaron
Good luck with it, Aaron. Note that it was written after the initial release of Storyline so I can't vouch for it's use with the current release.
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
Hi, Laura -- As this thread is a bit older, some of the participants may no longer be subscribed. You are welcome to reach out to individuals directly using the 'Contact Me' link on their profile page. Best of luck with your project! :)
Hi Jeff Furumura,
Hope you are doing good. your post might be helpful for me as i am implementing same problem statement.
Could you please share me project files (i.e. storyline project, DB Dump and ASP Project).
Thanks
Hey Nicky,
This forum discussion is a bit older so I'm not certain that Jeff is still subscribed here. You may want to message him directly using the "contact me" button on his profile to see if he's able to share any specifics with you on what he set up.
Best of luck with your project.
hi, i want to log in console player variable value but getting below error:
Uncaught ReferenceError: GetPlayer is not defined
i am currently using story_html5 file
Hello Sujeet and welcome to E-Learning Heroes :)
Your custom JavaScript is not something that I can assist in supporting, but hopefully someone in the community will be able to chime in and assist here.
Just stumbled across this old post. Any chance you'd post your asp form to see how it works?
Many thanks.
Hey Paul,
Jeff's post was quite a while ago and I'm not sure if he's still subscribed here. You are certainly welcome to reach out to the user directly via the 'Contact Me' option on the user profile if you do not hear back soon.
This discussion is closed. You can start a new discussion or contact Articulate Support.