from otree.api import ( models, widgets, BaseConstants, BasePlayer, BaseGroup, BaseSubsession, Currency as c, currency_range, ) import random author = 'Your name here' doc = """ Your app description """ class Group(BaseGroup): pass class Subsession(BaseSubsession): pass class Constants(BaseConstants): name_in_url = 'elecCostControl' players_per_group = None num_rounds = 20 correctAnswers_example = 9 randomSeeds_example = 11111 correctAnswers = [12, 9, 13, 15, 9, 11, 10, 8, 10, 12, 10, 11, 9, 10, 13, 11, 14, 9, 12, 10] randomSeeds = [12345, 12346, 12347, 12348, 12349, 12340, 12355, 12365, 12375, 12385, 12395, 12315, 12445, 12545, 12645, 12745, 12845, 12945, 12045, 13345, 13445, 13545, 13645, 13745, 13845, 13945, 13045, 14345, 15345, 16345] powerCostHigh = 0.4 powerCostLow = 0.1 taskPayment = 15 gridSize = 240 penalty_mistake = 10 class Player(BasePlayer): cost = models.FloatField(initial=0.0) rightAnswers = models.IntegerField(initial=0) elapsed_time_example = models.IntegerField(initial=0, label="") elapsed_time = models.IntegerField(initial=0, label="") elapsed_time_midpoint = models.IntegerField(initial=0, label="") light_activated = models.IntegerField(initial=0, label="") mistakes_made = models.IntegerField(initial=0, label="") mistakes_made_example = models.IntegerField(initial=0, label="") realEffortTask_answer = models.IntegerField(label="") realEffortTask_answer_example = models.IntegerField(label="") efficiencyInvest = models.FloatField(initial=0) payout = models.FloatField(initial=0) start_task = models.FloatField() end_task = models.FloatField() START_time_epoch = models.FloatField() ENDE_time_epoch = models.FloatField() treatment = models.BooleanField() prolificID = models.StringField(label="") def set_initial_num_participants(self): if self.test_existance_of_session_vars() == False: self.session.vars['num_participants_finished'] = 0 def test_existance_of_session_vars(self): check = False if 'num_participants_finished' in self.session.vars: check = True return check investChoice = models.IntegerField( label="", choices=[ [1, 'Yes, I do invest.'], [2, 'No, I do not want to invest.'], ], widget=widgets.RadioSelect, ) screenshots = models.IntegerField( label="Did you use screenshots to solve the tasks? (The answer will not impact your bonus or your compensation!)", choices=[ [1, 'Yes'], [2, 'No'], ], widget=widgets.RadioSelect, ) patience = models.IntegerField( label="I'm willing to forego something that is useful to me today for additional profit in the future.", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) altruism = models.IntegerField( label="I'm willing to give for a good cause without receiving anything in return.", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) risk = models.IntegerField( label="I'm willing to take risks.", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) awareness = models.IntegerField( label="I was able to evaluate precisely how much I had (so far) spent on electricity in every round of the experiment.", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) attention = models.IntegerField( label="Please choose the leftmost option \"Completely disagree\".", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) impulsive = models.IntegerField( label="I generally think things over for a long time before acting.", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) efficiency = models.IntegerField( label="When buying new appliances, energy efficiency is more important to me than the price.", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) savings = models.IntegerField( label="I would like to save more energy.", choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], widget=widgets.RadioSelectHorizontal, ) investKnow = models.StringField( label="Assuming you had GBP 200 in your bank account today that receives 10% interest per year. How much would you have in your bank account after two years?", choices=['GBP 220', 'GBP 240', 'GBP 242','GBP 204', 'Don\'t know'] ) Geschlecht = models.StringField( label="Gender", choices=["Female", "Male", "Diverse", "I don't identify with any of the given options"] ) Alter = models.StringField( label="Age", choices=["Below 18 years", "18-29", "30-39", "40-49", "50-59", "60-69", "70-79", "80 years or older"] ) Hoechste_berufliche_Qualifikation = models.StringField( label="Highest level of qualification", choices=["No qualification", "Professional qualification", "Bachelor's degree", "Master's degree", "Doctorate"] ) Erwerbsstatus = models.StringField( label="Occupation", choices=["Employed", "Self-employed", "Currently unemployed", "Retired", "Student", "Other"] ) Einkommen = models.StringField( label="Average monthly household income", choices=["Below 1000 GBP", "1000-2000 GBP", "2000-3000 GBP", "3000-4000 GBP", "4000-5000 GBP", "Over 5000 GBP", "Don't know/don't want to say"] ) FinalFeedback = models.LongStringField( label="Do you have any final remarks?", initial='', blank=True ) pass