Overview
The Practice Tests API allows users to create comprehensive practice tests from study materials. Unlike regular quizzes, practice tests support question banks, custom test creation, and detailed performance tracking.
Endpoints
Create Question Bank
POST /api/practice-tests/banks
curl -X POST https://api.inspir.uk/api/practice-tests/banks \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"name": "Biology Chapter 5",
"description": "Photosynthesis and cellular respiration",
"topic": "Biology"
}'
Create a question bank to organize practice questions.
Authentication: Required
Request Body
Name of the question bank
Description of the question bank content
Generate Practice Questions
POST /api/practice-tests/generate
With File Upload
curl -X POST https://api.inspir.uk/api/practice-tests/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"content": "Study material text...",
"questionCount": 20,
"difficultyMix": "balanced"
}'
Generate practice questions from content or uploaded file.
Authentication: Optional (guests get questions without saving)
Request Body
Text content to generate questions from (required if no file)
PDF, DOCX, or TXT file (max 10MB, required if no content)
Number of questions to generate (5-50)
Difficulty distribution: easy, balanced, hard, or mixed
Question types to include: multiple-choice, true-false, short-answer, fill-blank
Optional question bank ID to save questions to
Response
Whether the request was successful
Generated questions Type: multiple-choice, true-false, short-answer, or fill-blank
Answer options (for multiple-choice and true-false)
Explanation of the correct answer
Difficulty: easy, medium, or hard
Specific topic this question covers
Whether questions were saved (true for authenticated users)
Create Practice Test
POST /api/practice-tests/tests
curl -X POST https://api.inspir.uk/api/practice-tests/tests \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"title": "Biology Midterm Practice",
"questionIds": ["q1", "q2", "q3"],
"timeLimit": 60,
"passingScore": 70
}'
Create a custom practice test from question bank.
Authentication: Required
Request Body
Array of question IDs to include in the test
Time limit in minutes (optional)
Passing score percentage (0-100)
Whether to randomize question order
Show immediate feedback after each question
Submit Test Attempt
POST /api/practice-tests/tests/:id/submit
curl -X POST https://api.inspir.uk/api/practice-tests/tests/test123/submit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"answers": [
{"questionId": "q1", "answer": "A"},
{"questionId": "q2", "answer": "True"}
],
"timeSpent": 45
}'
Submit answers for a practice test.
Authentication: Required
Request Body
Total time spent in minutes
Response
Whether the submission was successful
Test results Number of correct answers
Total number of questions
Whether the user passed (based on passingScore)
Detailed results per question Whether answer was correct
Explanation of correct answer
AI-generated personalized feedback
Topics where user needs improvement
Get Practice Tests
GET /api/practice-tests/tests
curl -X GET https://api.inspir.uk/api/practice-tests/tests \
-H "Authorization: Bearer YOUR_TOKEN"
Get user’s practice tests.
Authentication: Required
Get Practice Test by ID
GET /api/practice-tests/tests/:id
curl -X GET https://api.inspir.uk/api/practice-tests/tests/test123
Get a specific practice test.
Authentication: Optional (public tests only)
Error Responses
400 - Invalid request (missing fields, invalid file type)
401 - Authentication required
404 - Test or question not found
413 - File too large (max 10MB)
500 - AI generation failed
Supported File Types
PDF (.pdf)
Word Documents (.docx)
Text Files (.txt)
Maximum file size: 10 MB
Practice tests support advanced features like time limits, passing scores, and detailed analytics to help students prepare for exams effectively.
Use the difficultyMix parameter to create tests that match your exam difficulty. Start with “balanced” and adjust based on your performance.