import random from otree.api import * doc = """ Your app description """ class Subsession(BaseSubsession): pass class Constants(BaseConstants): name_in_url = 'Experiment' players_per_group = 2 endowment = 10 blue_bonus = 0.05 yellow_bonus = 0.10 tasks1 = ['UG', 'Doubled', 'Half', 'DG', 'EarnD', 'EarnR', 'PGG', 'BE'] num_rounds = len(tasks1) + 1 questions = ['UG_1', 'UG_2', 'UG_3', 'UG_4', 'UG_5', 'UG_6', 'UG_7', 'UG_8', 'UG_9', 'UG_10', 'UG_11', 'Doubled_1', 'Doubled_2', 'Doubled_3', 'Doubled_4', 'Doubled_5', 'Doubled_6', 'Doubled_7', 'Doubled_8', 'Doubled_9', 'Doubled_10', 'Doubled_11', 'Half_1', 'Half_2', 'Half_3', 'Half_4', 'Half_5', 'Half_6', 'Half_7', 'Half_8', 'Half_9', 'Half_10', 'Half_11', 'DG_1', 'DG_2', 'DG_3', 'DG_4', 'DG_5', 'DG_6', 'DG_7', 'DG_8', 'DG_9', 'DG_10', 'DG_11', 'EarnR_1', 'EarnR_2', 'EarnR_3', 'EarnR_4', 'EarnR_5', 'EarnR_6', 'EarnR_7', 'EarnR_8', 'EarnR_9', 'EarnR_10', 'EarnR_11', 'EarnD_1', 'EarnD_2', 'EarnD_3', 'EarnD_4', 'EarnD_5', 'EarnD_6', 'EarnD_7', 'EarnD_8', 'EarnD_9', 'EarnD_10', 'EarnD_11', 'N_2', 'C_2', 'N_4', 'C_4', 'N_8', 'C_8', 'N_16', 'C_16', 'PGG1_0', 'PGG1_0', 'PGG1_2', 'PGG1_4', 'PGG1_6', 'PGG1_8', 'PGG1_10', 'PGG2_0', 'PGG2_2', 'PGG2_4', 'PGG2_6', 'PGG2_8', 'PGG2_10', 'PGG3_0', 'PGG3_2', 'PGG3_4', 'PGG3_6', 'PGG3_8', 'PGG3_10', 'PGG4_0', 'PGG4_2', 'PGG4_4', 'PGG4_6', 'PGG4_8', 'PGG4_10'] class Group(BaseGroup): contribution_group = models.CurrencyField rejection_group = models.CurrencyField class Player(BasePlayer): RFT_balls_in_blue = models.IntegerField(min=0, max=20) RFT_balls_in_yellow = models.IntegerField(min=0, max=20) contribution = models.IntegerField(widget=widgets.RadioSelectHorizontal, label="How much will you like to offer to Person B?", choices=[[0, "0€"], [1, "1€"], [2, "2€"], [3, "3€"], [4, "4€"], [5, "5€"], [6, "6€"], [7, "7€"], [8, "8€"], [9, "9€"],[10, "10€"]]) rejection = models.IntegerField(widget=widgets.RadioSelectHorizontal, label="What is the lowest offer you are willing to accept?", choices=[[0, "0€"], [1, "1€"], [2, "2€"], [3, "3€"], [4, "4€"], [5, "5€"], [6, "6€"], [7, "7€"], [8, "8€"], [9, "9€"],[10, "10€"]]) code = models.StringField(label="Insert your code here") treatment = models.StringField() payoff_norms = models.CurrencyField() payoff_rule = models.CurrencyField() payoff_ug = models.CurrencyField() payoff_total = models.CurrencyField() recall = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal, label="Please use a scale from 0 to 10 where 0 means you are “I did not " "remember anything” and a 10 means you are “I did remember everything”. " "You can also use the values in-between to indicate where you fall on the scale.") donation = models.CurrencyField(min=0, max=1000, label="") risk = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal, label="Please use a scale from 0 to 10 where 0 means you are “completely " "unwilling to take risks” and a 10 means you are “very willing " "to take risks”. " "You can also use the values in-between to indicate where you fall on the scale.") altruistic = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal, label=" Please use a scale from 0 to 10, where 0 means you are “completely " "unwilling to share” and a 10 means you are “very willing to share”. " "You can also use the values in-between to indicate where you fall " "on the scale.") rules = models.IntegerField(choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal, label=" Please use a scale from 0 to 10, where 0 means you are “completely " "unwilling to follow rules” and a 10 means you are “very willing to follow " "rules” You can also use the values in-between to indicate where you fall " "on the scale.") # This is for main choices, each variable is one row in the choice table MPL UG_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnR_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) EarnD_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) N_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) C_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) N_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) C_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) N_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) C_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) N_16 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) C_16 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG1_0 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG1_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG1_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG1_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG1_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG1_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG2_0 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG2_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG2_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG2_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG2_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG2_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG3_0 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG3_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG3_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG3_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG3_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG3_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG4_0 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG4_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG4_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG4_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG4_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) PGG4_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) A = models.PositiveIntegerField(choices=[[1, '

Très inapproprié

'], [2, '

Inapproprié

'], [3, '

Plutôt inapproprié

'], [4, '

Plutôt approprié

'], [5, '

Approprié

'], [6, '

Très approprié

']], widget=widgets.RadioSelectHorizontal) B = models.PositiveIntegerField(choices=[[1, '

Très inapproprié

'], [2, '

Inapproprié

'], [3, '

Plutôt inapproprié

'], [4, '

Plutôt approprié

'], [5, '

Approprié

'], [6, '

Très approprié

']], widget=widgets.RadioSelectHorizontal) C = models.PositiveIntegerField(choices=[[1, '

Très inapproprié

'], [2, '

Inapproprié

'], [3, '

Plutôt inapproprié

'], [4, '

Plutôt approprié

'], [5, '

Approprié

'], [6, '

Très approprié

']], widget=widgets.RadioSelectHorizontal) D = models.PositiveIntegerField(choices=[[1, '

Très inapproprié

'], [2, '

Inapproprié

'], [3, '

Plutôt inapproprié

'], [4, '

Plutôt approprié

'], [5, '

Approprié

'], [6, '

Très approprié

']], widget=widgets.RadioSelectHorizontal) # # These variables are collected in the final questionnaire gender = models.StringField(widget=widgets.RadioSelectHorizontal(), choices=['Male', 'Female']) age = models.IntegerField(choices=range(18, 60, 1)) Study = models.TextField(label="What are your current field and level of studies? (example: Law M1). In case you " "are not" " currently studying, what are your last studies?") Nationality = models.TextField(label="What is your nationality? (example: French)") # FUNCTIONS def creating_session(subsession: Subsession): payment = random.sample(range(1, len(Constants.questions)-12), 1) import itertools responses = dict() numberround = dict() for i in Constants.questions: responses[i] = {'Very Inappropriate': 0, 'Inappropriate': 0, 'Rather Inappropriate': 0, 'Rather Appropriate': 0, 'Appropriate': 0, 'Very Appropriate': 0} numberround[i] = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0} subsession.session.vars['responses'] = responses subsession.session.vars['rounds_to_pay'] = payment treatment = itertools.cycle(['A', 'B']) for player in subsession.get_players(): player.payoff_norms = 0 player.payoff_ug = 0 player.payoff_rule = 0 player.payoff_total = 0 player.treatment = next(treatment) player.participant.vars['round'] = numberround if subsession.round_number == 1: T1 = Constants.tasks1.copy() random.shuffle(T1) if player.treatment == 'A': l = ['UG_play'] for i in T1: l.append(i) player.task = l round_numbers = list(range(1, Constants.num_rounds + 1)) player.participant.vars['task_rounds'] = dict(zip(player.task, round_numbers)) else: l = T1 l.append('UG_play') player.task = l round_numbers = list(range(1, Constants.num_rounds + 1)) player.participant.vars['task_rounds'] = dict(zip(player.task, round_numbers)) # if subsession.round_number == 1: # for p in subsession.get_players(): # round_numbers = list(range(1, Constants.num_rounds + 1)) # random.shuffle(round_numbers) # p.participant.vars['task_rounds'] = dict(zip(Constants.tasks, round_numbers)) def set_payoffs(group: Group): random_var = random.uniform(0, 1) p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) if random_var <= 0.5: # p1 proposer and p2 recipient if p1.in_round(1).contribution >= p2.in_round(9).rejection: p1.payoff_ug = 10 - p1.in_round(1).contribution p2.payoff_ug = p1.in_round(1).contribution else: p1.payoff_ug = 0 p2.payoff_ug = 0 else: # p2 proposer and p1 recipient if p2.in_round(9).contribution >= p1.in_round(1).rejection: p2.payoff_ug = 10 - p2.in_round(9).contribution p1.payoff_ug = p2.in_round(9).contribution else: p1.payoff_ug = 0 p2.payoff_ug = 0 for i in group.subsession.session.vars['rounds_to_pay']: vector2 = [] winnerA = keys_with_top_values(group.subsession.session.vars['responses'][Constants.questions[i]]) for k in winnerA: if k == 'Very Inappropriate': vector2.append(1) else: if k == 'Inappropriate': vector2.append(2) else: if k == 'Rather Inappropriate': vector2.append(3) else: if k == 'Rather Appropriate': vector2.append(4) else: if k == 'Appropriate': vector2.append(5) else: vector2.append(6) num = key_with_top_values_int(p1.participant.vars['round'][Constants.questions[i]]) if eval('p1.' + 'in_round' + '(' + 'num' + ').' + Constants.questions[i]) in vector2: p1.payoff_norms = p1.payoff_norms + 8 if i > len(Constants.questions) - 24: j = i + 12 vector3 = [] winnerB = keys_with_top_values(group.subsession.session.vars['responses'][Constants.questions[j]]) for m in winnerB: if m == 'Very Inappropriate': vector3.append(1) else: if m == 'Inappropriate': vector3.append(2) else: if m == 'Rather Inappropriate': vector3.append(3) else: if m == 'Rather Appropriate': vector3.append(4) else: if m == 'Appropriate': vector3.append(5) else: vector3.append(6) num2 = key_with_top_values_int(p2.participant.vars['round'][Constants.questions[j]]) if eval('p2.' + 'in_round(' + 'num2' + ').' + Constants.questions[j]) in vector3: p2.payoff_norms = p2.payoff_norms + 8 else: num2 = key_with_top_values_int(p2.participant.vars['round'][Constants.questions[i]]) if eval('p2.' + 'in_round' + '(' + 'num2' + ').' + Constants.questions[i]) in vector2: p2.payoff_norms = p2.payoff_norms + 8 p1.participant.vars['RFT_balls_in_blue'] = p1.RFT_balls_in_blue p1.participant.vars['RFT_balls_in_yellow'] = p1.RFT_balls_in_yellow p1.participant.vars['RFT_profit'] = p1.payoff p2.participant.vars['RFT_balls_in_blue'] = p2.RFT_balls_in_blue p2.participant.vars['RFT_balls_in_yellow'] = p2.RFT_balls_in_yellow p2.participant.vars['RFT_profit'] = p2.payoff p1.payoff_rule = p1.RFT_balls_in_blue * Constants.blue_bonus + p1.RFT_balls_in_yellow * Constants.yellow_bonus p2.payoff_rule = p2.RFT_balls_in_blue * Constants.blue_bonus + p2.RFT_balls_in_yellow * Constants.yellow_bonus p1.payoff = p1.payoff_norms + p1.payoff_ug + p1.payoff_rule p2.payoff = p2.payoff_norms + p2.payoff_ug + p2.payoff_rule p1.payoff_total = p1.payoff_norms + p1.payoff_ug + p1.payoff_rule + 4 p2.payoff_total = p2.payoff_norms + p2.payoff_ug + p2.payoff_rule + 4 def keys_with_top_values(my_dict): return [key for (key, value) in my_dict.items() if value == max(my_dict.values())] def key_with_top_values_int(d): key = 0 for k, v in d.items(): if v > 0: key = k return int(key) def my_function(subsession): for g in subsession.get_groups(): set_payoffs(g) # PAGES class InstructionsUG(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG_play'] class Contribution1(Page): form_model = 'player' form_fields = ['contribution'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG_play'] class RejectionThreshold(Page): form_model = 'player' form_fields = ['rejection'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG_play'] class ElicitationNormsUG(Page): # which forms are needed from class player form_model = 'player' form_fields = ['UG_1', 'UG_2', 'UG_3', 'UG_4', 'UG_5', 'UG_6', 'UG_7', 'UG_8', 'UG_9', 'UG_10', 'UG_11'] list = form_fields # all 11 options @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsUG.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class ElicitationNormsDoubled(Page): # which forms are needed from class player form_model = 'player' form_fields = ['Doubled_1', 'Doubled_2', 'Doubled_3', 'Doubled_4', 'Doubled_5', 'Doubled_6', 'Doubled_7', 'Doubled_8', 'Doubled_9', 'Doubled_10', 'Doubled_11'] # all 11 options list = form_fields @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsDoubled.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class ElicitationNormsHalf(Page): # which forms are needed from class player form_model = 'player' form_fields = ['Half_1', 'Half_2', 'Half_3', 'Half_4', 'Half_5', 'Half_6', 'Half_7', 'Half_8', 'Half_9', 'Half_10', 'Half_11'] list = form_fields # all 11 options @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsHalf.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class ElicitationNormsDG(Page): # which forms are needed from class player form_model = 'player' form_fields = ['DG_1', 'DG_2', 'DG_3', 'DG_4', 'DG_5', 'DG_6', 'DG_7', 'DG_8', 'DG_9', 'DG_10', 'DG_11'] list = form_fields @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsDG.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class ElicitationNormsEarnR(Page): # which forms are needed from class player form_model = 'player' form_fields = ['EarnR_1', 'EarnR_2', 'EarnR_3', 'EarnR_4', 'EarnR_5', 'EarnR_6', 'EarnR_7', 'EarnR_8', 'EarnR_9', 'EarnR_10', 'EarnR_11'] list = form_fields @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['EarnR'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsEarnR.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class ElicitationNormsEarnD(Page): # which forms are needed from class player form_model = 'player' form_fields = ['EarnD_1', 'EarnD_2', 'EarnD_3', 'EarnD_4', 'EarnD_5', 'EarnD_6', 'EarnD_7', 'EarnD_8', 'EarnD_9', 'EarnD_10', 'EarnD_11'] list = form_fields @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['EarnD'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsEarnD.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class ElicitationNormsPGG_AN1(Page): # which forms are needed from class player form_model = 'player' form_fields = ['PGG1_0', 'PGG1_2', 'PGG1_4', 'PGG1_6', 'PGG1_8', 'PGG1_10', 'PGG2_0', 'PGG2_2', 'PGG2_4', 'PGG2_6', 'PGG2_8', 'PGG2_10'] list = form_fields @staticmethod def is_displayed(player: Player): participant = player.participant return player.treatment == 'A' and player.round_number == player.participant.vars['task_rounds']['PGG'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsPGG_AN1.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class ElicitationNormsPGG_AN2(Page): # which forms are needed from class player form_model = 'player' form_fields = ['PGG3_0', 'PGG3_2', 'PGG3_4', 'PGG3_6', 'PGG3_8', 'PGG3_10', 'PGG4_0', 'PGG4_2', 'PGG4_4', 'PGG4_6', 'PGG4_8', 'PGG4_10'] list = form_fields @staticmethod def is_displayed(player: Player): participant = player.participant return player.treatment == 'B' and player.round_number == player.participant.vars['task_rounds']['PGG'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsPGG_AN2.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class Instructions1(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class ConsentForm(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class GeneralInstructionsExperiment(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class ExampleSituation(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class SituationDescriptionUG(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG'] class SituationDescriptionDoubled(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] class SituationDescriptionHalf(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] class SituationDescriptionDG(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] class SituationDescriptionEarnR(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['EarnR'] class SituationDescriptionEarnD(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['EarnD'] class SituationDescriptionBystander_N(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['BE'] class ElicitationNormsBystander_N(Page): # which forms are needed from class player form_model = 'player' form_fields = ['N_2', 'C_2', 'N_4', 'C_4', 'N_8', 'C_8', 'N_16', 'C_16'] list = form_fields @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['BE'] def before_next_page(player: Player, timeout_happened): for i in ElicitationNormsBystander_N.list: player.participant.vars['round'][i][player.round_number] = player.participant.vars['round'][i][player.round_number] + 1 if eval('player.' + i) == 1: player.session.vars['responses'][i]['Very Inappropriate'] = \ player.session.vars['responses'][i]['Very Inappropriate'] + 1 elif eval('player.' + i) == 2: player.session.vars['responses'][i]['Inappropriate'] = \ player.session.vars['responses'][i]['Inappropriate'] + 1 elif eval('player.' + i) == 3: player.session.vars['responses'][i]['Rather Inappropriate'] = \ player.session.vars['responses'][i]['Rather Inappropriate'] + 1 elif eval('player.' + i) == 4: player.session.vars['responses'][i]['Rather Appropriate'] = \ player.session.vars['responses'][i]['Rather Appropriate'] + 1 elif eval('player.' + i) == 5: player.session.vars['responses'][i]['Appropriate'] = \ player.session.vars['responses'][i]['Appropriate'] + 1 else: player.session.vars['responses'][i]['Very Appropriate'] = \ player.session.vars['responses'][i]['Very Appropriate'] + 1 class SituationDescriptionPGG_AN(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['PGG'] class InstructionsGame(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG_play'] class InstructionsExperiment(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class Code(Page): form_model = 'player' form_fields = ['code'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class QuestionnaireIntro(Page): # forms to retrieve individual information form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class QuestionnaireRecall(Page): # forms to retrieve individual information form_model = 'player' form_fields = ['recall'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class QuestionnaireAltruism1(Page): # forms to retrieve individual information form_model = 'player' form_fields = ['donation'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class QuestionnaireAltruism2(Page): # forms to retrieve individual information form_model = 'player' form_fields = ['altruistic'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class QuestionnaireRisk(Page): # forms to retrieve individual information form_model = 'player' form_fields = ['risk'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class QuestionnairePersonal(Page): # forms to retrieve individual information form_model = 'player' form_fields = ['age', 'gender', 'Nationality', 'Study'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class QuestionnaireRules(Page): # forms to retrieve individual information form_model = 'player' form_fields = ['rules'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class Page2(Page): # forms to retrieve individual information form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class Page3(Page): # forms to retrieve individual information form_model = 'player' form_fields = ['RFT_balls_in_blue', 'RFT_balls_in_yellow'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class ResultsWaitPage(WaitPage): template_name = 'Social_Norms/MyWaitPage.html' wait_for_all_groups = True after_all_players_arrive = my_function @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds class Capture(Page): form_model = 'player' form_fields = ['A', 'B', 'C', 'D'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class Results(Page): form_model = 'player' def vars_for_template(player: Player): if player.id_in_group == 1: return dict(session=player.subsession.session.vars['responses'], payment=player.subsession.session.vars['rounds_to_pay'], max=keys_with_top_values(player.subsession.session.vars['responses']['UG_2']), ms=keys_with_top_values(player.subsession.session.vars['responses']['UG_3']), rule=player.payoff_rule ) if player.id_in_group == 2: return dict(session2=player.subsession.session.vars['responses']) @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds page_sequence = [ConsentForm, Code, GeneralInstructionsExperiment, InstructionsExperiment, InstructionsGame, InstructionsUG, RejectionThreshold, Contribution1, Instructions1, ExampleSituation, SituationDescriptionUG, ElicitationNormsUG, SituationDescriptionDoubled, ElicitationNormsDoubled, SituationDescriptionHalf, ElicitationNormsHalf, SituationDescriptionDG, ElicitationNormsDG, SituationDescriptionPGG_AN, ElicitationNormsPGG_AN1, ElicitationNormsPGG_AN2, SituationDescriptionBystander_N, ElicitationNormsBystander_N, SituationDescriptionEarnR, ElicitationNormsEarnR, SituationDescriptionEarnD, ElicitationNormsEarnD, Page2, Page3, QuestionnaireIntro, QuestionnaireRecall, QuestionnaireRules, QuestionnaireAltruism1, QuestionnaireAltruism2, QuestionnaireRisk, QuestionnairePersonal, ResultsWaitPage, Results]