from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from datetime import datetime class controller_page(Page): def before_next_page(self): if self.participant.vars['consent']: self.player.calculate_payoff() class general_comments(Page): form_fields = ['general_comments'] form_model = 'player' class Results_Page(Page): def vars_for_template(self): payoff_date = datetime.strptime(self.participant.vars['timepref_pat_mpl_payout_day'], '%Y-%m-%d').date() payoff_time_text = self.participant.vars['timepref_pat_mpl_delay_days'] money_now = self.participant.payoff_plus_participation_fee() points_later = self.participant.vars['mpl_pat_pot_payoff'] money_later = self.participant.vars['mpl_pat_pot_payoff'] * \ self.session.config['real_world_currency_per_point'] if\ self.participant.vars['mpl_pat_pot_payoff'] >= 0 else 0 return {'group_size': Constants.beauty_group_size - 1, 'computer_sub': self.player.participant.vars['computer_submission'], 'computer_win': self.player.computer_winner, 'payoff_game': self.player.winner_game, 'chosen_earned': round(float(self.player.earned_by_game) * self.session.config['real_world_currency_per_point'], 2), 'showup_fee': self.session.config['participation_fee'], 'pl_payoff_no_endow': self.participant.vars['mpl_pat_pot_payoff'] -\ self.participant.vars['MPL_base_endowment'], 'pl_payoff': self.participant.vars['mpl_pat_pot_payoff'], 'base_endowment': self.participant.vars['MPL_base_endowment'], 'payoff_delay_text': payoff_time_text, 'payoff_date': payoff_date, 'money_now': money_now, 'money_later': round(money_later, 2), 'points_later': points_later, 'consent': self.participant.vars['consent'] } page_sequence = [ controller_page, general_comments, Results_Page ]