Email quiz results using java script
By
Liliana Lucy
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
Hi Lilly
Check the order, mine has GetPlayer first...
Hi Wendy,
Thanks for replying so quickly. I changed the order but it still didn't work.
Lilliana, do you have the necessary variables in your Storyline file? In the example you've posted above, the javascript is looking for a variable called NumericEntry.
You may find the information in thread helpful.
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:)
Hey Steve, I'd love to see those refs - was looking into adding stuff to a Google Spreadsheet a while back but couldn't get it working.
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:)
Thanks Steve, I'll give this a try when I get a chance.
I really appreciate you sharing this - I used to use a widget to do similar stuff with Captivate and have been missing this functionality since switching to Storyline.
Glad you were all able to get the assistance you needed here!
Hi Matthew,
Attached are the triggers that I added. I'm still not able to get it to work.
Do you know if this only works in Storyline 2? I only have Storyline 1.
Lily Cisneros Lucy
Just an FYI Lily, replying via email does not attach the files or documents here - you'll need to visit the forum thread to include them.
Thanks all for your suggestions. I feel like I've tried everything and nothing seems to work. Attached are the triggers that I created. Thanks!
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)?
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
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.
Hello,
Attached is a project I created using a product called Storyline.
** Powered by Articulate Storyline - http://www.articulate.com **
Hi Liliana,
You'll need to visit the forum and upload the file there as files sent via email don't come through.
Hi Matthew,
Here's my storlyline file.
Thanks!
Lily
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.
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!
Cool, looks like Jackson has got it all fixed up for you.
Hi Everybody,
Thanks for all of your help!
For anyone following along with the document Steve shared above, please note that there are a couple typos in the code as discussed in this thread.
Thanks Matthew for updating and linking to the other post.
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.
Great suggestion, Bruce! Thanks for providing that info, and I hope it's of further assistance to Lucy. :)