Adding Error Messages: Difference between revisions

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


Each intervention page has a '''page creator''' view for creating the page and an '''error messages''' view to write the error message. This is located below the insert panel (Figure 1)
Each intervention page has a '''page creator''' view for creating the page and an '''error messages''' view to write the error message. This is located below the insert panel (Figure 1)
--------------
Once you have added an error message text box to the page you can click on the error messages view to add your logic.
Below is a list of example error messages that can be used with a breakdown of what they mean. Examples can also be found in the tutorial folder on the LifeGuide Community website.
=Example 1: Error messages for unanswered single\multiple choice and text entry interactions=
This example uses the '''isempty''' command to check that an end-user gives a response to a specified interaction. If a specified interaction is left empty, an error message will appear to ask end-users to respond before they move onto the next page.
The example given below is to ensure end-users enter a response to a single choice interaction, but the '''isempty''' logic command can be used to provide an error message for single/multiple choice and text entry interactions. The isempty command cannot be used for numeric interactions – see example 2 for how to write error messages for numeric interactions that end-users have not given a response to.
*Show generror if (isempty (gender))
In this example, '''generror''' is the name given to the error message; '''gender''' is the name given to the interaction that end-users are required to fill in before they move onto the next page; '''isempty''' is a logic command that checks if the interaction has been filled in or not. So if the interaction uniquely named '''gender''' is empty, the error message '''generror''' will be shown to end-users.
'''Please note:''' Unlike logic commands written in the '''intervention.lgil''' file, error message logic does not require the page name to be included with the interaction name, e.g. use '''gender''' rather than '''page1.gender'''.
=Example 2: Error messages for unanswered numeric interactions=
This example uses the '''isempty''' command to check that an end-user gives a response to a specified numeric interaction.
*Show ageerror if (age<18)
In this example, '''ageerror''' is the name given to the error message; '''age''' is the name given to the interaction that end-users are required to fill in before they move onto the next page. If an end-user does not select an age (and so the default value of 0 remains), or selects an age under 18 (in this example, we want end-users to be over the age of 18), an error message will appear.

Revision as of 10:20, 5 November 2010

Adding Error Messages

Error messages can be used to tell end-users that they have not given a response to a specific interaction and need to do so before moving on to the next page.

Error messages are useful if you want to ensure that end-users interact with the page in a certain way. Examples of when you might want to do this include:

  • You need end-users to respond to a specific interaction(s)
  • You need to make sure that an end-user’s login details have not already been registered
  • You need to check if an e-mail address that an end-user enters is valid
  • You want end-users to confirm their response by entering it twice
  • You need to check that an end-user has entered the correct combination of letters and/or numbers given to them previously (e.g. a participant number)
  • You want end-users to enter a specific response (e.g. a study code)

NB: An end-user cannot move to the next page in the intervention until the specified interactions have been completed correctly.

Adding Error Messages to Intervention Pages

Error messages are added to pages using a text box that has been set as an error type. Although the error message is always visible on the page in the authoring tool, it will only be shown to end-users if the error it refers to has occurred (e.g. if they have not entered the required information).

We recommend writing error messages in bold text or in a different colour to the rest of the text on the page so that it will be easier for end-users to see.

Naming your error message

Each error message needs to be given a name that is unique to the page that it is on so that it can be used in the logic.

Important: You cannot give an error message the unique name error as error is a key command that is used by the logic. However, as long as it is prefixed with another word e.g. ageerror then this is fine.

The Error Message Logic

Error messages require logic but unlike other commands in LifeGuide, the logic needs to be written on the error message view of the page that you want the error message to show on, not in the intervention file.

Each intervention page has a page creator view for creating the page and an error messages view to write the error message. This is located below the insert panel (Figure 1)


Once you have added an error message text box to the page you can click on the error messages view to add your logic.

Below is a list of example error messages that can be used with a breakdown of what they mean. Examples can also be found in the tutorial folder on the LifeGuide Community website.


Example 1: Error messages for unanswered single\multiple choice and text entry interactions

This example uses the isempty command to check that an end-user gives a response to a specified interaction. If a specified interaction is left empty, an error message will appear to ask end-users to respond before they move onto the next page.

The example given below is to ensure end-users enter a response to a single choice interaction, but the isempty logic command can be used to provide an error message for single/multiple choice and text entry interactions. The isempty command cannot be used for numeric interactions – see example 2 for how to write error messages for numeric interactions that end-users have not given a response to.

  • Show generror if (isempty (gender))

In this example, generror is the name given to the error message; gender is the name given to the interaction that end-users are required to fill in before they move onto the next page; isempty is a logic command that checks if the interaction has been filled in or not. So if the interaction uniquely named gender is empty, the error message generror will be shown to end-users.

Please note: Unlike logic commands written in the intervention.lgil file, error message logic does not require the page name to be included with the interaction name, e.g. use gender rather than page1.gender.

Example 2: Error messages for unanswered numeric interactions

This example uses the isempty command to check that an end-user gives a response to a specified numeric interaction.

  • Show ageerror if (age<18)

In this example, ageerror is the name given to the error message; age is the name given to the interaction that end-users are required to fill in before they move onto the next page. If an end-user does not select an age (and so the default value of 0 remains), or selects an age under 18 (in this example, we want end-users to be over the age of 18), an error message will appear.