Computer Science Investigatory Project by Aditya Sharma
Computer Science Investigatory Project by Aditya Sharma
ON
JEE QUESTION PAPER
MANAGEMENT SYSTEM
1
CERTIFICATE
This is to certify that the project entitled “Jee Question Paper Management System”
submitted by “Aditya Sharma” (Registration No.: ___________________________
Year: _______) to Amrita Vidyalayam, Kolkata, is Computer Science Project work
carried out by him/her under our supervision and guidance. The project work has been
successfully completed, partially fulfilling the requirements of the regulations related
to the nature of the Computer Science Practical Examination conducted by CBSE
during the academic year 2024-25.
2
GROUP MEMBERS
• ADITYA SHARMA
• ARASHI SINGH
• RITAM DAS
3
CONTENTS
S. NO. TOPICS PAGE NO.
1 ACKNOWLEDGMENT 5
2 INTRODUCTION 6
5 ALGORITHM 10 – 11
6 SYSTEM REQUIREMENTS 12
7 SOURCE CODE 13 – 19
8 OUTPUT 20 – 22
11 CONCLUSION 25
12 BIBLIOGRAPHY 26
4
ACKNOWLEDGMENT
I would like to express my sincere gratitude to all those who
contributed to the successful completion of my project, "JEE Question
Paper Management".
5
INTRODUCTION
The software developed for this project is a "JEE Question Paper
Management System" which allows users to manage, add, update,
fetch, and delete questions related to JEE examination preparation.
The system is implemented using Python and MySQL as the database
management system, ensuring ease of use, secure login, and an
intuitive interface for interacting with the database.
6
OBJECTIVES OF THE PROGRAM
• To implement a user authentication system with the ability to
register, login, and store credentials securely.
7
DESCRIPTION OF THE PROGRAM
• User Management: The user management system allows for user
registration and login. After successful login, users can access the
question management features.
8
• Delete Question: Users can delete any question from the
database. Once deleted, the remaining questions are displayed to
ensure that the system remains organized.
• Exit The System: User can end the program and exit from it.
9
ALGORITHM
1. Login and Registration:
2. Add Question:
3. Fetch Question:
• Retrieve all questions from the database along with their details.
4. Update Question:
5. Delete Question:
7. Exit:
• Disconnects from the Main Server and closes the database.
• Exits from the Program.
11
SYSTEM REQUIREMENTS
• Hardware:
• Software:
• Python 3.x
• MySQL Server
• Python libraries:
o mysql.connector
o tabulate
o textwrap
o random
• Operating System:
12
SOURCE CODE
import mysql.connector
from tabulate import tabulate
import textwrap
import random
def create_user_database_and_table(cursor):
"""Creates a database and a users table if not already present."""
cursor.execute("CREATE DATABASE IF NOT EXISTS user_management")
cursor.execute("USE user_management")
cursor.execute("""
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
)
""")
while True:
print("1. Login")
print("2. Register")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == '1':
username = input("Enter username: ")
password = input("Enter password: ")
cursor.execute("SELECT * FROM users WHERE username = %s AND password =
%s", (username, password))
user = cursor.fetchone()
if user:
print(f"Welcome, {username}! Login successful.")
return True
else:
print("Invalid username or password. Please try again.")
13
username = input("Enter a new username: ")
password = input("Enter a new password: ")
try:
cursor.execute("INSERT INTO users (username, password) VALUES (%s, %s)",
(username, password))
conn.commit()
print("Registration successful. You can now log in.")
except mysql.connector.Error as err:
print(f"Error: {err}. Username may already exist.")
else:
print("Invalid choice. Please try again.")
def create_database_and_tables(cursor):
"""Creates a database and tables for storing subjects and questions."""
cursor.execute("CREATE DATABASE IF NOT EXISTS jee_management")
cursor.execute("USE jee_management")
cursor.execute("""
CREATE TABLE IF NOT EXISTS subjects (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS questions (
id INT AUTO_INCREMENT PRIMARY KEY,
subject_id INT,
question TEXT,
answer TEXT,
difficulty VARCHAR(10),
FOREIGN KEY (subject_id) REFERENCES subjects(id)
)
""")
subjects = ["Mathematics", "Physics", "Chemistry", "English"]
for subject in subjects:
cursor.execute("INSERT IGNORE INTO subjects (name) VALUES (%s)", (subject,))
print("\nSelect a subject:")
for idx, subject in enumerate(subjects, 1):
print(f"{idx}. {subject[1]}")
14
subject_choice = input("\nEnter subject choice number: ")
if not subject_choice.isdigit() or int(subject_choice) not in range(1, len(subjects) + 1):
print("Invalid choice. Please try again.")
return
subject_choice = int(subject_choice)
subject_id = subjects[subject_choice - 1][0]
cursor.execute("""
INSERT INTO questions (subject_id, question, answer, difficulty)
VALUES (%s, %s, %s, %s)
""", (subject_id, question, answer, difficulty))
conn.commit()
print("Question added successfully.")
def fetch_question(cursor):
"""Fetches and displays all available questions in a formatted table."""
cursor.execute("""
SELECT q.id, s.name AS subject, q.question, q.answer, q.difficulty
FROM questions q
JOIN subjects s ON q.subject_id = s.id
""")
questions = cursor.fetchall()
if not questions:
print("No questions available.")
return
formatted_questions = [
(qid, wrap_text(subject), wrap_text(question), wrap_text(answer), difficulty)
for qid, subject, question, answer, difficulty in questions
]
15
"""Updates an existing question in the database."""
cursor.execute("""
SELECT q.id, q.question, q.answer, q.difficulty
FROM questions q
""")
questions = cursor.fetchall()
if not questions:
print("No questions available to update.")
return
formatted_questions = [
(qid, wrap_text(question), wrap_text(answer), difficulty)
for qid, question, answer, difficulty in questions
]
if not question_data:
print("Invalid ID. Question not found.")
return
16
new_difficulty = difficulties[int(difficulty_choice) - 1]
cursor.execute("""
UPDATE questions
SET question = %s, answer = %s, difficulty = %s
WHERE id = %s
""", (new_question, new_answer, new_difficulty, question_id))
conn.commit()
print("Question updated successfully.")
formatted_questions = [
(qid, wrap_text(question)) for qid, question in questions
]
def generate_test_paper(cursor):
"""Generates a test paper by selecting questions based on difficulty."""
cursor.execute("SELECT * FROM subjects")
subjects = cursor.fetchall()
print("\nSelect a subject:")
for idx, subject in enumerate(subjects, 1):
print(f"{idx}. {subject[1]}")
17
subject_choice = int(subject_choice)
subject_id = subjects[subject_choice - 1][0]
cursor.execute("""
SELECT q.id, q.question, q.difficulty
FROM questions q
WHERE q.subject_id = %s
""", (subject_id,))
questions = cursor.fetchall()
if not questions:
print("No questions available in this subject.")
return
formatted_questions = [
(qid, wrap_text(question), difficulty) for qid, question, difficulty in questions
]
try:
easy_count = int(input("\nEnter number of easy questions: "))
medium_count = int(input("Enter number of medium questions: "))
hard_count = int(input("Enter number of hard questions: "))
except ValueError:
print("Invalid input. Please enter valid numbers.")
return
test_paper = (
random.sample(easy_questions, easy_count) +
random.sample(medium_questions, medium_count) +
random.sample(hard_questions, hard_count)
)
formatted_test_paper = [
(qid, wrap_text(question), difficulty) for qid, question, difficulty in test_paper
]
18
print(tabulate(formatted_test_paper, headers=["ID", "Question", "Difficulty"],
tablefmt="grid"))
def main():
"""Main function to run the JEE Question Paper Management System."""
conn = mysql.connector.connect(host="localhost", user="root", password="3804")
cursor = conn.cursor()
create_database_and_tables(cursor)
if choice == 1:
add_question(cursor, conn)
elif choice == 2:
fetch_question(cursor)
elif choice == 3:
update_question(cursor, conn)
elif choice == 4:
delete_question(cursor, conn)
elif choice == 5:
generate_test_paper(cursor)
elif choice == 6:
print("Exiting the system. Goodbye!")
break
cursor.close()
conn.close()
if __name__ == "__main__":
main()
19
OUTPUT
• Registration and Login
• Adding a Question
20
• Fetching Questions
• Updating a Question
21
• Deleting a Question
22
USES OF THE SOFTWARE
• For Students: It helps students prepare for the JEE examination by
providing a structured question bank with various difficulty levels.
They can use the system to practice questions and generate test
papers.
• For Teachers: Teachers can manage the question bank, add new
questions, update existing ones, and delete outdated questions.
23
LIMITATIONS OF THE SOURCE
CODE
• Automatic ID Update: When a question is deleted from the
database, the IDs of the remaining questions do not automatically
update. This means the IDs may not be in a sequential order,
potentially leading to inconsistencies when referencing question
IDs.
• Privacy Issues: Any user can log in and use the same database.
This leads to privacy concerns as users have access to the same set
of data. Ideally, a new database should be created for each user to
maintain individual privacy and ensure data segregation.
24
CONCLUSION
The JEE Question Paper Management System is a practical and
effective tool designed to streamline the process of managing and
generating question papers for various subjects relevant to
competitive exams like JEE. Using a MySQL database and Python
programming, the system provides functionalities that enable users to
manage questions efficiently, including adding, updating, deleting,
and fetching questions, as well as generating test papers based on
different difficulty levels.
By organizing questions into a well-structured database, the system
ensures easy access to a wide range of questions. The ability to select
questions based on subject and difficulty level allows students to
tailor their preparation to meet their needs.
The user login system, though simple, provides a basic level of
security by requiring authentication before accessing the database.
This functionality makes it suitable for multiple users, although it
could be improved in future versions by creating separate databases
for each user to enhance privacy and ensure that the data remains
segregated.
Despite its capabilities, the system does have limitations. One major
limitation is that when questions are deleted, their IDs are not
automatically updated, leading to potential issues with the sequential
order of IDs. Additionally, the system uses plain text for storing
passwords, which can be a security concern. Furthermore, since all
users share the same database, privacy issues arise, and a better
approach would be to create a new database for each user to ensure
data confidentiality.
In conclusion, the JEE Question Paper Management System provides
a reliable platform for managing and generating question papers for
students preparing for competitive exams. While the system meets the
objectives of the project, future enhancements such as password
encryption, improved privacy measures, and automatic ID updates
would improve the overall performance and security of the system.
25
BIBLIOGRAPHY
The data used in this project has been sourced from the following
reliable references:
26