feat(courses): add learner progress snapshot API (closes #169)#269
Merged
Nabeelahh merged 2 commits intoJun 30, 2026
Merged
Conversation
Adds a ProgressModule under the courses feature that exposes aggregated snapshot data for a learner across every course they have touched, satisfying issue BlockDash-Studios#169. Endpoints (all under /courses/progress): - GET snapshot/:userId full snapshot per learner - GET snapshot/:userId/course/:courseId single-course snapshot - POST :userId/courses register enrollment + totals - PUT :userId/courses/:courseId/lessons record a lesson completion - PUT :userId/courses/:courseId/tasks record a task completion - DELETE :userId reset learner progress The ProgressService keeps an in-memory learner -> course[Set/Map] store and hydrates course metadata via CourseService. Completion percentage uses a weighted 70/30 lesson/task split and the snapshot sorts touched courses first with active work at the top. 21 unit tests cover empty snapshots, idempotent completions, auto-registration, status transitions, learner isolation, sort order, deleted-course handling, the firstCompletedLessonId hint, and NotFoundException paths. Closes BlockDash-Studios#169
|
@otobongdev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a learner-facing course progress snapshot API under the courses feature (
BackendAcademy/src/courses/). Consumers can fetch an aggregated snapshot of a learner's progress across every course they have touched, or drill into a single course. Closes #169.What's new
A new
ProgressModulemounted atBackendAcademy/src/courses/progress/:progress.service.ts– in-memory learner → course progress store. Hydrates course metadata via the existingCourseService, derives per-coursecompletionPercentusing a documented weighted 70/30 lesson/task split, and returns a sortedIProgressSnapshot(touched courses first, untouched courses pushed to the end).progress.controller.ts– REST endpoints mounted under/courses/progress, all withParseUUIDPipefor ids.progress.module.ts– registered insrc/app.module.tsand re-exported fromsrc/courses/index.ts.interfaces/progress-snapshot.interface.ts–IProgressSnapshot,ICourseSnapshot,IOverallSnapshot, and theCourseProgressStatusenum.dto/register-course-progress.dto.ts– seed enrollment withtotalLessons/totalTasks.dto/record-completion.dto.ts–RecordLessonCompletionDtoandRecordTaskCompletionDto.progress.service.spec.ts– 21 unit tests, all green.Endpoints
/courses/progress/snapshot/:userId/courses/progress/snapshot/:userId/course/:courseId/courses/progress/:userId/courses/courses/progress/:userId/courses/:courseId/lessons/courses/progress/:userId/courses/:courseId/tasks/courses/progress/:userIdSnapshot response shape
{ "userId": "...", "generatedAt": "2026-…", "overall": { "totalXp": 60, "coursesCompleted": 1, "coursesInProgress": 1, "lessonsCompleted": 2, "tasksCompleted": 1, "lastActiveAt": "2026-…" }, "courses": [ { "courseId": "...", "title": "Rust Basics", "level": "beginner", "learningPathId": "path-rust-basics", "status": "completed", "completionPercent": 100, "lessonsCompleted": 1, "totalLessons": 1, "tasksCompleted": 1, "totalTasks": 1, "xpEarned": 50, "xpAvailable": 200, "startedAt": "...", "lastActivityAt": "...", "completedAt": "...", "firstCompletedLessonId": "lesson-1" } ] }Design notes
lastActivityAt.0(not NaN) when neither total is registered.getSnapshotskips progress rows whose underlying course record has been removed.Tests (
progress.service.spec.ts, 21 cases, all green)registerCourseNotFoundException for missing coursegetCourseSnapshotreturns null when the learner never touched the courseresetLearnerclears the statexpAvailablereflectscourse.xpRewardfirstCompletedLessonIdhint from prior completions + null when noneWhat's NOT in this PR
src/social/social.service.tssyntax error exists onmainand is unchanged by this PR.Closes #169