from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Wait0(WaitPage): group_by_arrival_time = True title_text = 'Please wait while you are assigned a partner...' template_name = 'App1/Wait0.html' def is_displayed(self): self.subsession.group_randomization(current_player=self.player, round_used=self.subsession.round_used, first_player=self.subsession.first_player, second_player=self.subsession.second_player) return self.subsession.round_used == False and self.participant.vars['participant_done'] == False class Seller_page2_success(Page): form_model = 'group' timeout_seconds = 60 def is_displayed(self): return self.player.id_in_group == 1 and self.group.TRANSFER_SUCCESS == True and self.participant.vars['participant_done'] == False class Seller_page2_fail(Page): form_model = 'group' timeout_seconds = 60 def is_displayed(self): return self.player.id_in_group == 1 and self.group.TRANSFER_SUCCESS == False and self.participant.vars['participant_done'] == False class Buyer_page2(Page): form_model = 'player' timeout_seconds = 60 def is_displayed(self): return self.player.id_in_group == 2 and self.group.TRANSFER_SUCCESS in [True, False] and self.participant.vars['participant_done'] == False class Wait1(WaitPage): def is_displayed(self): return self.group.TRANSFER_SUCCESS in [True, False] and self.participant.vars['participant_done'] == False body_text = 'Waiting on other player' class Seller_chat_page(Page): form_model = 'group' timeout_seconds = 150 def is_displayed(self): return self.player.id_in_group == 1 and self.group.TRANSFER_SUCCESS in [True, False] and self.participant.vars['participant_done'] == False class Buyer_chat_page(Page): form_model = 'player' timeout_seconds = 150 def is_displayed(self): return self.player.id_in_group == 2 and self.group.TRANSFER_SUCCESS in [True, False] and self.participant.vars['participant_done'] == False class Seller_page3(Page): form_model = 'group' timeout_seconds = 120 form_fields = ['A_META_BELIEVE'] def is_displayed(self): return self.player.id_in_group == 1 and self.group.TRANSFER_SUCCESS in [True, False] and self.participant.vars['participant_done'] == False class Buyer_page3_belief_first(Page): form_model = 'group' timeout_seconds = 120 def is_displayed(self): return self.player.id_in_group == 2 and self.group.DECISION_FIRST == False and self.participant.vars['participant_done'] == False form_fields = ['B_BELIEVE', 'B_TRANSFER'] def vars_for_template(self): return dict( B_TRANSFER_label='Would you like to transfer {} to the "Seller"'.format(Constants.fee) ) class Buyer_page3_decision_first(Page): form_model = 'group' timeout_seconds = 120 def is_displayed(self): return self.player.id_in_group == 2 and self.group.DECISION_FIRST == True and self.participant.vars['participant_done'] == False form_fields = ['B_BELIEVE', 'B_TRANSFER'] def vars_for_template(self): return dict( B_TRANSFER_label='Would you like to transfer {} to the "Seller"'.format(Constants.fee) ) class Wait3(WaitPage): body_text = 'Waiting on other player' def is_displayed(self): return self.group.TRANSFER_SUCCESS in [True, False] and self.participant.vars['participant_done'] == False def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): form_model = 'player' timeout_seconds = 45 def is_displayed(self): return self.group.TRANSFER_SUCCESS in [True, False] and self.participant.vars['participant_done'] == False def before_next_page(self): import time self.participant.vars['wait_page_arrival'] = time.time() # def is_displayed(self): # return self.participant.id_in_session in [1, 2, 3, 4] page_sequence = [Wait0, Seller_page2_success, Seller_page2_fail, Buyer_page2, Wait1, Seller_chat_page, Buyer_chat_page, Seller_page3, Buyer_page3_belief_first, Buyer_page3_decision_first, Wait3, Results]