A lightweight CLI tool for managing student records and grades, built with Python.
- Lesson-based grading — grades are now associated with specific lessons (e.g.,
Math,Science); each lesson stores its own grade list - Updated data format — student lines now use
id | name | Lesson1: g1,g2 | Lesson2: g3format with per-lesson segments add-gradeupdated — now requires a lesson name:add-grade <id> <lesson> <grade>; appends to existing lesson or creates a new segmentdelete-gradeupdated — now requires a lesson name:delete-grade <id> <lesson> <grade>; removes the lesson segment if no grades remainchange-gradeupdated — now requires a lesson name:change-grade <id> <lesson> <old> <new>listupdated — displays per-lesson grades and averages for each studentstudent-infoupdated — shows per-lesson breakdown with grades and averagesreportupdated — markdown report table now includes a LESSON column with per-lesson rows- Lesson validation — lesson names must contain only alphabetic characters
- Test suite expanded — from 42 to 49 tests covering lesson-based operations and edge cases
clear-datacommand — bulk deletion of all student records with Y/N confirmation promptclear-logcommand — ability to clear the activity log- Activity logging — all operations are automatically recorded to
log.txtwith timestamps and status (SUCCESS,ERROR,INFO) helpsystem — built-in command reference with per-command detailed usage (help <command>)- Colored output — integrated
coloramafor color-coded terminal messages (green/red/cyan/yellow/magenta) - Descriptive error messages — all errors now use an operation-prefixed format (e.g.,
Adding student failed: ...) - DRY refactoring — codebase-wide restructuring with shared helpers, constants, and dispatch tables across
utils.py,main.py, andtest.py
# Initialize the system
python main.py init
# Add a student
python main.py add-student 101 Berke
# Add grades under specific lessons
python main.py add-grade 101 Math 85
python main.py add-grade 101 Math 90
python main.py add-grade 101 Science 75
# View records
python main.py list
python main.py student-info 101
# Generate a markdown report
python main.py reportRun python main.py help to see all available commands.
| Command | Usage | Description |
|---|---|---|
init |
python main.py init |
Initializes the system and creates storage |
add-student |
python main.py add-student <id> <name> |
Registers a new student |
add-grade |
python main.py add-grade <id> <lesson> <grade> |
Adds a grade (0–100) under a lesson |
delete-student |
python main.py delete-student <id> |
Removes a student and all associated data |
delete-grade |
python main.py delete-grade <id> <lesson> <grade> |
Removes a specific grade from a lesson |
change-grade |
python main.py change-grade <id> <lesson> <old> <new> |
Replaces an existing grade in a lesson |
list |
python main.py list |
Lists all students with per-lesson grades and averages |
student-info |
python main.py student-info <id> |
Displays detailed per-lesson info for a student |
report |
python main.py report |
Generates a formatted Markdown report with lesson columns |
clear-data |
python main.py clear-data |
Deletes all student records (requires confirmation) |
clear-log |
python main.py clear-log |
Clears the activity log |
help |
python main.py help [command] |
Displays usage instructions |
minigrades/
├── main.py # CLI entry point
├── utils.py # Core functions and helpers
├── test.py # Pytest test suite (49 tests)
├── SPEC.txt # Formal specification
├── README.md
└── .minigrades/ # Runtime storage (generated by init)
├── data.txt # Student records
├── report.md # Generated report
└── log.txt # Activity log
python -m pytest test.py -vAll operations are covered with 49 tests, including edge cases for input validation, lesson validation, duplicate detection, and error handling.
- Python 3.13+
- colorama — colored terminal output
pip install coloramaStudent data is stored in .minigrades/data.txt as pipe-delimited records (ID | Name | Lesson1: g1,g2 | Lesson2: g3). Each lesson has its own segment with a colon-separated grade list. Every operation is logged to log.txt with a timestamp and status. The report command generates a Markdown table at .minigrades/report.md with per-lesson rows.
All averages are displayed with 2 decimal precision. Grades are maintained in insertion order.