Used by thousands of students worldwide - help us reach 150 members
Quizzes
/quizAI-generated multiple-choice quizzes for books. A quiz belongs to one book and holds a list of questions, each with exactly 4 options (one correct) and a rationale. Reading quizzes is public; generating, editing and deleting them is limited to editors and admins.
/quiz/generate/:bookIdGenerate a new quiz for a bookGET/quiz/book/:bookIdList quizzes for a bookGET/quiz/book/:bookId/latestGet the most recent quiz for a bookGET/quiz/:quizIdGet a quiz by idPUT/quiz/:quizId/questions/:questionIndexReplace a question in a quizPOST/quiz/:quizId/questionsAdd a question to a quizDELETE/quiz/:quizId/questions/:questionIndexDelete a question from a quizDELETE/quiz/:quizIdDelete a quizGenerate a new quiz for a book
Sends the full content of the book (Arabic, English, commentary and root words of every line, plus title and author) to Google Gemini and asks for a multiple-choice quiz covering every major topic, with 4 options per question, exactly one correct, and a rationale. The model output is parsed as JSON, must contain a non-empty questions array, and is saved as a new Quiz linked to the book; existing quizzes for the book are kept. The call is synchronous and can take a while for large books. The response includes summary fields, the username of the caller as createdBy (not stored on the quiz) and the full saved quiz. Only the role is checked; there is no book ownership check.
Path parameters
bookIdstring | Book ObjectId |
Errors
401No bearer token provided (plain-text body)403Invalid or expired token, or the user has neither the editor nor the admin role (plain-text body)404Book not found (or, as plain text, the user behind the token no longer exists)500Quiz generation failed (AI provider error, unparseable or empty model output, malformed bookId); error carries the failure message
curl -X POST "https://app.ummahspot.com/quiz/generate/:bookId" \
-H "Authorization: Bearer $SHARH_TOKEN"{
"id": "66f2d3b0a1b2c3d4e5f60718",
"bookId": "665f1b2c3d4e5f6a7b8c9d0e",
"questionsCount": 25,
"createdAt": "2025-01-15T10:30:00.000Z",
"createdBy": "ustadh_ahmad",
"quiz": {
"_id": "66f2d3b0a1b2c3d4e5f60718",
"book": "665f1b2c3d4e5f6a7b8c9d0e",
"questions": [
{
"_id": "66f2d3b0a1b2c3d4e5f60719",
"questionText": "How does the author define speech (kalam)?",
"options": [
{ "_id": "66f2d3b0a1b2c3d4e5f6071a", "text": "Any sound produced by the tongue", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071b", "text": "A composed utterance that conveys meaning by convention", "isCorrect": true },
{ "_id": "66f2d3b0a1b2c3d4e5f6071c", "text": "A single word with a meaning", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071d", "text": "Written text only", "isCorrect": false }
],
"rationale": "The text defines speech as a composed, meaningful utterance established by convention; the other options omit one of these conditions."
}
],
"createdAt": "2025-01-15T10:30:00.000Z",
"__v": 0
}
}List quizzes for a book
Returns summary information (id, question count, creation date) for every quiz generated for the book, newest first. quizzes is an empty array when the book has none. No authentication or book visibility check is performed.
Path parameters
bookIdstring | Book ObjectId |
Errors
404Book not found500Failed to fetch quizzes (including a malformed bookId)
curl -X GET "https://app.ummahspot.com/quiz/book/:bookId"{
"bookId": "665f1b2c3d4e5f6a7b8c9d0e",
"bookTitle": "Al-Ajrumiyyah",
"quizzes": [
{
"id": "66f2d3b0a1b2c3d4e5f60718",
"questionsCount": 25,
"createdAt": "2025-01-15T10:30:00.000Z"
}
],
"total": 1
}Get the most recent quiz for a book
Returns the full, most recently generated quiz for the book, including every question with its options, the isCorrect flags and rationales. The book field is populated with the book title, author and difficulty. No authentication is required, so correct answers are visible to any caller.
Path parameters
bookIdstring | Book ObjectId |
Errors
404No quiz found for this book500Failed to fetch latest quiz (including a malformed bookId)
curl -X GET "https://app.ummahspot.com/quiz/book/:bookId/latest"{
"_id": "66f2d3b0a1b2c3d4e5f60718",
"book": {
"_id": "665f1b2c3d4e5f6a7b8c9d0e",
"title": "Al-Ajrumiyyah",
"author": "Ibn Ajurrum",
"difficulty": "Beginner"
},
"questions": [
{
"_id": "66f2d3b0a1b2c3d4e5f60719",
"questionText": "How does the author define speech (kalam)?",
"options": [
{ "_id": "66f2d3b0a1b2c3d4e5f6071a", "text": "Any sound produced by the tongue", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071b", "text": "A composed utterance that conveys meaning by convention", "isCorrect": true },
{ "_id": "66f2d3b0a1b2c3d4e5f6071c", "text": "A single word with a meaning", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071d", "text": "Written text only", "isCorrect": false }
],
"rationale": "The text defines speech as a composed, meaningful utterance established by convention; the other options omit one of these conditions."
}
],
"createdAt": "2025-01-15T10:30:00.000Z",
"__v": 0
}Get a quiz by id
Returns the full quiz, including every question with its options, the isCorrect flags and rationales. The book field is populated with the book title, author, category and difficulty. No authentication is required, so correct answers are visible to any caller.
Path parameters
quizIdstring | Quiz ObjectId |
Errors
404Quiz not found500Failed to fetch quiz (including a malformed quizId)
curl -X GET "https://app.ummahspot.com/quiz/:quizId"{
"_id": "66f2d3b0a1b2c3d4e5f60718",
"book": {
"_id": "665f1b2c3d4e5f6a7b8c9d0e",
"title": "Al-Ajrumiyyah",
"author": "Ibn Ajurrum",
"category": "Grammar",
"difficulty": "Beginner"
},
"questions": [
{
"_id": "66f2d3b0a1b2c3d4e5f60719",
"questionText": "How does the author define speech (kalam)?",
"options": [
{ "_id": "66f2d3b0a1b2c3d4e5f6071a", "text": "Any sound produced by the tongue", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071b", "text": "A composed utterance that conveys meaning by convention", "isCorrect": true },
{ "_id": "66f2d3b0a1b2c3d4e5f6071c", "text": "A single word with a meaning", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071d", "text": "Written text only", "isCorrect": false }
],
"rationale": "The text defines speech as a composed, meaningful utterance established by convention; the other options omit one of these conditions."
}
],
"createdAt": "2025-01-15T10:30:00.000Z",
"__v": 0
}Replace a question in a quiz
Replaces the question at the given zero-based position with the supplied question text, options and rationale. The whole question is overwritten; partial updates are not supported. Only the role is checked, so any editor or admin can edit any quiz.
Path parameters
quizIdstring | Quiz ObjectId |
questionIndexnumber | Zero-based index of the question in the quiz questions array |
Body parameters
questionTextrequiredstring | The question text |
optionsrequiredobject[] | Exactly 4 answer options, each shaped { text: string, isCorrect: boolean }. Every option needs a non-empty string text, and exactly one option must have isCorrect set to true. |
rationalerequiredstring | Explanation of why the correct answer is right |
Errors
400Validation failed: questionText, options and rationale are required; options must be an array of exactly 4 items; exactly one option must be marked as correct; all options must have text; or Invalid question index (out of range)401No bearer token provided (plain-text body)403Invalid or expired token, or the user has neither the editor nor the admin role (plain-text body)404Quiz not found (or, as plain text, the user behind the token no longer exists)500Failed to update question (including a malformed quizId)
curl -X PUT "https://app.ummahspot.com/quiz/:quizId/questions/:questionIndex" \
-H "Authorization: Bearer $SHARH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"questionText":"string","options":[],"rationale":"string"}'{
"message": "Question updated successfully",
"updatedQuestion": {
"_id": "66f2e4c1a1b2c3d4e5f60801",
"questionText": "How does the author define speech (kalam)?",
"options": [
{ "_id": "66f2e4c1a1b2c3d4e5f60802", "text": "Any sound produced by the tongue", "isCorrect": false },
{ "_id": "66f2e4c1a1b2c3d4e5f60803", "text": "A composed utterance that conveys meaning by convention", "isCorrect": true },
{ "_id": "66f2e4c1a1b2c3d4e5f60804", "text": "A single word with a meaning", "isCorrect": false },
{ "_id": "66f2e4c1a1b2c3d4e5f60805", "text": "Written text only", "isCorrect": false }
],
"rationale": "The text defines speech as a composed, meaningful utterance established by convention."
},
"questionIndex": 0
}Add a question to a quiz
Appends a new question to the end of the quiz. The response echoes the question as submitted (normalised to text and isCorrect per option), its zero-based index and the new total. Only the role is checked, so any editor or admin can edit any quiz.
Path parameters
quizIdstring | Quiz ObjectId |
Body parameters
questionTextrequiredstring | The question text |
optionsrequiredobject[] | Exactly 4 answer options, each shaped { text: string, isCorrect: boolean }. Every option needs a non-empty string text, and exactly one option must have isCorrect set to true. |
rationalerequiredstring | Explanation of why the correct answer is right |
Errors
400Validation failed: questionText, options and rationale are required; options must be an array of exactly 4 items; exactly one option must be marked as correct; all options must have text401No bearer token provided (plain-text body)403Invalid or expired token, or the user has neither the editor nor the admin role (plain-text body)404Quiz not found (or, as plain text, the user behind the token no longer exists)500Failed to add question (including a malformed quizId)
curl -X POST "https://app.ummahspot.com/quiz/:quizId/questions" \
-H "Authorization: Bearer $SHARH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"questionText":"string","options":[],"rationale":"string"}'{
"message": "Question added successfully",
"addedQuestion": {
"questionText": "Which of the following is a sign of a noun?",
"options": [
{ "text": "Accepting the definite article", "isCorrect": true },
{ "text": "Accepting the particle of negation lam", "isCorrect": false },
{ "text": "Accepting the feminine ta of the verb", "isCorrect": false },
{ "text": "None of the above", "isCorrect": false }
],
"rationale": "Nouns are recognised by the definite article, tanwin and the genitive case; the other signs belong to verbs."
},
"questionIndex": 25,
"totalQuestions": 26
}Delete a question from a quiz
Removes the question at the given zero-based position and returns it along with the number of questions left. The last remaining question of a quiz cannot be deleted; delete the quiz instead. Indexes of later questions shift down by one. Only the role is checked, so any editor or admin can edit any quiz.
Path parameters
quizIdstring | Quiz ObjectId |
questionIndexnumber | Zero-based index of the question in the quiz questions array |
Errors
400Invalid question index (out of range), or Cannot delete the last question in a quiz401No bearer token provided (plain-text body)403Invalid or expired token, or the user has neither the editor nor the admin role (plain-text body)404Quiz not found (or, as plain text, the user behind the token no longer exists)500Failed to delete question (including a malformed quizId)
curl -X DELETE "https://app.ummahspot.com/quiz/:quizId/questions/:questionIndex" \
-H "Authorization: Bearer $SHARH_TOKEN"{
"message": "Question deleted successfully",
"deletedQuestion": {
"_id": "66f2d3b0a1b2c3d4e5f60719",
"questionText": "How does the author define speech (kalam)?",
"options": [
{ "_id": "66f2d3b0a1b2c3d4e5f6071a", "text": "Any sound produced by the tongue", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071b", "text": "A composed utterance that conveys meaning by convention", "isCorrect": true },
{ "_id": "66f2d3b0a1b2c3d4e5f6071c", "text": "A single word with a meaning", "isCorrect": false },
{ "_id": "66f2d3b0a1b2c3d4e5f6071d", "text": "Written text only", "isCorrect": false }
],
"rationale": "The text defines speech as a composed, meaningful utterance established by convention."
},
"remainingQuestions": 24
}Delete a quiz
Permanently deletes the quiz and all of its questions, and returns the id and creation date of the deleted quiz. Only the role is checked, so any editor or admin can delete any quiz.
Path parameters
quizIdstring | Quiz ObjectId |
Errors
401No bearer token provided (plain-text body)403Invalid or expired token, or the user has neither the editor nor the admin role (plain-text body)404Quiz not found (or, as plain text, the user behind the token no longer exists)500Failed to delete quiz (including a malformed quizId)
curl -X DELETE "https://app.ummahspot.com/quiz/:quizId" \
-H "Authorization: Bearer $SHARH_TOKEN"{
"message": "Quiz deleted successfully",
"deletedQuiz": {
"id": "66f2d3b0a1b2c3d4e5f60718",
"createdAt": "2025-01-15T10:30:00.000Z"
}
}