from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'questions' players_per_group = None questions = { 'q1': { 'text': 'Rob and Kerry each roll a die. ' 'Determine the probability that they both roll an even number.', 'choices': ['1/6', '1/4', '1/2', '3/4'], 'solution': '1/4', 'table': 'no' }, 'q2': { 'text': 'Of the students in a class playing musical instruments, 60% are female. ' '20% of the females and 30% of the males play the violin. ' 'Find the probability that a student plays the violin.', 'choices': ['20%', '24%', '25%', '30%'], 'solution': '24%', 'table': 'no' }, 'q3': { 'text': 'Machine A makes 40% of the bottles produced at a factory. ' 'Machine B makes the rest. Machine A spoils 10% of its products, while Machine B spoils only 5%. ' 'Find the probability that the next bottle inspected at this factory is spoiled.', 'choices': ['5%', '7%', '7.5%', '10%'], 'solution': '7%', 'table': 'no' }, 'q4': { 'text': 'A sweater was originally priced at $80, but the brand was not selling well and the manager ' 'discounted it by 30%. ' 'During a store-wide sale, a further 10% discount was applied to all items. ' 'Calculate the cost of the sweater during the sale.', 'choices': ['$48', '$50.4', '$56', '$72'], 'solution': '$50.4', 'table': 'no' }, 'q5': { 'text': 'A gardener charges a $60 call-out fee and then $30 for each our he spends on the job. ' 'How long did he work on the job if the total bill is $180?', 'choices': ['3 hours', '4 hours', '4.5 hours', '6 hours'], 'solution': '4 hours', 'table': 'no' }, 'q6': { 'text': 'Douglas invests $2,000 for two years at 10% yearly interest rate. ' 'At the end of the first year, the interest will be also in invested. ' 'How much money Douglas will have at the end of the second year?', 'choices': ['$2,020', '$2,200', '$2,400', '$2,420'], 'solution': '$2,420', 'table': 'no' }, 'q7': { 'text': 'Carol and Toby invested the same amount in a 3-year investment account. ' 'Carol’s account pays 7% interest rate in the first year and 5% for the rest. ' 'Toby’s account pays 7% interest rate for the last year and 5% for the rest. ' 'Which account pays more at the end of the third year?', 'choices': ["Carol's account", "Toby's account", 'The two account will pay the same amount', 'The answer depends on the amount invested'], 'solution': 'The two account will pay the same amount', 'table': 'no' }, # 'q8': { # 'text': 'Thomas runs a sport store with 300 m2. ' # 'He is looking to expand his business and wants to lease a premises with approximately ' # 'twice the area of his current shop. ' # 'He would also like the store to be within 5 km of the city’s Main Square. ' # 'Examine the advertisements below and find which one is would be most appropriate for Thomas.', # 'choices': ['A', # 'B', # 'C', # 'D'], # 'solution': 'B', # 'table': 'yes' # }, 'q8': { 'text': 'Thomas receives an end-of-the-year bonus of $4,500. ' 'He wants to save it, however, he is planning to buy a new car soon and ' 'he might need this amount for the purchase. ' 'Examine the funds below and find which one would be most appropriate for Thomas.', 'choices': ['A', 'B', 'C', 'D'], 'solution': 'B', 'table': 'yes' }, 'q9': { 'text': 'Suppose you had $100 in a savings account and the interest rate was 2% per year. ' 'After 5 years, how much do you think you would have in the account if you left the money to grow?', 'choices': ['More than $102', 'Exactly $102', 'Less than $102'], 'solution': 'More than $102', 'table': 'no' }, 'q10': { 'text': 'Imagine that the interest rate on your savings account was 1% per year ' 'and inflation was 2% per year. ' 'After 1 year, how much would you be able to buy with the money in this account?', 'choices': ['More than today', 'Exactly the same', 'Less than today'], 'solution': 'Less than today', 'table': 'no' }, 'q11': { 'text': 'Is this statement is true or false? ' '"Buying a single company’s stock usually provides a safer return than a stock mutual fund."', 'choices': ['True', 'False'], 'solution': 'False', 'table': 'no' }, } num_rounds = len(questions.keys()) class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): rounds = list(Constants.questions.keys()) random.shuffle(rounds) p.participant.vars['rounds_order'] = dict() i = 1 for r in rounds: p.participant.vars['rounds_order'][i] = r i += 1 class Group(BaseGroup): pass class Player(BasePlayer): question = models.StringField() answer = models.StringField( widget=widgets.RadioSelect ) confidence = models.IntegerField( min=0, max=100 ) solution = models.StringField() answer_correct = models.BooleanField() confidence_2 = models.IntegerField(min=0, max=100) confidence_4 = models.IntegerField(min=0, max=100) confidence_6 = models.IntegerField(min=0, max=100) confidence_8 = models.IntegerField(min=0, max=100)