import json
import random
from otree.api import *
from otree.api import BasePlayer
from otree.api import Page, models
doc = """
Your app description
This experiment studies the incomplete preference and the relationship between incomplete preference and status quo bias
"""
class Constants(BaseConstants):
name_in_url = 'incomplete_preference'
players_per_group = None
tasks_eg = ['egx_1', 'egy_1', 'egx_2', 'egy_2','egx_3','egy_3']
num_rounds_eg = len(tasks_eg)
tasks_exchange = ['x1y1', 'x1y2', 'x1y3', 'x2y1', 'x2y2', 'x2y3', 'x3y1', 'x3y2', 'x3y3']
num_rounds_exchange = len(tasks_exchange)
tasks_refexchange = ['x1y3_x0', 'x1y3_x1', 'x3y1_x0', 'x3y1_x3', 'x2y2_x0', 'x2y2_x2',
'x1y3_y0', 'x1y3_y3', 'x3y1_y0', 'x3y1_y1', 'x2y2_y0', 'x2y2_y2']
num_rounds_refexchange = len(tasks_refexchange)
num_rounds = num_rounds_eg + num_rounds_exchange + num_rounds_refexchange
# these are the endowment parameters
y0 = 7 # initial endowment for money
x0 = 1 # initial endowment for chocolate
dy1 = 3 # extra money 1
dx1 = 2 # extra chocolate 1
dy2 = 5 # extra money 2
dx2 = 4 # extra chocolate 2
dy3 = 8 # extra money 3
dx3 = 6 # extra chocolate 3
# these are the endowment parameters for example
y0_example = 5
x0_example = 1
extra_money_example = 5
extra_chocolate_example = 3
# list of money and chocolate
list_m = list(range(1, 11))
list_c = list(range(1, 11))
# final bundles (initial endowment plus extra payments)
bundle_x0y1_y = y0 + dy1
bundle_x0y1_x = x0
bundle_x1y0_y = y0
bundle_x1y0_x = x0 + dx1
bundle_x0y2_y = y0 + dy2
bundle_x0y2_x = x0
bundle_x2y0_y = y0
bundle_x2y0_x = x0 + dx2
bundle_x0y3_y = y0 + dy3
bundle_x0y3_x = x0
bundle_x3y0_y = y0
bundle_x3y0_x = x0 + dx3
# reference point bundles in robustness questions
bundle_x0_x = x0
bundle_x0_y = 0
bundle_x1_x = x0 + dx1
bundle_x1_y = 0
bundle_x2_x = x0 + dx2
bundle_x2_y = 0
bundle_x3_x = x0 + dx3
bundle_x3_y = 0
bundle_y0_x = 0
bundle_y0_y = y0
bundle_y1_x = 0
bundle_y1_y = y0 + dy1
bundle_y2_x = 0
bundle_y2_y = y0 + dy2
bundle_y3_x = 0
bundle_y3_y = y0 + dy3
# constants for introduction page
num_egquestion = 6
num_exchangequestion = int((num_egquestion/2)*(num_egquestion/2))
num_referencequestion = int(num_egquestion*2)
num_pairwisequestion = int(num_exchangequestion + num_referencequestion)
num_totalquestion = int(num_egquestion + num_pairwisequestion)
# constants for comprehension test
test_chocolate_1 = 1
test_money_1 = 10
test_chocolate_2 = 8
test_money_2 = 5
# prefixs
reference_exchange_fields = [
'x1y3_x0', 'x1y3_x1', 'x3y1_x0', 'x3y1_x3', 'x2y2_x0', 'x2y2_x2',
'x1y3_y0', 'x1y3_y3', 'x3y1_y0', 'x3y1_y1', 'x2y2_y0', 'x2y2_y2'
]
class Subsession(BaseSubsession):
pass
class Group(BaseGroup):
pass
class Player(BasePlayer):
# models needed
egx_1 = models.StringField(blank=True)
egy_1 = models.StringField(blank=True)
egx_2 = models.StringField(blank=True)
egy_2 = models.StringField(blank=True)
egx_3 = models.StringField(blank=True)
egy_3 = models.StringField(blank=True)
exchange_x1y1 = models.StringField(blank=True)
exchange_x1y2 = models.StringField(blank=True)
exchange_x1y3 = models.StringField(blank=True)
exchange_x2y1 = models.StringField(blank=True)
exchange_x2y2 = models.StringField(blank=True)
exchange_x2y3 = models.StringField(blank=True)
exchange_x3y1 = models.StringField(blank=True)
exchange_x3y2 = models.StringField(blank=True)
exchange_x3y3 = models.StringField(blank=True)
refexchange_x1y3_x0 = models.StringField(blank=True)
refexchange_x1y3_x1 = models.StringField(blank=True)
refexchange_x3y1_x0 = models.StringField(blank=True)
refexchange_x3y1_x3 = models.StringField(blank=True)
refexchange_x2y2_x0 = models.StringField(blank=True)
refexchange_x2y2_x2 = models.StringField(blank=True)
refexchange_x1y3_y0 = models.StringField(blank=True)
refexchange_x1y3_y3 = models.StringField(blank=True)
refexchange_x3y1_y0 = models.StringField(blank=True)
refexchange_x3y1_y1 = models.StringField(blank=True)
refexchange_x2y2_y0 = models.StringField(blank=True)
refexchange_x2y2_y2 = models.StringField(blank=True)
exchange_x1y1_num = models.StringField(blank=True)
exchange_x1y2_num = models.StringField(blank=True)
exchange_x1y3_num = models.StringField(blank=True)
exchange_x2y1_num = models.StringField(blank=True)
exchange_x2y2_num = models.StringField(blank=True)
exchange_x2y3_num = models.StringField(blank=True)
exchange_x3y1_num = models.StringField(blank=True)
exchange_x3y2_num = models.StringField(blank=True)
exchange_x3y3_num = models.StringField(blank=True)
refexchange_x1y3_x0_num = models.StringField(blank=True)
refexchange_x1y3_x1_num = models.StringField(blank=True)
refexchange_x3y1_x0_num = models.StringField(blank=True)
refexchange_x3y1_x3_num = models.StringField(blank=True)
refexchange_x2y2_x0_num = models.StringField(blank=True)
refexchange_x2y2_x2_num = models.StringField(blank=True)
refexchange_x1y3_y0_num = models.StringField(blank=True)
refexchange_x1y3_y3_num = models.StringField(blank=True)
refexchange_x3y1_y0_num = models.StringField(blank=True)
refexchange_x3y1_y1_num = models.StringField(blank=True)
refexchange_x2y2_y0_num = models.StringField(blank=True)
refexchange_x2y2_y2_num = models.StringField(blank=True)
# models for example and test
ExampleMPL = models.StringField(blank=True)
test_chocolate_1 = models.IntegerField(blank=True,
label='how many pieces of chocolate will X get?')
test_money_1 = models.CurrencyField(blank=True,
label='how much money will X get?')
test_chocolate_2 = models.IntegerField(blank=True,
label='how many pieces of chocolate will X get?')
test_money_2 = models.CurrencyField(blank=True,
label='how much money will X get?')
# models for comprehension test
correct_test_indicator = models.IntegerField(blank=True)
# randomly choose one number
random_question = models.IntegerField()
random_row_egx = models.IntegerField()
random_row_egy = models.IntegerField()
randomrow_example = models.IntegerField()
example_choice = models.StringField(blank=True)
# payment page
choice = models.StringField()
choice_num = models.StringField()
task_order = models.IntegerField()
row = models.IntegerField()
payment_m = models.FloatField(blank=True)
payment_c = models.IntegerField(blank=True)
payment_question_bundle_1_x = models.IntegerField()
payment_question_bundle_1_y = models.IntegerField()
payment_question_bundle_2_x = models.IntegerField()
payment_question_bundle_2_y = models.IntegerField()
payment_question_bundle_3_x = models.IntegerField()
payment_question_bundle_3_y = models.IntegerField()
treatment_exchange1 = models.StringField()
treatment_exchange2 = models.StringField()
treatment_exchange3 = models.StringField()
treatment_exchange4 = models.StringField()
treatment_exchange5 = models.StringField()
treatment_exchange6 = models.StringField()
treatment_exchange7 = models.StringField()
treatment_exchange8 = models.StringField()
treatment_exchange9 = models.StringField()
task_roundscomp = models.StringField()
# models for time record
time_spent_MPL = models.FloatField()
time_spent_egx_1 = models.FloatField()
time_spent_egy_1 = models.FloatField()
time_spent_egx_2 = models.FloatField()
time_spent_egy_2 = models.FloatField()
time_spent_egx_3 = models.FloatField()
time_spent_egy_3 = models.FloatField()
time_spent_exchange_x1y1 = models.FloatField()
time_spent_exchange_x1y2 = models.FloatField()
time_spent_exchange_x1y3 = models.FloatField()
time_spent_exchange_x2y1 = models.FloatField()
time_spent_exchange_x2y2 = models.FloatField()
time_spent_exchange_x2y3 = models.FloatField()
time_spent_exchange_x3y1 = models.FloatField()
time_spent_exchange_x3y2 = models.FloatField()
time_spent_exchange_x3y3 = models.FloatField()
time_spent_refexchange_x1y3_x0 = models.FloatField()
time_spent_refexchange_x1y3_x1 = models.FloatField()
time_spent_refexchange_x3y1_x0 = models.FloatField()
time_spent_refexchange_x3y1_x3 = models.FloatField()
time_spent_refexchange_x2y2_x0 = models.FloatField()
time_spent_refexchange_x2y2_x2 = models.FloatField()
time_spent_refexchange_x1y3_y0 = models.FloatField()
time_spent_refexchange_x1y3_y3 = models.FloatField()
time_spent_refexchange_x3y1_y0 = models.FloatField()
time_spent_refexchange_x3y1_y1 = models.FloatField()
time_spent_refexchange_x2y2_y0 = models.FloatField()
time_spent_refexchange_x2y2_y2 = models.FloatField()
# models for consent form
fullname = models.StringField()
SID = models.StringField()
attend_date = models.StringField()
consent = models.StringField(blank=True)
optout = models.StringField(blank=True)
# models for payoff
@staticmethod
def vars_for_template(self):
money_rows = {f'money_row{i}': Constants.list_m[i] for i in range(1, len(Constants.list_m))}
# retrieve values from constants and store them in a dictionary
return {
'x0': Constants.x0,
'y0': Constants.y0,
'dx1': Constants.dx1,
'dy1': Constants.dy1,
'dx2': Constants.dx2,
'dy2': Constants.dy2,
'dx3': Constants.dx3,
'dy3': Constants.dy3,
**money_rows
}
def initialize(self):
# Assign a random number to each player
self.participant.vars['random_question'] = random.randint(1, Constants.num_totalquestion) # Adjust the range as needed
self.participant.vars['random_row_egx'] = random.randint(1, len(Constants.list_c))
self.participant.vars['random_row_egy'] = random.randint(1, len(Constants.list_m))
# function
def creating_session(subsession: Subsession):
if subsession.round_number == 1:
for p in subsession.get_players():
round_numbers_eg = list(range(1, Constants.num_rounds_eg + 1))
random.shuffle(round_numbers_eg)
task_eg_rounds = dict(zip(Constants.tasks_eg, round_numbers_eg))
round_numbers_exchange = list(range(Constants.num_rounds_eg + 1,
Constants.num_rounds_eg + Constants.num_rounds_exchange + 1))
random.shuffle(round_numbers_exchange)
task_exchange_rounds = dict(zip(Constants.tasks_exchange, round_numbers_exchange))
round_numbers_refexchange = list(range(Constants.num_rounds_eg + Constants.num_rounds_exchange + 1,
Constants.num_rounds_eg + Constants.num_rounds_exchange
+ Constants.num_rounds_refexchange + 1))
random.shuffle(round_numbers_refexchange)
task_refexchange_rounds = dict(zip(Constants.tasks_refexchange, round_numbers_refexchange))
task_eg_rounds.update(task_exchange_rounds)
task_eg_rounds.update(task_refexchange_rounds)
task_rounds = task_eg_rounds
del task_eg_rounds
del task_exchange_rounds
del task_refexchange_rounds
p.task_roundscomp = json.dumps(task_rounds)
p.participant.vars['task_roundscomp'] = p.task_roundscomp
p.participant.vars['payment_m'] = 0
p.payment_m = p.participant.vars['payment_m']
p.participant.vars['payment_c'] = 0
p.payment_c = p.participant.vars['payment_c']
for i in range(1, int(Constants.num_exchangequestion+1)):
treatment_exchange = ['x', 'y']
treatment_key = f'treatment_exchange{i}'
setattr(p, treatment_key, random.choice(treatment_exchange))
p.participant.vars[treatment_key] = getattr(p, treatment_key)
setattr(p, treatment_key, p.participant.vars[treatment_key])
del treatment_key
for r in range(1, Constants.num_rounds+1):
if 2 <= subsession.round_number == r:
for p in subsession.get_players():
for i in range(1, Constants.num_rounds_exchange+1):
treatment_key = f'treatment_exchange{i}'
setattr(p, treatment_key, p.participant.vars[treatment_key])
p.task_roundscomp = p.participant.vars['task_roundscomp']
p.payment_c = p.participant.vars['payment_c']
p.payment_m = p.participant.vars['payment_m']
labels = ['participant1', 'participant2', 'participant3','participant4','participant5','participant6',
'participant7','participant8','participant9','participant10']
for player, label in zip(subsession.get_players(), labels):
player.participant.label = label
def vars_for_admin_report(subsession: Subsession):
# payoffs = sorted([p.payoff for p in subsession.get_players()])
html = '
'
for p in subsession.get_players():
participant_label = p.participant.label
payoff_m = p.payment_m
payoff_c = p.payment_c
html += f'| {participant_label} | ' +\
f' {payoff_m} | ' +\
f' {payoff_c} | ' +\
f'
'
return {
'html': html
}
# PAGES
class Introduction(Page):
form_model = 'player'
def is_displayed(self):
return self.round_number == 1
@staticmethod
def before_next_page(self: Player, timeout_happened):
self.initialize()
class Consent(Page):
form_model = 'player'
form_fields = ['fullname','SID','attend_date','consent']
def is_displayed(self):
return self.round_number == 1
class section1(Page):
form_model = 'player'
def is_displayed(self):
return self.round_number == 1
class ExampleMPL(Page):
form_model = 'player'
form_fields = ['ExampleMPL','example_choice','time_spent_MPL']
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
participant = self.participant
participant.vars['randomrow_example'] = random.randint(1, len(Constants.list_c))
return{
'x0_example': Constants.x0_example,
'y0_example': Constants.y0_example,
'extra_chocolate_example': Constants.extra_chocolate_example,
'list_c': Constants.list_c,
'len_list_c': len(Constants.list_c),
'randomrow_example': participant.vars['randomrow_example']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
print(f"Before next page: {participant.vars}")
participant.vars['ExampleMPL'] = self.ExampleMPL
participant.vars['Example_choice'] = self.ExampleMPL[participant.vars['randomrow_example']-1]
if participant.vars['Example_choice'] == "L":
participant.vars['Example_payment_c'] = Constants.x0_example
participant.vars['Example_payment_m'] = Constants.y0_example + Constants.extra_money_example
if participant.vars['Example_choice'] == "R":
participant.vars['Example_payment_c'] = Constants.x0_example + participant.vars['randomrow_example']
participant.vars['Example_payment_m'] = Constants.y0_example
print(f"After setting page_start_time: {participant.vars}")
def is_displayed(self):
return self.round_number == 1
class ExampleElicit(Page):
form_model = 'player'
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'randomrow_example': self.participant.vars['randomrow_example'],
'example_choice': self.participant.vars['Example_choice'],
'example_payment_m': self.participant.vars['Example_payment_m'],
'example_payment_c': self.participant.vars['Example_payment_c']
}
def is_displayed(self):
return self.round_number == 1
class Test(Page):
form_model = 'player'
form_fields = ['test_chocolate_1','test_money_1','test_chocolate_2','test_money_2','correct_test_indicator']
def is_displayed(self):
return self.round_number == 1
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['correct_test_indicator'] = self.correct_test_indicator
class PageEGx_1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['egx_1','time_spent_egx_1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'x0': Constants.x0,
'y0': Constants.y0,
'list_c': Constants.list_c,
'len_list_c': len(Constants.list_c),
'task_order': json.loads(self.participant.vars['task_roundscomp'])['egx_1']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['egx_1'] = self.egx_1
@staticmethod
def is_displayed(player: Player):
participant = player.participant
return player.round_number == json.loads(participant.vars['task_roundscomp'])['egx_1']
class PageEGy_1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['egy_1','time_spent_egy_1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'x0': Constants.x0,
'y0': Constants.y0,
'list_m': Constants.list_m,
'len_list_m': len(Constants.list_m),
'task_order': json.loads(self.participant.vars['task_roundscomp'])['egy_1']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['egy_1'] = self.egy_1
@staticmethod
def is_displayed(player: Player):
participant = player.participant
return player.round_number == json.loads(participant.vars['task_roundscomp'])['egy_1']
class PageEGx_2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['egx_2','time_spent_egx_2'] # all 20 options
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'x0': Constants.x0,
'y0': Constants.y0,
'list_c': Constants.list_c,
'len_list_c': len(Constants.list_c),
'task_order': json.loads(self.participant.vars['task_roundscomp'])['egx_2']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['egx_2'] = self.egx_2
@staticmethod
def is_displayed(player: Player):
participant = player.participant
return player.round_number == json.loads(participant.vars['task_roundscomp'])['egx_2']
class PageEGy_2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['egy_2','time_spent_egy_2'] # all 20 options
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'x0': Constants.x0,
'y0': Constants.y0,
'list_m': Constants.list_m,
'len_list_m': len(Constants.list_m),
'task_order': json.loads(self.participant.vars['task_roundscomp'])['egy_2']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['egy_2'] = self.egy_2
@staticmethod
def is_displayed(player: Player):
participant = player.participant
return player.round_number == json.loads(participant.vars['task_roundscomp'])['egy_2']
class PageEGx_3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['egx_3','time_spent_egx_3'] # all 20 options
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'x0': Constants.x0,
'y0': Constants.y0,
'list_c': Constants.list_c,
'len_list_c': len(Constants.list_c),
'task_order': json.loads(self.participant.vars['task_roundscomp'])['egx_3']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['egx_3'] = self.egx_3
@staticmethod
def is_displayed(player: Player):
participant = player.participant
return player.round_number == json.loads(participant.vars['task_roundscomp'])['egx_3']
class PageEGy_3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['egy_3','time_spent_egy_3'] # all 20 options
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'x0': Constants.x0,
'y0': Constants.y0,
'list_m': Constants.list_m,
'len_list_m': len(Constants.list_m),
'task_order': json.loads(self.participant.vars['task_roundscomp'])['egy_3']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['egy_3'] = self.egy_3
@staticmethod
def is_displayed(player: Player):
participant = player.participant
return player.round_number == json.loads(participant.vars['task_roundscomp'])['egy_3']
class section2(Page):
def is_displayed(self: Player):
return self.round_number == Constants.num_rounds_eg+1
class PageExchange_x1y1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x1y1','exchange_x1y1_num','time_spent_exchange_x1y1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y1']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x1y1'] = self.exchange_x1y1
participant.vars['exchange_x1y1_num'] = self.exchange_x1y1_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange1'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y1']
class PageExchange_y1x1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x1y1','exchange_x1y1_num','time_spent_exchange_x1y1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y1']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x1y1'] = self.exchange_x1y1
participant.vars['exchange_x1y1_num'] = self.exchange_x1y1_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange1'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y1']
class PageExchange_x1y2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x1y2','exchange_x1y2_num','time_spent_exchange_x1y2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y2']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x1y2'] = self.exchange_x1y2
participant.vars['exchange_x1y2_num'] = self.exchange_x1y2_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange2'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y2']
class PageExchange_y2x1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x1y2','exchange_x1y2_num','time_spent_exchange_x1y2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y2']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x1y2'] = self.exchange_x1y2
participant.vars['exchange_x1y2_num'] = self.exchange_x1y2_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange2'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y2']
class PageExchange_x1y3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x1y3','exchange_x1y3_num','time_spent_exchange_x1y3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y3']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x1y3'] = self.exchange_x1y3
participant.vars['exchange_x1y3_num'] = self.exchange_x1y3_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange3'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y3']
class PageExchange_y3x1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x1y3','exchange_x1y3_num','time_spent_exchange_x1y3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y3']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x1y3'] = self.exchange_x1y3
participant.vars['exchange_x1y3_num'] = self.exchange_x1y3_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange3'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y3']
class PageExchange_x2y1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x2y1','exchange_x2y1_num','time_spent_exchange_x2y1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y1']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x2y1'] = self.exchange_x2y1
participant.vars['exchange_x2y1_num'] = self.exchange_x2y1_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange4'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y1']
class PageExchange_y1x2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x2y1','exchange_x2y1_num','time_spent_exchange_x2y1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y1']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x2y1'] = self.exchange_x2y1
participant.vars['exchange_x2y1_num'] = self.exchange_x2y1_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange4'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y1']
class PageExchange_x2y2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x2y2','exchange_x2y2_num','time_spent_exchange_x2y2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y2']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x2y2'] = self.exchange_x2y2
participant.vars['exchange_x2y2_num'] = self.exchange_x2y2_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange5'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y2']
class PageExchange_y2x2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x2y2','exchange_x2y2_num','time_spent_exchange_x2y2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y2']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x2y2'] = self.exchange_x2y2
participant.vars['exchange_x2y2_num'] = self.exchange_x2y2_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange5'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y2']
class PageExchange_x2y3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x2y3','exchange_x2y3_num','time_spent_exchange_x2y3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y3']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x2y3'] = self.exchange_x2y3
participant.vars['exchange_x2y3_num'] = self.exchange_x2y3_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange6'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y3']
class PageExchange_y3x2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x2y3','exchange_x2y3_num','time_spent_exchange_x2y3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y3']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x2y3'] = self.exchange_x2y3
participant.vars['exchange_x2y3_num'] = self.exchange_x2y3_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange6'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y3']
class PageExchange_x3y1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x3y1','exchange_x3y1_num','time_spent_exchange_x3y1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y1']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x3y1'] = self.exchange_x3y1
participant.vars['exchange_x3y1_num'] = self.exchange_x3y1_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange7'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y1']
class PageExchange_y1x3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x3y1','exchange_x3y1_num','time_spent_exchange_x3y1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y1']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x3y1'] = self.exchange_x3y1
participant.vars['exchange_x3y1_num'] = self.exchange_x3y1_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange7'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y1']
class PageExchange_x3y2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x3y2','exchange_x3y2_num','time_spent_exchange_x3y2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y2']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x3y2'] = self.exchange_x3y2
participant.vars['exchange_x3y2_num'] = self.exchange_x3y2_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange8'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y2']
class PageExchange_y2x3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x3y2','exchange_x3y2_num','time_spent_exchange_x3y2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y2']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x3y2'] = self.exchange_x3y2
participant.vars['exchange_x3y2_num'] = self.exchange_x3y2_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange8'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y2']
class PageExchange_x3y3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x3y3','exchange_x3y3_num','time_spent_exchange_x3y3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y3']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x3y3'] = self.exchange_x3y3
participant.vars['exchange_x3y3_num'] = self.exchange_x3y3_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange9'] == 'x' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y3']
class PageExchange_y3x3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['exchange_x3y3','exchange_x3y3_num','time_spent_exchange_x3y3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y3']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['exchange_x3y3'] = self.exchange_x3y3
participant.vars['exchange_x3y3_num'] = self.exchange_x3y3_num
def is_displayed(self: Player):
participant = self.participant
return self.participant.vars['treatment_exchange9'] == 'y' and self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y3']
class PageRefexchange_x1y3_x0(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x1y3_x0','refexchange_x1y3_x0_num','time_spent_refexchange_x1y3_x0']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'bundle_x0_y': Constants.bundle_x0_y,
'bundle_x0_x': Constants.bundle_x0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y3_x0']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x1y3_x0'] = self.refexchange_x1y3_x0
participant.vars['refexchange_x1y3_x0_num'] = self.refexchange_x1y3_x0_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y3_x0']
class PageRefexchange_x1y3_x1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x1y3_x1','refexchange_x1y3_x1_num','time_spent_refexchange_x1y3_x1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'bundle_x1_y': Constants.bundle_x1_y,
'bundle_x1_x': Constants.bundle_x1_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y3_x1']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x1y3_x1'] = self.refexchange_x1y3_x1
participant.vars['refexchange_x1y3_x1_num'] = self.refexchange_x1y3_x1_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y3_x1']
class PageRefexchange_x3y1_x0(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x3y1_x0', 'refexchange_x3y1_x0_num','time_spent_refexchange_x3y1_x0']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x0_y': Constants.bundle_x0_y,
'bundle_x0_x': Constants.bundle_x0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y1_x0']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x3y1_x0'] = self.refexchange_x3y1_x0
participant.vars['refexchange_x3y1_x0_num'] = self.refexchange_x3y1_x0_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y1_x0']
class PageRefexchange_x3y1_x3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x3y1_x3', 'refexchange_x3y1_x3_num','time_spent_refexchange_x3y1_x3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_x3_y': Constants.bundle_x3_y,
'bundle_x3_x': Constants.bundle_x3_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y1_x3']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x3y1_x3'] = self.refexchange_x3y1_x3
participant.vars['refexchange_x3y1_x3_num'] = self.refexchange_x3y1_x3_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y1_x3']
class PageRefexchange_x2y2_x0(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x2y2_x0', 'refexchange_x2y2_x0_num','time_spent_refexchange_x2y2_x0']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x0_y': Constants.bundle_x0_y,
'bundle_x0_x': Constants.bundle_x0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y2_x0']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x2y2_x0'] = self.refexchange_x2y2_x0
participant.vars['refexchange_x2y2_x0_num'] = self.refexchange_x2y2_x0_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y2_x0']
class PageRefexchange_x2y2_x2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x2y2_x2', 'refexchange_x2y2_x2_num','time_spent_refexchange_x2y2_x2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_x2_y': Constants.bundle_x2_y,
'bundle_x2_x': Constants.bundle_x2_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y2_x2']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x2y2_x2'] = self.refexchange_x2y2_x2
participant.vars['refexchange_x2y2_x2_num'] = self.refexchange_x2y2_x2_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y2_x2']
class PageRefexchange_x1y3_y0(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x1y3_y0','refexchange_x1y3_y0_num','time_spent_refexchange_x1y3_y0']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'bundle_y0_y': Constants.bundle_y0_y,
'bundle_y0_x': Constants.bundle_y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y3_y0']
}
def before_next_page(self:Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x1y3_y0'] = self.refexchange_x1y3_y0
participant.vars['refexchange_x1y3_y0_num'] = self.refexchange_x1y3_y0_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y3_y0']
class PageRefexchange_x1y3_y3(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x1y3_y3','refexchange_x1y3_y3_num','time_spent_refexchange_x1y3_y3']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return{
'bundle_x0y3_y': Constants.bundle_x0y3_y,
'bundle_x0y3_x': Constants.bundle_x0y3_x,
'bundle_x1y0_y': Constants.bundle_x1y0_y,
'bundle_x1y0_x': Constants.bundle_x1y0_x,
'bundle_y3_y': Constants.bundle_y3_y,
'bundle_y3_x': Constants.bundle_y3_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x1y3_y3']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x1y3_y3'] = self.refexchange_x1y3_y3
participant.vars['refexchange_x1y3_y3_num'] = self.refexchange_x1y3_y3_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x1y3_y3']
class PageRefexchange_x3y1_y0(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x3y1_y0', 'refexchange_x3y1_y0_num','time_spent_refexchange_x3y1_y0']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_y0_y': Constants.bundle_y0_y,
'bundle_y0_x': Constants.bundle_y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y1_y0']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x3y1_y0'] = self.refexchange_x3y1_y0
participant.vars['refexchange_x3y1_y0_num'] = self.refexchange_x3y1_y0_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y1_y0']
class PageRefexchange_x3y1_y1(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x3y1_y1', 'refexchange_x3y1_y1_num','time_spent_refexchange_x3y1_y1']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x3y0_y': Constants.bundle_x3y0_y,
'bundle_x3y0_x': Constants.bundle_x3y0_x,
'bundle_x0y1_y': Constants.bundle_x0y1_y,
'bundle_x0y1_x': Constants.bundle_x0y1_x,
'bundle_y1_y': Constants.bundle_y1_y,
'bundle_y1_x': Constants.bundle_y1_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x3y1_y1']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x3y1_y1'] = self.refexchange_x3y1_y1
participant.vars['refexchange_x3y1_y1_num'] = self.refexchange_x3y1_y1_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x3y1_y1']
class PageRefexchange_x2y2_y0(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x2y2_y0', 'refexchange_x2y2_y0_num','time_spent_refexchange_x2y2_y0']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_y0_y': Constants.bundle_y0_y,
'bundle_y0_x': Constants.bundle_y0_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y2_y0']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x2y2_y0'] = self.refexchange_x2y2_y0
participant.vars['refexchange_x2y2_y0_num'] = self.refexchange_x2y2_y0_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y2_y0']
class PageRefexchange_x2y2_y2(Page):
# which forms are needed from class player
form_model = 'player'
form_fields = ['refexchange_x2y2_y2', 'refexchange_x2y2_y2_num','time_spent_refexchange_x2y2_y2']
# values that are to be displayed (dictionary)
@staticmethod
def vars_for_template(self):
# retrieve values from constants and store them in a dictionary
return {
'bundle_x2y0_y': Constants.bundle_x2y0_y,
'bundle_x2y0_x': Constants.bundle_x2y0_x,
'bundle_x0y2_y': Constants.bundle_x0y2_y,
'bundle_x0y2_x': Constants.bundle_x0y2_x,
'bundle_y2_y': Constants.bundle_y2_y,
'bundle_y2_x': Constants.bundle_y2_x,
'task_order': json.loads(self.participant.vars['task_roundscomp'])['x2y2_y2']
}
def before_next_page(self: Player, timeout_happened):
participant = self.participant
participant.vars['refexchange_x2y2_y2'] = self.refexchange_x2y2_y2
participant.vars['refexchange_x2y2_y2_num'] = self.refexchange_x2y2_y2_num
def is_displayed(self: Player):
participant = self.participant
return self.round_number == json.loads(participant.vars['task_roundscomp'])['x2y2_y2']
class Outcome(Page):
@staticmethod
# payment question and rows
def vars_for_template(self:Player):
# values that are to be displayed (dictionary)
self.random_question = self.participant.vars['random_question']
self.random_row_egx = self.participant.vars['random_row_egx']
self.random_row_egy = self.participant.vars['random_row_egy']
choice_variants = {
1: {'prefix': 'egx_1', 'm_constant': Constants.dy1, 'c_constant': 0, 'list_var': 'list_c'},
2: {'prefix': 'egy_1', 'm_constant': 0, 'c_constant': Constants.dx1, 'list_var': 'list_m'},
3: {'prefix': 'egx_2', 'm_constant': Constants.dy2, 'c_constant': 0, 'list_var': 'list_c'},
4: {'prefix': 'egy_2', 'm_constant': 0, 'c_constant': Constants.dx2, 'list_var': 'list_m'},
5: {'prefix': 'egx_3', 'm_constant': Constants.dy3, 'c_constant': 0, 'list_var': 'list_c'},
6: {'prefix': 'egy_3', 'm_constant': 0, 'c_constant': Constants.dx3, 'list_var': 'list_m'},
}
choice_info = choice_variants.get(self.random_question)
if choice_info:
prefix = choice_info['prefix']
self.choice = self.participant.vars[prefix][self.random_row_egx - 1]
self.row = self.random_row_egx
self.task_order = json.loads(self.participant.vars['task_roundscomp'])[prefix]
if self.choice == "L":
self.payment_m = Constants.y0 + choice_info['m_constant']
self.payment_c = Constants.x0 + choice_info['c_constant']
elif self.choice == "R":
self.payment_m = Constants.y0 + getattr(Constants, choice_info['list_var'])[self.random_row_egx - 1]
self.payment_c = Constants.x0
if self.random_question <= 6:
self.choice_num = "9999"
self.payment_question_bundle_1_x = 9999
self.payment_question_bundle_1_y = 9999
self.payment_question_bundle_2_x = 9999
self.payment_question_bundle_2_y = 9999
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if 7 <= self.random_question <= 27:
choices_mapping = {
7: (self.participant.vars['exchange_x1y1'], self.participant.vars['exchange_x1y1_num']),
8: (self.participant.vars['exchange_x1y2'], self.participant.vars['exchange_x1y2_num']),
9: (self.participant.vars['exchange_x1y3'], self.participant.vars['exchange_x1y3_num']),
10: (self.participant.vars['exchange_x2y1'], self.participant.vars['exchange_x2y1_num']),
11: (self.participant.vars['exchange_x2y2'], self.participant.vars['exchange_x2y2_num']),
12: (self.participant.vars['exchange_x2y3'], self.participant.vars['exchange_x2y3_num']),
13: (self.participant.vars['exchange_x3y1'], self.participant.vars['exchange_x3y1_num']),
14: (self.participant.vars['exchange_x3y2'], self.participant.vars['exchange_x3y2_num']),
15: (self.participant.vars['exchange_x3y3'], self.participant.vars['exchange_x3y3_num']),
16: (self.participant.vars['refexchange_x1y3_x0'], self.participant.vars['refexchange_x1y3_x0_num']),
17: (self.participant.vars['refexchange_x1y3_x1'], self.participant.vars['refexchange_x1y3_x1_num']),
18: (self.participant.vars['refexchange_x3y1_x0'], self.participant.vars['refexchange_x3y1_x0_num']),
19: (self.participant.vars['refexchange_x3y1_x3'], self.participant.vars['refexchange_x3y1_x3_num']),
20: (self.participant.vars['refexchange_x2y2_x0'], self.participant.vars['refexchange_x2y2_x0_num']),
21: (self.participant.vars['refexchange_x2y2_x2'], self.participant.vars['refexchange_x2y2_x2_num']),
22: (self.participant.vars['refexchange_x1y3_y0'], self.participant.vars['refexchange_x1y3_y0_num']),
23: (self.participant.vars['refexchange_x1y3_y3'], self.participant.vars['refexchange_x1y3_y3_num']),
24: (self.participant.vars['refexchange_x3y1_y0'], self.participant.vars['refexchange_x3y1_y0_num']),
25: (self.participant.vars['refexchange_x3y1_y1'], self.participant.vars['refexchange_x3y1_y1_num']),
26: (self.participant.vars['refexchange_x2y2_y0'], self.participant.vars['refexchange_x2y2_y0_num']),
27: (self.participant.vars['refexchange_x2y2_y2'], self.participant.vars['refexchange_x2y2_y2_num']),
}
self.choice, self.choice_num = choices_mapping[self.random_question]
self.row = 9999
if self.random_question == 7:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x1y1']
if self.participant.vars['treatment_exchange1'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x1y0_x
self.payment_question_bundle_1_y = Constants.bundle_x1y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y1_x
self.payment_question_bundle_2_y = Constants.bundle_x0y1_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange1'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y1_x
self.payment_question_bundle_1_y = Constants.bundle_x0y1_y
self.payment_question_bundle_2_x = Constants.bundle_x1y0_x
self.payment_question_bundle_2_y = Constants.bundle_x1y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 8:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x1y2']
if self.participant.vars['treatment_exchange2'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x1y0_x
self.payment_question_bundle_1_y = Constants.bundle_x1y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y2_x
self.payment_question_bundle_2_y = Constants.bundle_x0y2_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange2'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y2_x
self.payment_question_bundle_1_y = Constants.bundle_x0y2_y
self.payment_question_bundle_2_x = Constants.bundle_x1y0_x
self.payment_question_bundle_2_y = Constants.bundle_x1y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 9:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x1y3']
if self.participant.vars['treatment_exchange3'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x1y0_x
self.payment_question_bundle_1_y = Constants.bundle_x1y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y3_x
self.payment_question_bundle_2_y = Constants.bundle_x0y3_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange3'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y3_x
self.payment_question_bundle_1_y = Constants.bundle_x0y3_y
self.payment_question_bundle_2_x = Constants.bundle_x1y0_x
self.payment_question_bundle_2_y = Constants.bundle_x1y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 10:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x2y1']
if self.participant.vars['treatment_exchange4'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x2y0_x
self.payment_question_bundle_1_y = Constants.bundle_x2y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y1_x
self.payment_question_bundle_2_y = Constants.bundle_x0y1_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange4'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y1_x
self.payment_question_bundle_1_y = Constants.bundle_x0y1_y
self.payment_question_bundle_2_x = Constants.bundle_x2y0_x
self.payment_question_bundle_2_y = Constants.bundle_x2y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 11:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x2y2']
if self.participant.vars['treatment_exchange5'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x2y0_x
self.payment_question_bundle_1_y = Constants.bundle_x2y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y2_x
self.payment_question_bundle_2_y = Constants.bundle_x0y2_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange5'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y2_x
self.payment_question_bundle_1_y = Constants.bundle_x0y2_y
self.payment_question_bundle_2_x = Constants.bundle_x2y0_x
self.payment_question_bundle_2_y = Constants.bundle_x2y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 12:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x2y3']
if self.participant.vars['treatment_exchange6'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x2y0_x
self.payment_question_bundle_1_y = Constants.bundle_x2y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y3_x
self.payment_question_bundle_2_y = Constants.bundle_x0y3_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange6'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y3_x
self.payment_question_bundle_1_y = Constants.bundle_x0y3_y
self.payment_question_bundle_2_x = Constants.bundle_x2y0_x
self.payment_question_bundle_2_y = Constants.bundle_x2y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 13:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x3y1']
if self.participant.vars['treatment_exchange7'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x3y0_x
self.payment_question_bundle_1_y = Constants.bundle_x3y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y1_x
self.payment_question_bundle_2_y = Constants.bundle_x0y1_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange7'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y1_x
self.payment_question_bundle_1_y = Constants.bundle_x0y1_y
self.payment_question_bundle_2_x = Constants.bundle_x3y0_x
self.payment_question_bundle_2_y = Constants.bundle_x3y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 14:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x3y2']
if self.participant.vars['treatment_exchange8'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x3y0_x
self.payment_question_bundle_1_y = Constants.bundle_x3y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y2_x
self.payment_question_bundle_2_y = Constants.bundle_x0y2_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange8'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y2_x
self.payment_question_bundle_1_y = Constants.bundle_x0y2_y
self.payment_question_bundle_2_x = Constants.bundle_x3y0_x
self.payment_question_bundle_2_y = Constants.bundle_x3y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 15:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x3y3']
if self.participant.vars['treatment_exchange9'] == 'x':
self.payment_question_bundle_1_x = Constants.bundle_x3y0_x
self.payment_question_bundle_1_y = Constants.bundle_x3y0_y
self.payment_question_bundle_2_x = Constants.bundle_x0y3_x
self.payment_question_bundle_2_y = Constants.bundle_x0y3_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.participant.vars['treatment_exchange9'] == 'y':
self.payment_question_bundle_1_x = Constants.bundle_x0y3_x
self.payment_question_bundle_1_y = Constants.bundle_x0y3_y
self.payment_question_bundle_2_x = Constants.bundle_x3y0_x
self.payment_question_bundle_2_y = Constants.bundle_x3y0_y
self.payment_question_bundle_3_x = 9999
self.payment_question_bundle_3_y = 9999
if self.random_question == 16:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x1y3_x0']
self.payment_question_bundle_1_x = Constants.bundle_x0_x
self.payment_question_bundle_1_y = Constants.bundle_x0_y
self.payment_question_bundle_2_x = Constants.bundle_x1y0_x
self.payment_question_bundle_2_y = Constants.bundle_x1y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y3_x
self.payment_question_bundle_3_y = Constants.bundle_x0y3_y
if self.random_question == 17:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x1y3_x1']
self.payment_question_bundle_1_x = Constants.bundle_x1_x
self.payment_question_bundle_1_y = Constants.bundle_x1_y
self.payment_question_bundle_2_x = Constants.bundle_x1y0_x
self.payment_question_bundle_2_y = Constants.bundle_x1y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y3_x
self.payment_question_bundle_3_y = Constants.bundle_x0y3_y
if self.random_question == 18:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x3y1_x0']
self.payment_question_bundle_1_x = Constants.bundle_x0_x
self.payment_question_bundle_1_y = Constants.bundle_x0_y
self.payment_question_bundle_2_x = Constants.bundle_x3y0_x
self.payment_question_bundle_2_y = Constants.bundle_x3y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y1_x
self.payment_question_bundle_3_y = Constants.bundle_x0y1_y
if self.random_question == 19:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x3y1_x3']
self.payment_question_bundle_1_x = Constants.bundle_x3_x
self.payment_question_bundle_1_y = Constants.bundle_x3_y
self.payment_question_bundle_2_x = Constants.bundle_x3y0_x
self.payment_question_bundle_2_y = Constants.bundle_x3y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y1_x
self.payment_question_bundle_3_y = Constants.bundle_x0y1_y
if self.random_question == 20:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x2y2_x0']
self.payment_question_bundle_1_x = Constants.bundle_x0_x
self.payment_question_bundle_1_y = Constants.bundle_x0_y
self.payment_question_bundle_2_x = Constants.bundle_x2y0_x
self.payment_question_bundle_2_y = Constants.bundle_x2y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y2_x
self.payment_question_bundle_3_y = Constants.bundle_x0y2_y
if self.random_question == 21:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x2y2_x2']
self.payment_question_bundle_1_x = Constants.bundle_x2_x
self.payment_question_bundle_1_y = Constants.bundle_x2_y
self.payment_question_bundle_2_x = Constants.bundle_x2y0_x
self.payment_question_bundle_2_y = Constants.bundle_x2y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y2_x
self.payment_question_bundle_3_y = Constants.bundle_x0y2_y
if self.random_question == 22:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x1y3_y0']
self.payment_question_bundle_1_x = Constants.bundle_y0_x
self.payment_question_bundle_1_y = Constants.bundle_y0_y
self.payment_question_bundle_2_x = Constants.bundle_x1y0_x
self.payment_question_bundle_2_y = Constants.bundle_x1y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y3_x
self.payment_question_bundle_3_y = Constants.bundle_x0y3_y
if self.random_question == 23:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x1y3_y3']
self.payment_question_bundle_1_x = Constants.bundle_y3_x
self.payment_question_bundle_1_y = Constants.bundle_y3_y
self.payment_question_bundle_2_x = Constants.bundle_x1y0_x
self.payment_question_bundle_2_y = Constants.bundle_x1y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y3_x
self.payment_question_bundle_3_y = Constants.bundle_x0y3_y
if self.random_question == 24:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x3y1_y0']
self.payment_question_bundle_1_x = Constants.bundle_y0_x
self.payment_question_bundle_1_y = Constants.bundle_y0_y
self.payment_question_bundle_2_x = Constants.bundle_x3y0_x
self.payment_question_bundle_2_y = Constants.bundle_x3y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y1_x
self.payment_question_bundle_3_y = Constants.bundle_x0y1_y
if self.random_question == 25:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x3y1_y1']
self.payment_question_bundle_1_x = Constants.bundle_y1_x
self.payment_question_bundle_1_y = Constants.bundle_y1_y
self.payment_question_bundle_2_x = Constants.bundle_x3y0_x
self.payment_question_bundle_2_y = Constants.bundle_x3y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y1_x
self.payment_question_bundle_3_y = Constants.bundle_x0y1_y
if self.random_question == 26:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x2y2_y0']
self.payment_question_bundle_1_x = Constants.bundle_y0_x
self.payment_question_bundle_1_y = Constants.bundle_y0_y
self.payment_question_bundle_2_x = Constants.bundle_x2y0_x
self.payment_question_bundle_2_y = Constants.bundle_x2y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y2_x
self.payment_question_bundle_3_y = Constants.bundle_x0y2_y
if self.random_question == 27:
self.task_order = json.loads(self.participant.vars['task_roundscomp'])['x2y2_y2']
self.payment_question_bundle_1_x = Constants.bundle_y2_x
self.payment_question_bundle_1_y = Constants.bundle_y2_y
self.payment_question_bundle_2_x = Constants.bundle_x2y0_x
self.payment_question_bundle_2_y = Constants.bundle_x2y0_y
self.payment_question_bundle_3_x = Constants.bundle_x0y2_x
self.payment_question_bundle_3_y = Constants.bundle_x0y2_y
bundle_mapping = {
"x0y1": (Constants.bundle_x0y1_y, Constants.bundle_x0y1_x),
"x1y0": (Constants.bundle_x1y0_y, Constants.bundle_x1y0_x),
"x0y2": (Constants.bundle_x0y2_y, Constants.bundle_x0y2_x),
"x2y0": (Constants.bundle_x2y0_y, Constants.bundle_x2y0_x),
"x0y3": (Constants.bundle_x0y3_y, Constants.bundle_x0y3_x),
"x3y0": (Constants.bundle_x3y0_y, Constants.bundle_x3y0_x),
"x0": (Constants.bundle_x0_y, Constants.bundle_x0_x),
"x1": (Constants.bundle_x1_y, Constants.bundle_x1_x),
"x2": (Constants.bundle_x2_y, Constants.bundle_x2_x),
"x3": (Constants.bundle_x3_y, Constants.bundle_x3_x),
"y0": (Constants.bundle_y0_y, Constants.bundle_y0_x),
"y1": (Constants.bundle_y1_y, Constants.bundle_y1_x),
"y2": (Constants.bundle_y2_y, Constants.bundle_y2_x),
"y3": (Constants.bundle_y3_y, Constants.bundle_y3_x),
}
if self.choice in bundle_mapping:
self.payment_m, self.payment_c = bundle_mapping[self.choice]
self.payoff = self.payment_m
# if self.participant.vars['correct_test_indicator'] == 1:
# self.payment_m = self.payment_m + 0.5
return{
'random_question': self.random_question,
'random_row_egx': self.random_row_egx,
'random_row_egy': self.random_row_egy,
'payment_m': self.payment_m,
'payment_c': self.payment_c,
'payment_question': self.random_question,
'payment_row': self.row,
'payment_question_choice': self.choice,
'payment_question_choice_num' : self.choice_num,
'payment_question_order' : self.task_order,
'payment_question_bundle_1_x': self.payment_question_bundle_1_x,
'payment_question_bundle_1_y': self.payment_question_bundle_1_y,
'payment_question_bundle_2_x': self.payment_question_bundle_2_x,
'payment_question_bundle_2_y': self.payment_question_bundle_2_y,
'payment_question_bundle_3_x': self.payment_question_bundle_3_x,
'payment_question_bundle_3_y': self.payment_question_bundle_3_y
}
def is_displayed(self: Player):
return self.round_number == Constants.num_rounds
class final(Page):
def is_displayed(self: Player):
return self.round_number == Constants.num_rounds
page_sequence = [Consent,Introduction, section1, ExampleMPL, ExampleElicit, Test, PageEGx_1, PageEGy_1,PageEGx_2, PageEGy_2,
PageEGx_3, PageEGy_3, section2,
PageExchange_x1y1, PageExchange_y1x1, PageExchange_x1y2, PageExchange_y2x1, PageExchange_x1y3, PageExchange_y3x1,
PageExchange_x2y1, PageExchange_y1x2, PageExchange_x2y2, PageExchange_y2x2, PageExchange_x2y3, PageExchange_y3x2,
PageExchange_x3y1, PageExchange_y1x3, PageExchange_x3y2, PageExchange_y2x3, PageExchange_x3y3, PageExchange_y3x3,
PageRefexchange_x1y3_x0, PageRefexchange_x1y3_x1, PageRefexchange_x3y1_x0, PageRefexchange_x3y1_x3,
PageRefexchange_x2y2_x0, PageRefexchange_x2y2_x2,
PageRefexchange_x1y3_y0, PageRefexchange_x1y3_y3, PageRefexchange_x3y1_y0, PageRefexchange_x3y1_y1,
PageRefexchange_x2y2_y0, PageRefexchange_x2y2_y2,
Outcome,final]