Overview
Admins and instructors currently enroll students one at a time via individual API calls. Enrolling a cohort of 500 students requires 500 sequential requests, is slow, and risks partial failure leaving students in inconsistent enrollment states.
Specifications
Features:
POST /enrollments/bulk accepts an array of { userId, courseId } pairs.
- Entire batch succeeds or fails atomically inside a database transaction.
Tasks:
- Create
BulkEnrollmentDto with @ArrayMaxSize(500) validation.
- Implement
EnrollmentsService.bulkEnroll() using TypeORM QueryRunner transaction.
- Return a summary:
{ enrolled: N, skipped: N, failed: N, errors: [] }.
- Add rate limiting on the bulk endpoint (max 1 request/minute per user).
- Add integration tests for partial failure rollback.
Impacted Files:
src/courses/enrollments/ (service and controller)
Acceptance Criteria
- Partial validation failure rolls back all enrolled records.
- Response includes per-item error details for skipped records.
- Bulk enroll 500 users in under 2 seconds.
Overview
Admins and instructors currently enroll students one at a time via individual API calls. Enrolling a cohort of 500 students requires 500 sequential requests, is slow, and risks partial failure leaving students in inconsistent enrollment states.
Specifications
Features:
POST /enrollments/bulkaccepts an array of{ userId, courseId }pairs.Tasks:
BulkEnrollmentDtowith@ArrayMaxSize(500)validation.EnrollmentsService.bulkEnroll()using TypeORMQueryRunnertransaction.{ enrolled: N, skipped: N, failed: N, errors: [] }.Impacted Files:
src/courses/enrollments/(service and controller)Acceptance Criteria