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

Authentication

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

Request Body

courseId
string
required
The unique identifier of the course
chapterId
string
required
The unique identifier of the chapter
answers
array
required
Array of answer indices (0-3) corresponding to each quiz question. Must match the number of questions in the quiz.Example: [0, 2, 1, 3, 0, 1, 2, 0, 3, 1]

Response

success
boolean
Indicates whether the submission was successful
result
object
The quiz result with scoring and recommendations
message
string
Error message if success is false

Code Examples

const response = await fetch('https://api.skillrise.com/api/quiz/submit', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_TOKEN'
  },
  body: JSON.stringify({
    courseId: '507f1f77bcf86cd799439011',
    chapterId: 'chapter-001',
    answers: [0, 2, 1, 3, 0, 1, 2, 0, 3, 1]
  })
});

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

Response Example

High Performance (Mastered)
{
  "success": true,
  "result": {
    "score": 9,
    "total": 10,
    "percentage": 90,
    "group": "mastered",
    "recommendations": "• Excellent work! You've demonstrated strong mastery of variables and data types\n• Challenge yourself by exploring advanced topics like type coercion and symbol data types\n• Practice building small projects that utilize different data types effectively\n• Consider helping peers who are struggling with these concepts to reinforce your knowledge\n• Keep up the great momentum as you progress through the course"
  }
}
Moderate Performance (On Track)
{
  "success": true,
  "result": {
    "score": 6,
    "total": 10,
    "percentage": 60,
    "group": "on_track",
    "recommendations": "• Review the differences between let, const, and var declarations\n• Practice writing code examples for each primitive data type\n• Revisit the lectures on type conversion and comparison operators\n• Try creating a small project that uses different variable types\n• Don't get discouraged - you're making solid progress!"
  }
}
Low Performance (Needs Review)
{
  "success": true,
  "result": {
    "score": 3,
    "total": 10,
    "percentage": 30,
    "group": "needs_review",
    "recommendations": "• Revisit all lectures in this chapter, taking detailed notes\n• Focus on understanding what variables are and how they store data\n• Practice declaring variables using let and const with simple examples\n• Watch supplementary videos on JavaScript data types\n• Consider scheduling time with a tutor or joining a study group\n• Remember that learning takes time - stay persistent!"
  }
}

Error Responses

{
  "success": false,
  "message": "Invalid request data"
}
{
  "success": false,
  "message": "Quiz not found"
}
{
  "success": false,
  "message": "Answer count does not match question count"
}

Performance Groups

GroupPercentage RangeDescription
needs_review0-40%Significant gaps in understanding. Comprehensive review recommended.
on_track41-75%Good progress with room for improvement. Additional practice suggested.
mastered76-100%Strong comprehension. Ready to advance to next topics.

Notes

  • The quiz result is automatically saved to the database and associated with the user’s account
  • AI recommendations are personalized based on:
    • The specific questions answered incorrectly
    • The overall performance level
    • The chapter content and topics covered
  • Users can retake quizzes multiple times - all attempts are stored
  • The answers array must contain exactly the same number of elements as there are questions in the quiz
  • Each answer must be an integer from 0 to 3, corresponding to the option index