Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably 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 a "parent" question.

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.
      • Answer Yes -> go to page 2
      • Answer No -> go to page 5 (i.e. skip over irrelevant questions in pages 2 through 4)
  • Page 2
    • Question 2: What is the color of your car?
    • Question 3: Did you buy it new or second-hand?
      • Answer new -> go to page 3
      • Answer second-hand -> go to page 4
  • Page 3
    • Question 4: Did you pay your new car cash or did you get a bank loan?
  • Page 4
    • Question 5: Did you buy your second-hand car from a garage or directly from its previous owner?
  • Page 5
    • Question 6: Do you sometimes use public transport to go to work?

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
    • 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
    • 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
    • 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: optional
    • 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 sometimes use public transport to go to work?
    • Save Q6. Upon saving question Q6 you notice that a Page break has been automatically inserted between Child question Q5 and question Q6.

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 6 questions.

07-08-2013 17-49-53.jpg

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 question and one or more Child questions, you cannot change their Parent question & Choice, as that might ruin the consequent flow. The only way to change their Parent is to edit their Child question(s) first.

07-08-2013 18-12-59.jpg

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, together with all its Child (and Grand-Child questions).

07-08-2013 18-20-29.jpg

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 test it out before making it available in a course. In the case of a Conditional branching questionnaire, the Preview is especially useful as it will mimic the flow that a respondent will see, by selecting the various choices offered by the Parent questions.

When a Conditional branching questionnaire is first displayed on the Preview page, only those pages containing "top" parent questions are displayed, as well as pages containing questions that do not have a Parent question.

When a choice is made in the Parent questions, the Child question(s) corresponding to that choice is/are displayed.

The following screnshots illustrate the various possible sequences that can be displayed. In this example, we have set Question 3 as Non-required.

07-08-2013 18-52-40.jpg

The only 2 questions displayed are those with no Parent: Q1 and Q6.

07-08-2013 18-54-36.jpg

Upon clicking on Q1 'No', nothing changes in the display, because in our questionnaire we do not have any Child question dependent on that choice.

08-08-2013 19-07-13.jpg

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.

08-08-2013 18-56-25.jpg

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.

08-08-2013 22-45-33.jpg

Upon clicking the Yes radio button in answer to Q1, questions Q2 and Q3 on Page 2, which depend on that Q1 Yes choice are automatically displayed. In "Answer the questions" mode, the respondent would be taken to Page 2 of the questionnaire. Now, if we click on the I bought it new radio button of Q3, Q4 on Page 3 will be displayed, etc.

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.