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'] def vars_for_template(self): self.participant.vars['question_chosen'] = question(self) class questionchosen(Page): form_model = 'player' def vars_for_template(self): return dict( question_chosen = self.participant.vars['question_chosen'], #endow_choice = self.participant.vars['endow_choice'], #deduction_choice = self.participant.vars['deduction_choice'], 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['question_chosen'], } def before_next_page(self): if self.participant.vars['question_chosen'] == 1: if self.player.get_choice1_display() == 'A starting budget of 4 Pounds with 0 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice1_display() == 'A starting budget of ' + str(choices()[1]) + ' Pounds with 1 Pound deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[1] if self.participant.vars['question_chosen'] == 2: if self.player.get_choice2_display() == 'A starting budget of 4 Pounds with 0 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice2_display() == 'A starting budget of ' + str(choices()[2]) + ' Pounds with 1 Pound deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[2] if self.participant.vars['question_chosen'] == 3: if self.player.get_choice3_display() == 'A starting budget of 4 Pounds with 0 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice3_display() == 'A starting budget of ' + str(choices()[3]) + ' Pounds with 1 Pound deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[3] if self.participant.vars['question_chosen'] == 4: if self.player.get_choice4_display() == 'A starting budget of 4 Pounds with 0 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice4_display() == 'A starting budget of ' + str(choices()[4]) + ' Pounds with 1 Pound deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[4] if self.participant.vars['question_chosen'] == 5: if self.player.get_choice5_display() == 'A starting budget of 4 Pounds with 0 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice5_display() == 'A starting budget of ' + str(choices()[5]) + ' Pounds with 1 Pound deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[5] if self.participant.vars['question_chosen'] == 6: if self.player.get_choice6_display() == 'A starting budget of 4 Pounds with 0 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice6_display() == 'A starting budget of ' + str(choices()[6]) + ' Pounds with 1 Pound deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[6] if self.participant.vars['question_chosen'] == 7: if self.player.get_choice7_display() == 'A starting budget of 4 Pounds with 0 deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 0 self.participant.vars['endow_choice'] = 4 if self.player.get_choice7_display() == 'A starting budget of ' + str(choices()[7]) + ' Pounds with 1 Pound deduction after every 10 seconds': self.participant.vars['deduction_choice'] = 1 self.participant.vars['endow_choice'] = choices()[7] page_sequence = [instruction_choice, survey, questionchosen]