Skip to main content

Get Lesson Details

Retrieves detailed information about a specific lesson including content, quizzes, and resources. Requires enrollment in the parent course.

Path Parameters

id
string
required
Lesson ID

Response

lesson
object
Detailed lesson object

Example Request

curl https://your-domain.com/api/lessons/42

Example Response

{
  "lesson": {
    "id": 42,
    "title": "Introduction to Variables",
    "type": "video",
    "video_url": "https://example.com/video.mp4",
    "text_content": null,
    "estimated_duration": 15,
    "is_required": true,
    "order_index": 0,
    "course_id": 1,
    "resources": [
      {
        "id": "1",
        "title": "Lesson Notes",
        "type": "pdf",
        "url": "https://example.com/notes.pdf",
        "file_size": 1024000
      }
    ],
    "quiz_questions": [
      {
        "id": "10",
        "question_type": "multiple-choice",
        "question_text": "What is a variable?",
        "question_data": {
          "options": ["A container for data", "A function", "A loop"],
          "correctOption": 0
        },
        "points": 1,
        "order_index": 0
      }
    ],
    "courses": {
      "id": 1,
      "title": "Introduction to Programming",
      "settings": {
        "requiresSequentialProgress": false
      }
    }
  }
}

Lesson Access Control

Access to lesson content is controlled by enrollment status:
  • Regular Users: Must be enrolled in the course to access any lesson
  • Admin/Instructor: Can access all lessons without enrollment
The API automatically checks enrollment status and returns a 403 Forbidden error if the user is not enrolled.

Lesson Content Types

Lessons support three main content types:

Video Lessons

Video lessons have a video_url field pointing to the video file. The URL may be transformed to use Azure Front Door CDN if enabled.
{
  "type": "video",
  "video_url": "https://cdn.example.com/videos/lesson-42.mp4",
  "estimated_duration": 15
}

Text Lessons

Text lessons contain HTML or markdown content in the text_content field.
{
  "type": "text",
  "text_content": "<h1>Introduction</h1><p>Welcome to this lesson...</p>",
  "estimated_duration": 10
}

Quiz Lessons

Quiz lessons contain questions from the normalized quiz_questions table. Questions support multiple types:
  • multiple-choice: Single correct answer from options
  • true-false: Boolean answer
  • fill-blank: Text input with correct answers
  • short-answer: Keyword-based evaluation
  • essay: Free-form text (manual grading)
  • matching: Match items from two lists

Quiz Question Structure

Quiz questions are stored in the quiz_questions table with the following structure:

Resources

Lessons can include downloadable resources linked through the lesson_resources junction table:
{
  "id": "1",
  "title": "Lesson Notes",
  "description": "Detailed notes for this lesson",
  "type": "pdf",
  "url": "https://s3.amazonaws.com/bucket/notes.pdf",
  "file_size": 1024000,
  "mime_type": "application/pdf",
  "download_count": 42
}

Error Codes

Status CodeDescription
200Success
401Unauthorized - Authentication required
403Forbidden - Not enrolled in course
404Not Found - Lesson not found
500Internal Server Error