from otree.api import * import random doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'social_learning_nogender' PLAYERS_PER_GROUP = 5 NUM_ROUNDS = 80 quiz_correct = 1 quiz_bonus = 1 guess_correct = 5 belief_payment = 2 participant_fee = 8 male_link = [['https://i.imgur.com/cKIK5BW.png', 'Adam'], ['https://i.imgur.com/ANNCedm.png', 'Ben'], ['https://i.imgur.com/RpiKCuq.png', 'Charles'], ['https://i.imgur.com/Yf17Sdv.png', 'Daniel'], ['https://i.imgur.com/wKTO2pm.png', 'Edward'], ['https://i.imgur.com/mABiM5L.png', 'George'], ['https://i.imgur.com/BL7Vp8G.png', 'Henry'], ['https://i.imgur.com/emkx6dl.png', 'John'], ['https://i.imgur.com/iWfKsiq.png', 'Martin'], ['https://i.imgur.com/8nIOJfG.png', 'Tom'] ] female_link = [['https://i.imgur.com/mcnlsDa.png', 'Anne'], ['https://i.imgur.com/hQTTOPT.png', 'Barbara'], ['https://i.imgur.com/0eHjDYg.png', 'Caroline'], ['https://i.imgur.com/yjk25hp.png', 'Diana'], ['https://i.imgur.com/9571b0a.png', 'Emily'], ['https://i.imgur.com/oiFiWsE.png', 'Gabrielle'], ['https://i.imgur.com/uBZFySm.png', 'Hannah'], ['https://i.imgur.com/c6aK2zc.png', 'Jacqueline'], ['https://i.imgur.com/spsAHl1.png', 'Mary'], ['https://i.imgur.com/A3CwzJg.png', 'Tracy'] ] q1 = 'Which Dickens character asked for more?' q2 = 'What city provides the setting for The Phantom of the Opera?' q3 = 'What tennis player was listed as the world’s highest‐earning female athlete at the start of 2006?' q4 = 'What Jack Nicholson movie was hyped: “Brace yourself for Melvin”?' q5 = 'What decade provides the setting for the 2005 movie King Kong?' q6 = 'What was The Police’s best-selling single?' q7 = 'Which of the following actions would be the most effective in decreasing acid rain and acid deposition problems?' q8 = 'In general, which of the following is the best long‐term method of preventing Extinctions?' q9 = 'The ultimate source of energy for terrestrial ecosystems is' q10 = 'All of the following are true of the movement to prohibit alcoholic beverages in the United States EXCEPT:' q11 = 'What’s the Shakespeare play if “All the world’s a stage”?' q12 = 'What war do the girls in Little Women grow up during?' q13 = 'The encomienda system in the Spanish Empire in the Americas most closely resembled the European practice of' q14 = 'Who steers the shell and motivates the rowers in a crew race?' q15 = 'What kind of animals starred in the movie Happy Feet?' q16 = 'Of the following, which is the most serious immediate problem associated with sanitary landfills?' c1 = 'Oliver Twist' c2 = 'Paris' c3 = 'Maria Sharapova' c4 = 'As Good As It Gets' c5 = '1930s' c6 = 'Every Breath You Take' c7 = 'Reducing use of fossil fuels' c8 = 'Protecting the habitats of endangered species' c9 = 'the Sun' c10 = 'It arose quite suddenly amid the hysteria surrounding the First World War.' c11 = 'As You Like It' c12 = 'Civil War' c13 = 'manorialism' c14 = 'Coxswain' c15 = 'Penguins' c16 = 'Leachate contamination of groundwater' n = 'None of the above' class Subsession(BaseSubsession): random1 = models.IntegerField() random2 = models.IntegerField() random3 = models.IntegerField() random4 = models.IntegerField() random5 = models.IntegerField() random6 = models.IntegerField() random7 = models.IntegerField() random8 = models.IntegerField() random9 = models.IntegerField() random10 = models.IntegerField() random11 = models.IntegerField() random12 = models.IntegerField() random13 = models.IntegerField() random14 = models.IntegerField() random15 = models.IntegerField() random16 = models.IntegerField() class Group(BaseGroup): pass class Player(BasePlayer): question1 = models.StringField( widget=widgets.RadioSelect, label=C.q1 ) question2 = models.StringField( widget=widgets.RadioSelect, label=C.q2 ) question3 = models.StringField( widget=widgets.RadioSelect, label=C.q3 ) question4 = models.StringField( widget=widgets.RadioSelect, label=C.q4 ) question5 = models.StringField( widget=widgets.RadioSelect, label=C.q5 ) question6 = models.StringField( widget=widgets.RadioSelect, label=C.q6 ) question7 = models.StringField( widget=widgets.RadioSelect, label=C.q7 ) question8 = models.StringField( widget=widgets.RadioSelect, label=C.q8 ) question9 = models.StringField( widget=widgets.RadioSelect, label=C.q9 ) question10 = models.StringField( widget=widgets.RadioSelect, label=C.q10 ) question11 = models.StringField( widget=widgets.RadioSelect, label=C.q11 ) question12 = models.StringField( widget=widgets.RadioSelect, label=C.q12 ) question13 = models.StringField( widget=widgets.RadioSelect, label=C.q13 ) question14 = models.StringField( widget=widgets.RadioSelect, label=C.q14 ) question15 = models.StringField( widget=widgets.RadioSelect, label=C.q15 ) question16 = models.StringField( widget=widgets.RadioSelect, label=C.q16 ) state1 = models.IntegerField() state2 = models.IntegerField() state3 = models.IntegerField() state4 = models.IntegerField() state5 = models.IntegerField() state6 = models.IntegerField() state7 = models.IntegerField() state8 = models.IntegerField() state9 = models.IntegerField() state10 = models.IntegerField() state11 = models.IntegerField() state12 = models.IntegerField() state13 = models.IntegerField() state14 = models.IntegerField() state15 = models.IntegerField() state16 = models.IntegerField() state_trivia = models.IntegerField() correct1 = models.IntegerField() correct2 = models.IntegerField() correct3 = models.IntegerField() correct4 = models.IntegerField() correct5 = models.IntegerField() correct6 = models.IntegerField() correct7 = models.IntegerField() correct8 = models.IntegerField() correct9 = models.IntegerField() correct10 = models.IntegerField() correct11 = models.IntegerField() correct12 = models.IntegerField() correct13 = models.IntegerField() correct14 = models.IntegerField() correct15 = models.IntegerField() correct16 = models.IntegerField() correct = models.IntegerField() initial_e = models.IntegerField( choices=[0, 1, 2, 3, 4] ) answer_e = models.IntegerField( choices=[0, 1, 2, 3, 4] ) correct_e = models.FloatField(min=0, max=100) neighbor1 = models.IntegerField() neighbor2 = models.IntegerField() neighbor1_belief = models.IntegerField() neighbor2_belief = models.IntegerField() previous_belief = models.IntegerField() neighbor1_correct = models.FloatField(min=0, max=100) neighbor2_correct = models.FloatField(min=0, max=100) guess_payoff = models.FloatField() quiz_payoff = models.FloatField() belief_payoff = models.FloatField() # functions def set_random(subsession: Subsession): if subsession.round_number == 1: subsession.random1 = random.randint(0, 4) subsession.random2 = random.randint(0, 4) subsession.random3 = random.randint(0, 4) subsession.random4 = random.randint(0, 4) elif subsession.round_number == 21: subsession.random5 = random.randint(0, 4) subsession.random6 = random.randint(0, 4) subsession.random7 = random.randint(0, 4) subsession.random8 = random.randint(0, 4) elif subsession.round_number == 41: subsession.random9 = random.randint(0, 4) subsession.random10 = random.randint(0, 4) subsession.random11 = random.randint(0, 4) subsession.random12 = random.randint(0, 4) elif subsession.round_number == 61: subsession.random13 = random.randint(0, 4) subsession.random14 = random.randint(0, 4) subsession.random15 = random.randint(0, 4) subsession.random16 = random.randint(0, 4) def set_state(subsession: Subsession): for p in subsession.get_players(): if 1 < p.id_in_group < C.PLAYERS_PER_GROUP: p.neighbor1 = p.id_in_group - 1 p.neighbor2 = p.id_in_group + 1 elif p.id_in_group == 1: p.neighbor1 = C.PLAYERS_PER_GROUP p.neighbor2 = p.id_in_group + 1 else: p.neighbor1 = p.id_in_group - 1 p.neighbor2 = 1 if subsession.round_number == 1: for p in subsession.get_players(): p.state_trivia = p.state1 + p.state2 + p.state3 + p.state4 if p.state1 == 0 and p.question1 == C.c1: p.correct1 = 1 elif p.state1 == 1 and p.question1 == C.n: p.correct1 = 1 else: p.correct1 = 0 if p.state2 == 0 and p.question2 == C.c2: p.correct2 = 1 elif p.state2 == 1 and p.question2 == C.n: p.correct2 = 1 else: p.correct2 = 0 if p.state3 == 0 and p.question3 == C.c3: p.correct3 = 1 elif p.state3 == 1 and p.question3 == C.n: p.correct3 = 1 else: p.correct3 = 0 if p.state4 == 0 and p.question4 == C.c4: p.correct4 = 1 elif p.state4 == 1 and p.question4 == C.n: p.correct4 = 1 else: p.correct4 = 0 p.correct = p.correct1 + p.correct2 + p.correct3 + p.correct4 return p.state_trivia, p.correct1, p.correct2, p.correct3, p.correct4, p.correct elif subsession.round_number == 21: for p in subsession.get_players(): p.state_trivia = p.state5 + p.state6 + p.state7 + p.state8 if p.state5 == 0 and p.question5 == C.c5: p.correct5 = 1 elif p.state5 == 1 and p.question5 == C.n: p.correct5 = 1 else: p.correct5 = 0 if p.state6 == 0 and p.question6 == C.c6: p.correct6 = 1 elif p.state6 == 1 and p.question6 == C.n: p.correct6 = 1 else: p.correct6 = 0 if p.state7 == 0 and p.question7 == C.c7: p.correct7 = 1 elif p.state7 == 1 and p.question7 == C.n: p.correct7 = 1 else: p.correct7 = 0 if p.state8 == 0 and p.question8 == C.c8: p.correct8 = 1 elif p.state8 == 1 and p.question8 == C.n: p.correct8 = 1 else: p.correct8 = 0 p.correct = p.correct5 + p.correct6 + p.correct7 + p.correct8 return p.state_trivia, p.correct5, p.correct6, p.correct7, p.correct8, p.correct elif subsession.round_number == 41: for p in subsession.get_players(): p.state_trivia = p.state9 + p.state10 + p.state11 + p.state12 if p.state9 == 0 and p.question9 == C.c9: p.correct9 = 1 elif p.state9 == 1 and p.question9 == C.n: p.correct9 = 1 else: p.correct9 = 0 if p.state10 == 0 and p.question10 == C.c10: p.correct10 = 1 elif p.state10 == 1 and p.question10 == C.n: p.correct10 = 1 else: p.correct10 = 0 if p.state11 == 0 and p.question11 == C.c11: p.correct11 = 1 elif p.state11 == 1 and p.question11 == C.n: p.correct11 = 1 else: p.correct11 = 0 if p.state12 == 0 and p.question12 == C.c12: p.correct12 = 1 elif p.state12 == 1 and p.question12 == C.n: p.correct12 = 1 else: p.correct12 = 0 p.correct = p.correct9 + p.correct10 + p.correct11 + p.correct12 return p.state_trivia, p.correct9, p.correct10, p.correct11, p.correct12, p.correct elif subsession.round_number == 61: for p in subsession.get_players(): p.state_trivia = p.state13 + p.state14 + p.state15 + p.state16 if p.state13 == 0 and p.question13 == C.c13: p.correct13 = 1 elif p.state13 == 1 and p.question13 == C.n: p.correct13 = 1 else: p.correct13 = 0 if p.state14 == 0 and p.question14 == C.c14: p.correct14 = 1 elif p.state14 == 1 and p.question14 == C.n: p.correct14 = 1 else: p.correct14 = 0 if p.state15 == 0 and p.question15 == C.c15: p.correct15 = 1 elif p.state15 == 1 and p.question15 == C.n: p.correct15 = 1 else: p.correct15 = 0 if p.state16 == 0 and p.question16 == C.c16: p.correct16 = 1 elif p.state16 == 1 and p.question16 == C.n: p.correct16 = 1 else: p.correct16 = 0 p.correct = p.correct13 + p.correct14 + p.correct15 + p.correct16 return p.state_trivia, p.correct13, p.correct14, p.correct15, p.correct16, p.correct return p.neighbor1, p.neighbor2 def get_quiz(subsession: Subsession): if 1 < subsession.round_number <= 20: for p in subsession.get_players(): p.question1 = p.in_round(1).question1 p.question2 = p.in_round(1).question2 p.question3 = p.in_round(1).question3 p.question4 = p.in_round(1).question4 p.neighbor1 = p.in_round(1).neighbor1 p.neighbor2 = p.in_round(1).neighbor2 elif 21 < subsession.round_number <= 40: for p in subsession.get_players(): p.question5 = p.in_round(21).question5 p.question6 = p.in_round(21).question6 p.question7 = p.in_round(21).question7 p.question8 = p.in_round(21).question8 p.neighbor1 = p.in_round(21).neighbor1 p.neighbor2 = p.in_round(21).neighbor2 elif 41 < subsession.round_number <= 60: for p in subsession.get_players(): p.question9 = p.in_round(41).question9 p.question10 = p.in_round(41).question10 p.question11 = p.in_round(41).question11 p.question12 = p.in_round(41).question12 p.neighbor1 = p.in_round(41).neighbor1 p.neighbor2 = p.in_round(41).neighbor2 elif 61 < subsession.round_number <= 80: for p in subsession.get_players(): p.question13 = p.in_round(61).question13 p.question14 = p.in_round(61).question14 p.question15 = p.in_round(61).question15 p.question16 = p.in_round(61).question16 p.neighbor1 = p.in_round(61).neighbor1 p.neighbor2 = p.in_round(61).neighbor2 def get_belief(subsession: Subsession): if subsession.round_number in [1, 21, 41, 61]: for player in subsession.get_players(): player.previous_belief = player.initial_e n1 = player.group.get_player_by_id(player.neighbor1) n2 = player.group.get_player_by_id(player.neighbor2) player.neighbor1_belief = n1.initial_e player.neighbor2_belief = n2.initial_e else: for player in subsession.get_players(): player.previous_belief = player.in_round(subsession.round_number-1).answer_e n1 = player.group.get_player_by_id(player.neighbor1) n2 = player.group.get_player_by_id(player.neighbor2) player.neighbor1_belief = n1.in_round(subsession.round_number-1).answer_e player.neighbor2_belief = n2.in_round(subsession.round_number-1).answer_e return player.neighbor1_belief, player.neighbor2_belief def set_payoff(subsession: Subsession): paying_quiz = random.choice([1, 21, 41, 61]) subsession.session.paying_quiz = paying_quiz paying_guess = paying_quiz + 19 belief1 = paying_quiz + 4 belief2 = paying_quiz + 9 belief3 = paying_quiz + 14 belief4 = paying_quiz + 19 i = random.random() * 100 j = random.random() * 100 k = random.randint(1, 4) l = random.randint(1, 2) for p in subsession.get_players(): if p.in_round(paying_quiz).correct == 4: p.quiz_payoff = 4 * C.quiz_correct + C.quiz_bonus else: p.quiz_payoff = p.in_round(paying_quiz).correct * C.quiz_correct if p.in_round(paying_guess).answer_e == p.in_round(paying_quiz).state_trivia: p.guess_payoff = C.guess_correct else: p.guess_payoff = 0 if k == 1: if l == 1: if p.in_round(belief1).neighbor1_correct >= i: if p.in_round(belief1).neighbor1_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if p.in_round(belief1).neighbor2_correct >= i: if p.in_round(belief1).neighbor2_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 elif k == 2: if l == 1: if p.in_round(belief2).neighbor1_correct >= i: if p.in_round(belief2).neighbor1_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if p.in_round(belief2).neighbor2_correct >= i: if p.in_round(belief2).neighbor2_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 elif k == 3: if l == 1: if p.in_round(belief3).neighbor1_correct >= i: if p.in_round(belief3).neighbor1_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if p.in_round(belief3).neighbor2_correct >= i: if p.in_round(belief3).neighbor2_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if l == 1: if p.in_round(belief4).neighbor1_correct >= i: if p.in_round(belief4).neighbor1_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if p.in_round(belief4).neighbor2_correct >= i: if p.in_round(belief4).neighbor2_belief == p.in_round(paying_quiz).state_trivia: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 else: if j < i: p.belief_payoff = C.belief_payment else: p.belief_payoff = 0 p.payoff = p.quiz_payoff + p.guess_payoff + p.belief_payoff + C.participant_fee return p.quiz_payoff, p.guess_payoff, p.belief_payoff, p.payoff def question1_choices(player): given_choices = ['The Artful Dodger', 'Tiny Tim', 'Miss Havisham', 'Nicholas Nickleby', 'Oliver Twist'] choices = given_choices[0:player.subsession.random1] + given_choices[player.subsession.random1+1:] + [C.n] correct_answer = C.c1 if correct_answer in choices: player.state1 = 0 else: player.state1 = 1 return choices def question2_choices(player): given_choices = ['London', 'New York', 'Paris', 'Rome', 'Venice'] choices = given_choices[0:player.subsession.random2] + given_choices[player.subsession.random2+1:] + [C.n] correct_answer = C.c2 if correct_answer in choices: player.state2 = 0 else: player.state2 = 1 return choices def question3_choices(player): given_choices = ['Anna Kournikova', 'Serena Williams', 'Maria Sharapova', 'Venus Williams', 'Lindsay Davenport'] choices = given_choices[0:player.subsession.random3] + given_choices[player.subsession.random3+1:] + [C.n] correct_answer = C.c3 if correct_answer in choices: player.state3 = 0 else: player.state3 = 1 return choices def question4_choices(player): given_choices = ['One Flew Over the Cuckoo’s Nest', 'As Good As It Gets', 'The Shining', 'Five Easy Pieces', 'About Schmidt'] choices = given_choices[0:player.subsession.random4] + given_choices[player.subsession.random4+1:] + [C.n] correct_answer = C.c4 if correct_answer in choices: player.state4 = 0 else: player.state4 = 1 return choices def question5_choices(player): given_choices = ['1910s', '1920s', '1930s', '1940s', '1950s'] choices = given_choices[0:player.subsession.random5] + given_choices[player.subsession.random5+1:] + [C.n] correct_answer = C.c5 if correct_answer in choices: player.state5 = 0 else: player.state5 = 1 return choices def question6_choices(player): given_choices = ['Every Little Thing She Does Is Magic', 'Roxanne', 'Don’t Stand So Close to Me', 'Every Breath You Take', 'I Want to Know What Love Is'] choices = given_choices[0:player.subsession.random6] + given_choices[player.subsession.random6+1:] + [C.n] correct_answer = C.c6 if correct_answer in choices: player.state6 = 0 else: player.state6 = 1 return choices def question7_choices(player): given_choices = ['Using higher smokestacks', 'Developing acid‐resistant crops', 'Adding lime to acidified lakes', 'Relocating power plants to areas of lower population density', 'Reducing use of fossil fuels'] choices = given_choices[0:player.subsession.random7] + given_choices[player.subsession.random7+1:] + [C.n] correct_answer = C.c7 if correct_answer in choices: player.state7 = 0 else: player.state7 = 1 return choices def question8_choices(player): given_choices = ['Breeding endangered species in captivity', 'Protecting the habitats of endangered species', 'Paying people not to kill endangered species', 'Providing food to endangered species in the wild', 'Removing predators from areas that contain endangered species'] choices = given_choices[0:player.subsession.random8] + given_choices[player.subsession.random8+1:] + [C.n] correct_answer = C.c8 if correct_answer in choices: player.state8 = 0 else: player.state8 = 1 return choices def question9_choices(player): given_choices = ['nutrients in soil', 'nutrients in vegetation', 'primary consumers', 'producers', 'the Sun'] choices = given_choices[0:player.subsession.random9] + given_choices[player.subsession.random9+1:] + [C.n] correct_answer = C.c9 if correct_answer in choices: player.state9 = 0 else: player.state9 = 1 return choices def question10_choices(player): given_choices = ['It arose quite suddenly amid the hysteria surrounding the First World War.', 'It won the support of many progressive reformers.', 'It was often favored by people who disliked immigrants and their cultural practices.', 'It was a movement in which women played leading roles.', 'It gained strength from new scientific evidence that alcohol was harmful to health.'] choices = given_choices[0:player.subsession.random10] + given_choices[player.subsession.random10+1:] + [C.n] correct_answer = C.c10 if correct_answer in choices: player.state10 = 0 else: player.state10 = 1 return choices def question11_choices(player): given_choices = ['Hamlet', 'Romeo and Juliet', 'A Midsummer Night’s Dream', 'Much Ado About Nothing', 'As You Like It'] choices = given_choices[0:player.subsession.random11] + given_choices[player.subsession.random11+1:] + [C.n] correct_answer = C.c11 if correct_answer in choices: player.state11 = 0 else: player.state11 = 1 return choices def question12_choices(player): given_choices = ['American Revolution', 'World War I', 'World War II', 'Civil War', 'Vietnam War'] choices = given_choices[0:player.subsession.random12] + given_choices[player.subsession.random12+1:] + [C.n] correct_answer = C.c12 if correct_answer in choices: player.state12 = 0 else: player.state12 = 1 return choices def question13_choices(player): given_choices = ['absolutism', 'primogeniture', 'patronage', 'manorialism', 'nepotism'] choices = given_choices[0:player.subsession.random13] + given_choices[player.subsession.random13+1:] + [C.n] correct_answer = C.c13 if correct_answer in choices: player.state13 = 0 else: player.state13 = 1 return choices def question14_choices(player): given_choices = ['Coxswain', 'Sculler', 'Sweep', 'Rigger', 'Stern'] choices = given_choices[0:player.subsession.random14] + given_choices[player.subsession.random14+1:] + [C.n] correct_answer = C.c14 if correct_answer in choices: player.state14 = 0 else: player.state14 = 1 return choices def question15_choices(player): given_choices = ['Elephants', 'Chickens', 'Monkeys', 'Penguins', 'Rabbits'] choices = given_choices[0:player.subsession.random15] + given_choices[player.subsession.random15+1:] + [C.n] correct_answer = C.c15 if correct_answer in choices: player.state15 = 0 else: player.state15 = 1 return choices def question16_choices(player): given_choices = ['Generation of CO2 gas', 'Leachate contamination of groundwater', 'Release of disease organisms', 'Incomplete degradation of wastes', 'Compaction and settling'] choices = given_choices[0:player.subsession.random16] + given_choices[player.subsession.random16+1:] + [C.n] correct_answer = C.c16 if correct_answer in choices: player.state16 = 0 else: player.state16 = 1 return choices #page class ShuffleWaitPage(WaitPage): wait_for_all_groups = True @staticmethod def after_all_players_arrive(subsession): if subsession.round_number in [1, 21, 41, 61]: subsession.group_randomly() elif 1 < subsession.round_number <= 20: subsession.group_like_round(1) elif 21 < subsession.round_number <= 40: subsession.group_like_round(21) elif 41 < subsession.round_number <= 60: subsession.group_like_round(41) else: subsession.group_like_round(61) class InstructionTrivia(Page): def is_displayed(self): display = [1, 21, 41, 61] return self.round_number in display class WaitRandom(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'set_random' def is_displayed(self): display = [1, 21, 41, 61] return self.round_number in display class Trivia1(Page): form_model = 'player' form_fields = ['question1', 'question2', 'question3', 'question4'] def is_displayed(self): return self.round_number == 1 class Trivia2(Page): form_model = 'player' form_fields = ['question5', 'question6', 'question7', 'question8'] def is_displayed(self): return self.round_number == 21 class Trivia3(Page): form_model = 'player' form_fields = ['question9', 'question10', 'question11', 'question12'] def is_displayed(self): return self.round_number == 41 class Trivia4(Page): form_model = 'player' form_fields = ['question13', 'question14', 'question15', 'question16'] def is_displayed(self): return self.round_number == 61 class WaitQuiz(WaitPage): title_text = 'Please Wait' body_text = 'Thank you for completing the quiz. On the next screen, you will be asked about your answers for the trivia quiz. Please wait till everyone has finished the trivia quiz.' wait_for_all_groups = True after_all_players_arrive = 'set_state' def is_displayed(self): display = [1, 21, 41, 61] return self.round_number in display class GetQuiz(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'get_quiz' def is_displayed(self): display = [1, 21, 41, 61] return self.round_number not in display class InstructionUpdate(Page): form_model = 'player' form_fields = ['initial_e', 'correct_e'] def is_displayed(self): display = [1, 21, 41, 61] return self.round_number in display class InstructionNeighborUpdate(Page): def is_displayed(self): display = [1, 21, 41, 61] return self.round_number in display class WaitBelief(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'get_belief' class NeighborBeliefUpdate(Page): form_model = 'player' form_fields = ['neighbor1_correct', 'neighbor2_correct'] def is_displayed(self): display = [1, 21, 41, 61] + [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80] return self.round_number in display @staticmethod def vars_for_template(player): if player.round_number in list(range(21)): round = player.round_number elif player.round_number in list(range(21, 41)): round = player.round_number - 20 elif player.round_number in list(range(41, 61)): round = player.round_number - 40 else: round = player.round_number - 60 return dict( round=round ) class NeighborUpdate(Page): def is_displayed(self): display = [1, 21, 41, 61] + [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80] return self.round_number not in display @staticmethod def vars_for_template(player): if player.round_number in list(range(21)): round = player.round_number elif player.round_number in list(range(21, 41)): round = player.round_number - 20 elif player.round_number in list(range(41, 61)): round = player.round_number - 40 else: round = player.round_number - 60 return dict( round=round ) class SelfUpdate1(Page): form_model = 'player' form_fields = ['answer_e'] def is_displayed(self): display = list(range(1, 21)) return self.round_number in display class SelfUpdate2(Page): form_model = 'player' form_fields = ['answer_e'] def is_displayed(self): display = list(range(21, 41)) return self.round_number in display @staticmethod def vars_for_template(player): round = player.round_number - 20 return dict( round=round, ) class SelfUpdate3(Page): form_model = 'player' form_fields = ['answer_e'] def is_displayed(self): display = list(range(41, 61)) return self.round_number in display @staticmethod def vars_for_template(player): round = player.round_number - 40 return dict( round=round, ) class SelfUpdate4(Page): form_model = 'player' form_fields = ['answer_e'] def is_displayed(self): display = list(range(61, 81)) return self.round_number in display @staticmethod def vars_for_template(player): round = player.round_number - 60 return dict( round=round, ) class WaitPayoff(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'set_payoff' def is_displayed(self): return self.round_number == C.NUM_ROUNDS title_text = 'Please Wait' body_text = 'The experiment is now complete. Thank you for participating. Please wait to see which of the four repetitions was chosen for payment.' class Result(Page): def is_displayed(self): return self.round_number == C.NUM_ROUNDS def vars_for_template(player): if player.session.paying_quiz == 1: pay_round = 1 elif player.session.paying_quiz == 21: pay_round = 2 elif player.session.paying_quiz == 41: pay_round = 3 elif player.session.paying_quiz == 61: pay_round = 4 return dict(pay_round=pay_round) page_sequence = [ShuffleWaitPage, InstructionTrivia, WaitRandom, Trivia1, Trivia2, Trivia3, Trivia4, WaitQuiz, GetQuiz, InstructionUpdate, InstructionNeighborUpdate, WaitBelief, NeighborBeliefUpdate, NeighborUpdate, SelfUpdate1, SelfUpdate2, SelfUpdate3, SelfUpdate4, WaitPayoff, Result ]