from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants #class Introduction(Page): #timeout_seconds = 100 class DecisionWait(WaitPage): wait_for_all_groups = True # class DecisionGuess(Page): # def is_displayed(self): # return self.round_number in [1, 5, 10] # # form_model = 'player' # form_fields = ['decision_guess'] # # def before_next_page(self): # if self.round_number == 1: # self.participant.vars['decision_guess_task1_r1'] = self.player.decision_guess # self.player.decision_guess_task1_r1 = str(self.participant.vars['decision_guess_task1_r1']) # elif self.round_number == 5: # self.participant.vars['decision_guess_task1_r5'] = self.player.decision_guess # self.player.decision_guess_task1_r5 = str(self.participant.vars['decision_guess_task1_r5']) # elif self.round_number == 10: # self.participant.vars['decision_guess_task1_r10'] = self.player.decision_guess # self.player.decision_guess_task1_r10 = str(self.participant.vars['decision_guess_task1_r10']) # else: # pass class DecIntro1(Page): pass class Decision1(Page): form_model = 'player' form_fields = ['decision_1'] def before_next_page(self): # Round 1: Unconditional choice if self.player.decision_1 == 1: self.participant.vars['task1_decision_uncond'] = int(1) self.participant.vars['task1_decision_type_uncond'] = str("X") else: self.participant.vars['task1_decision_uncond'] = int(0) self.participant.vars['task1_decision_type_uncond'] = str("Y") self.participant.vars['task1_group_id'] = self.group.id_in_subsession self.participant.vars['task1_group_id_uncond'] = self.group.id_in_subsession self.player.task1_decision_uncond = int(self.participant.vars['task1_decision_uncond']) self.player.task1_decision_type_uncond = str(self.participant.vars['task1_decision_type_uncond']) print(self.participant.vars) class DecIntro2(Page): pass class Decision2(Page): form_model = 'player' form_fields = ['decision_2'] def before_next_page(self): # Round 2: Conditional choice - if partner chooses X if self.player.decision_2 == 1: self.participant.vars['task1_decision_condX'] = int(1) self.participant.vars['task1_decision_type_condX'] = str("X") else: self.participant.vars['task1_decision_condX'] = int(0) self.participant.vars['task1_decision_type_condX'] = str("Y") self.participant.vars['task1_group_id_condX'] = self.group.id_in_subsession self.player.task1_decision_condX = int(self.participant.vars['task1_decision_condX']) self.player.task1_decision_type_condX = str(self.participant.vars['task1_decision_type_condX']) class Decision3(Page): form_model = 'player' form_fields = ['decision_3'] def before_next_page(self): # Round 3: Conditional choice - if partner chooses Y if self.player.decision_3 == 1: self.participant.vars['task1_decision_condY'] = int(1) self.participant.vars['task1_decision_type_condY'] = str("X") else: self.participant.vars['task1_decision_condY'] = int(0) self.participant.vars['task1_decision_type_condY'] = str("Y") self.participant.vars['task1_group_id_condY'] = self.group.id_in_subsession self.player.task1_decision_condY = int(self.participant.vars['task1_decision_condY']) self.player.task1_decision_type_condY = str(self.participant.vars['task1_decision_type_condY']) class ResultsWaitPage1(WaitPage): wait_for_all_groups = True class ResultsWaitPage2(WaitPage): after_all_players_arrive = 'set_relevant_choices' class ResultsWaitPage3(WaitPage): after_all_players_arrive = 'set_decisive_choices' class ResultsWaitPage4(WaitPage): after_all_players_arrive = 'set_payoffs' class EndTask1(Page): # timeout_seconds = 10 def vars_for_template(self): subs = self.subsession return dict( task1order_1=subs.task1_order == 1 ) def before_next_page(self): self.player.participant.vars['task1_payoff_int'] = int(self.player.task1_payoff_int) self.player.participant.vars['task1_relevant_choice'] = int(self.player.task1_relevant_choice) self.player.participant.vars['task1_decisive_choice'] = int(self.player.task1_decisive_choice) self.player.participant.vars['task1_relevant_choice_type'] = self.player.task1_relevant_choice_type self.player.participant.vars['task1_decisive_choice_type'] = self.player.task1_decisive_choice_type self.player.participant.vars['task1_decisive_choice_type_partner'] = \ self.player.task1_decisive_choice_type_partner page_sequence = [ DecisionWait, # DecisionGuess, DecIntro1, Decision1, DecIntro2, Decision2, Decision3, ResultsWaitPage1, ResultsWaitPage2, ResultsWaitPage3, ResultsWaitPage4, EndTask1 ]