from . import models from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class welcome(Page): def is_displayed(self): return self.round_number == 1 class WaitPageA(WaitPage): pass class Introduction1(Page): def is_displayed(self): return self.round_number == 1 class Introduction2(Page): def is_displayed(self): return self.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'] def error_message(self, values): print('values is', values) if values["quiz_1"] != "3 Sellers" or values["quiz_2"] != "3 rounds" or values["quiz_3"] != \ "The Buyer will then NOT buy any lottery tickets." or values["quiz_4"] != \ "The Buyer will then buy all three lottery tickets.": return 'You gave at least one incorrect answer. You have to answer all four quiz questions correctly to ' \ 'start with the task. If you have any questions about the task, you can ask the experimenter.' class Introduction_r23(Page): def is_displayed(self): return self.round_number == 2 or self.round_number == 3 def vars_for_template(self): previousround = self.round_number - 1 thisround = self.round_number return { 'thisround': thisround, 'previousround': previousround } class Accountability(Page): def is_displayed(self): return self.group.accountability == True class Request(Page): form_model = models.Player form_fields = ['WTA'] def vars_for_template(self): if self.round_number == 1: firstsecondorthird = "first" if self.round_number == 2: firstsecondorthird = "second" if self.round_number == 3: firstsecondorthird = "third" if self.group.treatment == "certainty": WTPrange = "200 points" uncertaintyexplanation = " " if self.group.treatment == "lowuncertainty": WTPrange = "150 to 250 points" uncertaintyexplanation = "How many points exactly the Buyer offers in this round is uncertain. The Buyer will use a computer to determine his/her exact offer. This computer will randomly determine the amount of points the Buyer offers to the three Sellers. However, you know that the Buyer's offer will minimally be 150 and maximally 250 points." if self.group.treatment == "highuncertainty": WTPrange = "100 to 300 points" uncertaintyexplanation = "How many points exactly the Buyer offers in this round is uncertain. The Buyer will use a computer to determine his/her exact offer. This computer will randomly determine the amount of points the Buyer offers to the three Sellers. However, you know that the Buyer's offer will minimally be 100 and maximally 300 points." return { 'WTPrange': WTPrange, 'uncertaintyexplanation': uncertaintyexplanation, 'firstsecondorthird': firstsecondorthird } class uncertainty_check(Page): form_model = models.Player form_fields = ['uncertaintycheck'] class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class ResultsWaitPage_r3(WaitPage): def is_displayed(self): return self.round_number == 3 def after_all_players_arrive(self): self.group.ticketssold = self.group.in_round(1).deal + self.group.in_round(2).deal + self.group.in_round(3).deal self.group.ticketskept = 3 - self.group.ticketssold class Accountability_round1(Page): def is_displayed(self): return self.group.accountability == True and self.round_number == 3 def vars_for_template(self): requestround1 = self.player.in_round(1).WTA if self.group.in_round(1).treatment == "certainty": WTPrange1 = "200 points" if self.group.in_round(1).treatment == "lowuncertainty": WTPrange1 = "150 to 250 points" if self.group.in_round(1).treatment == "highuncertainty": WTPrange1 = "100 to 300 points" return { 'requestround1': requestround1, 'WTPrange1': WTPrange1 } class WaitPage1(WaitPage): pass class Accountability_round2(Page): def is_displayed(self): return self.group.accountability == True and self.round_number == 3 def vars_for_template(self): requestround2 = self.player.in_round(2).WTA if self.group.in_round(2).treatment == "certainty": WTPrange2 = "200 points" if self.group.in_round(2).treatment == "lowuncertainty": WTPrange2 = "150 to 250 points" if self.group.in_round(2).treatment == "highuncertainty": WTPrange2 = "100 to 300 points" return { 'requestround2': requestround2, 'WTPrange2': WTPrange2 } class WaitPage2(WaitPage): pass class Accountability_round3(Page): def is_displayed(self): return self.group.accountability == True and self.round_number == 3 def vars_for_template(self): requestround3 = self.player.in_round(3).WTA if self.group.in_round(3).treatment == "certainty": WTPrange3 = "200 points" if self.group.in_round(3).treatment == "lowuncertainty": WTPrange3 = "150 to 250 points" if self.group.in_round(3).treatment == "highuncertainty": WTPrange3 = "100 to 300 points" return { 'requestround3': requestround3, 'WTPrange3': WTPrange3 } class accountability_check(Page): def is_displayed(self): return self.subsession.round_number == Constants.num_rounds form_model = models.Player form_fields = ['accountabilitycheck_1', 'accountabilitycheck_2', 'accountabilitycheck_3'] class WaitPage3(WaitPage): pass class Results(Page): def is_displayed(self): return self.round_number == 3 def vars_for_template(self): return { 'ticketssold': self.group.ticketssold, 'ticketskept': self.group.ticketskept } class Lottery(Page): def is_displayed(self): return self.round_number == 3 def vars_for_template(self): self.player.numberofprizes = self.player.in_round(1).prize + self.player.in_round(2).prize + self.player.in_round(3).prize return { 'numberofprizes': self.player.numberofprizes } page_sequence = [ welcome, WaitPageA, Introduction1, Introduction2, quiz, Introduction_r23, Accountability, Request, uncertainty_check, ResultsWaitPage, ResultsWaitPage_r3, Accountability_round1, WaitPage1, Accountability_round2, WaitPage2, Accountability_round3, accountability_check, WaitPage3, Results, Lottery, ]