from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random def choices(): choice00000 = (0, 4, 5, 6, 7, 8, 9, 10) return choice00000 def question(self): choice4 = random.randint(1, 7) return choice4 class instruction_choice(Page): pass class survey(Page): form_model = 'player' form_fields = ['choice1', 'choice2', 'choice3', 'choice4', 'choice5', 'choice6', 'choice7'] class questionchosen(Page): form_model = 'player' def vars_for_template(self): return dict( question_chosen = self.participant.vars['baseline'], choose1 = self.player.get_choice1_display(), choose2 = self.player.get_choice2_display(), choose3 = self.player.get_choice3_display(), choose4 = self.player.get_choice4_display(), choose5 = self.player.get_choice5_display(), choose6 = self.player.get_choice6_display(), choose7 = self.player.get_choice7_display(), ) def js_vars(self): return { 'question_chosen': self.participant.vars['baseline'], } def before_next_page(self): if self.participant.vars['baseline'] == 1: if self.player.get_choice1_display() == 'A budget of \N{pound sign} 4 with no deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice1_display() == 'A budget of \N{pound sign} ' + str(choices()[1]) + ' with a \N{pound sign} 1 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[1] if self.participant.vars['baseline'] == 2: if self.player.get_choice2_display() == 'A budget of \N{pound sign} 4 with no deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice2_display() == 'A budget of \N{pound sign} ' + str(choices()[2]) + ' with a \N{pound sign} 1 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[2] if self.participant.vars['baseline'] == 3: if self.player.get_choice3_display() == 'A budget of \N{pound sign} 4 with no deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice3_display() == 'A budget of \N{pound sign} ' + str(choices()[3]) + ' with a \N{pound sign} 1 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[3] if self.participant.vars['baseline'] == 4: if self.player.get_choice4_display() == 'A budget of \N{pound sign} 4 with no deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice4_display() == 'A budget of \N{pound sign} ' + str(choices()[4]) + ' with a \N{pound sign} 1 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[4] if self.participant.vars['baseline'] == 5: if self.player.get_choice5_display() == 'A budget of \N{pound sign} 4 with no deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice5_display() == 'A budget of \N{pound sign} ' + str(choices()[5]) + ' with a \N{pound sign} 1 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[5] if self.participant.vars['baseline'] == 6: if self.player.get_choice6_display() == 'A budget of \N{pound sign} 4 with no deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice6_display() == 'A budget of \N{pound sign} ' + str(choices()[6]) + ' with a \N{pound sign} 1 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[6] if self.participant.vars['baseline'] == 7: if self.player.get_choice7_display() == 'A budget of \N{pound sign} 4 with no deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice7_display() == 'A budget of \N{pound sign} ' + str(choices()[7]) + ' with a \N{pound sign} 1 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[7] page_sequence = [instruction_choice, survey, questionchosen]