Note: You are currently viewing documentation for Moodle 3.6. Up-to-date documentation for the latest stable version of Moodle is likely available here: Questionnaire Conditional branching.

Questionnaire Conditional branching

From MoodleDocs

Overview

Definition

Conditional branching (or Skip logic) is a feature that changes what question or page a respondent sees next based on how they answer the current question. Conditional branching creates a custom path through the survey that varies based on a respondent’s answers.

Organization

In the Questionnaire plugin, the Conditional branching path is organized through pages, containing one or more "child" questions depending on one or more "parent" question answers. For a question, you can add one or more mandatory parent question responses and / or one or more optional question responses. All question responses in the mandatory section must be met exactly for the child question to be displayed. At least one question response in the optional section must be met for the question to be displayed. You can also specify whether the question response option must be the one answered, or the one not answered. In previous versions, only one question response could be selected and it had to be the answer given. If only one mandatory question response is selected as the one that must be answered, then the functionality will be identical to previous versions.

dependentquestion171211.png

Settings

If you want to use the Conditional branching feature in a Questionnaire, when you create or edit the questionnaire, in the Response options section of the settings, you must set the Allow branching questions option to Yes. Please note that this option is set to No by default.

A simple example

The flow we want to obtain

  • Page 1
    • Question 1 Do you own a car? Yes/No.
  • Page 2 - Display if question 1 answer is "Yes"
    • Question 2: What is the colour of your car?
    • Question 3: Did you buy it new or second-hand?
  • Page 3 - Display if question 3 answer is "new"
    • Question 4: Did you pay for your new car with cash or did you get a bank loan?
  • Page 4 - Display if question 3 answer is "second-hand"
    • Question 5: Did you buy your second-hand car from a garage or directly from its previous owner?
  • Page 5
    • Question 6: Do you work outside of your residence?
  • Page 6 - Display if question 1 answer is "No" and question 6 answer is "Yes"
    • Question 7: Do you use public transport to go to work?
  • Page 7
    • Question 8: Did you like this questionnaire?

etc.

Procedure to obtain that flow

  • Create Q1 as a Yes/No question.
    • Question Name: Own car. Note that you must give your question a name, as this name will be used later on in the Questionnaire to build the list of available Parent questions. Please keep this name as short as possible.
    • Response Required: Yes. Since you plan to use question Q1 as a Parent question, it would not make sense to set it as non-required.
    • Question Text: Do you own a car?
    • Save Q1. No Page break will be inserted at this stage because you have not yet used a Parent question to create one or more Child questions.
  • Create Q2 as a Text Box question type
    • Question Name: Optional colour
    • Response Required: Yes or No (depending on what you want to do with that question's answers later on).
    • Parent Question : own car->Yes. The Parent question (Q1) option offers 2 choices, since it is a Yes/No question.
    • Question Text: What is the colour of your car?
    • Save Q2. Upon saving Child question Q2 you notice that a Page break has been automatically inserted between the Parent question Q1 and its Child question Q2.
  • Create Q3 as a Radio Buttons (or Dropdown Box) question type
    • Question Name: Car status
    • Response Required: Yes. We are giving question Q3 a name and setting it as Required because we plan to use it as a Parent question.
    • Parent Question: Own car->Yes
    • Question Text: Did you buy it new or second-hand?
    • Possible answers:
      • new::I bought it new
      • used::I bought it second-hand.
    • Please note that in the Possible answers field we are using the "short label" feature. You should use this feature if the full text of your Possible answers choices is fairly long.
    • Save Q3. Upon saving Child question Q3 you notice that no Page break has been inserted. This is because both Q2 and Q3 are Child questions of the same Parent question Q1 and thus will be displayed on the same page of the questionnaire.
  • Create Q4 as a Radio Buttons question type
    • Question Name: Optional payment
    • Response Required: Yes or No
    • Parent Question: car status->new
    • Please note that the list of potential Parent question choices displays the "short label" that we entered for the Possible answers in Q3, instead of the full text.
    • Question Text: How did you pay for your new car?
    • Possible answers:
      • I paid cash
      • I got a bank loan
    • Save Q4. Upon saving Child question Q4 you notice that a Page break has been automatically inserted between Parent question Q3 and its Child question Q4.
  • Create Q5 as a Radio Buttons question type
    • Question Name: Optional owner
    • Response Required: Yes or No
    • Parent Question: car status->used
    • Question Text: Where did you buy your second-hand car?
    • Possible answers:
      • I bought it from a garage
      • I bought it directly from its previous owner
    • Save Q5. Upon saving Child question Q5 you notice that a Page break has been automatically inserted between Child question Q4 and Child question Q5 because these two question do not have the same Parent question.
  • Create Q6 as YES/NO question type.
    • Question Name: Work outside home
    • Response Required: Yes or No
    • Parent Question: None.
      Question 6 is not dependent on any of the previous questions, and it will be displayed to the questionnaire respondent regardless of their previous answers.
    • Question Text: Do you work outside of your residence?
    • Save Q6. Upon saving question Q6 you notice that a Page break has been automatically inserted between Child question Q5 and question Q6.
  • Create Q7 as YES/NO question type.
    • Question Name: Transit
    • Response Required: Yes or No
    • Parent Question 1: Own car->No / This answer given
    • Parent Question 2:Work outside home->Yes / This answer given
    • Question Text: Do you sometimes use public transport to go to work?
    • Save Q7. Upon saving question Q7 you notice that a Page break has been automatically inserted between Child question Q6 and question Q7.
  • Create Q8 as YES/NO question type.
    • Question Name: Enjoy
    • Response Required: Yes or No
    • Parent Question: None.
      Question 6 is not dependent on any of the previous questions, and it will be displayed to the questionnaire respondent regardless of their previous answers.
    • Question Text: Did you enjoy this questionnaire?
    • Save Q8. Upon saving question Q8 you notice that a Page break has been automatically inserted between Child question Q7 and question Q8.

Now continue creating questions normally, until you want to use Conditional branching again.

Here is what your Manage questions section will look like after you have created those first 8 questions.

managequestions171211.png

Operations on Conditional branching questions

Move

By using the standard Moodle "Move" icon you can move your questionnaire questions to different positions. However, due to the special nature of the questionnaire flow when using the Conditional branching feature, there are restrictions on the new positions that you can move our questions to.

  • You cannot move a Parent question below any of its Child questions.
  • You cannot move a Child question above its Parent question.
  • You cannot remove those Page breaks which are needed to ensure a correct flow of dependent questions.

07-08-2013 18-04-16.jpg

Those restrictions will show on the Manage questions screen where the Move icon is replaced with a "Forbidden" (Moodle "block") icon. They will also operate when you are in "Move question" mode, where the Move to here icon/placeholder will not be displayed in the "forbidden" positions.

Edit

Using the standard Moodle "Edit" icon you may edit any question. However, for those questions which have both a Parent and / or Child questions, care should be taken when changing their Parent questions & Choice, as that might ruin the consequent flow.

Delete

You cannot Delete those Page breaks which have been automatically inserted when adding Child questions.

If you try to Delete a Parent question, you will get a warning with the list of its Child questions. If you answer Yes to the warning, the Parent question will be deleted, and the direct dependencies will be removed.

deleteparent171211.png

Setting as Required/Not required

As said above, you would normally set all potential Parent questions as Required. However, there might be cases where you want to leave the respondent the choice to respond or not. If you set a question as Not required, then the usual "No answer" button will be displayed (for Yes/No and Radio Buttons questions). If the respondent does not answer a Parent question, all of its Child questions will be skipped over.

Previewing Questionnaire

The Previewing Questionnaire page is useful for a Questionnaire creator to see the questionnaire question display with the various dependencies displayed. The following screenshot illustrates an example preview screen with conditional questions.

previewdependent171211.png

It is possible for a teacher previewing a questionnaire to "Submit the preview". This will mimic the behaviour of the real Submit questionnaire process: any required question that has not been responded to or any response that does not conform to the question's conditions will be marked with a Warning.

If all the required questions have been correctly filled in, then upon submitting the preview, a "correct" message will be displayed.

To simulate a new questionnaire flow, you can either click the Preview link in your course's navigation bar, or the Preview link in the Questionnaire Administration block or the Reset link at the bottom of the Preview window.

Individual Responses Report

Branching questionnaire reports display the same as non-Branching ones. The only notable difference is with the Individual Responses Report, where it is possible to view the particular path that a respondent took through the various conditional questions. Here are 2 examples.

08-08-2013 23-40-12.jpg

Respondent "Michael Cane" said he owns a red car, bought it new and paid cash for it. He was not presented with Q5, which is displayed between parentheses and greyed out.

08-08-2013 23-43-18.jpg

Respondent "John Doe" said he does not own a car. He was not presented with any of the dependent questions Q2 through Q5.