from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import csv import random import time import xlrd # for reading XLS-files import math # import xlsxwriter module import xlsxwriter from random import choice ########### ALL INSTRUCTION PAGES class A_Intro_Title(Page): form_model = 'player' form_fields = ['tab_intro_title_part2', 'focus_intro_title_part2', 'totaltime_intro_title_part2'] def is_displayed(self): return self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/A_Intro_Title.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) confirm = sheet.cell_value(2, Constants.language_code) return dict( title = title, confirm = confirm ) def before_next_page(self): # load lottery-data from part 1 try: # lottery A self.player.lotteryA_low = self.participant.vars['lotteryA'][0] self.player.lotteryA_high = self.participant.vars['lotteryA'][1] self.player.probA_low = self.participant.vars['lotteryA'][2] self.player.probA_high = self.participant.vars['lotteryA'][3] # lottery B self.player.lotteryB_low = self.participant.vars['lotteryB'][0] self.player.lotteryB_high = self.participant.vars['lotteryB'][1] self.player.probB_low = self.participant.vars['lotteryB'][2] self.player.probB_high = self.participant.vars['lotteryB'][3] except: # lottery A self.player.lotteryA_low = 600 self.player.lotteryA_high = 1600 self.player.probA_low = 0.25 self.player.probA_high = 0.75 # lottery B self.player.lotteryB_low = 600 self.player.lotteryB_high = 2107.1 self.player.probB_low = 0.5 self.player.probB_high = 0.5 # load other data from part 1 try: # payoff-relevant round part 1 self.player.payoffrelevant_round_part1 = self.participant.vars['payoffrelevant_round_part1'] # lottery payoffs from payoff-relevant lottery self.player.payoffrelevant_round_part1_low = self.participant.vars['lotterychoice_part1_low'] self.player.payoffrelevant_round_part1_high = self.participant.vars['lotterychoice_part1_high'] # selected lottery from payoff-relevant round part 1 self.player.lotterychoice_part1 = self.participant.vars['lotterychoice_part1'] # payoff part 1 self.player.payoff_part1 = self.participant.vars['payoff_part1'] except: self.player.payoffrelevant_round_part1 = 0 self.player.payoffrelevant_round_part1_low = 0.0 self.player.payoffrelevant_round_part1_high = 0.0 self.player.lotterychoice_part1 = 0 self.player.payoff_part1 = 0 #### Prepare lottery outcomes: make a random draw from BOTH possible lotteries! draw = random.randint(1, 100) if (draw / 100 < self.player.probA_low): self.player.drawC = self.player.lotteryA_low else: self.player.drawC = self.player.lotteryA_high if (draw / 100 < self.player.probB_low): self.player.drawD = self.player.lotteryB_low else: self.player.drawD = self.player.lotteryB_high class CountPage(Page): form_model = 'player' def before_next_page(self): self.player.affiliation = self.participant.vars['affiliaiton'] def vars_for_template(self): affiliation = self.player.affiliation return dict( affiliation=affiliation ) class B_Intro_Types(Page): def is_displayed(self): return self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/B_Intro_Types.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) confirm = sheet.cell_value(3, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, confirm = confirm, ) class The_Other_ParticipantBASE(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.player.version == 'BASE' and self.round_number == 1 def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/The_Other_ParticipantBASE.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class The_Other_ParticipantDEM(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.player.version == 'DEMO' and self.round_number == 1 def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/The_Other_ParticipantDEM.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class The_Other_ParticipantREP(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.player.version == 'REPU' and self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/The_Other_ParticipantREP.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class The_Other_ParticipantMALE(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.player.version == 'MALE' and self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/The_Other_ParticipantMALE.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class The_Other_ParticipantFEMALE(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.player.version == 'FEMALE' and self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/The_Other_ParticipantFEMALE.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class The_Other_ParticipantPIC1(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.player.version == 'PIC1' and self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/The_Other_ParticipantPIC1.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class The_Other_ParticipantPIC2(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.player.version == 'PIC2' and self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/The_Other_ParticipantPIC2.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class C_Intro_General(Page): form_model = 'player' form_fields = ['tab_general_part2', 'focus_general_part2', 'totaltime_general_part2'] def is_displayed(self): return self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/C_Intro_General.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) return dict( title = title, paragraph1 = paragraph1, paragraph2 = paragraph2, paragraph3 = paragraph3, confirm = confirm, ) class D_Description_Lotteries_seq(Page): form_model = 'player' form_fields = ['tab_desc_lotteries_part2', 'focus_desc_lotteries_part2', 'totaltime_desc_lotteries_part2'] def is_displayed(self): return self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/D_Description_Lotteries.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) # create shortcut for variable assignment q = self.player.in_round(1) return dict( title=title, paragraph1=paragraph1, # "{:.2f}".format(x) is used for displaying the numbers with EXACTLY 2 decimal positions paragraph2=paragraph2.format(lotteryA_high="{:.0f}".format(q.lotteryA_high), lotteryA_low="{:.0f}".format(q.lotteryA_low), currency=Constants.currency), paragraph3=paragraph3.format(lotteryB_high="{:.1f}".format(q.lotteryB_high), lotteryB_low="{:.0f}".format(q.lotteryB_low), currency=Constants.currency), confirm=confirm, lotteryA_high= round(q.lotteryA_high,0), lotteryA_low = round(q.lotteryA_low, 0), lotteryB_high= round(q.lotteryB_high, 0), lotteryB_low = round(q.lotteryB_low, 0), currency = Constants.currency, ) class D_Description_Lotteries(Page): form_model = 'player' form_fields = ['tab_desc_lotteries_part2', 'focus_desc_lotteries_part2', 'totaltime_desc_lotteries_part2'] def is_displayed(self): return self.round_number == 1 # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/D_Description_Lotteries.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) paragraph2 = sheet.cell_value(3, Constants.language_code) paragraph3 = sheet.cell_value(4, Constants.language_code) confirm = sheet.cell_value(5, Constants.language_code) # create shortcut for variable assignment q = self.player.in_round(1) return dict( title = title, paragraph1 = paragraph1, # "{:.2f}".format(x) is used for displaying the numbers with EXACTLY 2 decimal positions paragraph2 = paragraph2.format(lotteryA_high = "{:.0f}".format(q.lotteryA_high), lotteryA_low = "{:.0f}".format(q.lotteryA_low), currency = Constants.currency), paragraph3 = paragraph3.format(lotteryB_high = "{:.1f}".format(q.lotteryB_high), lotteryB_low = "{:.0f}".format(q.lotteryB_low), currency = Constants.currency), confirm = confirm, ) class E_Description_Choice(Page): form_model = 'player' form_fields = ['ControlQuestion1', 'ControlQuestion2', 'ControlQuestion3', 'ControlQuestion4', 'counterWrong', 'tab_desc_choice_part2', 'focus_desc_choice_part2', 'totaltime_desc_choice_part2'] def is_displayed(self): return self.round_number == 1 and self.player.version == 'BASE' # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/E_Description_Choice.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) table_title = sheet.cell_value(3, Constants.language_code) table11 = sheet.cell_value(4, Constants.language_code) table21 = sheet.cell_value(5, Constants.language_code) table122 = sheet.cell_value(6, Constants.language_code) table13 = sheet.cell_value(7, Constants.language_code) table23 = sheet.cell_value(8, Constants.language_code) table14 = sheet.cell_value(9, Constants.language_code) table24 = sheet.cell_value(10, Constants.language_code) table15 = sheet.cell_value(11, Constants.language_code) table25 = sheet.cell_value(12, Constants.language_code) table16 = sheet.cell_value(13, Constants.language_code) table26 = sheet.cell_value(14, Constants.language_code) paragraph2 = sheet.cell_value(15, Constants.language_code) confirm = sheet.cell_value(16, Constants.language_code) return dict( title = title, paragraph1 = paragraph1.format(num_rounds = Constants.num_rounds), paragraph2 = paragraph2.format(num_rounds = Constants.num_rounds), table_title = table_title, table11 = table11, table21 = table21, table122 = table122, table13 = table13, table23 = table23, table14 = table14, table24 = table24, table15 = table15, table25 = table25, table16 = table16, table26 = table26, confirm = confirm, ) class E_Description_ChoiceDEM(Page): form_model = 'player' form_fields = ['ControlQuestion1', 'ControlQuestion2', 'ControlQuestion3', 'ControlQuestion4', 'counterWrong', 'tab_desc_choice_part2', 'focus_desc_choice_part2', 'totaltime_desc_choice_part2'] def is_displayed(self): return self.round_number == 1 and self.player.version == 'DEMO' # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/E_Description_Choice.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) table_title = sheet.cell_value(3, Constants.language_code) table11 = sheet.cell_value(4, Constants.language_code) table21 = sheet.cell_value(5, Constants.language_code) table122 = sheet.cell_value(6, Constants.language_code) table13 = sheet.cell_value(7, Constants.language_code) table23 = sheet.cell_value(8, Constants.language_code) table14 = sheet.cell_value(9, Constants.language_code) table24 = sheet.cell_value(10, Constants.language_code) table15 = sheet.cell_value(11, Constants.language_code) table25 = sheet.cell_value(12, Constants.language_code) table16 = sheet.cell_value(13, Constants.language_code) table26 = sheet.cell_value(14, Constants.language_code) paragraph2 = sheet.cell_value(15, Constants.language_code) confirm = sheet.cell_value(16, Constants.language_code) return dict( title = title, paragraph1 = paragraph1.format(num_rounds = Constants.num_rounds), paragraph2 = paragraph2.format(num_rounds = Constants.num_rounds), table_title = table_title, table11 = table11, table21 = table21, table122 = table122, table13 = table13, table23 = table23, table14 = table14, table24 = table24, table15 = table15, table25 = table25, table16 = table16, table26 = table26, confirm = confirm, ) class E_Description_ChoiceREP(Page): form_model = 'player' form_fields = ['ControlQuestion1', 'ControlQuestion2', 'ControlQuestion3', 'ControlQuestion4', 'counterWrong', 'tab_desc_choice_part2', 'focus_desc_choice_part2', 'totaltime_desc_choice_part2'] def is_displayed(self): return self.round_number == 1 and self.player.version == 'REPU' # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/E_Description_Choice.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) table_title = sheet.cell_value(3, Constants.language_code) table11 = sheet.cell_value(4, Constants.language_code) table21 = sheet.cell_value(5, Constants.language_code) table122 = sheet.cell_value(6, Constants.language_code) table13 = sheet.cell_value(7, Constants.language_code) table23 = sheet.cell_value(8, Constants.language_code) table14 = sheet.cell_value(9, Constants.language_code) table24 = sheet.cell_value(10, Constants.language_code) table15 = sheet.cell_value(11, Constants.language_code) table25 = sheet.cell_value(12, Constants.language_code) table16 = sheet.cell_value(13, Constants.language_code) table26 = sheet.cell_value(14, Constants.language_code) paragraph2 = sheet.cell_value(15, Constants.language_code) confirm = sheet.cell_value(16, Constants.language_code) return dict( title = title, paragraph1 = paragraph1.format(num_rounds = Constants.num_rounds), paragraph2 = paragraph2.format(num_rounds = Constants.num_rounds), table_title = table_title, table11 = table11, table21 = table21, table122 = table122, table13 = table13, table23 = table23, table14 = table14, table24 = table24, table15 = table15, table25 = table25, table16 = table16, table26 = table26, confirm = confirm, ) class E_Description_ChoiceMALE(Page): form_model = 'player' form_fields = ['ControlQuestion1', 'ControlQuestion2', 'ControlQuestion3', 'ControlQuestion4', 'counterWrong', 'tab_desc_choice_part2', 'focus_desc_choice_part2', 'totaltime_desc_choice_part2'] def is_displayed(self): return self.round_number == 1 and self.player.version == 'MALE' # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/E_Description_Choice.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) table_title = sheet.cell_value(3, Constants.language_code) table11 = sheet.cell_value(4, Constants.language_code) table21 = sheet.cell_value(5, Constants.language_code) table122 = sheet.cell_value(6, Constants.language_code) table13 = sheet.cell_value(7, Constants.language_code) table23 = sheet.cell_value(8, Constants.language_code) table14 = sheet.cell_value(9, Constants.language_code) table24 = sheet.cell_value(10, Constants.language_code) table15 = sheet.cell_value(11, Constants.language_code) table25 = sheet.cell_value(12, Constants.language_code) table16 = sheet.cell_value(13, Constants.language_code) table26 = sheet.cell_value(14, Constants.language_code) paragraph2 = sheet.cell_value(15, Constants.language_code) confirm = sheet.cell_value(16, Constants.language_code) return dict( title = title, paragraph1 = paragraph1.format(num_rounds = Constants.num_rounds), paragraph2 = paragraph2.format(num_rounds = Constants.num_rounds), table_title = table_title, table11 = table11, table21 = table21, table122 = table122, table13 = table13, table23 = table23, table14 = table14, table24 = table24, table15 = table15, table25 = table25, table16 = table16, table26 = table26, confirm = confirm, ) class E_Description_ChoiceFEMALE(Page): form_model = 'player' form_fields = ['ControlQuestion1', 'ControlQuestion2', 'ControlQuestion3', 'ControlQuestion4', 'counterWrong', 'tab_desc_choice_part2', 'focus_desc_choice_part2', 'totaltime_desc_choice_part2'] def is_displayed(self): return self.round_number == 1 and self.player.version == 'FEMALE' # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/E_Description_Choice.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) table_title = sheet.cell_value(3, Constants.language_code) table11 = sheet.cell_value(4, Constants.language_code) table21 = sheet.cell_value(5, Constants.language_code) table122 = sheet.cell_value(6, Constants.language_code) table13 = sheet.cell_value(7, Constants.language_code) table23 = sheet.cell_value(8, Constants.language_code) table14 = sheet.cell_value(9, Constants.language_code) table24 = sheet.cell_value(10, Constants.language_code) table15 = sheet.cell_value(11, Constants.language_code) table25 = sheet.cell_value(12, Constants.language_code) table16 = sheet.cell_value(13, Constants.language_code) table26 = sheet.cell_value(14, Constants.language_code) paragraph2 = sheet.cell_value(15, Constants.language_code) confirm = sheet.cell_value(16, Constants.language_code) return dict( title = title, paragraph1 = paragraph1.format(num_rounds = Constants.num_rounds), paragraph2 = paragraph2.format(num_rounds = Constants.num_rounds), table_title = table_title, table11 = table11, table21 = table21, table122 = table122, table13 = table13, table23 = table23, table14 = table14, table24 = table24, table15 = table15, table25 = table25, table16 = table16, table26 = table26, confirm = confirm, ) class E_Description_ChoicePIC1(Page): form_model = 'player' form_fields = ['ControlQuestion1', 'ControlQuestion2', 'ControlQuestion3', 'ControlQuestion4', 'counterWrong', 'tab_desc_choice_part2', 'focus_desc_choice_part2', 'totaltime_desc_choice_part2'] def is_displayed(self): return self.round_number == 1 and self.player.version == 'PIC1' # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/E_Description_Choice.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) table_title = sheet.cell_value(3, Constants.language_code) table11 = sheet.cell_value(4, Constants.language_code) table21 = sheet.cell_value(5, Constants.language_code) table122 = sheet.cell_value(6, Constants.language_code) table13 = sheet.cell_value(7, Constants.language_code) table23 = sheet.cell_value(8, Constants.language_code) table14 = sheet.cell_value(9, Constants.language_code) table24 = sheet.cell_value(10, Constants.language_code) table15 = sheet.cell_value(11, Constants.language_code) table25 = sheet.cell_value(12, Constants.language_code) table16 = sheet.cell_value(13, Constants.language_code) table26 = sheet.cell_value(14, Constants.language_code) paragraph2 = sheet.cell_value(15, Constants.language_code) confirm = sheet.cell_value(16, Constants.language_code) return dict( title = title, paragraph1 = paragraph1.format(num_rounds = Constants.num_rounds), paragraph2 = paragraph2.format(num_rounds = Constants.num_rounds), table_title = table_title, table11 = table11, table21 = table21, table122 = table122, table13 = table13, table23 = table23, table14 = table14, table24 = table24, table15 = table15, table25 = table25, table16 = table16, table26 = table26, confirm = confirm, ) class E_Description_ChoicePIC2(Page): form_model = 'player' form_fields = ['ControlQuestion1', 'ControlQuestion2', 'ControlQuestion3', 'ControlQuestion4', 'counterWrong', 'tab_desc_choice_part2', 'focus_desc_choice_part2', 'totaltime_desc_choice_part2'] def is_displayed(self): return self.round_number == 1 and self.player.version == 'PIC2' # only display in the first round def vars_for_template(self): loc = ("Part2_WTP_DOSE/data/E_Description_Choice.xlsx") # To open Workbook wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # Get all titles & paragraphs title = sheet.cell_value(1, Constants.language_code) paragraph1 = sheet.cell_value(2, Constants.language_code) table_title = sheet.cell_value(3, Constants.language_code) table11 = sheet.cell_value(4, Constants.language_code) table21 = sheet.cell_value(5, Constants.language_code) table122 = sheet.cell_value(6, Constants.language_code) table13 = sheet.cell_value(7, Constants.language_code) table23 = sheet.cell_value(8, Constants.language_code) table14 = sheet.cell_value(9, Constants.language_code) table24 = sheet.cell_value(10, Constants.language_code) table15 = sheet.cell_value(11, Constants.language_code) table25 = sheet.cell_value(12, Constants.language_code) table16 = sheet.cell_value(13, Constants.language_code) table26 = sheet.cell_value(14, Constants.language_code) paragraph2 = sheet.cell_value(15, Constants.language_code) confirm = sheet.cell_value(16, Constants.language_code) return dict( title = title, paragraph1 = paragraph1.format(num_rounds = Constants.num_rounds), paragraph2 = paragraph2.format(num_rounds = Constants.num_rounds), table_title = table_title, table11 = table11, table21 = table21, table122 = table122, table13 = table13, table23 = table23, table14 = table14, table24 = table24, table15 = table15, table25 = table25, table16 = table16, table26 = table26, confirm = confirm, ) class F_Description_RLIM(Page): form_model = 'player' form_fields = ['tab_desc_rlim_part2', 'focus_desc_rlim_part2', 'totaltime_desc_rlim_part2'] def is_displayed(self): return self.round_number == 1 # only display in the first round class Xclusion(Page): def is_displayed(self): return self.player.counterWrong==3 class preQuestion(Page): form_model = 'player' form_fields = ['tab_pre_question_part2', 'focus_pre_question_part2', 'totaltime_pre_question_part2'] def is_displayed(self): return self.round_number == 1 # only display in the first round class preDecision(Page): form_model = 'player' form_fields = ['tab_pre_decision_part2', 'focus_pre_decision_part2', 'totaltime_pre_decision_part2'] def is_displayed(self): return self.round_number == Constants.num_rounds # only display in the last round ############### END OF INSTRUCTION PAGES ################################################## # DOSE PROCEDURE class Question(Page): form_model = 'player' form_fields = ['pricechoice','tab_question_part2', 'focus_question_part2', 'totaltime_question_part2'] def before_next_page(self): self.player.in_round(1).WTP = 0 current_round = self.round_number if(self.round_number==Constants.num_rounds): # get pricechoice from last round ### set WTP and choice consistency according to the choices in the 10 previous rounds (i.e. look them up in the decision tree file) if(self.player.pricechoice==0): #if 'paying a price' was chosen move down by one cell #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) * 200 # multiply with 200 (linear transformation in points) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+2)) elif(self.player.pricechoice==1): #if 'not paying a price' was chosen stay on same line #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) * 200 # multiply with 200 (linear transformation of payoffs in points!!!!) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 2)) ### select one chosen decision situation at random from the 10 choices # select payoff-relevant round self.player.payoffrelevant_round_part2 = random.choice(range(1,Constants.num_rounds+1)) payoffrelevant_round_part2 = self.player.payoffrelevant_round_part2 # determine if 'pay' or 'not pay' was chosen in the payoff-relevant round choice = self.player.in_round(payoffrelevant_round_part2).pricechoice def vars_for_template(self): # store current round current_round=self.round_number # The following is just a technical procedure: # We transfer the lottery information from one round to another. We do this assignment just that we don't have # to always remember that the lottery info is just saved in the lottery variables of the first round! if (current_round > 1): q = self.player q.lotteryA_high = q.in_round(current_round - 1).lotteryA_high q.lotteryA_low = q.in_round(current_round - 1).lotteryA_low q.probA_low = q.in_round(current_round - 1).probA_low q.lotteryB_high = q.in_round(current_round - 1).lotteryB_high q.lotteryB_low = q.in_round(current_round - 1).lotteryB_low q.probB_low = q.in_round(current_round - 1).probB_low ########### GET CURRENT OPTIMAL PRICE ############# ### PROCEDURE: ### 1. Get the row of the next optimal price by looking at the previous answer: ###### if 'pay & decide' was chosen in the previous round, move down the decision tree (i.e. row number will increase) ###### if 'not pay & delegate' was chosen in the previous round, move up the decision tree (i.e. row number will decrease) ###### Special Case in 1st round: No answer is necessary. Row is for everyone the same and given by our prior ###### VARIABLE NAME: player.tree_row ###### (Aug. 2020: We use 10 rounds, first row of binary tree is 512) ### 2. Get the number of the next optimal price by storing the value in the row of the decision tree ###### Read cell value (excel sheet:"decisiontree_WTP.xsls") of the optimal row to get optimal price ###### Note: the sheet is read in models.py in the Constants-class ###### Special Case in 1st round: optimal price is written on row number 512 in the 1st column of the excel sheet ###### VARIABLE NAME: player.optimal_price (corresponds to the index of the price matrix) ### 3. set current_price to the price corresponding to the optimal price ### NOTE: This procedure may seems a little bit cumbersome. This is because it is implemented the same way as in part 1 for the lotteries. ###### NOTE: because of the specific CSV-file of the prices, we have to go one row up (i.e. subtract 1 from optimal_lottery-value) # intializing for 1st round. tree_row is set initially in models.py to 512, so we don't need make any changes in the 1st round if(current_round==1): # use the intial value of 512 set in models.py for the 1st round optimal_price_row = self.player.tree_row # set player.optimal_price self.player.optimal_price_index=int(Constants.sheet.cell_value(optimal_price_row, current_round)) elif(current_round>1): # move down (if A was chosen i.e. player.lotterychoice in previous round was 0) in the decision tree matrix # or down (if B was chosen i.e. player.lotterychoice in previous round was 1) in the decision tree matrix if(self.player.in_round(current_round-1).pricechoice == 0): # if price was chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row + Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree elif(self.player.in_round(current_round-1).pricechoice == 1): # if price was not chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row - Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree optimal_price_row = self.player.tree_row self.player.optimal_price_index = int(Constants.sheet.cell_value(optimal_price_row, current_round)) optimal_price= self.player.optimal_price_index - 1 #subtract one, because we read the price from the CSV-file, which starts at row 0 #### Determine the price about to be asked self.player.current_price = float(Constants.questions[optimal_price]['price']) return dict( current_round=current_round, bonus = -self.player.current_price # inverse price (used for display purposes if price < 0) ) def is_displayed(self): return self.player.version == 'BASE' class QuestionDEM(Page): form_model = 'player' form_fields = ['pricechoice','tab_question_part2', 'focus_question_part2', 'totaltime_question_part2'] def before_next_page(self): self.player.in_round(1).WTP = 0 current_round = self.round_number if(self.round_number==Constants.num_rounds): # get pricechoice from last round ### set WTP and choice consistency according to the choices in the 10 previous rounds (i.e. look them up in the decision tree file) if(self.player.pricechoice==0): #if 'paying a price' was chosen move down by one cell #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) * 200 # multiply with 200 (linear transformation in points) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+2)) elif(self.player.pricechoice==1): #if 'not paying a price' was chosen stay on same line #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) * 200 # multiply with 200 (linear transformation of payoffs in points!!!!) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 2)) ### select one chosen decision situation at random from the 10 choices # select payoff-relevant round self.player.payoffrelevant_round_part2 = random.choice(range(1,Constants.num_rounds+1)) payoffrelevant_round_part2 = self.player.payoffrelevant_round_part2 # determine if 'pay' or 'not pay' was chosen in the payoff-relevant round choice = self.player.in_round(payoffrelevant_round_part2).pricechoice def vars_for_template(self): # store current round current_round=self.round_number # The following is just a technical procedure: # We transfer the lottery information from one round to another. We do this assignment just that we don't have # to always remember that the lottery info is just saved in the lottery variables of the first round! if (current_round > 1): q = self.player q.lotteryA_high = q.in_round(current_round - 1).lotteryA_high q.lotteryA_low = q.in_round(current_round - 1).lotteryA_low q.probA_low = q.in_round(current_round - 1).probA_low q.lotteryB_high = q.in_round(current_round - 1).lotteryB_high q.lotteryB_low = q.in_round(current_round - 1).lotteryB_low q.probB_low = q.in_round(current_round - 1).probB_low ########### GET CURRENT OPTIMAL PRICE ############# ### PROCEDURE: ### 1. Get the row of the next optimal price by looking at the previous answer: ###### if 'pay & decide' was chosen in the previous round, move down the decision tree (i.e. row number will increase) ###### if 'not pay & delegate' was chosen in the previous round, move up the decision tree (i.e. row number will decrease) ###### Special Case in 1st round: No answer is necessary. Row is for everyone the same and given by our prior ###### VARIABLE NAME: player.tree_row ###### (Aug. 2020: We use 10 rounds, first row of binary tree is 512) ### 2. Get the number of the next optimal price by storing the value in the row of the decision tree ###### Read cell value (excel sheet:"decisiontree_WTP.xsls") of the optimal row to get optimal price ###### Note: the sheet is read in models.py in the Constants-class ###### Special Case in 1st round: optimal price is written on row number 512 in the 1st column of the excel sheet ###### VARIABLE NAME: player.optimal_price (corresponds to the index of the price matrix) ### 3. set current_price to the price corresponding to the optimal price ### NOTE: This procedure may seems a little bit cumbersome. This is because it is implemented the same way as in part 1 for the lotteries. ###### NOTE: because of the specific CSV-file of the prices, we have to go one row up (i.e. subtract 1 from optimal_lottery-value) # intializing for 1st round. tree_row is set initially in models.py to 512, so we don't need make any changes in the 1st round if(current_round==1): # use the intial value of 512 set in models.py for the 1st round optimal_price_row = self.player.tree_row # set player.optimal_price self.player.optimal_price_index=int(Constants.sheet.cell_value(optimal_price_row, current_round)) elif(current_round>1): # move down (if A was chosen i.e. player.lotterychoice in previous round was 0) in the decision tree matrix # or down (if B was chosen i.e. player.lotterychoice in previous round was 1) in the decision tree matrix if(self.player.in_round(current_round-1).pricechoice == 0): # if price was chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row + Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree elif(self.player.in_round(current_round-1).pricechoice == 1): # if price was not chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row - Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree optimal_price_row = self.player.tree_row self.player.optimal_price_index = int(Constants.sheet.cell_value(optimal_price_row, current_round)) optimal_price= self.player.optimal_price_index - 1 #subtract one, because we read the price from the CSV-file, which starts at row 0 #### Determine the price about to be asked self.player.current_price = float(Constants.questions[optimal_price]['price']) return dict( current_round=current_round, bonus = -self.player.current_price # inverse price (used for display purposes if price < 0) ) def is_displayed(self): return self.player.version == 'DEMO' class QuestionREP(Page): form_model = 'player' form_fields = ['pricechoice','tab_question_part2', 'focus_question_part2', 'totaltime_question_part2'] def before_next_page(self): self.player.in_round(1).WTP = 0 current_round = self.round_number if(self.round_number==Constants.num_rounds): # get pricechoice from last round ### set WTP and choice consistency according to the choices in the 10 previous rounds (i.e. look them up in the decision tree file) if(self.player.pricechoice==0): #if 'paying a price' was chosen move down by one cell #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) * 200 # multiply with 200 (linear transformation in points) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+2)) elif(self.player.pricechoice==1): #if 'not paying a price' was chosen stay on same line #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) * 200 # multiply with 200 (linear transformation of payoffs in points!!!!) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 2)) ### select one chosen decision situation at random from the 10 choices # select payoff-relevant round self.player.payoffrelevant_round_part2 = random.choice(range(1,Constants.num_rounds+1)) payoffrelevant_round_part2 = self.player.payoffrelevant_round_part2 # determine if 'pay' or 'not pay' was chosen in the payoff-relevant round choice = self.player.in_round(payoffrelevant_round_part2).pricechoice def vars_for_template(self): # store current round current_round=self.round_number # The following is just a technical procedure: # We transfer the lottery information from one round to another. We do this assignment just that we don't have # to always remember that the lottery info is just saved in the lottery variables of the first round! if (current_round > 1): q = self.player q.lotteryA_high = q.in_round(current_round - 1).lotteryA_high q.lotteryA_low = q.in_round(current_round - 1).lotteryA_low q.probA_low = q.in_round(current_round - 1).probA_low q.lotteryB_high = q.in_round(current_round - 1).lotteryB_high q.lotteryB_low = q.in_round(current_round - 1).lotteryB_low q.probB_low = q.in_round(current_round - 1).probB_low ########### GET CURRENT OPTIMAL PRICE ############# ### PROCEDURE: ### 1. Get the row of the next optimal price by looking at the previous answer: ###### if 'pay & decide' was chosen in the previous round, move down the decision tree (i.e. row number will increase) ###### if 'not pay & delegate' was chosen in the previous round, move up the decision tree (i.e. row number will decrease) ###### Special Case in 1st round: No answer is necessary. Row is for everyone the same and given by our prior ###### VARIABLE NAME: player.tree_row ###### (Aug. 2020: We use 10 rounds, first row of binary tree is 512) ### 2. Get the number of the next optimal price by storing the value in the row of the decision tree ###### Read cell value (excel sheet:"decisiontree_WTP.xsls") of the optimal row to get optimal price ###### Note: the sheet is read in models.py in the Constants-class ###### Special Case in 1st round: optimal price is written on row number 512 in the 1st column of the excel sheet ###### VARIABLE NAME: player.optimal_price (corresponds to the index of the price matrix) ### 3. set current_price to the price corresponding to the optimal price ### NOTE: This procedure may seems a little bit cumbersome. This is because it is implemented the same way as in part 1 for the lotteries. ###### NOTE: because of the specific CSV-file of the prices, we have to go one row up (i.e. subtract 1 from optimal_lottery-value) # intializing for 1st round. tree_row is set initially in models.py to 512, so we don't need make any changes in the 1st round if(current_round==1): # use the intial value of 512 set in models.py for the 1st round optimal_price_row = self.player.tree_row # set player.optimal_price self.player.optimal_price_index=int(Constants.sheet.cell_value(optimal_price_row, current_round)) elif(current_round>1): # move down (if A was chosen i.e. player.lotterychoice in previous round was 0) in the decision tree matrix # or down (if B was chosen i.e. player.lotterychoice in previous round was 1) in the decision tree matrix if(self.player.in_round(current_round-1).pricechoice == 0): # if price was chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row + Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree elif(self.player.in_round(current_round-1).pricechoice == 1): # if price was not chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row - Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree optimal_price_row = self.player.tree_row self.player.optimal_price_index = int(Constants.sheet.cell_value(optimal_price_row, current_round)) optimal_price= self.player.optimal_price_index - 1 #subtract one, because we read the price from the CSV-file, which starts at row 0 #### Determine the price about to be asked self.player.current_price = float(Constants.questions[optimal_price]['price']) return dict( current_round=current_round, bonus = -self.player.current_price # inverse price (used for display purposes if price < 0) ) def is_displayed(self): return self.player.version == 'REPU' class QuestionMALE(Page): form_model = 'player' form_fields = ['pricechoice','tab_question_part2', 'focus_question_part2', 'totaltime_question_part2'] def before_next_page(self): self.player.in_round(1).WTP = 0 current_round = self.round_number if(self.round_number==Constants.num_rounds): # get pricechoice from last round ### set WTP and choice consistency according to the choices in the 10 previous rounds (i.e. look them up in the decision tree file) if(self.player.pricechoice==0): #if 'paying a price' was chosen move down by one cell #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) * 200 # multiply with 200 (linear transformation in points) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+2)) elif(self.player.pricechoice==1): #if 'not paying a price' was chosen stay on same line #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) * 200 # multiply with 200 (linear transformation of payoffs in points!!!!) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 2)) ### select one chosen decision situation at random from the 10 choices # select payoff-relevant round self.player.payoffrelevant_round_part2 = random.choice(range(1,Constants.num_rounds+1)) payoffrelevant_round_part2 = self.player.payoffrelevant_round_part2 # determine if 'pay' or 'not pay' was chosen in the payoff-relevant round choice = self.player.in_round(payoffrelevant_round_part2).pricechoice def vars_for_template(self): # store current round current_round=self.round_number # The following is just a technical procedure: # We transfer the lottery information from one round to another. We do this assignment just that we don't have # to always remember that the lottery info is just saved in the lottery variables of the first round! if (current_round > 1): q = self.player q.lotteryA_high = q.in_round(current_round - 1).lotteryA_high q.lotteryA_low = q.in_round(current_round - 1).lotteryA_low q.probA_low = q.in_round(current_round - 1).probA_low q.lotteryB_high = q.in_round(current_round - 1).lotteryB_high q.lotteryB_low = q.in_round(current_round - 1).lotteryB_low q.probB_low = q.in_round(current_round - 1).probB_low # intializing for 1st round. tree_row is set initially in models.py to 512, so we don't need make any changes in the 1st round if(current_round==1): # use the intial value of 512 set in models.py for the 1st round optimal_price_row = self.player.tree_row # set player.optimal_price self.player.optimal_price_index=int(Constants.sheet.cell_value(optimal_price_row, current_round)) elif(current_round>1): # move down (if A was chosen i.e. player.lotterychoice in previous round was 0) in the decision tree matrix # or down (if B was chosen i.e. player.lotterychoice in previous round was 1) in the decision tree matrix if(self.player.in_round(current_round-1).pricechoice == 0): # if price was chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row + Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree elif(self.player.in_round(current_round-1).pricechoice == 1): # if price was not chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row - Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree optimal_price_row = self.player.tree_row self.player.optimal_price_index = int(Constants.sheet.cell_value(optimal_price_row, current_round)) optimal_price= self.player.optimal_price_index - 1 #subtract one, because we read the price from the CSV-file, which starts at row 0 #### Determine the price about to be asked self.player.current_price = float(Constants.questions[optimal_price]['price']) return dict( current_round=current_round, bonus = -self.player.current_price # inverse price (used for display purposes if price < 0) ) def is_displayed(self): return self.player.version == 'MALE' class QuestionFEMALE(Page): form_model = 'player' form_fields = ['pricechoice','tab_question_part2', 'focus_question_part2', 'totaltime_question_part2'] def before_next_page(self): self.player.in_round(1).WTP = 0 current_round = self.round_number if(self.round_number==Constants.num_rounds): # get pricechoice from last round ### set WTP and choice consistency according to the choices in the 10 previous rounds (i.e. look them up in the decision tree file) if(self.player.pricechoice==0): #if 'paying a price' was chosen move down by one cell #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) * 200 # multiply with 200 (linear transformation in points) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+2)) elif(self.player.pricechoice==1): #if 'not paying a price' was chosen stay on same line #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) * 200 # multiply with 200 (linear transformation of payoffs in points!!!!) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 2)) ### select one chosen decision situation at random from the 10 choices # select payoff-relevant round self.player.payoffrelevant_round_part2 = random.choice(range(1,Constants.num_rounds+1)) payoffrelevant_round_part2 = self.player.payoffrelevant_round_part2 # determine if 'pay' or 'not pay' was chosen in the payoff-relevant round choice = self.player.in_round(payoffrelevant_round_part2).pricechoice def vars_for_template(self): # store current round current_round=self.round_number # The following is just a technical procedure: # We transfer the lottery information from one round to another. We do this assignment just that we don't have # to always remember that the lottery info is just saved in the lottery variables of the first round! if (current_round > 1): q = self.player q.lotteryA_high = q.in_round(current_round - 1).lotteryA_high q.lotteryA_low = q.in_round(current_round - 1).lotteryA_low q.probA_low = q.in_round(current_round - 1).probA_low q.lotteryB_high = q.in_round(current_round - 1).lotteryB_high q.lotteryB_low = q.in_round(current_round - 1).lotteryB_low q.probB_low = q.in_round(current_round - 1).probB_low # intializing for 1st round. tree_row is set initially in models.py to 512, so we don't need make any changes in the 1st round if(current_round==1): # use the intial value of 512 set in models.py for the 1st round optimal_price_row = self.player.tree_row # set player.optimal_price self.player.optimal_price_index=int(Constants.sheet.cell_value(optimal_price_row, current_round)) elif(current_round>1): # move down (if A was chosen i.e. player.lotterychoice in previous round was 0) in the decision tree matrix # or down (if B was chosen i.e. player.lotterychoice in previous round was 1) in the decision tree matrix if(self.player.in_round(current_round-1).pricechoice == 0): # if price was chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row + Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree elif(self.player.in_round(current_round-1).pricechoice == 1): # if price was not chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row - Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree optimal_price_row = self.player.tree_row self.player.optimal_price_index = int(Constants.sheet.cell_value(optimal_price_row, current_round)) optimal_price= self.player.optimal_price_index - 1 #subtract one, because we read the price from the CSV-file, which starts at row 0 #### Determine the price about to be asked self.player.current_price = float(Constants.questions[optimal_price]['price']) return dict( current_round=current_round, bonus = -self.player.current_price # inverse price (used for display purposes if price < 0) ) def is_displayed(self): return self.player.version == 'FEMALE' class QuestionPIC1(Page): form_model = 'player' form_fields = ['pricechoice','tab_question_part2', 'focus_question_part2', 'totaltime_question_part2'] def before_next_page(self): self.player.in_round(1).WTP = 0 current_round = self.round_number if(self.round_number==Constants.num_rounds): # get pricechoice from last round ### set WTP and choice consistency according to the choices in the 10 previous rounds (i.e. look them up in the decision tree file) if(self.player.pricechoice==0): #if 'paying a price' was chosen move down by one cell #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) * 200 # multiply with 200 (linear transformation in points) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+2)) elif(self.player.pricechoice==1): #if 'not paying a price' was chosen stay on same line #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) * 200 # multiply with 200 (linear transformation of payoffs in points!!!!) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 2)) ### select one chosen decision situation at random from the 10 choices # select payoff-relevant round self.player.payoffrelevant_round_part2 = random.choice(range(1,Constants.num_rounds+1)) payoffrelevant_round_part2 = self.player.payoffrelevant_round_part2 # determine if 'pay' or 'not pay' was chosen in the payoff-relevant round choice = self.player.in_round(payoffrelevant_round_part2).pricechoice def vars_for_template(self): # store current round current_round=self.round_number # The following is just a technical procedure: # We transfer the lottery information from one round to another. We do this assignment just that we don't have # to always remember that the lottery info is just saved in the lottery variables of the first round! if (current_round > 1): q = self.player q.lotteryA_high = q.in_round(current_round - 1).lotteryA_high q.lotteryA_low = q.in_round(current_round - 1).lotteryA_low q.probA_low = q.in_round(current_round - 1).probA_low q.lotteryB_high = q.in_round(current_round - 1).lotteryB_high q.lotteryB_low = q.in_round(current_round - 1).lotteryB_low q.probB_low = q.in_round(current_round - 1).probB_low # intializing for 1st round. tree_row is set initially in models.py to 512, so we don't need make any changes in the 1st round if(current_round==1): # use the intial value of 512 set in models.py for the 1st round optimal_price_row = self.player.tree_row # set player.optimal_price self.player.optimal_price_index=int(Constants.sheet.cell_value(optimal_price_row, current_round)) elif(current_round>1): # move down (if A was chosen i.e. player.lotterychoice in previous round was 0) in the decision tree matrix # or down (if B was chosen i.e. player.lotterychoice in previous round was 1) in the decision tree matrix if(self.player.in_round(current_round-1).pricechoice == 0): # if price was chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row + Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree elif(self.player.in_round(current_round-1).pricechoice == 1): # if price was not chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row - Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree optimal_price_row = self.player.tree_row self.player.optimal_price_index = int(Constants.sheet.cell_value(optimal_price_row, current_round)) optimal_price= self.player.optimal_price_index - 1 #subtract one, because we read the price from the CSV-file, which starts at row 0 #### Determine the price about to be asked self.player.current_price = float(Constants.questions[optimal_price]['price']) return dict( current_round=current_round, bonus = -self.player.current_price # inverse price (used for display purposes if price < 0) ) def is_displayed(self): return self.player.version == 'PIC1' class QuestionPIC2(Page): form_model = 'player' form_fields = ['pricechoice','tab_question_part2', 'focus_question_part2', 'totaltime_question_part2'] def before_next_page(self): self.player.in_round(1).WTP = 0 current_round = self.round_number if(self.round_number==Constants.num_rounds): # get pricechoice from last round ### set WTP and choice consistency according to the choices in the 10 previous rounds (i.e. look them up in the decision tree file) if(self.player.pricechoice==0): #if 'paying a price' was chosen move down by one cell #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+1)) * 200 # multiply with 200 (linear transformation in points) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row+1, current_round+2)) elif(self.player.pricechoice==1): #if 'not paying a price' was chosen stay on same line #self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) *10 # multiply with 10 (linear transformation of payoffs) self.player.WTP = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 1)) * 200 # multiply with 200 (linear transformation of payoffs in points!!!!) self.player.choice_consistency = float(Constants.sheet.cell_value(self.player.in_round(current_round).tree_row, current_round + 2)) ### select one chosen decision situation at random from the 10 choices # select payoff-relevant round self.player.payoffrelevant_round_part2 = random.choice(range(1,Constants.num_rounds+1)) payoffrelevant_round_part2 = self.player.payoffrelevant_round_part2 # determine if 'pay' or 'not pay' was chosen in the payoff-relevant round choice = self.player.in_round(payoffrelevant_round_part2).pricechoice def vars_for_template(self): # store current round current_round=self.round_number # The following is just a technical procedure: # We transfer the lottery information from one round to another. We do this assignment just that we don't have # to always remember that the lottery info is just saved in the lottery variables of the first round! if (current_round > 1): q = self.player q.lotteryA_high = q.in_round(current_round - 1).lotteryA_high q.lotteryA_low = q.in_round(current_round - 1).lotteryA_low q.probA_low = q.in_round(current_round - 1).probA_low q.lotteryB_high = q.in_round(current_round - 1).lotteryB_high q.lotteryB_low = q.in_round(current_round - 1).lotteryB_low q.probB_low = q.in_round(current_round - 1).probB_low # intializing for 1st round. tree_row is set initially in models.py to 512, so we don't need make any changes in the 1st round if(current_round==1): # use the intial value of 512 set in models.py for the 1st round optimal_price_row = self.player.tree_row # set player.optimal_price self.player.optimal_price_index=int(Constants.sheet.cell_value(optimal_price_row, current_round)) elif(current_round>1): # move down (if A was chosen i.e. player.lotterychoice in previous round was 0) in the decision tree matrix # or down (if B was chosen i.e. player.lotterychoice in previous round was 1) in the decision tree matrix if(self.player.in_round(current_round-1).pricechoice == 0): # if price was chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row + Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree elif(self.player.in_round(current_round-1).pricechoice == 1): # if price was not chosen in previous round self.player.tree_row = self.player.in_round(current_round-1).tree_row - Constants.shift[current_round - 2] # set row of optimal lottery for identification in the binary tree optimal_price_row = self.player.tree_row self.player.optimal_price_index = int(Constants.sheet.cell_value(optimal_price_row, current_round)) optimal_price= self.player.optimal_price_index - 1 #subtract one, because we read the price from the CSV-file, which starts at row 0 #### Determine the price about to be asked self.player.current_price = float(Constants.questions[optimal_price]['price']) return dict( current_round=current_round, bonus = -self.player.current_price # inverse price (used for display purposes if price < 0) ) def is_displayed(self): return self.player.version == 'PIC2' class Results(Page): def is_displayed(self): return self.player.treatment == 3 def is_displayed(self): return self.round_number == Constants.num_rounds #only display in the last round ##################################################################################### def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() return dict( player_in_all_rounds=player_in_all_rounds, ) class Decision_Self(Page): form_model = 'player' form_fields = ['lotterychoice_auto','tab_self_part2', 'focus_self_part2', 'totaltime_self_part2'] def is_displayed(self): display = False if self.round_number == Constants.num_rounds: # only display in the last round and if autonomy was selected if(self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice == 0): self.player.delegation = False display = True return display def vars_for_template(self): #### make a random draw from BOTH lotteries! draw=random.randint(1,100) if(draw/100 < self.player.probA_low): self.player.drawC = self.player.lotteryA_low else: self.player.drawC = self.player.lotteryA_high if(draw/100 < self.player.probB_low): self.player.drawD = self.player.lotteryB_low else: self.player.drawD = self.player.lotteryB_high choice = self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice price = self.player.in_round(self.player.payoffrelevant_round_part2).current_price return dict( choice = choice, price = price, bonus = -price, drawC = self.player.in_round(1).drawC, drawD = self.player.in_round(1).drawD, ) class Decision_Delegation(Page): form_model = 'player' form_fields = ['tab_delegation_part2', 'focus_delegation_part2', 'totaltime_delegation_part2'] def is_displayed(self): display = False if self.round_number == Constants.num_rounds: # only display in the last round and if delegation was selected if(self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice == 1): display = True self.player.delegation = True return display def before_next_page(self): with open("Part2_type2\lotteries.csv", 'a', newline='') as file: # open CSV-File; change file name here writer = csv.writer(file) # Order of rows in delegation CSV-file # Ahigh, Alow, pAlow, Bhigh, Blow, pBlow, UserID, Decision userID = random.randint(1,100) writer.writerow([self.player.lotteryA_high, self.player.lotteryA_low, self.player.probA_low, self.player.lotteryB_high, self.player.lotteryB_low, self.player.probB_low, userID]) class Payoff_Screen(Page): def is_displayed(self): return self.round_number == Constants.num_rounds # only display in the last round ##################################################################################### def vars_for_template(self): externalDM = "none" auto = self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice if auto == 0: # if lottery choice was not delegated in payoff-relevant round if self.player.lotterychoice_auto == 0: # if lottery C was chosen self.player.payoff_part2 = self.player.in_round(1).drawC - self.player.in_round(self.player.payoffrelevant_round_part2).current_price self.player.draw = self.player.in_round(1).drawC else: # if lottery D was chosen self.player.payoff_part2 = self.player.in_round(1).drawD - self.player.in_round(self.player.payoffrelevant_round_part2).current_price self.player.draw = self.player.in_round(1).drawD ##### calculate final payoff in ECU and real currency (only in case of non-delegation) self.player.final_payoff = self.player.in_round(1).payoff_part1 + self.player.payoff_part2 + Constants.showup_fee self.player.final_payoff_converted = self.player.final_payoff * Constants.XR self.player.payoff_part1_converted = self.player.in_round(1).payoff_part1 * Constants.XR self.player.payoff_part2_converted = self.player.payoff_part2 * Constants.XR else: ######### NEW CASE: Type 2 (decision maker) makes decisions à la strategy method beforehand. Thus we know ################### the delegated decisions for each lottery. Decision file: decisions_type2.csv # read & store all SM decisions with open('Part2_WTP_DOSE/DEM_FEM_PIC2.csv') as decisions_file: decisions = list(csv.DictReader(decisions_file)) rowDecision = 20 # default to catch errors (instead of a try condition) for i in range(0, len(decisions)): if float(decisions[i]['Bhigh']) == round(self.player.lotteryB_high,0): rowDecision = i #print(rowDecision) if decisions[rowDecision]['Decision'] == 'A': externalDM = "A" #### make a random draw from BOTH lotteries! draw = random.randint(1, 100) if (draw / 100 < self.player.probA_low): self.player.payoff_part2 = self.player.lotteryA_low else: self.player.payoff_part2 = self.player.lotteryA_high elif decisions[rowDecision]['Decision'] == 'B': externalDM = "B" #### make a random draw from BOTH lotteries! draw = random.randint(1, 100) if (draw / 100 < self.player.probB_low): self.player.payoff_part2 = self.player.lotteryB_low else: self.player.payoff_part2 = self.player.lotteryB_high ############################################## self.player.payoff_part2_converted = self.player.payoff_part2 * Constants.XR ##### calculate final payoff in ECU and real currency (only in case of non-delegation) #self.player.final_payoff = self.player.in_round(1).payoff_part1 + Constants.showup_fee self.player.final_payoff = self.player.in_round(1).payoff_part1 + Constants.showup_fee + self.player.payoff_part2 self.player.final_payoff_converted = self.player.final_payoff * Constants.XR self.player.payoff_part1_converted = self.player.in_round(1).payoff_part1 * Constants.XR self.player.payoff = self.player.final_payoff_converted try: self.participant.label = self.participant.vars['prolificID'] except: self.participant.label = "not set" #### THIS PART IS FOR SP22 (occupational sorting) only # pass variables for displaying at the end of the survey self.participant.vars['payoff_info_part1'] = [ self.player.in_round(1).payoffrelevant_round_part1, self.player.in_round(1).payoffrelevant_round_part1_low, self.player.in_round(1).payoffrelevant_round_part1_high, self.player.in_round(1).payoff_part1, self.player.in_round(1).lotterychoice_part1, self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice, self.player.in_round(self.player.payoffrelevant_round_part2).current_price, -self.player.in_round(self.player.payoffrelevant_round_part2).current_price, # this is just the inverse price and for display purposes only self.player.lotterychoice_auto, self.player.in_round(1).drawC, self.player.in_round(1).drawD, externalDM ] self.participant.vars['payoff_info_part2'] = [ self.player.lotterychoice_auto, self.player.payoff_part1_converted, self.player.payoffrelevant_round_part2, self.player.lotteryA_high, self.player.lotteryA_low, self.player.draw, self.player.lotteryB_high, self.player.lotteryB_low, self.player.payoff_part2, self.player.payoff_part2_converted, self.player.final_payoff_converted ] return dict( # get the information about part 1 payoffrelevant_round_part1 = self.player.in_round(1).payoffrelevant_round_part1, part1_low = self.player.in_round(1).payoffrelevant_round_part1_low, part1_high = self.player.in_round(1).payoffrelevant_round_part1_high, payoff_part1 = self.player.in_round(1).payoff_part1, lotterychoice_part1 = self.player.in_round(1).lotterychoice_part1, # if self=0 --> autonomy happened in payoff-relevant round self = self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice, price = self.player.in_round(self.player.payoffrelevant_round_part2).current_price, bonus = -self.player.in_round(self.player.payoffrelevant_round_part2).current_price, # this is just the inverse price and for display purposes only lotterychoice_part2 = self.player.lotterychoice_auto, drawC = self.player.in_round(1).drawC, drawD = self.player.in_round(1).drawD, externalDM = externalDM ) class Payoff_Screen_End(Page): form_model = 'player' def is_displayed(self): return self.round_number == Constants.num_rounds # only display in the last round ##################################################################################### def vars_for_template(self): externalDM = "none" auto = self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice if auto == 0: # if lottery choice was not delegated in payoff-relevant round if self.player.lotterychoice_auto == 0: # if lottery C was chosen self.player.payoff_part2 = self.player.in_round(1).drawC - self.player.in_round(self.player.payoffrelevant_round_part2).current_price self.player.draw = self.player.in_round(1).drawC else: # if lottery D was chosen self.player.payoff_part2 = self.player.in_round(1).drawD - self.player.in_round(self.player.payoffrelevant_round_part2).current_price self.player.draw = self.player.in_round(1).drawD ##### calculate final payoff in ECU and real currency (only in case of non-delegation) self.player.final_payoff = self.player.in_round(1).payoff_part1 + self.player.payoff_part2 + Constants.showup_fee self.player.final_payoff_converted = self.player.final_payoff * Constants.XR self.player.payoff_part1_converted = self.player.in_round(1).payoff_part1 * Constants.XR self.player.payoff_part2_converted = self.player.payoff_part2 * Constants.XR else: decision_file = 'Part2_WTP_DOSE/DEM_FEM_PIC2.csv' if self.player.version == 'REPU': decision_file = 'Part2_WTP_DOSE/REP_MALE_PIC1.csv' ######### NEW CASE: Type 2 (decision maker) makes decisions à la strategy method beforehand. Thus we know ################### the delegated decisions for each lottery. Decision file: DEM_FEM_PIC".csv # read & store all SM decisions with open(decision_file) as decisions_file: decisions = list(csv.DictReader(decisions_file)) rowDecision = 20 # default to catch errors (instead of a try condition) for i in range(0, len(decisions)): if float(decisions[i]['Bhigh']) == round(self.player.lotteryB_high,0): rowDecision = i #print(rowDecision) if decisions[rowDecision]['Decision'] == 'A': externalDM = "A" #### make a random draw from BOTH lotteries! draw = random.randint(1, 100) if (draw / 100 < self.player.probA_low): self.player.payoff_part2 = self.player.lotteryA_low else: self.player.payoff_part2 = self.player.lotteryA_high elif decisions[rowDecision]['Decision'] == 'B': externalDM = "B" #### make a random draw from BOTH lotteries! draw = random.randint(1, 100) if (draw / 100 < self.player.probB_low): self.player.payoff_part2 = self.player.lotteryB_low else: self.player.payoff_part2 = self.player.lotteryB_high ############################################## self.player.payoff_part2_converted = self.player.payoff_part2 * Constants.XR ##### calculate final payoff in ECU and real currency (only in case of non-delegation) #self.player.final_payoff = self.player.in_round(1).payoff_part1 + Constants.showup_fee self.player.final_payoff = self.player.in_round(1).payoff_part1 + Constants.showup_fee + self.player.payoff_part2 self.player.final_payoff_converted = self.player.final_payoff * Constants.XR self.player.payoff_part1_converted = self.player.in_round(1).payoff_part1 * Constants.XR self.player.payoff = self.player.final_payoff_converted try: self.participant.label = self.participant.vars['prolificID'] except: self.participant.label = "not set" #### THIS PART IS FOR SP22 (occupational sorting) only # pass variables for displaying at the end of the survey self.participant.vars['payoff_info_part1'] = [ self.player.in_round(1).payoffrelevant_round_part1, self.player.in_round(1).payoffrelevant_round_part1_low, self.player.in_round(1).payoffrelevant_round_part1_high, self.player.in_round(1).payoff_part1, self.player.in_round(1).lotterychoice_part1, self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice, self.player.in_round(self.player.payoffrelevant_round_part2).current_price, -self.player.in_round(self.player.payoffrelevant_round_part2).current_price, # this is just the inverse price and for display purposes only self.player.lotterychoice_auto, self.player.in_round(1).drawC, self.player.in_round(1).drawD, externalDM ] self.participant.vars['payoff_info_part2'] = [ self.player.lotterychoice_auto, self.player.payoff_part1_converted, self.player.payoffrelevant_round_part2, self.player.lotteryA_high, self.player.lotteryA_low, self.player.draw, self.player.lotteryB_high, self.player.lotteryB_low, self.player.payoff_part2, self.player.payoff_part2_converted, self.player.final_payoff_converted ] return dict( # get the information about part 1 payoffrelevant_round_part1 = self.player.in_round(1).payoffrelevant_round_part1, part1_low = self.player.in_round(1).payoffrelevant_round_part1_low, part1_high = self.player.in_round(1).payoffrelevant_round_part1_high, payoff_part1 = self.player.in_round(1).payoff_part1, lotterychoice_part1 = self.player.in_round(1).lotterychoice_part1, # if self=0 --> autonomy happened in payoff-relevant round self = self.player.in_round(self.player.payoffrelevant_round_part2).pricechoice, price = self.player.in_round(self.player.payoffrelevant_round_part2).current_price, bonus = -self.player.in_round(self.player.payoffrelevant_round_part2).current_price, # this is just the inverse price and for display purposes only lotterychoice_part2 = self.player.lotterychoice_auto, drawC = self.player.in_round(1).drawC, drawD = self.player.in_round(1).drawD, externalDM = externalDM ) ################## PROLIFIC PILOT ONLY (REDUCED SURVEY + FEEDBACK ###################################################### class Z_Demographics(Page): form_model = 'player' def is_displayed(self): return self.round_number == Constants.num_rounds # only display in the last round form_fields = ['income', 'maritalstatus', 'employmentstatus', 'education', 'religious', 'urbanrural', 'children', 'household', 'race', 'citizen', 'social', 'economic', 'vote', 'voteB', 'registered', 'risk', 'trust1', 'trust2', 'circle', 'attention_check', 'exclusion','tab_survey_part2', 'focus_survey_part2', 'totaltime_survey_part2'] class Xclusion_questionnaire(Page): def is_displayed(self): return self.player.exclusion == 2 ######################################################################################################################## page_sequence = [ A_Intro_Title, C_Intro_General, The_Other_ParticipantBASE, The_Other_ParticipantDEM, The_Other_ParticipantREP, The_Other_ParticipantMALE, The_Other_ParticipantFEMALE, The_Other_ParticipantPIC1, The_Other_ParticipantPIC2, D_Description_Lotteries_seq, E_Description_Choice, E_Description_ChoiceDEM, E_Description_ChoiceREP, E_Description_ChoiceMALE, E_Description_ChoiceFEMALE, E_Description_ChoicePIC1, E_Description_ChoicePIC2, Xclusion, F_Description_RLIM, preQuestion, Question, QuestionDEM, QuestionREP, QuestionMALE, QuestionFEMALE, QuestionPIC1, QuestionPIC2, preDecision, Decision_Self, Decision_Delegation, Z_Demographics, Xclusion_questionnaire, Payoff_Screen_End, ] #page_sequence = [A_Intro_Title,Question,Decision_Self,Decision_Delegation,Payoff_Screen]