from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import logging logger = logging.getLogger(__name__) from os import environ author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'jar' players_per_group = None num_rounds = 8 # Set 8 here as this is the max, and we can exit early if we want less rounds treatments = ['a', 'b', 'c', 'd'] consent_timeout = int(environ.get('CONSENT_TIMEOUT', 120)) overview_timeout = 60 payoff_calc_timeout = 120 payoff_example1_timeout = 120 payoff_example2_timeout = 90 bonus_timeout = 60 comp_questions_timeout = 600 error_message_timeout = 30 practice_max_attempts = 3 higher_payoff_AP = 4 lower_payoff_AP = 3 example_position = 2 timeout = models.IntegerField( choices=[0, 1] ) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): timeout = models.IntegerField( choices=[0, 1], initial=0 ) my_bret_payoff = models.CurrencyField() def update_paradox_index(self) -> int: last_index = self.participant.vars['paradox_index'] last_index += 1 # Here we wrap back to the start at the end of the number of possible paradox's if last_index == self.get_paradox_size(): last_index = 0 self.participant.vars['paradox_index'] = last_index def get_paradox_size(self): return 4 if (self.participant.vars['treatment'] in ['a', 'b']) else 8 example_attempts = models.IntegerField(initial=1) failed_attention_check = models.IntegerField( choices=[0, 1] ) attention_players = models.IntegerField( label='How many players are in your group?', choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ) attention_position = models.CharField( label='What is your position in the group? ', choices=['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th'], # widget=widgets.RadioSelectHorizontal() ) attention_opportunity = models.CharField( label='When do you have a chance to affect the group decision?', choices=['When previous player(s) choose(s) orange', 'When previous player(s) choose(s) blue'], # widget=widgets.RadioSelectHorizontal() ) attention_othersred = models.CharField( label='If you choose orange and an orange ball was drawn for all other players, how much would other players individually earn?', # 'Imagine that you are selected such that one of your decisions has financial implications. ' choices=['£4', '£3'], # widget=widgets.RadioSelectHorizontal() ) attention_othersblue = models.CharField( label= 'If you choose orange and a blue ball was drawn for all other players, how much would other players individually earn?', # 'Imagine that you are selected such that one of your decisions has financial implications. ' choices=['£4', '£3'], # widget=widgets.RadioSelectHorizontal() ) attention_majorityblue = models.CharField( choices=['0%', '64.8%', '71.0%', '97.2%', '99.7%', '100%'], # widget=widgets.RadioSelectHorizontal() ) attention_scenarios = models.CharField( label='What will change between scenarios?', choices=['the color of the ball drawn for you', 'your position in the decision queue', 'both of the above', 'none of the above'], # widget=widgets.RadioSelectHorizontal() ) chose_orange = models.BooleanField( initial=None, choices=[ [False, 'I choose blue'], [True, 'I choose orange'] ], ) blue_balls = models.IntegerField() size = models.IntegerField() treatment_name = models.StringField() red_balls = models.IntegerField() position = models.CharField() nr_next_players = models.IntegerField()