from otree.api import * import random import itertools import numpy as np from random import choice author = 'Zeyu Qiu' doc = """ Baseline """ class C(BaseConstants): NAME_IN_URL = 'individual' PLAYERS_PER_GROUP = None NUM_ROUNDS = 4 Ethnic = [ dict(name='White', label='White'), dict(name='Black', label='Black'), dict(name='Latino', label='Latino'), dict(name='Asian', label='Asian'), dict(name='Arab', label='Arab'), dict(name='Otherethnic', label='Other (free text)'), dict(name='Prefer_not_to_say', label='Prefer not to say') ] def set_scale_choices_list(length): choices_list = [] for i in range(length): choices_list.append((i + 1, str(i + 1))) return choices_list def make_scale_field(label_string, length): return models.IntegerField( choices=set_scale_choices_list(length), widget=widgets.RadioSelectHorizontal, label=label_string # blank=True ) class Subsession(BaseSubsession): pass def creating_session(subsession): session = subsession.session session.vars['session_random_round1'] = random.randint(1, 2) session.vars['session_random_round2'] = random.randint(3, C.NUM_ROUNDS) for p in subsession.get_players(): p.random_round1 = session.vars['session_random_round1'] p.random_round2 = session.vars['session_random_round2'] for p in subsession.get_players(): if p.id_in_subsession: pressures = itertools.cycle([3,3,3,3]) for player in subsession.get_players(): player.code_treatment = next(pressures) if p.code_treatment == 0: p.treatment = "base" elif p.code_treatment == 1: p.treatment = "exog" elif p.code_treatment == 2: p.treatment = "resp" else: p.treatment = "indi" for p in subsession.get_players(): p.t_rand = random.random() p.t_rand2 = random.random() class Group(BaseGroup): pass class Player(BasePlayer): random_round1 = models.IntegerField() random_round2 = models.IntegerField() t_rand = models.FloatField() t_rand2 = models.FloatField() prob = models.FloatField() prob_percent = models.FloatField() other_percent = models.FloatField() is_winner = models.BooleanField( initial=False ) other_ticket = models.IntegerField() # variables for wheel of fortune my_pie = models.FloatField() share_a = models.FloatField() share_b = models.FloatField() final_arrow = models.FloatField() arrow_stop = models.FloatField() won = models.StringField() yourbid = models.StringField() otherbid = models.StringField() wonwon = models.StringField() bidcost = models.StringField() prize = models.StringField() ticketcost = models.IntegerField() pay = models.IntegerField() treatment = models.StringField() Q1 = models.StringField( choices=[ ['1', 'Yes, always '], ['2', 'No, never '], ['3', 'Yes with some probability but not always'] ], label='', widget=widgets.RadioSelect ) Q2 = models.StringField( choices=[ ['1', 'Yes, always '], ['2', 'No, never '], ['3', 'Yes with some probability but not always'] ], label='', widget=widgets.RadioSelect ) Q3 = models.StringField( choices=[ ['1', 'Always in UP '], ['2', 'Always in DOWN '], ['3', 'With some probability in UP and with some probability in DOWN'] ], label='', widget=widgets.RadioSelect ) Q4 = models.StringField( choices=[ ['1', 'Always in UP '], ['2', 'Always in DOWN '], ['3', 'With some probability in UP and with some probability in DOWN'] ], label='', widget=widgets.RadioSelect ) Q5 = models.StringField( choices=[ ['1', 'Always 0 '], ['2', 'Always 120 '], ['3', 'Any number between 0 and 120 with equal probability'], ['4', 'Any number between 0 and 120, although not necessarily with the same probability'] ], label='', widget=widgets.RadioSelect ) Q6 = models.StringField( choices=[ ['1', 'Always 0 '], ['2', 'Always 120 '], ['3', 'Any number between 0 and 120 with equal probability'], ['4', 'Any number between 0 and 120, although not necessarily with the same probability'] ], label='', widget=widgets.RadioSelect ) Anna = models.IntegerField( label="Anna (enter number between 0 and 120)", min=0, max=120 ) Bruno = models.IntegerField( label="Random number (enter number between 0 and 120)", min=0, max=120 ) Q7 = models.StringField( label='', widget=widgets.RadioSelect ) Q8 = models.StringField( label='', widget=widgets.RadioSelect ) Q9 = models.StringField( label='', widget=widgets.RadioSelect ) bid = models.StringField( choices=[ ['1', 'Bid '], ['2', 'Not bid '] ], label='', widget=widgets.RadioSelect ) guess = models.StringField( choices=[ ['1', 'Bid '], ['2', 'Not bid '] ], label='', widget=widgets.RadioSelect ) other = models.StringField( ) ticket = models.IntegerField( label="", min=0, max=120 ) ticket2 = models.IntegerField( label="", min=0, max=120 ) selected_round1 = models.IntegerField() selected_round2 = models.IntegerField() bonus = models.IntegerField() payoff1 = models.IntegerField() payoff2 = models.IntegerField() euro1 = models.FloatField() euro2 = models.FloatField() bonusfinal = models.IntegerField() bonuseuro = models.FloatField() sum = models.FloatField() gender = models.StringField( choices=[ ['1', 'Male'], ['2', 'Female'], ['3', 'Nonbinary'], ['4', 'Prefer not to say'] ], label="1. Do you mostly identify as? ", widget=widgets.RadioSelect ) age = models.IntegerField( label="2. What is your age (in numbers)?", min=0, max=120 ) White = models.BooleanField(blank=True) Black = models.BooleanField(blank=True) Latino = models.BooleanField(blank=True) Asian = models.BooleanField(blank=True) Arab = models.BooleanField(blank=True) Otherethnic = models.BooleanField(blank=True) Prefer_not_to_say = models.BooleanField(blank=True) other_text = models.StringField(blank=False, label="You selected 'Other'. What is your ethnicity?" ) student = models.StringField( choices=[ ['1', 'Yes'], ['2', 'No'], ], label="4. Are you a student? ", widget=widgets.RadioSelect ) degree = models.StringField(blank=False, label="7. Please give us the full title of your degree of study." ) level = models.StringField( choices=[ ['1', 'Primary'], ['2', 'Secondary'], ['3', 'University or higher'] ], label="7. What is the highest level of education you have attained?", widget=widgets.RadioSelect ) work = models.StringField( choices=[ ['1', 'Full-time'], ['2', 'Part-time'], ['3', 'Not working'] ], label="8. Are you working?", widget=widgets.RadioSelect ) status = models.StringField( choices=[ ['1', 'Single'], ['2', ' In a stable relationship'], ['3', 'Married'], ['4', ' Divorced '], ['5', 'Widowed'] ], label="6. What best describes your civil status? ", widget=widgets.RadioSelect ) child = models.StringField( choices=[ ['1', 'I have no siblings'], ['2', ' 1'], ['3', '2'], ['4', ' 3 '], ['5', '+3'] ], label="5. Do you have any siblings? ", widget=widgets.RadioSelect ) living = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) political = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) volunteer = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) risk = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) gamble = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) back = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) myself = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) long = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ], label="", widget=widgets.RadioSelectHorizontal ) chance = models.StringField( label="17. Imagine you're playing the Lotto game, where you select six numbers from 1 to 59. To win the jackpot, all six of your chosen numbers must match the six numbers drawn. What are the odds of winning the jackpot? ", widget=widgets.RadioSelect ) def chance_choices(player): choices = ['1 in 45 thousand', '1 in 450 thousand', '1 in 4.5 million', '1 in 45 million', '1 in 450 million', '1 in 4.5 billion'] random.shuffle(choices) return choices def Q1_error_message(player, value): if value != '3': return 'Your answer is wrong.' def Q2_error_message(player, value): if value != '2': return 'Your answer is wrong.' def Q3_error_message(player, value): if value != '1': return 'Your answer is wrong.' def Q4_error_message(player, value): if value != '3': return 'Your answer is wrong.' def Q5_error_message(player, value): if value != '4': return 'Your answer is wrong.' def Q6_error_message(player, value): if value != '2': return 'Your answer is wrong.' def Q7_choices(player): if player.Anna==0 and player.Bruno==0: correct5 = 50 elif player.Anna==0 and player.Bruno!=0: correct5 = 0 elif player.Anna!=0 and player.Bruno==0: correct5= 100 else: correct5 = round(player.Anna/(player.Anna+player.Bruno)*100,2) if correct5>50: choices = [ ['1', '{}%'.format(correct5)], ['2', '0%'], ['3', '25%'] ] return choices elif correct5<50: choices = [ ['1', '{}%'.format(correct5)], ['2', '75%'], ['3', '100%'] ] return choices else: choices = [ ['1', '{}%'.format(correct5)], ['2', '0%'], ['3', '100%'] ] return choices def Q7_error_message(player, value): if value != '1': return 'Your answer is wrong.' def Q8_choices(player): correct6 = player.Anna c66 = 72- correct6 c666 = 120- correct6 choices = [ ['1', 'The prize (120 tokens) – cost of bid for the advantage (48 tokens) - cost of tickets Anna bought ({} tokens) = {} tokens'.format(correct6,c66)], ['2', 'The prize (120 tokens) – cost of tickets Anna bought ({} tokens) = {} tokens'.format(correct6,c666)], ['3', 'The prize (120 tokens) – cost of bid for the advantage (48 tokens) = 72 tokens'], ['4','The prize (120 tokens) = 120 tokens'] ] return choices def Q8_error_message(player, value): if value != '3': return 'Your answer is wrong.' def Q9_choices(player): correct7 = player.Anna c77 = -48 - correct7 c777 = 120 - correct7 choices = [ ['1', '– cost of bid for the advantage (48 tokens) - cost of tickets Anna bought ({} tokens) = {} tokens'.format(correct7,c77)], ['2', '– cost of tickets Anna bought ({} tokens) = – {} tokens'.format(correct7,correct7)], ['3', 'The prize (120 tokens) – cost of tickets Anna bought ({} tokens) = {} tokens'.format(correct7,c777)] ] return choices def Q9_error_message(player, value): if value != '2': return 'Your answer is wrong.' # FUNCTIONS def set_probabilities(player): if player.ticket == 0 and player.other_ticket == 0: player.prob = 0.5 else: player.prob = (player.ticket / (player.ticket+player.other_ticket)) player.prob_percent = round(player.prob * 100, 1) player.other_percent = round(100 - player.prob_percent,1) def set_winner(player): prob = random.random() if prob <= player.prob: player.is_winner = True player.participant.vars['is_winner'] = player.is_winner # functions for wheel of fortune def set_shares(player): if player.prob_percent == 0: player.share_a = 0 if 2 >= player.prob_percent > 0: player.share_a = 1 if 100 > player.prob_percent >= 98: player.share_a = 99 if player.prob_percent == 100: player.share_a = 100 if 2 < player.prob_percent < 98: player.share_a = round(player.prob_percent) player.share_b = 100 - player.share_a def set_my_pie(player): player.my_pie = (round(player.prob_percent) / 100) * 360 def set_arrow_stop(player): rand = (np.random.randint(low=1, high=99)) * 0.01 if player.is_winner: player.arrow_stop = (player.my_pie * rand) + (360 - player.my_pie) player.won = 'You won' if not player.is_winner: player.arrow_stop = (360 - player.my_pie) * rand player.won = 'You did not win' def set_final_arrow(player): if player.arrow_stop == 0: player.final_arrow = 2 if player.arrow_stop == player.my_pie: player.final_arrow = player.my_pie + 2 if player.arrow_stop != 0 and player.arrow_stop != player.my_pie: player.final_arrow = round(player.arrow_stop) # PAGES # PAGES class Consent(Page): def is_displayed(player: Player): if player.treatment == "base" and player.round_number == 1: return True elif player.treatment == "exog" and player.round_number == 1: return True elif player.treatment == "resp" and player.round_number == 1: return True elif player.treatment == "indi" and player.round_number == 1: return True else: return False class Instructions(Page): @staticmethod def js_vars(player): session =player.session return dict() def is_displayed(player: Player): if player.treatment == "base" and player.round_number==1: return True elif player.treatment == "exog" and player.round_number==1: return True elif player.treatment == "resp" and player.round_number==1: return True elif player.treatment == "indi" and player.round_number==1: return True else: return False class First(Page): def is_displayed(player: Player): if player.treatment == "base" and player.round_number == 1: return True elif player.treatment == "exog" and player.round_number == 1: return True elif player.treatment == "resp" and player.round_number == 1: return True elif player.treatment == "indi" and player.round_number == 1: return True else: return False class Q1(Page): form_model = 'player' form_fields = ['Q1', 'Q2', 'Q3', 'Q4'] def is_displayed(player: Player): if player.treatment == "base" and player.round_number == 1: return True elif player.treatment == "exog" and player.round_number == 1: return True elif player.treatment == "resp" and player.round_number == 1: return True elif player.treatment == "indi" and player.round_number == 1: return True else: return False class Q2(Page): form_model = 'player' form_fields = ['Anna', 'Bruno', 'Q5', 'Q6' ] def is_displayed(player: Player): if player.treatment == "base" and player.round_number == 1: return True elif player.treatment == "exog" and player.round_number == 1: return True elif player.treatment == "resp" and player.round_number == 1: return True elif player.treatment == "indi" and player.round_number == 1: return True else: return False class Q3(Page): form_model = 'player' def get_form_fields(player): if player.Anna ==0 and player.Bruno ==0: return ['Q7'] elif player.Anna ==0 and player.Bruno !=0: return ['Q7', 'Q9'] elif player.Anna !=0 and player.Bruno ==0: return ['Q7', 'Q8'] else: return ['Q7', 'Q8', 'Q9'] def is_displayed(player: Player): if player.treatment == "base" and player.round_number == 1: return True elif player.treatment == "exog" and player.round_number == 1: return True elif player.treatment == "resp" and player.round_number == 1: return True elif player.treatment == "indi" and player.round_number == 1: return True else: return False def vars_for_template(player): return dict( Anna=player.Anna, Bruno=player.Bruno ) class Second(Page): def is_displayed(player: Player): if player.treatment == "base" and player.round_number == 1: return True elif player.treatment == "exog" and player.round_number == 1: return True elif player.treatment == "resp" and player.round_number == 1: return True elif player.treatment == "indi" and player.round_number == 1: return True else: return False class Decision(Page): form_model = 'player' form_fields = ['bid' ] def vars_for_template(player): return dict( round=player.round_number ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {1, 2}: return True else: return False class Summary1(Page): form_model = 'player' def vars_for_template(player): if player.bid == '1': your = 'bid' else: your = 'did not bid' return dict( your =your, round=player.round_number ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {1, 2}: return True else: return False class Decision2(Page): form_model = 'player' def get_form_fields(player): if player.bid =='1' and player.t_rand > 0.5: return ['ticket', 'ticket2'] else: return ['ticket'] def vars_for_template(player): if player.bid == '1': your = 'bid' else: your = 'did not bid' if player.bid == "1" and player.t_rand > 0.5: player.other_ticket = int(round(120 * random.random(), 1)) elif player.bid == "1" and player.t_rand <= 0.5: player.other_ticket = 120 elif player.bid == "2" and player.t_rand2 > 0.5: player.other_ticket = int(round(120 * random.random(), 1)) elif player.bid == "2" and player.t_rand2 <= 0.5: player.other_ticket = 120 return dict( your=your, round=player.round_number ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {1, 2}: return True else: return False def before_next_page(player: Player, timeout_happened): set_probabilities(player) set_winner(player) set_shares(player) set_my_pie(player) set_arrow_stop(player) set_final_arrow(player) class Wheel(Page): @staticmethod def js_vars(player: Player): return dict( share_a=player.share_a, share_b=player.share_b, final_arrow=player.final_arrow, won = player.won, ticket = player.ticket, other_ticket = player.other_ticket, prob_percent = player.prob_percent, other_percent = player.other_percent ) def vars_for_template(player): return dict( round=player.round_number ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {1, 2}: return True else: return False class Summary2(Page): form_model = 'player' def vars_for_template(player): if player.bid == '1': player.yourbid = 'bid' player.bidcost = '– cost of bid for the advantage (48 tokens)' else: player.yourbid = 'did not bid' player.bidcost = '' if player.is_winner: player.wonwon = 'won' player.prize = 'The prize (120 tokens)' if not player.is_winner: player.wonwon = 'did not win' player.prize = '' if player.bid == '1' and player.t_rand > 0.5: player.ticketcost = 0 elif player.bid == '1' and player.t_rand <= 0.5: player.ticketcost = player.ticket elif player.bid == '2': player.ticketcost = player.ticket if player.bid == '1' and player.t_rand > 0.5 and player.is_winner: player.pay = 72 elif player.bid == '1' and player.t_rand > 0.5 and not player.is_winner: player.pay = -48 elif player.bid == '2' and player.is_winner: player.pay = 120-player.ticket elif player.bid == '2' and not player.is_winner: player.pay = -player.ticket elif player.bid == '1' and player.t_rand <= 0.5 and player.is_winner: player.pay = 72-player.ticket elif player.bid == '1' and player.t_rand <= 0.5 and not player.is_winner: player.pay = -48-player.ticket return dict( your =player.yourbid, round=player.round_number, ticket=player.ticket, won=player.wonwon, bidcost = player.bidcost, prize = player.prize, ticketcost = player.ticketcost, pay = player.pay ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {1, 2}: return True else: return False class Endfirst(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {3}: return True else: return False class Decision3(Page): form_model = 'player' form_fields = ['bid', ] def vars_for_template(player): return dict( round=player.round_number-2 ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {3, 4}: return True else: return False class Summary3(Page): form_model = 'player' def vars_for_template(player): if player.bid == '1': your = 'bid' else: your = 'did not bid' return dict( your =your, round=player.round_number-2 ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {3, 4}: return True else: return False class Decision4(Page): form_model = 'player' def get_form_fields(player): if player.bid == '1' and player.t_rand > 0.5: return ['ticket', 'ticket2'] else: return ['ticket'] def vars_for_template(player): if player.bid == '1': your = 'bid' else: your = 'did not bid' if player.bid == "1" and player.t_rand > 0.5: player.other_ticket = int(round(120 * random.random(), 1)) elif player.bid == "1" and player.t_rand <= 0.5: player.other_ticket = 120 elif player.bid == "2" and player.t_rand2 > 0.5: player.other_ticket = int(round(120 * random.random(), 1)) elif player.bid == "2" and player.t_rand2 <= 0.5: player.other_ticket = 120 return dict( your=your, round=player.round_number-2 ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {3, 4}: return True else: return False def before_next_page(player: Player, timeout_happened): set_probabilities(player) set_winner(player) set_shares(player) set_my_pie(player) set_arrow_stop(player) set_final_arrow(player) class Wheel2(Page): @staticmethod def js_vars(player: Player): return dict( share_a=player.share_a, share_b=player.share_b, final_arrow=player.final_arrow, won = player.won, ticket = player.ticket, other_ticket = player.other_ticket, prob_percent = player.prob_percent, other_percent = player.other_percent ) def vars_for_template(player): return dict( round=player.round_number-2 ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {3, 4}: return True else: return False class Summary4(Page): form_model = 'player' def vars_for_template(player): if player.bid == '1': player.yourbid = 'bid' player.bidcost = '– cost of bid for the advantage (12 tokens)' else: player.yourbid = 'did not bid' player.bidcost = '' if player.is_winner: player.wonwon = 'won' player.prize = 'The prize (120 tokens)' if not player.is_winner: player.wonwon = 'did not win' player.prize = '' if player.bid == '1' and player.t_rand > 0.5: player.ticketcost = 0 elif player.bid == '1' and player.t_rand <= 0.5: player.ticketcost = player.ticket elif player.bid == '2': player.ticketcost = player.ticket if player.bid == '1' and player.t_rand > 0.5 and player.is_winner: player.pay = 108 elif player.bid == '1' and player.t_rand > 0.5 and not player.is_winner: player.pay = -12 elif player.bid == '2' and player.is_winner: player.pay = 120 - player.ticket elif player.bid == '2' and not player.is_winner: player.pay = -player.ticket elif player.bid == '1' and player.t_rand <= 0.5 and player.is_winner: player.pay = 108 - player.ticket elif player.bid == '1' and player.t_rand <= 0.5 and not player.is_winner: player.pay = -12 - player.ticket return dict( your=player.yourbid, round=player.round_number-2, ticket=player.ticket, won=player.wonwon, bidcost=player.bidcost, prize=player.prize, ticketcost=player.ticketcost, pay=player.pay ) def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {3, 4}: return True else: return False class Endsecond(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False class Questionnaire(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False form_model = 'player' def get_form_fields(player: Player): return ['gender', 'age', 'White','Black','Latino','Asian','Arab','Otherethnic', 'Prefer_not_to_say','student','child' ] def error_message(player: Player, values): num_selected = 0 for et in C.Ethnic: if values[et['name']]: num_selected += 1 if num_selected < 1: return "You must select at least 1 option." class Questionnaire2(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4} and player.field_maybe_none('Otherethnic') == 1: return True else: return False form_model = 'player' form_fields = ['other_text'] class Questionnaire3(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False form_model = 'player' def get_form_fields(player: Player): if player.student == '1': return ['status','degree','work' ] elif player.student == '2': return ['status', 'level','work' ] class Questionnaire4(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False form_model = 'player' form_fields = ['living','political'] class Questionnaire5(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False form_model = 'player' form_fields = ['volunteer','risk'] class Questionnaire6(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False form_model = 'player' form_fields = ['gamble','back','myself'] class Questionnaire7(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False form_model = 'player' form_fields = ['long', 'chance'] class Thanks(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False def before_next_page(player: Player, timeout_happened): player.selected_round1 = player.random_round1 player.selected_round2 = player.random_round2-2 player_in_selected_round1 = player.in_round(player.random_round1) player_in_selected_round2 = player.in_round(player.random_round2) player.payoff1 = player_in_selected_round1.pay player.payoff2 = player_in_selected_round2.pay player.euro1 = round(player.payoff1/15,2) player.euro2 = round(player.payoff2/15,2) player.sum = round(10.5 + player.euro1 + player.euro2,2) player.payoff = player.sum class payoff(Page): def is_displayed(player: Player): if player.treatment in {"base", "exog", "resp", "indi"} and player.round_number in {4}: return True else: return False page_sequence = [Consent,Instructions, First, Q1, Q2, Q3, Second, Decision, Summary1, Decision2, Wheel, Summary2, Endfirst, Decision3, Summary3, Decision4, Wheel2, Summary4, Endsecond, Questionnaire, Questionnaire2, Questionnaire3, Questionnaire4, Questionnaire5, Questionnaire6,Questionnaire7, Thanks, payoff]