oTree Forum >

**#1
by
trungnguyen2004
**

problem with is_display for different groups: Hello everyone, I'm new at using otree and I have run into a problem that I hope to seek advice from everyone. Currently, my project is to randomly assign Set A and Set B for participants. When a participant is assigned to set A, PageA will be display, and so on. However: I have run into the problem using these line of code: from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): def creating_session(self): import random for player in self.get_players(): player.set_assignment = random.choice(['Set A', 'Set B']) print('Assigned set_assignment:', player.set_assignment) class Group(BaseGroup): pass class Player(BasePlayer): set_assignment = models.StringField() q1_setA = models.StringField( label="S1. 100% chance of getting $7 <br> R1. 20% chance of getting $10, 75% chance of getting $7, and 5% chance of getting nothing.", choices=['S1', 'R1'], widget=widgets.RadioSelect ) q2_setA = models.StringField( label="The second question asks the respondent to choose from lotteries S2 and R2:<br>S2. 25% chance of getting $7 and 75% chance of getting nothing; <br> R2. 20% chance of getting $10 and 80% chance of getting nothing.", choices=['S2', 'R2'], widget=widgets.RadioSelect ) q1_setB = models.StringField( label="S1. 100% chance of getting $700 <br> R1. 20% chance of getting $10, 75% chance of getting $7, and 5% chance of getting nothing.", choices=['S1', 'R1'], widget=widgets.RadioSelect ) q2_setB = models.StringField( label="The second question asks the respondent to choose from lotteries S2 and R2:<br>S2. 25% chance of getting $7 and 75% chance of getting nothing; <br> R2. 20% chance of getting $10 and 80% chance of getting nothing.", choices=['S2', 'R2'], widget=widgets.RadioSelect ) # PAGES class SetAPage(Page): form_model = 'player' form_fields = ['q1_setA', 'q2_setA'] def is_displayed(self): if self.set_assignment: return self.set_assignment == 'Set A' return False class SetBPage(Page): form_model = 'player' form_fields = ['q1_setB', 'q2_setB'] def is_displayed(self): if self.set_assignment: return self.set_assignment == 'Set B' return False class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [SetAPage, SetBPage] Please help me with some advice. Thank you everyone.

**#2
by
henning99
**

Inside your is_displayed function the if statement seems off. You are trying to use an if statement on a string value. Try this: @staticmethod def is_displayed(player): return player.set_assignment == 'Set A'

**#3
by
henning99
**

Also you are using self. maybe you need use player.