from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'condition2' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 ACTIVE_ROLE = 'active player' PASSIVE_ROLE = 'passive player' class Subsession(BaseSubsession): @staticmethod def creating_session(subsession): subsession.group_randomly(fixed_id_in_group=True) print(subsession.get_group_matrix()) class Group(BaseGroup): @staticmethod def set_payoffs(groups): Active = group.get_player_by_role(C.ACTIVE_ROLE) Passive = group.get_player_by_role(C.PASSIVE_ROLE) class Player(BasePlayer): competition = models.StringField(initial= 0, label='Which scheme would you like to choose in case condition 2 applies?', choices=["Competition Scheme", "Individual Scheme"]) Sabotage = models.StringField(initial= 0, label = 'Would you like to sabotage your opponent’s performance by adding 30 seconds to his or her time?', choices = [ "Yes, I would like to sabotage my opponent’s performance.", "No, I would not like to sabotage my opponent’s performance."]) # PAGES class Condition2(Page): form_model = 'player' form_fields = ["competition"] @staticmethod def is_displayed(player:Player): return player.role == C.ACTIVE_ROLE class Condition2p(Page): form_model = 'player' @staticmethod def is_displayed(player:Player): return player.role == C.PASSIVE_ROLE class Results(Page): form_model = 'player' form_fields = ["Sabotage"] @staticmethod def is_displayed(player): return player.competition == 'Competition Scheme' and player.role == C.ACTIVE_ROLE class Results1(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.competition == 'Individual Scheme' and player.role == C.ACTIVE_ROLE page_sequence = [Condition2,Condition2p,Results,Results1]