from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, safe_json ) from django import forms from django.forms import widgets as django_widgets import math import random author = 'Nikolas Kirk' doc = """ Collect demographic info and calculate payoff """ class Constants(BaseConstants): name_in_url = 'anchor_rp_goodbye' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): bonus_amount = models.CurrencyField() def set_payoff(self): if self.participant.vars['failed_comprehension'] or self.participant.vars['failed_answer']: self.payoff = self.session.config['participation_fee'] self.bonus_amount = self.session.config['participation_fee'] else: if self.participant.vars['chance']: self.participant.vars['task_payment'] = self.participant.vars['credited'] else: self.participant.vars['task_payment'] = self.participant.vars['rp'] self.participant.vars['total_payment'] = self.session.config['participation_fee'] + self.participant.vars[ 'correct_bonus'] + self.participant.vars['fixed_bonus'] + self.participant.vars['task_payment'] self.payoff = c(self.participant.vars['total_payment']) self.bonus_amount = self.participant.vars['total_payment'] - self.session.config['participation_fee'] - self.participant.vars['fixed_bonus']