from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'end' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField( label="What is your age?", ) gender = models.StringField( label="What is your gender?", choices=[('m', 'Male'), ('f', 'Female'), ('oth', 'Prefer not to say')], widget=widgets.RadioSelect ) education = models.StringField( label="What is your education field?", choices=[('fs', 'Formal sciences'), ('sse', 'Social sciences: business, economics, finance'), ('ssp', 'Social sciences: psychology, sociology'), ('sso', 'Social sciences: other'), ('ns','Natural sciences'), ('os', 'Other')], widget=widgets.RadioSelect ) q1 = 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? Please indicate the probability in percent.", ) q2a = 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)?", ) q2b = 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?", ) q3 = 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?", ) # PAGES class PEQ(Page): form_model = 'player' form_fields = ['age', 'gender', 'education'] class Berlin(Page): form_model = 'player' form_fields = ['q1'] class Berlin2a(Page): form_model = 'player' form_fields = ['q2a'] @staticmethod def is_displayed(player: Player): if player.q1 != 25: return True else: return False class Berlin2b(Page): form_model = 'player' form_fields = ['q2b'] @staticmethod def is_displayed(player: Player): if player.q1 == 25: return True else: return False class Berlin3(Page): form_model = 'player' form_fields = ['q3'] @staticmethod def is_displayed(player: Player): if player.q1 == 25: if player.q2b != 20: return True else: return False else: return False class BerlinFeedback(Page): @staticmethod def vars_for_template(player: Player): if player.q1 != 25: ret_dict = dict(q1 = "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? Please indicate the probability in percent.", q1_ans = player.q1, q1_corr = 25, q2 = "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)?", q2_ans = player.q2a, q2_corr = 30) else: if player.q2b == 20: ret_dict = dict(q1 = "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? Please indicate the probability in percent.", q1_ans = player.q1, q1_corr = 25, q2 = "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?", q2_ans = player.q2b, q2_corr = 20) else: ret_dict = dict(q1 = "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? Please indicate the probability in percent.", q1_ans = player.q1, q1_corr = 25, q2 = "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?", q2_ans = player.q2b, q2_corr = 20, q3 = "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?", q3_ans = player.q3, q3_corr = 50) return ret_dict class End(Page): pass page_sequence = [PEQ, Berlin, Berlin2a, Berlin2b, Berlin3, BerlinFeedback, End]