Send results slide via email using Javascript ??

Hello!  I'm pretty new to... well... all of this, but I'm a fast learner.  I've been toying around with adding Javascript to my Storyline project for some advanced capabilities, and so far I've figured out how to execute an email with HTML5.  I understand that there are issues with mobile and Flash.

So my question is: is it possible to set up Javascript within my Storyline project that will email an image of the results slide/certificate of completion? 

It would be great if the image could be in the body of the email, but I would also be happy if it were an attachment.  I don't know if it is possible to set it up so that once the user lands on the results/completion slide, there is an image automatically generated and included in the email.... again, pretty new at this. =)

Here is my current set up (for my test project) including code:

  • I set up a text entry called "EmailAddress"  - the user will enter their desired email addresses in here.
  • I have a text variable called "EmailAddress"
  • I added a trigger to a button that will execute Javascript when the user clicks.

This is the Javascript I'm using:

var player = GetPlayer();
var course="Storyline test course"
var email=player.GetVar("EmailAddress");
var subject="Assessment Complete";
var body_start="I've just completed my assessment!";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

Please note: I've patched my JS together from information I've found within these forums and on the web.  I don't know how to write JS or all the rules, but I can usually figure out how to use it if I play around with it for long enough.

Any help would be amazing, and thank you so much in advance... and sorry if this question has already been covered; I wasn't able to find an answer anywhere. =)

29 Replies
Travis Smith

Hello,

Your JavaScript is wrong. You are missing a semi-colon from the end of the var course... statement, which you don't use so you can just delete it.

----

var player = GetPlayer();
var email=player.GetVar("EmailAddress");
var subject="Assessment Complete";
var body_start="I've just completed my assessment!";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

Ana Victória

Hello,

I need something similar but the email has to have a little more text. I have the following text variables:

- Commitment

- Name

- ManagerEmail

I edited the above jc to nomething like this:

var player = GetPlayer();
var email=player.GetVar("ManagerEmail");
var nome=player.GetVar("Name");
var texto=player.GetVar("Commitment");
var subject="My Corporate Responsibility Commitment";
var body_start="Dear Manager, "+nome+" has sent you his/her Corporate Responsibility Commitment:";
var body_end="Please discuss this commitment with "+nome;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start +texto +body_end;
win=window.open(mailto_link,'emailWin');

Will it work? is it possible to have in the '&body' ?

Thanks !!

Sam Carter

Travis Smith said:

Try this: https://gist.github.com/wpsmith/5221305

I ran into clients that didn't have email applications on some of the workstations, and other situations where workstation mis-configuration didn't invoke the email application at all.  Because the workforce was so large, addressing all the exceptions was not possible.

To solve the problem I developed a server-side email solution which allowed learners to do form-entry email in the course via a web object.  It sends email reliably, but it requires setup of a server-side script which requires a lot of cooperation with both LMS and server administration.  Installing private or course-specific scripts is a major issue that many LMS installations won't support.

LMS server scripts could be avoided by having the course reference a 3rd party email solution but many installations would see this as a security violation, or would it?  I understand courses reference youtube videos which are 3rd party, but those aren't executable scripts.

Does anyone have a story of how reliably reference 3rd party services, or how to implement email feedback using 3rd party services or... something out of the box?

Layton Fogah

Hello Alicia,

Did you ever figure out the answer to your question?  I am hoping to setup something similar.  I have done something similar in the past using Captivate and a third party widget but haven't been able to duplicate the same procedure using Storyline.  Based on your original post you seem to be quite close to a solution using javascript.  Any insights that you can share would be greatly appreciated.

Regards,

Alicia Summers

Leyhton F said:

Hello Alicia,

Did you ever figure out the answer to your question?  I am hoping to setup something similar.  I have done something similar in the past using Captivate and a third party widget but haven't been able to duplicate the same procedure using Storyline.  Based on your original post you seem to be quite close to a solution using javascript.  Any insights that you can share would be greatly appreciated.

Regards,


Hi Leyhton,

Unfortunately no, I was never able to get the Javascript to execute what I needed it to do.  I wanted the Javascript to email an image - a certificate of completion.  I was able to get Javascript to execute sending an email with the original script I posted above, but I'm not quite proficient enough in Javascript to get it to email an image...or perhaps that's just not a capability at this time.

John Griffiths said:

Hi,

This script looks really promising and I would be really interested to know which file you edit to insert it? I have looked under the project / story_content / story.js file but cannot find the right place for it to be.

Any help would be much appreciated.

John 


Hi John,

I can't speak for anyone else, but when I add Javascript to Storyline I open up the Storyline file that I'm editing and add a trigger.  Select "Execute Javascript" as the action and you'll get a little "..." button right below the action line (for the Script).  Click on that button and a blank box will appear.  Copy and paste your Javascript into the box and click OK. Then just fill out the When and Object lines as needed.  Hope this helps!

John Griffiths

Hi Alicia,

Of course! Sorry, brain went to sleep there. I am currently trying to get a similar script to work, albeit not using images but Dennis seems to know a lot about it.

Check out the thread, you might be able to catch a break:

http://community.articulate.com/forums/p/40049/227676.aspx#227676

John 

Travis Smith

Sam Clark said:

Travis Smith said:

Try this: https://gist.github.com/wpsmith/5221305

I ran into clients that didn't have email applications on some of the workstations, and other situations where workstation mis-configuration didn't invoke the email application at all.  Because the workforce was so large, addressing all the exceptions was not possible.

To solve the problem I developed a server-side email solution which allowed learners to do form-entry email in the course via a web object.  It sends email reliably, but it requires setup of a server-side script which requires a lot of cooperation with both LMS and server administration.  Installing private or course-specific scripts is a major issue that many LMS installations won't support.

LMS server scripts could be avoided by having the course reference a 3rd party email solution but many installations would see this as a security violation, or would it?  I understand courses reference youtube videos which are 3rd party, but those aren't executable scripts.

Does anyone have a story of how reliably reference 3rd party services, or how to implement email feedback using 3rd party services or... something out of the box?

Yes, this would be a huge security issue. Depending on the server setup, you may be able to do a Gmail API integration, but you would need access to the MX records, PHP configuration access (php.ini), etc. which I highly doubt any one would ever give you. There is only so much one can do within a course.

Travis Smith

John Griffiths said:

Hi,

This script looks really promising and I would be really interested to know which file you edit to insert it? I have looked under the project / story_content / story.js file but cannot find the right place for it to be.

Any help would be much appreciated.

John 


It would go within the course, Execute JavaScript or possibly in the user.js file.

Jacek Chrabąszcz

Hello,

You can simply send emails joining JavaScript and PHP, e.g. in Execute JavaScript put a simple script

var player = GetPlayer();

$.ajax({

url: "quiz.php",

type: "POST",

data: {"student" :player.GetVar("student"), "score":player.GetVar("score")},

success: function(data)

{

alert("Success" + data);

}

});

In the folder with story_html5.story you can add -let's say- quiz.php:

<?php
$message .= 'Hello!' . "\r\n\r\n";
$message .= 'Student: ' . $_POST['student'] . "\r\n\r\n";
$message .= 'Score: ' . $_POST['score'];
mail("your@address.com","Quiz 1", $message);
?>

And you will receive an email:

Subject: Quiz 1

Hello!

Student: e.g. John Doe

Score: e.g. 21

Of course you can add many variables from Storyline in your $message.

Best regards

Jacek

Jacek Chrabąszcz

I hope so :-) Then I'll elaborate on this subject.
 
W dniu 2014-11-17 20:18:23 użytkownik E-Learning Heroes napisał:
Reply to Send results slide via email using Javascript ??
Ashley Terwilliger replied:
It may be just what someone else needs though! You never know. :-)
Reply
View
To post a response, simply reply to this email.
You received this email because you subscribed to this discussion. Unsubscribe
© 2014 Articulate Global, Inc. All rights reserved.
 

Jacek Chrabąszcz

Thank you Ashley :-)
W dniu 2014-11-17 21:38:14 użytkownik E-Learning Heroes napisał:

Reply to Send results slide via email using Javascript ??
Ashley Terwilliger replied:

Thanks Jacek - and just so you know when you reply via email sometimes your signature is included. You can edit the post if you'd like to remove those elements!

Bj Wilson

What do you mean by use .$ Could you please explain further with an updated example of the code.

Could you add something like this to add in your from address to the php code: 

$headers = "From: My Site <admin@mysite.org>";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
Jacek Chrabąszcz

Hi, a full stop, "." is a symbol for string concatenation in PHP, likewise "+" in e.g. JavaScript. I pass JavaScript variables (via ajax function in Storyline) to PHP then I use a simple mail() function.
 
W dniu 2014-11-17 23:38:36 użytkownik E-Learning Heroes napisał:
Reply to Send results slide via email using Javascript ??
Bj Wilson replied:
What do you mean by use .$ Could you please explain further with an updated example of the code.
Reply
View
To post a response, simply reply to this email.
You received this email because you subscribed to this discussion. Unsubscribe
© 2014 Articulate Global, Inc. All rights reserved.
 

Tabatha Willis

I am creating a course where the user will simulate replying to an email. I need their reply to actually email to be manually reviewed and graded. This is primarily for soft skills training. I've used different java codes listed in these forums, but none seem to be working. In the image attached, the "type your text here" area is what would need to be emailed. This is TextEntry13 in my course. If I could include the subject and the users name "TextEntry" that would be awesome.

Any help would be greatly appreciated. 

Leslie McKerchie

Hi Tabatha!

This thread is a bit dated and your request is out of the scope of Articulate support, but hopefully someone in the community will be able to chime in and assist here. If you were hoping for assistance from a particular user, you are welcome to reach out to them directly via the 'Contact Me' option on the user profile if available.