from otree.api import * import csv import random as r doc = """ Tri de CV - Partie 2 Version démo à 3 CV """ class C(BaseConstants): NAME_IN_URL = 'triCV_partie2/2' PLAYERS_PER_GROUP = None NUM_ROUNDS = 3 WIN_HIGH = 45 WIN_LOW = 30 LOSE_LOW = -20 LOSE_HIGH = -60 CRITERIA = 0.5 WIN_ESTIMATION = 60 # Nature of the evidences and probabilities associates # INFO A = 75/25 # INFO B = 65/35 # INFO C = 70/30 # INFO D = 60/40 INFOS = [ ('Genre', ['Femme', 'Homme']), ('Diplome', ['Pertinent', 'Non pertinent']), ('Experience', ['Plus de deux ans', 'Moins de deux ans']), ('Age', ['Plus de cinquante ans', 'Moins de cinquante ans']) ] DOMAINES = ['employés / employées de services', 'ouvriers / ouvrières de la construction'] METIERS = { DOMAINES[0]: ['Aide-soignant / Aide-soignante', 'Assistant maternel / Assistante maternelle', 'Aide-ménager / Aide-ménagère', 'Auxiliaire de vie'], DOMAINES[1]: ['Plombier chauffagiste / Plombière chauffagiste', 'Electricien / Electricienne', 'Maçon / Maçonne', 'Peintre'] } DESCRIPTIONS = { DOMAINES[0] : 'Cette catégorie de métiers regroupe les personnels salariés d\'exécution effectuant un travail ' 'généralement manuel en vue de produire des services domestiques ou équivalents destinés aux ' 'particuliers.', DOMAINES[1] : 'Cette catégorie de métiers regroupe les personnes exécutant dans le cadre d\'un travail peu ' 'divisé, des tâches manuelles nécessaires à la construction et l’aménagement de bâtiments.', METIERS[DOMAINES[0]][0] : 'Personne salariée qui, dans les établissements de soins, sous le contrôle du ' 'personnel infirmier, surveillent les malades, leur donnent des soins d\'hygiène et ' 'participent à leur alimentation.', METIERS[DOMAINES[0]][1]: 'Personne salariée de particuliers ou d\'établissements privés qui fait profession de ' 's\'occuper d\'enfants, généralement âgés de moins de 6 ans, pendant tout ou partie ' 'de la journée.', METIERS[DOMAINES[0]][2]: 'Personne salariée exécutant chez un particulier divers travaux domestiques, et ' 'notamment le nettoyage des locaux.', METIERS[DOMAINES[0]][3]: 'Personne salariée de structures associatives ou d\'entreprises spécialisées dans ' 'l\'aide à la personne qui aide les personnes malades, handicapées ou âgées, très ' 'dépendantes pour accomplir les actes de la vie quotidienne (courses, prise des repas, ' 'travaux ménagers, démarches administratives, sorties).', METIERS[DOMAINES[1]][0]: 'Personne spécialisée dans la mise en place et la réparation des installations de ' 'plomberie, de chauffage et de climatisation, des installations sanitaires.', METIERS[DOMAINES[1]][1]: 'Personne qualifiée montant des éléments électriques et électroniques sur un châssis et ' 'procédant aux connexions, d\'après des plans.', METIERS[DOMAINES[1]][2]: 'Personne qualifiée de la maçonnerie réalisant la partie maçonnée d\'une construction ' '(fondations, murs, façade, chapes) par assemblage de matériaux divers ' '(briques, pierres, parpaings, etc.) avec des liants tels que les mortiers de chaux ' 'et de ciment, de sable et gravier.', METIERS[DOMAINES[1]][3]: 'Personne qualifiée réalisant, à l\'aide de peinture et autres revêtements légers, ' 'les travaux de finition du bâtiment : protection, revêtement, peinture, décoration ' 'des murs, portes, fenêtres, etc.' } PATH = '_static/triCV/' #Dictionnaires contenant les informations sur les candidats et les probabilités associées def gain_estimations(self, proba_sub, proba_obj): gain = cu(0) float_proba_obj = float(proba_obj) pourcentage_proba_sub = proba_sub * 100 source = 'estimation' score = 0 if pourcentage_proba_sub < 50: loto = r.randint(0, 49) if loto < pourcentage_proba_sub: source = 'loterie' tirage = r.randint(0, 49) if tirage >= loto: gain = cu(C.WIN_ESTIMATION) elif float_proba_obj < 0.50: gain = cu(C.WIN_ESTIMATION) else: loto = r.randint(50, 100) if loto > pourcentage_proba_sub: source = 'loterie' tirage = r.randint(50, 100) if tirage <= loto: gain = cu(C.WIN_ESTIMATION) elif float_proba_obj >= 0.50: gain = cu(C.WIN_ESTIMATION) if (pourcentage_proba_sub >= 50 and float_proba_obj >= 0.50) or (pourcentage_proba_sub < 50 and float_proba_obj < 0.50): score = 1 return gain, source, score def gain_choix(self, choix_sub, choix_obj): gain = 0 score = 0 float_choix_obj = float(choix_obj) if float_choix_obj == 3 or float_choix_obj == 4: if choix_sub == 1: gain = C.LOSE_HIGH elif choix_sub == 2: gain = C.LOSE_LOW elif choix_sub == 3: gain = C.WIN_LOW score = 1 elif choix_sub == 4: gain = C.WIN_HIGH score = 1 else: if choix_sub == 1: gain = C.WIN_HIGH score = 1 elif choix_sub == 2: gain = C.WIN_LOW score = 1 elif choix_sub == 3: gain = C.LOSE_LOW elif choix_sub == 4: gain = C.LOSE_HIGH return gain, score def dict_data(self): dict_data = dict() with open(C.PATH+'Candidats.csv', newline='') as csv_infos: DATA = csv.DictReader(csv_infos) for row in DATA: tuple_indices = (row['Indice 1'], row['Indice 2'], row['Indice 3'], row['Indice 4'], row['Occurrences']) dict_data_indices = {'p_indices' : row['P(indices)'], 'nb_indices' : row['Nb_indices'], 'p_bon_indices' : row['P(bon|indices)'], 'eg_rejet_high' : row['EG Rejeter High'], 'eg_rejet_low' : row['EG Rejeter Low'], 'eg_accept_low' : row['EG Accepter Low'], 'eg_accept_high' : row['EG Accepter High'], 'eg_max' : row['EG max'], 'p_indices*eg_max' : row['P(indices)*EG max']} dict_data[tuple_indices] = dict_data_indices.copy() return dict_data def dict_data4indices(self): dic_data_4indices = dict() with open(C.PATH+'40Candidats4indices.csv', newline='') as csv_infos: DATA = csv.DictReader(csv_infos) for row in DATA: tuple_indices = (row['Indice 1'], row['Indice 2'], row['Indice 3'], row['Indice 4'], row['Occurrences']) dict_data_indices = {'p_indices' : row['P(indices)'], 'nb_indices' : row['Nb_indices'], 'p_bon_indices' : row['P(bon|indices)'], 'eg_rejet_high' : row['EG Rejeter High'], 'eg_rejet_low' : row['EG Rejeter Low'], 'eg_accept_low' : row['EG Accepter Low'], 'eg_accept_high' : row['EG Accepter High'], 'eg_max' : row['EG max'], 'p_indices*eg_max' : row['P(indices)*EG max']} dic_data_4indices[tuple_indices] = dict_data_indices.copy() return dic_data_4indices def get_population(self): dict4indices = self.dict_data4indices(C) dict = self.dict_data(C) liste_candidats = self.melange(C, list(dict4indices.keys())) pile_cv = [] pile_infos = [] ordre_infos = [] for candidat in liste_candidats: infos = self.melange(C, C.INFOS) orga_infos = [] for info in infos: l = self.melange(C, info[1]) info_shuffled = [info[0], l] orga_infos.append(info_shuffled) pile_infos.append(orga_infos) candidats = self.get_candidat(C, candidat, dict, orga_infos) pile_cv.append(candidats[0]) ordre_infos.append(candidats[1]) return pile_cv, pile_infos, ordre_infos #Prend en paramètres un candidat (liste) et un pool de candidats (dictionnaire) et renvoie une liste contenant le parcours de révélation d'un candidat indice par indice def get_candidat(self, candidat, dict, orga_infos): revelation_candidat = ['0', '0', '0', '0', '1'] ordre_indices = self.melange(C, [1, 2, 3, 4]) indice1 = self.get_indice(C, 1, ordre_indices, orga_infos, revelation_candidat, candidat, dict) indice2 = self.get_indice(C, 2, ordre_indices, orga_infos, indice1[2], candidat, dict) indice3 = self.get_indice(C, 3, ordre_indices, orga_infos, indice2[2], candidat, dict) indice4 = self.get_indice(C, 4, ordre_indices, orga_infos, indice3[2], candidat, dict) parcours_candidat = [indice1, indice2, indice3, indice4] return parcours_candidat, ordre_indices def melange(self, liste): copie = liste[:] r.shuffle(copie) return copie # Prend en argument un indice (le numéro de l'indice souhaité) et rend l'indice associé et le candidat sachant l'indice donné def get_indice(self, num, ordre_indices, orga_infos, revelation_candidat_prev, candidat, dict): # Permet de définir quelle info sera donnée (Âge, Expérience, Bac, etc). # Si 1 alors Genre, Si 2 = Bac, Si 3 = Expérience, Si 4 = Age EDIT : Faux avec ordre aléatoire type_info = ordre_indices.index(num) # On met à jour l'état de connaissance sur le candidat selon l'info qui va être donnée revelation_candidat = revelation_candidat_prev.copy() revelation_candidat[type_info] = candidat[type_info] # On récupère le dictionnaire contenant les informations sur le candidat sachant les infos donnés candidat_ap_indice = dict[tuple(revelation_candidat)] # Indice à présenter #indice = '' # On définit l'indice selon la valeur (1 ou 2) et selon le type de l'info déterminé par l'emplacement sur le tuple key pour un candidat indice = orga_infos[type_info][0] + ' : ' + orga_infos[type_info][1][int(revelation_candidat[type_info])-1] # On renvoie : # - l'indice à afficher (string), # - les infos sur le candidat mises à jour (dictionnaire) # - l'état de dévoilement du candidat (liste) reponse = [indice, candidat_ap_indice, revelation_candidat, candidat] return reponse def get_metiers(self, domaine): metiers = [] descriptions = [] for i in range(C.NUM_ROUNDS): metier = r.choice(domaine) metiers.append(metier) descriptions.append(C.DESCRIPTIONS[metier]) return metiers, descriptions class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def creating_session(subsession:Subsession): if subsession.round_number == 1: for p in subsession.get_players(): tup = C.get_population(C) p.participant.vars['pile_CV'] = tup[0] p.participant.vars['pile_infos'] = tup[1] p.participant.vars['ordre_infos'] = tup[2] p.participant.vars['nb_bonnes_estimations2'] = 0 p.participant.vars['nb_bons_choix2'] = 0 p.participant.vars['nb_rounds2'] = C.NUM_ROUNDS p.participant.vars['essai_gagnant2'] = r.randint(1, C.NUM_ROUNDS) p.participant.vars['estimation_gagnante2'] = r.randint(1, 4) p.participant.vars['choix_gagnant2'] = r.randint(1, C.NUM_ROUNDS) p.participant.vars['gain_final2'] = 0 tirage_metiers = C.get_metiers(C, C.METIERS[p.participant.vars['domaine']]) p.participant.vars['metiers'] = tirage_metiers[0] p.participant.vars['descriptions'] = tirage_metiers[1] class Player(BasePlayer): id_candidat = models.StringField() ordre_infos = models.StringField() metier = models.StringField() domaine = models.StringField() info_a = models.StringField() label_a1 = models.StringField() label_a2 = models.StringField() info_b = models.StringField() label_b1 = models.StringField() label_b2 = models.StringField() info_c = models.StringField() label_c1 = models.StringField() label_c2 = models.StringField() info_d = models.StringField() label_d1 = models.StringField() label_d2 = models.StringField() poids_genre = models.StringField() poids_diplome = models.StringField() poids_experience = models.StringField() poids_age = models.StringField() valeur_genre = models.StringField() valeur_diplome = models.StringField() valeur_experience = models.StringField() valeur_age = models.StringField() ordre_genre = models.IntegerField() ordre_diplome = models.IntegerField() ordre_experience = models.IntegerField() ordre_age = models.IntegerField() indice_1 = models.StringField() indice_2 = models.StringField() indice_3 = models.StringField() indice_4 = models.StringField() p_indice_1 = models.FloatField() p_indice_2 = models.FloatField() p_indice_3 = models.FloatField() p_indice_4 = models.FloatField() proba_sub_candidat_1 = models.FloatField( choices=[i for i in range(101)] ) proba_sub_candidat_2 = models.FloatField( choices=[i for i in range(101)] ) proba_sub_candidat_3 = models.FloatField( choices=[i for i in range(101)] ) proba_sub_candidat_4 = models.FloatField( choices=[i for i in range(101)] ) choix_sub = models.IntegerField( choices=[ [1, 'Rejeter fortement'], [2, 'Rejeter faiblement'], [3, 'Accepter faiblement'], [4, 'Accepter fortement'] ], widget=widgets.RadioSelectHorizontal ) proba_obj_candidat_1 = models.StringField() proba_obj_candidat_2 = models.StringField() proba_obj_candidat_3 = models.StringField() proba_obj_candidat_4 = models.StringField() choix_obj = models.IntegerField() score_1 = models.IntegerField() score_2 = models.IntegerField() score_3 = models.IntegerField() score_4 = models.IntegerField() score_choix = models.IntegerField() class Transition(Page): timeout_seconds = 1 class Indice1(Page): @staticmethod def vars_for_template(player): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] indice1 = candidat[0][0] metier = player.participant.vars['metiers'][k] description = player.participant.vars['descriptions'][k] orga_infos = player.participant.vars['pile_infos'][k] info_a = orga_infos[0][0] label_a1 = orga_infos[0][1][0] label_a2 = orga_infos[0][1][1] info_b = orga_infos[1][0] label_b1 = orga_infos[1][1][0] label_b2 = orga_infos[1][1][1] info_c = orga_infos[2][0] label_c1 = orga_infos[2][1][0] label_c2 = orga_infos[2][1][1] info_d = orga_infos[3][0] label_d1 = orga_infos[3][1][0] label_d2 = orga_infos[3][1][1] return dict( indice1=indice1, metier=metier, description=description, info_a=info_a, label_a1=label_a1, label_a2=label_a2, info_b=info_b, label_b1=label_b1, label_b2=label_b2, info_c=info_c, label_c1=label_c1, label_c2=label_c2, info_d=info_d, label_d1=label_d1, label_d2=label_d2, ) @staticmethod def js_vars(player): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] indice1 = candidat[0][0] candidat_ap_indice = candidat[0][1] proba_obj_candidat1 = candidat_ap_indice['p_bon_indices'] return dict( indice1=indice1, proba_obj_candidat1=proba_obj_candidat1, ) form_model = 'player' form_fields = ['proba_sub_candidat_1', 'indice_1', 'proba_obj_candidat_1'] @staticmethod def get_form_fields(player): return Indice1.form_fields @staticmethod def before_next_page(player: Player, timeout_happened): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] candidat_final = candidat[3][1] proba_obj_candidat = candidat_final['p_bon_indices'] player.proba_sub_candidat_1 = player.proba_sub_candidat_1 / 100 gain = C.gain_estimations(C, player.proba_sub_candidat_1, proba_obj_candidat) player.score_1 = gain[2] player.participant.vars['nb_bonnes_estimations2'] += gain[2] if player.round_number == player.participant.vars['essai_gagnant2'] and player.participant.vars['estimation_gagnante2'] == 1: player.participant.vars['gain_final2'] += gain[0] class Indice2(Page): @staticmethod def vars_for_template(player): k = player.round_number - 1 derniere_proba = int(player.proba_sub_candidat_1 * 100) derniere_non_proba = 100 - derniere_proba candidat = player.participant.vars['pile_CV'][k] orga_infos = player.participant.vars['pile_infos'][k] metier = player.participant.vars['metiers'][k] description = player.participant.vars['descriptions'][k] info_a = orga_infos[0][0] label_a1 = orga_infos[0][1][0] label_a2 = orga_infos[0][1][1] info_b = orga_infos[1][0] label_b1 = orga_infos[1][1][0] label_b2 = orga_infos[1][1][1] info_c = orga_infos[2][0] label_c1 = orga_infos[2][1][0] label_c2 = orga_infos[2][1][1] info_d = orga_infos[3][0] label_d1 = orga_infos[3][1][0] label_d2 = orga_infos[3][1][1] indice1 = candidat[0][0] indice2 = candidat[1][0] return dict( indice1=indice1, indice2=indice2, metier=metier, description=description, derniere_proba=derniere_proba, derniere_non_proba=derniere_non_proba, info_a=info_a, label_a1=label_a1, label_a2=label_a2, info_b=info_b, label_b1=label_b1, label_b2=label_b2, info_c=info_c, label_c1=label_c1, label_c2=label_c2, info_d=info_d, label_d1=label_d1, label_d2=label_d2, ) @staticmethod def js_vars(player): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] indice2 = candidat[1][0] candidat_ap_indice = candidat[1][1] proba_obj_candidat2 = candidat_ap_indice['p_bon_indices'] return dict( indice2=indice2, proba_obj_candidat2=proba_obj_candidat2, ) form_model = 'player' form_fields = ['proba_sub_candidat_2', 'indice_2', 'proba_obj_candidat_2'] @staticmethod def get_form_fields(player): return Indice2.form_fields @staticmethod def before_next_page(player: Player, timeout_happened): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] candidat_final = candidat[3][1] proba_obj_candidat = candidat_final['p_bon_indices'] player.proba_sub_candidat_2 = player.proba_sub_candidat_2 / 100 gain = C.gain_estimations(C, player.proba_sub_candidat_2, proba_obj_candidat) player.score_2 = gain[2] player.participant.vars['nb_bonnes_estimations2'] += gain[2] if player.round_number == player.participant.vars['essai_gagnant2'] and player.participant.vars['estimation_gagnante2'] == 2: player.participant.vars['gain_final2'] += gain[0] class Indice3(Page): @staticmethod def vars_for_template(player): k = player.round_number - 1 derniere_proba = int(player.proba_sub_candidat_2 * 100) derniere_non_proba = 100 - derniere_proba candidat = player.participant.vars['pile_CV'][k] orga_infos = player.participant.vars['pile_infos'][k] metier = player.participant.vars['metiers'][k] description = player.participant.vars['descriptions'][k] info_a = orga_infos[0][0] label_a1 = orga_infos[0][1][0] label_a2 = orga_infos[0][1][1] info_b = orga_infos[1][0] label_b1 = orga_infos[1][1][0] label_b2 = orga_infos[1][1][1] info_c = orga_infos[2][0] label_c1 = orga_infos[2][1][0] label_c2 = orga_infos[2][1][1] info_d = orga_infos[3][0] label_d1 = orga_infos[3][1][0] label_d2 = orga_infos[3][1][1] indice1 = candidat[0][0] indice2 = candidat[1][0] indice3 = candidat[2][0] return dict( indice1=indice1, indice2=indice2, indice3=indice3, metier=metier, description=description, derniere_proba=derniere_proba, derniere_non_proba=derniere_non_proba, info_a=info_a, label_a1=label_a1, label_a2=label_a2, info_b=info_b, label_b1=label_b1, label_b2=label_b2, info_c=info_c, label_c1=label_c1, label_c2=label_c2, info_d=info_d, label_d1=label_d1, label_d2=label_d2, ) @staticmethod def js_vars(player): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] indice3 = candidat[2][0] candidat_ap_indice = candidat[2][1] proba_obj_candidat3 = candidat_ap_indice['p_bon_indices'] return dict( indice3=indice3, proba_obj_candidat3=proba_obj_candidat3, ) form_model = 'player' form_fields = ['proba_sub_candidat_3', 'indice_3', 'proba_obj_candidat_3'] @staticmethod def get_form_fields(player): return Indice3.form_fields @staticmethod def before_next_page(player: Player, timeout_happened): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] candidat_final = candidat[3][1] proba_obj_candidat = candidat_final['p_bon_indices'] player.proba_sub_candidat_3 = player.proba_sub_candidat_3 / 100 gain = C.gain_estimations(C, player.proba_sub_candidat_3, proba_obj_candidat) player.score_3 = gain[2] player.participant.vars['nb_bonnes_estimations2'] += gain[2] if player.round_number == player.participant.vars['essai_gagnant2'] and player.participant.vars['estimation_gagnante2'] == 3: player.participant.vars['gain_final2'] += gain[0] class Indice4(Page): @staticmethod def vars_for_template(player): k = player.round_number - 1 derniere_proba = int(player.proba_sub_candidat_3 * 100) derniere_non_proba = 100 - derniere_proba candidat = player.participant.vars['pile_CV'][k] orga_infos = player.participant.vars['pile_infos'][k] metier = player.participant.vars['metiers'][k] description = player.participant.vars['descriptions'][k] info_a = orga_infos[0][0] label_a1 = orga_infos[0][1][0] label_a2 = orga_infos[0][1][1] info_b = orga_infos[1][0] label_b1 = orga_infos[1][1][0] label_b2 = orga_infos[1][1][1] info_c = orga_infos[2][0] label_c1 = orga_infos[2][1][0] label_c2 = orga_infos[2][1][1] info_d = orga_infos[3][0] label_d1 = orga_infos[3][1][0] label_d2 = orga_infos[3][1][1] indice1 = candidat[0][0] indice2 = candidat[1][0] indice3 = candidat[2][0] indice4 = candidat[3][0] return dict( indice1=indice1, indice2=indice2, indice3=indice3, indice4=indice4, metier=metier, description=description, derniere_proba=derniere_proba, derniere_non_proba=derniere_non_proba, info_a=info_a, label_a1=label_a1, label_a2=label_a2, info_b=info_b, label_b1=label_b1, label_b2=label_b2, info_c=info_c, label_c1=label_c1, label_c2=label_c2, info_d=info_d, label_d1=label_d1, label_d2=label_d2, ) @staticmethod def js_vars(player): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] indice4 = candidat[3][0] candidat_ap_indice = candidat[3][1] proba_obj_candidat4 = candidat_ap_indice['p_bon_indices'] return dict( indice4=indice4, proba_obj_candidat4=proba_obj_candidat4, ) form_model = 'player' form_fields = ['proba_sub_candidat_4', 'indice_4', 'proba_obj_candidat_4'] @staticmethod def get_form_fields(player): return Indice4.form_fields @staticmethod def before_next_page(player: Player, timeout_happened): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] candidat_final = candidat[3][1] proba_obj_candidat = candidat_final['p_bon_indices'] player.proba_sub_candidat_4 = player.proba_sub_candidat_4 / 100 gain = C.gain_estimations(C, player.proba_sub_candidat_4, proba_obj_candidat) player.score_4 = gain[2] player.participant.vars['nb_bonnes_estimations2'] += gain[2] if player.round_number == player.participant.vars['essai_gagnant2'] and player.participant.vars['estimation_gagnante2'] == 4: player.participant.vars['gain_final2'] += gain[0] class Choix(Page): form_model = 'player' form_fields = ['choix_sub', 'choix_obj'] @staticmethod def vars_for_template(player): derniere_proba = int(player.proba_sub_candidat_4 * 100) derniere_non_proba = 100 - derniere_proba k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] orga_infos = player.participant.vars['pile_infos'][k] metier = player.participant.vars['metiers'][k] description = player.participant.vars['descriptions'][k] info_a = orga_infos[0][0] label_a1 = orga_infos[0][1][0] label_a2 = orga_infos[0][1][1] info_b = orga_infos[1][0] label_b1 = orga_infos[1][1][0] label_b2 = orga_infos[1][1][1] info_c = orga_infos[2][0] label_c1 = orga_infos[2][1][0] label_c2 = orga_infos[2][1][1] info_d = orga_infos[3][0] label_d1 = orga_infos[3][1][0] label_d2 = orga_infos[3][1][1] indice1 = candidat[0][0] indice2 = candidat[1][0] indice3 = candidat[2][0] indice4 = candidat[3][0] return dict( indice1=indice1, indice2=indice2, indice3=indice3, indice4=indice4, metier=metier, description=description, derniere_proba=derniere_proba, derniere_non_proba=derniere_non_proba, info_a=info_a, label_a1=label_a1, label_a2=label_a2, info_b=info_b, label_b1=label_b1, label_b2=label_b2, info_c=info_c, label_c1=label_c1, label_c2=label_c2, info_d=info_d, label_d1=label_d1, label_d2=label_d2, ) @staticmethod def js_vars(player): k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] candidat_ap_indice = candidat[3][1] l = [float(candidat_ap_indice['eg_rejet_high']), float(candidat_ap_indice['eg_rejet_low']), float(candidat_ap_indice['eg_accept_low']), float(candidat_ap_indice['eg_accept_high']), ] choix_objectif = l.index(max(l)) + 1 # 'eg_rejet_high' : row['EG Rejeter High'], 'eg_rejet_low' : row['EG Rejeter Low'], 'eg_accept_low' : row['EG Accepter Low'], 'eg_accept_high' : row['EG Accepter High'], 'eg_max' : row['EG max'] return dict( choix_objectif=choix_objectif, ) @staticmethod def get_form_fields(player): return Choix.form_fields @staticmethod def before_next_page(player: Player, timeout_happened): gain = C.gain_choix(C, player.choix_sub, player.choix_obj) player.score_choix = gain[1] player.participant.vars['nb_bons_choix2'] += gain[1] if player.round_number == player.participant.vars['choix_gagnant2']: player.participant.vars['gain_final2'] += gain[0] k = player.round_number - 1 candidat = player.participant.vars['pile_CV'][k] id_candidat = candidat[0][3] player.id_candidat = str([int(id_candidat[0]), int(id_candidat[1]), int(id_candidat[2]), int(id_candidat[3])]) player.poids_genre = id_candidat[0] player.poids_diplome = id_candidat[1] player.poids_experience = id_candidat[2] player.poids_age = id_candidat[3] orga_infos = player.participant.vars['pile_infos'][k] indice1 = candidat[0][0] indice2 = candidat[1][0] indice3 = candidat[2][0] indice4 = candidat[3][0] if 'Genre' in indice1: player.ordre_genre = 1 if 'Femme' in indice1: player.valeur_genre = 'Femme' else: player.valeur_genre = 'Homme' elif 'Diplome' in indice1: player.ordre_diplome = 1 if 'Pertinent' in indice1: player.valeur_diplome = 'Pertinent' else: player.valeur_diplome = 'Non pertinent' elif 'Experience' in indice1: player.ordre_experience = 1 if 'Plus de deux ans' in indice1: player.valeur_experience = 'Plus de deux ans' else: player.valeur_experience = 'Moins de deux ans' elif 'Age' in indice1: player.ordre_age = 1 if 'Moins de cinquante ans' in indice1: player.valeur_age = 'Moins de cinquante ans' else: player.valeur_age = 'Plus de cinquante ans' if 'Genre' in indice2: player.ordre_genre = 2 if 'Femme' in indice2: player.valeur_genre = 'Femme' else: player.valeur_genre = 'Homme' elif 'Diplome' in indice2: player.ordre_diplome = 2 if 'Pertinent' in indice2: player.valeur_diplome = 'Pertinent' else: player.valeur_diplome = 'Non pertinent' elif 'Experience' in indice2: player.ordre_experience = 2 if 'Plus de deux ans' in indice2: player.valeur_experience = 'Plus de deux ans' else: player.valeur_experience = 'Moins de deux ans' elif 'Age' in indice2: player.ordre_age = 2 if 'Moins de cinquante ans' in indice2: player.valeur_age = 'Moins de cinquante ans' else: player.valeur_age = 'Plus de cinquante ans' if 'Genre' in indice3: player.ordre_genre = 3 if 'Femme' in indice3: player.valeur_genre = 'Femme' else: player.valeur_genre = 'Homme' elif 'Diplome' in indice3: player.ordre_diplome = 3 if 'Pertinent' in indice3: player.valeur_diplome = 'Pertinent' else: player.valeur_diplome = 'Non pertinent' elif 'Experience' in indice3: player.ordre_experience = 3 if 'Plus de deux ans' in indice3: player.valeur_experience = 'Plus de deux ans' else: player.valeur_experience = 'Moins de deux ans' elif 'Age' in indice3: player.ordre_age = 3 if 'Moins de cinquante ans' in indice3: player.valeur_age = 'Moins de cinquante ans' else: player.valeur_age = 'Plus de cinquante ans' if 'Genre' in indice4: player.ordre_genre = 4 if 'Femme' in indice4: player.valeur_genre = 'Femme' else: player.valeur_genre = 'Homme' elif 'Diplome' in indice4: player.ordre_diplome = 4 if 'Pertinent' in indice4: player.valeur_diplome = 'Pertinent' else: player.valeur_diplome = 'Non pertinent' elif 'Experience' in indice4: player.ordre_experience = 4 if 'Plus de deux ans' in indice4: player.valeur_experience = 'Plus de deux ans' else: player.valeur_experience = 'Moins de deux ans' elif 'Age' in indice4: player.ordre_age = 4 if 'Moins de cinquante ans' in indice4: player.valeur_age = 'Moins de cinquante ans' else: player.valeur_age = 'Plus de cinquante ans' player.info_a = orga_infos[0][0] player.label_a1 = orga_infos[0][1][0] player.label_a2 = orga_infos[0][1][1] player.info_b = orga_infos[1][0] player.label_b1 = orga_infos[1][1][0] player.label_b2 = orga_infos[1][1][1] player.info_c = orga_infos[2][0] player.label_c1 = orga_infos[2][1][0] player.label_c2 = orga_infos[2][1][1] player.info_d = orga_infos[3][0] player.label_d1 = orga_infos[3][1][0] player.label_d2 = orga_infos[3][1][1] if player.label_a1 in indice1: player.p_indice_1 = 0.75 elif player.label_a2 in indice1: player.p_indice_1 = 0.25 elif player.label_b1 in indice1: player.p_indice_1 = 0.65 elif player.label_b2 in indice1: player.p_indice_1 = 0.35 elif player.label_c1 in indice1: player.p_indice_1 = 0.70 elif player.label_c2 in indice1: player.p_indice_1 = 0.30 elif player.label_d1 in indice1: player.p_indice_1 = 0.60 elif player.label_d2 in indice1: player.p_indice_1 = 0.40 if player.label_a1 in indice2: player.p_indice_2 = 0.75 elif player.label_a2 in indice2: player.p_indice_2 = 0.25 elif player.label_b1 in indice2: player.p_indice_2 = 0.65 elif player.label_b2 in indice2: player.p_indice_2 = 0.35 elif player.label_c1 in indice2: player.p_indice_2 = 0.70 elif player.label_c2 in indice2: player.p_indice_2 = 0.30 elif player.label_d1 in indice2: player.p_indice_2 = 0.60 elif player.label_d2 in indice2: player.p_indice_2 = 0.40 if player.label_a1 in indice3: player.p_indice_3 = 0.75 elif player.label_a2 in indice3: player.p_indice_3 = 0.25 elif player.label_b1 in indice3: player.p_indice_3 = 0.65 elif player.label_b2 in indice3: player.p_indice_3 = 0.35 elif player.label_c1 in indice3: player.p_indice_3 = 0.70 elif player.label_c2 in indice3: player.p_indice_3 = 0.30 elif player.label_d1 in indice3: player.p_indice_3 = 0.60 elif player.label_d2 in indice3: player.p_indice_3 = 0.40 if player.label_a1 in indice4: player.p_indice_4 = 0.75 elif player.label_a2 in indice4: player.p_indice_4 = 0.25 elif player.label_b1 in indice4: player.p_indice_4 = 0.65 elif player.label_b2 in indice4: player.p_indice_4 = 0.35 elif player.label_c1 in indice4: player.p_indice_4 = 0.70 elif player.label_c2 in indice4: player.p_indice_4 = 0.30 elif player.label_d1 in indice4: player.p_indice_4 = 0.60 elif player.label_d2 in indice4: player.p_indice_4 = 0.40 player.metier = player.participant.vars['metiers'][k] player.domaine = player.participant.vars['domaine'] player.ordre_infos = str(player.participant.vars['ordre_infos'][k]) page_sequence = [ Transition, Indice1, Indice2, Indice3, Indice4, Choix ]