from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) doc = 'gender and altruism in charitable contributions' class Constants(BaseConstants): name_in_url = 'GenderAltruism' players_per_group = None num_rounds = 1 endowment = c(10) class Subsession(BaseSubsession): treatment = models.StringField() treatments = models.StringField() def creating_session(self): import itertools treatments = itertools.cycle(['R1','R2','R3']) for p in self.get_players(): p.treatment = next(treatments) class Group(BaseGroup): def set_payoffs(self): pass class Player(BasePlayer): age = models.IntegerField(label='What is your age', max=125, min=13) gender = models.StringField(choices=[['Male', 'Male'], ['Female', 'Female']], label='What is your gender', widget=widgets.RadioSelect) treatment = models.StringField() contribution1 = models.CurrencyField(blank=True, label='From your payment of 10 points for this game, how much will you contribute to this charitable cause:', max=10, min=0) contribution2 = models.CurrencyField(blank=True, label='From your payment of 10 points for this game, how much will you contribute to this charitable cause:', max=10, min=0) contribution3 = models.CurrencyField(blank=True, label='From your payment of 10 points for this game, how much will you contribute to this charitable cause:', max=10, min=0) payoff1 = models.CurrencyField(max=10, min=0) payoff2 = models.CurrencyField(max=10, min=0) payoff3 = models.CurrencyField(max=10, min=0) finalpayoff = models.CurrencyField(max=10, min=0) workerID = models.StringField(blank=True, label='Please enter your Amazon M-turk worker ID:')