Dynamic Seating Allocation System Final Copy 1
Dynamic Seating Allocation System Final Copy 1
Submitted By
G. SURESH
VYSYA COLLEGE
(AFFILIATED TO PERIYAR UNIVERSITY)
MARCH – 2024
Date:
CERTIFICATE
Date of Viva-voice:
Special thanks to my guide and the dedicated faculty members of our department for
their constant support and assistance during the project's execution.
I also express my gratitude to all the other faculty members and individuals who
generously shared their expertise and resources, making significant contributions to the
project's success.
I would like to express my special gratitude and thanks to all above mentioned people
for giving us such attention and time. My thanks and appreciations also go to our other
faculties in developing the project and people who have willingly helped us out with their
abilities.
I sincerely appreciate the time and attention provided by everyone involved, without
which this project would not have been possible.
CONTENTS
CHAPTER PAGE NO
COLLEGE BONAFIDE CERTIFICATE
ACKNOWLEDGEMENT
SYNOPSIS
1. INTRODUCTION 1
1.1 SYSTEM SPECIFICATION 3
1.1.1 HARDWARE CONFIGURATION 3
1.1.2 SOFTWARE SPECIFICATION 3
2. SYSTEM STUDY
2.1 EXISTING SYSTEM 4
2.1.1 DESCRIPTION 4
2.1.2 DRAWBACKS 5
2.2 PROPOSED SYSTEM 6
2.2.1 DESCRIPTION 6
2.2.2 FEATURES 7
3. SYSTEM DESIGN AND DEVELOPMENT
3.1 FILE DESIGN 8
3.2 INPUT DESIGN 8
3.3 OUTPUT DESIGN 9
3.4 CODE DESIGN 9
3.5 SYSTEM DEVELOPMENT 10
3.5.1 DESCRIPTION OF MODULES 10
4. SYSTEM DESIGN AND IMPLEMENTATION 13
5. CONCLUSION 16
6. BIBLIOGRAPHY 17
APPENDICES
A. DATA FLOW DIAGRAM 18
B. USE CASE DIAGRAM 19
C. TABLE STRUCTURE 20
D. SAMPLE CODING 21
E. SAMPLE INPUT 48
F. SAMPLE OUTPUT 52
SYNOPSIS
By using modern technology and innovative approaches, this project aims to transform the
way seating arrangements are managed in learning environments. With a focus on user-friendly
interfaces and intuitive workflows, the system empowers educators and administrators to create
optimal seating arrangements with ease and efficiency.
In the past, assigning seats manually and dealing with paperwork was the norm. However,
this project introduces a new modern age for educational institutions, using automation and digital
tools to streamline the process of allocating seats. This advancement saves time and effort for
everyone involved. While Excel and VBA macros have progressed to address certain needs, this
project goes beyond by providing a user-friendly graphical interface. This interface improves
accessibility and usability for administrators, teachers, and students, making the whole process
smoother and more efficient.
1
OBJECTIVE:
The primary objective is to optimize and streamline the allocation of seats to students, with
the overarching goal of enhancing the overall efficiency and effectiveness of the seating arrangement
process. By providing a user-friendly interface and implementing effective seating arrangements,
the project aims to simplify seat allocation, making it more accessible and manageable for
administrators, teachers, and students.
BENEFITS:
2
1.1 SYSTEM SPECIFICATION
1.1.1 Hardware Configuration
Hardware requirements for this system are listed below:
• RAM : 4GB
• Frontend : PyQt5,Tkinter,DataFrames
3
2. SYSTEM STUDY
2.1 EXISTING SYSTEM
• The existing system in our college relies on Excel coupled with VBA macros for
seating arrangements. This system typically involves manually inputting student data, room
specifications, and seating preferences into Excel spreadsheets, with VBA macros automating
• The system allows for highly customizable seating arrangements tailored to specific
• VBA macros automate repetitive tasks, such as assigning students to seats based on
predefined criteria and generating seating charts or reports. This automation enhances
efficiency and reduces the time and effort required for manual seat allocation.
VBA programming. Staff turnover or changes in personnel could disrupt the continuity and
2.1.1 DESCRIPTION:
• While the existing system requires users to manually input student data and room
specifications into Excel sheets, my project provides a graphical user interface (GUI) that
simplifies this process. Instead of navigating complex spreadsheets and writing VBA macros,
users can input data effortlessly using intuitive forms and menus.
• Furthermore, the existing system's reliance on VBA macros for automation poses
challenges for users who lack programming skills or familiarity with Excel. In contrast, my
project eliminates the need for VBA programming by offering built-in algorithms and
4
automation features accessible through the GUI. This approach enhances accessibility and
system by offering a modern, user-friendly, and automated solution for seating arrangement
2.1.2 DRAWBACKS:
While the existing system with Excel and Macros/VBA may have served its
purpose to some extent, it is not without its drawbacks:
1. Limited Scalability:
The existing system's reliance on Excel and VBA macros may limit its scalability,
especially when dealing with large datasets or complex seating arrangements. As the
volume of data increases, the performance of Excel may degrade, resulting in slower
Operating and maintaining the existing system requires a certain level of technical
3. Complexity:
Managing large datasets and seating configurations in Excel can be complex and
5
2.2 PROPOSED SYSTEM
The proposed system is a modern, user-friendly software application designed to
revolutionize the process of seating arrangement management in educational institutions. Unlike
the existing system, which relies on manual data entry and limited automation through Excel and
VBA macros, the proposed system offers a comprehensive solution with advanced features and
enhanced usability .
2.2.1 DESCRIPTION
• Imagine a system where you can easily input exam details, such as the number of students
and available rooms, using a familiar and intuitive interface. With just a few clicks, you can
define seating preferences and let the system handle the rest.
• This system is all about automation. It takes care of assigning seats to students based on
various factors like room capacity and special requirements, so you don't have to worry
about manual calculations or errors keeping in.
• One of the best parts is its flexibility. Whether you're organizing a small classroom test or a
large-scale exam, the system adapts seamlessly to your needs, making it suitable for any
educational institution.
• Finally, this system offers a simple and user-friendly solution to the challenges faced in
managing seating arrangements for exams in educational institutions. It's like having a
smart assistant that handles all the complexities behind the scenes, leaving educators and
administrators with a hassle-free experience.
6
2.2.2 FEATURES
The system allows users to import student data from Excel files, ensuring
compatibility with existing data sources.
Utilizing Python and pandas, the system processes and allocates student seats in a
more efficient and optimized manner.
3. Dynamic Scalability:
The proposed system is designed to handle varying student numbers and classroom
configurations, providing scalability for growing educational institutions.
4. User-Friendly Interface:
A Tkinter-based graphical user interface (GUI) makes the system accessible to users
with varying technical expertise, reducing dependency on specialized skills.
5. Error Reduction:
Automation minimizes the risk of human errors, enhancing the accuracy of student
seat allocation.
The system generates seating arrangements swiftly, saving time for educators and
administrators.
7
3. SYSTEM DESIGN AND DEVELOPMENT
The file design of a student seat allocation system is essential for effectively managing
student data, room information, and the seating arrangement process. It involves organizing data into
structured files that facilitate efficient storage, retrieval, and manipulation of information. A well-
designed file structure ensures the integrity, security, and accessibility of data throughout the seat
allocation process.
The input file for the student seat allocation system is an Excel spreadsheet (.xlsx). It's
like a table where each column represents a different department, like "BCA" or "MATHS". In each
department's column, you'll see a list of students, with each student listed on a separate row. Every
column shows the student's unique register number, which helps to identify them. This organized
setup makes it easy to find and manage student information, which is important for assigning seats
during the allocation process. During the allocation process, the input file will be read by alternative
columns, with odd columns read alone and even columns read alone. It's essential to ensure that the
input file remains consistent throughout this process.
8
3.3 OUTPUT DESIGN
The student seat allocation system provides seating arrangements in two formats: Excel and
PDF.
In the Excel format, seating arrangements are organized like tables in a spreadsheet (.xlsx).
Each sheet represents a different class or room in the exam venue. Students are assigned specific
seats, displayed in rows and columns with students' register numbers are listed in the cells. This
layout helps manage student information efficiently and ensures clear seat assignments. Room
numbers are also included for easy identification of exam rooms. It's important to keep the data
consistent throughout the process.
The PDF format presents seating arrangements in a visually appealing way. Each page of the
PDF corresponds to a specific class or room in the exam hall. Seats are arranged in rows and
columns, with students' register numbers listed next to each seat. The PDF includes headers with
essential information such as the college name, exam details, and signatures of hall supervisors
and principals at the bottom of each page. This format offers a straightforward and comprehensive
overview of the seating arrangement, making exam management easier.
At the code implies, the student seat allocation system is like a smoothly running code,
made up of different parts that work together seamlessly. First, it gathers information about
students and the available rooms from files, like Excel sheets. Then, it uses a smart algorithm to
figure out where each student should sit. This decision is based on things like how big the room is
and how many students there are. Once the seats are assigned, the system creates a clear seating
plan. This could be in the form of Excel sheets or PDFs, making it easy to see where each student
should go. If something goes wrong along the way, the system handles it gracefully. It gives clear
messages to help understand and fix any issues that arise.
9
3.5 SYSTEM DEVELOPMENT
It is a structured approach to creating and improving software systems to meet specific needs.
It starts with understanding what the college administrators needed. It involved planning out each
step carefully to make sure everything would work well. As the only developer, I had to think
through everything and turn ideas into reality. Testing was important to make sure everything
worked smoothly. Finally, the system was ready for use by the administrators, meeting their needs
effectively.
• Login Module
• Signup Module
• Room Specification
• Generate Excel Output
• Generate PDF Output
10
Login Module:
The login module is the gateway for administrators to access the system securely. Here's how it
works:
❖ Administrators need to enter their username and password in the designated fields provided
on the screen. Once they've filled in their details, they can click the "Sign in" button.
❖ To make it easier, there's a checkbox that allows administrators to show or hide their
password while typing.
❖ If administrators make a mistake and enter the wrong username or password, the system
will show them an error message to let them know and ask them to try again with the
correct details.
Signup Module:
The sign-up module serves as a platform for new users to register and create an account within
the system.
❖ It provides a user-friendly interface where individuals can input their desired username and
password.
❖ Upon submission, the system ensures that the entered passwords match correctly before
proceeding further. In case of any discrepancies, such as mismatched passwords, custom
error dialogs are displayed to notify the user about the issue.
❖ Valid user credentials are securely stored in a text file for future authentication. Once the
registration process is successfully completed, users receive confirmation through a custom
information dialog.
Room Specification:
The room specification module facilitates the configuration of exam rooms within the system.
11
Generate Excel Output
This module is responsible for creating structured Excel spreadsheets that contain the seating
arrangements for the exam halls.
❖ This module takes the allocated seats data and organizes it into an Excel file format (.xlsx),
making it easy to manage and distribute.
❖ The process begins by gathering the allocated seating information from the system's Excel
Sheet.
❖ Then, using the openpyxl library and pandas in Python, the module generates an Excel
workbook with multiple sheets, each representing a different exam hall or room.
❖ Within each sheet, the seating arrangement is laid out in a tabular format, with rows and
columns corresponding to the seats in the room
❖ The student's registration number is placed in each cell to denote their allocated seat.
❖ Additionally, the room number and other relevant details may be included in the
spreadsheet for reference.
❖ This module transforms the allocated seating data into PDF documents, which are easy to
distribute and view across different devices.
❖ The process begins by gathering the allocated seating information from the system's Excel
Sheet , similar to the Excel output module.
❖ Using a PDF generation library such as ReportLab and PyFPDF in Python, the module
creates PDF files containing the seating arrangements.
❖ The seating arrangement is presented in a structured layout, with rows and columns
representing individual seats
❖ Each seat is labeled with the student's unique identifier or registration number to indicate
their allocated position.
❖ The PDF output may include other relevant details such as the room number, exam date,
and supervisor instructions.
12
4. SYSTEM DESIGN AND DEVELOPMENT
TESTING
Testing is the ultimate step of software development. Testing software extend towards
coding phase and it represents the ultimate review of configuration, design, coding. A series of test
cases are created that are intended to demolish the component that has been built. It is essential that
all components of an application be tested, as the failure to do so many results in a series of bugs
after the software id put to use.
SOFTWARE TESTING
Software testing is the process used to measure the quality of developed computer
software. Usually, quality is constrained to such topics as correctness, completeness, security, but
can also include more technical requirements as described under the ISO standard ISO 9126, such
as capability, reliability, efficiency, portability, maintainability, compatibility, and usability. Testing
is a process of technical investigation, performed on behalf of stakeholders, that is intended to revel
quality-related information about product with respect to the context in which it is intended to
operate.
13
Following testing types are performed after coding.
• Unit Testing
• Integration Testing
• Functionality Testing
UNIT TESTING
Unit testing is implemented to evaluate individual units or components of the project, such as
functions, methods, or classes, in isolation. Each unit is tested independently to verify its correctness
and functionality, ensuring that it behaves as intended and produces the expected output for a given
set of inputs. In unit testing, the focus is on testing small, atomic units of code, typically at the
function or method level, to ensure they perform as expected and meet the specified requirements.
This approach allows for the early detection and resolution of defects, promoting code reliability
and maintainability.
INTEGRATION TESTING
Integration testing focuses on testing how different units or components of the project
interact and work together when integrated into the system. This testing ensures that the integration
of various modules does not introduce any unexpected behavior or errors and that the system
functions seamlessly as a whole.
Integration tests are designed to validate the flow of data and control between different
modules, ensuring that data is passed correctly between components and that the overall system
behavior meets the specified requirements.
During integration testing, various modules or components are integrated incrementally, and
their interactions are examined to detect any inconsistencies, interface mismatches, or
communication issues.
14
FUNCTIONALITY TESTING
Functionality testing assesses the overall functionality of the project by validating its features
and capabilities against the specified requirements. This testing ensures that all functionalities work
as intended, perform their intended tasks accurately, and meet the user's expectations.
Verify that administrators can securely log in to the system using their credentials and access
the necessary functionalities.
Test the system's ability to allocate seats to students based on predefined criteria, such as
exam schedules, seating capacity, and special accommodations.
Ensure that seats are assigned accurately and efficiently, considering factors like student
preferences, accessibility requirements, and exam regulations.
SYSTEM DEVELOPMENT
Implementation is the most crucial stage in achieving a successful system and giving the
user’s confidence that the new system is workable and effective.
15
5. CONCLUSION
The project title DYNAMIC SEATING ALLOCATION SYSTEM was deeply studied and
analyzed to design the code and implement.
It was done under the guidance of the experienced project guide. All the current requirements
possibilities have been taken care during the project time,
This project highlights the iterative nature of development and the importance of user
feedback in driving continuous improvement.
FUTUREWORK
For future improvements, we can make the DYNAMIC SEATING ALLOCATION
SYSTEM better in a few ways. One idea is exploring features such as dynamic seating allocation
algorithms to optimize space utilization and accommodate varying exam schedules efficiently.
Moreover, integrating a notification system to alert students about their allocated seats and
exam details in real-time could enhance user experience and reduce administrative workload.
16
6. BIBILOGRAPHY
For Python
https://www.w3schools.com/python/
For PyQT5
https://doc.qt.io/qtforpython-6/quickstart.html
For Tkinter
https://www.geeksforgeeks.org/python-gui-tkinter/
Book:
1. Skiena, S. S. (2008). Algorithm Design Manual. Springer.
17
APPENDICES
A. DATA FLOW DIAGRAM
ADMIN FLOW DIAGRAM
ADMIN/USER
LOGIN
18
USE CASE DIAGRAM
Login
Add necessary
details
Generate Output
Excel or PDF
Format
19
B. TABLE STRUCTURE
20
C. SAMPLE CODING
Main.py
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout,
QFileDialog, QMessageBox
from PyQt5.QtCore import Qt
from design_module import DesignModule
from allocation_module import AllocationModule
from pdf_module import PdfModule
import sys
class MainProgram(QWidget):
def __init__(self):
super().__init__()
self.design_module = DesignModule(self)
self.allocation_module = AllocationModule(self)
self.init_ui()
def init_ui(self):
self.setWindowTitle('Classroom Generator')
self.setGeometry(100, 100, 400, 300)
layout = QVBoxLayout(self)
layout.addWidget(self.design_module)
21
def generate_excel_output(self):
file_path = self.design_module.file_entry.text()
students_per_class_text = self.design_module.class_entry.text()
rows_text = self.design_module.rows_entry.text()
columns_text = self.design_module.columns_entry.text()
try:
students_per_class = int(students_per_class_text)
rows = int(rows_text)
columns = int(columns_text)
except ValueError:
QMessageBox.critical(self, 'Error', 'Please enter valid numerical values for
students per class, rows, and columns.')
return
l3, _ = self.allocation_module.read_excel_and_generate_output(file_path,
students_per_class)
self.allocation_module.generate_excel_output(l3, students_per_class, rows,
columns)
def generate_pdf_output(self):
try:
file_path = self.design_module.file_entry.text()
students_per_class_text = self.design_module.class_entry.text()
rows_text = self.design_module.rows_entry.text()
columns_text = self.design_module.columns_entry.text()
22
exam_name = self.design_module.exam_name_combobox.currentText()
exam_date =
self.design_module.date_edit.date().toString(Qt.DefaultLocaleLongDate)
session = self.design_module.session_combobox.currentText()
try:
students_per_class = int(students_per_class_text)
rows = int(rows_text)
columns = int(columns_text)
except ValueError:
QMessageBox.critical(self, 'Error', 'Please enter valid numerical values for
students per class, rows, and columns.')
return
l3, _ = self.allocation_module.read_excel_and_generate_output(file_path,
students_per_class)
23
pdf = PdfModule.generate_pdf_output(l3, students_per_class, rows, columns,
exam_name, exam_date,session,college_name)
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
filename, _ = QFileDialog.getSaveFileName(self, "Save PDF file",
"AllocatedStudents.pdf", "PDF Files (*.pdf);;All Files (*)", options=options)
if filename:
pdf.output(filename)
QMessageBox.information(self, 'Success', f'PDF file "{filename}" has been
created successfully.')
except Exception as e:
QMessageBox.critical(self, 'Error', f'An error occurred: {str(e)}')
print(f'An error occurred: {str(e)}')
def main():
app = QApplication(sys.argv)
window = MainProgram()
window.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Login.py
import tkinter as tk
from tkinter import Toplevel, Label, Button, Entry, Checkbutton, BooleanVar
from PIL import Image, ImageTk
import ast
24
error_dialog.title(title)
error_dialog.iconbitmap(r"C:\Users\sures\OneDrive\Desktop\Exam
Seat\Assests\img\logoico.ico")
error_dialog.geometry('400x150+500+300')
error_dialog.configure(bg='#c0392b') # Set background color to light red
error_dialog.resizable(False, False)
def close_dialog():
error_dialog.destroy()
# Resume background tasks here
def toggle_password_visibility():
global show_password
show_password = not show_password
if show_password:
code.config(show="")
else:
code.config(show="*")
def signin():
25
username = user.get()
password = code.get()
screen.mainloop()
elif username != 'admin' and password != '1234':
show_custom_error("Incorrect", "Incorrect Username and Password")
root = tk.Tk()
root.title('EXAM HALL SEATING ARRANGEMENT')
root.iconbitmap(r'C:\Users\sures\OneDrive\Desktop\Exam
Seat\Assests\img\logoico.ico')
root.geometry('925x500+300+200')
root.configure(bg='#e84118') # Set background color to #e84118
root.resizable(False, False)
26
# Load and display the background image
try:
pil_image = Image.open(r'C:\Users\sures\OneDrive\Desktop\Exam
Seat\Assests\img\bg1.jpg')
img = ImageTk.PhotoImage(pil_image)
label = Label(root, image=img)
label.place(x=0, y=0, relwidth=1, relheight=1)
except Exception as e:
print(f"An error occurred: {e}")
###==================================================
# Create an Username Entry widget
27
def on_enter_user(e):
user.delete(0,'end')
def on_leave_user(e):
name=user.get()
if name=='':
user.insert(0,'Username')
tk.Frame(frame,width=295,height=2,bg='black').place(x=25,y=107)
###==================================================
# Create a Password Entry widget
def on_enter_code(e):
code.delete(0,'end')
def on_leave_code(e):
name=code.get()
if name=='':
code.insert(0,'Password')
show_password = False
28
code = tk.Entry(frame, width=20, fg='black', border=0, bg='white', font=('Microsoft Vahei
UI Light', 11), show="*")
code.place(x=30, y=150) # Adjust the position as needed
code.insert(0,'Password')
code.bind('<FocusIn>',on_enter_code)
code.bind('<FocusOut>',on_leave_code)
tk.Frame(frame,width=295,height=2,bg='black').place(x=25,y=177)
##=============================================================
##=============================================================
tk.Button(frame, width=39, pady=7, text='Sign in', bg='#1abc9c', fg='white', border=0,
command=signin).place(x=35, y=240)
label = tk.Label(frame, text="Don't have an account?", fg='black', bg='white',
font=('Microsoft Vahei UI Light', 9))
label.place(x=75, y=290)
root.mainloop()
29
SignUp.py
from tkinter import *
from tkinter import messagebox
import ast
import tkinter as tk
from tkinter import Toplevel, Label, Button, Entry
from PIL import Image, ImageTk
window=Tk()
window.title("EXAM HALL SEATING ARRANGEMENT")
window.geometry('925x500+300+200')
window.configure(bg='#fff')
window.resizable(False,False)
window.iconbitmap(r'C:\Users\sures\OneDrive\Desktop\Exam
Seat\Assests\img\logoico.ico')
def close_dialog():
30
error_dialog.destroy()
# Resume background tasks here
def close_dialog():
info_dialog.destroy()
# Resume background tasks here
31
info_dialog.grab_set()
# Wait until the info dialog is closed before continuing with the background tasks
info_dialog.wait_window()
def signup():
username = user.get()
password = code.get()
confirm_password = confirm_code.get()
if password == confirm_password:
try:
file = open('datasheet.txt', 'r+')
d = file.read()
r = ast.literal_eval(d)
32
else:
show_custom_error('Incorrect', 'Password should not match')
def sign():
window.destroy()
#Create Frame
frame=Frame(window,width=350,height=390,bg='white')
frame.place(x=480,y=50)
33
heading.place(x=120, y=5)
###-------------------------------------------------------------------------------------------------------
------
def on_enter(e):
user.delete(0,'end')
def on_leave(e):
if user.get()=='':
user.insert(0,'Username')
Frame(frame,width=295,height=2,bg='black').place(x=25,y=107)
###-------------------------------------------------------------------------------------------------------
------
def on_enter(e):
code.delete(0,'end')
def on_leave(e):
if code.get()=='':
code.insert(0,'Password')
code=Entry(frame,width=25,fg='black',border=0,bg='white',font=('Microsoft Vahei UI
Light', 11))
code.place(x=30,y=150)
34
code.insert(0,'Password')
code.bind('<FocusIn>',on_enter)
code.bind('<FocusOut>',on_leave)
Frame(frame,width=295,height=2,bg='black').place(x=25,y=177)
###-------------------------------------------------------------------------------------------------------
------
def on_enter(e):
confirm_code.delete(0,'end')
def on_leave(e):
if confirm_code.get()=='':
confirm_code.insert(0,'Confirm Password')
confirm_code=Entry(frame,width=25,fg='black',border=0,bg='white',font=('Microsoft
Vahei UI Light', 11))
confirm_code.place(x=30,y=220)
confirm_code.insert(0,'Confirm Password')
confirm_code.bind('<FocusIn>',on_enter)
confirm_code.bind('<FocusOut>',on_leave)
Frame(frame,width=295,height=2,bg='black').place(x=25,y=247)
#--------------------------------------------------------------------------------
Button(frame,width=39,pady=7,text='Sign
Up',bg='#1abc9c',fg='white',border=0,command=signup).place(x=35,y=280)
label=Label(frame,text='I have an account',fg='black',bg='white',font=('Microsoft Vahei UI
Light', 9))
label.place(x=90,y=340)
signin=Button(frame,width=6,text='Sign
in',border=0,bg='white',cursor='hand2',fg='#1abc9c',command=sign)
35
signin.place(x=190,y=340)
window.mainloop()
Design_module.py
class DesignModule(QWidget):
def __init__(self, parent):
super().__init__()
self.parent = parent
self.init_ui()
def init_ui(self):
self.file_label = QLabel('Select Excel file:')
self.file_entry = QLineEdit()
self.browse_button = QPushButton('Browse')
self.browse_button.clicked.connect(self.browse_file)
self.rows_label = QLabel('Rows:')
self.rows_entry = QLineEdit()
self.columns_label = QLabel('Columns:')
36
self.columns_entry = QLineEdit()
self.session_label = QLabel('Session:')
self.session_combobox = QComboBox()
self.session_combobox.addItems(['FN', 'AN'])
layout = QVBoxLayout()
layout.addWidget(self.file_label)
layout.addWidget(self.file_entry)
layout.addWidget(self.browse_button)
layout.addWidget(self.college_name_label)
37
layout.addWidget(self.college_name_entry)
layout.addWidget(self.class_label)
layout.addWidget(self.class_entry)
layout.addWidget(self.rows_label)
layout.addWidget(self.rows_entry)
layout.addWidget(self.columns_label)
layout.addWidget(self.columns_entry)
layout.addWidget(self.date_label)
layout.addWidget(self.date_edit)
layout.addWidget(self.exam_name_label)
layout.addWidget(self.exam_name_combobox)
layout.addWidget(self.session_label)
layout.addWidget(self.session_combobox)
self.setLayout(layout)
def browse_file(self):
filename, _ = QFileDialog.getOpenFileName(self, 'Select Excel file', '/', 'Excel files
(*.xlsx);;All files (*.*)')
self.file_entry.setText(filename)
38
Allocation_module.py
# allocation_module.py
import pandas as pd
from PyQt5.QtWidgets import QMessageBox, QFileDialog
from openpyxl.styles import Alignment
from openpyxl.utils import get_column_letter
from openpyxl import Workbook
from openpyxl.utils.dataframe import dataframe_to_rows
class AllocationModule:
def __init__(self, parent):
self.parent = parent
l1 = []
l2 = []
if len_diff > 0:
num_to_append = len_diff // 2
l2.extend(l1[-num_to_append:])
39
l1 = l1[:-num_to_append]
elif len_diff < 0:
num_to_append = abs(len_diff) // 2
l1.extend(l2[-num_to_append:])
l2 = l2[:-num_to_append]
if len_diff % 2 == 1:
last_element_l2 = l2.pop()
l2.reverse()
if len_diff % 2 == 1:
l3.append(last_element_l2)
students_total = len(l3)
classes = -(-students_total // students_per_class)
40
remaining_slots = students_per_class * classes - students_total
l3 += ['NONE'] * remaining_slots
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
filename, _ = QFileDialog.getSaveFileName(self.parent, "Save Excel file",
"AllocatedStudents.xlsx", "Excel Files (*.xlsx);;All Files (*)", options=options)
if filename:
if not filename.endswith(".xlsx"):
filename += ".xlsx"
wb = Workbook()
for i in range(classes):
start_row = i * students_per_class
end_row = min((i + 1) * students_per_class, students_total)
class_data = df_output.iloc[start_row:end_row]
if not class_data.empty:
none_values = pd.DataFrame({'Student_ID': ['NONE'] * (students_per_class -
len(class_data))})
class_data = pd.concat([class_data, none_values], ignore_index=True)
ws = wb.create_sheet(title=f'Class_{i + 1}')
41
for col in range(1, reshaped_df.shape[1] + 1):
column_letter = get_column_letter(col)
ws.column_dimensions[column_letter].width = 19
default_sheet = wb.active
wb.remove(default_sheet)
wb.save(filename)
QMessageBox.information(self.parent, 'Success', f'Excel file "{filename}" has been
created successfully.')
Pdf_module.py
from fpdf import FPDF
from PyQt5.QtWidgets import QMessageBox
class PdfModule:
@staticmethod
def generate_pdf_output(l3, students_per_class, rows, columns, exam_name,
exam_date,session,college_name):
42
hall_supervisor_signature = "Hall Supervisor Signature"
principal_signature = "Principal Signature"
class CustomPDF(FPDF):
def __init__(self, hall_supervisor_signature="Hall Supervisor Signature",
principal_signature="Principal Signature"):
super().__init__()
self.hall_supervisor_signature = hall_supervisor_signature
self.principal_signature = principal_signature
def footer(self):
self.set_y(-12)
self.set_font("Arial", style='I', size=8)
self.set_text_color(128, 128, 127) # Gray color
self.cell(0, 10, "Developed by @Suresh G", 0, 0, 'C')
students_total = len(l3)
classes = -(-students_total // students_per_class)
for i in range(classes):
start_row = i * students_per_class
end_row = min((i + 1) * students_per_class, students_total)
class_data = l3[start_row:end_row]
43
college_name = college_name.upper() # Convert college name to uppercase
# Add Date
x_left = 10 # Set left margin
y_top = 50 # Set top margin
pdf.set_font("Arial", style='B', size=10)
pdf.text(x_left, y_top, f"Date: {exam_date}") # Draw the date
44
y_top = 50 # Set top margin
pdf.set_font("Arial", style='B', size=10)
pdf.text(x_left, y_top, f"Session : {session}") # Add Session
cell_height = 15
cell_width = 28.75
# Move to the center of the page before drawing the table
pdf.set_x(x_center)
45
for row in range(rows): # Iterate over rows first
pdf.ln()
for col in range(columns): # Then iterate over columns
index = table_index * (rows * columns) + row + col * rows
if index < len(class_data):
student_id = class_data[index]
# Add serial number for each cell
serial_number = col * rows + row + 1
pdf.cell(5, cell_height, txt=str(serial_number), border=1, ln=0,
align='C')
pdf.cell(cell_width, cell_height, student_id, 1, 0, 'C')
# Add extra space after every two columns
if col % 2 == 1 and col != columns - 1: # Add space after every second
column except the last one
pdf.cell(2.5, 0, '', ln=0) # Add a small gap between columns
else:
serial_number = col * rows + row + 1
pdf.cell(5, cell_height, str(serial_number), 1, 0, 'C') # Empty cell for
serial number
pdf.cell(cell_width, cell_height, '', 1, 0, 'C') # Empty cell
if col % 2 == 1 and col != columns - 1: # Add space after every second
column except the last one
pdf.cell(2.5, 0, '', ln=0) # Add a small gap between columns
pdf.ln()
46
pdf.text(x_signature, y_signature, pdf.hall_supervisor_signature) # Access class
attribute using instance
x_principal_signature = pdf.w - pdf.get_string_width(pdf.principal_signature) -
10
pdf.text(x_principal_signature, y_signature, pdf.principal_signature) # Access
class attribute using instance
return pdf
47
D. SAMPLE INPUT
Login Page
48
SignUp Page
49
Allocation Module
50
EXCEL INPUT
51
E. SAMPLE OUTPUT:
PDF OUTPUT
52
53
EXCEL OUTPUT
54