from otree.api import * # import random # import string # import csv doc = """ Your app description """ # Payoff rule # Idea: We select a random number between 0 and 10. If 0 is picked the first decision is taken and so on. Then, for the taken decision, the binarized scoring rule is applied. # this has to be repeated for the other beliefs as well ... ########################################################################################################### ################################## MODELS ################################ ########################################################################################################### class Constants(BaseConstants): name_in_url = 'risk_and_time_preferences' players_per_group = None num_rounds = 1 QuestionnaireChoices = [ [0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10'], ] QuestionnaireChoices_0 = [ [0, ''], [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], [8, ''], [9, ''], [10, ''], ] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): risk_car = models.IntegerField( label='How willing are you to take risks in car driving?', choices=Constants.QuestionnaireChoices_0, widget=widgets.RadioSelectHorizontal ) risk_finance = models.IntegerField( label='How willing are you to take risk in financial matters?', choices=Constants.QuestionnaireChoices_0, widget=widgets.RadioSelectHorizontal ) risk_sports = models.IntegerField( label='How willing are you to take risks in sports and leisure activities?', choices=Constants.QuestionnaireChoices_0, widget=widgets.RadioSelectHorizontal ) risk_career = models.IntegerField( label='How willing are you to take risks in your career?', choices=Constants.QuestionnaireChoices_0, widget=widgets.RadioSelectHorizontal ) risk_health = models.IntegerField( label='How willing are you to take risks in health matters?', choices=Constants.QuestionnaireChoices_0, widget=widgets.RadioSelectHorizontal ) patience = models.IntegerField( label='', choices=Constants.QuestionnaireChoices, widget=widgets.RadioSelectHorizontal ) time_154 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '154 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, ) time_125 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '125 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_185 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '185 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_112 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '112 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_139 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '139 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_169 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '169 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_202 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '202 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_210 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '210 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_193 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '193 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_177 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '177 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_161 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '161 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_146 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '146 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_132 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '132 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_119 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '119 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_106 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '106 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_103 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '103 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_109 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '109 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_116 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '116 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_129 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '119 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_122 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '122 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_136 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '136 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_143 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '143 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_150 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '150 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_158 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '158 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_165 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '165 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_173 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '173 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_181 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '181 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_189 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '189 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_197 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '197 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_206 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '206 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) time_215 = models.IntegerField( choices=[ [0, '100 Euro today'], [1, '215 Euro in 12 months'], ], widget=widgets.RadioSelectHorizontal, initial=-99, blank=True ) ########################################################################################################### ################################## PAGES ################################ ########################################################################################################### class Risk(Page): form_model = 'player' form_fields = [ 'risk_car', 'risk_finance', 'risk_sports', 'risk_career', 'risk_health', ] class Patience(Page): form_model = 'player' form_fields = [ 'patience', ] class Time_1(Page): form_model = 'player' form_fields = [ 'time_154', ] class Time_2(Page): form_model = 'player' form_fields = [ 'time_125', 'time_185' ] @staticmethod def error_message(player: Player, values): if values['time_125'] == -99 and values['time_185'] == -99: return 'You need to choose one of the options' class Time_3(Page): form_model = 'player' form_fields = [ 'time_112', 'time_139', 'time_202', 'time_169', ] @staticmethod def error_message(player: Player, values): if values['time_112'] == -99 and values['time_139'] == -99 and values['time_202'] == -99 and values['time_169'] == -99: return 'You need to choose one of the options' class Time_4(Page): form_model = 'player' form_fields = [ 'time_106', 'time_119', 'time_132', 'time_146', 'time_161', 'time_177', 'time_193', 'time_210', ] @staticmethod def error_message(player: Player, values): if values['time_106'] == -99 and values['time_119'] == -99 and values['time_132'] == -99 and values['time_146'] == -99 and values['time_161'] == -99 and values['time_177'] == -99 and values['time_193'] == -99 and values['time_210'] == -99: return 'You need to choose one of the options' class Time_5(Page): form_model = 'player' form_fields = [ 'time_103', 'time_109', 'time_116', 'time_129', 'time_122', 'time_136', 'time_143', 'time_150', 'time_158', 'time_165', 'time_173', 'time_181', 'time_189', 'time_197', 'time_206', 'time_215', ] @staticmethod def error_message(player: Player, values): if values['time_103'] == -99 and values['time_109'] == -99 and values['time_116'] == -99 and values['time_129'] == -99 and values['time_122'] == -99 and values['time_136'] == -99 and values['time_143'] == -99 and values['time_150'] == -99 and values['time_158'] == -99 and values['time_165'] == -99 and values['time_173'] == -99 and values['time_181'] == -99 and values['time_189'] == -99 and values['time_197'] == -99 and values['time_206'] == -99 and values['time_215'] == -99: return 'You need to choose one of the options' class Part5(Page): pass class Part4(Page): pass page_sequence = [ Part4, Risk, Part5, Time_1, Time_2, Time_3, Time_4, Time_5, Patience ]