Calculator to Populate Dates
Feb 04, 2016
By
Sarah Linden
Hi everyone--
I'm looking for a way for Storyline to generate five dates based on a "final" date submitted by the learner (learner submits any date they want). Each of the five dates calculates 30-10 weeks backwards from the final date.
For example, if the learner types August 1 as the final date, Storyline would calculate the following dates: Jan 4, March 28, April 25, etc.
Any idea how to do this without needing coding? Thanks!
9 Replies
Hi, Sarah -- This post is a bit older but you may want to take a look at some of the suggestions offered. Please let us know if you are all set, or if you still need help, please feel free to share your file if you have one started. :)
I was afraid coding would be required! Thanks for the link to the discussion. :)
Hi, Sarah -- It would seem so, but there is always a chance that someone else can chime in with ideas or advice that did the trick for them without the use of coding! And it wouldn't hurt to share your post with even more of the community over here in our design-related forum, as well.
Will do, thanks!
Hi Sarah,
I think the attached sample file accomplishes what you want. It uses Javascript to subtract the required number of days from the date the user enters. (Take a look at the code within the Execute Javascript trigger.)
For use in an actual project, you will probably want to add some error checking to caution the user if she enters a number out of range (e.g., as entering '13' for the month or '32' for the day). The script I drafted would require fewer variables and would be more efficient if I used a loop and more arrays but I wanted to make it relatively easy to follow in case you're new to Javascript.
A few caveats about using Javascript with Storyline:
1. You have to publish the project to see the results (it won't work in preview).
2. When passing variables back and forth between Javascript and Storyline, the exact same spelling of that variable must be used in both. In other words, you can't create a variable in Javascript and send that variable value to Storyline if the corresponding variable has not already been created in Storyline.
3. Javascript will not work with the Articulate Mobile Player app (but it will work with Flash and HTML5 output).
4. You may have to post the published output to a web server and run it from there because sometimes browser security settings restrict Javascript from running on a local drive.
Hope that gets you started!
Steve,
Nice write up!
As for #2,
"When passing variables back and forth between Javascript and Storyline, the exact same spelling of that variable must be used in both. In other words, you can't create a variable in Javascript and send that variable value to Storyline if the corresponding variable has not already been created in Storyline."
Just for clarification, in JS you can create a variable:
var myVariable = 10;
Then send the value to Storyline to set a variable, let's say Points, for example:
var player = GetPlayer();
player.SetVar("Points",myVariable);
This would set the Storyline variable, "Points" to 10.
You're right, of course, Zsolt. I could have communicated that better. What I was trying to get across to Sarah was that the variable that you're going to set using Javascript and pass back to Storyline must already exist in Storyline.
So, using your example, if there was no variable called "Points" in Storyline (or if the variable was erroneously named "Point" in Storyline), player.SetVar("Points",myVariable) wouldn't work.
Thanks guys! Also responded to discussion in Building Better Courses. :)
Thanks for sharing Sarah! Here is a link for anyone following along.
This discussion is closed. You can start a new discussion or contact Articulate Support.