HOW TO: Use Javascript to create custom print results page in Storyline 2
Sep 01, 2017
A colleague of mine asked the question recently about how to show allow the user to print the results of Essay questions.
While I know you can use the built-in "Print Results," since that isn't supported in HTML5, I have been working on an alternative using Javascript.
Here's the Javascript code I used and a quick mockup/proof of concept.
var player = GetPlayer();
var newWindow = window.open("", "_blank");
newWindow.document.write("<button onclick='window.print();'>Print Results</button>");
newWindow.document.write("<h1>Response 1</h1><p>"+player.GetVar("Essay1")+"</p>");
newWindow.document.write("<h1>Response 2</h1><p>"+player.GetVar("Essay2")+"</p>");
newWindow.document.write("<h1>Response 3</h1><p>"+player.GetVar("Essay3")+"</p>");
newWindow.document.title = "Results";
2 Replies
Nicely done! For everyone new to scripting, the code requires you set up text type variables called Essay1, Essay2, and Essay3. And remember, scripting is unsupported in the Articulate Mobile Player (AMP).
Just to clarify the variables referenced in the Javascript are the Text Entry Variables from the Storyline questions.
Typically as a best practice I always rename them from the default "TextEntry", "TextEntry1" so that they are actually meaningful.
This discussion is closed. You can start a new discussion or contact Articulate Support.