Forum Discussion
User notes that they can print and email
Hi all. I built a course earlier this year that contains a "notes" function to allow users to take a moment to reflect and type their thoughts on certain questions. This is used in place of a typical multiple response/choice type question. Thought I'd share it here with you!
Here are the files:
Screenr Part 1: Demonstration - https://player.vimeo.com/video/204928444
Screenr Part 2: How It Was Built - https://player.vimeo.com/video/204928450
Storyline Source: https://bit.ly/3Kd96as
Published Output: https://bit.ly/3Z0hj5X
Cheers!
Stephanie
- JillyDutton1Community Member
Wow, Matthew - thanks so much! This has been uber helpful, and now my test module is working the same as yours!
As a tricky workaround I was going to use a pre-populated Stage1_Notes text entry to pull content into the email, but I can't get that bit to work (possibly because I'm making this bit more difficult than it needs to be).
Any ideas how to get this variable to pull through to the email body? I have attached a zipped source file to tinker with if you need. My ultimate goal is to get the notes and functionality for Stage One right and then to dupe the scene for all four stages, changing the Javascript to pull the relevant notes variable into the email.
Thanks again, this is going to make the module so much more engaging for my audience :)
- TracyCarrollCommunity Member
Thank you, Matthew, this was very helpful for me!
- HollyMacDonaldSuper Hero
I am also out of my depth when it comes to javascript. I have the following page set up and the email function didn't execute. I added a trigger to adjust the variable, but I'm not sure it is the right thing to do. Anyone want to help a non-coder with this?
Here's the javascript I have
var player = GetPlayer();
var useremail=player.GetVar("email");
var subject="Journal Entries";
var Thoughts9=player.GetVar("Thoughts9");
var Thoughts1=player.GetVar("Thoughts1");
var Thoughts2=player.GetVar("Thoughts2");
var Thoughts3=player.GetVar("Thoughts3");
var Thoughts4=player.GetVar("Thoughts4");
var Thoughts5=player.GetVar("Thoughts5");
var Thoughts6=player.GetVar("Thoughts6");
var Thoughts7=player.GetVar("Thoughts7");
var Thoughts8=player.GetVar("Thoughts8");var mailto_link='mailto:'+useremail+'?subject='+subject+'&body='
+"Journal Entry 1:%0d%0A“
+Thoughts9+"%0d%0A%0d%0A
Journal Entry 2:%0d%0A“
+Thoughts1+"%0d%0A%0d%0A
Journal Entry 3:%0d%0A“
+Thoughts2+"%0d%0A%0d%0A
Journal Entry 4:%0d%0A“
+Thoughts3+"%0d%0A%0d%0A
Journal Entry 5:%0d%0A“
+Thoughts4+"%0d%0A%0d%0A
Journal Entry 6:%0d%0A“
+Thoughts5+"%0d%0A%0d%0A
Journal Entry 7:%0d%0A“
+Thoughts6+"%0d%0A%0d%0A
Journal Entry 8:%0d%0A“
+Thoughts7+"%0d%0A%0d%0A
Journal Entry 9:%0d%0A“
+Thoughts8+"%0d%0A%0d%0A"win=window.open(mailto_link,'emailWin');
Many thanks if you can pinpoint what I'm missing (javascript, trigger, variable???)
- HollyMacDonaldSuper Hero
Hi Matthew, I tried that, but it still didn't execute.
I think it's a trigger/variable problem. Where I have var useremail=player.GetVar("email"); I am not sure I have the right variable and/or trigger.
The variable type I have is text entry, but not sure if I should have a trigger that adjusts the variable and if so to what.
Any other ideas?
- onEnterFrameCommunity Member
Hi Holly,
A few thoughts from just taking a glance at your code. But I am not sure if your actual code is just like what is above? Or maybe the forum reformatted it?
Generally speaking you shouldn't have a hard line break in the middle of a variable. Your var mailto_link= has a line break after '&body='. And then a bunch more breaks after each entry. You should either make that one long line or append those to the end of the var like this:
var mailto_link='mailto:'+useremail+'?subject='+subject+'&body='
mailto_link += 'Journal Entry 1:%0d%0A'
There are a few other ways to handle that but the solution above should be fine for what you are doing.
Some of your strings have opening quote marks but no closing quote marks.
Also some of those quotes in your code are not the normal quotes. This is OK: " this is not “ . I know... they look almost identical. Avoid the curly looking ones. Using a code editor (like Sublime) will help you see those.
It is generally best practice to use double quotes around strings and to mix them with single quotes. You have some lines that start with single quotes append values in double quotes.
I think this may work for you:
var player = GetPlayer();
var useremail=player.GetVar("email");
var subject="Journal Entries";
var Thoughts9=player.GetVar("Thoughts9");
var Thoughts1=player.GetVar("Thoughts1");
var Thoughts2=player.GetVar("Thoughts2");
var Thoughts3=player.GetVar("Thoughts3");
var Thoughts4=player.GetVar("Thoughts4");
var Thoughts5=player.GetVar("Thoughts5");
var Thoughts6=player.GetVar("Thoughts6");
var Thoughts7=player.GetVar("Thoughts7");
var Thoughts8=player.GetVar("Thoughts8");var mailto_link="mailto:"+useremail+"?subject="+subject+"&body="
mailto_link += "Journal Entry 1:%0d%0A"
mailto_link += Thoughts9+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 2:%0d%0A"
mailto_link += Thoughts1+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 3:%0d%0A"
mailto_link += Thoughts2+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 4:%0d%0A"
mailto_link += Thoughts3+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 5:%0d%0A"
mailto_link += Thoughts4+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 6:%0d%0A"
mailto_link += Thoughts5+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 7:%0d%0A"
mailto_link += Thoughts6+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 8:%0d%0A"
mailto_link += Thoughts7+"%0d%0A%0d%0A"
mailto_link += "Journal Entry 9:%0d%0A"
mailto_link += Thoughts8+"%0d%0A%0d%0A"win=window.open(mailto_link,"emailWin");
Hope that help!
- HollyMacDonaldSuper Hero
Going back to square one. I've used Matthew's sample file and while his works, it doesn't work when I try to copy elements onto the slide. I've used James' javascript and no luck. I used someone else's suggested javascript and no luck.
Can someone please let me know if my logic is right/wrong.
1. Create text entry box for user to enter email. Automatic variable is created.
2. Create text variable called useremail
3. Change name of text entry variable to "useremail"
4. Add button
5. Add trigger to execute javascript when user clicks button
6. Enter javascript that starts with
var player = GetPlayer();
...and ends with ...
win=window.open(mailto_link,"emailWin");
Thanks!
- HollyMacDonaldSuper Hero
Thanks a million Matthew - I'll give that a try.
Fingers crossed!
Holly
- LisaTreeceCommunity Member
Hi Everyone!
I ran across this post last week when trying to figure out this whole Java thing (I have zero experience), and I'm hoping to get some advice :)
I am attempting to have an email populate with different variables in the body of the email The variables are numbers, not text, so I'm not sure if that makes a difference. I've tried adjusting a few of the different scripts I've found in this thread, but I can't seem to get any of them to work. Here is my most recent attempt:
var player = GetPlayer();
var email= "dbs_training@cscglobal.com";
var subject= "DNS Certification Assessment Results";
var score = player.GetVar("Results.ScorePercent");
var dnsbasics = player.GetVar("dnsbasics");
var zonebasics = player.GetVar("zonebasics");
var digsandzonechecks = player.GetVar("disandrcz");
var zonemanagement = player.GetVar("zonemngmt");
var reportingtools = player.GetVar("reportingtool");
var troubleshooting = player.GetVar("trblshooting");
var advancedzones = player.GetVar("advancedzones");
var urlf = player.GetVar("urlf");
var dnsa = player.GetVar("dnsa");
var emailbody = "End Score:\n\n"+score+"\n\nDNS Basics:\n\n"+dnsbasics+"\n\nZone Basics:\n\n"+zonebasics+"\n\nDigs and Registry Zone Checks:\n\n"+digsandzonechecks+"\n\nZone Management in Domain Manager:\n\n"+zonemanagement+"\n\nDNS Reporting Tools:\n\n"+reportingtools+"\n\nZone Troubleshooting:\n\n"+troubleshooting+"\n\nAdvanced Zones:\n\n"+advancedzones+"\n\nURL Forwarding:\n\n"+urlf+"\n\nDNS Advanced:\n\n"+dnsa;
var mailto_link='mailto: '+email+'?subject='+subject+'&body='+emailbody;
win=window.open(mailto_link,'emailWin');Any advice would be much much much appreciated!
Thanks, Lisa
- onEnterFrameCommunity Member
It is hard to trouble shoot without access to the course.
One thing you could to help would be to open up your browser's developer console (press F12) and see if there are any error messages there. It will usually even direct you to the problematic line and might give a hint about what is wrong.
In the meantime... a few things to check.
- This probably when run locally so make sure you testing from a web server.
- I'm not sure you can access quiz results like this
player.GetVar("Results.ScorePercent");
You may need to set the value of a custom variable in Storyline and get that. - Since this solution is popping up a new window the browser could be blocking poppups.
- LisaTreeceCommunity Member
Thanks for the advice...no error messages are appearing in the developer console
- I've been publishing to our LMS for testing
- I removed "Results.ScorePercent" from the code
- I ensured there were no popup blockers enabled
All of this and still no luck :(