From 4d5eee160b98481cd77e600af62f2ef5c9164e78 Mon Sep 17 00:00:00 2001 From: "antoine.perederii" Date: Fri, 13 Jan 2023 20:52:30 +0100 Subject: [PATCH] ajout de MdPAdmin --- SAE.h | 9 +++-- TEST.c | 3 +- administrateur.c | 33 ++++++++++++++++ mdpAdmin.bin | Bin 0 -> 30 bytes menus.c | 100 +++++++++++++++++++++++++++-------------------- responsable.c | 32 +++++++-------- 6 files changed, 114 insertions(+), 63 deletions(-) create mode 100644 mdpAdmin.bin diff --git a/SAE.h b/SAE.h index d516e1a..95257d5 100755 --- a/SAE.h +++ b/SAE.h @@ -50,8 +50,8 @@ void afficherCandidatsRefuses(Etudiant *tetud[], int nbCandidats); void afficherCandidatsAttente(Etudiant *tetud[], int nbCandidats); Etudiant moyenneCandidat(Etudiant mEtudiant); Etudiant *moyenneCandidats(Etudiant *tetud[], int nbCandiats); -Etudiant modifStatueCandidat(Etudiant *tetud[], int nbCandidats, float noteMin[]); -int statueCandidat(Etudiant *tetud[], int nbCandidats); +Etudiant modifStatueCandidat(Etudiant *tetud[], int nbCandidats, float noteMin[], VilleIUT *tiut[], int nbIUT, char respVille[30], char respDept[30]); +int statueCandidat(Etudiant *tetud[], int nbCandidats, Etudiant *tetudAdmis[], Etudiant *tetudAttente[], int nbEtudAdmis, int nbEtudAttente); int nbCandidatsAdmis(Etudiant *tetud[], int nbCandidats); int nbCandidatsRefuses(Etudiant *tetud[], int nbCandidats); int nbCandidatsAttente(Etudiant *tetud[], int nbCandidats); @@ -83,4 +83,7 @@ void deptResp(VilleIUT *tiut[], int nbVilles, char respVille[], char respIUT[]); int chargementRespDept(Etudiant *tetud[], int nbCand, char respVille[], char respIUT[], Etudiant *tetudResp[]); void lancerAdmissions(Etudiant *tetudResp[], int nbCandResp, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente, char ville[], char dept[]); void sauvegardeAdmis(Etudiant *tetudAdmis[], int nbEtudAdmis); -void sauvegardeAttente(Etudiant *tetudAttente[], int nbEtudAttente); \ No newline at end of file +void sauvegardeAttente(Etudiant *tetudAttente[], int nbEtudAttente); + +void chargerMdPAdmin(); +void modifierMdPAdmin(); \ No newline at end of file diff --git a/TEST.c b/TEST.c index 4f5d33e..f5b6908 100644 --- a/TEST.c +++ b/TEST.c @@ -2,6 +2,7 @@ int main(void) { - global(); + // chargerMdPAdmin(); + modifierMdPAdmin(); return 0; } diff --git a/administrateur.c b/administrateur.c index eaec93b..abeaea8 100644 --- a/administrateur.c +++ b/administrateur.c @@ -145,4 +145,37 @@ void stopperPhaseCandidature(bool *phaseCandidature, bool *phaseTraitement) { printf("La phase de candidature est déjà fermée.\n"); } +} + +void chargerMdPAdmin() +{ + FILE *flot; + flot = fopen("mdpAdmin.bin", "rb"); + if (flot == NULL) + { + printf("Erreur lors de l'ouverture du fichier mdpAdmin.bin\n"); + exit(1); + } + char mdp[30]; + fread(mdp, sizeof(char), 30, flot); + printf("Le mot de passe de l'administrateur est : %s\n", mdp); + fclose(flot); +} + +void modifierMdPAdmin() +{ + char mdp[30]; + FILE *flot; + flot = fopen("mdpAdmin.bin", "wb"); + if (flot == NULL) + { + printf("Erreur lors de l'ouverture du fichier mdpAdmin.txt\n"); + return; + } + printf("Entrez le nouveau mot de passe de l'administrateur :\n> "); + fgets(mdp, 30, stdin); + mdp[strlen(mdp) - 1] = '\0'; + fwrite(mdp, sizeof(char), strlen(mdp) + 1, flot); + fprintf(flot, "\n"); + fclose(flot); } \ No newline at end of file diff --git a/mdpAdmin.bin b/mdpAdmin.bin new file mode 100644 index 0000000000000000000000000000000000000000..8774f7e0050e770a882048993e47e7869628f6a1 GIT binary patch literal 30 lcmXTQ&Pppw$tuf8%Sutm%1FyD%SuVgOUuqG%S&P40sy "); + while(mdp != MdPAdmin) + { + if(i == 3) + { + printf("Vous avez entré 3 fois le mauvais mot de passe, veuillez réessayer plus tard.\n"); + } + printf("Veuillez entrer le mot de passe administrateur :\n> "); + scanf("%s%*c", mdp); + i++; + } menuAdministrateur(tiut, nbIUT, tetud, nbCandidats, phaseCandidatures, phaseTraitement); break; case 2: @@ -64,9 +78,9 @@ void menu(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats, boo case 4: menuResponsable(tetud, *nbCandidats, tiut, nbIUT, tetudAdmis, *nbEtudAdmis, tetudAttente, *nbEtudAttente); break; - case 5: - menuPostCandidat(); - break; + // case 5: + // menuPostCandidat(); + // break; case 9: c = true; return; @@ -289,16 +303,16 @@ void menuResponsable(Etudiant *tetud[], int nbCandidats, VilleIUT *tiut[], int * case 2: modificationNbPDeptResp(tiut, *nbIUT, respVille, respDept); break; - case 3: - //*noteMin = modifNoteMin(noteMin); - // ? Note min stocké où ? ==> dans le fichier informationsIUT.txt - break; //! A revoir segment fault - case 4: - modifStatueCandidat(tetudResp, nbCandidatsDept, noteMin, tiut, *nbIUT, respVille, respDept); //! Mettre dans l'admin et dire que c'est lui qui lance tt - // lancerAdmissions(tetudResp, nbCandidats, tetudAdmis, nbEtudAdmis, tetudAttente, nbEtudAttente, respVille, respDept); - //! Qd finis enregistrer dans tblAdmis et tblAttente puis sauv dans fichier - statueCandidat(tetud, nbCandidats, tetudAdmis, tetudAttente, nbEtudAdmis, nbEtudAttente); - break; + // case 3: + // //*noteMin = modifNoteMin(noteMin); + // // ? Note min stocké où ? ==> dans le fichier informationsIUT.txt + // break; //! A revoir segment fault + // case 4: + // modifStatueCandidat(tetudResp, nbCandidatsDept, noteMin, tiut, *nbIUT, respVille, respDept); //! Mettre dans l'admin et dire que c'est lui qui lance tt + // // lancerAdmissions(tetudResp, nbCandidats, tetudAdmis, nbEtudAdmis, tetudAttente, nbEtudAttente, respVille, respDept); + // //! Qd finis enregistrer dans tblAdmis et tblAttente puis sauv dans fichier + // statueCandidat(tetud, nbCandidats, tetudAdmis, tetudAttente, nbEtudAdmis, nbEtudAttente); + // break; case 9: c = true; return; @@ -372,33 +386,33 @@ void menuAffichage(Etudiant *tetudResp[], int nbCandidatsDept) } } -void menuPostCandidat() -{ - int choix; - bool c = false; - while (c == false) - { - printf("\n\nMenu des Affichages Responsable de Departement : Que voulez-vous faire ?\n"); - printf("\t1 - Afficher les informations sur mes voeus\n"); - printf("\t2 - Validation d'un voeux (et refus des autres)\n"); - printf("\t9 - Quitter\n"); - printf("\nEntrez votre choix :\n> "); - scanf("%d%*c", &choix); - switch (choix) - { - case 1: - afficherCandidat(tetud, *nbCandidats); - break; - case 2: - ValidationCandidature();//** Valide une candidature et rejette ttes les autres ==> enregistre dans tblAdmis et tblAttente - MiseAJourAdmission();//** relance l'admission - break; - case 9: - c = true; - return; - default: - printf("Option non reconnue. Veuillez recommencer.\n"); - break; - } - } -} \ No newline at end of file +// void menuPostCandidat() +// { +// int choix; +// bool c = false; +// while (c == false) +// { +// printf("\n\nMenu des Affichages Responsable de Departement : Que voulez-vous faire ?\n"); +// printf("\t1 - Afficher les informations sur mes voeus\n"); +// printf("\t2 - Validation d'un voeux (et refus des autres)\n"); +// printf("\t9 - Quitter\n"); +// printf("\nEntrez votre choix :\n> "); +// scanf("%d%*c", &choix); +// switch (choix) +// { +// case 1: +// afficherCandidat(tetud, *nbCandidats); +// break; +// case 2: +// ValidationCandidature();//** Valide une candidature et rejette ttes les autres ==> enregistre dans tblAdmis et tblAttente +// MiseAJourAdmission();//** relance l'admission +// break; +// case 9: +// c = true; +// return; +// default: +// printf("Option non reconnue. Veuillez recommencer.\n"); +// break; +// } +// } +// } \ No newline at end of file diff --git a/responsable.c b/responsable.c index e3888af..9c44053 100644 --- a/responsable.c +++ b/responsable.c @@ -70,13 +70,13 @@ Etudiant modifStatueCandidat(Etudiant *tetud[], int nbCandidats, float noteMin[] if (trouve == false) { printf("L'IUT de ce responsable n'existe pas. Veuillez réessayer en changeant de responsable.\n"); - return; + return **tetud; } posDept = rechercheDept(tiut[posIUT]->ldept, respDept, &trouve); if (trouve == false) { printf("Le departement de ce responsable n'existe pas. Veuillez réessayer en changeant de responsable.\n"); - return; + return **tetud; } for (int i = 0; i < nbCandidats; i++) { @@ -114,20 +114,20 @@ int statueCandidat(Etudiant *tetud[], int nbCandidats, Etudiant *tetudAdmis[], E } } -Etudiant ValidationCandidature() -{ - int i; - char choix[30]; - printf("Quel voeu souhaitez-vous valider ?\n") - scanf("%s", &choix); - for (i = 0; i < nbCandidats; i++) - { - if (tetud[i]->lChoix->choix.decisionAdmission == 1) - { - tetud[i]->lChoix->choix.decisionAdmission = 0; - } - } -} +// Etudiant ValidationCandidature() +// { +// int i; +// char choix[30]; +// printf("Quel voeu souhaitez-vous valider ?\n"); +// scanf("%s", &choix); +// for (i = 0; i < nbCandidats; i++) +// { +// if (tetud[i]->lChoix->choix.decisionAdmission == 1) +// { +// tetud[i]->lChoix->choix.decisionAdmission = 0; +// } +// } +// } int nbCandidatsAdmis(Etudiant *tetud[], int nbCandidats) {