A comprehensive Learning Management System built with Flask, featuring role-based access control, assignment management, rubric-based grading, messaging, calendar integration, and AI-powered study planning.
SpartanSync is a full-featured Learning Management System designed to facilitate communication and collaboration between students, teaching assistants (TAs), and instructors. The platform provides comprehensive tools for managing courses, assignments, submissions, grading, announcements, and more.
Key Highlights:
- Multi-role Support: Students, TAs, and Instructors with appropriate permissions
- Course Management: Create courses, manage enrollments, and organize content
- Assignment System: Create assignments with rubric-based grading
- Messaging: Direct messaging between users
- Calendar: View assignments on a calendar with ICS export
- AI Study Planner: OpenAI-powered personalized study plans
- Weighted Grading: Automatic grade calculation (Homework 30%, Exam 50%, Project 20%)
- Secure login/logout with session management (Flask-Login)
- Role-based access control (Student, TA, Instructor)
- User registration with role selection
- Password hashing with Werkzeug security
- Instructors create and manage courses
- Students enroll in courses via "Manage My Classes"
- Course-specific dashboards and content
- Course codes and descriptions
- Create assignments with titles, descriptions, due dates, and point values
- Category-based assignments (Homework, Exam, Project)
- Rubric-based grading with multiple criteria
- Assignment status tracking (Published, Closed)
- Allow/disable submissions toggle
- Students submit assignments with text content
- TAs and Instructors grade submissions using rubrics
- Rubric scores stored in JSON format
- Status tracking (Submitted, Graded)
- Automatic score calculation from rubric criteria
- General and course-specific announcements
- Instructor-only creation and deletion
- Chronological display with course badges
- Filtered by student enrollments
- One-on-one conversations between users
- Conversation threading with message history
- Monthly calendar view of assignments
- Color-coded assignments by course
- ICS export for Google Calendar, Outlook, Apple Calendar
- Export by month or 90-day window
- OpenAI GPT-4 integration for study plan generation
- Personalized recommendations based on assignments
- Considers due dates, point values, and user goals
- Formatted advice with time management tips
- Automatic grade calculation by category
- Configurable weights (Homework 30%, Exam 50%, Project 20%)
- Per-course grade display
- Breakdown by category with earned/possible points
- Flask: Python web framework
- Flask-Login: User session management
- Flask-SQLAlchemy: ORM for database interactions
- SQLite: Lightweight database
- WTForms: Form validation and rendering
- Jinja2: Template engine
- Tailwind CSS: Utility-first CSS framework (via CDN)
- Vanilla JavaScript: For interactive components
- OpenAI API: GPT-4 mini for study planning
- pytest: Testing framework
- pytest fixtures: Test data management
- Python 3.8+ installed
- Git (for cloning)
- OpenAI API key (optional, for AI Study Planner feature)
-
Clone the repository:
git clone <repository-url> cd SpartanSync
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
- macOS/Linux:
source venv/bin/activate - Windows:
venv\Scripts\activate
- macOS/Linux:
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables (optional, for AI features):
- Create a
.envfile in the root directory:touch .env
- Add your OpenAI API key:
OPENAI_API_KEY=your-api-key-here - Get an API key from: https://platform.openai.com/api-keys
- Create a
-
Initialize the database (automatic on first run):
# Optional: Manually create database python create_db.py
-
Activate your virtual environment (if not already activated):
source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows
-
Run the application:
python run.py # or flask run --port 5001 -
Access the application: Open your browser and navigate to:
-
Create an account:
- Visit
/createaccountor click "Create Account" on the login page - Choose your role (Student, TA, or Instructor)
- Fill in username, email, and password
- Visit
SpartanSync includes a comprehensive demo mode with pre-populated data to showcase all features without manual setup.
-
Seed the demo data:
# Using the seed script python seed_demo.py # OR using Flask CLI flask seed-demo # To reset and recreate demo data python seed_demo.py --reset flask seed-demo --reset
-
Start the server:
python run.py
-
Use Demo Login Buttons:
- Visit the login page and click one of the demo buttons:
- Student (blue) - Logs in as demo-student1
- Instructor (purple) - Logs in as demo-cs-instructor
- TA (green) - Logs in as demo-cs-ta
- Visit the login page and click one of the demo buttons:
All demo passwords are: demo
Students (5 total):
demo-student1,demo-student2,demo-student3,demo-student4,demo-student5
Instructors (5 total):
demo-physics-instructor- Teaches PHYS 101 (Introduction to Physics)demo-math-instructor- Teaches MATH 201 (Calculus II)demo-cs-instructor- Teaches CS 101 (Introduction to Programming)demo-chem-instructor- Teaches CHEM 150 (General Chemistry)demo-eng-instructor- Teaches ENG 102 (Composition and Literature)
TAs (5 total):
demo-physics-ta,demo-math-ta,demo-cs-ta,demo-chem-ta,demo-eng-ta- Each TA assists with their respective subject course
- 5 Courses: Physics, Math, CS, Chemistry, English
- 18 Assignments: 3-4 per course with varied categories (Homework, Exam, Project)
- Rubric Criteria: 2-4 criteria per assignment
- Student Enrollments: Each student enrolled in 3 courses
- Submissions: Mix of graded, submitted, and pending submissions
- 14 Announcements: Course-specific and general announcements
- 5 Conversations: Messages between students, instructors, and TAs
- Varied Due Dates: Past, current, and upcoming assignments for calendar demo
Capabilities:
- View enrolled courses and assignments
- Submit assignments
- View grades and rubric feedback
- Manage class enrollments
- View course announcements
- Send and receive messages
- Use AI Study Planner
- Export calendar to ICS
Restrictions:
- Cannot create or delete assignments
- Cannot create announcements
- Cannot grade submissions
- Cannot see other students' submissions
Capabilities:
- All student capabilities
- Grade submissions for assigned courses
- Add/edit rubric criteria
- View all submissions for assigned courses
Restrictions:
- Cannot create or delete assignments
- Cannot create or delete announcements
- Cannot create courses
- Only see courses they're assigned to
Capabilities:
- All TA capabilities
- Create and delete courses
- Create and delete assignments
- Create and delete announcements
- Full grading access to all courses they create
- View all student submissions
Full Control:
- Complete management of their courses
- Assignment publishing and unpublishing
- Course enrollment visibility
Login (/login):
- Username and password authentication
- "Remember Me" functionality
- Demo login buttons for quick access
- Error messages for invalid credentials
Registration (/createaccount):
- Username, email, and password required
- Role selection (Student, TA, Instructor)
- Duplicate username/email prevention
- Password hashing with Werkzeug
Logout (/logout):
- POST-only endpoint
- Session termination
- Redirect to login page
Student Dashboard (/dashboard):
- Assignment list filtered by enrolled courses
- Status badges (Pending, Submitted, Graded, Overdue, Closed)
- Submission status per assignment
- Quick links to assignment details
- Recent announcements
Instructor Dashboard (/dashboard):
- All created assignments
- Pending submissions count
- Quick grading access
- Upcoming assignment overview
TA Dashboard (/dashboard):
- Assignments from assigned courses
- Submissions needing grading
- Course-filtered content
Create Course (/courses/new) - Instructors only:
- Course name (e.g., "Introduction to Python")
- Course code (unique, e.g., "CS101")
- Description (optional)
View Courses (/courses):
- Browse all available courses
- Course cards with name, code, description
- Links to course detail pages
Course Detail (/courses/<id>):
- View course information
- List all course assignments with status
- View course announcements
- Grade information for enrolled students
Manage Enrollments (/classes/manage) - Students only:
- Multi-select interface
- Choose courses to display on dashboard
- Filter assignments by enrollment
- Saved to Classes table as JSON
Create Assignment (/assignments/new) - Instructors only:
- Title and description
- Due date and time picker
- Point value (0+)
- Category selection (Homework, Exam, Project)
- Course selection (optional)
- Allow/disable submissions
- Auto-creates default rubric criterion
View Assignments (/assignments):
- List all assignments (role-filtered)
- Course badges
- Due dates and point values
- Status indicators
- Category tags
Assignment Detail (/assignments/<id>):
- Full description
- Due date countdown
- Course information
- Points and category
- Rubric criteria display
- Submission form (students)
- Grading interface (instructors/TAs)
Rubric Management:
- Add criteria to assignments
- Define title, description, max points
- Flexible point distribution
- Edit/delete criteria (instructors/TAs)
Delete Assignment - Instructors only:
- Cascade deletion (removes submissions and rubrics)
- Confirmation required
Submit Assignment (Students):
- Text submission area
- Update before due date
- View submission status
- See graded scores and rubric feedback
Grade Submissions (Instructors/TAs):
- View all student submissions
- Rubric-based grading interface
- Score each criterion (0 to max_points)
- Automatic total calculation
- Mark as "Graded"
- Rubric scores stored in JSON
Submission Status:
- Submitted: Awaiting grading
- Graded: Score and feedback available
- Pending: Not yet submitted
- Overdue: Past due date, not submitted
- Closed: Submissions disabled
Create Announcement (/announcements/new) - Instructors only:
- Title and body
- Course targeting (specific or general)
- Created_at timestamp
- Author tracking
View Announcements (/announcements):
- List all announcements (course-filtered for students)
- Detail view for each announcement
- Course badges
- Creation date and author
- Chronological ordering
Delete Announcement - Instructors only:
- Remove outdated announcements
- Accessible from list/detail views
Inbox (/messages):
- List all conversations
- Last message preview
- Sorted by most recent activity
- Participant names
Create Conversation (/messages/new):
- Select recipient from user list
- Optional conversation title
- Send initial message
- One-to-one conversations
View Conversation (/messages/<id>):
- Full message thread
- Chronological ordering
- Sender information
Send Message:
- Reply to existing conversations
- Multi-message support
- Real-time message display
Calendar View (/calendar):
- Interactive monthly calendar
- Navigate between months
- Color-coded assignments by course
- Event listings on each day
- Multi-day event support
- Responsive grid layout
ICS Export (/calendar/export):
- Download assignments as
.icsfile - Export specific month or 90-day window
- Full iCalendar format (VCALENDAR, VEVENT)
- Compatible with major calendar applications:
- Google Calendar
- Outlook
- Apple Calendar
- Thunderbird
- Includes assignment title, description, due date
- Respects student enrollments
Study Plan Generation (/study-plan) - Students only:
- OpenAI GPT-4 mini integration
- Personalized study schedules
- Considers:
- All unsubmitted assignments
- Due dates
- Point values
- User's topic/area of focus
- Returns formatted advice:
- Study plan for completing assignments
- Time management tips
- Organization strategies
- References to SpartanSync features
- Error handling if API unavailable
Usage:
- Enter focus area (e.g., "preparing for exams", "managing workload")
- Click "Generate Study Plan"
- Receive AI-generated personalized advice
Grade Calculation:
- Category Weights:
- Homework: 30%
- Exam: 50%
- Project: 20%
- Per-category average calculation
- Percentage conversion (earned/possible)
- Weighted final grade computation
- Handles partial grades
Display Locations:
- Course detail pages (enrolled students)
- Home page course cards (enrolled students)
- Dashboard references
Grade Breakdown:
- Shows total earned/possible points
- Category-wise breakdown
- Percentage per category
- Final weighted grade
OPENAI_API_KEY=your-api-key-here
SpartanSync includes comprehensive test coverage using pytest.
# Activate virtual environment
source venv/bin/activate
# Run all tests
pytest
# Run with verbose output
pytest -v
# Run specific test file
pytest tests/test_models.py
# Run with coverage report
pytest --cov=app tests/test_models.py: User, Course, Assignment, Submission modelstest_routes.py: Core application routestest_forms.py: Form validationtest_messages.py: Messaging systemtest_calendar.py: Calendar and ICS export
Located in tests/conftest.py:
app: Flask application with test configclient: Test client for making requestsdb: Database instancestudent_user,instructor_user,ta_user: User fixturescourse,multiple_courses: Course fixturesassignment,multiple_assignments: Assignment fixturessubmission: Submission fixtureannouncement: Announcement fixturerubric_criterion: Rubric fixture
File: app/main/gpt_client.py
Function: generate_study_plan(prompt: str) -> str
- Uses GPT-4 mini model
- Constructs prompt from assignment data
- Returns formatted study advice
Problem: Database not created
# Solution: Manually create database
python create_db.pyProblem: Database locked error
# Solution: Close all connections and restart server
# Kill any running Flask processes
pkill -f flask
# Restart server
python run.pyProblem: Port already in use
# Solution: Use a different port
flask run --port 5002
# OR
python run.py # Configured for port 5001Problem: ModuleNotFoundError
# Solution: Ensure virtual environment is activated
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
# Reinstall dependencies
pip install -r requirements.txtProblem: Demo users already exist
# Solution: Reset demo data
python seed_demo.py --reset
# OR
flask seed-demo --resetProblem: Study planner not working
# Check if .env file exists with API key
cat .env
# Verify API key is loaded
python -c "import os; from dotenv import load_dotenv; load_dotenv(); print(os.getenv('OPENAI_API_KEY'))"- Create database model in
app/models.py - Create form in
app/forms.py - Add route in appropriate blueprint (
app/auth/routes.pyorapp/main/routes.py) - Create template in
app/templates/or blueprint templates - Add tests in
tests/ - Update demo data in
seed_demo.pyif needed
Currently using SQLite with manual schema updates. To modify database:
- Edit models in
app/models.py - Delete
app/app.db - Run
python create_db.py - Reseed demo data:
python seed_demo.py
- Login:
/login - Dashboard:
/dashboard - Home:
/home - Courses:
/courses - Assignments:
/assignments - Announcements:
/announcements - Messages:
/messages - Calendar:
/calendar - Study Plan:
/study-plan(students) - Manage Classes:
/classes/manage(students)
flask run # Start development server
flask seed-demo # Seed demo data
flask seed-demo --reset # Reset and reseed demo datapython seed_demo.py # Seed demo data
python run.py # Start server
# Visit http://localhost:5001/login
# Click "Student", "Instructor", or "TA" button