import random from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Task3' PLAYERS_PER_GROUP = None TASKS = ['10u', '10d', '11u', '11d','12u', '12d','13u', '13d','14u', '14d','15u', '15d','16u', '16d','17u', '17d','18u', '18d','19u', '19d'] NUM_ROUNDS = len(TASKS) TIMER_TEXT = " " class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def make_field2(label): return models.IntegerField( choices=[ [1, "1 - Strongly Disagree"], [2, "2"], [3, "3"], [4, "4 - Neither Agree Nor Disagree"], [5, "5"], [6, "6"], [7, "7 - Strongly Agree"] ], label=label, widget=widgets.RadioSelect, ) class Player(BasePlayer): treat = models.IntegerField() task3_q1 = models.BooleanField( label="1. I need to predict the data in this task.", widget=widgets.RadioSelect ) task3_q2 = models.IntegerField( label="2. I can get $___ for 10 correct predictions. ", ) task3_q3 = models.BooleanField( label="3. I will know the correct number of predictions at the end of the experiment.", widget=widgets.RadioSelect ) task3_pre_predict=models.IntegerField(min=0,max=20) predict_10u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_10d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_11u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_11d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_12u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_12d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_13u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_13d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_14u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_14d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_15u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_15d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_16u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_16d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_17u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_17d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_18u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_18d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_19u=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) predict_19d=models.IntegerField(choices=[ [-1, 'Downward'], [+1, 'Upward'], ],initial=0,widget=widgets.RadioSelect) treatment_task3=models.IntegerField() task3_post_predict=models.IntegerField(min=0,max=20) Num_q1=models.FloatField(label="1. If you buy a drink for $0.85 and pay with $1, you should get $____ change.") Num_q2=models.FloatField(label="2. In a sale, a shop is selling all items at half price. Before the sale, a sofa costs $300. It will cost $_____ in the sale.") Num_q3=models.FloatField(label="3. If the chance of getting a disease is 10 per cent, _____ people out of 1,000 would be expected to get the disease.") Num_q4=models.FloatField(label="4. A second hand car dealer is selling a car for $6,000. This is two-thirds of what it cost new. The new car cost $____.") Num_q5=models.FloatField(label="5. If 5 people all have the winning numbers in the lottery and the prize is $2 million, each of them will get $______ million.") Fin_q1=models.IntegerField(choices=[ [1, 'More than today with the money in this account'], [2, 'Exactly the same as today with the money in this account'], [3, 'Less than today with the money in this account'], [4, 'Do not know'], [5, 'Refuse to answer'], ],widget=widgets.RadioSelect,label="6. Imagine that the interest rate on your savings account was 1% per year and inflation was 2% per year. After 1 year, would you be able to buy:" ) Fin_q2=models.FloatField(choices=[ [1, 'True'], [2, 'False'], [3, 'Do not know'], [4, 'Refuse to answer'], ],widget=widgets.RadioSelect,label="7. Do you think that the following statement is true or false? “Bonds are normally riskier than stocks.”") Fin_q3=models.FloatField(choices=[ [1, 'More than $200'], [2, 'Exactly $200'], [3, 'Less than $200'], [4, 'Do not know'], [5, 'Refuse to answer'], ],widget=widgets.RadioSelect,label="8. Suppose you had $100 in a savings account and the interest rate is 20% per year and you never withdraw money or interest payments. After 5 years, how much would you have on this account in total?") invest_choice = models.IntegerField( choices=[ [0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10'], ], label="Your investment choice is:" , widget=widgets.RadioSelectHorizontal ) prob1=models.FloatField(label="In the prediction task you just performed, what is the probability you will be ranked upper half compared to another participant? %______") prob2=models.FloatField(label="In the prediction task you just performed, what is the probability you will be ranked in top 5 compared to 9 other participants? %______") # survey1 Anticipatory1 = make_field2('I tend to imagine a good result because the positive expectation itself makes me happy.') Anticipatory2= make_field2('I tend to imagine a good result, and the longer the positive expectation lasts, the happier I am.') instrumental= make_field2('I tend to imagine a good result to motivate myself to work harder.') Attention = make_field2('This question is to check your attention, please choose "Strongly Agree" in this question.') ego = make_field2('I tend to imagine a good result to maintain a good self-esteem.') # survey2 Bring_best = models.IntegerField( choices=[ [1, '1-not at all like me'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10-exactly like me'], ], label="Competition brings the best out of me" , widget=widgets.RadioSelectHorizontal, ) Will_risk = models.IntegerField( choices=[ [1, '1-Not willing to take risks at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10-Very willing to take risks'], ], label="Are you a person who is usually willing to take risks, or are you " "trying to avoid taking risks. " , widget=widgets.RadioSelectHorizontal, ) # survey3 Gender = models.IntegerField( choices=[ [0, 'Female'], [1, 'Male '], ], label="What is your gender?", widget=widgets.RadioSelectHorizontal, ) Age = models.IntegerField(max=100, label="What is your age?") Ethnicity = models.IntegerField( choices=[ [1, 'Asian'], [2, 'Black '], [3, 'Hispanic-Latino'], [4, 'Native American'], [5, 'White'], [6, 'Other'], ], label="What is your ethnicity?", widget=widgets.RadioSelect, ) Degree = models.IntegerField( choices=[ [1, "Less than high school degree"], [2, "High school graduate (high school diploma or equivalent including GED)"], [4, "Associate degree in college (2-year)"], [5, "Bachelor’s degree in college (4-year)"], [6, "Higher than Bachelor’s degree"], ], label="What is the highest level of school you have completed or the highest degree you have received?", widget=widgets.RadioSelect, ) Income = models.IntegerField( choices=[ [0, 'Less than $10,000 '], [1, '$10,000 to $20,000'], [2, '$20,000 to $30,000 '], [3, '$30,000 to $40,000 '], [4, '$40,000 to $50,000 '], [5, '$50,000 to $60,000'], [6, '$60,000 to $70,000'], [7, '$70,000 to $80,000'], [8, '$80,000 to $90,000'], [9, '$90,000 to $100,000'], [10, '$100,000 to $200,000'], [11, 'Over $200,000'], ], label="What was your total personal income last year? ", widget=widgets.RadioSelect, ) Econ = models.IntegerField( choices=[ [1, 'Yes '], [0, 'No'], ], label="Have you learnt any Economics\Econometric lesson before?", widget=widgets.RadioSelectHorizontal, ) Fin = models.IntegerField( choices=[ [1, 'Yes '], [0, 'No'], ], label="Have you invested in financial market before?", widget=widgets.RadioSelectHorizontal, ) random_task=models.IntegerField() #plot_correct_task3=models.IntegerField(initial=0) is_success = models.BooleanField() invest_result=models.IntegerField(label="Your investment result is:") show=models.IntegerField(initial=0) # FUNCTIONS def creating_session(subsession:Subsession): import itertools treatments = itertools.cycle( itertools.product([17 , 14 , 1 , 6 , 26 , 12 , 27 , 30 , 3 , 2 , 9 , 10 , 22 , 19 , 4 , 16 , 20 , 28 , 13 , 18 , 8 , 21 , 7 , 32 , 29 , 23 , 11 , 25 , 31 , 5 , 15 , 24 ,]) ) for player in subsession.get_players(): treatment = next(treatments) player.treat = treatment[0] # print('player treat is', player.treat) if player.treat == 4 or player.treat == 7 or player.treat == 10 or player.treat == 13 or player.treat == 20 or player.treat == 23 or player.treat == 26 or player.treat == 29: player.treatment_task3 = 2 elif player.treat == 1 or player.treat == 8 or player.treat == 11 or player.treat == 14 or player.treat == 17 or player.treat == 24 or player.treat == 27 or player.treat == 30: player.treatment_task3 = 3 elif player.treat == 2 or player.treat == 5 or player.treat == 12 or player.treat == 15 or player.treat == 18 or player.treat == 21 or player.treat == 28 or player.treat == 31: player.treatment_task3 = 4 else: player.treatment_task3 = 5 if subsession.round_number == 1: for p in subsession.get_players(): round_numbers = list(range(1, C.NUM_ROUNDS+1)) random.shuffle(round_numbers) task3_rounds = dict(zip(C.TASKS, round_numbers)) print('player', p.id_in_subsession) print('task3_rounds is', task3_rounds) p.participant.task3_rounds = task3_rounds def get_timeout_seconds3(player: Player): participant = player.participant import time return participant.expiry3 - time.time() #def is_displayed1(player: Player): # """only returns True if there is time left.""" # return get_timeout_seconds1(player) > 0 class Instructions(Page): form_model = 'player' form_fields = [ 'task3_q1','task3_q2','task3_q3'] @staticmethod def error_message(player: Player, values): if player.treatment_task3 == 2: solutions = dict(task3_q1=True, task3_q2=1, task3_q3=True) elif player.treatment_task3 == 3: solutions = dict(task3_q1=True, task3_q2=1, task3_q3=False) elif player.treatment_task3 == 4: solutions = dict(task3_q1=True, task3_q2=1, task3_q3=True) else: solutions = dict(task3_q1=True, task3_q2=1, task3_q3=False) errors = {name: 'Wrong' for name in solutions if values[name] != solutions[name]} print('errors is', errors) if errors: return 'Wrong answer. Please read the Instructions and answer the understanding questions again.' @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant import time participant.expiry3 = time.time() + 60*5 participant.treatment_task3 = player.treatment_task3 participant.plot_correct_task3 = 0 class Task3_pre_predict(Page): form_model = 'player' form_fields = ['task3_pre_predict'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 and (player.treatment_task3==4 or player.treatment_task3==5) class Task10u(Page): form_model = 'player' form_fields = ['predict_10u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['10u'] and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_10u==-1: participant.plot_correct_task3 += 1 class Task10d(Page): form_model = 'player' form_fields = ['predict_10d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['10d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_10d==1: participant.plot_correct_task3 += 1 class Task11u(Page): form_model = 'player' form_fields = ['predict_11u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['11u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_11u==-1: participant.plot_correct_task3 += 1 class Task11d(Page): form_model = 'player' form_fields = ['predict_11d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['11d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_11d==1: participant.plot_correct_task3 += 1 class Task12u(Page): form_model = 'player' form_fields = ['predict_12u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['12u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_12u==1: participant.plot_correct_task3 += 1 class Task12d(Page): form_model = 'player' form_fields = ['predict_12d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['12d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_12d==-1: participant.plot_correct_task3 += 1 class Task13u(Page): form_model = 'player' form_fields = ['predict_13u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['13u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_13u==-1: participant.plot_correct_task3 += 1 class Task13d(Page): form_model = 'player' form_fields = ['predict_13d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['13d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_13d==1: participant.plot_correct_task3 += 1 class Task14u(Page): form_model = 'player' form_fields = ['predict_14u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['14u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_14u==1: participant.plot_correct_task3 += 1 class Task14d(Page): form_model = 'player' form_fields = ['predict_14d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['14d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_14d==-1: participant.plot_correct_task3 += 1 class Task15u(Page): form_model = 'player' form_fields = ['predict_15u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['15u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_15u==-1: participant.plot_correct_task3 += 1 class Task15d(Page): form_model = 'player' form_fields = ['predict_15d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['15d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_15d==1: participant.plot_correct_task3 += 1 class Task16u(Page): form_model = 'player' form_fields = ['predict_16u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['16u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_16u==1: participant.plot_correct_task3 += 1 class Task16d(Page): form_model = 'player' form_fields = ['predict_16d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['16d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_16d==-1: participant.plot_correct_task3 += 1 class Task17u(Page): form_model = 'player' form_fields = ['predict_17u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['17u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_17u==-1: participant.plot_correct_task3 += 1 class Task17d(Page): form_model = 'player' form_fields = ['predict_17d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['17d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_17d==-1: participant.plot_correct_task3 += 1 class Task18u(Page): form_model = 'player' form_fields = ['predict_18u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['18u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_18u==1: participant.plot_correct_task3 += 1 class Task18d(Page): form_model = 'player' form_fields = ['predict_18d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['18d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_18d==1: participant.plot_correct_task3 += 1 class Task19u(Page): form_model = 'player' form_fields = ['predict_19u'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['19u']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_19u==-1: participant.plot_correct_task3 += 1 class Task19d(Page): form_model = 'player' form_fields = ['predict_19d'] get_timeout_seconds = get_timeout_seconds3 timer_text = C.TIMER_TEXT @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == participant.task3_rounds['19d']and get_timeout_seconds3(player) > 0 @staticmethod def vars_for_template(player): a = player.round_number return dict( a=a, ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if player.predict_19d==1: participant.plot_correct_task3 += 1 class Task3_post_predict(Page): form_model = 'player' form_fields = ['task3_post_predict'] @staticmethod def is_displayed(player: Player): return player.round_number == 20 and (player.treatment_task3==2 or player.treatment_task3==3) class Test(Page): form_model = 'player' form_fields = ['Num_q1','Num_q2','Num_q3','Num_q4','Num_q5','Fin_q1','Fin_q2','Fin_q3'] @staticmethod def is_displayed(player: Player): return player.round_number == 20 @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant print('participant.plot_correct_task3 is',participant.plot_correct_task3) player.random_task = random.choice([1, 2,3]) print('player random_task is ', player.random_task) participant.random_task = player.random_task if player.random_task == 1 and participant.treatment_task1==0: player.show=1 elif player.random_task == 2 and (participant.treatment_task2==2 or participant.treatment_task2==4): player.show = 2 elif player.random_task == 3 and (participant.treatment_task3==2 or participant.treatment_task3==4): player.show = 3 class Investment_Choice(Page): form_model = 'player' form_fields = ['invest_choice'] @staticmethod def is_displayed(player: Player): return player.round_number == 20 class survey3(Page): form_model = 'player' form_fields = ['prob1','prob2', 'Anticipatory1', 'Anticipatory2', 'instrumental', 'ego', 'Attention', 'Bring_best', 'Will_risk'] @staticmethod def is_displayed(player: Player): return player.round_number == 20 @staticmethod def before_next_page(player: Player, timeout_happened): import random player.is_success = random.choice([True, False]) if player.is_success: player.invest_result = player.invest_choice*3 +(10-player.invest_choice) else: player.invest_result = 10-player.invest_choice class survey4(Page): form_model = 'player' form_fields = [ 'Gender', 'Age','Ethnicity', 'Degree','Income','Econ','Fin' ] @staticmethod def is_displayed(player: Player): return player.round_number == 20 class Results(Page): form_model = 'player' # form_fields = ['invest_result'] @staticmethod def is_displayed(player: Player): return player.round_number == 20 @staticmethod def app_after_this_page(player, upcoming_apps): print('upcoming_apps is', upcoming_apps) return "thankyou" # @staticmethod # def app_after_this_page(player, upcoming_apps): # print('upcoming_apps is', upcoming_apps) # if player.treat <=16: # return "Task1" # else: # return "Task2" page_sequence = [Instructions,Task3_pre_predict,Task10u,Task10d,Task11u,Task11d,Task12u,Task12d,Task13u,Task13d,Task14u,Task14d,Task15u,Task15d,Task16u,Task16d,Task17u,Task17d,Task18u,Task18d,Task19u,Task19d,Task3_post_predict,Test,Investment_Choice,survey3,survey4,Results] #page_sequence = [verbalInstructions, verbal_prac_instructions, verbal_prac, verbal_pr_instructions, verbal_pr_predict, verbal_pr, verbal_t_instructions,verbal_t_predict, verbal_t,verbal_choice, # mathInstructions, math_prac_instructions, math_prac, math_pr_instructions,math_pr_predict, # math_pr, math_t_instructions, math_t_predict, math_t, final_predict, math_choice, Investment_Choice, survey1, survey2, survey3, Results] # page_sequence = [survey4, survey4_result]