from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): agree = models.IntegerField( choices=[[1,"I agree to participate in the study"],], label =(""), widget=widgets.RadioSelect ) state = models.IntegerField(choices=[*range(1, 37, 1)], label=("Please select the state/UT you currently live in"), widget=widgets.RadioSelect ) owntoday = models.IntegerField() ownpredicted = models.IntegerField() problosejob = models.IntegerField( choices=[[0, "0 (Not at all likely)"], [1, "1"], [2, "2"] , [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"],[9, "9"], [10,"10 (very likely)"]], label=("How likely is it for the breadwinner in your family to lose his/her job during the next 6 months?"), widget=widgets.RadioSelectHorizontal ) probreduceincome = models.IntegerField( choices=[[0, "0 (Not at all likely)"], [1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10 (very likely)"]], label=("How likely is it for your family income to reduce in the next 6 months?"), widget=widgets.RadioSelectHorizontal ) findnewjob = models.IntegerField( choices=[[1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10"],[11, "11"],[12, "12"],[13, "more than 12 months"]], label=("If you were to lose your job during the next 3 months, in how many months do you expect to find and accept a new job that would be at least as good as your current job, in terms of earnings and benefits?"), widget=widgets.RadioSelectHorizontal ) growth6 = models.IntegerField( choices=[[0, "0 (Not at all confident)"], [1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10 (Absolutely confident)"]], label=("How confident are you that the Indian economy will rise back to 7.5% growth rate in the next 6 months?"), widget=widgets.RadioSelectHorizontal ) growth12 = models.IntegerField( choices=[[0, "0 (Not at all confident)"], [1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10 (Absolutely confident)"]], label=("How confident are you that the Indian economy will rise back to 7.5% growth rate in the next 1 year?"), widget=widgets.RadioSelectHorizontal ) unemployment6 = models.IntegerField( choices=[[0, "0 (Not at all confident)"], [1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10 (very confident)"]], label=("How confident are you that the unemployment rate will fall back to 5.4% in the next 6 months?"), widget=widgets.RadioSelectHorizontal ) unemployment12 = models.IntegerField( choices=[[0, "0 (Not at all confident)"], [1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10 (very confident)"]], label=("How confident are you that the unemployment rate will fall back to 5.4% in the next 1 year?"), widget=widgets.RadioSelectHorizontal ) inflation6 = models.FloatField(label=("What do you think will be the inflation percentage rate in the next 6 months?")) inflation12 = models.FloatField(label=("What do you think will be the inflation percentage rate in the next 1 year?")) stock6 = models.FloatField(label=("What do you think will be the value of the investment in the next 6 months?")) stock12 = models.FloatField(label=("What do you think will be the value of the investment in the next 1 year?")) consumer1 = models.IntegerField( choices=[[1, "Have improved"], [0, "Have remained same"], [-1, "Have worsened"]], label=(""), widget=widgets.RadioSelectHorizontal ) consumer2 = models.IntegerField( choices=[[-1, "Have gone up"], [0, "Have remained almost the same"], [1, "Have gone down"]], label=(""), widget=widgets.RadioSelectHorizontal ) consumer3 = models.IntegerField( choices=[[1, "Have become somewhat better"], [0, "Have remained the same"], [-1, "Have become somewhat worse off"]], label=(""), widget=widgets.RadioSelectHorizontal ) consumer4 = models.IntegerField( choices=[[1, "Have increased"], [0, "Have remained the same"], [-1, "Have decreased"]], label=(""), widget=widgets.RadioSelectHorizontal ) consumer5 = models.IntegerField( choices=[[1, "Have increased"], [0, "Have remained the same"], [-1, "Have decreased"]], label=(""), widget=widgets.RadioSelectHorizontal ) consumer6 = models.IntegerField( choices=[[1, "Will improve"], [0, "Will remain the same"], [-1, "Will worsen"]], label=(""), widget=widgets.RadioSelectHorizontal ) consumer7 = models.IntegerField( choices=[[-1, "Will go up"], [0, "Will remain same"], [1, "Will go down"],], label=(""), widget=widgets.RadioSelectHorizontal ) consumer8 = models.IntegerField( choices=[[1, "Will increase"], [0, "Will remain same"], [-1, "Will decrease"],], label=(""), widget=widgets.RadioSelectHorizontal ) consumer9 = models.IntegerField( choices=[[1, "Increase"], [0, "Neither increase nor decrease"], [-1, "Decrease"],], label=(""), widget=widgets.RadioSelectHorizontal ) consumer10 = models.IntegerField( choices=[[1, "Not particularly worried"], [0, "Slightly worried"], [-1, "Quite worried"],], label=(""), widget=widgets.RadioSelectHorizontal ) day = models.IntegerField(choices=[*range(1, 32, 1)], label=("Day")) month = models.IntegerField(choices=[*range(1, 13, 1)], label=("Month")) year = models.IntegerField(choices=[*range(1930, 2016, 1)], label=("Year")) gender = models.IntegerField( choices=[[1, "Male"], [2, "Female"], [3, "Other"], ], label=("Gender"), widget=widgets.RadioSelectHorizontal ) marital = models.IntegerField( choices=[[1, "Have Partners/Married"], [2, "Single/Divorced"], ], label=("What is your marital status?"), widget=widgets.RadioSelectHorizontal ) religion = models.IntegerField( choices=[[1, "Christian"], [2, "Muslim"], [3, "Hindu"], [4, "Buddhist"], [5, "Others"],], label=("What is your religious identity?"), widget=widgets.RadioSelectHorizontal ) education = models.IntegerField( choices=[[1, "Class X"], [2, "Class XII"], [3, "Bachelor's Degree"], [4, "Master's Degree"], [5, "Higher than Master's Degree"], ], label=("What is the highest educational degree you have attained ?"), widget=widgets.RadioSelectHorizontal ) income = models.IntegerField( choices=[[1, "Less than Rs.10,000"], [2, "Rs.10,000-Rs.20,000"], [3, "Rs.20,001-Rs.30,000"], [4, "Rs.30,001-Rs.40,000"], [5, "Rs.40,001-Rs.50,000"],[6, "Rs.50,001-Rs.60,000"],[7, "Rs.60,001-Rs.70,000"],[8, "Rs.70,001-Rs.80,000"], [9, "Rs.80,001-Rs.90,000"],[10, "Rs.90,001-Rs.1,00,000"],[11, "More than 1 lakh"],], label=("Monthly family income before tax (in rupees)"), widget = widgets.RadioSelectHorizontal ) health = models.IntegerField( choices=[[1,"1 (Very poor health) "] ,[2,"2"], [3,"3"],[4,"4"],[5,"5 (Very good health)"],], label=("On a scale of 1 to 5, how healthy do you think you are?"), widget=widgets.RadioSelectHorizontal ) caste = models.IntegerField( choices=[[1, "General(G)"], [2, "Scheduled Caste(SC)"], [3, "Scheduled Tribe(ST)"], [4, "Other Backward Class(OBC)"],], label=("Caste Category"), widget=widgets.RadioSelectHorizontal ) distancezone = models.IntegerField( choices=[[0, "My locality is a containment zone"], [1, "Less than 15 minutes’ walking distance"], [2, "15-30 minutes’ walking distance"], [3,"More than 30 minutes' walking distance"],], label=("How far is your locality from a Covid-19 containment zone?"), widget=widgets.RadioSelectHorizontal ) risk=models.IntegerField( choices=[[0, "0 (Not at all willing to take risk)"], [1, "1"], [2, "2"] , [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"],[9, "9"], [10,"10 (Very willing to take risk)"]], label=("How do you see yourself: are you generally a person who is fully prepared to take risks or do you try to avoid taking risks?"), widget=widgets.RadioSelectHorizontal ) inapp_socialgather = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) inapp_work = models.IntegerField( choices=[1,2, 3,4,5], widget=widgets.RadioSelect ) inapp_grocery = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) inapp_violation = models.IntegerField( choices=[1,2, 3,4,5], widget=widgets.RadioSelect ) Cgovtrue = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) Ceffort = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) Cgovtbetter = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) Sgovtrue = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) Seffort = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) Sgovtbetter = models.IntegerField( choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect ) investcorona = models.IntegerField( choices=[[1,"The stock market price increases"] ,[2,"The stock market price remains unchanged"],[3,"The stock market price decreases"]], label=(""), widget=widgets.RadioSelect ) def set_treatment(self): self.treatment = 6 self.actual1 = 338 self.actual2 = 1312 self.actual3 = 4661 self.actual4 = 26747 self.actual5 = 85991 self.actual6 = 189618 self.actual7 = 337635 self.actual8 = 501560 def set_payment(self): k = random.choice([5,8]) self.choice= k if k==4: self.ub1 = int(1.05 * self.actual4) self.lb1 = int(0.95 * self.actual4) if (self.guess4 < self.lb1) : self.taskpay = c(0) elif (self.guess4 > self.ub1): self.taskpay = c(0) else: self.taskpay =c(0.25) self.investpay = c(1.09*self.invest4) + c(50)- c(self.invest4) self.payoff = (self.investpay/100) if k==5: self.ub1 = int(1.05 * self.actual5) self.lb1 = int(0.95 * self.actual5) if (self.guess5 < self.lb1): self.taskpay = c(0) elif (self.guess5 > self.ub1): self.taskpay = c(0) else: self.taskpay = c(0.25) self.investpay = c(0.75*self.invest5) + c(50)-c(self.invest5) self.payoff = (self.investpay/100) if k==6: self.ub1 = int(1.05 * self.actual6) self.lb1 = int(0.95 * self.actual6) if (self.guess6 < self.lb1): self.taskpay = c(0) elif (self.guess6 > self.ub1): self.taskpay = c(0) else: self.taskpay = c(0.25) self.investpay = c(1.07*self.invest6) + c(50)- c(self.invest6) self.payoff = (self.investpay/100) if k==7: self.ub1 = int(1.05 * self.actual7) self.lb1 = int(0.95 * self.actual7) if (self.guess7 < self.lb1): self.taskpay = c(0) elif (self.guess7 > self.ub1): self.taskpay = c(0) else: self.taskpay = c(0.25) self.investpay = c(1.03*self.invest7) + c(50)- c(self.invest7) self.payoff = (self.investpay/100) if k==8: self.ub1 = int(1.05 * self.actual8) self.lb1 = int(0.95 * self.actual8) if (self.guess8 < self.lb1): self.taskpay = c(0) elif (self.guess8 > self.ub1): self.taskpay = c(0) else: self.taskpay = c(0.25) self.payoff = 0 self.completion_code = "GingerGarlic" self.totalpay = self.payoff+0.55 completion_code = models.StringField() taskpay = models.CurrencyField() investpay = models.CurrencyField() totalpay = models.CurrencyField() ub1 = models.IntegerField() lb1 = models.IntegerField() treatment = models.IntegerField() guess4 = models.IntegerField() def guess4_error_message(self, value): if value > 50000: return 'Actual number of total cases recorded up to Day 15 in Country W is less than 50,000. You will not be able to proceed without correcting your answer.' if value < self.actual3: return 'Actual number of total cases recorded up to Day 15 has to be more than total cases recorded up to Day 10 (that is, 4661). You will not be able to proceed without correcting your answer.' invest4 = models.IntegerField(min=0, max=50, label=("Cents")) guess5 = models.IntegerField() def guess5_error_message(self, value): if value > 170000: return 'Actual number of total cases recorded up to Day 20 in Country W is less than 170000. You will not be able to proceed without correcting your answer.' if value < self.guess4 : if self.treatment ==6: return 'Your prediction of the number of total cases recorded up to Day 20 has to be more than your prediction of cases recorded up to Day 15. You will not be able to proceed without correcting your answer.' invest5 = models.IntegerField(min=0, max=50,label=("Cents")) guess6 = models.IntegerField() def guess6_error_message(self, value): if value < self.guess5 : if self.treatment==6: return 'Your prediction of the number of total cases recorded up to Day 25 has to be more than your prediction of cases recorded up to Day 20. You will not be able to proceed without correcting your answer.' invest6 = models.IntegerField(min=0, max=50,label=("Cents")) guess7 = models.IntegerField() def guess7_error_message(self, value): if value < self.guess6: if self.treatment==6: return 'Your prediction of the number of total cases recorded up to Day 30 has to be more than your prediction of cases recorded up to Day 25. You will not be able to proceed without correcting your answer.' invest7 = models.IntegerField(min=0, max=50,label=("Cents")) guess8 = models.IntegerField() def guess8_error_message(self, value): if self.treatment==6: if value < self.guess7: return 'Your prediction of the number of total cases recorded up to Day 35 has to be more than your prediction of cases recorded up to Day 30. You will not be able to proceed without correcting your answer.' actual1 = models.IntegerField() actual2 = models.IntegerField() actual3 = models.IntegerField() actual4 = models.IntegerField() actual5 = models.IntegerField() actual6 = models.IntegerField() actual7 = models.IntegerField() actual8 = models.IntegerField() choice = models.IntegerField()