This document describes the TeacherCourseViewSet endpoints for managing courses, lessons, quizzes, questions, challenges, and AI-powered editing.
IsTeacher permissionteacher/courses/
GET /teacher/courses/ → List teacher’s coursesGET{
"id": 18,
"title": "Python for Beginners 4",
"description": "Learn Python from scratch with hands-on projects.",
"created_at": "2025-08-19T22:40:59.070736+03:30",
"updated_at": "2025-08-19T22:40:59.070952+03:30",
"published": true,
"image_url": "https://example.com/python-course.png",
"enroll_count": 0,
"lesson_count": 15,
"language": "English",
"level": "beginner",
"teacher": 1,
"category": 1
},
GET /teacher/courses/{id}/ → Retrieve a course
Description: Get the Course = pk
Method: GET
Output:
{
"id": 18,
"title": "Python for Beginners 4",
"description": "Learn Python from scratch with hands-on projects.",
"created_at": "2025-08-19T22:40:59.070736+03:30",
"updated_at": "2025-08-19T22:40:59.070952+03:30",
"published": true,
"image_url": "https://example.com/python-course.png",
"enroll_count": 0,
"lesson_count": 15,
"language": "English",
"level": "beginner",
"teacher": 1,
"category": 1
},
POST /teacher/courses/ → Create a course (teacher auto-assigned)
Description: Post new course
Method: POST
Input:
{
"title": "PHP",
"description": "Learn Python from scratch with hands-on projects.",
"category": 1,
"published": true,
"image_url": "https://example.com/python-course.png",
"language": "English",
"level": "beginner"
}
{
"id": 22,
"title": "PHP",
"description": "Learn Python from scratch with hands-on projects.",
"created_at": "2025-08-27T19:30:51.508921+03:30",
"updated_at": "2025-08-27T19:30:51.509052+03:30",
"published": true,
"image_url": "https://example.com/python-course.png",
"enroll_count": 0,
"lesson_count": 15,
"language": "English",
"level": "beginner",
"teacher": 1,
"category": 1
}
PATCH /teacher/courses/{id}/ → Partially update
PUT /teacher/courses/{id}/ → Update a course
Description: Put the changes
Method: PUT / PATCH
Input:
{
"title": "PHP 1",
"description": "Learn Python from scratch with hands-on projects.",
"category": 1,
"published": true,
"image_url": "https://example.com/python-course.png",
"language": "English",
"level": "beginner"
}
{
"title": "PHP 1",
"description": "Learn Python from scratch with hands-on projects.",
"category": 1,
"published": true,
"image_url": "https://example.com/python-course.png",
"language": "English",
"level": "beginner"
}
DELETE /teacher/courses/{id}/ → DeletePOST /teacher/courses/img_generate_ai/
Body:
{ "course_title": "Python Basics" }
Response:
{ "imag_url": "https://..." }
POST /teacher/courses/{id}/challenge_generate_ai/
Body:
{ "number": 3 }
Response:
{
"message": "3 challenges created",
"challenges": [{ "id": 1, "topic": "Loops" }]
}
POST /teacher/courses/{id}/generate_challenges/
Body:
{
"topic": "Recursion",
"challenge_text": "Write factorial function",
"difficulty": "medium",
"answers": ["def fact(n): ..."]
}
Response:
{ "message": "challenges are made", "id": 10 }
GET /teacher/courses/{id}/get_challenges/
Description: Get the challenges for course = 5
Get [
{
"id": 4,
"topic": "آشنایی با متغیرها و انواع داده در C#",
"challenge_text": "یک برنامه ساده در زبان C# بنویسید که دو عدد صحیح از ورودی دریافت کند و مجموع آنها را محاسبه و نمایش دهد.",
"difficulty": "easy",
"language": "Persian",
"answers": [
"using System;\n\nclass Program\n{\n static void Main()\n {\n Console.WriteLine(\"عدد اول را وارد کنید:\");\n int number1 = Convert.ToInt32(Console.ReadLine());\n\n Console.WriteLine(\"عدد دوم را وارد کنید:\");\n int number2 = Convert.ToInt32(Console.ReadLine());\n\n int sum = number1 + number2;\n Console.WriteLine(\"مجموع دو عدد: \" + sum);\n }\n}"
]
},
},
POST /teacher/courses/{id}/add_lesson/
Description: Add lesson for course = 8
Method: POST
Input:
{
"title": "Introduction to Django",
"description": "Getting started with Django framework.",
"content": "In this lesson we cover installation and setup.",
"order": 2
}
{
"id": 53,
"title": "Introduction to Django",
"description": "Getting started with Django framework.",
"content": "In this lesson we cover installation and setup.",
"order": 2,
"created_at": "2025-08-27T20:07:29.080339+03:30",
"course": 8,
"audio": null
}
GET /teacher/courses/{id}/get_lessons/
Description: GET the lessons for course = 8
Method: GET
Output:
{
"id": 42,
"title": "Updated Lesson Title",
"description": "Getting started with Django framework.",
"content": "This is the new content",
"order": 1,
"created_at": "2025-08-19T15:32:00.444874+03:30",
"course": 8,
"audio": null
},
GET /teacher/courses/{id}/lessons/{lesson_id}/
Description: GET the lesson = 42 for course = 8 (USE FOR UPDATING)
Method: GET
Output:
{
"id": 42,
"title": "Updated Lesson Title",
"description": "Getting started with Django framework.",
"content": "This is the new content",
"order": 1,
"created_at": "2025-08-19T15:32:00.444874+03:30",
"course": 8,
"audio": null
}
PATCH/PUT /teacher/courses/{id}/lessons/{lesson_id}/update_lesson/AI Lesson Improvement
POST /teacher/courses/{id}/lessons/{lesson_id}/ai_edit/
Description: Edit with AI
Method: POST
Output:
{
"id": 1,
"title": "1",
"description": "English tutorial for beginners",
"content": "ABCD / دستور زبان ساده\n\nدر این درس، قصد داریم به بررسی مبانی دستور زبان انگلیسی بپردازیم. این مباحث شامل الفبای انگلیسی و نحوه استفاده صحیح از آنها در جملات است. یادگیری این اصول پایهای به شما کمک میکند تا در مکالمات و نوشتارهای روزمره به صورت دقیقتر و موثرتر عمل کنید.\n\n### الفبای انگلیسی\n\nالفبای انگلیسی شامل ۲۶ حرف است که به دو دسته حروف بزرگ (capital letters) و حروف کوچک (lowercase letters) تقسیم میشوند. یادگیری الفبای انگلیسی اولین گام در فراگیری زبان است.\n\n**مثال:**\n\n- حروف بزرگ: A, B, C, D\n- حروف کوچک: a, b, c, d\n\n### ساختار جمله\n\nدر زبان انگلیسی، هر جمله معمولاً شامل سه بخش اصلی است: فاعل (subject)، فعل (verb)، و مفعول (object). ترتیب این اجزا در جمله بسیار مهم است و به فهم بهتر کمک میکند.\n\n**مثال:**\n\n- جمله: \"The cat eats fish.\"\n - فاعل: The cat\n - فعل: eats\n - مفعول: fish\n\n### نکات کاربردی\n\n1. **تمرین تلفظ:**\n - برای بهتر شدن در تلفظ حروف، میتوانید از منابع آنلاین یا اپلیکیشنهای آموزشی استفاده کنید.\n \n2. **نوشتن روزانه:**\n - سعی کنید روزانه چند جمله ساده با استفاده از حروف و کلمات جدیدی که یاد میگیرید بنویسید. این کار به تقویت مهارتهای نوشتاری شما کمک میکند.\n\n3. **خواندن و گوش دادن:**\n - کتابهای ساده یا داستانهای کوتاه بخوانید و به پادکستها یا فایلهای صوتی آموزشی گوش دهید تا به مرور با ساختار جملات و کاربرد صحیح حروف آشنا شوید.\n\n### نتیجهگیری\n\nیادگیری الفبای انگلیسی و اصول اولیه دستور زبان، پایهای محکم برای یادگیری زبان فراهم میکند. با تمرین مداوم و استفاده از منابع آموزشی متنوع، میتوانید مهارتهای زبانی خود را به سطح بالاتری ارتقا دهید.",
"order": 1,
"created_at": "2025-08-12T10:41:22.387044+03:30",
"course": 1,
"audio": null
}
GET /teacher/courses/{id}/get_quizzes/
Description: get quiz of course = 1
Method: GET
Output:
{
"id": 1,
"title": "quiz",
"lesson": 1
},
POST /teacher/courses/{id}/lessons/{lesson_id}/add_quiz/
Description: Add quiz for course = 1
Method: POST
Input:
{
"title" : "For loop"
}
{
"id": 4,
"title": "For loop",
"lesson": 1
}
GET /teacher/courses/{id}/lessons/{lesson_id}/quiz/{quiz_id}/retrieve_quiz/
Description: GET the quiz = 5 for lesson = 1 for course = 1 (USE FOR UPDATING)
Method: GET
Output:
{
"id": 5,
"title": "For loop1",
"lesson": 1
}
PATCH/PUT /teacher/courses/{id}/lessons/{lesson_id}/quiz/{quiz_id}/update_quiz/
Description: Update quiz
Method: PUT/PATCH
Input:
{
"title" : "For loop 3 "
}
{
"id": 5,
"title": "For loop 3",
"lesson": 1
}
POST /teacher/courses/quiz/{quiz_id}/add_question/
Description: Add question for quiz = 2
Method: POST
Input:
{
"question_text": "which one is hi",
"option_1": "hello",
"option_2": "hi",
"option_3": "bye",
"option_4": "hey",
"correct_option": "1"
}
{
"id": 2,
"question_text": "which one is hi",
"option_1": "hello",
"option_2": "hi",
"option_3": "bye",
"option_4": "hey",
"correct_option": "1",
"quiz": 2
}
GET /teacher/courses/quiz/{quiz_id}/get_question/
Description: get quiz = 2
Method: GET
Output:
{
"id": 1,
"question_text": "which one is hi",
"option_1": "hello",
"option_2": "hi",
"option_3": "bye",
"option_4": "hey",
"correct_option": "1",
"quiz": 2
}
GET /teacher/courses/quiz/{quiz_id}/question/{question_id}/retrieve_question/
Description: GET the question = 1 for quiz = 1 (USE FOR UPDATING)
Method: GET
Output:
{
"id": 1,
"question_text": "which one is hi",
"option_1": "hello",
"option_2": "hi",
"option_3": "bye",
"option_4": "hey",
"correct_option": "1",
"quiz": 2
}
PATCH/PUT /teacher/courses/{id}/quiz/{quiz_id}/question/{question_id}/update_question/
Description: Update question
Method: PUT/PATCH
Input:
{
"question_text": "which one is hi 2",
"option_1": "hello",
"option_2": "hi",
"option_3": "bye",
"option_4": "hey",
"correct_option": "1"
}
{
"id": 1,
"question_text": "which one is hi 2",
"option_1": "hello",
"option_2": "hi",
"option_3": "bye",
"option_4": "hey",
"correct_option": "1",
"quiz": 2
}
PATCH /teacher/courses/{id}/update_price/
Body:
{ "price": 49.99 }
Response:
{ "id": 3, "title": "Python Basics", "price": 49.99 }
400 Bad Request → Missing/invalid fields403 Forbidden → AI edit daily limit reached404 Not Found → Lesson/Quiz/Question not found500 Internal Server Error → AI generation failure