from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, Currency) import random class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None num_rounds = 1 endowment_list = [0, c(-80), c(-60), c(-40), c(-20), c(0), c(20), c(40), c(60), c(80)] class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.initial = Constants.endowment_list[p.id_in_group] class Group(BaseGroup): def set_payoffs(self): for p in self.get_players(): p.payoff = (P.Q1_correct, + P.Q2_correct + P.Q3_correct + P.Q4_correct + P.Q5_correct + P.Q6_correct + P.Q7_correct + P.Q8_correct + P.Q9_correct + P.Q10_correct)*15 class Player(BasePlayer): initial = models.CurrencyField( ) Q1_correct = models.BooleanField( initial = False ) Q2_correct = models.BooleanField( initial=False ) Q3_correct = models.BooleanField( initial=False ) Q4_correct = models.BooleanField( initial=False ) Q5_correct = models.BooleanField( initial=False ) Q6_correct = models.BooleanField( initial=False ) Q7_correct = models.BooleanField( initial=False ) Q8_correct = models.BooleanField( initial=False ) Q9_correct = models.BooleanField( initial=False ) Q10_correct = models.BooleanField( initial=False ) age = models.IntegerField( label='What is your age?', min=1, max=125) gender = models.StringField( choices=['Male', 'Female', 'Other'], label='What is your gender?', widget=widgets.RadioSelect) Practice_Round = models.IntegerField( label = ''' Enter your answer in the box below''' ) Q1 = models.IntegerField( label = ''' Enter your answer in the box below ''' ) Q2 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q3 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q4 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q5 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q6 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q7 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q8 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q9 = models.IntegerField( label=''' Enter your answer in the box below ''' ) Q10 = models.IntegerField( label=''' Enter your answer in the box below ''' ) # crt_bat = models.IntegerField( # label=''' # A bat and a ball cost 22 dollars in total. # The bat costs 20 dollars more than the ball. # How many dollars does the ball cost?''' # ) # # crt_widget = models.IntegerField( # label=''' # "If it takes 5 machines 5 minutes to make 5 widgets, # how many minutes would it take 100 machines to make 100 widgets?" # ''' # ) # # crt_lake = models.IntegerField( # label=''' # In a lake, there is a patch of lily pads. # Every day, the patch doubles in size. # If it takes 48 days for the patch to cover the entire lake, # how many days would it take for the patch to cover half of the lake? # ''' # )