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 3, 5, 2, 3, 5, 0, 0, 14, 0, 0, 13, 0, 0, 10, 0, 0, 20, 0, 0, 10, 0, 0, 20, 5, 3, 6, 3, 5, 6, 2, 4, 7, 8, 2, 2, 2, 4, 7, 8, 2, 2, 5, 5, 5, 2, 2, 2, 12, 3, 1, 2, 4, 2, 12, 3, 1, 2, 4, 2, 4, 4, 4, 3, 6, 3, 5, 4, 4, 2, 8, 3, 7, 3, 3, 3, 7, 3, 7, 2, 7, 2, 12, 2, 7, 2, 7, 2, 12, 2, 4, 6, 2, 5, 3, 4, 6, 5, 2, 8, 2, 3, 3, 2, 8, 1, 3, 13, 3, 2, 8, 1, 3, 13, 6, 2, 5, 5, 2, 6, 6, 2, 5, 5, 2, 6, 0, 0, 11, 0, 0, 10, 5, 3, 4, 1, 7, 4, 4, 6, 4, 2, 10, 4, 4, 6, 4, 2, 10, 4, 3, 3, 4, 2, 2, 5, 4, 1, 11, 3, 7, 1, 1, 11, 1, 6, 1, 6, 1, 6, 4, 8, 1, 5, 2, 2, 2, 3, 3, 3, 4, 1, 3, 1, 4, 2, 3, 4, 8, 2, 4, 7, 2, 8, 4, 7, 2, 10) INEQUALITY_AVERSE_LIFETIME = (1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1) INEQUALITY_AVERSE_PERIOD = (2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1) VECTOR_DOMINANCE = (False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False) CUMULATIVE_DOMINANCE = (False, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, True, False, False, False, False, False, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, False, False, False, False) DISCOUNTING_DOMINANCE = (False, False, True, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False) STATIC = (False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False) PERIOD_WISE_DOMINANCE = (False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False) PERIOD_WISE_VS_DISCOUNTING = (True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False) PERTURBATION = (False, True, False, True, False, True, False, True, False, False, False, True, False, False, True, False, False, True, False, False, False, False, True, False, False, False, True, False, True, False, False, False, True, False, False, False, False, False, False, False, False) DISCOUNTING_DOMINANCE_NOT_PERIOD = (False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, False, True, False, True) ANONYMITY = (False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, False, False, False) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): decision = models.IntegerField(choices=[[1, '1'], [2, '2']], label='Please select which set of payment schedules you would rather be given to the other players, option 1 or option 2.', widget=widgets.RadioSelect) decision_that_counts_round = models.IntegerField() decision_that_counts = models.IntegerField() payment_service = models.StringField(choices=[['Venmo', 'Venmo'], ['Zelle', 'Zelle']], label='Would you like us to send your payments using Venmo or using Zelle?', widget=widgets.RadioSelect) payment_username = models.StringField(label='Please enter the email address you would like your amazon gift cards to be sent to.') choice1player1pay1 = models.FloatField() choice1player1pay2 = models.FloatField() choice1player1pay3 = models.FloatField() choice1player2pay1 = models.FloatField() choice1player2pay2 = models.FloatField() choice1player2pay3 = models.FloatField() choice2player1pay1 = models.FloatField() choice2player1pay2 = models.FloatField() choice2player1pay3 = models.FloatField() choice2player2pay1 = models.FloatField() choice2player2pay2 = models.FloatField() choice2player2pay3 = models.FloatField() chosenplayer1pay1 = models.FloatField(initial=0) chosenplayer1pay2 = models.FloatField(initial=0) chosenplayer1pay3 = models.FloatField(initial=0) chosenplayer2pay1 = models.FloatField(initial=0) chosenplayer2pay2 = models.FloatField(initial=0) chosenplayer2pay3 = models.FloatField(initial=0) inequality_averse_lifetime = models.BooleanField() inequality_averse_period = models.BooleanField() vector_dominant = models.BooleanField() cumulatively_dominant = models.BooleanField() discounting_dominant = models.BooleanField() static = models.BooleanField() period_wise = models.BooleanField() period_wise_versus_discounting = models.BooleanField() perturbation = models.BooleanField() comp_1 = models.FloatField(label='If you selected option 1, how many dollars will player 1 be paid one month from today?') comp_2 = models.FloatField(label='If you selected option 2, how many dollars will player 2 be 3 months from today?') discounting_not_period = models.BooleanField() anonymity = models.BooleanField() def set_decision_that_counts_round(player: Player): import random player.decision_that_counts_round = random.randint(1,C.NUM_ROUNDS) def set_decision_that_counts(player: Player): for i in range(1,C.NUM_ROUNDS+1): if player.decision_that_counts_round==i: counts=player.in_round(i) player.decision_that_counts=counts.decision def set_chosen(player: Player): if player.decision_that_counts==1: player.chosenplayer1pay1=C.SCHEDULE1[6*(player.decision_that_counts_round-1)] player.chosenplayer1pay2=C.SCHEDULE1[6*(player.decision_that_counts_round-1)+1] player.chosenplayer1pay3=C.SCHEDULE1[6*(player.decision_that_counts_round-1)+2] player.chosenplayer2pay1=C.SCHEDULE1[6*(player.decision_that_counts_round-1)+3] player.chosenplayer2pay2=C.SCHEDULE1[6*(player.decision_that_counts_round-1)+4] player.chosenplayer2pay3=C.SCHEDULE1[6*(player.decision_that_counts_round-1)+5] if player.decision_that_counts==2: player.chosenplayer1pay1=C.SCHEDULE2[6*(player.decision_that_counts_round-1)] player.chosenplayer1pay2=C.SCHEDULE2[6*(player.decision_that_counts_round-1)+1] player.chosenplayer1pay3=C.SCHEDULE2[6*(player.decision_that_counts_round-1)+2] player.chosenplayer2pay1=C.SCHEDULE2[6*(player.decision_that_counts_round-1)+3] player.chosenplayer2pay2=C.SCHEDULE2[6*(player.decision_that_counts_round-1)+4] player.chosenplayer2pay3=C.SCHEDULE2[6*(player.decision_that_counts_round-1)+5] def set_Inequality_Aversion(player: Player): r=player.round_number if player.decision==C.INEQUALITY_AVERSE_LIFETIME[r-1]: if player.decision==C.INEQUALITY_AVERSE_PERIOD[r-1]: player.inequality_averse_lifetime=1 player.inequality_averse_period=1 if player.decision!=C.INEQUALITY_AVERSE_PERIOD[r-1]: player.inequality_averse_lifetime=1 player.inequality_averse_period=0 if player.decision!=C.INEQUALITY_AVERSE_LIFETIME[r-1]: if player.decision==C.INEQUALITY_AVERSE_PERIOD[r-1]: player.inequality_averse_lifetime=0 player.inequality_averse_period=1 if player.decision!=C.INEQUALITY_AVERSE_PERIOD[r-1]: player.inequality_averse_lifetime=0 player.inequality_averse_period=0 def set_dominance_type(player: Player): r=player.round_number if C.VECTOR_DOMINANCE[r-1]==1: player.vector_dominant=1 player.cumulatively_dominant=0 player.discounting_dominant=0 player.period_wise=0 player.period_wise_versus_discounting=0 player.static=0 player.perturbation=0 player.discounting_not_period=0 player.anonymity=0 if C.CUMULATIVE_DOMINANCE[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=1 player.discounting_dominant=0 player.period_wise=0 player.period_wise_versus_discounting=0 player.static=0 player.perturbation=0 player.discounting_not_period=0 player.anonymity=0 if C.DISCOUNTING_DOMINANCE[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=0 player.discounting_dominant=1 player.period_wise=0 player.period_wise_versus_discounting=0 player.static=0 player.perturbation=0 player.discounting_not_period=0 player.anonymity=0 if C.PERIOD_WISE_DOMINANCE[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=0 player.discounting_dominant=0 player.period_wise=1 player.period_wise_versus_discounting=0 player.static=0 player.perturbation=0 player.discounting_not_period=0 player.anonymity=0 if C.PERIOD_WISE_VS_DISCOUNTING[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=0 player.discounting_dominant=0 player.period_wise=0 player.period_wise_versus_discounting=1 player.static=0 player.perturbation=0 player.discounting_not_period=0 player.anonymity=0 if C.PERTURBATION[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=0 player.discounting_dominant=0 player.period_wise=0 player.period_wise_versus_discounting=0 player.static=0 player.perturbation=1 player.discounting_not_period=0 player.anonymity=0 if C.STATIC[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=0 player.discounting_dominant=0 player.period_wise=0 player.period_wise_versus_discounting=0 player.static=1 player.perturbation=0 player.discounting_not_period=0 player.anonymity=0 if C.DISCOUNTING_DOMINANCE_NOT_PERIOD[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=0 player.discounting_dominant=0 player.period_wise=0 player.period_wise_versus_discounting=0 player.static=0 player.perturbation=0 player.discounting_not_period=1 player.anonymity=0 if C.ANONYMITY[r-1]==1: player.vector_dominant=0 player.cumulatively_dominant=0 player.discounting_dominant=0 player.period_wise=0 player.period_wise_versus_discounting=0 player.static=0 player.perturbation=0 player.discounting_not_period=0 player.anonymity=1 class MyPageNotDisplayed(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==1: return False else: return False class Introduction(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==1: return True else: return False class Consent(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==1: return True else: return False class PaymentInfo(Page): form_model = 'player' form_fields = ['payment_username'] @staticmethod def is_displayed(player: Player): if player.round_number==1: return True else: return False class MyWaitPage(WaitPage): @staticmethod def is_displayed(player: Player): if player.round_number==1: return True else: return False class InstructionsPart1(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==1: return True else: return False class Example(Page): form_model = 'player' form_fields = ['comp_1', 'comp_2'] @staticmethod def is_displayed(player: Player): if player.round_number==1: return True else: return False @staticmethod def error_message(player: Player, values): if not values["comp_1"]==4: return "Please answer question 1 again. If you need help with this question, please raise your hand." if not values["comp_2"]==9: return "Please answer question 2 again. If you need help with this question, please raise your hand." class ChoicesPart1(Page): form_model = 'player' form_fields = ['decision'] @staticmethod def is_displayed(player: Player): session = player.session subsession = player.subsession for p in subsession.get_players(): r=player.round_number r2=r player.choice1player1pay1=round(C.SCHEDULE1[6*(r2-1)],2) player.choice1player1pay2=round(C.SCHEDULE1[6*(r2-1)+1],2) player.choice1player1pay3=round(C.SCHEDULE1[6*(r2-1)+2],2) player.choice1player2pay1=round(C.SCHEDULE1[6*(r2-1)+3],2) player.choice1player2pay2=round(C.SCHEDULE1[6*(r2-1)+4],2) player.choice1player2pay3=round(C.SCHEDULE1[6*(r2-1)+5],2) player.choice2player1pay1=round(C.SCHEDULE2[6*(r2-1)],2) player.choice2player1pay2=round(C.SCHEDULE2[6*(r2-1)+1],2) player.choice2player1pay3=round(C.SCHEDULE2[6*(r2-1)+2],2) player.choice2player2pay1=round(C.SCHEDULE2[6*(r2-1)+3],2) player.choice2player2pay2=round(C.SCHEDULE2[6*(r2-1)+4],2) player.choice2player2pay3=round(C.SCHEDULE2[6*(r2-1)+5],2) return True @staticmethod def before_next_page(player: Player, timeout_happened): set_Inequality_Aversion(player), set_dominance_type(player) class DTCSelection(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==C.NUM_ROUNDS: return True else: return False @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant set_decision_that_counts_round(player) set_decision_that_counts(player) set_chosen(player) if C.NUM_ROUNDS>1: r1=player.in_round(1) participant.vars['decision1']=r1.decision r16=player.in_round(16) participant.vars['decision16']=r16.decision r28=player.in_round(28) participant.vars['decision28']=r28.decision r29=player.in_round(29) participant.vars['decision29']=r29.decision r35=player.in_round(35) participant.vars['decision35']=r35.decision r38=player.in_round(38) participant.vars['decision38']=r38.decision class MyWaitPage2NotDisplayed(WaitPage): @staticmethod def is_displayed(player: Player): if player.round_number==C.NUM_ROUNDS: return True else: return False class DTCSelectionRedux(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==C.NUM_ROUNDS: return True else: return False class EndPart1(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==C.NUM_ROUNDS: return True else: return False page_sequence = [MyPageNotDisplayed, Introduction, Consent, PaymentInfo, MyWaitPage, InstructionsPart1, Example, ChoicesPart1, DTCSelection, MyWaitPage2NotDisplayed, DTCSelectionRedux, EndPart1]