Skip to main content
POST
/
api
/
microlearning
/
courses
/
:courseId
/
quiz
Submit Quiz
curl --request POST \
  --url https://api.example.com/api/microlearning/courses/:courseId/quiz \
  --header 'Content-Type: application/json' \
  --data '
{
  "employeeId": "<string>",
  "answers": [
    {}
  ],
  "quizType": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data.result": {
    "score": 123,
    "passed": true,
    "passingScore": 123
  }
}

Overview

Submit quiz answers for a specific course. The system automatically grades the quiz, updates progress, and awards certificates if the passing score is met.

Authentication

This endpoint requires authentication.
Authorization: Bearer YOUR_JWT_TOKEN

Endpoint

POST /api/microlearning/courses/:courseId/quiz

Path Parameters

courseId
string
required
The MongoDB ObjectId of the course

Request Body

employeeId
string
required
The MongoDB ObjectId of the employee (24-character hex string)
answers
array
required
Array of answer indices (0-based) corresponding to quiz questionsExample: [2, 0, 3, 1, 2] for a 5-question quiz
quizType
string
Type of quiz being submitted. Options: week1, final. Default: final

Response

success
boolean
Indicates if the quiz was processed successfully
message
string
Success message
data.result
object
Quiz grading result

Quiz Scoring Algorithm

The scoring system (src/services/microLearningService.js:90) works as follows:
  1. Each question has a points value (default: 1)
  2. Total points = sum of all question points
  3. Earned points = sum of points for correct answers
  4. Score = (earnedPoints / totalPoints) * 100 (rounded)

Progress Updates

Week 1 Quiz

When quizType is week1:
  • Updates progress.week1QuizScore with the calculated score
  • Advances to progress.currentWeek = 2
  • Status remains en_progreso

Final Quiz

When quizType is final:
  • Updates progress.finalQuizScore with the calculated score
  • Calculates progress.totalScore as average of Week 1 and Final scores
  • If score ≥ passingScore:
    • Sets progress.status = 'completado'
    • Sets progress.completedAt to current timestamp
    • If certificationType = 'aprobacion':
      • Sets progress.certified = true
      • Sets progress.certificateIssuedAt to current timestamp

Examples

curl -X POST https://api.cuido.com/api/microlearning/courses/65a1b2c3d4e5f6a7b8c9d0e1/quiz \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "employeeId": "65a1b2c3d4e5f6a7b8c9d0e2",
    "answers": [2, 0, 3, 1, 2],
    "quizType": "week1"
  }'

Response Examples

Passed Quiz

{
  "success": true,
  "message": "Quiz procesado exitosamente",
  "data": {
    "result": {
      "score": 85,
      "passed": true,
      "passingScore": 70
    }
  }
}

Failed Quiz

{
  "success": true,
  "message": "Quiz procesado exitosamente",
  "data": {
    "result": {
      "score": 60,
      "passed": false,
      "passingScore": 70
    }
  }
}

Error Responses

{
  "success": false,
  "message": "Validation error",
  "errors": [
    {
      "field": "answers",
      "message": "Answers array is required"
    }
  ]
}

Certification Types

The course can have two certification types:
  • participacion: Certificate awarded just for completing the course
  • aprobacion: Certificate awarded only if the passing score is met

Source Code References

  • Route: src/routes/microLearningRoutes.js:24
  • Controller: src/controllers/microLearningController.js:53
  • Service: src/services/microLearningService.js:40
  • Scoring Logic: src/services/microLearningService.js:90
  • Validator: src/validators/cuidoValidators.js:62

Build docs developers (and LLMs) love