Email quiz results using java script

I'm new to Storyline.  I found an article detailing how to insert java script to email quiz results since my company doesn't use an LMS.   I'm attaching what I've done so far but it doesn't seem to work.   

Here's the java script I used:

var email=lclucy@email.com;
var player = GetPlayer();
var subject=”Results”;
var body_start=player.GetVar(“NumericEntry”);
body_text = body_start;
var mailto_link=’mailto:’+email+’?subject=’+subject
+’&body=’+body_text;
win=window.open(mailto_link,’emailWin’);

Thanks for your help!

 

 

 

24 Replies
Steve Flowers

var email=lclucy@email.com;

That will also probably kick an error and cause it to fail. The email should be a string like this:

var email="lclucy@email.com";

While email can work. I generally prefer to use some kind of server side end-point as it's less steps for the user and doesn't rely on an email client. Some users with gmail / similar might have problems launching the right application. It's a little more complicated but if you're interested and able to run that route, I'll post some refs where you can drop all kinds of things into a Google Spreadsheet. Good for record keeping to boot:)

Steve Flowers

Hey Matthew - 

Give this a try. I used a Google Form as an endpoint in this example. Two different JS Triggers. One loads JQuery into the document head. The other executes to send data via POST. This is the simplest way I could find to do it. The delay was necessary for one of the browsers I tested as far as I remember. Could be for mobile / iOS. Don't remember:)

 

Matthew Bibby

Hi Liliana, I'm not sure what's causing the problem without having a proper look at how your course is set up. Are you able to share your Storyline file?

Did you add quotes around the email address as Steve mentioned above?

Are you testing this in its intended environment (it won't work if you are just testing it locally)?

Liliana Lucy

Hi Matthew,

I am fairly new to Storyline so I'm not sure what you mean by sharing the storyline file. If you can be very specific I can send you what you need.
I did add the quotation marks.
Not sure what you mean by testing locally. I put my email address in the script. Nothing happened.

Sorry. I know I'm asking very basic questions. I do thank you for your help.

Lily Cisneros Lucy
Learning Specialist
AAA Northern California, Nevada & Utah
1900 Powell Street, 10th Fl.
Emeryville, CA 94608
Office Phone:510 596-4849

Matthew Bibby

By sharing the storyline file I mean either posting the yourcoursename.story file on the forum or emailing it to me directly so that I can have a look and figure out where you've gone wrong. 

In order to test if the javascript is working, you'll need to upload your file to a web server or LMS, as it won't work if you are just opening it on your computer. If you don't have a way to do this, you could use TempShare.

Jackson Hamner

After looking at your code I think I found your problem. It has to do with the quotation marks and making sure they are formatted correctly.

In two place, the Subject and the GetVar part the quotation marks were incorrectly formatted (facing the wrong direction or something). After replacing them i got your code to work. Here is the fixed code that worked for me. 

var email="lclucy@email.com";
var player = GetPlayer();
var subject="Results";
var body_start=player.GetVar("NumericEntry");
body_text = body_start;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_text;
win=window.open(mailto_link,"emailWin");

This can happen sometimes if you write your code in word processing software like Microsoft Word with autocorrects, or if you edit the code a lot and the quotes get misaligned. I've attached a copy of the story file that I got it working on, but its a SL2 file so Im not sure itll be much help...

A suggestion I have would be to download something like Notepad++ and use that to write your javascript. It has some styles that help make sure your code is correct (if its a string the text is grey, a variable is blue, etc.) thats how I noticed the quotes weren't aligned correctly and fixed them.

Also if the Travel_Geography_SF story file I noticed you put quotes around the whole script and you don't need those, it will mess up the script.

Hopefully this helps!

 

Bruce Holliday

Hi Lucy,

I do see that for now you have a solution that works. However it's not wholly reliable in that email servers are not always available to users. Take a look at this thread which was mentioned in kind by Steve Flowers above. Using Google Sheets you can have a solution that works anywhere.