from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) author = 'Pablo Lozano' doc = """ Compliance to a certain norm experiment. """ class Constants(BaseConstants): name_in_url = 'questions2' players_per_group = None num_rounds = 20 class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.participant.vars['norm'] = True class Group(BaseGroup): pass class Player(BasePlayer): # Modelos para guardar las participant vars payoff_norm = models.FloatField() selectionYellow = models.PositiveIntegerField(blank=True, default=None, choices=[ [1, '']], widget=widgets.RadioSelect, verbose_name="") selectionBlue = models.PositiveIntegerField(blank=True, default=None, choices=[ [1, '']], widget=widgets.RadioSelect, verbose_name="") def storePayments(self): self.participant.vars['norm_payoff'] = sum([5 for p in self.in_all_rounds( ) if p.selectionYellow == 1]) + sum([10 for p in self.in_all_rounds() if p.selectionBlue == 1]) self.payoff_norm = self.participant.vars['norm_payoff']