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 BOX_VALUE = 0.5 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): kazanc = models.FloatField() #iban = models.StringField( # label='IBAN', # blank=True) #name = models.StringField( # label='İsim', # blank=True) #surname = models.StringField( # label='Soyisim', # blank=True) #payment_method = models.BooleanField( # doc="""the payment method that the subject prefers""", # label='Tercih ettiğiniz ödeme yöntemini seçiniz.', # widget=widgets.RadioSelect, # choices=[ # [True, 'Deney kazancımın aşağıda bildireceğim hesaba gönderilmesini onaylıyorum.'], # [False, 'Deney kazancımı BELİS laboratuvarından almak istiyorum'], # ] #) #own_iban = models.BooleanField( # doc="""the iban that the subject prefers""", # label='Ödeme kişisel hesabınıza mı yapılacak?', # widget=widgets.RadioSelect, # blank=True, # 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 setkazanc(group): players = group.get_players() for p in players: kazanc = p.participant.payoff_plus_participation_fee() p.kazanc = float(kazanc) print("participant payoff", p.participant.payoff_plus_participation_fee()) print("kazanc", kazanc) # PAGES class BRET_Result(Page): @staticmethod def vars_for_template(player: Player): participant = player.participant bret_payoff_html = C.BOX_VALUE * player.participant.vars['bret_boxes_collected'] return dict( bret_payoff=participant.vars['bret_payoff'], bret_box_collected=player.participant.vars['bret_boxes_collected'], bret_bomb=player.participant.vars['bret_bomb'], box_value=C.BOX_VALUE, bret_payoff_html=bret_payoff_html ) class ResultsWaitPage(WaitPage): after_all_players_arrive = setkazanc class PaymentInfo(Page): #@staticmethod #def before_next_page(player): # player.group.setkazanc() form_model = 'player' #form_fields = ["iban", # "name", # "surname", # 'payment_method', # "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_payoff_with_showup=player.participant.payoff_plus_participation_fee() ) #def error_message(player, values): # if values['payment_method'] and values['own_iban'] and values['name'] == None: # return 'Lütfen isim bilgisi giriniz.' # if values['payment_method'] and values['own_iban'] and values['iban'] == None: # return 'Lütfen IBAN bilgisi giriniz.' # if values['payment_method'] and values['own_iban'] and values['surname'] == None: # return 'Lütfen soyisim bilgisi giriniz.' # if values['payment_method'] and values['own_iban'] == False and values['other_relation'] == None: # return 'Lütfen yakınlık bilgisi giriniz.' # if values['payment_method'] and values['own_iban'] == False and values['other_name'] == None: # return 'Lütfen isim bilgisi giriniz.' # if values['payment_method'] and values['own_iban'] == False and values['other_surname'] == None: # return 'Lütfen soyisim bilgisi giriniz.' # if values['payment_method'] and values['own_iban'] == False and values['other_iban'] == None: # return 'Lütfen IBAN bilgisi giriniz.' page_sequence = [BRET_Result, ResultsWaitPage, PaymentInfo]