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": [
{}
]
}
'import requests
url = "https://api.example.com/api/quiz/submit"
payload = {
"courseId": "<string>",
"chapterId": "<string>",
"answers": [{}]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({courseId: '<string>', chapterId: '<string>', answers: [{}]})
};
fetch('https://api.example.com/api/quiz/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/quiz/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'courseId' => '<string>',
'chapterId' => '<string>',
'answers' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/quiz/submit"
payload := strings.NewReader("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\",\n \"answers\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/quiz/submit")
.header("Content-Type", "application/json")
.body("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\",\n \"answers\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/quiz/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\",\n \"answers\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": false,
"message": "Invalid request data"
}
Quiz API
Submit Quiz Result
Submit quiz answers and receive score with AI-powered recommendations
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": [
{}
]
}
'import requests
url = "https://api.example.com/api/quiz/submit"
payload = {
"courseId": "<string>",
"chapterId": "<string>",
"answers": [{}]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({courseId: '<string>', chapterId: '<string>', answers: [{}]})
};
fetch('https://api.example.com/api/quiz/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/quiz/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'courseId' => '<string>',
'chapterId' => '<string>',
'answers' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/quiz/submit"
payload := strings.NewReader("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\",\n \"answers\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/quiz/submit")
.header("Content-Type", "application/json")
.body("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\",\n \"answers\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/quiz/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\",\n \"answers\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"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
string
required
The unique identifier of the course
string
required
The unique identifier of the chapter
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
boolean
Indicates whether the submission was successful
object
The quiz result with scoring and recommendations
Show result object
Show result object
number
Number of correct answers
number
Total number of questions
number
Score as a percentage (rounded to nearest integer)
string
Performance category:
"needs_review" (≤40%), "on_track" (41-75%), or "mastered" (>75%)string
AI-generated personalized recommendations to improve understanding. Contains 4-5 bullet points with actionable advice.
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);
import requests
url = 'https://api.skillrise.com/api/quiz/submit'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
}
payload = {
'courseId': '507f1f77bcf86cd799439011',
'chapterId': 'chapter-001',
'answers': [0, 2, 1, 3, 0, 1, 2, 0, 3, 1]
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data['result'])
curl -X POST https://api.skillrise.com/api/quiz/submit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"courseId": "507f1f77bcf86cd799439011",
"chapterId": "chapter-001",
"answers": [0, 2, 1, 3, 0, 1, 2, 0, 3, 1]
}'
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
| Group | Percentage Range | Description |
|---|---|---|
needs_review | 0-40% | Significant gaps in understanding. Comprehensive review recommended. |
on_track | 41-75% | Good progress with room for improvement. Additional practice suggested. |
mastered | 76-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
answersarray 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
⌘I