Print Certificate within Storyline 360 using Java Script and .html

I have been trying for weeks to understand how to print a certificate after a quiz has been finished within storyline 360. I finally got the window to open with a "certificate" but I cannot get any of the variables to populate over - can anyone point me in the right direction? 

1 Reply
Sam Hill

Hi Evita, is the certificate launched in a new window from the Storyline file? If so, you should be able to include the following JavaScript in the file, to get some data from the Storyline file.

<script>
window.onload = function()
{
// get the scope for the method, should be in the opener
var scope = window.opener;
// get the SL player
var player = scope.GetPlayer();
// if you have a variable value in Storyline you want to get, use this method
var myvar = player.GetVar('yourvariable');
// if running on an LMS, get the student name
var name = scope.GetStudentName();
var firstlastname = name[1] + ' ' + name[0];
// Get the current date
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
var completiondate = mm + '/' + dd + '/' + yyyy;
// Once you have all of your values, you need to populate the certificate
// Populate any HTML like this <span class="firstlastname"></span>
document.getElementsByClassName('firstlastname').innerHTML = firstlastname;
// Populate any HTML like this <span class="completiondate"></span>
document.getElementsByClassName('completiondate').innerHTML = completiondate;
}
</script>