Generate Quiz
curl --request POST \
--url https://api.example.com/api/quiz/generate \
--header 'Content-Type: application/json' \
--data '
{
"courseId": "<string>",
"chapterId": "<string>"
}
'import requests
url = "https://api.example.com/api/quiz/generate"
payload = {
"courseId": "<string>",
"chapterId": "<string>"
}
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>'})
};
fetch('https://api.example.com/api/quiz/generate', 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/generate",
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>'
]),
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/generate"
payload := strings.NewReader("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\"\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/generate")
.header("Content-Type", "application/json")
.body("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/quiz/generate")
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}"
response = http.request(request)
puts response.read_body{
"success": false,
"message": "Invalid request data"
}
Quiz API
Generate Quiz
Generate an AI-powered quiz for a specific course chapter (Educator only)
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>"
}
'import requests
url = "https://api.example.com/api/quiz/generate"
payload = {
"courseId": "<string>",
"chapterId": "<string>"
}
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>'})
};
fetch('https://api.example.com/api/quiz/generate', 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/generate",
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>'
]),
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/generate"
payload := strings.NewReader("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\"\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/generate")
.header("Content-Type", "application/json")
.body("{\n \"courseId\": \"<string>\",\n \"chapterId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/quiz/generate")
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}"
response = http.request(request)
puts response.read_body{
"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
string
required
The unique identifier of the course
string
required
The unique identifier of the chapter within the course
Response
boolean
Indicates whether the quiz generation was successful
object
The generated quiz object
Show quiz object
Show quiz object
string
Unique identifier for the quiz
string
The course ID this quiz belongs to
string
The chapter ID this quiz covers
string
The title of the course
string
The title of the chapter
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);
import requests
url = 'https://api.skillrise.com/api/quiz/generate'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_EDUCATOR_TOKEN'
}
payload = {
'courseId': '507f1f77bcf86cd799439011',
'chapterId': 'chapter-001'
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data['quiz'])
curl -X POST https://api.skillrise.com/api/quiz/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_EDUCATOR_TOKEN" \
-d '{
"courseId": "507f1f77bcf86cd799439011",
"chapterId": "chapter-001"
}'
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
⌘I