Email quiz results using java script
Feb 02, 2015
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!
16 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.
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 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:)
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 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
Hello,
Attached is a project I created using a product called Storyline.
** Powered by Articulate Storyline - http://www.articulate.com **
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!
Hi Everybody,
Thanks for all of your help!
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. :)
This discussion is closed. You can start a new discussion or contact Articulate Support.