from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random import itertools import math author = 'Antoine Deplancke' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Max_Pol' players_per_group = None num_rounds = 2 paiement = 8 matrix0_haut = ['16', '15', '14', '13', '12', '11', '10', '9', '8', '7', '6', '5', '4'] matrix0_bas = ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16'] matrix1_haut = ['19', '18', '17', '16', '15', '14', '13', '12', '11', '10', '9', '8', '7'] matrix1_bas = ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19', '21', '23', '25'] matrix2_haut = ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'] matrix2_bas = ['5', '7', '9', '11', '13', '15', '17', '19', '21', '23', '25', '27', '29'] sous_groupes_gauche = ['G1_normal', 'G2_imputation'] sous_groupes_droite = ['D1_normal', 'D2_imputation'] class Subsession(BaseSubsession): def creating_session(self): # on définit les rounds d'apparition chomage et immig if self.round_number == 1: # au premier round seulement ! # définir l'ordre des round chomage et immigration for p in self.get_players(): p.participant.vars['round_immig'] = random.randint(1,2) if p.participant.vars['round_immig'] == 1: p.participant.vars['round_chomage'] = 2 p.round_immig = 1 p.round_chomage = 2 elif p.participant.vars['round_immig'] == 2: p.participant.vars['round_chomage'] = 1 p.round_immig = 2 p.round_chomage = 1 print('player ' + str(p.id_in_subsession) + ': immig en ' + str(p.participant.vars['round_immig']) + ' // chomage en ' + str(p.participant.vars['round_chomage'])) class Group(BaseGroup): pass class Player(BasePlayer): sexe = models.StringField(choices=["Une Femme", "Un Homme"], label='') age = models.IntegerField(min=18,max=75, label='') statut = models.StringField() p1_politique = models.StringField(widget=widgets.RadioSelect, choices=[ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Je ne sais pas']) polmessage = models.StringField() groupe = models.StringField() other_groupe = models.StringField() sous_groupe = models.StringField() round_immig = models.IntegerField() round_chomage = models.IntegerField() immig_mot_1 = models.StringField() immig_mot_2 = models.StringField() immig_mot_3 = models.StringField() chom_mot_1 = models.StringField() chom_mot_2 = models.StringField() chom_mot_3 = models.StringField() immig_eval_mot_1 = models.PositiveIntegerField(min=0, max=10, widget=widgets.Slider(attrs={'step': '1'})) immig_eval_mot_2 = models.PositiveIntegerField(min=0, max=10, widget=widgets.Slider(attrs={'step': '1'})) immig_eval_mot_3 =models.PositiveIntegerField(min=0, max=10, widget=widgets.Slider(attrs={'step': '1'})) chom_eval_mot_1 =models.PositiveIntegerField(min=0, max=10, widget=widgets.Slider(attrs={'step': '1'})) chom_eval_mot_2 = models.PositiveIntegerField(min=0, max=10, widget=widgets.Slider(attrs={'step': '1'})) chom_eval_mot_3 =models.PositiveIntegerField(min=0, max=10, widget=widgets.Slider(attrs={'step': '1'})) # pour la page d'identification sur les personnes de gauche self_love = models.PositiveIntegerField(label="J’apprécie le groupe des personnes de gauche :", min=0, max=100, widget=widgets.Slider(attrs={'step': '1'})) self_identification = models.PositiveIntegerField(label="Je m’identifie au groupe des personnes de gauche :", min=0, max=100, widget=widgets.Slider(attrs={'step': '1'})) others_love = models.PositiveIntegerField(label="J’apprécie le groupe des personnes de droite :", min=0, max=100, widget=widgets.Slider(attrs={'step': '1'})) others_identification = models.PositiveIntegerField(label="Je m’identifie au groupe des personnes de droite :", min=0, max=100, widget=widgets.Slider(attrs={'step': '1'})) matrix0_response = models.StringField(widget=widgets.RadioSelect, choices=[ ['col1', ''], ['col2', ''], ['col3', ''], ['col4', ''], ['col5', ''], ['col6', ''], ['col7', ''], ['col8', ''], ['col9', ''], ['col10', ''], ['col11', ''], ['col12', ''], ['col13', ''], ], blank=True) matrix1_response = models.StringField(widget=widgets.RadioSelect, choices=[ ['19_1', ''], ['18_3', ''], ['17_5', ''], ['16_7', ''], ['15_9', ''], ['14_11', ''], ['13_13', ''], ['12_15', ''], ['11_17', ''], ['10_19', ''], ['9_21', ''], ['8_23', ''], ['7_25', ''], ]) matrix2_response = models.StringField(widget=widgets.RadioSelect, choices=[ ['11_5', ''], ['12_7', ''], ['13_9', ''], ['14_11', ''], ['15_13', ''], ['16_15', ''], ['17_17', ''], ['18_19', ''], ['19_21', ''], ['20_23', ''], ['21_25', ''], ['22_27', ''], ['23_29', ''], ])