A Flask-based web application that automatically generates quizzes from PDF documents using Natural Language Processing and Machine Learning techniques.
- PDF Text Extraction: Automatically extracts text content from uploaded PDF documents
- AI-Powered Quiz Generation: Creates three types of quizzes:
- Multiple Choice Questions (MCQ)
- Fill-in-the-blank questions
- Subjective questions
- Smart Answer Evaluation: Uses semantic similarity for answer checking
- Performance Analytics: Visual charts showing quiz performance over time
- User registration and authentication
- Password reset with OTP verification via email
- Session management
- Quiz history tracking
- PDF Result Export: Download quiz results as formatted PDF
- Email Notifications: OTP-based password recovery
- Performance Dashboard: Graphical representation of quiz scores
- Responsive Web Interface: Modern HTML/CSS templates
- Flask: Web framework
- SQLite: Database for user data and quiz results
- PyMuPDF (fitz): PDF text extraction
- NLTK: Natural language processing
- Transformers: Hugging Face models for question generation
- Sentence Transformers: Semantic similarity checking
- Flask-Mail: Email functionality
- HTML5/CSS3
- JavaScript
- Responsive design
- Question Generation: Valhalla T5-small model
- Semantic Similarity: SentenceTransformer all-MiniLM-L6-v2
- NLP Processing: NLTK for tokenization and POS tagging
- Python 3.8 or higher
- pip (Python package installer)
- Gmail account for email functionality (or modify email settings)
-
Clone the repository
git clone https://github.com/Mru-preeti/python_project_sem4.git cd python_project_sem4-1 -
Create a virtual environment
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Download NLTK data
python -c "import nltk; nltk.download('averaged_perceptron_tagger'); nltk.download('punkt'); nltk.download('wordnet'); nltk.download('stopwords')"
-
Configure email settings
- Update the email configuration in
app.py:
app.config['MAIL_USERNAME'] = 'your-email@gmail.com' app.config['MAIL_PASSWORD'] = 'your-app-password'
- Update the email configuration in
-
Initialize the database
python database.py
-
Start the Flask application
python app.py
-
Access the application
- Open your web browser and go to
http://localhost:5000
- Open your web browser and go to
-
Build the Docker image
docker build -t eduextract . -
Run the container
docker run -p 5000:5000 eduextract
With environment variables:
docker run -p 5000:5000 \
-e FLASK_ENV=production \
-e MAIL_USERNAME=your-email@gmail.com \
-e MAIL_PASSWORD=your-app-password \
eduextractWith volume mounting for persistent data:
docker run -p 5000:5000 \
-v $(pwd)/uploads:/app/uploads \
-v $(pwd)/*.db:/app/ \
eduextractDocker Compose (create docker-compose.yml):
version: "3.8"
services:
eduextract:
build: .
ports:
- "5000:5000"
volumes:
- ./uploads:/app/uploads
- ./Login_data.db:/app/Login_data.db
environment:
- FLASK_ENV=production
- MAIL_USERNAME=your-email@gmail.com
- MAIL_PASSWORD=your-app-password- Pre-built NLTK data: NLTK datasets are downloaded during image build
- System dependencies: Includes necessary system packages for ML libraries
- Optimized caching: Dockerfile layers optimized for faster rebuilds
- Production ready: Configured for production deployment
python_project_sem4-1/
βββ app.py # Main Flask application
βββ database.py # Database initialization
βββ requirements.txt # Python dependencies
βββ dockerfile # Docker configuration
βββ README.md # Project documentation
βββ static/ # CSS, JS, and image files
β βββ styles.css
β βββ quiz.css
β βββ script.js
β βββ ...
βββ templates/ # HTML templates
β βββ login.html
β βββ home.html
β βββ quiz.html
β βββ result.html
β βββ ...
βββ uploads/ # PDF file storage
βββ *.db # SQLite databases
- Register with username, email, and password
- Login with your credentials
- Use forgot password feature if needed
- Navigate to the quiz creation page
- Upload a PDF document
- Select quiz type (MCQ, Fill-in-blank, or Subjective)
- The system will automatically generate 5 questions
- Answer the generated questions
- Submit your responses
- View immediate results with detailed feedback
- View quiz history
- Check performance analytics
- Download results as PDF
Configure SMTP settings in app.py:
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'your-email@gmail.com'
app.config['MAIL_PASSWORD'] = 'your-app-password'The application uses SQLite by default. Database files:
Login_data.db: User authentication and quiz resultsquiz.db: Quiz-specific datayour_database.db: Additional data storage
-
Question Generation:
valhalla/t5-small-qg-hl- Generates questions from text passages
- Optimized for educational content
-
Semantic Similarity:
all-MiniLM-L6-v2- Evaluates answer correctness
- Provides similarity scores for subjective answers
- Password validation with complexity requirements
- Session management
- OTP-based password recovery
- SQL injection prevention with parameterized queries
-
Model Download Errors
- Ensure stable internet connection
- Models are downloaded automatically on first use
-
Email Not Sending
- Check Gmail app password configuration
- Verify SMTP settings
-
PDF Processing Errors
- Ensure PDF is text-based (not scanned images)
- Check file size limitations
Check console output for detailed error messages and debugging information.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Team Members: Mru-preeti and contributors
- Project: Semester 4 Python Project
- Hugging Face for pre-trained models
- NLTK for natural language processing tools
- Flask community for excellent documentation
- PyMuPDF for PDF processing capabilities
For support and questions:
- Create an issue on GitHub
- Contact: srushtiprajakt.t@gmail.com
Note: Make sure to update email credentials and other sensitive configuration before deploying to production.