from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class questionnaire(Page): form_model = 'player' form_fields = ['lottery_choice'] def vars_for_template(self): return { 'round_number': self.round_number, 'qn_index': self.participant.vars['risk_qn_order'][self.round_number - 1][0], 'option1A': self.participant.vars['risk_qn_order'][self.round_number - 1][1][0], 'option1B': self.participant.vars['risk_qn_order'][self.round_number - 1][1][1], 'option1C': self.participant.vars['risk_qn_order'][self.round_number - 1][1][2], 'option1D': self.participant.vars['risk_qn_order'][self.round_number - 1][1][3], 'option2A': self.participant.vars['risk_qn_order'][self.round_number - 1][2][0], 'option2B': self.participant.vars['risk_qn_order'][self.round_number - 1][2][1], 'option2C': self.participant.vars['risk_qn_order'][self.round_number - 1][2][2], 'option2D': self.participant.vars['risk_qn_order'][self.round_number - 1][2][3] } def before_next_page(self): print("Player", self.player.id_in_group, "question", self.round_number) self.player.outcome_payout = self.participant.vars['risk_qn_order'][self.round_number - 1][self.player.lottery_choice][self.player.outcome] if self.round_number == self.player.chosen_task: self.player.payoff += c(self.participant.vars['risk_qn_order'][self.round_number - 1][self.player.lottery_choice][self.player.outcome]) print('this question will be implemented') print('Outcome ' + str(['A','B','C','D'][self.player.outcome]) + ' realized') print('payout is ' + str(self.player.payoff)) print(' ') page_sequence = [ questionnaire ]