From 69de74a317039c2df6ffc3723354ca9685475fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20DAIM?= Date: Fri, 13 Jan 2023 15:54:27 +0100 Subject: [PATCH] Modif menus et ajout de fonctions de listes / gererAdmission / ... --- Msae.c | 167 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 125 insertions(+), 42 deletions(-) diff --git a/Msae.c b/Msae.c index b6912aa..8d78e2f 100644 --- a/Msae.c +++ b/Msae.c @@ -563,7 +563,7 @@ void lancerPhaseCandidature(int *phaseCandidature) clearpage(); } /*autre*/ -int comptClermont(tCand,int tMax) +int comptClermont(Candidat *tCand[],int tMax) { int i=0,compt=0,j=0; for(i=0;inombreChoix) + { + if(strcmp(tCand[pos]->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(tCand[pos]->tChoix[j]->dep, "Informatique") == 0) + { + tCand[pos]->tChoix[j]->decisionCand=-1; + break; + } + } + suppr=rechercherCandListe(*ladmis,tCand[pos]->numeroC,&trouve); + *ladmis=supprimerCand(*ladmis,tCand[pos]); + *f=fileToAdmis(*f,ladmis,1,mini); } } } @@ -964,53 +975,104 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM } -void menuResp(Candidat *tCand[],int tMax,int phaseCandidature,FileCand *f,ListeCand *ladmis) +void menuResp(Candidat *tCand[],int tMax,int phaseCandidature,FileCand *f,ListeCand *ladmis,float *mini) { - int admis,deci,trouve,pos,posC,i; - float mini; - system("clear"); - printf("Quel est le nombre de candidat admis ?\t"); - scanf("%d%*c",&admis); - printf("\nQuelle moyenne minimale les candidats doivent avoir ?\t"); - scanf("%f",&mini); - printf("\n\nVoici les candidats ayant sélectionner votre département :\t"); - afficher(*f); - printf("Voulez-vous en refuser ? (insérer son numéro ou 0 pour quitter)\t"); - scanf("%d%*c",&deci); - while (deci!=0) + int select=0; + while(select!=9) { - pos=rechercherCandidat(tCand,tMax,deci, &trouve); - if(trouve==1) + system("clear"); + printf("___________________________________________________________\n"); + printf("| Menu Responsable |\n"); + printf("|---------------------------------------------------------|\n"); + printf("| 1 Déclarez une moyenne minimale (obligatoire) |\n"); + printf("| 2 Gérer les admissions |\n"); + printf("| 3 Afficher la liste des admissions ou la file d'attente |\n"); + printf("| 9 Quitter |\n"); + printf("|_________________________________________________________|\n"); + printf("\nSaisie :\t"); + scanf("%d%*c",&select); + if(select==1) + { + printf("Quelle est la moyenne minimale pour entrer dans votre département?\t"); + scanf("%f",mini); + } + if(select==2) { - posC=rechercherChoix(tCand[pos]->tChoix,tCand[pos]->nombreChoix,"Clermont-Ferrand","Informatique",&trouve); - tCand[pos]->tChoix[posC]->decisionResp=-1; + gererAdmis(f,ladmis,*mini); + } + if(select==3) + { + afficherCandidatsParCategorie(*f,*ladmis); } - else printf("Mauvais numéro. Taper 0 pour quitter\n"); - printf("Voulez-vous en refuser ? (insérer son numéro ou 0 pour quitter)\t"); - scanf("%d%*c",&deci); } - *ladmis=listeCandNouv(); - *f=fileToAdmis(*f,ladmis,admis); - printf("Voi"); + clearpage(); +} + +void gererAdmis(FileCand *f, ListeCand *l,float mini) +{ + int select=0,admis,i=0; + char choix; + Candidat *c; + while (select!=9) + { + system("clear"); + printf("1 Accepter des candidats\n"); + printf("2 Refuser des candidats\n"); + printf("9 Quitter\n"); + scanf("%d%*c",&select); + if(select==1) + { + afficher(*f); + printf("\nCombien de candidats voulez vous accepter?\t"); + scanf("%d%*c",&admis); + *f=fileToAdmis(*f,l,admis,mini); + afficherListeCand(*l); + } + if(select==2) + { + c=tete(*f); + afficherCandidat(c); + printf("Refuser le candidat?(o/n)"); + scanf("%c",&choix); + if(choix=='o'||choix=='O') + { + *f=supt(*f); + while(inombreChoix) + { + if (strcmp(c->tChoix[i]->ville, "Clermont-Ferrand") == 0 && strcmp(c->tChoix[i]->dep, "Informatique") == 0) + { + c->tChoix[i]->decisionResp=-1; + } + i++; + } + } + } + } + clearpage(); } -FileCand fileToAdmis(FileCand f, ListeCand *l, int nbAdmis) +FileCand fileToAdmis(FileCand f, ListeCand *l, int nbAdmis,float mini) { + int j; Candidat *c; while(nbAdmis!=0) { - c=f.t->c; - f=supt(f); - *l=insererCandEntete(*l,c); - for(j = 0; j < c->nombreChoix; j++) + if(f.t->c->moyenne>=mini) { - if(strcmp(c->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(c->tChoix[j]->dep, "Informatique") == 0) + c=f.t->c; + f=supt(f); + *l=insererCandEntete(*l,c); + for(j = 0; j < c->nombreChoix; j++) { - c->tChoix[j]->decisionResp = 1; + if(strcmp(c->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(c->tChoix[j]->dep, "Informatique") == 0) + { + c->tChoix[j]->decisionResp = 1; + } } + nbAdmis--; } - nbAdmis--; + else f=supt(f); } return f; } @@ -1059,6 +1121,7 @@ void clearpage(void) /* Permet de demander à l'utilisateur pour continuer à la void globale(void) /* Permet l'initialisation du tableau, le chargement de celui-ci et l'appel des fonctions login, menus et enregistrement */ { int tLog, retour,tMax,numC,phaseCandidature=0,pos; + float mini; Candidat **tCand; VilleIUT *tiut[100]; /* Déclaration du tableau de pointeurs tiut */ FileCand f; @@ -1083,16 +1146,16 @@ void globale(void) /* Permet l'initialisation du tableau, le chargement de celui { if(retour == 1) { - menuAdmin(tiut, &tLog, 100,&phaseCandidature); + menuAdmin(tiut, &tLog, 100,tCand,tMax,&phaseCandidature,&f,&ladmis); } if(retour == 0) { - menuCandidat(tiut, &tLog, 100,tCand,tMax,pos,phaseCandidature); + menuCandidat(tiut, &tLog, 100,tCand,tMax,pos,phaseCandidature,&f,&ladmis,mini); } retour = login(tCand,&tMax,&pos); if(retour==3) { - menuResp(tCand,tMax;phaseCandidature); + menuResp(tCand,tMax,phaseCandidature,&f,&ladmis,&mini); } } enregistrement(tiut, tLog); @@ -1884,7 +1947,7 @@ Candidat** remplirCandCl(Candidat *tCand[], Candidat *tempC[], int tMax, int nbC { for(j = 0; j < tCand[i]->nombreChoix; j++) { - if(strcmp(tCand[i]->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(tCand[i]->tChoix[j].dep, "Informatique") == 0) + if(strcmp(tCand[i]->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(tCand[i]->tChoix[j]->dep, "Informatique") == 0) { tempC[k] = tCand[i]; k = k + 1; @@ -1917,4 +1980,24 @@ int plusGrandCandTemp(Candidat *tCand[], int nbCl) /* Fonction permettant de tro } } return maxi; +} + +void afficherCandidatsParCategorie(FileCand f,ListeCand l) +{ + int categ, i, pos, trouve; + printf("Quelle catégorie de candidats souhaitez-vous afficher ? (admis = 1 / attente = 2)\nSaisie : "); + scanf("%d%*c", &categ); + printf("\n"); + if(categ==1) + { + afficherListeCand(l); + } +} + +void afficherListeCand(ListeCand l) +{ + while(l->suiv!=NULL) + { + afficherCandidat(l->c); + } } \ No newline at end of file