How to save information about users and use it later in the intervention: Difference between revisions

From Lifeguide Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:
To save responses, the commands <code>save</code> and <code>savevalue</code> are used.
To save responses, the commands <code>save</code> and <code>savevalue</code> are used.
To load responses, the commands, <code>load</code> and <code>loadvalue</code> are used.
To load responses, the commands, <code>load</code> and <code>loadvalue</code> are used.
The command <code>saveandload</code> is used to display responses when end-users are re-shown the same page.== <code> savevalue </code> ==
The command <code>saveandload</code> is used to display responses when end-users are re-shown the same page.
 
== <code> savevalue </code> ==


The savevalue command allows you to save a variable for a user that can then be loaded again in later sessions.
The savevalue command allows you to save a variable for a user that can then be loaded again in later sessions.

Revision as of 16:29, 15 May 2015

You can use users' saved information in many ways:

- to display the responses end-users gave to an interaction, which you can display as text.

- to display the original page so end-users can see how they responded to an interaction and then change their answer

- to provide feedback based on their responses, e.g. a score for a quiz

End-users must have created an account in order for their responses to be saved to their username.

To save responses, the commands save and savevalue are used. To load responses, the commands, load and loadvalue are used. The command saveandload is used to display responses when end-users are re-shown the same page.

savevalue

The savevalue command allows you to save a variable for a user that can then be loaded again in later sessions.

You can use it to save the group that users have been randomised to:

savevalue(username, "group", "web")

You can use it to save the time users have seen a particular page:

savevalue(username, "s1time", currenttime())

You can use it to save the response that they have given to a single or multiple-choice interaction:

savevalue(username, "fatigue", page1.interaction1)

N.B. You must use a Next type button on the page that you are saving information from when you use savevalue. If you use a Jump button, the logic referring to savevalue will not be read and so the variable will not save.

save

The save key command allows you to save the responses that an end-user enters on a page. This can then be loaded using the load key command onto another page to re-show it to your end-user. The save and load commands can be used across sessions and requires end-users to have registered a user account.

Example:

show page1

save page1 for username

Then, later on in the logic (either in the same session or a later session) the following logic would be used:

show page20

set default page20.interaction2 to load page1.interaction1 for username

So, in the first part of this logic page1 is saved for the end-user. Then when they get to page20 in the intervention the response that they entered on interaction1 on page1 will be reshown to them on interaction2 on page20.


saveandload

This key command can be used after a page that includes interactions so that if an end-user moves away from that page and then comes back to it, the page will automatically show them what they entered the last time they were on that page. This line of logic would simply be written as so:

show page1

saveandload page1 for username

Any interaction on page1 would then be saved and loaded each time the end-user comes back to that page.