0% found this document useful (0 votes)
9 views10 pages

pawan 2

Uploaded by

nagarkrishh54
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)
9 views10 pages

pawan 2

Uploaded by

nagarkrishh54
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/ 10

Index:

1. Introduction
2. Project Requirements
o Hardware Requirements
o Software Requirements
3. System Design
o Flowchart
o Data Flow Diagram (DFD)
o Entity Relationship Diagram (ERD)
4. Modules and Features
o Admin/Teacher Login
o Student Management
o Attendance Management
o Attendance Reports
5. Database Design
o Tables and Structure
6. Technology Stack
o Python
o MySQL/SQLite
7. Step-by-Step Implementation
o Setting up the Database
o Coding the Application
8. Testing
9. Conclusion

1. Introduction

The Attendance Management System helps automate the attendance-taking process. It stores data
about students, tracks their attendance for each subject, and generates reports for teachers and
administrative staff. The system aims to save time and reduce the chances of errors that occur
when managing attendance manually.

2. Project Requirements

Hardware Requirements:

 Computer with a minimum of 2 GB RAM


 100 MB free disk space
 Internet connection (optional, if using online resources)

Software Requirements:

 Python 3.x
 MySQL or SQLite (for database management)
 Pandas (optional, for report generation)
 MySQL Workbench or any other SQL client (for database management)

3. System Design

Flowchart:

1. Start
2. Login Page:
o Teacher/Admin enters username and password.
o Verify credentials from database.
3. Main Dashboard:
o Admin can add/update student details.
o Admin can manage attendance.
o Admin can view attendance reports.
4. Attendance Management:
o Teacher selects the date and subject.
o Teacher marks attendance (Present/Absent).
5. Generate Reports:
o Attendance report for the selected student(s).
o Export reports to CSV or Excel format.
6. End

Data Flow Diagram (DFD):

 Level 0 (Context Diagram):


o Input: Teacher/Admin credentials, Attendance data (date, subject, student name,
status).
o Process: Mark attendance, Generate report.
o Output: Attendance data, Reports.
 Level 1 DFD:
o Login Module: Receives username and password, authenticates.
o Student Module: Stores student information.
o Attendance Module: Marks attendance and stores attendance records.
o Report Generation: Generates attendance reports.

Entity Relationship Diagram (ERD):

Entities involved:

 Student: student_id (PK), student_name, student_class, student_roll_number.


 Attendance: attendance_id (PK), student_id (FK), date, subject, status (Present/Absent).
 Teacher/Admin: teacher_id (PK), username, password.

Relationships:
 Student to Attendance: One student can have multiple attendance records.
 Teacher to Attendance: A teacher marks the attendance for students.

4. Modules and Features

Admin/Teacher Login

 Functionality: Secure login page for teachers or admins. Allows only authorized
personnel to access the system.
 Fields: Username, Password.

Student Management

 Functionality: Allows the admin to add, update, or delete student records.


 Fields: Student ID, Name, Class, Roll Number, Contact Information.

Attendance Management

 Functionality: Teachers can mark attendance for students for a specific day and subject.
 Fields: Student ID, Date, Subject, Status (Present/Absent).

Attendance Reports

 Functionality: Admin or teacher can generate reports to view student attendance over a
period.
 Fields: Student ID, Date Range, Subject, Attendance Status.
Sql code :
-- Create the database
CREATE DATABASE attendance_db;

-- Switch to the newly created database


USE attendance_db;

-- Create students table


CREATE TABLE students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
class VARCHAR(10),
roll_number VARCHAR(20),
contact_number VARCHAR(15)
);

-- Create attendance table


CREATE TABLE attendance (
attendance_id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
date DATE,
subject VARCHAR(50),
status VARCHAR(10),
FOREIGN KEY (student_id) REFERENCES students(student_id)
);

-- Create teachers (admin) table


CREATE TABLE teachers (
teacher_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50),
password VARCHAR(50)
);

# for mysql and python connection:

pip install mysql-connector


for python code :

import mysql.connector
from getpass import getpass
import datetime

# Connect to MySQL Database


def connect_db():
return mysql.connector.connect(host="localhost", user="root",
password="password", database="attendance_db")

# Login System
def login():
print("=== Login ===")
username = input("Enter username: ")
password = getpass("Enter password: ")

connection = connect_db()
cursor = connection.cursor()
cursor.execute("SELECT * FROM teachers WHERE username=%s AND
password=%s", (username, password))
result = cursor.fetchone()

if result:
print("\nLogin successful!\n")
return True
else:
print("\nInvalid credentials!\n")
return False

# Add new student


def add_student():
print("\n=== Add New Student ===")
name = input("Enter student name: ")
student_class = input("Enter student class: ")
roll_number = input("Enter student roll number: ")
contact_number = input("Enter contact number: ")

connection = connect_db()
cursor = connection.cursor()
cursor.execute("INSERT INTO students (name, class, roll_number,
contact_number) VALUES (%s, %s, %s, %s)",
(name, student_class, roll_number, contact_number))
connection.commit()

print(f"Student {name} added successfully!")

# View all students


def view_students():
print("\n=== All Students ===")
connection = connect_db()
cursor = connection.cursor()
cursor.execute("SELECT * FROM students")
result = cursor.fetchall()

if result:
for student in result:
print(f"ID: {student[0]}, Name: {student[1]}, Class: {student[2]}, Roll
Number: {student[3]}, Contact: {student[4]}")
else:
print("No students found.")

# Mark attendance for a class


def mark_attendance():
print("\n=== Mark Attendance ===")
student_id = int(input("Enter student ID: "))
subject = input("Enter subject: ")
status = input("Enter status (Present/Absent): ")
date = datetime.date.today()
connection = connect_db()
cursor = connection.cursor()
cursor.execute("INSERT INTO attendance (student_id, date, subject, status)
VALUES (%s, %s, %s, %s)",
(student_id, date, subject, status))
connection.commit()

print("Attendance marked successfully!")

# View attendance report


def view_report():
print("\n=== View Attendance Report ===")
student_id = int(input("Enter student ID: "))
subject = input("Enter subject: ")
start_date = input("Enter start date (YYYY-MM-DD): ")
end_date = input("Enter end date (YYYY-MM-DD): ")

connection = connect_db()
cursor = connection.cursor()
cursor.execute("""
SELECT date, subject, status FROM attendance
WHERE student_id=%s AND subject=%s AND date BETWEEN %s AND %s
""", (student_id, subject, start_date, end_date))

result = cursor.fetchall()

if result:
print("\nAttendance Report:")
for record in result:
print(f"Date: {record[0]}, Subject: {record[1]}, Status: {record[2]}")
else:
print("No records found for this student in the given date range.")

# Main menu
def main():
while True:
print("\n=== Attendance Management System ===")
print("1. Login")
print("2. Add Student")
print("3. View Students")
print("4. Mark Attendance")
print("5. View Attendance Report")
print("6. Exit")

choice = input("\nEnter your choice: ")

if choice == '1':
if login():
logged_in = True
else:
logged_in = False
elif choice == '2':
add_student()
elif choice == '3':
view_students()
elif choice == '4':
if logged_in:
mark_attendance()
else:
print("\nPlease log in first!")
elif choice == '5':
if logged_in:
view_report()
else:
print("\nPlease log in first!")
elif choice == '6':
print("Exiting the system...")
break
else:
print("\nInvalid choice. Please try again.")
# Run the program
if __name__ == "__main__":
logged_in = False
main()
Explanation of Code

1. connect_db(): This function establishes a connection to the MySQL database.


2. login(): Handles the login functionality. It checks if the provided credentials (username
and password) match any teacher/admin entry in the teachers table.
3. add_student(): Adds a new student to the students table.
4. view_students(): Displays all students stored in the students table.
5. mark_attendance(): Marks attendance for a student for a given subject on the current
date.
6. view_report(): Displays the attendance report for a student over a specified date range
and subject.
7. main(): The main menu loop where users can choose various options like login, add
students, mark attendance, view reports, etc.

You might also like