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 Summaryscreen showing for the second (conditional) question (VI2), click on theSet conditionsbutton on theSurvey toolbar. - In the
Previous questionstab of theQuestiontext box, click on the question that this question is conditional upon – VI1. - Choose the appropriate
Comparison operator– Greater than or equal to - Click the
Constanttab in theAnswertext box, then type 1. - Click the
Add Conditionbutton. - Click the
Closebutton in the top right-hand corner to close theConditions designerwindow. - Click
Preview question groupto preview the question, testing entering a 0, then another number. - Close the
Previewtab.
Copy questions
- Click on
Question explorerin theSurvey explorerpanel on the left of the screen. - Click on the VI1 question to select it.
- Click the
Copybutton 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 optionsare required for this question - click theSave and closebutton on the toolbar. - Now click on the VI2 question in
Question explorerto select it. - Click the
Copybutton 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 closebutton on the toolbar. - With the
Question Summaryscreen showing for MI2, click on theSet conditionsbutton on theSurvey toolbar. - In the
Previous questionstab of theQuestiontext box, click on the question that this question is conditional upon – MI1. - Choose the appropriate
Comparison operator– Greater than or equal to - Click the
Constanttab in theAnswertext box, then type 1. - Click the
Add Conditionbutton. - Click the
Closebutton in the top right-hand corner to close theConditions designerwindow.
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 Groupbutton. 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 questionschoose List (dropdown).- Click the
Save and closebutton.
- Click the
Edit answer optionsbutton 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 onebutton (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 closebutton. - Preview the question, then close the
Previewtab.
Ready to move on? Head to the next page or ask a question.