Skip to main content
POST
/
api
/
microlearning
/
courses
/
:courseId
/
enroll
Course Enrollment
curl --request POST \
  --url https://api.example.com/api/microlearning/courses/:courseId/enroll \
  --header 'Content-Type: application/json' \
  --data '
{
  "employeeId": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data.enrollment": {
    "_id": "<string>",
    "employeeId": "<string>",
    "courseId": "<string>",
    "progress": {
      "status": "<string>",
      "currentWeek": 123,
      "certified": true
    },
    "timeSpent": 123,
    "accessCount": 123,
    "createdAt": "<string>"
  }
}

Overview

Enroll an employee in a specific microlearning course. Each employee can only be enrolled once per course.

Authentication

This endpoint requires authentication.
Authorization: Bearer YOUR_JWT_TOKEN

Endpoint

POST /api/microlearning/courses/:courseId/enroll

Path Parameters

courseId
string
required
The MongoDB ObjectId of the course to enroll in

Request Body

employeeId
string
required
The MongoDB ObjectId of the employee to enroll (24-character hex string)

Response

success
boolean
Indicates if enrollment was successful
message
string
Success message
data.enrollment
object
The created enrollment object

Examples

curl -X POST https://api.cuido.com/api/microlearning/courses/65a1b2c3d4e5f6a7b8c9d0e1/enroll \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "employeeId": "65a1b2c3d4e5f6a7b8c9d0e2"
  }'

Response Example

{
  "success": true,
  "message": "Inscripción exitosa",
  "data": {
    "enrollment": {
      "_id": "65a1b2c3d4e5f6a7b8c9d0e3",
      "employeeId": "65a1b2c3d4e5f6a7b8c9d0e2",
      "courseId": "65a1b2c3d4e5f6a7b8c9d0e1",
      "progress": {
        "status": "inscrito",
        "currentWeek": 1,
        "certified": false
      },
      "timeSpent": 0,
      "accessCount": 0,
      "createdAt": "2024-01-15T10:30:00.000Z",
      "updatedAt": "2024-01-15T10:30:00.000Z"
    }
  }
}

Error Responses

{
  "success": false,
  "message": "Ya está inscrito en este curso"
}

Business Logic

The enrollment service (src/services/microLearningService.js:11) performs the following:
  1. Checks if the employee is already enrolled in the course
  2. Creates a new CourseEnrollment document with default values
  3. Links the employee and course via ObjectId references
  4. Initializes progress tracking for the 15-day methodology

15-Day Methodology

Courses follow a two-week structure:
  • Week 1: Initial content consumption and Week 1 quiz
  • Week 2: Advanced content and final quiz
  • Certification: Awarded upon passing the final quiz (if certificationType is aprobacion)

Source Code References

  • Route: src/routes/microLearningRoutes.js:21
  • Controller: src/controllers/microLearningController.js:43
  • Service: src/services/microLearningService.js:11
  • Model: src/models/CourseEnrollment.js

Build docs developers (and LLMs) love