Branching logic
Determine whether or not to show a question based on conditions.
If statements have the syntax “if…then”, however LimeSurvey Conditions meet the statement “Only show this question if…” In simple terms, a LimeSurvey Condition is the “then” part of the If statement, so it is applied to the second (conditional) question. In this example, we are saying “ask how many hours (VI2) only if the answer to VI1 is 1 or more”.
In this section we will tell LimeSurvey to only display the following questions if certain conditions are met.
- With the
Question Summary
screen showing for the second (conditional) question (VI2), click on theSet conditions
button on theSurvey toolbar
. - In the
Previous questions
tab of theQuestion
text box, click on the question that this question is conditional upon – VI1. - Choose the appropriate
Comparison operator
– Greater than or equal to - Click the
Constant
tab in theAnswer
text box, then type 1. - Click the
Add Condition
button. - Click the
Close
button in the top right-hand corner to close theConditions designer
window. - Click
Preview question group
to preview the question, testing entering a 0, then another number. - Close the
Preview
tab.
Copy questions
- Click on
Question explorer
in theSurvey explorer
panel on the left of the screen. - Click on the VI1 question to select it.
- Click the
Copy
button on theSurvey toolbar
. - In the
Code:
text box, type a new code – MI1 (Moderate Intensity 1 – refer to the survey design). - In the
Question:
text box, change “vigorous” intensity sports to “moderate” intensity sports. (two places) - In the
Help:
text box, delete the existing text then type (or copy andPaste as Plain Text
):
Moderate-intensity sports include brisk walking, cycling or swimming; are likely to cause small increases in breathing or heart rate, and should be done for at least 10 minutes continuously.
- No
Copy options
are required for this question - click theSave and close
button on the toolbar. - Now click on the VI2 question in
Question explorer
to select it. - Click the
Copy
button on theSurvey toolbar
. - Type a new code – MI2.
- In the
Question:
text box, change “vigorous” intensity sports to “moderate” intensity sports. - Click the
Save and close
button on the toolbar. - With the
Question Summary
screen showing for MI2, click on theSet conditions
button on theSurvey toolbar
. - In the
Previous questions
tab of theQuestion
text box, click on the question that this question is conditional upon – MI1. - Choose the appropriate
Comparison operator
– Greater than or equal to - Click the
Constant
tab in theAnswer
text box, then type 1. - Click the
Add Condition
button. - Click the
Close
button in the top right-hand corner to close theConditions designer
window.
Answer options
In the previous questions, the respondent is to enter (type) an answer to the question. For questions where the answers are provided for selection (e.g. multiple choice), the question and answers are created in two separate steps.
- Click the
Add new Question to Group
button. Code:
SRQuestion:
Type (or copy andPaste as Plain Text
):
The following question is about sitting or reclining including time spent sitting at a desk, sitting with friends, travelling in a car, bus, train, reading, playing cards or watching television. Do not include time spent sleeping. How much time do you usually spend sitting or reclining on a typical day?
Question type:
underSingle choice questions
choose List (dropdown).- Click the
Save and close
button.
- Click the
Edit answer options
button on theSurvey toolbar
. - In the first answer box, add
Code:
SRa, then in the first text box, typeLess than 1 hour
. - Click the
Insert a new answer option after this one
button (the ‘+’ sign), then repeat until all answer options are added, incrementing the codes – SR1b, SR1c, etc. – as you go.
SRb 3 hours
SRc 4-8 hours
SRd 9-12 hours
SRe More than 12 hours
- Click the
Save and close
button. - Preview the question, then close the
Preview
tab.
Ready to move on? Head to the next page or ask a question.