from otree.api import * from datetime import date doc = """ This application provides a webpage instructing participants how to get paid. Examples are given for the lab and Amazon Mechanical Turk (AMT). """ class C(BaseConstants): NAME_IN_URL = 'payment_info' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): earnings = models.FloatField() total_points = models.CurrencyField() iban = models.StringField( label='IBAN', blank=False) name = models.StringField( label='Hesap sahibinin adı', blank=False) surname = models.StringField( label='Hesap sahibinin soyadı', blank=False) own_iban = models.BooleanField( doc="""the iban that the subject prefers""", label='Ödeme kişisel hesabınıza mı yapılacak?', widget=widgets.RadioSelect, choices=[ [True, 'Deney kazancımın aşağıda bildireceğim kişisel hesabıma gönderilmesini onaylıyorum.'], [False, 'Deney kazancımın aşağıda bildireceğim 3. kişi hesabına gönderilmesini onaylıyorum.'], ] ) other_relation = models.StringField( label='Yakınlık derecesi', blank=True) other_iban = models.StringField( label='IBAN', blank=True) other_name = models.StringField( label='İsim', blank=True) other_surname = models.StringField( label='Soyisim', blank=True) # FUNCTIONS #def call_payoff(group): # players = group.get_players() # for p in players: # p.payoff = p.participant.payoff # print("call payoff", p.payoff) def set_earnings(group): players = group.get_players() for p in players: earnings = p.participant.payoff_plus_participation_fee() p.total_points = earnings / 4 p.earnings = float(earnings) print("earnings", earnings) # PAGES p.with_showup = p.participant.with_showup class ResultsWaitPage(WaitPage): after_all_players_arrive = set_earnings class Outro(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): participant = player.participant return dict(control_payoff=participant.vars['payoff']) #return dict(ac_payoff=participant.vars['payoff']) #change this according to the treatment!!! change the corresponding field in outro.html class PaymentInfo(Page): form_model = 'player' form_fields = ["iban", "name", "surname", "own_iban", "other_iban", "other_name", "other_surname", 'other_relation'] @staticmethod def vars_for_template(player: Player): participant = player.participant return dict(redemption_code=participant.label or participant.code, id=participant.id_in_session, date=str(date.today()), final_payment=player.participant.payoff_plus_participation_fee() ) # @staticmethod # def error_message(player: Player, values): # if values['own_iban'] and values['name'] == None: # return 'Lütfen isim bilgisi giriniz.' # if values['own_iban'] and values['iban'] == None: # return 'Lütfen IBAN bilgisi giriniz.' # if values['own_iban'] and values['surname'] == None: # return 'Lütfen soyisim bilgisi giriniz.' # if values['own_iban'] == False and values['other_relation'] == None: # return 'Lütfen yakınlık bilgisi giriniz.' # if values['own_iban'] == False and values['other_name'] == None: # return 'Lütfen isim bilgisi giriniz.' # if values['own_iban'] == False and values['other_surname'] == None: # return 'Lütfen soyisim bilgisi giriniz.' # if values['own_iban'] == False and values['other_iban'] == None: # return 'Lütfen IBAN bilgisi giriniz.' class End_Page(Page): form_model = 'player' page_sequence = [ResultsWaitPage, Outro, PaymentInfo, End_Page]