from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Mounir and Maren' doc = """ This app is for the lottery part of the experiment and the berlin-numercy test, which is placed between two lotteries. The app contains a single lottery, double lottery, consistency check, and combined lottery. """ class Constants(BaseConstants): name_in_url = 'lot' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Here is the formfield for the single lottery s_lottery = models.StringField( label="Choose between", widget=widgets.RadioSelect, choices=[["1", "A) A sure profit of 19.000 "], ['2', "B) A 20 percent chance to gain 100.000, and 80 percent chance to gain nothing"]] ) # Here are the two formfield that together make up the double lottery d_lottery1 = models.StringField( label="Decision (1): Choose between", widget=widgets.RadioSelect, choices=[["1", "A) A candidate with a sure profit of 24.000 generated"], ["2", "B) A candidate with a 25 percent chance to generate a profit of 100.000, and 75 percent chance to generate nothing"]] ) d_lottery2 = models.StringField( label="Decision (2): Choose between", widget=widgets.RadioSelect, choices=[["3", "C) A candidate with a sure loss of 75.000 generated"], ["4", "D) A candidate with a 75 percent chance to cause a loss of 100.000, and 25 percent chance to lose nothing"]] ) # Here are the two formfields for the consistency-check lottery cons_lottery1 = models.StringField( label="Decision (1): Choose between", widget=widgets.RadioSelect, choices=[["1", "A) A candidate with a sure profit of 19.000 generated"], ["2", "B) A candidate with a 20 percent chance to generate a profit of 100.000, and 80 percent chance to generate nothing"]] ) cons_lottery2 = models.StringField( label="Decision (2): Choose between", widget=widgets.RadioSelect, choices=[["3", "C) A candidate with a sure loss of 80.000 generated"], ["4", "D) A candidate with a 80 percent chance to cause a loss of 100.000, and 20 percent chance to lose nothing"]] ) # Here is the formfield for the combined presentation of the double lottery comb_lottery = models.StringField( label="Choose between", widget=widgets.RadioSelect, choices=[["1", "A) A candidate with a 25 percent chance of generating a profit of 24.000 and a 75 percent chance of generating losses of 76.000"], ["2", "B) A candidate with a 25 percent chance of generating a profit of 25.000 and a 75 percent chance of losing 75.000"]] ) # Here are the formfields that save the perceived complexity for each lottery task complex_single = models.IntegerField( label="I would rate the complexity/difficulty of this task as (0% simple – 100% difficult). Type your answer without the percentage sign:", min=0, max=100 ) complex_double = models.IntegerField( label="I would rate the complexity/difficulty of this task as (0% simple – 100% difficult). Type your answer without the percentage sign:", min=0, max=100 ) complex_consistency = models.IntegerField( label="I would rate the complexity/difficulty of this task as (0% simple – 100% difficult). Type your answer without the percentage sign:", min=0, max=100 ) complex_combined = models.IntegerField( label="I would rate the complexity/difficulty of this task as (0% simple – 100% difficult). Type your answer without the percentage sign:", min=0, max=100 ) # Here are the formfields for the four questions of the berlin-numeracy test berlin_choire = models.FloatField( 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)." ) berlin_die = models.FloatField( 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)?" ) berlin_loadedDie = models.FloatField( 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?" ) berlin_mushrooms = models.FloatField( 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?" ) # Here are the variables that show if the respective question was answered correctly berlin_choire_correct = models.BooleanField(initial = None) berlin_die_correct = models.BooleanField(initial = None) berlin_loadedDie_correct = models.BooleanField(initial = None) berlin_mushrooms_correct = models.BooleanField(initial = None) # This is the variable that will give a player's overall score in the berlin-numeracy test berlin_score = models.PositiveIntegerField() # Here we set the correct answers for each question def set_is_berlin_choire_correct(self): self.berlin_choire_correct = self.berlin_choire == 25 def set_is_berlin_die_correct(self): self.berlin_die_correct = self.berlin_die == 30 def set_is_berlin_loadedDie_correct(self): self.berlin_loadedDie_correct = self.berlin_loadedDie == 20 def set_is_berlin_mushrooms_correct(self): self.berlin_mushrooms_correct = self.berlin_mushrooms == 50 def set_berlin_score(self): self.berlin_score = getattr(self, 'berlin_choire_correct') + getattr(self, 'berlin_die_correct') + getattr(self, 'berlin_loadedDie_correct') + getattr(self, 'berlin_mushrooms_correct')