About the Project Topic
A smart attendance system automates the manual
process of taking attendance in classrooms.
Traditional methods are time-consuming and prone
to errors. This project uses QR Code technology to
create a contactless, efficient attendance system.
Key Features: Benifits
1. Students scan QR code using 1. Saves classroom time
smartphones 2. Eliminates manual errors
2. Automated attendance recording 3. Environment friendly (paperless)
3. Real-time tracking for teachers 4. Easy to implement in schools
4. Contactless and hygienic solution 5. Uses basic smartphones
5. Generates automatic reports
Structure of the System
Main Components:
Student Registration Module - To add student details
QR Code Generator - Creates daily unique QR codes
Attendance Scanner - Students scan QR code to mark
attendance
Database System - Stores all records using SQLite
Report Generator - Creates various attendance reports
Workflow:
Teacher → Generates QR Code → Displays in class
Student → Scans QR Code → Attendance Marked
System → Updates Database → Generates Reports
Systems Requirements for
using the Software
Python 3.7 version or more is used as the primary
programming language in this project due to its simplicity and
versatility. It helps in generating daily QR codes, managing
attendance data, interacting with the SQL database, and
handling date/time functions. With the help of built-in and
third-party libraries, Python efficiently automates and
controls the entire attendance marking system.
SQL (Structured Query Language) is used in this project to
store, retrieve, and manage student attendance data securely
and systematically. It helps in creating a well-structured
database where each student's daily attendance, time of scan,
and other related records are saved. Python connects to the
SQL database to insert new entries, fetch records, and ensure
that attendance tracking is accurate and organized
Required Python libraries:
import sqlite3 # For database
import qrcode # For QR generation
import datetime # For date/time
import random # For unique codes
Hardware Requirements:
Computer with Python installed
Smartphone with camera
Projector/Display screen (for showing QR code)
Basic computer lab setup
Database design:
--Students Table
CREATE TABLE students (admno INTEGER PRIMARY KEY,name TEXT NOT NULL, class
INTEGER,phone TEXT);
--Attendance Table
CREATE TABLE attendance (id INTEGER PRIMARY KEY AUTOINCREMENT, admno INTEGER,date
DATE, status TEXT,scan_time TIME);
Important Functions And File Used
Files Used:
[Link] - SQLite database file
students table - Stores student information
attendance table - Stores attendance records
Qr code image files
Important Functions
1. main_menu():This function is defined to provide a menu to the
user. The various options in the menu are:
1. Add New Student 2. Generate Today's QR Code
3. Mark Attendance 4. View Attendance Report
[Link] Report 6. Find Defaulters
0. Exit
2. add_student(): Adds new student records to [Link] admission
number, name, class, phone as input and Checks if admission number already
exists and then Inserts data into 'students' [Link] success/failure
feedback,Ensures data integrity with validation.
3.generate_qr(): Creates daily unique QR code for attendance. Generates
random security code (4 digits) and also Combines current date with random
code and Saves QR code as image file (.png format) then Displays confirmation
message with QR data to Ensures each day's QR code is different.
4. mark_attendence(): Core function is to record attendance by
Taking admission number and QR code input then Validates student
exists in database and also Prevents duplicate attendance marking by
Inserting records into 'attendance' table with [Link] then
Provides instant feedback to student.
5. check_attendance(): to Verifie if student already marked
attendance and to Prevents multiple attendance entries by returning
True/False based on existing records. It is used within
mark_attendance() for validation. Ensures data accuracy.
6. view_attendance_report(): Shows attendance for specific
date and Lists all students with attendance status and also Calculates
total present/absent days. Computes overall attendance percentage.
7. monthly_report(): Generates attendance summary for entire
month and Calculates attendance percentage per student. Shows
number of days present/absent.
8. find_defaulters(): Identifies students with attendance below
threshold (75%). Compares against minimum requirement and provides
Lists of defaulters with their percentages. Alerts teachers about poor
attendance.
9. create_tables(): to Creates necessary database tables if
they don't exist. Establishes 'students' table structure to Sets up
'attendance' table with proper [Link] primary keys and data
types.
10. get_current_date(): Returns today's date in multiple formats
and also Provides date for QR code generation. Formats date for
database storage (YYYY-MM-DD). It is Used throughout system for
date consistency. Ensures all functions use same date reference.
11. validate_qr_code():Validates scanned QR code data and to
Check if QR code matches today's generated code or not by
Comparing date portion with current date. Returns True if valid, False
if invalid. Prevents attendance fraud with old/incorrect codes
12. save_qr_image(): Saves generated QR code as image [Link]
qrcode library to create PNG [Link] file with date
(qr_DDMMYYYY.png).Stores in project directory for easy [Link] be
displayed via projector in class.
13. initialize_system(): It is a system startup function. It Creates
database connection, Initializes required tables, Checks for existing
data,Displays welcome message, Prepares system for use, Called when
program starts.
14. exit_system(): to gracefully closes the system and saves any
pending data, it closes database connection, displays thank you
message to ensures clean exit.
15.display_welcome(): It shows project title and description,
Provides brief instructions. Sets tone for user interaction which
includes decorative formatting.
System Startup & Main Menu
==================================================
QR CODE ATTENDANCE SYSTEM
==================================================
✓ Database tables created successfully!
System initialized successfully!
========================================
MAIN MENU
========================================
1. Add New Student
2. View All Students
3. Generate Today's QR Code
4. Mark Attendance
5. View Attendance Report
6. Monthly Report
7. Find Defaulters
8. Exit
========================================
Enter your choice (1-8): _
Adding Students
Enter your choice (1-8): 1
--- ADD NEW STUDENT ---
Enter Admission Number: 1001
Enter Student Name: Rohan Sharma
Enter Class: 12
Enter Phone Number: 9876543210
✓ Student 'Rohan Sharma' added successfully!
--- ADD NEW STUDENT ---
Enter Admission Number: 1002
Enter Student Name: Priya Patel
Enter Class: 12
Enter Phone Number: 8765432109
✓ Student 'Priya Patel' added successfully!
--- ADD NEW STUDENT ---
Enter Admission Number: 1001
✗ Student with this admission number already exists!
Viewing Students & Generating QR Code
Enter your choice (1-8): 2
--- REGISTERED STUDENTS ---
Adm No Name Class Phone
------------------------------------------------------------------------
1001 Rohan Sharma 12 9876543210
1002 Priya Patel 12 8765432109
1003 Amit Kumar 11 7654321098
1004 Sneha Singh 11 6543210987
1005 Rajesh Verma 10 9876123450
Total Students: 5
Enter your choice (1-8): 3
--- GENERATE TODAY'S QR CODE ---
✓ QR Code generated successfully!
Date: 15-12-2024
QR Code Data: ATTENDANCE-15122024-4587
QR Code saved as: qr_15122024.png
Instructions:
1. Display this QR code on projector 2. Students should scan with their phones
3. QR code is valid only for today
Marking Attendance
Enter your choice (1-8): 4
--- MARK ATTENDANCE ---
Enter Admission Number: 1001
Scan/Enter today's QR code: ATTENDANCE-15122024-4587
✓ Attendance marked for Rohan Sharma at 09:15:24
--- MARK ATTENDANCE ---
Enter Admission Number: 1002
Scan/Enter today's QR code: ATTENDANCE-15122024-4587
✓ Attendance marked for Priya Patel at 09:16:05
--- MARK ATTENDANCE ---
Enter Admission Number: 1003
Scan/Enter today's QR code: ATTENDANCE-14122024-1234
✗ Invalid or expired QR code!
--- MARK ATTENDANCE ---
Enter Admission Number: 1001
Scan/Enter today's QR code: ATTENDANCE-15122024-4587
✗ Attendance already marked for today!
Daily Attendance Report
Enter your choice (1-8): 5
--- ATTENDANCE REPORT ---
Enter date (DD-MM-YYYY) or press Enter for today:
Attendance Report for 15-12-2024
==================================================================
Adm No Name Class Status Time
--------------------------------------------------------------------------
1001 Rohan Sharma 12 Present 09:15:24
1002 Priya Patel 12 Present 09:16:05
1003 Amit Kumar 11 Absent -
1004 Sneha Singh 11 Absent -
1005 Rajesh Verma 10 Absent -
--------------------------------------------------------------------------
Present: 2 | Absent: 3 | Total: 5
Attendance Percentage: 40.00%
--- ATTENDANCE REPORT ---
Enter date (DD-MM-YYYY) or press Enter for today: 14-12-2024
Attendance Report for 14-12-2024
============================================================
Adm No Name Class Status Time
------------------------------------------------------------
1001 Rohan Sharma 12 Present 08:45:12
1002 Priya Patel 12 Present 09:00:30
1003 Amit Kumar 11 Present 08:55:15
1004 Sneha Singh 11 Present 09:10:20
1005 Rajesh Verma 10 Absent -
------------------------------------------------------------
Present: 4 | Absent: 1 | Total: 5
Attendance Percentage: 80.00%
Monthly Report & Defaulters
Enter your choice (1-8): 6
--- MONTHLY ATTENDANCE REPORT ---
Enter month (MM): 12
Enter year (YYYY): 2024
Monthly Report - 12/2024
============================================================
Adm No Name Class Present Percentage
------------------------------------------------------------
1001 Rohan Sharma 12 15 68.2%
1002 Priya Patel 12 16 72.7%
1003 Amit Kumar 11 14 63.6%
1004 Sneha Singh 11 18 81.8%
1005 Rajesh Verma 10 10 45.5%
Enter your choice (1-8): 7
--- STUDENTS WITH ATTENDANCE BELOW 75% ---
Adm No Name Class Percentage
------------------------------------------------------------
1001 Rohan Sharma 12 68.2%
1002 Priya Patel 12 72.7%
1003 Amit Kumar 11 63.6%
1005 Rajesh Verma 10 45.5%
Total Defaulters: 4
--- STUDENTS WITH ATTENDANCE BELOW 75% ---
✓ No defaulters found! All students have good attendance.
Error Handling & Exit
Enter your choice (1-8): 1
--- ADD NEW STUDENT ---
Enter Admission Number: 1006
Enter Student Name: Anjali
Enter Class: Ten
✗ Invalid input! Please enter correct data types.
--- ATTENDANCE REPORT ---
Enter date (DD-MM-YYYY) or press Enter for today: 31-02-2024
✗ Invalid date format! Use DD-MM-YYYY
--- MONTHLY ATTENDANCE REPORT ---
Enter month (MM): December
✗ Invalid input! Please enter numbers only.
Enter your choice (1-8): 9
✗ Invalid choice! Please enter 1-8.
Enter your choice (1-8): 8
Thank you for using QR Attendance System! Goodbye!
Source Code