from . import models from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction1(Page): def is_displayed(self): return self.subsession.round_number == 1 class Introduction2(Page): def is_displayed(self): return self.subsession.round_number == 1 class Introduction3(Page): def is_displayed(self): return self.subsession.round_number == 1 class quiz(Page): def is_displayed(self): return self.subsession.round_number == 1 form_model = models.Player form_fields = ['quiz_1', 'quiz_2', 'quiz_3', 'quiz_4', 'quiz_5', 'quiz_6'] def error_message(self, values): print('values is', values) if values["quiz_1"] != "3 participants" or values["quiz_2"] != "20 rounds" or values["quiz_3"] != \ "The Buyer will then earn a monetary bonus of 20 points." or values["quiz_4"] != \ "The Buyer will then not earn a monetary bonus." or values["quiz_5"] != \ "That Seller will then earn the number of points he/she asked for his/her part of the puzzle." or \ values["quiz_6"] != "That Seller will then earn zero points in that round.": return 'You gave at least one incorrect answer. You have to answer all six quiz questions correctly to ' \ 'start with the puzzle-pieces task. If you have any questions about the task, you can ask the experimenter.' class Role(Page): def vars_for_template(self): seller1 = self.group.get_player_by_id(2) seller2 = self.group.get_player_by_id(3) if self.player.treatment == 1: seller1.numberofpieces = "90 pieces" seller2.numberofpieces = "10 pieces" else: seller1.numberofpieces = "59 pieces" seller2.numberofpieces = "41 pieces" return {'numberofpieces1': seller1.numberofpieces, 'numberofpieces2': seller2.numberofpieces} def before_next_page(self): if self.player.treatment == 1: self.player.treatmentname = "highly unequal" else: self.player.treatmentname = "slightly unequal" class WTA(Page): form_model = models.Player form_fields = ['WTA'] def is_displayed(self): return self.player.id_in_group == 2 or self.player.id_in_group == 3 def vars_for_template(self): seller1 = self.group.get_player_by_id(2) seller2 = self.group.get_player_by_id(3) if self.player.treatment == 1: seller1.numberofpieces = "90 pieces" seller2.numberofpieces = "10 pieces" else: seller1.numberofpieces = "59 pieces" seller2.numberofpieces = "41 pieces" return {'numberofpieces1': seller1.numberofpieces, 'numberofpieces2': seller2.numberofpieces} class WTP(Page): form_model = models.Player form_fields = ['WTP1', 'WTP2'] def is_displayed(self): return self.player.id_in_group == 1 def error_message(self, values): if values["WTP1"] + values["WTP2"] > 20: return 'You have an endowment of 20 points per round, and can thus maximally offer 20 points for the whole puzzle. Please make sure that the two offers together do not exceed 20 points.' def vars_for_template(self): seller1 = self.group.get_player_by_id(2) seller2 = self.group.get_player_by_id(3) if self.player.treatment == 1: seller1.numberofpieces = "90 pieces" seller2.numberofpieces = "10 pieces" else: seller1.numberofpieces = "59 pieces" seller2.numberofpieces = "41 pieces" return {'numberofpieces1': seller1.numberofpieces, 'numberofpieces2': seller2.numberofpieces} class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): def vars_for_template(self): buyer = self.group.get_player_by_id(1) seller1 = self.group.get_player_by_id(2) seller2 = self.group.get_player_by_id(3) WTA1 = seller1.WTA WTA2 = seller2.WTA WTP1 = buyer.WTP1 WTP2 = buyer.WTP2 price_puzzle = seller1.payoff + seller2.payoff payoff_seller1 = seller1.payoff payoff_seller2 = seller2.payoff payoff_buyer = buyer.payoff spent = seller1.payoff + seller2.payoff if seller1.sell == True: deal1 = "Therefore, the Buyer made a deal with Seller 1 to buy his/her part of the puzzle for" else: deal1 = "Therefore, the Buyer did not make a deal with Seller 1 to buy his/her part of the puzzle for" if seller2.sell == True: deal2 = "Therefore, the Buyer made a deal with Seller 2 to buy his/her part of the puzzle for" else: deal2 = "Therefore, the Buyer did not make a deal with Seller 2 to buy his/her part of the puzzle for" if buyer.success == True: successornot = "The Buyer managed to buy the whole puzzle from the two sellers, and therefore the Buyer receives a bonus of" else: successornot = "The Buyer did not manage to buy the whole puzzle from the two sellers, and therefore the Buyer does not receive a bonus of" return {'WTA1': WTA1, 'WTA2': WTA2, 'WTP1': WTP1, 'WTP2': WTP2, 'price_puzzle': price_puzzle, 'payoff_seller1': payoff_seller1, 'payoff_seller2': payoff_seller2, 'payoff_buyer': payoff_buyer, 'deal1': deal1, 'deal2': deal2, 'successornot': successornot, 'spent': spent} class Waitpage(WaitPage): pass class motives(Page): def is_displayed(self): return self.subsession.round_number == Constants.num_rounds form_model = models.Player form_fields = ['motive_1', 'motive_2', 'motive_3', 'motive_4', 'motive_5', 'motive_6', 'motive_7', 'motive_8'] page_sequence = [ Introduction1, Introduction2, Introduction3, quiz, Role, WTA, WTP, ResultsWaitPage, Results, Waitpage, motives ]