from otree.api import Currency as c, currency_range from ._builtin import Page class Lying(Page): form_model = 'player' form_fields = ['lying_low', 'lying_high'] def before_next_page(self): self.player.set_payoff() self.participant.vars['lying_payoff'] = self.player.payoff class LyingResults(Page): def vars_for_template(self): if self.player.draw == 'low': return {'value': 50, 'payoff': self.player.payoff, 'payoff_low': 50 + self.player.lying_low, 'payoff_high': 50 + self.player.lying_high, 'lying_low': self.player.lying_low, 'lying_high': self.player.lying_high} else: return {'value': 100, 'payoff': self.player.payoff, 'payoff_low': 50 + self.player.lying_low, 'payoff_high': 50 + self.player.lying_high, 'lying_low': self.player.lying_low, 'lying_high': self.player.lying_high} class Attitudes(Page): form_model = 'player' form_fields = ['trust_sender', 'trust_receiver'] class Demographics(Page): form_model = 'player' form_fields = ['age', 'study', 'gender'] class Results(Page): def vars_for_template(self): return {'game_payoff': self.participant.vars['game_payoff'], 'non_game_payoff': self.participant.vars['belief_payoff'] + self.participant.vars['risk_payoff'] + self.participant.vars['crt_payoff'] + self.participant.vars['lying_payoff'], 'participation_fee': self.session.config['participation_fee'], 'exchange_rate': round(1/self.session.config['real_world_currency_per_point'], 1), 'total_payoff': self.participant.vars['game_payoff'] + self.participant.vars['belief_payoff'] + self.participant.vars['risk_payoff'] + self.participant.vars['crt_payoff'] + self.participant.vars['lying_payoff'], 'earnings': round((self.participant.vars['game_payoff'] + self.participant.vars['belief_payoff'] + self.participant.vars['risk_payoff'] + self.participant.vars['crt_payoff'] + self.participant.vars['lying_payoff'])*self.session.config['real_world_currency_per_point'], 2) , 'payment': (self.participant.vars['game_payoff'] + self.participant.vars['belief_payoff'] + self.participant.vars['risk_payoff'] + self.participant.vars['crt_payoff'] + self.participant.vars['lying_payoff'])*self.session.config['real_world_currency_per_point'] + int(self.session.config['participation_fee']) } page_sequence = [Lying, LyingResults, Attitudes, Demographics, Results]