Introduction

Here is everything you would need to know about jump questions in PsyToolkit surveys. Similar information can also be found in the main documentation here.

In short: In PsyToolkit, you can jump between different questions based on what people answer. We use the jump type of question for this.

It is often easiest to learn from example, and here are just many different types of exampes for different situations.

Jump based on answer given

Imagine that you only want to ask certain people something. This is common. In this example, we ask if people are born in the UK, and if not, we ask them some extra questions we want to know.

For this, we need only one simply jump line, which we can do with j:

l: country
t: radio
q: Are you born in the United Kingdom?
- Yes (1)
- No (2)

j: if $country == 1 then goto food (3)

l: foreign (4)
t: textline
q: Where are you from?
- Enter country name

l: whenarrived (5)
t: textline
q: When did you settle in the United Kingdom
- Enter year

l: food (6)
t: radio
q: Which food do you like?
- Bread
- Potatoes
1 If people choose Yes, the score for $country will be 1
2 If people choose Yes, the score for $country will be 2
3 This is the jump line. Because only one line long, we can use shortcut j:
4 This is the question (foreign) where people end if people answered "No"
5 The question whenarrived follows for, thus is done next.
6 No matter what the answer to the question country was, you will always get this one.
In this conditional we use == (double equal sign). You can also use =. Both can be used and work. In computer languages, for equality checks the == is commonly used, which is why PsyToolkit has this option as well.

Unconditional jump

Sometimes, you need to jump to another question. You can do this with one line:

j: some_question

This can be useful at the end of a number of questions for a specific group of participants. In the example below, this is shown.

l: transport
t: radio
q: Do you use your car or the train mostly for travel to work?
- I use the car (1)
- I use the train (2)

j: if $transport = 2 then goto train (3)

l: car
t: radio
q: Do you like to drive fast?
- yes
- no

j: food (4)

l: train (5)
t: radio
q: Do you think train tickets are expensive?
- Yes
- No

l: food (6)
t: radio
q: Which food do you like?
- Bread
- Potatoes
1 If people choose I use the car, the score for $transport will be 1
2 If people choose I use the train, the score for $transport will be 2
3 If the value for $transport equals 1, then the next question will be train, otherwise it will be car
4 After the question car the survey always jumps to the food question
5 If people choose 2 for the transport question, they will get here
6 You will always get this question.
The main difference with the first example is that particpants either get the car or the train question, but not both.

Jump with more than two options

In the examples above, we used the j:. That was possible because the choices were simple. But sometimes you want to have more complex jumps, as in this example below.

l: diet
q: How do you describe yourself
- A meat eater
- A vegetarian
- A vegan
- A pescatarian (fish, but not meat)

l: (1)
t: jump (2)
- if $diet = 1 then goto meat
- if $diet = 2 then goto vegetarian
- if $diet = 3 then goto vegan
- if $diet = 4 then goto pescatarian

l: meat
t: check
q: Which of the following are your favourite meats?

j: further (3)

l: vegetarian
t: check
q: Which of the following are your favourite veggie dishes?
- Egg sandwich
- Honey crackers

j: further

l: vegan
q: Which of the following are your favourite vegan dishes?
- Bombay Burrito
- Spicy eggplant

j: further

l: pescatarian
q: Which of the following are your favourite fish dishes?
- Salmon
- Cod

j: further

l: further (4)
t: info
q: Thank you so far, now something else
1 This jump question does not have a label, it is just left empty. You can have one, but for jump it can be left empty.
2 This indicates this is a jump question. The participant does to see this on screen, PsyToolkit just uses it for making a jump
3 At the end of the meat section, we now jump to the question further unconditionally.
4 All participants will get to this question, no matter which diet

Jump for counterbalancing

In some surveys, including those with experiments, participants are assigned one of multiple conditions. For this, use the set random option and then use a jump, as follows.

Imagine you have 3 different conditions. First we assign each participant randomly to one of the three and then we jump as before. The follow up code is not included in this example

l: condition
t: set
- random 1 4

l:
t: jump
- if $condition = 1 then goto my_condition1
- if $condition = 2 then goto my_condition2
- if $condition = 3 then goto my_condition3
- if $condition = 4 then goto my_condition4

Here is a full example (note that sometimes we use = and sometimes == in these examples, both works in if statements).

l: choose_a_number
t: set
- random 1 2

l:
t: jump
- if $choose_a_number == 1 then goto Group1
- if $choose_a_number == 2 then goto Group2

l: Group1
t: experiment
- experiment_order1

l: alwaysjump
t: jump
- goto GoOn

l: Group2
t: experiment
- experiment_order2

l: GoOn
t: radio
q: How did you like the experiment
- I liked it
- I did not like it

When to use the shortcut j:

You can only use the j: instruction when the jump question has only one line. If there is more than one line, then you need more lines.

The j: is just a simple shortcut, especially because for jump items, the label l: is not necessary.

Jump and going back in survey

If you try these examples, you you need to be aware that once you have answered a question, you cannot necessarily go back and choose a different answer and then have a different jump. That is possible, but you need to choose the PsyToolkit survey option to allow participants to go back in the survey.