A Flask-based web application that allows users to upload PDF or DOCX lecture notes, extract text content, create interactive quizzes, and take assessments with detailed feedback and scoring.
- Multi-format Support: Upload PDF and DOCX files
- Text Extraction: Automatically extracts text content from uploaded documents
- File Validation: Secure file handling with type and size validation
- Preview: Display extracted text before quiz creation
- Interactive Creation: Create multiple-choice questions with 4 options
- Question Types: Support for text-based questions with explanations
- Flexible Storage: Save quizzes as JSON files for easy management
- Quiz Listing: View all available quizzes with metadata
- Responsive Design: Mobile-friendly interface
- Progress Tracking: Real-time progress bar and question counter
- Timer: Track time spent on quiz
- User Information: Optional student details collection
- Navigation: Smooth user experience with validation
- Detailed Scoring: Comprehensive scoring with percentage and statistics
- Question-by-Question Review: See correct/incorrect answers with explanations
- Performance Analysis: Personalized feedback and improvement recommendations
- Printable Results: Generate PDF-ready result summaries
- Session Management: Unique session IDs for result tracking
- Python 3.7 or higher
- pip (Python package installer)
-
Clone the repository
git clone https://github.com/yourusername/horizon-exam-bot.git cd horizon-exam-bot -
Create a virtual environment (recommended)
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run the application
python app.py
-
Access the application Open your web browser and navigate to
http://localhost:5000
horizon-exam-bot/
├── app.py # Main Flask application
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── templates/ # HTML templates
│ ├── index.html # Home page with upload and quiz creation
│ ├── quiz.html # Quiz taking interface
│ └── results.html # Results display page
├── uploads/ # Temporary file uploads (auto-created)
├── data/ # Quiz storage (auto-created)
│ └── quiz_*.json # Individual quiz files
└── static/ (optional) # Static assets (CSS, JS, images)
POST /api/upload- Upload and extract text from PDF/DOCX files
POST /api/quiz/create- Create a new quizGET /api/quiz/<quiz_id>- Get quiz questions for takingGET /api/quiz/list- List all available quizzes
POST /api/quiz/<quiz_id>/submit- Submit quiz answersGET /api/session/<session_id>/results- Get detailed results
GET /- Main application pageGET /quiz/<quiz_id>- Quiz taking pageGET /results/<session_id>- Results display page
- Visit the home page
- Click on the upload area or drag and drop a PDF/DOCX file
- Wait for text extraction to complete
- Review the extracted text
- After uploading a document, scroll to the quiz creation section
- Enter a quiz title and optional description
- Add questions using the "Add Question" button
- For each question:
- Enter the question text
- Add four multiple-choice options (A, B, C, D)
- Select the correct answer
- Optionally add an explanation
- Click "Create Quiz" to save
- From the home page, click "Take Quiz" on any available quiz
- Answer all questions by selecting the appropriate options
- Optionally enter your name and email
- Click "Submit Quiz" when complete
- After submitting a quiz, you'll be redirected to the results page
- View your score, detailed question review, and performance analysis
- Print or save results using the print button
You can set the following environment variables to customize the application:
FLASK_ENV=development # Set to 'production' for production
FLASK_DEBUG=True # Enable debug mode
SECRET_KEY=your-secret-key # Set a secure secret key for production
UPLOAD_FOLDER=uploads # Custom upload directory
MAX_CONTENT_LENGTH=16777216 # Max file size (16MB default)The default maximum file size is 16MB. To change this, modify the MAX_CONTENT_LENGTH configuration in app.py:
app.config['MAX_CONTENT_LENGTH'] = 32 * 1024 * 1024 # 32MB- File Type Validation: Only allows PDF and DOCX files
- Secure Filename Handling: Uses Werkzeug's secure_filename
- File Size Limits: Prevents oversized file uploads
- Temporary File Cleanup: Automatically removes uploaded files after processing
- Input Validation: Validates all form inputs and API requests
The application is designed with modularity in mind:
- DocumentProcessor: Handles text extraction from various file formats
- QuizManager: Manages quiz creation, storage, and scoring
- Extensible Design: Easy to add new file types or question formats
- JSON-based: Quizzes stored as JSON files for simplicity
- Session Management: In-memory session storage (easily replaceable with database)
- Scalable: Can be extended to use databases like PostgreSQL or MongoDB
- Bootstrap 5: Responsive, modern UI framework
- Vanilla JavaScript: No complex frameworks for better performance
- Progressive Enhancement: Works without JavaScript for basic functionality
-
Set production environment
export FLASK_ENV=production export SECRET_KEY=your-secure-secret-key
-
Use a production WSGI server
pip install gunicorn gunicorn -w 4 -b 0.0.0.0:5000 app:app
-
Configure reverse proxy (Nginx example)
server { listen 80; server_name your-domain.com; location / { proxy_pass http://127.0.0.1:5000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
Create a Dockerfile:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]- Database Integration: PostgreSQL/MongoDB support
- User Authentication: Login system with user accounts
- Advanced Question Types: True/false, fill-in-the-blank, essay questions
- Image Support: Questions and answers with images
- Analytics Dashboard: Detailed analytics for educators
- Bulk Quiz Import: Import questions from CSV/Excel
- Quiz Categories: Organize quizzes by subject/topic
- Collaborative Features: Share quizzes between users
- Mobile App: Native mobile applications
- AI Integration: Auto-generate questions from text
- Caching: Redis for improved performance
- Background Tasks: Celery for long-running processes
- API Rate Limiting: Prevent abuse
- Advanced Security: OAuth, JWT tokens
- Monitoring: Application performance monitoring
- Backup System: Automated quiz backup
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Please use the GitHub Issues page to report bugs or request features.
For support and questions:
- Create an issue on GitHub
- Email: support@horizonexambot.com
- Documentation: Wiki
- Flask framework and community
- Bootstrap for the responsive UI
- PyPDF2 and python-docx for document processing
- All contributors and users of this project
Happy Learning! 📚✨