Forum Discussion
Send results slide via email using Javascript ??
Hi all,
If trying to use the above to do the email but also post the score the user gets. I've modified the code and added a variable but I don't know what I'm doing wrong. Can someone please check this out for me?
var player = GetPlayer();
var email='email@gmail.com';
var score=player.GetVar('percent');
var subject="Assessment Complete";
var body_start = 'Here is my percentage:' +score;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');
Hi DLD 1
Your code was perfect for what I wanted - email the player score (and name). Perhaps your problem is in the GetVar('percent') line - do you have a variable called 'percent'? Here's my script, based on yours:
var player = GetPlayer();
var email='bogus@gmail.com';
var score=player.GetVar('UserScore');
var name=player.GetVar('UserName');
var subject='Assessment Complete for: ' +name;
var body_start = 'Here is my score: ' +score;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');
As you can see, I've created two variables - UserScore and UserName. I've got triggers on each slide (Scenario template layout) to add different values to the UserScore var depending on their choice. On the Feedback slide, I've used a normal template feedback layout, but replaced the built-in var with my own, i.e. %UserScore% - which presents the total score of all choices on all slides. That var is then pulled into my email.
This is a perfect solution to not being able to pass scenario values to my LMS... so thankyou!