Using Calendars in LifeGuide

From Lifeguide Wiki
Revision as of 11:32, 23 November 2010 by 152.78.223.80 (talk)
Jump to navigation Jump to search

Using Calendars in LifeGuide

Calendars can be used to enable end-users to pick a certain date. For example, if they want an e-mail to be sent to them on a specific day or they want to set a day for when they will start a new behaviour.

To add a calendar.

Select the calendar interaction from the list of interactions available on the insert panel of the authoring tool.

Your new calendar interaction will be positioned in the top left-hand corner of the page author. Drag the calendar to where you would like it to be on the page or adjust the x and y figures on the style properties.

Example 1: Using the calendar to specify when to receive an email.

A demo of this example can be downloaded from the LifeGuide Community Website.

In order to use the date entered within a calendar to then do something on that specific date (e.g. to send an e-mail), logic needs to be used with the calendar interaction.


Please see the help-file related to sending emails for full details of this function.


NB: The e-mail will automatically be sent out at midnight on the date specified unless you also ask your end-user to select a specific time.


show page1


Shows the page that includes the calendar function and an option for selecting a specific time. Users can select the time in hours and minutes.

set mins to 0

if (page1.minutes = "fifteen") set mins to 15

if (page1.minutes = "thirty") set mins to 30

if (page1.minutes = "fortyfive") set mins to 45

Hours are pretty straight forward as this unit of time would always be used. However, as it could be likely that if an end-user wants to receive an e-mail on the hour they may not select the minutes unit of time then we first need to set minutes to 0. If the end-user then selects the 15 minute option the minutes will then be set to 15.

set datetext to printtime(page1.emaildate, "EEE, dd MMM yyyy")

On page2 of the intervention end-users will be shown the date that they selected. This uses the command printtime to display the date which has been taken from the intervention

A more specific breakdown of this line of logic sees that the variable datetext has been set to include the date from the interaction called emaildate from page1 and this will display the date as the day of the week, date, month and year where EEE corresponds with the day and so on.

set message to append ("This is the email that you queued to be sent at ", page1.hours, ":", mins, " on ", datetext, " on the LifeGuide calendar demo.")

In this example, the content of the email has been set to the word message to be used within the e-mail logic

set delay to +(page1.emaildate, (3600 * page1.hours), (60 * mins), (-1 * currenttime()))

The last part of the logic for sending an email includes the delay for when the message will be sent out. In this example we need to set the delay based on the date and time that they have selected from the interaction.

Here we can see that the variable delay has been set as the date entered in the calendar on page 1 (this interaction was called emaildate) plus 3600 x the number selected on the interaction called hours on page1. (This is because time within the LifeGuide logic works in seconds and there are 3600 seconds in an hour. So if a person chooses to receive their message at 3 o clock it would need to calculate 3 x 3600 to send it at this time). The same needs to be done with the minutes that they chose. (So here the logic is calculating 60 x the variable that was set earlier in the logic). Finally the command currenttime has been used to determine the time that the person used the page (which has be multiplied by -1) so that we can calculate a delay from the time that they entered the details.

after page1 if (sendemail(append("calendaremail", page1.emaildate) , page1.email, "The email you queued", message, delay)) goto page2

This logic sends the email. So here we can see that the string has been appended with the date that the person enters to ensure that this is a unique name for the email. The email address is taken from the interaction called email on page1. the subject of the email is "The email you queued", the variable message has been entered for the message content and the variable for the delay is included to give a time for when the email will be sent out.

show page2 set page2.hours to page1.hours set page2.minutes to mins set page2.date to datetext

This logic uses the set command to show end-users the information the date and time that they should expect to get their email.