Skip to content
Extraits de code Groupes Projets
Valider 1d5d704e rédigé par Adrien Payen's avatar Adrien Payen
Parcourir les fichiers

hi

parent b96b13d3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Aucun aperçu pour ce type de fichier
Aucun aperçu pour ce type de fichier
Fichier supprimé
...@@ -36,7 +36,7 @@ email_pattern = re.compile(r'^[a-zA-Z0-9._%+-]+@student\.uclouvain\.be$') ...@@ -36,7 +36,7 @@ email_pattern = re.compile(r'^[a-zA-Z0-9._%+-]+@student\.uclouvain\.be$')
gender_pattern = re.compile(r'^[MFO]$') gender_pattern = re.compile(r'^[MFO]$')
academic_year_pattern = re.compile(r'^(BAC[123]|MA[12])$') academic_year_pattern = re.compile(r'^(BAC[123]|MA[12])$')
campus_pattern = re.compile(r'^(Louvain-la-Neuve|Mons)$', re.IGNORECASE) campus_pattern = re.compile(r'^(Louvain-la-Neuve|Mons)$', re.IGNORECASE)
curriculum_pattern = re.compile(r'^(INGM1BA|INGM2M)$', re.IGNORECASE)
# REGISTER # REGISTER
def register_student(data): def register_student(data):
...@@ -113,6 +113,11 @@ def register_student(data): ...@@ -113,6 +113,11 @@ def register_student(data):
break # Exit the loop if the academic year is valid break # Exit the loop if the academic year is valid
else: else:
print("The academic year is not valid. Make sure to follow the requested format.") print("The academic year is not valid. Make sure to follow the requested format.")
if Academic_year in ['BAC1', 'BAC2', 'BAC3'] :
Curriculum = "INGM1BA"
else :
Curriculum = "INGM2M"
Courses_and_grade = {} Courses_and_grade = {}
if Academic_year == 'MA2': if Academic_year == 'MA2':
...@@ -159,15 +164,16 @@ def register_student(data): ...@@ -159,15 +164,16 @@ def register_student(data):
else: else:
print("The campus choice is not valid. Make sure to follow the requested format.") print("The campus choice is not valid. Make sure to follow the requested format.")
register(data, Firstname, Lastname, Date_of_birth, Place_of_birth, Address, Telephone, Email, Gender, Academic_year, Courses_and_grade, Campus) register(data, Firstname, Lastname, Curriculum, Date_of_birth, Place_of_birth, Address, Telephone, Email, Gender, Academic_year, Courses_and_grade, Campus)
def register(data, firstname, lastname, date_of_birth, place_of_birth, address, telephone, email, gender, academic_year, courses_and_grade, campus): def register(data, firstname, lastname,Curriculum, date_of_birth, place_of_birth, address, telephone, email, gender, academic_year, courses_and_grade, campus):
matricule = generate_matricule(firstname, lastname, date_of_birth) matricule = generate_matricule(firstname, lastname, date_of_birth)
student = { student = {
"Name": firstname, "Name": firstname,
"Surname": lastname, "Surname": lastname,
"Curriculum":Curriculum,
"Date of Birth": date_of_birth, "Date of Birth": date_of_birth,
"Place of Birth": place_of_birth, "Place of Birth": place_of_birth,
"Address": address, "Address": address,
...@@ -320,13 +326,45 @@ def modify(data): ...@@ -320,13 +326,45 @@ def modify(data):
print("The gender is not valid. Make sure to follow the requested format.") print("The gender is not valid. Make sure to follow the requested format.")
elif field_to_modify == 9: elif field_to_modify == 9:
while True: while True:
academic_year = input("What is your academic year? (BAC1/BAC2/BAC3/MA1/MA2): ") academic_year = input("What is your academic year? (BAC1/BAC2/BAC3/MA1/MA2): ")
if academic_year_pattern.match(academic_year):
print(f"The academic year is valid : {academic_year}") if academic_year_pattern.match(academic_year):
data.at[student_index, 'Academic Year'] = academic_year print(f"The academic year is valid: {academic_year}")
break # Exit the loop if the academic year is valid
if academic_year in ['BAC1', 'BAC2', 'BAC3']:
curriculum = "INGM1BA"
elif academic_year in ['MA1', 'MA2']:
curriculum = "INGM2M"
else:
print("Invalid academic year for curriculum assignment.")
continue
data.at[student_index, 'Academic Year'] = academic_year
data.at[student_index, 'Curriculum'] = curriculum
break # Exit the loop if the academic year is valid
else:
print("The academic year is not valid. Make sure to follow the requested format.")
elif field_to_modify == 10:
while True:
curriculum = input("What is your curriculum? (INGM1BA/INGM2M): ")
if curriculum_pattern.match(curriculum):
if curriculum == 'INGM1BA':
valid_academic_years = ['BAC1', 'BAC2', 'BAC3']
elif curriculum == 'INGM2M':
valid_academic_years = ['MA1', 'MA2']
academic_year = input(f"What is your academic year? ({'/'.join(valid_academic_years)}): ")
if academic_year in valid_academic_years and academic_year_pattern.match(academic_year):
print(f"The academic year for {curriculum} is valid: {academic_year}")
data.at[student_index, 'Academic Year'] = academic_year
data.at[student_index, 'Curriculum'] = curriculum
break # Exit the loop if both curriculum and academic year are valid
else:
print("Invalid academic year for the selected curriculum. Make sure to follow the requested format.")
else: else:
print("The academic year is not valid. Make sure to follow the requested format.") print("Invalid curriculum. Make sure to follow the requested format.")
elif field_to_modify == 11: # Courses and grades elif field_to_modify == 11: # Courses and grades
print("Courses already passed and their grade:\n") print("Courses already passed and their grade:\n")
for course, grade in data.iloc[student_index].items(): for course, grade in data.iloc[student_index].items():
...@@ -384,6 +422,7 @@ field_mapping = { ...@@ -384,6 +422,7 @@ field_mapping = {
8: 'Gender', 8: 'Gender',
9: 'Academic Year', 9: 'Academic Year',
10: 'Curriculum', 10: 'Curriculum',
11: 'Courses and Grades',
12: 'Campus' 12: 'Campus'
} }
......
...@@ -103,6 +103,12 @@ for each in range(number_of_students): # générer des données ...@@ -103,6 +103,12 @@ for each in range(number_of_students): # générer des données
# année de cours # année de cours
academic_year = random.choice(school_years) academic_year = random.choice(school_years)
# curriculum
if academic_year in ['BAC1', 'BAC2', 'BAC3'] :
curriculum = "INGM1BA"
else :
curriculum = "INGM2M"
# ville de naissance de la personne # ville de naissance de la personne
city_of_birth = random.choice(place_of_birth) city_of_birth = random.choice(place_of_birth)
...@@ -184,7 +190,7 @@ for each in range(number_of_students): # générer des données ...@@ -184,7 +190,7 @@ for each in range(number_of_students): # générer des données
grades[courses] = random.randint(0, 20) grades[courses] = random.randint(0, 20)
data_generated.append({"Firstname": last_name, "Lastname": first_name, "Academic Year" : academic_year, "Place of Birth" : city_of_birth , "Telephone": phone, "Address": adress_of_student, "Genre" : gender_of_student, "Email" : email_formated, "Campus" : campus, "Date of Birth" : complete_date_of_birth, "Matricule" : matricule, **grades}) data_generated.append({"Firstname": last_name, "Lastname": first_name, "Academic Year" : academic_year, "Curriculum" : curriculum, "Place of Birth" : city_of_birth , "Telephone": phone, "Address": adress_of_student, "Genre" : gender_of_student, "Email" : email_formated, "Campus" : campus, "Date of Birth" : complete_date_of_birth, "Matricule" : matricule, **grades})
# génération de données qui ne peuvent pas se ressembler # génération de données qui ne peuvent pas se ressembler
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter