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

From Lifeguide Wiki
Revision as of 12:38, 23 September 2014 by Judy (talk | contribs)
Jump to navigation Jump to search

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).

Example 1

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

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

Example 2

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

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

Example 3

You can choose to send an email to the study coordinator to alert them that a user has not entered a value that is not unique:

after page1 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 page_notunique


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).

Please click here to view a demo of how the saveuniquevalue can be used. To view the logic file, download this demo and import it to the LifeGuide authoring tool.