A Python-based tool to generate customizable question papers in PDF format with support for multiple question types.
- Object-Oriented Design: Clean, maintainable code using OOP principles
- Error Handling: Comprehensive error handling and validation
- Multiple Question Types: Support for Short Answer and Long Answer questions
- Flexible Input: Load questions from files or enter manually
- Random Selection: Automatically select random questions from question banks
- PDF Generation: Professional PDF output with customizable headers and formatting
- Logging: Built-in logging for debugging and tracking
- Python 3.7 or higher
- pip (Python package manager)
pip install reportlab coloramaRun the program interactively:
python3 quespm.pyFollow the prompts to:
- Enter question paper details (title, subject, marks, time)
- Optionally add a logo image
- Select question types
- Load questions from files or enter manually
- Generate the PDF
Create text files with questions in Python list format:
sample_short_questions.txt:
["What is Python", "Define OOP", "Explain inheritance", "What is polymorphism"]sample_long_questions.txt:
["Explain the concept of OOP with examples", "Discuss SOLID principles in software design"]You can also use the classes programmatically:
from quespm import QuestionPaperMaker
# Create instance
maker = QuestionPaperMaker()
# Set configuration
maker.config = {
'filename': 'my_exam.pdf',
'title': 'Final Exam',
'subtitle': 'Semester 1',
'marks': 100,
'time': 180,
'subject': 'Computer Science',
'logo_path': None
}
# Add questions
maker.question_manager.add_short_answer_questions([
"Question 1",
"Question 2"
])
# Generate PDF
maker.generate_pdf()quespm.py- Main Python file with OOP implementationsample_short_questions.txt- Example short answer questionssample_long_questions.txt- Example long answer questionsexample_usage.py- Example of programmatic usagetest_quespm.py- Test suite*.ttf- Font files for PDF generation (optional)
Main class that orchestrates the entire process.
Manages question loading, selection, and storage.
Handles PDF creation and formatting.
The application includes custom exceptions:
ConfigurationError- Invalid configurationQuestionError- Issues with questionsPDFGenerationError- PDF creation failures
The repository previously contained Jupyter notebook files (.ipynb) which were the original implementation. These have been removed as they were deprecated. The quespm.py file is now the only supported version with:
- Better code organization
- Error handling
- OOP design
- Improved maintainability
For historical reference, the old notebook files can be found in the git history.
Feel free to submit issues and enhancement requests!
This project is open source and available for educational purposes.