from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class MyWaitPage(WaitPage): group_by_arrival_time = True after_all_players_arrive = 'AssignTreatment2' body_text = 'Waiting for another participant... (if you are stuck for more than 5 minutes, you can exit, and use EXIT7777 as your mTurk completion code.)' class MyPage(Page): form_model = 'player' form_fields = ['ChoiceA'] timeout_seconds = 90 def is_displayed(self): return self.player.id_in_group == 1 def before_next_page(self): if self.timeout_happened: self.player.xyz = True self.player.ChoiceA = True self.player.Upload() class MyPage5(Page): form_model = 'player' form_fields = ['ChoiceB'] timeout_seconds = 90 def is_displayed(self): return self.player.id_in_group == 2 def before_next_page(self): if self.timeout_happened: self.player.xyz = True self.player.ChoiceB = True self.player.Upload() class MyWaitPage2(WaitPage): after_all_players_arrive = 'Dice' body_text = "Waiting for your partner's choice... (if you are stuck for more than 5 minutes, you can exit, and use EXIT8888 as your mTurk completion code.)" class MyPage2(Page): form_model = 'player' form_fields = ['ChoiceB'] def is_displayed(self): return self.player.id_in_group == 1 def before_next_page(self): if self.timeout_happened or self.player.xyz: self.player.xyz = True self.player.ChoiceB = True if self.session.config['Treatment'] == 0: self.player.CalcPayoffs() if self.session.config['Treatment'] == 1: self.player.CalcPayoffsInd() def get_timeout_seconds(self): if self.player.xyz: return 1 else: return 60 class MyPage6(Page): form_model = 'player' form_fields = ['ChoiceA'] def is_displayed(self): return self.player.id_in_group == 2 def before_next_page(self): if self.timeout_happened or self.player.xyz: self.player.xyz = True self.player.ChoiceA = True if self.session.config['Treatment'] == 0: self.player.CalcPayoffs() if self.session.config['Treatment'] == 1: self.player.CalcPayoffsInd() def get_timeout_seconds(self): if self.player.xyz: return 1 else: return 60 class MyWaitPage3(WaitPage): body_text = "Waiting for your partner's choice... (if you are stuck for more than 5 minutes, you can exit, and use EXIT9999 as your mTurk completion code.)" class Result00(Page): form_model = 'player' form_fields = ['WTP', 'Herd'] def is_displayed(self): return self.session.config['Treatment'] == 0 and self.group.Treatment2 == 0 class Result10(Page): form_model = 'player' form_fields = ['WTP', 'Herd'] def is_displayed(self): return self.session.config['Treatment'] == 1 and self.group.Treatment2 == 0 class Result01(Page): form_model = 'player' form_fields = ['Seq2', 'Seq1'] def is_displayed(self): return self.session.config['Treatment'] == 0 and self.group.Treatment2 == 1 class Result11(Page): form_model = 'player' form_fields = ['Seq2', 'Seq1'] def is_displayed(self): return self.session.config['Treatment'] == 1 and self.group.Treatment2 == 1 class MyPage4(Page): form_model = 'player' page_sequence = [MyWaitPage, MyPage, MyPage5, MyWaitPage2, MyPage2, MyPage6, MyWaitPage3, Result00, Result10, Result01, Result11, MyPage4]