Skip to content

milot-dev/gradebook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gradebook CLI

A Command Line Interface (CLI) application for managing students, courses, enrollments, and grades.

Built with Python following best practices in clean architecture and modular design.


Features

  • Add students and courses
  • Enroll students in courses
  • Add and validate grades (0-100)
  • Calculate course averages and student GPA
  • Persistent storage using JSON file
  • Input validation with user friendly error messages
  • Structured logging
  • Unit tests with mocking
  • Sample data seeding

Setup Instructions

1. Create a Virtual Environment (Recommended)

Create virtual environment

python -m venv venv

Activate on Windows

venv\Scripts\activate

Activate on macOS / Linux

source venv/bin/activate

2. Seed Sample Data

Run the seeding script to populate initial data:

python scripts/seed.py

This will create:

  • 3 sample students
  • 2 sample courses
  • Several enrollments with grades

Usage Examples

Basic Commands

# Add a new student
python main.py add-student "Milot Hyseni"

# Add a new course
python main.py add-course CS101 "Introduction to Programming"

# Enroll a student in a course
python main.py enroll 1 CS101

# Add a grade to a student's course
python main.py add-grade 1 CS101 92

# List all data
python main.py list-students
python main.py list-courses
python main.py list-enrollments

# View averages
python main.py avg 1 CS101
python main.py gpa 1
Example Outputs
Student created: Milot Hyseni with ID: 1

Grade 92 added successfully for student 1 in CS101

Average for student 1 in CS101: 89.50

GPA for student 1: 87.25

All Available Commands

python main.py add-student "Student Name"
python main.py add-course CODE "Course Title"
python main.py enroll STUDENT_ID COURSE_CODE
python main.py add-grade STUDENT_ID COURSE_CODE GRADE
python main.py list-students
python main.py list-courses
python main.py list-enrollments
python main.py avg STUDENT_ID COURSE_CODE
python main.py gpa STUDENT_ID

Running Tests

python -m unittest tests.test_service -v

Logging

All important events (CLI start/stop, data loading/saving, errors) are logged to:

textlogs/app.log

Design Decisions & Limitations

Design Decisions

  • Layered Architecture: Clear separation between Models, Storage, Business Logic (Service), Utils, and CLI layers for better maintainability and testability.
  • Relative Imports: Demonstrated inside the package as required.
  • Input Validation: Handled at multiple levels (models, utils, and argparse) with clear error messages.
  • Testing Strategy: Unit tests focus on the service layer using mocking to isolate business logic from file I/O.
  • Logging: Centralized using Python’s logging module for better debugging.

Limitations

  • Uses simple JSON file storage (not suitable for concurrent access or large scale use).
  • No support for deleting or updating students/courses/grades.
  • GPA calculation is a simple average of course averages (no credit hour weighting).
  • Single user application only.
  • No advanced reporting or export features.
Project Structure
textGradebook_CLI/
├── main.py
├── README.md
├── gradebook/
│   ├── __init__.py
│   ├── models.py
│   ├── service.py
│   ├── storage.py
│   └── utils.py
├── scripts/
│   └── seed.py
├── tests/
│   └── test_service.py
├── data/           # Auto created (gradebook.json)
└── logs/           # Auto created (app.log)

Technologies Used

  • Python 3 Standard Library only (argparse, json, logging, unittest, os)

No external dependencies required.

Made with ❤️ for learning clean Python architecture, testing, and packaging.

About

A Command Line Interface (CLI) application for managing students, courses, enrollments, and grades.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages