A method for randomizing more than 2 pages works like this (here for three tasks):
class Constants(BaseConstants):
name_in_url = 'random_page_order'
players_per_group = None
tasks = ['A', 'B', 'C']
num_rounds = len(tasks)
def creating_session(subsession):
import random
if subsession.round_number == 1:
for p in subsession.get_players():
round_numbers = list(range(1, Constants.num_rounds+1))
random.shuffle(round_numbers)
print(round_numbers)
p.participant.vars['task_rounds'] = dict(zip(Constants.tasks, round_numbers))
print(p.participant.vars['task_rounds'])
class TaskA(Page):
def is_displayed(player):
return self.round_number == player.participant.vars['task_rounds']['A']
class TaskB(Page):
def is_displayed(player):
return self.round_number == player.participant.vars['task_rounds']['B']
class TaskC(Page):
def is_displayed(player):
return self.round_number == player.participant.vars['task_rounds']['C']
page_sequence = [TaskA, TaskB, TaskC]
The print-commands are not necessary, but can help to understand how the randomization works.