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"
}
Generate an AI-powered quiz for a specific course chapter (Educator only)
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"
}
Authorization: Bearer <educator_token>
Show quiz object
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);
{
"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."
}
]
}
}
{
"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"
}