from otree.api import * c = cu doc = 'This app is to test things out.' class Constants(BaseConstants): name_in_url = 'Tests' players_per_group = None num_rounds = 1 endowment = cu(10) moderate_default = cu(5) information_default = cu(0) def creating_session(subsession): session = subsession.session import itertools treatment_group = itertools.cycle([1, 2, 3]) for player in subsession.get_players(): player.treatment_group = next(treatment_group) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): treatment_group = models.IntegerField() contribution_zero_default = models.CurrencyField(choices=[[0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']], initial=0, label='Enter your value:', max=Constants.endowment, min=0) contribution_moderate_default = models.CurrencyField(choices=[[0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']], initial=Constants.moderate_default, label='Enter your value:', max=Constants.endowment, min=0) contribution_information = models.CurrencyField(choices=[[0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']], initial=0, max=Constants.endowment, min=0) num_clicks = models.IntegerField() class Link(Page): form_model = 'player' form_fields = ['num_clicks'] @staticmethod def js_vars(player): return dict(url='https://germany.myclimate.org/de/offset_further_emissions') class Zero_default(Page): form_model = 'player' form_fields = ['contribution_zero_default'] @staticmethod def is_displayed(player): group = player.group return player.treatment_group == 1 class Moderate_Default(Page): form_model = 'player' form_fields = ['contribution_moderate_default'] @staticmethod def is_displayed(player): group = player.group return player.treatment_group == 2 class Information(Page): form_model = 'player' form_fields = ['contribution_information'] @staticmethod def is_displayed(player): group = player.group return player.treatment_group == 3 page_sequence = [Link, Zero_default, Moderate_Default, Information]