from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Your name here' doc = """ CODER UNE SELECTION ALEATOIRE DE 6 joueurs pour AMIENS """ class Constants(BaseConstants): name_in_url = 'EXLEY_RESULTAT' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): TOTAL_PAIEMENT_CHARITY = models.FloatField() TOTAL_PAIEMENT_SELF = models.FloatField() association_choice = models.StringField() def total_thune(self): if self.participant.vars['paiement_treatment'] == 'ASPS' or self.participant.vars['paiement_treatment'] == 'ACPS': if self.participant.vars['paiement_self_exley'] > 0: self.participant.vars['color_bouboule'] = "green" else: self.participant.vars['color_bouboule'] = "red" elif self.participant.vars['paiement_treatment'] == 'ACPC' or self.participant.vars['paiement_treatment'] == 'ASPC': if self.participant.vars['paiement_charity_exley'] > 0: self.participant.vars['color_bouboule'] = "green" else: self.participant.vars['color_bouboule'] = "red" if self.participant.vars['paiement_treatment_2'] == 'ASPS' or self.participant.vars['paiement_treatment_2'] == 'ACPS': if self.participant.vars['paiement_self_exley_2'] > 0: self.participant.vars['color_bouboule_2'] = "green" else: self.participant.vars['color_bouboule_2'] = "red" elif self.participant.vars['paiement_treatment_2'] == 'ACPC' or self.participant.vars['paiement_treatment_2'] == 'ASPC': if self.participant.vars['paiement_charity_exley_2'] > 0: self.participant.vars['color_bouboule_2'] = "green" else: self.participant.vars['color_bouboule_2'] = "red" self.TOTAL_PAIEMENT_SELF = self.participant.vars['ENDOWMENT'] + self.participant.vars['paiement_self_exley'] + self.participant.vars['paiement_self_exley_2'] self.TOTAL_PAIEMENT_CHARITY = self.participant.vars['paiement_charity_exley'] + self.participant.vars['paiement_charity_exley_2'] self.participant.vars['TOTAL_PAIEMENT_SELF'] = self.TOTAL_PAIEMENT_SELF self.participant.vars['TOTAL_PAIEMENT_CHARITY'] = self.TOTAL_PAIEMENT_CHARITY