Partie 1 | Partie 2 | Partie 3 | fonctionne Ensemble

master
Alexis LAURENT 2 years ago
parent 1a275149ed
commit c84e773ac9

217
SAE.c

@ -103,8 +103,7 @@ int menuAdminAffiche(void)
printf("1 - Mise à jour nombre de Places d'un Département d'un IUT\n");
printf("2 - Création d'un département dans un IUT\n");
printf("3 - Suppression d'un département dans un IUT\n");
printf("4 - Gestion des phases de candidature\n");
printf("5 - Changement d'un responsable de département\n");
printf("4 - Changement d'un responsable de département\n");
printf("\n\n9 - Repasser en mode Utilisateur");
printf("\n\n10 - Quitter\n");
printf("####################################################\n");
@ -170,6 +169,16 @@ void gestionMenu(VilleIUT **tiut, int nbEle, Candidat **tcandid, int *nbCandid,
return;
}
break;
case 11:
choix = gestionResponsable(tiut, nbEle, tcandid, *nbCandid);
if (choix == -1)
if(verifQuit())
{
SauvegarderIUT(tiut, nbEle);
SauvegardeCandid(tcandid, *nbCandid);
return;
}
break;
}
}
@ -198,10 +207,6 @@ int gestionMenuAdmin(VilleIUT **tiut, int nbEle)
system("clear");
break;
case 4:
//affichage du nombres de places par département d'un iut
clearpage();
break;
case 5:
modifChefDept(tiut, nbEle);
system("clear");
break;
@ -1074,7 +1079,7 @@ void gestionCandid(VilleIUT **tiut, int nbIUT, Candidat **tcandid, int *nbCandid
break;
case 2:
supprimerCandid(tcandid, nbCandid);
system("clear");
clearpage();
break;
case 3:
printf("Votre identifiant : ");
@ -1303,6 +1308,7 @@ void supprimerCandidDept(Candidat **tcandid, int nbCandid, VilleIUT **tiut, int
void modifCandid(Candidat **tcandid, int nbCandid, VilleIUT **tiut, int nbIUT, int iCandid)
{
int choix;
system("clear");
while(1)
{
choix = menuGestionCandid();
@ -1555,3 +1561,200 @@ void SauvegardeCandidDept(ChoixDept **tDept, int nbDept, FILE *flot)
fprintf(flot, "%s\n%d\n%d", tDept[i]->departement, tDept[i]->decisionDept, tDept[i]->decisionCandid);
}
int verifChefDepart(VilleIUT **tiut, int nbEle, char *dept, char *ville, char *nom)
{
int i, verif = 0;
ListeDept l;
for (i = 0; i < nbEle; i++)
{
if (strcmp(tiut[i]->ville, ville) == 0)
{
l = tiut[i]->idDept;
while (l != NULL)
{
if (strcmp(l->departement, dept) == 0)
{
if (strcmp(l->responsable, nom) == 0)
{
verif = 1;
}
}
l = l->suiv;
}
}
}
return verif;
}
int menuResponsableAffiche(void)
{
int choix;
printf("####################################################\n");
printf("\t\t|Menu Responsable|\n\n");
printf("\t\t------------------\n\n");
printf("1 - Traiter les candidatures (output dans des fichiers)\n");
printf("\n\n9 - Repasser en mode Utilisateur");
printf("\n\n10 - Quitter\n");
printf("####################################################\n");
printf("\nSelection : ");
scanf("%d", &choix);
return choix;
}
int gestionResponsable(VilleIUT **tiut, int nbEle, Candidat **tcandid, int tailleL)
{
int choix, codeRet, nb;
char dept[30];
char ville[30];
char nom[30];
Candidat** tabCandidV;
printf("Nom du département concernée : ");
scanf("%s", dept);
printf("\nNom de la ville concernée : ");
fgets(ville, 30, stdin);
ville[strlen(ville) - 1] = '\0';
printf("\nNom du responsable du département : ");
fgets(nom, 30, stdin);
nom[strlen(nom) - 1] = '\0';
printf("\n");
codeRet = verifChefDepart(tiut, nbEle, dept, ville, nom);
if (codeRet == 0)
return 0;
while (1)
{
choix = menuResponsableAffiche();
system("clear");
switch (choix)
{
case 1:
tabCandidV = candidDept(tcandid, dept, ville, tailleL,&nb);
examinerCandid(tabCandidV, nb, dept, ville);
system("clear");
break;
case 9:
return 0;
case 10:
return -1;
}
}
}
int traiterCandidIUTDept(Candidat *candid, char *dept, char *ville)
{
int i, verif = 0, nb = 0;
ListeCandid l = candid->idCandIUT;
while (l != NULL)
{
if (strcmp(l->iutCandid, ville) == 0)
{
verif = 1;
break;
}
l = l->suiv;
}
if (verif == 1)
{
for (i = 0; i < l->nbChoix; i++)
{
if (strcmp(l->tabDept[i]->departement, dept) == 0)
return 1;
}
}
return 0;
}
Candidat** candidDept(Candidat** tabCandidat, char* dept, char* ville, int tailleL, int* nb)
{
int tphys = 50, i, codeRetour;
Candidat **tabCandDept;
tabCandDept = (Candidat **)malloc(sizeof(Candidat *) * tphys);
if (tabCandDept == NULL)
{
printf("Pb malloc tab candid\n");
exit(1);
}
*nb = 0;
for (i = 0; i < tailleL; i++)
{
codeRetour = traiterCandidIUTDept(tabCandidat[i], dept, ville);
if (codeRetour == 1)
{
tabCandDept[*nb] = tabCandidat[i];
*nb += 1;
}
}
return tabCandDept;
}
void SauvegardeCandidAdmis(Candidat **tab, int nb, int admis)
{
FILE *flot;
int i;
float moy;
if (admis == 1)
flot = fopen("candidAdmis.txt", "w");
else
flot = fopen("candidMEA.txt", "w");
if (flot == NULL)
{
printf("Problème ouverture fichier candidat admis\n");
exit(1);
}
for (i = 0; i < nb; i++)
{
moy = (tab[i]->note[0] + tab[i]->note[1] + tab[i]->note[2] + tab[i]->note[3]) / 4;
fprintf(flot, "%s %s %.1f\n", tab[i]->nom, tab[i]->prenom, moy);
}
fclose(flot);
}
void examinerCandid(Candidat **tabCandid, int nb, char* dept, char* ville)
{
int nbAdmis, i, comptAdmis = 0, j, comptAttente = 0;
float mini, moy;
Candidat *tabAdmis[50];
Candidat *tabEnAttente[50];
ListeCandid l;
printf("Nombre d'admis ?\n");
scanf("%d", &nbAdmis);
printf("Note minimum ?\n");
scanf("%f", &mini);
for (i = 0; i < nb; i++)
{
moy = (tabCandid[i]->note[0] + tabCandid[i]->note[1] + tabCandid[i]->note[2] + tabCandid[i]->note[3]) / 4;
l = tabCandid[i]->idCandIUT;
while (l != NULL)
{
if (strcmp(l->iutCandid, ville) == 0)
break;
l = l->suiv;
}
for (j = 0; j < l->nbChoix; j++)
{
if (strcmp(l->tabDept[j]->departement, dept) == 0)
{
if (moy >= mini)
{
if (comptAdmis < nbAdmis)
{
l->tabDept[j]->decisionDept = 1;
tabAdmis[comptAdmis] = tabCandid[i];
comptAdmis += 1;
}
else
{
l->tabDept[j]->decisionDept = 2;
tabEnAttente[comptAttente] = tabCandid[i];
comptAttente += 1;
}
}
else
l->tabDept[j]->decisionDept = -1;
}
}
}
SauvegardeCandidAdmis(tabAdmis, comptAdmis, 1);
SauvegardeCandidAdmis(tabEnAttente, comptAttente, 0);
}

14
SAE.h

@ -233,3 +233,17 @@ void SauvegardeCandidDept(ChoixDept **tDept, int nbDept, FILE *flot);
void decalageGauche(Candidat **tab,int pos, int nbEle);
void decalageGaucheDept(ChoixDept **tab, int pos, int nbEle);
int verifChefDepart(VilleIUT **tiut, int nbEle, char *dept, char *ville, char *nom);
int menuResponsableAffiche(void);
int gestionResponsable(VilleIUT **tiut, int nbEle, Candidat **tcandid, int tailleL);
int traiterCandidIUTDept(Candidat *candid, char *dept, char *ville);
Candidat** candidDept(Candidat** tabCandidat, char* dept, char* ville, int tailleL, int* nb);
void SauvegardeCandidAdmis(Candidat **tab, int nb, int admis);
void examinerCandid(Candidat **tabCandid, int nb, char* dept, char* ville);

BIN
exe

Binary file not shown.

@ -1,7 +1,6 @@
Clermont-Ferrand
3
2
Informatique 130 Bouhours Cédric
Pokemon 7 Sacha Ketchum
Réseaux 5 Unmec Sympa
Lyon
2

@ -1,29 +1,6 @@
#include "SAEl.h"
void globale(void) {
int tailleL, i, nbP = 7;
char nom[30],depart[30];
VilleIUT** tab;
char nomFich[20];
strcpy(nomFich,"iut.txt");
tab = chargementVille(nomFich,30,&tailleL);
for(i = 0 ; i < tailleL ; i++) {
printf("Ville : %s\n",tab[i]->ville);
affichageListeDept(tab[i]->idDept);
}
printf("Nom du depart :\n");
scanf("%s%*c",depart);
printf("Nom responsable :\n");
fgets(nom,30,stdin);
nom[strlen(nom) - 1] = '\0';
insererDept(tab[0]->idDept,depart,nom,nbP);
printf("Ville : %s\n",tab[0]->ville);
affichageListeDept(tab[0]->idDept);
SauvegarderIUT(tab,tailleL);
}
#include "SAE.h"
int main(void) {
globale();
global();
return 0;
}
Loading…
Cancel
Save