How to re-show information that users have told you: Difference between revisions

From Lifeguide Wiki
Jump to navigation Jump to search
No edit summary
 
Line 9: Line 9:


Any interaction on page1 would then be saved and loaded each time the end-user comes back to that page.
Any interaction on page1 would then be saved and loaded each time the end-user comes back to that page.
== Showing users' responses on a new page ==
An example is to re-show a goal that an end-user has entered in a previous session so that they can say whether they achieved it.
First you will need to create a single/multiple-choice/numeric interaction or a text-entry box on a page and give it a unique name. Then in the '''intervention.lgil''' file, write the logic to save the goal the response that users will enter:
<code> show session1page1</code>
<code> savevalue(username, "goal1", session1page1.interaction1) </code>
The logic above is saving interaction1 on page1 as a variable called '''goal1'''
To show the goal on a page in a different session, you will need to create a new page, insert a text box and set the text as a printed variable.
'''[[How to set text as a printed variable|Click here for instructions on how to set text as a printed variable]]'''
Once you have set the text as a variable, you will need to add the following logic to the '''intervention.lgil''' file,:
<code>show page2 </code>
<code>set session2page1.s1goal to loadvalue(username,"goal1")</code>
The above logic will load the goal that was saved as '''goal1''' previously in the logic, into the text box with the variable name '''s1goal''' on page10.
If you are displaying this goal with other goals as feedback, please note there are a few extra steps:
1) You may need to use a container on page10. Please click on the '''Containers''' link at the bottom of the page for more information on this.
2) The text that you have just set as a variable will need to be set to '''feedback'''. First, click on the text box. Under '''Textbox properties''' scroll down to the end and select '''Feedback'''. Enter a unique name (e.g. goal_one)
3) You will need an extra line of logic telling the goal to show only if a goal has been previously entered by an end-user:
<code>show page10.goal_one if (not(isempty (loadvalue(username,"goal1")))) </code>
This logic will show the feedback item called '''goal_one''' on '''page10''' if '''goal1''' is not empty (i.e. if an end-user entered a goal which was saved as goal1)
[[Category:Containers]]

Latest revision as of 13:58, 19 August 2015

Showing users' responses on the same page

The saveandload 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 be written as:

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.