How to check whether users have entered a unique value, e.g. Study ID code: Difference between revisions

From Lifeguide Wiki
Jump to navigation Jump to search
Line 30: Line 30:
You can choose to send an email to the study coordinator if several specific values are not unique (e.g. surname, postcode and date of birth), as this could indicate that a participant is trying to register for your intervention more than once.
You can choose to send an email to the study coordinator if several specific values are not unique (e.g. surname, postcode and date of birth), as this could indicate that a participant is trying to register for your intervention more than once.


<code> after page1 if (and(not(saveuniquevalue(username, "surname", page1.interaction1)), not(saveuniquevalue(username, "postcode", page1.interaction2)), not(saveuniquevalue(username, "dob", page1.interaction3)), sendemail( append(username,"not_unique"), "study@soton.ac.uk", "Participant - not unique", append("Participant ", loadvalue (username, "idnumber"), "has entered information that is not unique."),10) )) goto page3 </code>
<code> after registration if (and(not(saveuniquevalue(username, "surname", page1.interaction1)), not(saveuniquevalue(username, "postcode", page1.interaction2)), not(saveuniquevalue(username, "dob", page1.interaction3)), sendemail( append(username,"not_unique"), "study@soton.ac.uk", "Participant - not unique", append("Participant ", loadvalue (username, "idnumber"), "has entered information that is not unique."),10) )) goto registrationfinish </code>


==Tutorial==
==Tutorial==
Please [https://www.lifeguideonline.org/manager/intervention/show/4460 click here ] to view a demo of how the <code>saveuniquevalue</code> can be used. The demo allows users to enter a unique value and then change it to another unique value. To view the logic file, download this demo and import it to the LifeGuide authoring tool.
Please [https://www.lifeguideonline.org/manager/intervention/show/4460 click here ] to view a demo of how the <code>saveuniquevalue</code> can be used. The demo allows users to enter a unique value and then change it to another unique value. To view the logic file, download this demo and import it to the LifeGuide authoring tool.

Revision as of 14:19, 23 September 2014

To check whether users have entered something unique into a text-entry box, the saveuniquevalue function can be used. saveuniquevalue is used in the same way as savevalue. The only difference is that with saveuniquevalue, if the value entered by an end-user is not unique, the data will return a false (negative) result, and you can use this to stop end-users continuing with the intervention until they have entered a value which is unique (and so gives a true result).


N.B. If you use saveuniquevalue for a specific interaction, e.g. Study ID number, you must use the saveuniquevalue every time you refer to the Study ID number, in order for the uniqueness to be saved each time. If you use saveuniquevalue the first time and then use savevalue, the uniqueness of the value will not be guaranteed (the value the end-user enters the second time may be unique, but this could be due to luck).


Example 1

To save and check a variable entered by an end-user is unique:

saveuniquevalue(username, "studyid", page1.interaction1)

Example 2

To save 2 variables on the same page as unique (email address and study ID):

after registration if (and( saveuniquevalue(registration.username, "email", registration.email), saveuniquevalue(registration.username, "studyid", registration.studyid) )) goto registrationfinish

Example 3

To direct end-users to a different page if a variable entered by an end-user is not unique:

after registration if (not(saveuniquevalue(username, "studyid", page1.interaction1) goto page_notunique

Example 4

You can choose to allow a participant to continue with the intervention, but send an email to the study coordinator to alert them that a user has entered a value that is not unique:

after registration if (and(not(saveuniquevalue(username, "studyid", page1.interaction1)), sendemail( append(username,"not_unique"), "study@soton.ac.uk", "Participant - not unique", append("Participant ", loadvalue (username, "idnumber"), "has entered information that is not unique."),10) )) goto registrationfinish

Example 5

You can choose to send an email to the study coordinator if several specific values are not unique (e.g. surname, postcode and date of birth), as this could indicate that a participant is trying to register for your intervention more than once.

after registration if (and(not(saveuniquevalue(username, "surname", page1.interaction1)), not(saveuniquevalue(username, "postcode", page1.interaction2)), not(saveuniquevalue(username, "dob", page1.interaction3)), sendemail( append(username,"not_unique"), "study@soton.ac.uk", "Participant - not unique", append("Participant ", loadvalue (username, "idnumber"), "has entered information that is not unique."),10) )) goto registrationfinish

Tutorial

Please click here to view a demo of how the saveuniquevalue can be used. The demo allows users to enter a unique value and then change it to another unique value. To view the logic file, download this demo and import it to the LifeGuide authoring tool.