from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) # from otree_tools.models.fields import OtherModelField import random import itertools author = 'Celine Zhang' doc = """ This is a one-period public goods game with 32 players and 4 per group. """ class Constants(BaseConstants): name_in_url = 'twoddnond' players_per_group = None num_rounds = 1 instructions_template = 'dictator/instructions.html' endowment = c(100) pool_multiplier = c(2.0) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): decision1 = models.CurrencyField( min=0, max=Constants.endowment, ) decision2 = models.CurrencyField( min=0, max=Constants.endowment, ) decision3 = models.CurrencyField( min=0, max=Constants.endowment, ) control1 = models.CurrencyField( min=0, max=Constants.endowment, ) control2 = models.CurrencyField( min=0, max=Constants.endowment, ) control3 = models.CurrencyField( min=0, max=Constants.endowment, ) newcheck = models.CharField(choices=['Reward up to 60 points to any Group Member.', 'Remove up to 60 points from any Group Member.', 'Increase the size of the Group Project by 60 points.' ], widget=widgets.RadioSelect) newcheck2 = models.CharField(choices=['Person 1', 'Person 2', 'Person 3' ], widget=widgets.RadioSelect) newcheck3 = models.CharField(choices=['Red', 'Purple', 'Yellow', 'Green', 'None of the above' ], widget=widgets.RadioSelect) s1q1attempt = models.IntegerField(initial=0) s1q2attempt = models.IntegerField(initial=0) s1q3attempt = models.IntegerField(initial=0) subjectid = models.CharField(initial='') payoff2 = models.CurrencyField() p1_payoff2 = models.CurrencyField() p2_payoff2 = models.CurrencyField() p3_payoff2 = models.CurrencyField() contribution = models.CurrencyField( min=0, max=Constants.endowment, doc="""The amount contributed by the player""", ) total_contribution = models.CurrencyField() individual_share = models.CurrencyField() def set_payoffs(self): self.total_contribution = self.contribution + 90 self.individual_share = self.total_contribution * Constants.pool_multiplier / 4 self.payoff2 = Constants.endowment - self.contribution + self.individual_share self.p1_payoff2 = sum([+56, +self.individual_share, ]) self.p2_payoff2 = sum([+93, +self.individual_share, ]) self.p3_payoff2 = sum([+61, +self.individual_share, ]) self.payoff = Constants.endowment - self.contribution + self.individual_share q1 = models.CharField(choices=['1 - Strongly disagree', '2 - disagree', '3 - slightly disagree', '4 - neither agree nor disagree', '5 - slightly agree', '6 - agree', '7 - Strongly agree' ], widget=widgets.RadioSelect) q2 = models.CharField(choices=['1 - Strongly disagree', '2 - disagree', '3 - slightly disagree', '4 - neither agree nor disagree', '5 - slightly agree', '6 - agree', '7 - Strongly agree' ], widget=widgets.RadioSelect) q3 = models.CharField(choices=['1 - Strongly disagree', '2 - disagree', '3 - slightly disagree', '4 - neither agree nor disagree', '5 - slightly agree', '6 - agree', '7 - Strongly agree' ], widget=widgets.RadioSelect) q4 = models.CharField(choices=['1 - Strongly disagree', '2 - disagree', '3 - slightly disagree', '4 - neither agree nor disagree', '5 - slightly agree', '6 - agree', '7 - Strongly agree' ], widget=widgets.RadioSelect) q5 = models.CharField(choices=['1 - Strongly disagree', '2 - disagree', '3 - slightly disagree', '4 - neither agree nor disagree', '5 - slightly agree', '6 - agree', '7 - Strongly agree' ], widget=widgets.RadioSelect) q6 = models.CharField(choices=['1 - Strongly disagree', '2 - disagree', '3 - slightly disagree', '4 - neither agree nor disagree', '5 - slightly agree', '6 - agree', '7 - Strongly agree' ], widget=widgets.RadioSelect)