from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class ProlificID(Page): form_model = 'player' form_fields = ['ProlificID'] def is_displayed(self): return self.round_number == 1 class InitialGrouping(WaitPage): wait_for_all_groups = True body_text = 'We are still waiting for the other participants to join the session and enter their ID. We appreciate your patience.' def is_displayed(self): return self.round_number == 1 class Instructions(Page): form_model = 'player' timeout_seconds = 180 def is_displayed(self): return self.round_number == 1 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True 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: 4 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: 1 minute' 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 def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 else: return 15 page_sequence = [ProlificID, InitialGrouping, Instructions, Decision, ContinueInstructions, GroupingWaitPage, ResultsWaitPage, Calculate]