from otree.api import * import random doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'main' players_per_group = 3 num_rounds = 1 # new_structure = [[1, 3, 5], [2, 4, 6]] comp1 = 'True' comp2 = 'False' comp3 = 'True' comp4 = '60' comp5 = '190' comp6 = '10' timeout = 45 class Subsession(BaseSubsession): pass class Group(BaseGroup): period = models.IntegerField(initial=0) id1rankp1 = models.IntegerField() id2rankp1 = models.IntegerField() id3rankp1 = models.IntegerField() id1rankp2 = models.IntegerField() id2rankp2 = models.IntegerField() id3rankp2 = models.IntegerField() id1rankp3 = models.IntegerField() id2rankp3 = models.IntegerField() id3rankp3 = models.IntegerField() id1rankp4 = models.IntegerField() id2rankp4 = models.IntegerField() id3rankp4 = models.IntegerField() id1rankp5 = models.IntegerField() id2rankp5 = models.IntegerField() id3rankp5 = models.IntegerField() id1rankp6 = models.IntegerField() id2rankp6 = models.IntegerField() id3rankp6 = models.IntegerField() id1rankp7 = models.IntegerField() id2rankp7 = models.IntegerField() id3rankp7 = models.IntegerField() id1rankp8 = models.IntegerField() id2rankp8 = models.IntegerField() id3rankp8 = models.IntegerField() id1rankp9 = models.IntegerField() id2rankp9 = models.IntegerField() id3rankp9 = models.IntegerField() id1rankf = models.IntegerField() id2rankf = models.IntegerField() id3rankf = models.IntegerField() # BUILD FUNCTIONS def likert_7(label): return models.IntegerField( choices = [ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, ''], ], label = label, widget = widgets.RadioSelect ) def make_field_A_B(): return models.BooleanField( choices = [ [True, 'A'], [False, 'B'], ], widget=widgets.RadioSelectHorizontal, label = '' ) class Player(BasePlayer): # treatment = models.StringField() consent = models.BooleanField() wlp = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl = models.IntegerField(initial=0) name = models.StringField(label="") wl1 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl2 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl3 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl4 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl5 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl6 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl7 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl8 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl9 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") wl10 = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], label="Please select a work level.") Q1 = models.StringField( choices=['True', 'False'], widget=widgets.RadioSelect, label='1. The higher the work level, the higher the reward.', initial='filler' ) Q2 = models.StringField( choices=['True', 'False'], widget=widgets.RadioSelect, label='2. The higher the work level, the lower the cost.', initial='filler' ) Q3 = models.StringField( choices=['True', 'False'], widget=widgets.RadioSelect, label='3. The reporting error in each period is your work level choice times 10% multiplied by the associated' ' work level choice payoff in Lira and may be either positive or negative.', initial='filler' ) Q4 = models.StringField( label='4. If you select work level 2 and the reporting error DOES NOT result in your favor, how many Lira' \ ' will your actual payoff be? (Please enter your answer as a number with no spaces)', ) Q5 = models.StringField( label='5. If you select work level 10 and the reporting error DOES result in your favor, how many Lira' \ ' will your actual payoff be? (Please enter your answer as a number with no spaces)', ) Q6 = models.StringField( label='6. How many periods are there in this session? (Please enter your answer as a number with no spaces)', ) r = models.IntegerField(initial=0) rt = models.IntegerField(initial=0) Pay = models.IntegerField(initial=0) fm = models.StringField() peq1 = likert_7('I found the task interesting.') # Post-Experimental Question 1 peq2 = likert_7('I found the task enjoyable. ') # Post-Experimental Question 2 peq3 = likert_7('I thought carefully about my work level choices.') # Post-Experimental Question 3 peq4 = likert_7('') peq5 = likert_7('I felt time pressure when choosing a work level.') peq6 = likert_7('') peq7 = likert_7('When the error worked in my favor it affected my work level choice in the following period.') peq8 = likert_7('When the error did not work in my favor it affected my work level choice in the following period.') peq9 = likert_7('') peq10= likert_7('') peq11 = likert_7('I thought the study was fair.') sc1 = likert_7('I always pay a lot of attention to how I do things compared with how others do things.') sc2 = likert_7('I often compare how I am doing socially (e.g., social skills, popularity) with other people.') sc3 = likert_7('I am not the type of person who compares often with others.') sc4 = likert_7('I often try to find out what others think who face similar problems as I face.') sc5 = likert_7('I always like to know what others in a similar situation would do.') sc6 = likert_7('If I want to learn more about something, I try to find out what others think about it.') op1 = likert_7('In uncertain times, I usually expect the best.') op2 = likert_7('It is easy for me to relax.') op3 = likert_7('If something can go wrong for me, it will.') op4 = likert_7('I am always optimistic about my future.') op5 = likert_7('I enjoy my friends a lot.') op6 = likert_7('It is important for me to keep busy.') op7 = likert_7('I hardly ever expect things to go my way.') op8 = likert_7('I do not get upset too easily.') op9 = likert_7('I rarely count on good things happening to me.') op10 = likert_7('Overall, I expect more good things to happen to me than bad.') ra1 = make_field_A_B() ra2 = make_field_A_B() ra3 = make_field_A_B() ra4 = make_field_A_B() ra5 = make_field_A_B() ra6 = make_field_A_B() ra7 = make_field_A_B() ra8 = make_field_A_B() ra9 = make_field_A_B() ra10 = make_field_A_B() ra11 = make_field_A_B() byuid = models.IntegerField(label="") background1 = models.IntegerField( # Background Question 1 label='What is your gender?', choices=[ [1, 'Male'], [2, 'Female'], [3, 'Other'], [4, 'Prefer not to answer'] ], widget=widgets.RadioSelect() ) background2 = models.IntegerField( # Background Question 2 label='What is your age in years?', ) background3 = models.IntegerField( # Background Question 3 label='What is your highest level of education?', choices=[ [1, 'No high school degree or equivalent'], [2, 'High school degree or equivalent'], [3, 'Some college'], [4, 'College degree'], [5, 'Graduate degree'] ], widget=widgets.RadioSelect() ) background4 = models.BooleanField( label='Are you a US Citizen?' ) background5 = models.BooleanField( label='Are you a BYU employee?' ) n1 = models.StringField(initial="John") n2 = models.StringField(initial="Matt") n3 = models.StringField(initial="Greg") rt1 = models.IntegerField(initial=0) rt2 = models.IntegerField(initial=0) rt3 = models.IntegerField(initial=0) rank = models.IntegerField() favor = models.BooleanField() f1 = models.BooleanField() f2 = models.BooleanField() f3 = models.BooleanField() f4 = models.BooleanField() f5 = models.BooleanField() f6 = models.BooleanField() f7 = models.BooleanField() f8 = models.BooleanField() f9 = models.BooleanField() ff = models.BooleanField() # FUNCTIONS # def creating_session(subsession): # import itertools # treat = itertools.cycle(["AI", "MI"]) # for player in subsession.get_players(): # player.treatment = next(treat) def Q1_error_message(player, Q1): if Q1 != Constants.comp1: return 'Incorrect. It is TRUE. The higher the work level, the higher the reward. Answer correctly to continue.' def Q2_error_message(player, Q2): if Q2 != Constants.comp2: return 'Incorrect. It is FALSE. The higher the work level, the higher the cost. Answer correctly to continue.' def Q3_error_message(player, Q3): if Q3 != Constants.comp3: return 'Incorrect. It is TRUE. The reporting error in this round is your work level choice times' \ ' 10% multiplied by the associated work level choice payoff in Lira.' def Q4_error_message(player, Q4): if Q4 != Constants.comp4: return 'Incorrect. 75 - (75 * 0.2) = 75 – 15 = 60. The correct answer is 60. Answer correctly to continue.' def Q5_error_message(player, Q5): if Q5 != Constants.comp5: return 'Incorrect. 95 + (95 * 1) = 190. The correct answer is 190. Answer correctly to continue.' def Q6_error_message(player, Q6): if Q6 != Constants.comp6: return 'Incorrect. The correct answer is 10. Answer correctly to continue.' def det_favor(player): if player.Pay < player.r: favor = True else: favor = False player.favor = favor if favor == True: return 'The reporting error worked in your favor. The top line on the graph indicates your payoff after the ' \ 'reporting error.', player.favor else: return 'The reporting error did not work in your favor. The bottom line on the graph indicates your payoff ' \ 'after the reporting error.', player.favor def calc_payoff(player): multi = random.choice([True, False]) if multi == True: if player.wl == 0: payoff = player.Pay * 1 elif player.wl == 1: payoff = player.Pay * 1.1 elif player.wl == 2: payoff = player.Pay * 1.2 elif player.wl == 3: payoff = player.Pay * 1.3 elif player.wl == 4: payoff = player.Pay * 1.4 elif player.wl == 5: payoff = player.Pay * 1.5 elif player.wl == 6: payoff = player.Pay * 1.6 elif player.wl == 7: payoff = player.Pay * 1.7 elif player.wl == 8: payoff = player.Pay * 1.8 elif player.wl == 9: payoff = player.Pay * 1.9 else: payoff = player.Pay * 2 else: if player.wl == 0: payoff = player.Pay * 1 elif player.wl == 1: payoff = player.Pay * 0.9 elif player.wl == 2: payoff = player.Pay * 0.8 elif player.wl == 3: payoff = player.Pay * 0.7 elif player.wl == 4: payoff = player.Pay * 0.6 elif player.wl == 5: payoff = player.Pay * 0.5 elif player.wl == 6: payoff = player.Pay * 0.4 elif player.wl == 7: payoff = player.Pay * 0.3 elif player.wl == 8: payoff = player.Pay * 0.2 elif player.wl == 9: payoff = player.Pay * 0.1 else: payoff = player.Pay * 0 return payoff def wl_calc_Pay(player, wl): if wl == 0: player.Pay = 60 elif wl == 1: player.Pay = 68 elif wl == 2: player.Pay = 75 elif wl == 3: player.Pay = 81 elif wl == 4: player.Pay = 86 elif wl == 5: player.Pay = 90 elif wl == 6: player.Pay = 93 elif wl == 7: player.Pay = 95 elif wl == 8: player.Pay = 96 elif wl == 9: player.Pay = 96 else: player.Pay = 95 return player.Pay def rank_me(group): id1 = group.get_player_by_id(1) id2 = group.get_player_by_id(2) id3 = group.get_player_by_id(3) if id1.rt > id2.rt and id1.rt > id3.rt and id2.rt > id3.rt: id1.rank = 1 id1.n1 = id1.name id1.rt1 = id1.rt id1.n2 = id2.name id1.rt2 = id2.rt id1.n3 = id3.name id1.rt3 = id3.rt elif id1.rt > id2.rt and id1.rt > id3.rt and id3.rt > id2.rt: id1.rank = 1 id1.n1 = id1.name id1.rt1 = id1.rt id1.n2 = id3.name id1.rt2 = id3.rt id1.n3 = id2.name id1.rt3 = id2.rt elif id1.rt > id2.rt and id1.rt < id3.rt: id1.rank = 2 id1.n1 = id3.name id1.rt1 = id3.rt id1.n2 = id1.name id1.rt2 = id1.rt id1.n3 = id2.name id1.rt3 = id2.rt elif id1.rt < id2.rt and id1.rt > id3.rt: id1.rank = 2 id1.n1 = id2.name id1.rt1 = id2.rt id1.n2 = id1.name id1.rt2 = id1.rt id1.n3 = id3.name id1.rt3 = id3.rt elif id1.rt < id2.rt and id1.rt < id3.rt and id2.rt > id3.rt: id1.rank = 3 id1.n1 = id2.name id1.rt1 = id2.rt id1.n2 = id3.name id1.rt2 = id3.rt id1.n3 = id1.name id1.rt3 = id1.rt else: id1.rank = 3 id1.n1 = id3.name id1.rt1 = id3.rt id1.n2 = id2.name id1.rt2 = id2.rt id1.n3 = id1.name id1.rt3 = id1.rt if id2.rt > id1.rt and id2.rt > id3.rt and id3.rt > id1.rt: id2.rank = 1 id2.n1 = id2.name id2.rt1 = id2.rt id2.n2 = id3.name id2.rt2 = id3.rt id2.n3 = id1.name id2.rt3 = id1.rt elif id2.rt > id1.rt and id2.rt > id3.rt and id3.rt < id1.rt: id2.rank = 1 id2.n1 = id2.name id2.rt1 = id2.rt id2.n2 = id1.name id2.rt2 = id1.rt id2.n3 = id3.name id2.rt3 = id3.rt elif id2.rt > id1.rt and id2.rt < id3.rt: id2.rank = 2 id2.n1 = id3.name id2.rt1 = id3.rt id2.n2 = id2.name id2.rt2 = id2.rt id2.n3 = id1.name id2.rt3 = id1.rt elif id2.rt < id1.rt and id2.rt > id3.rt: id2.rank = 2 id2.n1 = id1.name id2.rt1 = id1.rt id2.n2 = id2.name id2.rt2 = id2.rt id2.n3 = id3.name id2.rt3 = id3.rt elif id2.rt < id3.rt and id2.rt < id1.rt and id1.rt > id3.rt: id2.rank = 3 id2.n1 = id1.name id2.rt1 = id1.rt id2.n2 = id3.name id2.rt2 = id3.rt id2.n3 = id2.name id2.rt3 = id2.rt else: id2.rank = 3 id2.n1 = id3.name id2.rt1 = id3.rt id2.n2 = id1.name id2.rt2 = id1.rt id2.n3 = id2.name id2.rt3 = id2.rt if id3.rt > id2.rt and id3.rt > id1.rt and id1.rt > id2.rt: id3.rank = 1 id3.n1 = id3.name id3.rt1 = id3.rt id3.n2 = id1.name id3.rt2 = id1.rt id3.n3 = id2.name id3.rt3 = id2.rt elif id3.rt > id2.rt and id3.rt > id1.rt and id1.rt < id2.rt: id3.rank = 1 id3.n1 = id3.name id3.rt1 = id3.rt id3.n2 = id2.name id3.rt2 = id2.rt id3.n3 = id1.name id3.rt3 = id1.rt elif id3.rt > id2.rt and id3.rt < id1.rt: id3.rank = 2 id3.n1 = id1.name id3.rt1 = id1.rt id3.n2 = id3.name id3.rt2 = id3.rt id3.n3 = id2.name id3.rt3 = id2.rt elif id3.rt < id2.rt and id3.rt > id1.rt: id3.rank = 2 id3.n1 = id2.name id3.rt1 = id2.rt id3.n2 = id3.name id3.rt2 = id3.rt id3.n3 = id1.name id3.rt3 = id1.rt elif id3.rt < id2.rt and id3.rt < id1.rt and id1.rt > id2.rt: id3.rank = 3 id3.n1 = id1.name id3.rt1 = id1.rt id3.n2 = id2.name id3.rt2 = id2.rt id3.n3 = id3.name id3.rt3 = id3.rt else: id3.rank = 3 id3.n1 = id2.name id3.rt1 = id2.rt id3.n2 = id1.name id3.rt2 = id1.rt id3.n3 = id3.name id3.rt3 = id3.rt group.period += 1 if group.period == 1: group.id1rankp1 = id1.rank group.id2rankp1 = id2.rank group.id3rankp1 = id3.rank return group.id1rankp1, group.id2rankp1, group.id3rankp1, group.period elif group.period == 2: group.id1rankp2 = id1.rank group.id2rankp2 = id2.rank group.id3rankp2 = id3.rank return group.id1rankp2, group.id2rankp2, group.id3rankp2, group.period elif group.period == 3: group.id1rankp3 = id1.rank group.id2rankp3 = id2.rank group.id3rankp3 = id3.rank return group.id1rankp3, group.id2rankp3, group.id3rankp3, group.period elif group.period == 4: group.id1rankp4 = id1.rank group.id2rankp4 = id2.rank group.id3rankp4 = id3.rank return group.id1rankp4, group.id2rankp4, group.id3rankp4, group.period elif group.period == 5: group.id1rankp5 = id1.rank group.id2rankp5 = id2.rank group.id3rankp5 = id3.rank return group.id1rankp5, group.id2rankp5, group.id3rankp5, group.period elif group.period == 6: group.id1rankp6 = id1.rank group.id2rankp6 = id2.rank group.id3rankp6 = id3.rank return group.id1rankp6, group.id2rankp6, group.id3rankp6, group.period elif group.period == 7: group.id1rankp7 = id1.rank group.id2rankp7 = id2.rank group.id3rankp7 = id3.rank return group.id1rankp7, group.id2rankp7, group.id3rankp7, group.period elif group.period == 8: group.id1rankp8 = id1.rank group.id2rankp8 = id2.rank group.id3rankp8 = id3.rank return group.id1rankp8, group.id2rankp8, group.id3rankp8, group.period elif group.period == 9: group.id1rankp9 = id1.rank group.id2rankp9 = id2.rank group.id3rankp9 = id3.rank return group.id1rankp9, group.id2rankp9, group.id3rankp9, group.period elif group.period == 10: group.id1rankf = id1.rank group.id2rankf = id2.rank group.id3rankf = id3.rank return group.id1rankf, group.id2rankf, group.id3rankf, group.period # PAGES class wp(WaitPage): pass # wait_for_all_groups = True # @staticmethod # def after_all_players_arrive(subsession): # subsession.set_group_matrix(Constants.new_structure) class introt(Page): timeout_seconds = 30 timer_text = 'Minimum time remaining before you may advance:' class intro(Page): form_model = 'player' form_fields = ['consent'] class timet(Page): timeout_seconds = 20 timer_text = 'Timer:' class time(Page): pass class pmtt(Page): timeout_seconds = 15 timer_text = 'Timer:' class pmt(Page): pass class overt(Page): timeout_seconds = 25 timer_text = 'Timer:' form_model = 'player' form_fields = ['wlp'] class over(Page): form_model = 'player' form_fields = ['wlp'] class errt(Page): timeout_seconds = 45 timer_text = 'Timer:' class err(Page): pass class feedt(Page): timeout_seconds = 5 timer_text = 'Timer:' class feed(Page): form_model = 'player' form_fields = ['name'] class compq(Page): form_model = 'player' form_fields = ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6'] class ready(Page): pass class wp1(WaitPage): pass class p1(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl1'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl1 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f1 = player.favor class wp2(WaitPage): after_all_players_arrive = rank_me class r1(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p2(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl2'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl2 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f2 = player.favor class wp3(WaitPage): after_all_players_arrive = rank_me class r2(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p3(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl3'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl3 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f3 = player.favor class wp4(WaitPage): after_all_players_arrive = rank_me class r3(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p4(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl4'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl4 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f4 = player.favor class wp5(WaitPage): after_all_players_arrive = rank_me class r4(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p5(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl5'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl5 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f5 = player.favor class wp6(WaitPage): after_all_players_arrive = rank_me class r5(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p6(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl6'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl6 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f6 = player.favor class wp7(WaitPage): after_all_players_arrive = rank_me class r6(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p7(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl7'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl7 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f7 = player.favor class wp8(WaitPage): after_all_players_arrive = rank_me class r7(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p8(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl8'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl8 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f8 = player.favor class wp9(WaitPage): after_all_players_arrive = rank_me class r8(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p9(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl9'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl9 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.f9 = player.favor class wp10(WaitPage): after_all_players_arrive = rank_me class r9(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, x=player.rt ) class p10(Page): timeout_seconds = Constants.timeout form_model = 'player' form_fields = ['wl10'] @staticmethod def before_next_page(player, timeout_happened): player.wl = player.wl10 player.Pay = wl_calc_Pay(player, player.wl) player.r = int(calc_payoff(player)) player.fm = det_favor(player)[0] player.rt = player.rt + player.r player.ff = player.favor class wp11(WaitPage): after_all_players_arrive = rank_me class r10(Page): pass @staticmethod def vars_for_template(player): return dict( r=player.r, w=player.wl, p=player.Pay, f=player.fm, n1=player.n1, n2=player.n2, n3=player.n3, x1=player.rt1, x2=player.rt2, x3=player.rt3, ra=player.rank, x=player.rt ) class peq(Page): form_model = 'player' form_fields = ['peq1', 'peq2', 'peq3', 'peq4', 'peq5', 'peq6', 'peq7', 'peq8', 'peq9', 'peq10', 'peq11'] class sc(Page): form_model = 'player' form_fields = ['sc1', 'sc2', 'sc3', 'sc4', 'sc5', 'sc6'] class op(Page): form_model = 'player' form_fields = ['op1', 'op2', 'op3', 'op4', 'op5', 'op6', 'op7', 'op8', 'op9', 'op10'] class ab(Page): form_model = 'player' form_fields = ['ra1', 'ra2', 'ra3', 'ra4', 'ra5', 'ra6', 'ra7', 'ra8', 'ra9', 'ra10', 'ra11'] # @staticmethod # def app_after_this_page(player, upcoming_apps): # if player.participant.treatment == "AI": # return upcoming_apps[1] class back(Page): form_model = 'player' form_fields = ['background1', 'background2', 'background3', 'background4', 'background5'] class byuid(Page): form_model = 'player' form_fields = ['byuid'] class thanks(Page): pass page_sequence = [wp, introt, intro, timet, time, pmtt, pmt, overt, over, errt, err, feedt, feed, compq, ready, wp1, p1, wp2, r1, p2, wp3, r2, p3, wp4, r3, p4, wp5, r4, p5, wp6, r5, p6, wp7, r6, p7, wp8, r7, p8, wp9, r8, p9, wp10, r9, p10, wp11, r10, peq, sc, op, ab, back, byuid, thanks]