from ast import Num from otree.api import * from settings import SESSION_CONFIG_DEFAULTS author= "Nathaniel Lawrence, LEMMA, Université Panthéon-Assas" doc = """ Berlin Numeracy Test From: Cokely, E. T., Galesic, M., Schulz, E., Ghazal, S., & Garcia-Retamero, R. (2012). Measuring risk literacy: The berlin numeracy test. Judgment and Decision Making, 7(1), 25–47. """ ### Define constants here, in all-caps class C(BaseConstants): NAME_IN_URL = 'bnt' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 NUM_QUESTIONS = 9 + 1 CONVERSION_FACTOR = SESSION_CONFIG_DEFAULTS['conversion_factor'] CORRECT_ANSWER_FEE = cu(SESSION_CONFIG_DEFAULTS['correct_answer_fee'] * CONVERSION_FACTOR) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass ### define the questions a player must answer here class Player(BasePlayer): ## Session indices day = models.IntegerField() app_sequence = models.IntegerField() inf_sequence = models.IntegerField() intervention = models.IntegerField() ### Numeracy num_1 = models.IntegerField( label = 'Out of 1,000 people in a small town 500 are members of a choir. Out of these 500 members in the choir 100 are men. Out of the 500 inhabitants that are not in the choir 300 are men. What is the probability that a randomly drawn man is a member of the choir? ________ (%)', min=0 ) num_2a = models.IntegerField( label = 'Imagine we are throwing a five-sided die 50 times. On average, out of these 50 throws how many times would this five-sided die show an odd number (1, 3 or 5)? ______ out of 50 throws.', min=0 ) num_2b = models.IntegerField( label = 'Imagine we are throwing a loaded die (6 sides). The probability that the die shows a 6 is twice as high as the probability of each of the other numbers. On average, out of these 70 throws how many times would the die show the number 6? ________out of 70 throws.', min=0 ) num_3 = models.IntegerField( label = 'In a forest 20% of mushrooms are red, 50% brown and 30% white. A red mushroom is poisonous with a probability of 20%. A mushroom that is not red is poisonous with a probability of 5%. What is the probability that a poisonous mushroom in the forest is red? ________ (%)', min=0 ) ### Numeracy Attitude numatt_1 = models.StringField( choices = [['1','1 - Not confident at all'],['2','2'],['3','3'],['4','4'],['5','5 - Absolutely confident']], label='On a scale of 1 to 5, how confident are you in your mathematical abilities?', widget=widgets.RadioSelect ) numatt_2 = models.StringField( choices = [['1','1 - Not confident at all'],['2','2'],['3','3'],['4','4'],['5','5 - Absolutely confident']], label='On a scale of 1 to 5, how confident are you in your financial decision-making abilities?', widget=widgets.RadioSelect ) numatt_3 = models.StringField( choices = [['1','1 - Not confident at all'],['2','2'],['3','3'],['4','4'],['5','5 - Absolutely confident']], label='On a scale of 1 to 5, how confident are you in your understanding of mathematics? ', widget=widgets.RadioSelect ) numatt_4 = models.StringField( choices = [['1','1 - Not confident at all'],['2','2'],['3','3'],['4','4'],['5','5 - Absolutely confident']], label='On a scale of 1 to 5, how confident are you in your understanding of probability?', widget=widgets.RadioSelect ) numatt_5 = models.StringField( choices = [['1','1 - Not confident at all'],['2','2'],['3','3'],['4','4'],['5','5 - Absolutely confident']], label='On a scale of 1 to 5, how confident are you in your understanding of economics?', widget=widgets.RadioSelect ) # PAGES class BNT_Intro(Page): counter_questions = 0 class BNT_1(Page): form_model = 'player' form_fields = ['num_1'] counter_questions = BNT_Intro.counter_questions + 1 ## For progress bars @staticmethod def vars_for_template(player: Player): return dict( percentage=round(BNT_1.counter_questions / C.NUM_QUESTIONS * 100,) ) class BNT_2a(Page): form_model = 'player' form_fields = ['num_2a'] counter_questions = BNT_1.counter_questions + len(BNT_1.form_fields) ## For progress bars @staticmethod def vars_for_template(player: Player): return dict( percentage=round(BNT_2a.counter_questions / C.NUM_QUESTIONS * 100,) ) @staticmethod def is_displayed(player): return player.num_1 != 25 class BNT_2b(Page): form_model = 'player' form_fields = ['num_2b'] counter_questions = BNT_2a.counter_questions + len(BNT_2a.form_fields) ## For progress bars @staticmethod def vars_for_template(player: Player): return dict( percentage=round(BNT_2b.counter_questions / C.NUM_QUESTIONS * 100,) ) @staticmethod def is_displayed(player): return player.num_1 == 25 class BNT_3(Page): form_model = 'player' form_fields = ['num_3'] counter_questions = BNT_2b.counter_questions + len(BNT_2b.form_fields) ## For progress bars @staticmethod def vars_for_template(player: Player): return dict( percentage=round(BNT_3.counter_questions / C.NUM_QUESTIONS * 100,) ) @staticmethod def is_displayed(player): if player.field_maybe_none('num_2a') is None: if player.num_2b != 20: return True class NumeracyAttitude(Page): form_model = 'player' form_fields = ['numatt_1','numatt_2','numatt_3','numatt_4','numatt_5'] counter_questions = BNT_3.counter_questions + len(BNT_3.form_fields) ## For progress bars @staticmethod def vars_for_template(player: Player): return dict( percentage=round(NumeracyAttitude.counter_questions / C.NUM_QUESTIONS * 100,) ) class Results(Page): counter_questions = NumeracyAttitude.counter_questions + len(NumeracyAttitude.form_fields) ## For progress bars @staticmethod def vars_for_template(player: Player): return dict( percentage=round(Results.counter_questions / C.NUM_QUESTIONS * 100,) ) page_sequence = [ BNT_Intro, BNT_1, BNT_2a, BNT_2b, BNT_3, NumeracyAttitude, Results ]