0% found this document useful (0 votes)
21 views26 pages

Pything Final Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views26 pages

Pything Final Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Project Overview: we are trying to build a simple student profile system that can

handle basic student personal information, examination information and the ECA done by the
students. There are four txt files which the system uses

INTRODUCTION
This project automates student information which reduces manual work, and
human error. Functionality to: Add new student Update Student Details Schedule
Exam Marks for tracking ECA participation Automating these tasks improves
efficiency and makes life easier for administrators, teachers, and students.
This project uses powerful file handling features of Python to maintain your data
also provide easy access for you. Text files are used at the backend, therefore
making the system lightweight and easily deployable which still helps to serve all
functionalities needed for effective management of students. The purpose of the
system described in this article is to simplify managing information about students,
allowing you processing it faster and safer.
To summarize, this student management system project in Python acts as a
complete solution for managing the student’s data and thus helps to directly
enhance administrative efficiency of academic institutions. This lowers paperwork,
saves time and helps the field as it allows for a simple familiarization between
institutions that develop through accurate reliable records students can also be
tracked which goes to show better educational administration and service delivery.
ABOUT PYTHON
One cross-platform, versatile language that is renowned for creating a wide range
of applications is Python. Python, first created by Guido van Rossum and released
in 1991, provides programmers with simplicity and readability, making it an
excellent choice for both beginners and experts. Its continuous development,
including major updates such as Python 2.0 and Python 3.0, has brought about
enhanced features and performance improvements.
Python is one of the most popular programming languages globally, widely used in
various fields such as web development, data analysis, artificial intelligence, and
scientific computing. Python reduces development overhead by encouraging clean
and readable code through its use of an object-oriented paradigm. Its extensive
standard library and numerous third-party packages allow developers to create
robust and flexible applications with ease.
Python is particularly known for its simplicity and ease of learning, making it
accessible to newcomers while also providing advanced features for experienced
programmers. Its strong integration with other languages like C, C++, and Java
further enhances its utility, enabling smooth interoperability and extending the
programmer's capabilities.
Unlike many other languages, Python emphasizes code readability and developer
productivity, with its clean syntax and dynamic typing. This focus on simplicity
and efficiency makes Python a dominant language in contemporary software
development, where rapid prototyping and iterative development are key.
To put it simply, Python is more than just a language; it's a thriving ecosystem that
embodies the principles of software engineering, where innovation, efficiency, and
practicality converge to shape the future of technology.
ADVANTAGES OF THE PROPOSED
SYSTEM
 Better student performance by students
 Simplifying and streamlining all the activities
 Easy access to all
 Managing timetable
 keep track of the students
 Centralized database for information management
 Better student success
 Automated updates and multiple backups
 Class Scheduling
FUNCTION USED IN THE PROGRAM
Class Methods
1.buildup
@classmethod
def buildup(cls):
if not os.path.exists(cls.DATA_DIR):
os.makedirs(cls.DATA_DIR)
for file in [cls.STUDENT_FILE, cls.PASSWORD_FILE, cls.SUBJECTS_FILE,
cls.SPORTS_FILE]:
if not os.path.exists(file):
with open(file, 'w') as f:
pass
Description: This method ensures that the necessary directories and files are created if they do
not already exist.
Usage: It is used to initialize the file system required for storing student data.

2.menu
@classmethod
def menu(cls):
while True:
print("\nMain Menu")
print("---------")
print("1. Admin")
print("2. Student")
print("3. Exit")
choice = input("Choose from above: ")
if choice == "1":
cls.admin()
elif choice == "2":
cls.student()
elif choice == "3":
print("Exiting...")
break
else:
print("Invalid choice, please try again.")
Description: Displays the main menu and allows users to choose between admin, student
functionalities, or exiting the system.
Usage: It provides the entry point for the system, guiding the user to the appropriate functionality
based on their choice.

3.student
@classmethod
def student(cls):
while True:
print("\nStudent Menu")
print("------------")
print("1. Login")
print("2. Register")
print("3. Back to Main Menu")
choice = input("Choose from above: ")
if choice == "1":
cls.student_login()
elif choice == "2":
cls.student_register()
elif choice == "3":
break
else:
print("Invalid choice, please try again.")
Description: Displays the student menu and provides options for login, registration, or returning
to the main menu.
Usage: It is used to manage the interactions specific to students.

4.student_login
@classmethod
def student_login(cls):
print("\nStudent Login")
fname = input("Firstname: ")
student_id = input("ID: ")
password = input("Password: ")
if cls.verify_student_login(student_id, password):
cls.student_dashboard(fname, student_id)
else:
print("Invalid details!")
Description: Handles the student login process by verifying the provided ID and password.
Usage: It allows students to log in to the system.

5.student_register
@classmethod
def student_register(cls):
print("\nStudent Registration")
fname = input("Firstname: ")
lname = input("Lastname: ")
age = input("Age: ")
gender = input("Gender: ")
subjects = input("Subjects (comma-separated): ")
student_id = str(randint(1000000, 9000000))
password = input("Password: ")
if all([fname, lname, age, gender, subjects, password]):
with open(cls.STUDENT_FILE, "a") as f:
f.write(f"{fname},{lname},{age},{gender},{student_id}\n")
with open(cls.PASSWORD_FILE, "a") as f:
f.write(f"{student_id},{password}\n")
with open(cls.SUBJECTS_FILE, "a") as f:
f.write(f"{student_id},{subjects}\n")
print("Registration successful! Your ID is:", student_id)
else:
print("All fields are required!")

Description: Facilitates the registration of new students by collecting their details and storing
them in respective files.
Usage: It allows new students to register and get an ID for future logins.

6.verify_student_login
@classmethod
def verify_student_login(cls, student_id, password):
with open(cls.PASSWORD_FILE, "r") as f:
for line in f:
stored_id, stored_password = line.strip().split(',')
if stored_id == student_id and stored_password == password:
return True
return False

Description: Verifies the student login credentials by checking the provided ID and password
against stored data.
Usage: It is used during the login process to ensure the student provides correct credentials.

7.student_dashboard
@classmethod
def student_dashboard(cls, fname, student_id):
while True:
print("\nStudent Dashboard")
print("-----------------")
print("1. View My Details")
print("2. Add Sports Details")
print("3. Logout")
choice = input("Choose from above: ")
if choice == "1":
cls.show_student_details(student_id)
elif choice == "2":
cls.add_sports_details(student_id)
elif choice == "3":
break
else:
print("Invalid choice, please try again.")
Description: Displays the student dashboard with options to view details, add sports activities, or
logout.
Usage: It provides logged-in students with functionalities specific to their accounts.

8.show_student_details
@classmethod
def show_student_details(cls, student_id):
found = False
with open(cls.STUDENT_FILE, "r") as f:
for line in f:
details = line.strip().split(',')
if details[4] == student_id:
print(f"\nFirstname: {details[0]}\nLastname: {details[1]}\nAge: {details[2]}\
nGender: {details[3]}\nID: {details[4]}")
found = True
break
if not found:
print("Student could not be found!")
print("\nSubjects:")
with open(cls.SUBJECTS_FILE, "r") as f:
for line in f:
if line.startswith(student_id):
print(line.strip().split(',', 1)[1])
print("\nSports:")
with open(cls.SPORTS_FILE, "r") as f:
for line in f:
if line.startswith(student_id):
print(line.strip().split(',', 1)[1])
Description: Displays the details of a specific student, including their personal information,
subjects, and sports activities.
Usage: It allows students to view their stored details.

9.add_sports_details
@classmethod
def add_sports_details(cls, student_id):
sports = input("Enter sports and time (e.g., Football 3-4 PM): ")
with open(cls.SPORTS_FILE, "a") as f:
f.write(f"{student_id},{sports}\n")
print("Sports details added!")
Description: Allows students to add sports activities and their timings to their records.
Usage: It enables students to update their sports activities.

10.admin
@classmethod
def admin(cls):
print("\nAdmin Login")
username = input("Username: ")
password = input("Password: ")
if username == "Sujal" and password == "********":
cls.admin_dashboard()
else:
print("Invalid admin details!")
Description: Handles admin login by verifying hardcoded credentials.
Usage: It allows the admin to log in to the system.

11.admin_dashboard
@classmethod
def admin_dashboard(cls):
while True:
print("\nAdmin Dashboard")
print("----------------")
print("1. View All Students")
print("2. Add New Student")
print("3. Delete Student")
print("4. Logout")
choice = input("Choose from above: ")
if choice == "1":
cls.view_all_students()
elif choice == "2":
cls.add_new_student()
elif choice == "3":
cls.delete_student()
elif choice == "4":
break
else:
print("Invalid choice, please try again.")
Description: Provides a dashboard for admin functionalities such as viewing all students, adding
new students, deleting students, and logging out.
Usage: It allows the admin to manage the student records.

12.view_all_students
@classmethod
def view_all_students(cls):
print("\nAll Students:")
with open(cls.STUDENT_FILE, "r") as f:
for line in f:
print(line.strip())
print("\nSubjects:")
with open(cls.SUBJECTS_FILE, "r") as f:
for line in f:
print(line.strip())
print("\nSports:")
with open(cls.SPORTS_FILE, "r") as f:
for line in f:
print(line.strip())

Description: Displays all stored student details, including subjects and sports activities.
Usage: It allows the admin to view a comprehensive list of all students and their activities.

13.update_file
@classmethod
def _update_file(cls, file_path, student_id, exclude=False):
with open(file_path, "r") as f:
lines = f.readlines()
with open(file_path, "w") as f:
for line in lines:
if exclude:
if not line.startswith(student_id):
f.write(line)
else:
f.write(line)
Description: This is a helper method used internally to update files. It reads all lines from a
specified `file_path`, then rewrites the file content based on conditions:
- If `exclude` is `True`, it excludes lines that start with the provided `student_id`.
- If `exclude` is `False`, it writes all lines back to the file unchanged.
Usage: The method is used by other methods such as `delete_student` to update data files (like
`STUDENT_FILE`, `PASSWORD_FILE`, `SUBJECTS_FILE`, and `SPORTS_FILE`) when
adding or deleting student records.

This function is crucial for maintaining the integrity of student data by allowing selective updates
or deletions based on specific conditions passed from other parts of the system.

14.add_new_student
@classmethod
def add_new_student(cls):
cls.student_register()

Description: Calls the `student_register` method to add a new student to the system.
Usage: It provides a straightforward way for the admin to register new students.

15.delete_student
@classmethod
def delete_student(cls):
student_id = input("Enter the ID of the student to delete: ")
cls._update_file(cls.STUDENT_FILE, student_id, exclude=True)
cls._update_file(cls.PASSWORD_FILE, student_id, exclude=True)
cls._update_file(cls.SUBJECTS_FILE, student_id, exclude=True)
cls._update_file(cls.SPORTS_FILE, student_id, exclude=True)
print("Deleting student account...")
time.sleep(2)
print("Student account deleted successfully!")
Description: Deletes a student from all relevant files by their ID.
Usage: It allows the admin to remove a student's entire record from the system.

16.update_file
@classmethod
def _update_file(cls, file_path, student_id, exclude=False):
with open(file_path, "r") as f:
lines = f.readlines()
with open(file_path, "w") as f:
for line in lines:
if exclude:
if not line.startswith(student_id):
f.write(line)
else:
f.write(line)
Description: Updates a file by either excluding or including lines based on the provided
student ID.
Usage: This is a helper method used internally to manage file updates when adding or deleting
students.

Initialization and Menu Call

To properly initialize and run the student management system, ensure we call the following
methods correctly:
# Initialize the directories and files
StudentManagementSystem.buildup()
# Display the main menu to start interacting with the system
StudentManagementSystem.menu()

These functions collectively provide a structured way to manage student data, handle user
interactions, and perform administrative tasks within the system.

CLASSES
In the System, there are no external classes being imported or utilized beyond the standard
Python libraries (`os`, `time`, and `random`). However, within the code itself, there is the
definition of the `StudentManagementSystem` class, which encapsulates the entire student
management system.

`StudentManagementSystem` Class

Description:
The `StudentManagementSystem` class is designed to manage student data and interactions
within a school or educational institution. It includes functionalities for both students and
administrators (admins), allowing students to log in, register, view their details, and manage
sports activities. Admins can view all students, add new students, delete students, and manage
overall student records.

Usage:
1.Data Management:
- It uses files (`students.txt`, `passwords.txt`, `subjects.txt`, `sports.txt`) to store and manage
student information, passwords, subjects enrolled, and sports activities.

2.User Interactions:
- Provides menus (`menu`, `student`, `admin`) for users to navigate through different
functionalities based on their roles (student or admin).

3.Authentication:
- Manages student login and registration processes (`student_login`, `student_register`) with
password verification and ID generation.

4.Admin Functions:
- Allows admins to perform CRUD operations on student records (`add_new_student`,
`delete_student`, `view_all_students`).

5.Dashboard:
- Provides a dashboard (`student_dashboard`) for students to view their personal details and
manage sports activities.

Why it is Used:
Organization: It organizes functionalities related to student management into a structured class,
facilitating easier maintenance and scalability of the system.

Security: The system uses password-protected logins and file-based data storage to maintain
privacy and security of student information.

Usability: Provides an intuitive interface through menus and dashboards for both students and
admins to interact with the system efficiently.

By encapsulating these functionalities within a class, the code promotes modularity, reusability,
and maintainability, making it easier to extend or modify features as needed in a real-world
student management application.
OBJECT
In the System, there are no explicit instances of custom objects (besides strings and integers)
being instantiated or used directly as objects in the object-oriented programming sense (e.g., no
instances of custom classes or objects defined by the user).

Objects in Python

In Python, everything is an object, including basic types like integers, strings, lists, etc. When we
talk about objects in the context of classes and instances:

1.Class Definition:
The `StudentManagementSystem` class itself is a class definition. It defines the structure and
behavior of the student management system, encapsulating methods and data related to student
registration, login, admin functions, file operations, etc.

2.Instances of Built-in Types:


hroughout the code, there are instances of built-in types like strings (`fname`, `lname`, `age`,
`gender`, `subjects`, `password`) and integers (`student_id`) that are used to store and manipulate
data related to student information.

3.File Objects:
The code uses file objects (`open(...)`) to read from and write to files (`students.txt`,
`passwords.txt`, `subjects.txt`, `sports.txt`). These file objects are created and manipulated within
the context of reading and writing student data.

Why Objects Are Used:

Encapsulation: Objects (like the `StudentManagementSystem` class) encapsulate related


functionalities and data, promoting modular and organized code.

Abstraction: They allow complex systems (like managing student data and interactions) to be
abstracted into manageable components, improving code readability and maintenance.

Reusability: By defining classes and objects, code can be reused across different parts of the
application or in future projects, enhancing development efficiency.

While the code doesn't explicitly create instances of custom classes beyond the main
`StudentManagementSystem` class, understanding objects in Python helps in grasping how data
and functionalities are organized and utilized within the provided code structure.
CONCEPT OF OOP
Object-Oriented Programming (OOP) concepts used in the `StudentManagementSystem` code
snippet, detailing where they are used, how they are used, and why they are used:

1.Class Definition

Where it is used:
The entire functionality of managing student data and interactions is encapsulated within the
`StudentManagementSystem` class.

How it is used:
The class definition (`class StudentManagementSystem:`) provides a blueprint for creating
instances that manage student records, interactions, and administrative tasks.
Methods within the class (`classmethod` decorated functions) define specific operations such as
student login, registration, admin tasks, file management, and data display.

Why it is used:
Encapsulation: It encapsulates related functionalities (like student registration, login, admin
tasks) into a single unit, improving code organization and readability.
Modularity: By organizing functionalities into methods, it promotes reusability and allows easier
maintenance and scalability of the system.
Abstraction: Users interact with high-level methods (`menu`, `student`, `admin`) without needing
to understand the internal details of how student data is stored or managed.

2.Encapsulation

Where it is used:
Encapsulation is achieved through method definitions (`@classmethod` functions) within the
`StudentManagementSystem` class.

How it is used:
Methods encapsulate related operations such as student login (`student_login`), registration
(`student_register`), admin tasks (`admin_dashboard`), file handling (`_update_file`), etc.
Data attributes (`DATA_DIR`, `STUDENT_FILE`, etc.) are encapsulated within class variables
to manage file paths and directories.

Why it is used:
Information Hiding: Encapsulation hides the internal implementation details of how student data
is managed (e.g., file handling, data storage formats) from external users or classes, promoting
security and reducing complexity.
Modularity and Reusability: By encapsulating related operations into methods, it facilitates code
reuse, enhances maintainability, and allows for easy updates or extensions of functionality.

3.Abstraction

Where it is used:
Abstraction is evident in how high-level methods (`menu`, `student`, `admin`, etc.) provide
simplified interfaces for users to interact with the system.

How it is used:
Users interact with the system through abstracted methods that handle complex operations
internally (e.g., reading/writing files, validating user credentials).
Details of file handling (`open`, `write`, `read`) are abstracted within methods like `_update_file`
to manage student records without exposing low-level implementation details.

Why it is used:
Simplification: Abstraction simplifies user interactions by providing intuitive interfaces (menus,
dashboards) while managing intricate operations (data validation, file I/O) behind the scenes.
Flexibility: It allows the system to evolve by modifying internal implementations (e.g., switching
file storage to databases) without impacting how users interact with the system.

Conclusion
The use of these OOP concepts in the `StudentManagementSystem` code snippet demonstrates a
structured approach to managing student data and interactions. By leveraging class definitions,
encapsulation, and abstraction, the code achieves modularity, reusability, and maintainability,
crucial for developing scalable and robust software systems. These concepts collectively
contribute to organizing complex functionality into manageable units, enhancing code structure,
and facilitating effective system management.

ERROR HANDLING
 Where: Wrap critical sections of code (like main operations in methods) with try-
except blocks to catch unexpected exceptions and handle them gracefully.
 How: Use try-except blocks around code sections where errors might occur. Log
errors or provide meaningful error messages to assist in debugging.
 Why: Prevents unhandled exceptions from crashing the program, improving stability and
allowing for easier diagnosis of issues during development or runtime.
FILE OPERATIONS
2. File Operations
 Where: Methods that read from or write to files (_update_file, file reading methods)
should handle file I/O errors.
 How: Use try-except blocks to catch specific exceptions (FileNotFoundError,
IOError) when accessing files. Optionally, use os.path.exists to check file existence
before operations.
 Why: Ensures the program gracefully handles file-related issues, such as missing files or
permissions errors, preventing crashes and providing informative error messages.

FILE HANDLING
In the `StudentManagementSystem` code, file handling is extensively used to store and retrieve
student data, passwords, subjects, and sports details. Here's a breakdown of how file handling is
employed, along with descriptions of each usage:

1.File Paths Setup:

DATA_DIR = "student_data"
STUDENT_FILE = os.path.join(DATA_DIR, "students.txt")
PASSWORD_FILE = os.path.join(DATA_DIR, "passwords.txt")
SUBJECTS_FILE = os.path.join(DATA_DIR, "subjects.txt")
SPORTS_FILE = os.path.join(DATA_DIR, "sports.txt")
Description: Defines file paths where student data will be stored (`students.txt`), passwords
(`passwords.txt`), subjects (`subjects.txt`), and sports details (`sports.txt`).
Usage: Paths are used throughout the code to read from and write to these specific files.

2.Building Up Directories and Files:

@classmethod
def buildup(cls):
if not os.path.exists(cls.DATA_DIR):
os.makedirs(cls.DATA_DIR)
for file in [cls.STUDENT_FILE, cls.PASSWORD_FILE, cls.SUBJECTS_FILE,
cls.SPORTS_FILE]:
if not os.path.exists(file):
with open(file, 'w') as f:
pass
Description: Ensures that the directory (`student_data`) and necessary files (`students.txt`,
`passwords.txt`, `subjects.txt`, `sports.txt`) exist. If they don't, they are created.
Usage: Called at the start (`StudentManagementSystem.buildup()`) to initialize the system with
necessary directories and files.
3.Reading and Writing Student Details:

@classmethod
def student_register(cls):
with open(cls.STUDENT_FILE, "a") as f:
f.write(f"{fname},{lname},{age},{gender},{student_id}\n")
with open(cls.PASSWORD_FILE, "a") as f:
f.write(f"{student_id},{password}\n")
with open(cls.SUBJECTS_FILE, "a") as f:
f.write(f"{student_id},{subjects}\n")
Description: Writes student registration details (first name, last name, age, gender, ID) to their
respective files (`students.txt`, `passwords.txt`, `subjects.txt`).
Usage: Stores new student information during registration (`student_register` method).

4.Verification of Student Login:

@classmethod
def verify_student_login(cls, student_id, password):
with open(cls.PASSWORD_FILE, "r") as f:
for line in f:
stored_id, stored_password = line.strip().split(',')
if stored_id == student_id and stored_password == password:
return True
return False
Description: Reads `passwords.txt` to verify student login credentials based on ID and
password.
Usage: Used in `student_login` method to authenticate student login attempts.

5.Updating Files (Deleting Student Records):

@classmethod
def delete_student(cls):
student_id = input("Enter the ID of the student to delete: ")
cls._update_file(cls.STUDENT_FILE, student_id, exclude=True)
cls._update_file(cls.PASSWORD_FILE, student_id, exclude=True)
cls._update_file(cls.SUBJECTS_FILE, student_id, exclude=True)
cls._update_file(cls.SPORTS_FILE, student_id, exclude=True)

Description: Removes student records from all files (`students.txt`, `passwords.txt`,


`subjects.txt`, `sports.txt`) based on student ID.
Usage: Invoked when an admin deletes a student (`delete_student` method).

6.Reading and Displaying All Student Details:

@classmethod
def view_all_students(cls):
print("\nAll Students:")
with open(cls.STUDENT_FILE, "r") as f:
for line in f:
print(line.strip())
print("\nSubjects:")
with open(cls.SUBJECTS_FILE, "r") as f:
for line in f:
print(line.strip())
print("\nSports:")
with open(cls.SPORTS_FILE, "r") as f:
for line in f:
print(line.strip())

Description: Reads and prints all student details (from `students.txt`), subjects (from
`subjects.txt`), and sports details (from `sports.txt`).
Usage: Used in admin dashboard (`view_all_students` method) to display comprehensive student
information.

7.Internal File Management Helper:

@classmethod
def _update_file(cls, file_path, student_id, exclude=False):
with open(file_path, "r") as f:
lines = f.readlines()
with open(file_path, "w") as f:
for line in lines:
if exclude:
if not line.startswith(student_id):
f.write(line)
else:
f.write(line)

Description: Helper method to update (`write` or `exclude`) lines in a file based on conditions.
Usage: Utilized internally to manage file updates when adding new students
(`add_new_student`), deleting students (`delete_student`), or specific operations.

Summary
File handling in the `StudentManagementSystem` is crucial for persistent storage and retrieval of
student information across various aspects of the system. It ensures data integrity, facilitates user
interactions (registration, login, deletion), and supports administrative tasks (viewing all
students). Proper file management enhances system reliability and functionality, providing a
structured approach to data management within the application.

ALGORITHM OF THE PROGRAM


Initialization and Setup

1.Imports: Import necessary modules (`os`, `time`, and `randint` from `random`).
2.Class Definition: Define `StudentManagementSystem` class to encapsulate all functionalities.
3.File Paths: Define class variables for file paths (`STUDENT_FILE`, `PASSWORD_FILE`,
`SUBJECTS_FILE`, `SPORTS_FILE`).
Class Methods
`buildup()`
Purpose: Initialize the data directory and necessary files if they do not exist.
Steps:
- Check if `DATA_DIR` exists; if not, create it.
- Create each required file (`STUDENT_FILE`, `PASSWORD_FILE`, `SUBJECTS_FILE`,
`SPORTS_FILE`) if they do not exist.

`menu()`

Purpose: Display the main menu and handle user input for navigating between Admin and
Student options.
Steps:
- Display options (Admin, Student, Exit).
- Based on user input, call `admin()`, `student()`, or exit the program.

`student()`

Purpose: Display the student menu and handle user input for login, registration, or returning to
the main menu.
- **Steps**:
- Display options (Login, Register, Back to Main Menu).
- Based on user input, call `student_login()`, `student_register()`, or return to the main menu.

`student_login()`

Purpose: Handle student login by verifying credentials against `PASSWORD_FILE`.


Steps:
- Prompt for student's first name, ID, and password.
- Verify credentials using `verify_student_login()`.
- If valid, display student dashboard (`student_dashboard()`); otherwise, show an error
message.

`student_register()`

Purpose: Handle student registration by collecting details and saving them to respective files.
Steps:
- Prompt for student details (first name, last name, age, gender, subjects, password).
- Generate a random student ID.
- Validate input, then append details to `STUDENT_FILE`, `PASSWORD_FILE`, and
`SUBJECTS_FILE`.
`verify_student_login(student_id, password)`

Purpose: Verify student login credentials against stored passwords in `PASSWORD_FILE`.


Steps:
- Read `PASSWORD_FILE` line by line.
- Split each line to retrieve stored ID and password.
- Check if provided credentials match any stored credentials.

`student_dashboard(fname, student_id)`

Purpose: Display student dashboard with options to view details, add sports details, or logout.
Steps:
- Display options (View Details, Add Sports Details, Logout).
- Based on user input, call `show_student_details()`, `add_sports_details()`, or return to student
menu.

`show_student_details(student_id)`

Purpose: Display student's details including subjects and sports from respective files.
Steps:
- Search for student details in `STUDENT_FILE` using `student_id`.
- Display personal details, subjects, and sports using data from `SUBJECTS_FILE` and
`SPORTS_FILE`.

`add_sports_details(student_id)`

Purpose: Allow students to add sports details.


Steps:
- Prompt for sports details and time.
- Append details to `SPORTS_FILE` with associated `student_id`.

`admin()`

Purpose: Handle admin login by verifying credentials.


Steps**:
- Prompt for admin username and password.
- If credentials match predefined values, display admin dashboard (`admin_dashboard()`);
otherwise, show an error.

`admin_dashboard()`

Purpose: Display admin dashboard with options to view all students, add new student, delete
student, or logout.
Steps:
- Display options (View All Students, Add New Student, Delete Student, Logout).
- Based on user input, call `view_all_students()`, `add_new_student()`, `delete_student()`, or
return to main menu.

`view_all_students()`

Purpose: Display details of all students including subjects and sports from respective files.
Steps:
- Read and display contents of `STUDENT_FILE`, `SUBJECTS_FILE`, and `SPORTS_FILE`.

`add_new_student()`
Purpose: Add a new student using the registration method (`student_register()`).

`delete_student()`

Purpose: Delete a student by removing their details from all associated files.
Steps:
- Prompt for student ID to delete.
- Remove student details from `STUDENT_FILE`, `PASSWORD_FILE`, `SUBJECTS_FILE`,
and `SPORTS_FILE`.

`_update_file(file_path, student_id, exclude=False)`

Purpose: Utility method to update a file by including or excluding lines based on `exclude` flag.
Steps:
- Read lines from `file_path`.
- Write lines back to `file_path`, excluding lines starting with `student_id` if `exclude=True`.

Execution
- Initialize directories and files using `buildup()`.
- Display the main menu using `menu()`.

CODE

You might also like