diff --git a/.DS_Store b/.DS_Store index bae10ddde33593a43695304e7070e8f53ccd0eca..037352eb3c96f3e092083529fd07e9ce531b0c8c 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Adrien Payen_statistics.xlsx b/Adrien Payen_statistics.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..a1f752b154bcd6908d51748127d31b5f3f2a7121 Binary files /dev/null and b/Adrien Payen_statistics.xlsx differ diff --git a/Aubree Coleman_statistics.xlsx b/Aubree Coleman_statistics.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..3fbcb6617a7cbfae85a41cbe295aa31ab8e7bc8e Binary files /dev/null and b/Aubree Coleman_statistics.xlsx differ diff --git a/Cooper Lopez_statistics.xlsx b/Cooper Lopez_statistics.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..720b644c99765c7763b608ac59a0cdbe19c4010b Binary files /dev/null and b/Cooper Lopez_statistics.xlsx differ diff --git a/Data_Base.xlsx b/Data_Base.xlsx index ff3609863d3bf4498232613c4b243f066019e719..3677033dede2ed7e49e7e0637ebd4ebae7d378ca 100644 Binary files a/Data_Base.xlsx and b/Data_Base.xlsx differ diff --git a/overall_statistics.xlsx b/overall_statistics.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..a1f752b154bcd6908d51748127d31b5f3f2a7121 Binary files /dev/null and b/overall_statistics.xlsx differ diff --git a/projet_personnel/algorithme_gestion_etudiants.py b/projet_personnel/algorithme_gestion_etudiants.py index bba2dfb4ebc96ebfea2b54dc684fd43a70222696..693394b5111e4d11ab2d75e202dadf5ec194970f 100644 --- a/projet_personnel/algorithme_gestion_etudiants.py +++ b/projet_personnel/algorithme_gestion_etudiants.py @@ -39,6 +39,10 @@ academic_year_pattern = re.compile(r'^(BAC[123]|MA[12])$') campus_pattern = re.compile(r'^(Louvain-la-Neuve|Mons)$', re.IGNORECASE) curriculum_pattern = re.compile(r'^(INGM1BA|INGM2M)$', re.IGNORECASE) + +def reload_data(file_path): + return pd.read_excel(file_path) + # REGISTER def register_student(data): # Setting up the patterns to follow for entering information @@ -186,6 +190,7 @@ def register_student(data): # Ask the user if they want to modify any information before registration modify_info = input("Do you want to modify any information before registration? (YES/NO): ").upper() if modify_info == "YES": + data = reload_data(file_path) modify(data) # Call the modify function to update information break # Exit the loop after modification elif modify_info == "NO": @@ -193,15 +198,7 @@ def register_student(data): else: print("Invalid input. Please enter either 'YES' or 'NO'.") - return - -""" -def reload_data(file_path): - pd.read_excel(file_path) - return""" - -# faire la fonction qui permet de faire un reload des données !!!! - + return @@ -231,9 +228,11 @@ def register(data, firstname, lastname, Curriculum, date_of_birth, place_of_birt data.to_excel(file_path, index=False) + data = reload_data(file_path) + print('The person has been registered.\n') - return + return data def generate_matricule(firstname, lastname, date_of_birth): consonant_of_firstname = ''.join([c for c in firstname if c.lower() not in 'aeiou'])[:3] @@ -267,6 +266,13 @@ def modify(data): if confirmation == "YES": student_index = student_row.index[0] + print("\nDetails of the student before modification:") + for col in ['Matricule', 'Firstname', 'Lastname', 'Date of Birth', 'Place of Birth', 'Address', 'Telephone', 'Email', 'Gender', 'Academic Year', 'Curriculum', 'Campus']: + print(f"{col}: {data.at[student_index, col]}") + for course, grade in data.iloc[student_index].items(): + if course not in field_mapping.values(): + print(f"{course}: {grade}") + print(f"\nModifying the student with matricule {matricule_to_modify}:\n") print("1. Firstname") print("2. Lastname") @@ -286,6 +292,8 @@ def modify(data): field_name_to_modify = field_mapping.get(field_to_modify, None) print(f"You are modifying the field: {field_name_to_modify}") + matricule = None + if field_to_modify == 1: # If the field to modify is the name (Name) while True: firstname = input("What is the name you want to modify? ") @@ -440,7 +448,8 @@ def modify(data): print("Modification canceled.") break # Exit the loop if modification is canceled - data.at[student_index, 'Matricule'] = matricule # Update the Matricule column with the new matricule + if matricule is not None: + data.at[student_index, 'Matricule'] = matricule # Update the Matricule column with the new matricule print("Be careful because of a modification the registration number has changed :") @@ -448,6 +457,7 @@ def modify(data): # Save the modified data to the Excel file data.to_excel(file_path, index=False) + data = reload_data(file_path) print("Modification successfully done.") # Mapping for field names to DataFrame column names @@ -714,7 +724,7 @@ def sort_master(data): def export_option(data): export = input("Do you want to export in a file? (YES/NO) ").upper() if export == "YES": - filename = input("Enter the filename: ") + filename = input("Enter the filename without .xlsx : ") filename = filename + '.xlsx' export_data_to_excel(data, filename) @@ -738,9 +748,9 @@ def see_the_data(data, columns_to_show=None): def statistics_analysis(data): print_menu([ - "Get basic statistics", - "Get all student grades", - "Get all grades for a course", + "Get basic statistics of a student", + "Get all grades of a student", + "Get all grades of a course", ]) stats_choice = get_valid_input("Enter the number of what you want to do: ", 1, 3) @@ -830,7 +840,7 @@ def display_student_grades(results): for index, row in results.iterrows(): student_name = f"{row['Firstname']} {row['Lastname']}" print(f"\nGrades for student {student_name}:") - table = [[column, grade] for column, grade in row.iteritems() if pd.notnull(grade)] + table = [[column, grade] for column, grade in row.items() if pd.notna(grade) and column not in ['Firstname', 'Lastname', 'Academic Year', 'Curriculum', 'Place of Birth', 'Telephone', 'Address', 'Gender', 'Email', 'Campus', 'Date of Birth', 'Matricule']] print(tabulate(table, headers=["Course", "Grade"], tablefmt="pretty")) export_choice = input("Do you want to export these statistics? (YES/NO): ").upper() if export_choice == 'YES': @@ -838,7 +848,8 @@ def display_student_grades(results): def course_grades(data): print("Here is the list of courses:") - print(data.select_dtypes(include=['number']).columns) + for course in data.columns[13:]: + print(f"- {course}") course_name = input("For which course do you want to display grades? ") @@ -870,12 +881,6 @@ def display_course_grades(students_in_course, course_name): def export_stats(data): # Ensure numeric columns only numeric_columns = data.select_dtypes(include=['number']).columns - - # Calculate overall statistics - overall_stats = calculate_overall_stats(data, numeric_columns) - - # Save overall statistics to Excel - overall_stats.to_excel("overall_statistics.xlsx", index=False) # Calculate and save statistics for each student for index, row in data.iterrows(): @@ -885,18 +890,7 @@ def export_stats(data): print("Statistics exported successfully.") -def calculate_overall_stats(data, numeric_columns): - all_grades = [row[column] for column in numeric_columns for _, row in data.iterrows() if not pd.isnull(row[column])] - - overall_stats = { - "Lowest grade": min(all_grades), - "Highest grade": max(all_grades), - "Average grade": statistics.mean(all_grades), - "Median grade": statistics.median(all_grades), - "Standard deviation of grades": statistics.stdev(all_grades) - } - return pd.DataFrame(list(overall_stats.items()), columns=["Metric", "Value"]) def calculate_student_stats(row, numeric_columns): student_grades = [row[column] for column in numeric_columns if not pd.isnull(row[column])] @@ -919,7 +913,7 @@ def calculate_student_stats(row, numeric_columns): # Action -def action(): +def action(data): print("What do you want to do?\nBelow, you will find what is possible followed by the commands to type.") print("1. Register a student") print("2. Modify one or more fields") @@ -960,11 +954,13 @@ def action(): menu = [] while True: - response = action() + data = reload_data(file_path) + response = action(data) if response is False: break else: - if response == True: + if response: + # Reload the menu if the file was modified menu = [] else: menu.append(response)