from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import logging logger = logging.getLogger(__name__) author = 'Your name here' doc = """ Your app description """ # from otree.api import * # import random # import logging import csv from os import environ # from common.consts import variance_values # # logging.config.fileConfig('logging.conf') # logger = logging.getLogger('consentApp') class Constants(BaseConstants): name_in_url = 'consent' players_per_group = None num_rounds = 1 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 = 300 error_message_timeout = 30 practice_max_attempts = 2 attention_ans = [4, '2nd', 'When the first player chooses blue', '£Y', '£y', '65%'] class Subsession(BaseSubsession): variance_order = models.StringField() def creating_session(self): if 'variance_order' not in self.session.vars: # Randomise the bonus variance values for this session ordering = random.sample(range(0, 4), k=4) self.session.vars['variance_order'] = ordering # Stamp this so the experimenter can see it # variance_ordering = f'{variance_values[ordering[0]]},{variance_values[ordering[1]]},{variance_values[ordering[2]]},{variance_values[ordering[3]]}' # logger.info(f'Creating variance ordering: {variance_ordering}') # self.variance_order = variance_ordering class Group(BaseGroup): pass class Player(BasePlayer): consent = models.BooleanField(widget=widgets.CheckboxInput, default=False, initial=False) 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 outcome?', choices=['When the first player chooses red', 'When the first player chooses blue'], # widget=widgets.RadioSelectHorizontal() ) attention_othersred = models.CharField( label='If you choose red and all other players were drawn a red ball, how much would other players individually earn?', choices=['£y', '£Y'], # widget=widgets.RadioSelectHorizontal() ) attention_othersblue = models.CharField( label='If you choose red and all other players were drawn a blue ball, how much would other players individually earn?', choices=['£y', '£Y'], # widget=widgets.RadioSelectHorizontal() ) attention_majorityblue = models.CharField( label='What is the probability that half or more players get a lower payoff from outcome RED?', choices=['6%', '94%', '65%', '22%'], # widget=widgets.RadioSelectHorizontal() ) # def vars_for_template(self): # if self.participant.vars['treatment'] in ['a']: # self.participant.vars['treatment_name']="Likely_Small" # self.participant.vars['size']=4 # self.participant.vars['prior']=6 # if self.participant.vars['treatment'] in ['b']: # self.participant.vars['treatment_name']="VeryLikely_Small" # self.participant.vars['size']=4 # self.participant.vars['prior']=9 # if self.participant.vars['treatment'] in ['c']: # self.participant.vars['treatment_name']="Likely_Big" # self.participant.vars['size']=8 # self.participant.vars['prior']=6 # if self.participant.vars['treatment'] in ['d']: # self.participant.vars['treatment_name']="VeryLikely_Big" # self.participant.vars['size']=8 # self.participant.vars['prior']=9 # self.participant.vars['red_balls']=10-self.participant.vars['prior'] # self.participant.vars['nr_players_next']= # # # # prior = models.IntegerField() # size = models.IntegerField() # treatment_name = models.StringField() # red_balls = models.IntegerField() # nr_players_next = models.IntegerField() # position=models.IntegerField()