@ -125,7 +125,7 @@ void menuCandidat(VilleIUT*** tiutPointer, ListeCandidats* listePointer, int* nb
printf ( " \n \n Souhaitez-vous vous connecter/enregistrer maintenant ou entrer en mode invité (O/N) ? : " ) ;
scanf ( " %*c%c " , & connexion ) ;
if ( connexion = = ' O ' )
if ( connexion = = ' O ' | | connexion = = ' o ' )
identificationCandidat ( & id , listePointer , nbCandidats ) ;
else
if ( connexion ! = ' n ' & & connexion ! = ' N ' )
@ -204,13 +204,11 @@ void menuCandidat(VilleIUT*** tiutPointer, ListeCandidats* listePointer, int* nb
break ;
case 5 :
printf ( " Suivre sa candidature... \n \n " ) ;
if ( id = = 0 )
fprintf ( stderr , " \ e[0;91mErreur : vous devez d'abord vous authentifier, merci de réessayer plus tard. \n \ e[0m " ) ;
if ( candidat - > nbCandidatures = = 0 )
fprintf ( stderr , " \ e[0;91mErreur : vous n'avez aucune candidature en cours, merci de réessayer plus tard. \n \ e[0m " ) ;
else
afficherCandidatures( candidat - > listeCandidatures , candidat - > nbCandidatures ) ;
menuCandidat_suivreCandidature ( * listePointer , * nbCandidats , candidat ) ;
break ;
default :
@ -253,7 +251,7 @@ void menuResponsable(VilleIUT*** tiutPointer, ListeCandidats* listePointer, int*
printf ( " Merci d'entrer le mot de passe administrateur : " ) ;
system ( " stty -echo " ) ;
scanf ( " %[^ \n ] " , pass ) ;
scanf ( " \n %[^ \n ] " , pass ) ;
system ( " stty echo " ) ;
if ( strcmp ( pass , " resp2023 " ) ! = 0 ) {
@ -263,16 +261,30 @@ void menuResponsable(VilleIUT*** tiutPointer, ListeCandidats* listePointer, int*
} else
printf ( " \n \n \ e[1;32mMot de passe correct ! \ e[0m \n \n " ) ;
printf ( " -------------------------------------------------------------------- \n " ) ;
/* RESET LA NOTE MINI DE TOUT DEPT
ListeDept ldept ;
for ( int caca = 0 ; caca < * nbVilles ; caca + + ) {
ldept = ( * tiutPointer ) [ caca ] - > ldept ;
while ( ldept ! = NULL ) {
( * tiutPointer ) [ caca ] - > ldept - > noteMinimale = - 1 ;
ldept = ldept - > suiv ;
}
}
*/
printf ( " \ e[1;34mResponsable: M. BOUHOURS, IUT: Clermont-Ferrand, Département: Informatique \ e[0m \n " ) ;
printf ( " -------------------------------------------------------------------------- \n " ) ;
printf ( " \t 1 - Lister les candidatures \n \n " ) ;
printf ( " \t 2 - Traiter les candidatures \n \n " ) ;
printf ( " \t 9 - Quitter \n " ) ;
printf ( " --------------------------------------------------------------------- \n " ) ;
printf ( " --------------------------------------------------------------------- ----- \n " ) ;
if ( scanf ( " %d " , & choix ) = = 0 )
choix = 0 ;
printf ( " ----------------------------------------------------------------------- \n " ) ;
printf ( " ----------------------------------------------------------------------- --- \n " ) ;
while ( choix ! = 9 ) {
switch ( choix ) {
@ -283,6 +295,8 @@ void menuResponsable(VilleIUT*** tiutPointer, ListeCandidats* listePointer, int*
printf ( " Entrez le nom de la ville que vous souhaitez traiter : Clermont-Ferrand \n " ) ;
printf ( " Quel département souhaitez-vous modifier ? : Informatique \n " ) ;
calculerNoteGlobale ( * listePointer , * nbCandidats ) ; // Calcul des notes globales avant affichage
printf ( " \n \ e[1;32mAffichage des candidatures pour le département 'Informatique' de l'IUT 'Clermont-Ferrand' \n \n \ e[0m " ) ;
afficherCandidaturesByDept ( * listePointer , * nbCandidats , " Clermont-Ferrand " , " Informatique " ) ;
break ;
@ -294,15 +308,16 @@ void menuResponsable(VilleIUT*** tiutPointer, ListeCandidats* listePointer, int*
default :
// Permet d'aspirer les caractères en trop sur stdin (évite de répéter le message d'erreur X fois)
while ( ( poubelle = getchar ( ) ) ! = ' \n ' & & poubelle ! = EOF ) ;
fprintf ( stderr , " \ e[0;91mErreur : la valeur entrée est invalide, merci de réessayer. \n \ e[0m " ) ;
fprintf ( stderr , " \ e[0;91mErreur : la valeur entrée est invalide, merci de réessayer. \n \n \ e[0m " ) ;
break ;
}
printf ( " \n -------------------------------------------------------------------- \n " ) ;
printf ( " \ e[1;34mResponsable: M. BOUHOURS, IUT: Clermont-Ferrand, Département: Informatique \ e[0m \n " ) ;
printf ( " -------------------------------------------------------------------------- \n " ) ;
printf ( " \t 1 - Lister les candidatures \n \n " ) ;
printf ( " \t 2 - Traiter les candidatures \n \n " ) ;
printf ( " \t 9 - Quitter \n " ) ;
printf ( " --------------------------------------------------------------------- \n " ) ;
printf ( " --------------------------------------------------------------------- ----- \n " ) ;
if ( scanf ( " %d " , & choix ) = = 0 )
choix = 0 ;
@ -320,7 +335,7 @@ void menuAdmin(VilleIUT*** tiutPointer, ListeCandidats* listePointer, int* nbVil
printf ( " Merci d'entrer le mot de passe administrateur : " ) ;
system ( " stty -echo " ) ;
scanf ( " %[^ \n ] " , pass ) ;
scanf ( " \n %[^ \n ] " , pass ) ;
system ( " stty echo " ) ;
if ( strcmp ( pass , " admin2023 " ) ! = 0 ) {
@ -484,12 +499,12 @@ void menuPrincipal(/* TODO: prise en compte des status actuels du recrutement */
menuResponsable ( & tiut , & liste , & nbVilles , & nbCandidats ) ;
titreMenuPrincipal ( ) ;
} else
fprintf ( stderr , " \ e[0;91mErreur : les recrutements sont en cours, impossible d'accéder au menu responsable. Merci de réessayer plus tard. \n \ e[0m " ) ;
fprintf ( stderr , " \ e[0;91mErreur : les recrutements sont en cours, impossible d'accéder au menu responsable. Merci de réessayer plus tard. \n \n \ e[0m " ) ;
break ;
default :
// Permet d'aspirer les caractères en trop sur stdin (évite de répéter le message d'erreur X fois)
while ( ( poubelle = getchar ( ) ) ! = ' \n ' & & poubelle ! = EOF ) ;
fprintf ( stderr , " \ e[0;91mErreur : la valeur entrée est invalide, merci de réessayer. \n \ e[0m " ) ;
fprintf ( stderr , " \ e[0;91mErreur : la valeur entrée est invalide, merci de réessayer. \n \n \ e[0m " ) ;
break ;
}
@ -521,7 +536,7 @@ void menuPrincipal(/* TODO: prise en compte des status actuels du recrutement */
// FONCTIONS MENU RESP
void menuResponsable_traiterCandidatures ( VilleIUT * * tiut , int nbVilles , ListeCandidats liste , int nbCandidats ) {
char dept [ LEN_MAX ] , ville [ LEN_MAX ] , choix ;
char dept [ LEN_MAX ] , ville [ LEN_MAX ] , choix , poubelle ;
int nbCandidatsAccept , pos , verif ;
ListeDept ldept ;
@ -535,7 +550,11 @@ void menuResponsable_traiterCandidatures(VilleIUT** tiut, int nbVilles, ListeCan
printf ( " \n \ e[1;32mTraitement des candidatures pour le département '%s' de l'IUT '%s' \n \n \ e[0m " , dept , ville ) ;
printf ( " Combien de candidats souhaitez-vous accepter ? : " ) ;
scanf ( " %d " , & nbCandidatsAccept ) ;
if ( scanf ( " %d " , & nbCandidatsAccept ) = = 0 ) {
while ( ( poubelle = getchar ( ) ) ! = ' \n ' & & poubelle ! = EOF ) ;
fprintf ( stderr , " \n \ e[0;91mErreur : la valeur entrée est invalide, merci de réessayer plus tard. \n \n \ e[0m " ) ;
return ;
}
pos = rechercherVille ( tiut , nbVilles , ville ) ;
@ -544,8 +563,8 @@ void menuResponsable_traiterCandidatures(VilleIUT** tiut, int nbVilles, ListeCan
while ( ldept ! = NULL & & strcmp ( ldept - > departement , dept ) ! = 0 )
ldept = ldept - > suiv ;
if ( ldept - > noteMinimale ! = - 1 ) {
printf ( " \n Quelle est la note minimale pour l'acception du candidat ? : " ) ;
if ( ldept - > noteMinimale = = - 1 ) {
printf ( " \n \e[1;91mAttention, après avoir entré cette valeur, elle ne sera plus modifiable ! \ e[0m \n \n Quelle est la note minimale pour l'acception du candidat ? : " ) ;
verif = scanf ( " %f " , & ldept - > noteMinimale ) ;
while ( ( ldept - > noteMinimale ) < 0 | | ( ldept - > noteMinimale ) > 20 | | verif = = 0 ) {
fprintf ( stderr , " \ e[0;91mLa note entrée est incorrecte \n \ e[0mEntrez une note minimale entre 0 et 20 : " ) ;
@ -558,9 +577,15 @@ void menuResponsable_traiterCandidatures(VilleIUT** tiut, int nbVilles, ListeCan
scanf ( " %*c%c " , & choix ) ;
if ( choix = = ' n ' | | choix = = ' N ' )
menuResponsable_traiterCandidatures ( tiut , nbVilles , liste , nbCandidats ) ;
printf ( " \n \ e[1mAnnulation de l'opération. \ e[0m \n \n " ) ;
else
if ( choix = = ' o ' | | choix = = ' O ' )
traiterCandidatures ( tiut , nbVilles , liste , nbCandidats , nbCandidatsAccept , ldept - > noteMinimale ) ;
else {
while ( ( poubelle = getchar ( ) ) ! = ' \n ' & & poubelle ! = EOF ) ;
fprintf ( stderr , " \n \ e[0;91mErreur : la valeur entrée est invalide, merci de réessayer plus tard. \n \n \ e[0m " ) ;
}
traiterCandidatures ( tiut , nbVilles , liste , nbCandidats , nbCandidatsAccept , ldept - > noteMinimale ) ;
}
// FONCTIONS MENU ADMIN
@ -569,7 +594,7 @@ void menuAdmin_modifierPlaces(VilleIUT** tiut, int nbVilles) {
int nbPlaces ;
char searchIUT [ LEN_MAX ] , searchDept [ LEN_MAX ] ;
printf ( " Entrez une ville (tapez q pour annuler) : " ) ;
scanf ( " %[^ \n ] " , searchIUT ) ;
scanf ( " \n %[^ \n ] " , searchIUT ) ;
if ( strcasecmp ( searchIUT , " q " ) = = 0 )
return ;
@ -578,7 +603,7 @@ void menuAdmin_modifierPlaces(VilleIUT** tiut, int nbVilles) {
if ( code ! = - 1 ) {
printf ( " Quel département souhaitez-vous modifier ? : " ) ;
scanf ( " %[^ \n ] " , searchDept ) ;
scanf ( " \n %[^ \n ] " , searchDept ) ;
printf ( " Entrez le nouveau nombre de places pour le département '%s' : " , searchDept ) ;
scanf ( " %d " , & nbPlaces ) ;
@ -589,7 +614,7 @@ void menuAdmin_modifierPlaces(VilleIUT** tiut, int nbVilles) {
void menuAdmin_creerIUT ( VilleIUT * * * tiutPointer , int * nbVilles ) {
char nameIUT [ LEN_MAX ] ;
printf ( " Entrez le nom de la ville (tapez q pour annuler) : " ) ;
scanf ( " %[^ \n ] " , nameIUT ) ;
scanf ( " \n %[^ \n ] " , nameIUT ) ;
if ( strcasecmp ( nameIUT , " q " ) = = 0 )
return ;
@ -611,7 +636,7 @@ void menuAdmin_creerDepartement(VilleIUT** tiut, int nbVilles) {
MaillonDept * dept ;
printf ( " Entrez la ville dans laquelle vous souhaitez ajouter un département (tapez q pour annuler) : " ) ;
scanf ( " %[^ \n ] " , searchIUT ) ;
scanf ( " \n %[^ \n ] " , searchIUT ) ;
if ( strcasecmp ( searchIUT , " q " ) = = 0 )
return ;
@ -665,7 +690,7 @@ void menuAdmin_supprimerDepartement(VilleIUT** tiut, int nbVilles) {
VilleIUT * ville ;
printf ( " Entrez la ville dans laquelle vous souhaitez supprimer un département (tapez q pour annuler) : " ) ;
scanf ( " %[^ \n ] " , searchIUT ) ;
scanf ( " \n %[^ \n ] " , searchIUT ) ;
if ( strcasecmp ( searchIUT , " q " ) = = 0 )
return ;
@ -694,7 +719,7 @@ void menuAdmin_modifierResponsable(VilleIUT** tiut, int nbVilles) {
char searchIUT [ LEN_MAX ] , searchDept [ LEN_MAX ] , nom [ LEN_MAX ] ;
printf ( " Dans quel IUT souhaitez-vous faire une modification ? (tapez q pour annuler) : " ) ;
scanf ( " %[^ \n ] " , searchIUT ) ;
scanf ( " \n %[^ \n ] " , searchIUT ) ;
if ( strcasecmp ( searchIUT , " q " ) = = 0 )
return ;
@ -703,15 +728,90 @@ void menuAdmin_modifierResponsable(VilleIUT** tiut, int nbVilles) {
if ( code ! = - 1 ) {
printf ( " Quel département souhaitez-vous modifier ? : " ) ;
scanf ( " %[^ \n ] " , searchDept ) ;
scanf ( " \n %[^ \n ] " , searchDept ) ;
printf ( " Quel est le nom du nouveau responsable : " ) ;
scanf ( " %*c %[^\n ] " , nom ) ;
scanf ( " \n %[^\n ] " , nom ) ;
modifierNomResponsable ( tiut , nbVilles , searchIUT , searchDept , nom ) ;
}
}
// FONCTION MENU CANDIDAT
void menuCandidat_suivreCandidature ( ListeCandidats liste , int nbCandidats , Candidat * candidat ) {
int i , j , mustReply = 0 , nbPropositions = 0 ;
char reponse1 , reponse2 , poubelle ;
// Création d'une liste qui va contenir les candidatures pour lesquelles le candidat a été accepté
// (pour le moment, seul une proposition peut être faite étant donné que seul le département Informatique de Clermont-Ferrand est habilité à donner une réponse)
ListeCandidatures propositions = ( ListeCandidatures ) malloc ( candidat - > nbCandidatures * sizeof ( Candidature * ) ) ;
if ( propositions = = NULL ) {
perror ( " malloc " ) ;
exit ( errno ) ;
}
if ( candidat - > nbCandidatures = = 0 )
fprintf ( stderr , " \ e[0;91mErreur : vous n'avez aucune candidature en cours, merci de réessayer plus tard. \n \ e[0m " ) ;
else
afficherCandidatures ( candidat - > listeCandidatures , candidat - > nbCandidatures ) ;
for ( i = 0 ; i < candidat - > nbCandidatures ; i + + )
if ( candidat - > listeCandidatures [ i ] - > decision = = 1 & & candidat - > listeCandidatures [ i ] - > validation = = 0 ) {
mustReply = 1 ;
propositions [ nbPropositions + + ] = candidat - > listeCandidatures [ i ] ;
}
if ( mustReply = = 1 ) {
printf ( " Vous avez %d candidature(s) contenant une proposition d'admission, souhaitez-vous y répondre ? (O/N) : " , nbPropositions ) ;
scanf ( " %*c%c " , & reponse1 ) ;
for ( i = 0 ; i < nbPropositions ; i + + ) {
if ( reponse1 = = ' o ' | | reponse1 = = ' O ' ) {
afficherCandidatures ( propositions + i , 1 ) ;
printf ( " \n Souhaitez-vous accepter ou refuser cette proposition ? (A/R) : " ) ;
scanf ( " %*c%c " , & reponse2 ) ;
if ( reponse2 = = ' a ' | | reponse2 = = ' A ' ) {
printf ( " \n \ e[1;32mProposition pour le département '%s' à l'IUT '%s' acceptée ! \ e[0m \n " ,
propositions [ i ] - > departement , propositions [ i ] - > ville ) ;
for ( j = 0 ; j < candidat - > nbCandidatures ; j + + ) {
candidat - > listeCandidatures [ j ] - > decision = - 1 ;
candidat - > listeCandidatures [ j ] - > validation = - 1 ;
}
propositions [ i ] - > decision = 1 ;
propositions [ i ] - > validation = 1 ;
break ;
} else {
if ( reponse2 = = ' r ' | | reponse2 = = ' R ' )
printf ( " \n \ e[1;32mProposition pour le département '%s' à l'IUT '%s' refusée ! \ e[0m \n " ,
propositions [ i ] - > departement , propositions [ i ] - > ville ) ;
else {
while ( ( poubelle = getchar ( ) ) ! = ' \n ' & & poubelle ! = EOF ) ;
fprintf ( stderr , " \n \ e[0;91mErreur : la réponse saisie est incorrecte. Merci de réessayer plus tard. \n \ e[0m " ) ;
break ;
}
}
} else {
if ( reponse1 = = ' n ' | | reponse1 = = ' N ' )
printf ( " \n \t \ e[1mTrès bien. Vous pouvez toujours donner votre réponse ultérieurement. \ e[0m \n " ) ;
else {
while ( ( poubelle = getchar ( ) ) ! = ' \n ' & & poubelle ! = EOF ) ;
fprintf ( stderr , " \n \ e[0;91mErreur : la réponse saisie est incorrecte. Merci de réessayer plus tard. \n \ e[0m " ) ;
break ;
}
}
}
}
free ( propositions ) ;
}
VilleIUT * creerVille ( void ) {
VilleIUT * ville = ( VilleIUT * ) malloc ( sizeof ( VilleIUT ) ) ;
@ -981,6 +1081,8 @@ void saveVilles(VilleIUT* tiut[], int nbVilles) {
fwrite ( & lenNomResponsable , sizeof ( int ) , 1 , fe ) ;
fwrite ( maillon - > responsable , sizeof ( char ) , lenNomResponsable , fe ) ;
fwrite ( & maillon - > noteMinimale , sizeof ( int ) , 1 , fe ) ;
maillon = maillon - > suiv ;
}
}
@ -1045,6 +1147,8 @@ VilleIUT** readVilles(int* nbVilles) {
fread ( & lenNomResponsable , sizeof ( int ) , 1 , fe ) ;
fread ( maillon - > responsable , sizeof ( char ) , lenNomResponsable , fe ) ;
fread ( & maillon - > noteMinimale , sizeof ( int ) , 1 , fe ) ;
if ( maillonPrecedent = = NULL )
ville - > ldept = maillon ;