Using the CurrentDate variable as a condition

Hi everyone,


I have to admit I haven't looked into this on my own much yet. I'm in the middle of a project and was going to try after but I figured I'd see if anyone has ever done it.



I have some courses that have a survey link in them that takes them to a external site (Survey Monkey). We decided that we should start removing the survey links after 30 days.


So I was thinking, instead of going back in and removing the link and republishing, is there an action I can set to show the survey link?


Something like, On Show / Show: Survey Link / On Condition: CurrentDate is less than 30 days.


I would figure that the date doesn't on days, so it may have to be something more like giving it an exact date, like less that 9/22/13.


However, I am not sure how Lectora handles less than and greater than on a date field. There is an option of adding 30 conditions I guess and making the conditions to SHOW if CurrentDate is equal to: and list all the possible dates for the next 30 days. That seems long winded though.


Has anyone done something like this before?

Discussion (5)

Hmmmm.... No luck with this. I tried setting the condition for both Yes and No. Seems like the variable is not being written to. I will play with it though. Thanks.

Create variable called "MyMonkeyExpired".


Add another action to the page, before showing the monkey link:

On Show / Execute JS / Script:


var d = new Date();

var ex = new Date("11/22/2013"); //set this by hand as MM/DD/YYYY

Math.floor((Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) - Date.UTC(ex.getFullYear(), ex.getMonth(), ex.getDate())) / 1000 * 60 * 60 * 24) > 30 ? VarMyMonkeyExpired.set('YES') : VarMyMonkeyExpired.set('NO');


Change the condition on your action to "if myMonkeyExpired contains YES".

@sirwise23 55936 wrote:

Hmmmm.... No luck with this. I tried setting the condition for both Yes and No. Seems like the variable is not being written to. I will play with it though. Thanks.


1. Any JS errors in console?

2. Make sure the variable is either used in that page or added to Required variables list, otherwise Lectora won't create the variable and it consequently won't be populated.

3. If you're testing locally, make sure you test in IE, since other browsers don't work all that well with Lectora when the course is running from local hard drive.

Ok, I just checked - it all works, no problem.

Set the expiration date to e.g. 05/22/2013 - and you'll get and Expired! message. Set it to 11/22/2013 - and you'll get a "not expired!" message.


Download the project here - https://dl.dropboxusercontent.com/u/11433463/trivantis/expiration/Title%201.awt

Ahhhhh. Silly me. I didn't realize the date was to be set to the expiration date. I took it as the date should be today's date and that it would expire if it was more than 30 days from today. I never tried setting it as a date in the past to see if it works. This works great. Thank you.

Discussions have been disabled for this post