from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'condition7' 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 7 applies?', choices=["Competition Scheme", "Individual Scheme"]) destroy = models.StringField(initial=0, label="Would you like to destroy half of your opponent's payoff in case that you lose? ", choices=["Yes, I would like to destroy half of her/his earnings.", "No, I would not like to destroy half of her/his earnings."]) belief_destroy = models.IntegerField(min=0, max=100, label='How many passive players out of 100 do you think will choose the destroy option (between 0 to 100)? You will earn an extra 50 cents if the true number is within +5 to -5 number of your answer.' ) # PAGES class Condition7(Page): form_model = 'player' form_fields = ["competition"] @staticmethod def is_displayed(player: Player): return player.role == C.ACTIVE_ROLE class Results(Page): form_model = 'player' form_fields = ["destroy"] @staticmethod def is_displayed(player): return player.competition == 'Competition Scheme' and player.role == C.ACTIVE_ROLE class Results1(Page): form_model = 'player' form_fields = ["belief_destroy"] @staticmethod def is_displayed(player): return player.competition == 'Individual Scheme' and player.role == C.ACTIVE_ROLE class Results6(Page): form_model = 'player' form_fields = ["belief_destroy"] @staticmethod def is_displayed(player): return player.competition == 'Competition Scheme' and player.role == C.ACTIVE_ROLE class Condition7p(Page): form_model = 'player' form_fields = ["destroy"] @staticmethod def is_displayed(player: Player): return player.role == C.PASSIVE_ROLE page_sequence = [Condition7, Condition7p,Results,Results1,Results6]