Base URL: /challenges/
Authentication: Required (JWT / Session)
GET /challenges/start/Input Parameters (Query):
| Name | Type | Required | Description |
|---|---|---|---|
challenge_number |
int | ✅ | The challenge number (1, 2, 3, …). |
course_id |
int | ✅ | The course ID to fetch the challenge from. |
Response (200 OK):
{
"challenge_id": 12,
"challenge_text": "Write a Python function to reverse a string.",
"user_challenge_id": 55
}
400 Bad Request → Missing/invalid params403 Forbidden → Access denied (previous challenge not passed)404 Not Found → Challenge not foundPOST /challenges/submit/Input Parameters (Body: JSON):
| Name | Type | Required | Description |
|---|---|---|---|
user_challenge_id |
int | ✅ | The user_challenge_id returned from start. |
user_answer |
string | ✅ | The answer/solution submitted by the user. |
Response (200 OK):
{
"status": "Passed",
"score": 85,
"feedback": "Good job, clean solution!",
"character": {
"reaction": "smiling",
"mood_change": "positive"
}
}
400 Bad Request → Missing params404 Not Found → UserChallenge or Answer not found500 Internal Server Error → AI evaluation failedGET /challenges/list/Input Parameters (Query):
| Name | Type | Required | Description |
|---|---|---|---|
course_id |
int | ✅ | The course ID. |
Response (200 OK):
[
{
"id": 12,
"challenge_number": 1,
"topic": "String Manipulation",
"difficulty": "easy",
"challenge_text": "Write a Python function to reverse a string."
},
{
"id": 13,
"challenge_number": 2,
"topic": "File Handling",
"difficulty": "medium",
"challenge_text": "Write code to count lines in a text file."
}
]
400 Bad Request → Missing/invalid course_id404 Not Found → No challenges found