docs/lal-api-design.md

74 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 📘 LAL Project API Exercises Endpoint
This document describes the API endpoints for managing exercises within a lesson in the LAL (Learn Arabic Language) project. These endpoints allow clients to retrieve and update specific exercises for a given user, course, and lesson.
**_NOTE: this is a work-in-progress API specification for the LAL (Learn Arabic Language) project._**
---
## Endpoint Structure
All exercise-related actions are scoped under a specific user, course, and lesson using the following base path:
`/api/v1/{username}/courses/{course_id}/lessons/{lesson_id}/exercises`
---
#### GET an Exercise
Retrieve a specific exercise by its ID.
**Request:**
`GET /api/v1/{username}/courses/{course_id}/lessons/{lesson_id}/exercises/{exercise_id}`
**Description:**
Returns the specified exercise including its list of tasks and associated tags.
**Response:**
```json
{
"exercise": {
"id": 123,
"tags": [],
"tasks": [
{
"id": 1,
"title": "Task Title",
"wordtemplate": ["word1", "word2"],
"content": "Task content goes here",
"tags": []
}
]
}
}
```
---
### Edit an Exercise (PUT)
Update an existing exercise by ID.
**Request:**
`PUT /api/v1/{username}/courses/{course_id}/lessons/{lesson_id}/exercises/{exercise_id}`
**Description:**
Modifies an existing exercise and its tasks.
**Request Body:**
```json
{
"tags": ["updated-tag"],
"tasks": [
{
"id": 1,
"title": "Updated Task Title",
"wordtemplate": ["updated1", "updated2"],
"content": "Updated content",
"tags": ["grammar"]
}
]
}
```