This document describes how to use the endpoints for managing courses, modules, topics, and students in the provided API.
URL: /student/<int:student_id>/courses
Method: GET
Response:
{
"student_id": 1,
"student_name": "john_doe",
"courses": [
{"id": 101, "name": "Math 101"},
{"id": 102, "name": "English 101"}
]
}
URL: /add-course-to-student
Method: POST
Request Body:
{
"user_id": 1,
"course_id": 101
}
Response:
{
"message": "Course added to student successfully"
}
URL: /courses
Method: GET
Query Parameters:
include_modules=true
(optional): Include modules for each course.include_topics=true
(optional): Include topics for each module.
Response:
[
{
"id": 101,
"name": "Math 101",
"modules": [
{
"id": 201,
"name": "Algebra",
"topics": [
{"id": 301, "name": "Linear Equations"},
{"id": 302, "name": "Quadratic Equations"}
]
}
]
}
]
URL: /add-course
Method: POST
Request Body Examples:
- Course with Modules and Topics:
{
"name": "Math 101",
"modules": [
{
"name": "Algebra",
"topics": ["Linear Equations", "Quadratic Equations"]
}
]
}
- Course with Modules Only:
{
"name": "History 101",
"modules": [
{"name": "Ancient Civilizations"}
]
}
- Course Only:
{
"name": "Philosophy 101"
}
Response:
{
"message": "Course created successfully",
"course_id": 1
}
URL: /delete-course/<int:course_id>
Method: DELETE
Response:
{
"message": "Course with ID 101 deleted successfully"
}
URL: /edit-module/<int:module_id>
Method: PUT
Request Body:
{
"name": "Updated Algebra Module",
"description": "New description for Algebra"
}
Response:
{
"message": "Module updated successfully",
"module": {"id": 201, "name": "Updated Algebra Module"}
}
URL: /edit-topic/<int:topic_id>
Method: PUT
Request Body:
{
"name": "Updated Linear Equations",
"description": "Detailed topic description"
}
Response:
{
"message": "Topic updated successfully",
"topic": {"id": 301, "name": "Updated Linear Equations"}
}
URL: /edit-course/<int:course_id>
Method: PUT
Request Body:
{
"name": "Updated Math 101",
"description": "An updated description for the course"
}
Response:
{
"message": "Course updated successfully",
"course": {"id": 101, "name": "Updated Math 101"}
}
- Validation: Ensure all required fields (e.g.,
name
,id
) are provided in the request body. - Authentication: Use the access token from login/signup for protected endpoints.
- Error Handling: The API returns meaningful error messages (e.g.,
Student not found
,Course not found
) with appropriate HTTP status codes.
Let me know if you need further clarifications or additional features!