from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Beliefs(Page): form_model = 'player' form_fields = ['beliefs'] def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.beliefs = 21 def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 else: return 60 class Decision(Page): form_model = 'player' form_fields = ['decision'] def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.decision = 'A' def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 else: return 60 class ContinueInstructions(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 else: return 30 class GroupingWaitPage(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'Grouping_random' body_text = 'Maximum wait time: 5 minutes 30 seconds' def is_displayed(self): return self.round_number == 1 class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' body_text = 'Maximum wait time: 2 minutes' def is_displayed(self): return self.round_number == 2 class Calculate(Page): form_model = 'player' def is_displayed(self): return self.round_number == 2 def before_next_page(self): participant = self.participant playerf = self.player.in_round(1) players = self.player.in_round(2) participant.vars['first'] = playerf.decision participant.vars['second'] = players.decision participant.vars['ofirst'] = playerf.other_player().decision participant.vars['osecond'] = players.other_player().decision participant.vars['belief'] = playerf.beliefs participant.vars['beliefs'] = players.beliefs def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 else: return 15 page_sequence = [Beliefs, Decision, ContinueInstructions, GroupingWaitPage, ResultsWaitPage, Calculate]