CLI-based quiz maker application with categories and import/export support.
Project description
Quiz Maker 2 (QM2) - Interactive Terminal Quiz Application
Overview
Quiz Maker 2 (QM2) is a robust, interactive terminal-based quiz engine built with Python. It is designed for developers and power users who want a professional CLI experience for learning and testing knowledge. It features a modern UI, extensive import/export capabilities, and a high-performance core.
Key Features
- 4 Question Types: Multiple Choice, True/False, Fill-in-the-blank, Matching
- Timed Quiz Sessions: Customizable timeout settings with real-time feedback
- Flashcards Mode: Study mode for reviewing questions without scoring
- Score Tracking: Comprehensive statistics and performance analytics
- Category Management: Organize questions into hierarchical categories
- Import/Export: Convert between CSV and JSON formats
- Remote Import: Download quiz files directly from URLs
- Rich Terminal UI: Beautiful, colored interface using Rich library
- Performance Optimized: Caching system for large question sets
- Cross-Platform: Works on Windows, macOS, and Linux
Quick Start
pip install qm2
qm2
Or install from source:
git clone https://github.com/ahalvadzija/qm2.git
cd qm2
pip install -e .
Screenshots
Quiz Features
Tools & Help
Installation
From PyPI (Recommended)
pip install qm2
From Source
git clone https://github.com/ahalvadzija/qm2.git
cd qm2
pip install -e .
Development Installation
git clone https://github.com/ahalvadzija/qm2.git
cd qm2
pip install -e ".[dev]"
Docker Installation (Alternative)
If you prefer to run QM2 in an isolated environment without installing Python locally:
- Build the image:
docker build -t qm2 .
Run the application: Since QM2 is interactive, you must use the -it flags:
docker run -it qm2
Persist your data: To keep your quiz data and scores after the container stops, mount a local directory: Bash
docker run -it -v qm2_data:/root/.local/share/qm2 qm2
Usage
Basic Usage
# Start the application
qm2
# Or if installed from source
python -m qm2
Command Line Options
# Show help
qm2 --help
# Show version
qm2 --version
# Run with specific data directory
qm2 --data-dir /path/to/data
Features in Detail
Question Types
- Multiple Choice: Question + correct answer + 3 wrong answers
- True/False: Statement + boolean answer
- Fill-in-the-blank: Question with blank + correct answer
- Matching: Items to match with correct pairs
Category Management
- Create hierarchical categories (e.g.,
programming/python/basics) - Rename and delete categories
- Automatic directory structure creation
Import/Export Capabilities
- CSV ↔ JSON: Bidirectional conversion
- Template Generation: Create starter templates
- Remote Import: Download from URLs
- Bulk Operations: Manage multiple files efficiently
Performance Features
- Caching System: Optimized for large question sets
- Memory Management: Automatic cache cleanup
- Fast Loading: Sub-second load times for thousands of questions
Project Structure
qm2/
├── src/qm2/ # Core application package
│ ├── core/ # Business logic (engine, questions, scores)
│ ├── ui/ # Rich terminal user interface
│ ├── utils/ # File I/O and helper utilities
│ └── __main__.py # CLI entry point
├── tests/ # Extensive test suite (tests)
│ ├── test_engine.py # Core logic benchmarks
│ ├── test_performance.py # Speed & stress tests
│ └── ... # App, UI, and integration tests
├── docs/ # MkDocs documentation source
│ ├── index.md # Homepage
│ ├── guide.md # User guide
│ └── reference.md # Technical reference
├── examples/ # Sample JSON/CSV question sets
├── Dockerfile # Docker container configuration
├── .dockerignore # Docker build exclusions
├── mkdocs.yml # Documentation site configuration
├── pyproject.toml # Build system and dependencies
├── requirements.txt # Development dependencies
└── README.md # Project overview and quick start
Quality Assurance & Performance
Reliability is at the heart of QM2. The project maintains an 86% coverage rate backed by a massive suite of individual tests. CI/CD pipeline ensures that every release is battle-tested.
Test Coverage Breakdown
- App & UI (95+ tests): Comprehensive navigation testing including brute force menu traversal and submenu logic.
- Engine & Core (45+ tests): Validation of all question types, session handling, and flashcards mode.
- Validation & Security (40+ tests): Deep CSV/JSON schema validation and safe remote file importing.
- Data & IO (35+ tests): Cross-platform path handling, concurrent file access, and encoding resilience.
- Performance (12+ tests): Stress testing with large datasets and cache optimization benchmarks.
Performance Benchmarks
QM2 is engineered for high-speed interactions and efficient resource management, verified by a dedicated performance suite:
- Benchmarked Speed: Processes 1,000+ questions in < 1 second, ensuring no lag during large quiz sessions.
- Intelligent Caching: Implements a caching layer that makes subsequent data loads 10x faster.
- Memory Efficiency: Automatic cache cleanup prevents memory leaks during long-running sessions.
- Thread Safety: Verified safe concurrent file access, preventing data corruption during simultaneous read/write operations.
Performance Testing (tests/test_performance.py)
- Execution: 12 specialized performance tests passed in 2.11s.
- Coverage focus: Validated
core/engine.pyandutils/files.pyfor speed bottlenecks.
Core Engine Testing (tests/test_engine.py)
- Execution: 23 core logic tests passed in 1.34s.
- Coverage: High coverage (68%) of
src/qm2/core/engine.py, ensuring question logic and scoring are flawless.
How to Run Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=qm2
# Run specific test categories
pytest tests/test_engine.py # Core engine tests
pytest tests/test_questions.py # Question management tests
pytest tests/test_files.py # File operations tests
pytest tests/test_scores.py # Score tracking tests
pytest tests/test_performance.py # Performance tests
Configuration
QM2 uses platformdirs for cross-platform data storage:
- Linux:
~/.local/share/qm2/ - macOS:
~/Library/Application Support/qm2/ - Windows:
%APPDATA%\qm2\
Environment Variables
# Custom data directory
export QM2_DATA_DIR="/path/to/custom/data"
# Disable colors
export NO_COLOR=1
Question Format
JSON Format
[
{
"type": "multiple",
"question": "What is the capital of France?",
"correct": "Paris",
"wrong_answers": ["Rome", "Berlin", "Madrid"]
},
{
"type": "truefalse",
"question": "Python is a programming language.",
"correct": "True",
"wrong_answers": ["False"]
},
{
"type": "fillin",
"question": "The capital of Japan is ______.",
"correct": "Tokyo",
"wrong_answers": []
},
{
"type": "match",
"question": "Match programming languages with their types",
"pairs": {
"left": ["Python", "JavaScript", "C++"],
"right": ["Interpreted", "Web scripting", "Compiled"],
"answers": { "a": "1", "b": "2", "c": "3" }
}
}
]
CSV Format
type,question,correct,wrong_answers,left,right,answers
multiple,What is the capital of France?,Paris,"Rome,Berlin,Madrid",,,
truefalse,The Sun is a star.,True,False,,,
fillin,The capital of Japan is ______.,Tokyo,,,,
match,Match technologies,,,Python|HTML,Programming language|Markup language,"a:1,b:2"
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
git clone https://github.com/ahalvadzija/qm2.git
cd qm2
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
Running Tests
pytest tests/ -v
pytest --cov=qm2 tests/
Code Style
black src/ tests/
isort src/ tests/
flake8 src/ tests/
License
This project is licensed under the MIT License - see the LICENSE file for details.
💖 Acknowledgments
QM2 wouldn't be as beautiful or interactive without these amazing open-source projects:
- Rich – Powering the sleek terminal visuals, tables, and progress feedback.
- Questionary – Providing the intuitive, user-friendly interactive prompts.
Support
- Email: halvadzija.adnan@gmail.com
- Issues: GitHub Issues
Links
- PyPI: https://pypi.org/project/qm2/
- GitHub: https://github.com/ahalvadzija/qm2
- Documentation: https://ahalvadzija.github.io/qm2
Created by: Adnan Halvadžija
⭐ If you find this project useful, please give it a star on GitHub!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qm2-1.0.25.tar.gz.
File metadata
- Download URL: qm2-1.0.25.tar.gz
- Upload date:
- Size: 78.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68655aec18429c45c86975dd244bd89457606bef02ebd037b4436ff7c2acb757
|
|
| MD5 |
1ab14dd1cbd148fca2b76e561e96bd56
|
|
| BLAKE2b-256 |
cd85ef01f3cd8ee491fe036f0a2080e5cec75857e1c337766df2e009dd7b3b49
|
Provenance
The following attestation bundles were made for qm2-1.0.25.tar.gz:
Publisher:
pipeline.yml on ahalvadzija/qm2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qm2-1.0.25.tar.gz -
Subject digest:
68655aec18429c45c86975dd244bd89457606bef02ebd037b4436ff7c2acb757 - Sigstore transparency entry: 956295277
- Sigstore integration time:
-
Permalink:
ahalvadzija/qm2@d73e91f1810d757e323a5ded8fab665ceddedfe6 -
Branch / Tag:
refs/tags/v1.0.25 - Owner: https://github.com/ahalvadzija
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yml@d73e91f1810d757e323a5ded8fab665ceddedfe6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file qm2-1.0.25-py3-none-any.whl.
File metadata
- Download URL: qm2-1.0.25-py3-none-any.whl
- Upload date:
- Size: 37.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55f3c16d9ec764eef80bad89e3b194423245a7a1cc00983d2ba65f9cef0d917f
|
|
| MD5 |
9488d7b969d67698ea1475ca3c39e45e
|
|
| BLAKE2b-256 |
ccbb43faf4c3ee9e14b84af7183999108e8cee153d3f10b096fedac230619316
|
Provenance
The following attestation bundles were made for qm2-1.0.25-py3-none-any.whl:
Publisher:
pipeline.yml on ahalvadzija/qm2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qm2-1.0.25-py3-none-any.whl -
Subject digest:
55f3c16d9ec764eef80bad89e3b194423245a7a1cc00983d2ba65f9cef0d917f - Sigstore transparency entry: 956295280
- Sigstore integration time:
-
Permalink:
ahalvadzija/qm2@d73e91f1810d757e323a5ded8fab665ceddedfe6 -
Branch / Tag:
refs/tags/v1.0.25 - Owner: https://github.com/ahalvadzija
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yml@d73e91f1810d757e323a5ded8fab665ceddedfe6 -
Trigger Event:
push
-
Statement type: