Skip to main content
POST
/
api
/
quiz
/
generate
Generate Quiz
curl --request POST \
  --url https://api.example.com/api/quiz/generate \
  --header 'Content-Type: application/json' \
  --data '
{
  "courseId": "<string>",
  "chapterId": "<string>"
}
'
{
  "success": false,
  "message": "Invalid request data"
}

Authentication

This endpoint requires educator authentication. Include the authorization token in your request headers.
Authorization: Bearer <educator_token>

Request Body

courseId
string
required
The unique identifier of the course
chapterId
string
required
The unique identifier of the chapter within the course

Response

success
boolean
Indicates whether the quiz generation was successful
quiz
object
The generated quiz object
message
string
Error message if success is false

Code Examples

const response = await fetch('https://api.skillrise.com/api/quiz/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_EDUCATOR_TOKEN'
  },
  body: JSON.stringify({
    courseId: '507f1f77bcf86cd799439011',
    chapterId: 'chapter-001'
  })
});

const data = await response.json();
console.log(data.quiz);

Response Example

{
  "success": true,
  "quiz": {
    "_id": "64a1b2c3d4e5f6789abcdef0",
    "courseId": "507f1f77bcf86cd799439011",
    "chapterId": "chapter-001",
    "courseTitle": "Introduction to JavaScript",
    "chapterTitle": "Variables and Data Types",
    "questions": [
      {
        "question": "What is the difference between 'let' and 'const' in JavaScript?",
        "options": [
          "let allows reassignment, const does not",
          "const allows reassignment, let does not",
          "They are exactly the same",
          "let is block-scoped, const is function-scoped"
        ],
        "correctIndex": 0,
        "explanation": "Variables declared with 'let' can be reassigned, while 'const' creates a constant reference that cannot be reassigned."
      },
      {
        "question": "Which of the following is NOT a primitive data type in JavaScript?",
        "options": [
          "string",
          "number",
          "array",
          "boolean"
        ],
        "correctIndex": 2,
        "explanation": "Arrays are objects in JavaScript, not primitive data types. The primitive types are string, number, boolean, null, undefined, symbol, and bigint."
      }
    ]
  }
}

Error Responses

{
  "success": false,
  "message": "Invalid request data"
}
{
  "success": false,
  "message": "Course not found"
}
{
  "success": false,
  "message": "Chapter not found"
}
{
  "success": false,
  "message": "An unexpected error occurred"
}

Notes

  • The endpoint uses AI to generate 10 multiple-choice questions based on the chapter’s lectures
  • If a quiz already exists for the chapter, it will be replaced with the newly generated one
  • Questions are designed to test conceptual understanding of the chapter topics
  • Each question has exactly 4 options with one correct answer
  • The quiz generation process analyzes all lecture titles within the chapter to create relevant questions