from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, ) author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'deposit_refund' players_per_group = 4 num_rounds = 2 participation_fee = 3 endowment = 10 mpcr = 0.4 threshold = 8 #threshold to be considered compliant bond = 6 audit_p = 2/3 cost = 1 #cost of monitoring rate = 10 ## 2 payoff structure: pay_yellow_A 10c; pay_purple_B 70c and pay_yellow_A 10c 10c; pay_purple_B 50c class Subsession(BaseSubsession): pass #@staticmethod # def group_by_arrival_time_method(self, waiting_players): # # new_group = [] # # for p in waiting_players: # new_group.append(p) # if len(new_group) == 4: # here the number of player that form a group are defined. # return new_group # # for p in waiting_players: # this automatically advances players that have been waiting too long. # if p.waiting_too_long(): # p.participant.vars['time'] = 1 # return [p] class Group(BaseGroup): treatment = models.IntegerField() ##0: Baseline; 1: PM-SE; 2: PM-PE; 3:PM-3E; 4: 3M-SE; 5:3M-PE; 6: 3M-3E sum_contribution = models.IntegerField() die_p1 = models.IntegerField() die_p2 = models.IntegerField() die_p3 = models.IntegerField() die_p4 = models.IntegerField() audit_p1 = models.IntegerField() audit_p2 = models.IntegerField() audit_p3 = models.IntegerField() audit_p4 = models.IntegerField() contribution_p1 = models.IntegerField() contribution_p2 = models.IntegerField() contribution_p3 = models.IntegerField() contribution_p4 = models.IntegerField() compliant_p1 = models.IntegerField() compliant_p2 = models.IntegerField() compliant_p3 = models.IntegerField() compliant_p4 = models.IntegerField() punish_p1 = models.FloatField() punish_p2 = models.FloatField() punish_p3 = models.FloatField() punish_p4 = models.FloatField() class Player(BasePlayer): # def waiting_too_long(self): # import time # return time.time() - self.participant.vars['wait_page_arrival'] > 300 #is_dropout = models.BooleanField(initial=False) audit = models.IntegerField() contribution = models.IntegerField() compliant = models.IntegerField() punish = models.FloatField(initial=0) see_info = models.IntegerField(initial=0) pay_fee = models.IntegerField(initial=None, choices=[[0, 'No'], [1, 'Yes']], label='Do you want to pay the 1-token access fee?', widget=widgets.RadioSelectHorizontal()) forfeit = models.IntegerField(initial=None, choices=[[0, 'No'], [1, 'Yes']], label='Do you want to forfeit your own deposit?', widget=widgets.RadioSelectHorizontal()) forfeit_p1 = models.IntegerField(initial=None, choices=[[0, "Leave deposit unchanged"], [1, "Reduce deposit"]], verbose_name='1', widget=widgets.RadioSelectHorizontal()) forfeit_p2 = models.IntegerField(initial=None, choices=[[0, "Leave deposit unchanged"], [1, "Reduce deposit"]], verbose_name='2', widget=widgets.RadioSelectHorizontal()) forfeit_p3 = models.IntegerField(initial=None, choices=[[0, "Leave deposit unchanged"], [1, "Reduce deposit"]], verbose_name='3', widget=widgets.RadioSelectHorizontal()) forfeit_p4 = models.IntegerField(initial=None, choices=[[0, "Leave deposit unchanged"], [1, "Reduce deposit"]], verbose_name='4', widget=widgets.RadioSelectHorizontal()) refund = models.FloatField() current_pay = models.FloatField() current_pay_p1 = models.FloatField() current_pay_p2 = models.FloatField() current_pay_p3 = models.FloatField() #### PAYOFF #### pay_TG = models.FloatField() pay_MG = models.FloatField() total_pay = models.FloatField() rand_round = models.IntegerField() #Demographics q_english = models.PositiveIntegerField(initial=None, choices=[[0, 'No'], [1, 'Yes']], label='Is English the language you use the most at home?', widget=widgets.RadioSelect()) q_age = models.PositiveIntegerField(label='How old are you?', choices=range(18, 80), initial=None, blank=True) q_gender = models.PositiveIntegerField(initial=None, choices=[[0, 'Male'], [1, 'Female'],[2, 'Other'],[3, 'Prefer not to say']], label='Which category best describe your gender?', widget=widgets.RadioSelect()) q_risk = models.PositiveIntegerField(label="Are you a person who is generally willing to take risks, or do you try to avoid taking risks on a scale from 0 (completely unwilling to take risks) to 10 (completely willing to take risks)?", choices=range(0, 11), initial=None, blank=True) q_clarity = models.PositiveIntegerField(initial=None, choices=[[0, 'Extremely unclear'], [1, 'Somewhat unclear'], [2, 'Somewhat clear'], [3, 'Extremely clear']], label='How would you rate the clarity of the questions?', widget=widgets.RadioSelect()) q_check = models.StringField( label="", ) q_other = models.CharField(blank=True)