# api/urls.py (unchanged from your provided version, but included for completeness)

from django.urls import path
from .views import *
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # --- Auth ---
    path('auth/login', LoginView.as_view(), name='login'),
    path('auth/refresh-token', RefreshTokenView.as_view(), name='refresh_token'),
    path('auth/logout', LogoutView.as_view(), name='logout'),
    path('auth/change-password', ChangePasswordView.as_view(), name='change_password'),
    path('auth/me/', current_user, name='current_user'),

    # --- User Management ---
    path('users/', list_users, name='list_users'),                  # GET all users
    path('users/<int:pk>/', user_detail, name='user_detail'),       # GET/PATCH/DELETE specific user
    path('users/teachers', create_teacher, name='create_teacher'),  # POST teacher
    path('users/learners', create_learner, name='create_learner'),  # POST learner
    path('users/parents', create_parent, name='create_parent'),     # POST parent
    path('users/children/', get_children, name='get_children'),
    path('users/class/<int:class_id>/', list_class_students, name='list_class_students'),  # Changed to int:class_id for consistency
    path('link_parent/', link_parent, name='link_parent'),          # POST link parent

    # --- Analytics & Grades ---
    path('grades/', list_grades, name='list_grades'),
    path('analytics/parent/my-children-progress/', my_children_progress, name='my_children_progress'),
    path('teacher/my-classes/', list_teacher_classes, name='teacher_my_classes'),
    path('analytics/teacher/my-classes', list_teacher_classes, name='teacher_my_classes'),

    # --- Learning Areas & Content ---
    path('learning-areas/', list_create_learning_areas, name='list_create_learning_areas'),
    path('learning-areas/<int:pk>/', delete_learning_area, name='delete_learning_area'),
    path('my-learning-areas/', my_learning_areas, name='my_learning_areas'),
    path('available-learning-areas/', available_learning_areas, name='available_learning_areas'),
    path('enroll/learning-area/<int:area_id>/', enroll_learning_area, name='enroll_learning_area'),
    
    path('content/', create_content, name='create_content'),
    path('content/<int:pk>/', delete_content, name='delete_content'),
    path('content/learning-area/<int:learning_area_id>/', get_content, name='get_content'),
    path('content/progress/<int:content_id>/', content_progress, name='content_progress'),

    # --- Class Streams & Allocations ---
    path('classes/', list_create_class_streams, name='list_create_class_streams'),
    path('classes/<int:pk>/', delete_class_stream, name='delete_class_stream'),
    path('allocations/', list_create_allocations, name='list_create_allocations'),
    path('allocations/<int:pk>/', delete_allocation, name='delete_allocation'),
    path('my-allocations/', my_allocations, name='my_allocations'),

    # --- Quizzes ---
    path('quizzes/', create_quiz, name='create_quiz'),  # POST create quiz
    path('quizzes/teacher/<int:subject_id>/', teacher_quizzes, name='teacher_quizzes'),  # GET teacher's quizzes for subject
    path('quizzes/<int:pk>/', quiz_detail, name='quiz_detail'),  # GET/PUT/DELETE single quiz
    path('quizzes/<int:quiz_id>/attempt/', submit_quiz_attempt, name='submit_quiz_attempt'),  # POST attempt
    path('quizzes/student/my-quizzes/', my_quizzes, name='my_quizzes'),  # GET student's quizzes
    path('progress/my-progress/', my_progress, name='my_progress'),

    # --- Attendance ---
    path('attendance/record', record_attendance, name='record_attendance'),
    path('attendance/class/<int:class_id>/', get_class_attendance, name='get_class_attendance'),

    path('users/import-csv/', import_learners_csv, name='import_learners_csv'),
    
    # --- Student Class Info ---
    path('classes/student/my-class/', my_class_stream, name='my_class_stream'),

    path('admin/reset-user-password/', reset_user_password, name='reset_user_password'),
    path('admin/settings/', admin_settings, name='admin_settings'),
    path('admin/stats/', system_stats, name='system_stats'),
    path('admin/activity-logs/', activity_logs, name='user_activity_logs'),
    path('admin/bulk-actions/', bulk_user_actions, name='bulk_user_actions'),
    path('admin/export-users/', export_users_csv, name='export_users_csv'),
    path('admin/send-notifications/', send_bulk_notifications, name='send_bulk_notifications'),
    path('admin/create-admin/', create_admin_user, name='create_admin_user'),
    path('admin/audit-logs/', audit_logs, name='audit_logs'),

    path('teacher/classes/', list_teacher_classes, name='teacher-classes'),

    path('class/<int:class_id>/students/', list_class_students, name='class-students'),
    path('teacher/quizzes/<int:subject_id>/', teacher_quizzes, name='teacher-quizzes'),
    path('quiz/<int:quiz_id>/attempts/', quiz_attempts, name='quiz-attempts'),
    path('admin/system-stats/', system_stats, name='system-stats'),
    path('admin/import-learners-csv/', import_learners_csv, name='import-learners-csv'),
    path('admin-quiz-analytics/', admin_quiz_analytics, name='admin-quiz-analytics'),
    path('admin-student-analytics/',admin_student_analytics,name='admin_student_analytics')
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)