@ -18,8 +18,15 @@
void menuCandidat_suivreCandidature ( ListeCandidats liste , int nbCandidats , Candidat * candidat ) {
void menuCandidat_suivreCandidature ( ListeCandidats liste , int nbCandidats , Candidat * candidat ) {
int i , j , mustReply = 0 , nbPropositions = 0 ;
int i , j , k, mustReply = 0 , nbPropositions = 0 ;
char reponse1 , reponse2 , poubelle ;
char reponse1 , reponse2 , poubelle ;
FileAttente * file ;
CandidatTraite * candidatAdmis = ( CandidatTraite * ) malloc ( sizeof ( CandidatTraite ) ) ;
if ( candidatAdmis = = NULL ) {
perror ( " malloc " ) ;
exit ( errno ) ;
}
// Création d'une liste qui va contenir les candidatures pour lesquelles le candidat a été accepté
// 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)
// (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)
@ -66,10 +73,29 @@ void menuCandidat_suivreCandidature(ListeCandidats liste, int nbCandidats, Candi
break ;
break ;
} else {
} else {
if ( reponse2 = = ' r ' | | reponse2 = = ' R ' )
if ( reponse2 = = ' r ' | | reponse2 = = ' R ' ) {
printf ( " \n \ e[1;32mProposition pour le département '%s' à l'IUT '%s' refusée ! \ e[0m \n " ,
printf ( " \n \ e[1;32mProposition pour le département '%s' à l'IUT '%s' refusée ! \ e[0m \n " ,
propositions [ i ] - > departement , propositions [ i ] - > ville ) ;
propositions [ i ] - > departement , propositions [ i ] - > ville ) ;
else {
propositions [ i ] - > validation = - 1 ;
file = lireCandidatsAttente ( propositions [ i ] - > departement , propositions [ i ] - > ville ) ;
* candidatAdmis = defiler ( file ) ;
ecrireCandidatsAttente ( propositions [ i ] - > departement , propositions [ i ] - > ville , file ) ;
ajouterCandidatAdmis ( propositions [ i ] - > departement , propositions [ i ] - > ville , candidatAdmis ) ;
if ( strcmp ( candidatAdmis - > nom , " " ) ! = 0 & & strcmp ( candidatAdmis - > prenom , " " ) ! = 0 ) {
for ( j = 0 ; j < nbCandidats ; j + + ) {
if ( liste [ j ] - > nom = = candidatAdmis - > nom & & liste [ j ] - > prenom = = candidatAdmis - > prenom ) {
ListeCandidatures listeCandidatures = liste [ j ] - > listeCandidatures ;
for ( k = 0 ; k < liste [ j ] - > nbCandidatures ; k + + )
if ( listeCandidatures [ k ] - > ville = = propositions [ i ] - > ville
& & listeCandidatures [ k ] - > departement = = propositions [ i ] - > departement )
listeCandidatures [ k ] - > decision = 1 ;
}
}
}
} else {
while ( ( poubelle = getchar ( ) ) ! = ' \n ' & & poubelle ! = EOF ) ;
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 " ) ;
fprintf ( stderr , " \n \ e[0;91mErreur : la réponse saisie est incorrecte. Merci de réessayer plus tard. \n \ e[0m " ) ;
break ;
break ;
@ -88,6 +114,7 @@ void menuCandidat_suivreCandidature(ListeCandidats liste, int nbCandidats, Candi
}
}
free ( propositions ) ;
free ( propositions ) ;
free ( candidatAdmis ) ;
}
}
void menuResponsable_traiterCandidatures ( VilleIUT * * tiut , int nbVilles , ListeCandidats liste , int nbCandidats ) {
void menuResponsable_traiterCandidatures ( VilleIUT * * tiut , int nbVilles , ListeCandidats liste , int nbCandidats ) {
@ -153,6 +180,7 @@ FileAttente* creerFile(void) {
file - > tete = NULL ;
file - > tete = NULL ;
file - > queue = NULL ;
file - > queue = NULL ;
file - > nbAttente = 0 ;
return file ;
return file ;
}
}
@ -166,11 +194,12 @@ void enfiler(FileAttente *file, CandidatTraite candidat) {
nouveauMaillon - > candidat = candidat ;
nouveauMaillon - > candidat = candidat ;
nouveauMaillon - > suivant = NULL ;
nouveauMaillon - > suivant = NULL ;
if ( estVide ( file ) ) {
if ( estVide ( file ) )
file - > tete = nouveauMaillon ;
file - > tete = nouveauMaillon ;
file - > queue = nouveauMaillon ;
else
} else
file - > queue - > suivant = nouveauMaillon ;
file - > queue - > suivant = nouveauMaillon ;
file - > queue = nouveauMaillon ;
}
}
CandidatTraite defiler ( FileAttente * file ) {
CandidatTraite defiler ( FileAttente * file ) {
@ -182,12 +211,82 @@ CandidatTraite defiler(FileAttente *file) {
candidat = tete - > candidat ;
candidat = tete - > candidat ;
file - > tete = tete - > suivant ;
file - > tete = tete - > suivant ;
file - > nbAttente = file - > nbAttente - 1 ;
free ( tete ) ;
free ( tete ) ;
}
}
return candidat ;
return candidat ;
}
}
FileAttente * lireCandidatsAttente ( char * dept , char * ville ) {
FileAttente * fileCandidats = creerFile ( ) ;
CandidatTraite candidat ;
int i ;
char fNameAttente [ 100 ] ;
strcpy ( fNameAttente , " donnees/ " ) ;
strcat ( fNameAttente , ville ) ;
strcat ( fNameAttente , " _ " ) ;
strcat ( fNameAttente , dept ) ;
strcat ( fNameAttente , " _Attente.don " ) ;
if ( access ( fNameAttente , F_OK ) ! = - 1 ) {
FILE * fAttente = fopen ( fNameAttente , " r " ) ;
if ( fAttente = = NULL ) {
perror ( " fopen " ) ;
exit ( errno ) ;
}
fscanf ( fAttente , " %d \n " , & fileCandidats - > nbAttente ) ;
for ( i = 0 ; i < fileCandidats - > nbAttente ; i + + ) {
fscanf ( fAttente , " %[^ \n ] \n %[^ \n ] \n %f %f %f %f %f \n " ,
candidat . nom , candidat . prenom , & candidat . moyenneMath , & candidat . moyenneFrancais ,
& candidat . moyenneAnglais , & candidat . moyenneSpecialite , & candidat . noteGlobale ) ;
enfiler ( fileCandidats , candidat ) ;
}
fclose ( fAttente ) ;
}
return fileCandidats ;
}
void ecrireCandidatsAttente ( char * dept , char * ville , FileAttente * file ) {
Maillon * parcourir = file - > tete ;
char fNameAttente [ 100 ] ;
strcpy ( fNameAttente , " donnees/ " ) ;
strcat ( fNameAttente , ville ) ;
strcat ( fNameAttente , " _ " ) ;
strcat ( fNameAttente , dept ) ;
strcat ( fNameAttente , " _Attente.don " ) ;
FILE * fAttente = fopen ( fNameAttente , " w " ) ;
if ( fAttente = = NULL ) {
perror ( " fopen " ) ;
exit ( errno ) ;
}
if ( file - > nbAttente > 0 )
fprintf ( fAttente , " %d \n " , file - > nbAttente ) ;
while ( parcourir ! = NULL ) {
fprintf ( fAttente , " %s \n %s \n %f %f %f %f %f \n " ,
parcourir - > candidat . nom , parcourir - > candidat . prenom , parcourir - > candidat . moyenneMath , parcourir - > candidat . moyenneFrancais ,
parcourir - > candidat . moyenneAnglais , parcourir - > candidat . moyenneSpecialite , parcourir - > candidat . noteGlobale ) ;
parcourir = parcourir - > suivant ;
}
fclose ( fAttente ) ;
}
int compareCandidatsTraite ( const void * p1 , const void * p2 ) {
int compareCandidatsTraite ( const void * p1 , const void * p2 ) {
CandidatTraite * c1 = * ( ListeAdmis ) p1 ;
CandidatTraite * c1 = * ( ListeAdmis ) p1 ;
CandidatTraite * c2 = * ( ListeAdmis ) p2 ;
CandidatTraite * c2 = * ( ListeAdmis ) p2 ;
@ -203,6 +302,71 @@ int compareCandidatsTraite(const void* p1, const void* p2) {
return strcmp ( nomComplet1 , nomComplet2 ) ;
return strcmp ( nomComplet1 , nomComplet2 ) ;
}
}
void ajouterCandidatAdmis ( char * dept , char * ville , CandidatTraite * candidat ) {
ListeAdmis liste ;
int nbAdmis , i ;
char fNameAdmis [ 100 ] ;
strcpy ( fNameAdmis , " donnees/ " ) ;
strcat ( fNameAdmis , ville ) ;
strcat ( fNameAdmis , " _ " ) ;
strcat ( fNameAdmis , dept ) ;
strcat ( fNameAdmis , " _Admis.don " ) ;
FILE * fAdmis = fopen ( fNameAdmis , " r " ) ;
if ( fAdmis = = NULL ) {
perror ( " fopen " ) ;
exit ( errno ) ;
}
fscanf ( fAdmis , " %d \n " , & nbAdmis ) ;
liste = ( ListeAdmis ) malloc ( ( nbAdmis + 1 ) * sizeof ( CandidatTraite * ) ) ;
if ( liste = = NULL ) {
perror ( " malloc " ) ;
exit ( errno ) ;
}
for ( i = 0 ; i < nbAdmis ; i + + ) {
liste [ i ] = ( CandidatTraite * ) malloc ( sizeof ( CandidatTraite ) ) ;
if ( liste [ i ] = = NULL ) {
perror ( " malloc " ) ;
exit ( errno ) ;
}
fscanf ( fAdmis , " %[^ \n ] \n %[^ \n ] \n %f %f %f %f %f \n " ,
liste [ i ] - > nom , liste [ i ] - > prenom , & liste [ i ] - > moyenneMath , & liste [ i ] - > moyenneFrancais ,
& liste [ i ] - > moyenneAnglais , & liste [ i ] - > moyenneSpecialite , & liste [ i ] - > noteGlobale ) ;
}
fclose ( fAdmis ) ;
fAdmis = fopen ( fNameAdmis , " w " ) ;
if ( fAdmis = = NULL ) {
perror ( " fopen " ) ;
exit ( errno ) ;
}
nbAdmis + = 1 ;
liste [ nbAdmis - 1 ] = candidat ;
fprintf ( fAdmis , " %d " , nbAdmis ) ;
for ( i = 0 ; i < nbAdmis ; i + + ) {
fprintf ( fAdmis , " %s \n %s \n %f %f %f %f %f \n " ,
liste [ i ] - > nom , liste [ i ] - > prenom , liste [ i ] - > moyenneMath , liste [ i ] - > moyenneFrancais ,
liste [ i ] - > moyenneAnglais , liste [ i ] - > moyenneSpecialite , liste [ i ] - > noteGlobale ) ;
}
fclose ( fAdmis ) ;
free ( liste ) ;
}
void afficherCandidatsAdmis ( char * dept , char * ville ) {
void afficherCandidatsAdmis ( char * dept , char * ville ) {
ListeAdmis liste ;
ListeAdmis liste ;
int nbAdmis , i ;
int nbAdmis , i ;
@ -231,7 +395,7 @@ void afficherCandidatsAdmis(char* dept, char* ville) {
perror ( " malloc " ) ;
perror ( " malloc " ) ;
exit ( errno ) ;
exit ( errno ) ;
}
}
for ( i = 0 ; i < nbAdmis ; i + + ) {
for ( i = 0 ; i < nbAdmis ; i + + ) {
liste [ i ] = ( CandidatTraite * ) malloc ( sizeof ( CandidatTraite ) ) ;
liste [ i ] = ( CandidatTraite * ) malloc ( sizeof ( CandidatTraite ) ) ;
@ -258,7 +422,26 @@ void afficherCandidatsAdmis(char* dept, char* ville) {
fclose ( fAdmis ) ;
fclose ( fAdmis ) ;
free ( liste ) ;
free ( liste ) ;
} else {
} else
fprintf ( stderr , " \n \ e[1;91mErreur : les candidatures n'ont pas encore été traitées, merci de réessayer plus tard. \n \n \ e[0m " ) ;
fprintf ( stderr , " \n \ e[1;91mErreur : les candidatures n'ont pas encore été traitées, merci de réessayer plus tard. \n \n \ e[0m " ) ;
}
}
void afficherCandidatsAttente ( FileAttente * file ) {
int i = 0 ;
Maillon * parcourir = file - > tete ;
if ( ! estVide ( file ) )
while ( parcourir ! = NULL ) {
printf ( " \ e[4;37mCandidat '%s %s' (position %d/%d) : \ e[0m "
" \n - Moyenne en mathématiques : %.2f \n - Moyenne en français : %.2f "
" \n - Moyenne en anglais : %.2f \n - Moyenne en spécialité : %.2f "
" \n - Note globale attribuée : %.2f \n \n " ,
parcourir - > candidat . nom , parcourir - > candidat . prenom , + + i , file - > nbAttente , parcourir - > candidat . moyenneMath , parcourir - > candidat . moyenneFrancais ,
parcourir - > candidat . moyenneAnglais , parcourir - > candidat . moyenneSpecialite , parcourir - > candidat . noteGlobale ) ;
parcourir = parcourir - > suivant ;
}
else
fprintf ( stderr , " \n \ e[1;91mErreur : les candidatures n'ont pas encore été traitées ou aucun candidat n'est en attente, merci de réessayer plus tard. \n \n \ e[0m " ) ;
}
}