How to show follow up questionnaires at the right time

From Lifeguide Wiki
Jump to navigation Jump to search

You can use comparetimes and isempty to show users follow-up questionnaires at the right time.

The function hasseen can also be used with the above functions. Please see How to make sure that users see the right page when they log back into the intervention for more details of how to use hasseen with comparetimes and isempty.

Example 1

after login2 if (and(... comparetimes(loadvalue(username,"baseline_time"), currenttime(),"seconds") >= oneweek,... isempty(loadvalue(username,"followup_done"))... goto followup

You can write the time in seconds (604800) in place of oneweek in the logic above (see Example 2), but writing it as oneweek means that you can change the times more easily when you test your intervention (because you will only have the change the times at the beginning of the logic where you use set, and not the whole logic file).

The logic above will show the page followup if all of the following are true/have happened:

- It has been more than one week since baselinetime was saved

- The variable followup_done has not been saved (i.e. the variable followup_done is empty because the follow-up has not been completed)


In order for the above logic to work, the following should have been written in the logic in the appropriate places:

- baselinetime should be saved when the last page of the baseline questions is shown to the user, e.g.: savevalue(username,"baseline_time", currenttime() )

- oneweek should have been set at the top of the logic file, e.g.:

set oneweek to 604800

- followup_done should be saved when the last page of the follow-up questions was shown to the user, e.g.:

savevalue(username, "followup_done", "yes")

Example 2

after login2 if (and(... comparetimes(loadvalue(username,"baseline_time"), currenttime(),"seconds") >= 604800,... isempty(loadvalue(username,"followup_done"))... goto followup