Forum Discussion

TH-bf52b1b3-f6f's avatar
TH-bf52b1b3-f6f
Community Member
4 years ago

How to send quiz results via mail automatically via Javascript

Hi all,

until now I am able to let create a mail with the results of 5 quizzes automatically.

But the learner could adapt that mail text and has to hit the "Send"-button in his mail client.

How to send the mail automatically?

What I did to let it work so far:

1. Created 5 global variables (r1, r2,...r5) in which the resultvalues are stored

2. Created 5 events ("r1 = Results.ScorePercent", "r2 = Results1.ScorePercent"...) to store the result values in these global variables

3. Assigned this Javascript code to a button:

var player = GetPlayer();
var status=player.GetVar("completion");
var email = 'recepientsmailaddress@here.com';
var r1 = player.GetVar('r1');
var r2 = player.GetVar('r2');
var r3 = player.GetVar('r3');
var r4 = player.GetVar('r4');
var r5 = player.GetVar('r5');
var subject = 'My quiz results of XYZ Quiz';
var emailBody = 'My quiz results:' + " " + r1 + ", " + r2 + ", " + r3 + ", " + r4 + ", " + r5;
window.location.href='mailto:'+email+'?subject='+subject+'&body='+encodeURIComponent(emailBody);