from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'instructions_knowledge_check' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 BUYER_ROLE = 'Buyer' SELLER_ROLE = 'Seller' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): first_offer = models.StringField(choices=[['The buyer', 'The buyer'], ['The seller', 'The seller'], ['The buyer and seller make an offer simultaneously and a random draw determines which is used', 'The buyer and seller make an offer simultaneously and a random draw determines which is used ']], label='Who makes the first offer?', widget=widgets.RadioSelect) guaranteed_agreement = models.StringField(choices=[['True', 'True'], ['False', 'False']], label='You are guaranteed to reach an agreement. ', widget=widgets.RadioSelect) no_agreement_buyer = models.StringField(choices=[['The participation compensation (10 CAD) only', 'The participation compensation (10 CAD) only'], ['The participation compensation (10 CAD) and the digital token', 'The participation compensation (10 CAD) and the digital token'], ['The participation compensation (10 CAD) and the digital token, minus what the buyer pays for the digital token', 'The participation compensation (10 CAD) and the digital token, minus what the buyer pays for the digital token'], ['The digital token', 'The digital token']], label='If you DO NOT reach an agreement, the BUYER receives:', widget=widgets.RadioSelect) no_agreement_seller = models.StringField(choices=[['The participation compensation (10 CAD) only', 'The participation compensation (10 CAD) only'], ['The participation compensation (10 CAD) and the digital token', 'The participation compensation (10 CAD) and the digital token'], ['The participation compensation (10 CAD) and the sale price (what the buyer pays) of the digital token', 'The participation compensation (10 CAD) and the sale price (what the buyer pays) of the digital token'], ['The digital token', 'The digital token']], label='If you DO NOT reach an agreement, the SELLER receives: ', widget=widgets.RadioSelect) agreement_buyer = models.StringField(choices=[['The participation compensation (10 CAD)', 'The participation compensation (10 CAD)'], ['The digital token only', 'The digital token only'], ['250 EXD', '250 EXD'], ['The participation compensation (10 CAD) minus the sale price of the digital token, and the digital token (worth 100 EXD)', 'The participation compensation (10 CAD) minus the sale price of the digital token, and the digital token (worth 100 EXD)']], label='If you DO reach an agreement, the BUYER receives:', widget=widgets.RadioSelect) agreement_seller = models.StringField(choices=[['250 EXD', '250 EXD'], ['The participation compensation (10 CAD) only', 'The participation compensation (10 CAD) only'], ['The participation compensation (10 CAD) and the sale price (what the buyer pays) of the digital token', 'The participation compensation (10 CAD) and the sale price (what the buyer pays) of the digital token'], ['The digital token only', 'The digital token only']], label='If you DO reach an agreement, the SELLER receives:', widget=widgets.RadioSelect) max_rounds = models.StringField(choices=[['1', '1'], ['3', '3'], ['5', '5'], ['10', '10'], ['15', '15']], label='What is the maximum number of rounds in the negotiation? ', widget=widgets.RadioSelect) correct_1 = models.IntegerField() correct_2 = models.IntegerField() correct_3b = models.IntegerField() correct_3s = models.IntegerField() correct_4b = models.IntegerField() correct_4s = models.IntegerField() correct_5 = models.IntegerField() quiz_payoff = models.IntegerField() is_buyer = models.BooleanField() is_seller = models.BooleanField() def c1(player: Player): if player.first_offer=="The buyer and seller make an offer simultaneously and a random draw determines which is used": player.correct_1=1 else: player.correct_1=0 def c2(player: Player): if player.guaranteed_agreement=="False": player.correct_2=1 else: player.correct_2=0 def c3b(player: Player): if player.no_agreement_buyer=="The participation compensation (10 CAD) only": player.correct_3b=1 else: player.correct_3b=0 def c3s(player: Player): if player.no_agreement_seller=="The participation compensation (10 CAD) only": player.correct_3s=1 else: player.correct_3s=0 def c4b(player: Player): if player.agreement_buyer=="The participation compensation (10 CAD) minus the sale price of the digital token, and the digital token (worth 100 EXD)": player.correct_4b=1 else: player.correct_4b=0 def c4s(player: Player): if player.agreement_seller=="The participation compensation (10 CAD) and the sale price (what the buyer pays) of the digital token": player.correct_4s=1 else: player.correct_4s=0 def c5(player: Player): if player.max_rounds=="5": player.correct_5=1 else: player.correct_5=0 def buyer_seller(player: Player): if player.role==C.BUYER_ROLE: player.is_buyer=True else: player.is_buyer=False if player.role==C.SELLER_ROLE: player.is_seller=True else: player.is_seller=False class INTRO(Page): form_model = 'player' @staticmethod def before_next_page(player: Player, timeout_happened): if player.role==C.BUYER_ROLE: player.is_buyer=True else: player.is_buyer=False if player.role==C.SELLER_ROLE: player.is_seller=True else: player.is_seller=False class INSTRUCTIONS(Page): form_model = 'player' class INSTRUCTIONS_2(Page): form_model = 'player' @staticmethod def before_next_page(player: Player, timeout_happened): buyer_seller(player) class ROLE_ASSIGNMENT_WAIT(WaitPage): wait_for_all_groups = True title_text = 'Please Wait' body_text = 'Please wait for the other participants in the session.' class YOUR_ROLE(Page): form_model = 'player' class Q1(Page): form_model = 'player' form_fields = ['first_offer'] @staticmethod def before_next_page(player: Player, timeout_happened): c1(player) class A1(Page): form_model = 'player' class Q2(Page): form_model = 'player' form_fields = ['guaranteed_agreement'] @staticmethod def before_next_page(player: Player, timeout_happened): c2(player) class A2(Page): form_model = 'player' class Q3B(Page): form_model = 'player' form_fields = ['no_agreement_buyer'] @staticmethod def before_next_page(player: Player, timeout_happened): c3b(player) class A3B(Page): form_model = 'player' class Q3S(Page): form_model = 'player' form_fields = ['no_agreement_seller'] @staticmethod def before_next_page(player: Player, timeout_happened): c3s(player) class A3S(Page): form_model = 'player' class Q4B(Page): form_model = 'player' form_fields = ['agreement_buyer'] @staticmethod def before_next_page(player: Player, timeout_happened): c4b(player) class A4B(Page): form_model = 'player' class Q4S(Page): form_model = 'player' form_fields = ['agreement_seller'] @staticmethod def before_next_page(player: Player, timeout_happened): c4s(player) class A4S(Page): form_model = 'player' class Q5(Page): form_model = 'player' form_fields = ['max_rounds'] @staticmethod def before_next_page(player: Player, timeout_happened): c5(player) class A5(Page): form_model = 'player' @staticmethod def before_next_page(player: Player, timeout_happened): player.quiz_payoff=player.correct_1+player.correct_2+player.correct_3b+player.correct_3s+player.correct_4b+player.correct_4s+player.correct_5 class RESULTS(Page): form_model = 'player' @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.quiz_payoff = player.quiz_payoff participant.is_buyer = player.is_buyer participant.is_seller = player.is_seller participant.quiz_payoff=player.quiz_payoff class END_OF_APP_WAIT(WaitPage): wait_for_all_groups = True title_text = 'Please Wait' page_sequence = [INTRO, INSTRUCTIONS, INSTRUCTIONS_2, ROLE_ASSIGNMENT_WAIT, YOUR_ROLE, Q1, A1, Q2, A2, Q3B, A3B, Q3S, A3S, Q4B, A4B, Q4S, A4S, Q5, A5, RESULTS, END_OF_APP_WAIT]