Forum Discussion
User notes that they can print and email
Hi all. I built a course earlier this year that contains a "notes" function to allow users to take a moment to reflect and type their thoughts on certain questions. This is used in place of a typical multiple response/choice type question. Thought I'd share it here with you!
Here are the files:
Screenr Part 1: Demonstration - https://player.vimeo.com/video/204928444
Screenr Part 2: How It Was Built - https://player.vimeo.com/video/204928450
Storyline Source: https://bit.ly/3Kd96as
Published Output: https://bit.ly/3Z0hj5X
Cheers!
Stephanie
- OwenHoltSuper Hero
In my example, those are the names of Javascript variables that are created by the script and are used to contain the values of various StoryLine variables. I don't remember if it is the same in Stephanie's example but I believe that it is.
The code can basically be split into several sections:// Opens a new window for printing
myWindow = window.open("","Print","width=810,height=610,scrollbars=1,resizable=1");
// Launches the javascript function to get variable values. Gets storyline variables and assigns them to a java variable. The first part (before the =) is the new java variable. The second part (after the =) is a call to storyline to get the value from the specified storyline variable.
var player=GetPlayer();
var headline=player.GetVar("PrintTitle");
var date=player.GetVar("SystemDate");
var exercisenotes1=player.GetVar("NotesOne");
var exercisenotes2=player.GetVar("NotesTwo");
// Creates a java variable called contents and assigns it with html content. The html content controls how and where the content appears in the print window. It includes the java variables that you just created and assigned storyline values to.
var contents = "< html><head></head><body style='width:650px;padding:20px;'>"
contents+="< div style='font-size:22px;font-weight:bold;margin-top:20px;margin-bottom:20px;'>"+headline+"</div>";
contents+="< div style='font-size:16px;'>"+date+"</div>";
contents+="< div style='font-size:18px;font-weight:bold;margin-top:10px;'>Activity Notes 1</div>";
contents+="< div style='font-size:17px;margin-top:5px;'>"+exercisenotes1+"</div>";
contents+="< div style='font-size:18px;font-weight:bold;margin-top:10px;'>Activity Notes 2</div>";
contents+="< div style='font-size:17px;margin-top:5px;'>"+exercisenotes2+"</div>";
contents+="< /body></html>"
// Writes the html to the window and initiates the print function
myWindow.document.write(contents);
myWindow.document.close();
myWindow.focus();
myWindow.print();
- StephanieSuper Hero
Hi everyone - thanks for all of your comments. Sorry this took so long to reply too (travel and holidays out of the way, I'm back here on the forums daily).
Katie - The javascript and email functions should work properly in HTML5. They are basic implementations, however, you may run into issues with the window popping up after clicking the print button on some devices so likely a more detailed css solution would play better across multiple html5 devides (tablets, phones). Seems to work decently in HTML5 on the desktop. The elevator sequence was created in PowerPoint using a single image that I sliced and diced, applied motion path animations too then exported as an .mp4 and imported into Storyline.
Amr - There are some examples in the forums for code to print certificates/results. Using the built-in method - http://community.articulate.com/forums/p/36759/198052.aspx#198052 or customized method - http://community.articulate.com/forums/p/12471/75329.aspx
Owen - You might need to disable protected mode in thebrowser, add the site to trusted sites or remove "javascript" from the code - what was "<button onclick='javascript:window.print();'>" becomes "<button onclick='window.print();'>"
Bruce - Yes, you can enter lengthy text and it will be captured in its entirety in the email body, printed version too.
- roneltaruc-5c94Community Member
For some reason when typing in lengthy text not all texts show in the email body :/ -- I wonder what's wrong. I also noticed that breaks aren't reflected either. The paragraphs just connect to each other in one line even though in the original entry they are separated. Thoughts?
- OwenHoltSuper Hero
Can you provide us an example? How much text are we talking about here? How many line breaks?
Do you have/can you provide any screen shots or .story files?
- TracyCarrollCommunity Member
Hi all,
I don't know if this will be helpful, but I have a free Storyline 2 Print/Email Notes Template on my website, along with links to tutorials and resources on the subject.
You can download the template and/or read the blog post here: http://tracycarroll.net/storyline2-print-email-notes/ - KatieVenitCommunity Member
I got it to work! I had to copy the JS from one of the triggers, delete that trigger, create a new trigger with the copied code, and then change the case.
- OwenHoltSuper Hero
I never could get the print function to work correctly - not even in the downloaded file. The print window with its nice white background opens fine, but the print button in the new window does not function. I've tried both "" and "". Interestingly enough, if I start to change the print code, the email button stops working even though I am not making any changes to it. I settled for just printing the native page using nothing more than window.print(); as the javascript on my button.
- OwenHoltSuper Hero
Made a few modifications and have it working in a slightly different way. Since the problem seemed to be getting the print button to work in the pop-up, I just removed the button from the code and added code to launch the print function auto-magically.
Attached is my modified code. (Working in I.E. 9 but not working in Google Chrome) - OwenHoltSuper Hero
And here is a simple .story file with both email and printing functions currently working in I.E.9
- PhilMayorSuper Hero
You need a variable so you know if the notes panel is open and closed, e.g. NotesOpen
Set it to true whenever it is open and false when it is closed.
Now on each layer in your course add a trigger that shows your notes layer (I presume you are incrementing a variable, on condition NotesOpen is equal to true, ensure the the notes layer is set to not hide other layers.
Not sure why the notes panel button is hiding is that on a layer as well?
- PhilMayorSuper Hero
Is the notes panel a separate layer? Or does the notes layer have a button that toggles an object between hidden/normal?
- PhilMayorSuper Hero
You need another trigger then to show the additional layer if NotesOpen = true.