from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'challenge' players_per_group = None num_rounds = 1 participation_fee = c(4) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): sl1 =models.IntegerField() sl2 = models.IntegerField() Comprehension1= models.BooleanField( choices=[False,True], label="Your Payoff will be determined using 1 of the 4 following choice tasks randomly drawn.", ) Comprehension2 = models.BooleanField( choices=[False,True], label="If you choose the lottery you will get the expected payoff." ) def set_cq(self): if self.Comprehension1 == True: cq = 0 elif self.Comprehension12 == True: cq = 0 else: cq = 1 return cq BC1 = models.IntegerField( choices=[ [1, 'Certain'], [2, 'Lottery'] ], widget=widgets.RadioSelectHorizontal, label= "", ) BC2 = models.IntegerField( choices=[ [1, 'Certain'], [2, 'Lottery'] ], widget = widgets.RadioSelectHorizontal, label = "", ) BC3 = models.IntegerField( choices=[ [1, 'Certain'], [2, 'Lottery'] ], widget = widgets.RadioSelectHorizontal, label = "", ) #PriceList PL1 = models.IntegerField( choices=[1,2], widget=widgets.RadioSelectHorizontal, label = "With Certainty get 0$." ) PL2 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 1$." ) PL3 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 2$." ) PL4 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 3$." ) PL5 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 4$." ) PL6 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 5$." ) PL7 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 6$." ) PL8 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 7$." ) PL9 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 8$." ) PL10 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 9$." ) PL11 = models.IntegerField( choices=[1, 2], widget=widgets.RadioSelectHorizontal, label="With Certainty get 10$." ) def set_payoff(self): import random sl1 = random.choice([1, 2, 3, 4]) sl2 = random.choice([1, 2, 3, 4]) if sl1[0] == 1: if self.player.BC1 == 1: self.player.payoff = 4 + 5 elif self.player.BC1 == 2: sl3 = random.choice([0, 10]) self.player.payoff = 4 + sl3[0] elif sl1[0] == 2: if self.player.BC2 == 1: self.player.payoff = 4 + 5 elif self.player.BC2 == 2: sl3 = random.choice([0, 10], [0.25, 0.75]) self.player.payoff = 4 + sl3[0] elif sl1[0] == 3: if self.player.BC3 == 1: self.player.payoff = 4 + 5 elif self.BC3 == 2: sl3 = random.choice([0, 10], [0.75, 0.25]) self.player.payoff = 4 + sl3[0] elif sl1[0] == 4: if sl2[0] == 1: if self.player.PL1 == 2: self.player.payoff = 4 + 0 elif self.PL1 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 2: if self.player.PL2 == 2: self.player.payoff = 4 + 1 elif self.PL2 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 3: if self.player.PL3 == 2: self.player.payoff = 4 + 2 elif self.player.PL3 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 4: if self.player.PL4 == 2: self.player.payoff = 4 + 3 elif self.player.PL4 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 5: if self.player.PL5 == 2: self.player.payoff = 4 + 4 elif self.player.PL5 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 6: if self.player.PL6 == 2: self.player.payoff = 4 + 5 elif self.player.PL6 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 7: if self.player.PL7 == 2: self.player.payoff = 4 + 6 elif self.player.PL7 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 8: if self.player.PL8 == 2: self.player.payoff = 4 + 7 elif self.player.PL8 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 9: if self.player.PL9 == 2: self.player.payoff = 4 + 8 elif self.player.PL9 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 10: if self.player.PL10 == 2: self.player.payoff = 4 + 9 elif self.player.PL10 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0] elif sl2[0] == 11: if self.player.PL11 == 2: self.player.payoff = 4 + 10 elif self.player.PL11 == 1: sl3 = random.choice([5, 10], [0.3, 0.7]) self.player.payoff = 4 + sl3[0]