Skip to content

feat(courses,users): add enrollment-status, progress, quiz-attempts, module-reorder & learning-stats endpoints (#374, #381, #383, #385, #393) - #458

Merged
DeFiVC merged 5 commits into
ChainLearnOfficial:mainfrom
ZacLou:feat/multiple-course-user-endpoints
Sep 2, 2026
Merged

feat(courses,users): add enrollment-status, progress, quiz-attempts, module-reorder & learning-stats endpoints (#374, #381, #383, #385, #393)#458
DeFiVC merged 5 commits into
ChainLearnOfficial:mainfrom
ZacLou:feat/multiple-course-user-endpoints

Conversation

@ZacLou

Copy link
Copy Markdown

Summary

This PR adds 5 new API endpoints across the courses and users modules, addressing issues #374, #381, #383, #385, and #393.

New Endpoints

IssueEndpointDescription
#381GET /api/v1/courses/:id/enrollment-statusDetailed enrollment status for the current user: isEnrolled, enrolledAt, completedAt, module-by-module progress, quizCount, averageScore. Cached 30s. 404 for non-existent courses.
#385GET /api/v1/courses/:id/progressUser's detailed progress in a course: modules completed, quizzes taken, average score, completion %, module-by-module status. Cached 30s.
#393GET /api/v1/courses/:id/modules/:moduleId/quiz-attemptsAll quiz attempts for a module by the authenticated user, ordered oldest-first. Returns attempt number, score, percentage, passed status. Cached 30s.
#374POST /api/v1/admin/courses/:id/modules/reorderAdmin endpoint to reorder course modules atomically. Accepts {moduleIds: string[]}, validates all IDs belong to the course, updates order atomically via withLock, logs to audit trail.
#383GET /api/v1/users/me/learning-statsComprehensive learning stats: courses completed, quizzes taken, average score %, credits, credentials, learning streak, estimated study time, learning velocity. Cached 5min.

Implementation Details

  • All endpoints follow the existing controller → service → routes → types module pattern
  • Validation via zod schemas (validate() middleware)
  • Redis caching (30s for course endpoints, 5min for learning-stats) using cacheGet/cacheSet/cacheKey
  • authGuard on all user-facing endpoints, adminGuard on the reorder endpoint
  • NotFoundError for non-existent/inactive courses (404)
  • Module lists derived from courses.modules jsonb definitions, falling back to quiz-derived moduleId groups (matching getCourseDetail's pattern)
  • withLock for atomic module reordering (matching createModule/updateModule's pattern)
  • Audit logging via auditLog() for the admin reorder action

Closes#374, closes#381, closes#383, closes#385, closes#393

鲁班七号 added 2 commits September 2, 2026 21:26
…LearnOfficial#381, ChainLearnOfficial#385, ChainLearnOfficial#393)
- GET /api/v1/courses/:id/enrollment-status (ChainLearnOfficial#381): detailed enrollment
status with module-by-module progress, quiz count, average score
- GET /api/v1/courses/:id/progress (ChainLearnOfficial#385): user's detailed progress in a
course with module completion, quiz scores, completion percentage
- GET /api/v1/courses/:id/modules/:moduleId/quiz-attempts (ChainLearnOfficial#393): all quiz
attempts for a module ordered oldest-first with score/percentage/pass
- POST /api/v1/admin/courses/:id/modules/reorder (ChainLearnOfficial#374): admin endpoint to
reorder course modules atomically with audit logging
All endpoints follow the established controller→service→routes→types
pattern, use Redis caching (30s for course endpoints), and include
proper validation via zod schemas.
…earnOfficial#383)
Comprehensive learning statistics for the authenticated user: total
courses completed, quizzes taken, average score (percentage), credits
earned, credentials earned, learning streak (consecutive days),
estimated total study time, and learning velocity (quizzes in last
7 days). Cached for 5 minutes.
Follows the established controller→service→routes→types pattern.
@ZacLou
ZacLouforce-pushed the feat/multiple-course-user-endpoints branch from b7ce7b4 to 3e1de33CompareSeptember 2, 2026 13:27
鲁班七号 added 3 commits September 2, 2026 22:11
- course.routes.ts: add missing ');' closing enrolledUsers route
- course.service.ts: add missing '}' closing reorderModules method
- course.types.ts: remove broken empty EnrolledUserEntry interface and
duplicate 'users' field declaration in EnrolledUsersResult
- course.controller.ts: drop unused ReorderModulesBody import
Fixes CI Lint & Typecheck failures (3 parsing errors) reported on 3e1de33.
course-waitlist.test.ts had the same reference line twice, which tripped
the @typescript-eslint/triple-slash-reference rule and kept Lint red.
The file already imports describe/it/expect/beforeAll/afterAll from
"vitest" directly, matching every other test in the repo. This was the
last file in tests/ still using the triple-slash form.
@DeFiVC
DeFiVC merged commit 4765abb into ChainLearnOfficial:mainSep 2, 2026
3 of 5 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants

@ZacLou@DeFiVC