I am working on a course that deals with dates in Storyline. I want the Learner to be able to say that today's date is X. Then within the text of the course, I want to show a date that is 8 months away.
For example, the Learner inputs today's date is 04/23/15. I want to have the presentation to show a scenario that is 8 months away - the date 12/23/15.
This is essential for me to create an e-learning course that will not require monthly updates. Is there a way to make this happen with variables?
This can be done, but does require the use of Javascript. Here is a recent thread that discusses the reverse (showing a date three months in the past).
Also there is some information in this article about implementing Javascript elements in your course, and there is even an option to gather the current date without the user having to enter it.
Unfortunately I don't know of another way to set this up, but hopefully if someone in the community has done similar they'll be able to share information with you here.
This helped :-) Thank you to both of you. the links together provided me with enough information to piece it all together. The final code is:
var currentTime = new Date() var month = currentTime.getMonth() + 9 var day = currentTime.getDate() var year = currentTime.getFullYear() var dateString=month + "/" + day + "/" + year var player = GetPlayer(); player.SetVar("SystemDate",dateString);
This line : var month = currentTime.getMonth() + 9 is what really threw me for a loop. Although I am trying to find 8 months from today, the 9 is used. At a 0 value, it looks at the prior month, 1 is the current month, etc.
in the Storyline project, I can pull the variable in my text by using %SystemDate%.
Thank you again! Hopefully this information posted back with my solution will help others.
Just to confirm - I found a problem with this code. It only works if the month is December or Earlier. Once you cross into the next year, it will not adjust the date correctly.
This worked for me, so that it loops over into the next year if the date goes past december:
var currentTime = new Date(); var year = currentTime.getFullYear(); var day = currentTime.getDate(); var month = currentTime.getMonth(); if((month + 9) > 11){ month = (month + 9) - 11; year+=1; } var dateString=month + "/" + day + "/" + year; var player = GetPlayer(); player.SetVar("SystemDate",dateString);
10 Replies
This can be done, but does require the use of Javascript. Here is a recent thread that discusses the reverse (showing a date three months in the past).
Hi Brandon,
Also there is some information in this article about implementing Javascript elements in your course, and there is even an option to gather the current date without the user having to enter it.
Thanks. So without the Javascript elements, there is not a way to do this?
Hi Brandon,
Unfortunately I don't know of another way to set this up, but hopefully if someone in the community has done similar they'll be able to share information with you here.
This helped :-) Thank you to both of you. the links together provided me with enough information to piece it all together. The final code is:
var currentTime = new Date()
var month = currentTime.getMonth() + 9
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=month + "/" + day + "/" + year
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
This line : var month = currentTime.getMonth() + 9 is what really threw me for a loop. Although I am trying to find 8 months from today, the 9 is used. At a 0 value, it looks at the prior month, 1 is the current month, etc.
in the Storyline project, I can pull the variable in my text by using %SystemDate%.
Thank you again! Hopefully this information posted back with my solution will help others.
Just to confirm - I found a problem with this code. It only works if the month is December or Earlier. Once you cross into the next year, it will not adjust the date correctly.
This worked for me, so that it loops over into the next year if the date goes past december:
Thanks for popping to share Jackson!
Jackson - Tested and works great! Thank you so much for the assistance!!!
No problem, glad you got it working!
:D
This discussion is closed. You can start a new discussion or contact Articulate Support.