from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'role' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 PRINCIPAL_ROLE = 'Principal' AGENT_ROLE = 'Agent' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): pass def chat_nickname(player): group = player.group return 'Group {} player {}'.format(group.id_in_subsession, player.id_in_group) def chat_channel(player): group = player.group return 'Group {}'.format(group.id_in_subsession) class ShuffleWaitPage0(WaitPage): wait_for_all_groups = True @staticmethod def after_all_players_arrive(subsession): matrix = [[1, 2], [3, 4]] subsession.set_group_matrix(matrix) # This method works!! Pre-assign from MatLab, and fix it class MyPage(Page): @staticmethod def vars_for_template(player): return dict( channel=chat_channel(player) ) class ShuffleWaitPage(WaitPage): wait_for_all_groups = True @staticmethod def after_all_players_arrive(subsession): matrix = [[4, 1], [2, 3]] subsession.set_group_matrix(matrix) class Page1(Page): @staticmethod def vars_for_template(player): return dict( channel=chat_channel(player) ) class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [ShuffleWaitPage0, MyPage, ShuffleWaitPage, Page1, Results]