from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'pandya_vivek' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): condition = models.IntegerField() age = models.IntegerField(label='What is your age?', min=18, max=70) gender = models.StringField( choices=[['Male', 'Male'], ['Female', 'Female']], label='What is your gender?', widget=widgets.RadioSelect, ) choice=models.StringField( choices=[['Yes', 'Yes'], ['No', 'No']], label='Do you want to accept the alternative offer?', widget=widgets.RadioSelect, ) ##FUNCTIONS def creating_session(subsession): import itertools clist = itertools.cycle([0,1,1,0]) for player in subsession.get_players(): player.condition = next(clist) ##PAGES class intro(Page): form_model = 'player' class thanks(Page): form_model = 'player' class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender'] class Intervention0(Page): def is_displayed(player: Player): return player.condition == 0 pass class Intervention1(Page): def is_displayed(player: Player): return player.condition == 1 pass class Choice0(Page): def is_displayed(player: Player): return player.condition == 0 form_model = 'player' form_fields = ['choice'] pass class Choice1(Page): def is_displayed(player: Player): return player.condition == 1 form_model = 'player' form_fields = ['choice'] pass class Results(Page): pass page_sequence = [intro, Demographics, Intervention0, Intervention1, Choice0, Choice1, thanks]