from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from datetime import datetime def check_timeout(self): if self.timeout_happened: self.participant.PARTNER_ALIVE = False def is_displayed(self): return (self.participant.PARTNER_ALIVE == True) def isnot_displayed(self): return (self.participant.PARTNER_ALIVE == False) class InstructionsS2(Page): is_displayed = is_displayed timeout_seconds = Constants.time_waiting before_next_page = check_timeout class Wait(WaitPage): after_self_arrives = 'check_partner_status' class InstructionsTwist(Page): is_displayed = is_displayed timeout_seconds = Constants.time_waiting before_next_page = check_timeout class ControlQuestions(Page): is_displayed = is_displayed timeout_seconds = Constants.time_waiting before_next_page = check_timeout form_model = 'player' form_fields = ['control_question1', 'control_question2'] class RoleInfo(Page): is_displayed = is_displayed timeout_seconds = Constants.time_waiting before_next_page = check_timeout class Decision(Page): is_displayed = is_displayed timeout_seconds = Constants.time_waiting form_model = 'player' def get_form_fields(self): if self.player.role() == 'Sender': return ['decisionSender'] if self.player.role() == 'Receiver': return ['guessReceiver'] class ResultsWaitPage(WaitPage): is_displayed = is_displayed after_all_players_arrive = 'set_payoffs' before_next_page = 'check_partner_status' class Results(Page): is_displayed = is_displayed timeout_seconds = Constants.time_waiting before_next_page = check_timeout class PrevInstrS3(Page): timeout_seconds = Constants.time_waiting before_next_page = check_timeout def is_displayed(self): return (self.participant.PARTNER_ALIVE == True and self.player.role() == 'Receiver') class FindoutDecision(Page): form_model = 'player' form_fields = ['revealdecision'] timeout_seconds = Constants.time_waiting before_next_page = check_timeout def is_displayed(self): return (self.participant.PARTNER_ALIVE == True and self.player.role() == 'Receiver') class FindoutWaitPage(WaitPage): def is_displayed(self): return (self.participant.PARTNER_ALIVE == True) after_self_arrives = 'checkSenderWish' class FindoutResults(Page): def is_displayed(self): return (self.participant.PARTNER_ALIVE == True and self.player.role() == 'Receiver' and self.player.revealdecision == 1) timeout_seconds = Constants.time_waiting before_next_page = check_timeout class Failed(Page): is_displayed=isnot_displayed form_model='player' form_fields=['OpenQ2'] class Thanks(Page): is_displayed=isnot_displayed page_sequence = [Wait,InstructionsS2, InstructionsTwist, Wait, ControlQuestions, RoleInfo, Decision, ResultsWaitPage, Results, PrevInstrS3, FindoutDecision, FindoutWaitPage, FindoutResults,Failed, Thanks]