# academics/urls_report_cards.py
"""
All report card URLs — both PDF endpoints and front-end pages.
Included via: path('academics/', include('academics.urls_report_cards'))
"""
from django.urls import path
from academics.views_report_cards import (
    report_card_preview,
    report_card_pdf_download,
    bulk_class_pdf_download,
    ReportCardAPIView,
    BulkReportCardAPIView,
)
from academics.views_rc_frontend import (
    rc_dashboard,
    rc_marks,
    rc_save_marks,
    rc_init_class,
    rc_compute,
    rc_compute_class,
    rc_detail,
)

urlpatterns = [

    # ── Front-end pages ─────────────────────────────────────────
    # Dashboard: all classes + term selector
    path(
        'report-cards/',
        rc_dashboard,
        name='rc-dashboard'
    ),
    # Mark entry grid: class × term
    path(
        'report-cards/class/<int:class_id>/term/<int:term_id>/marks/',
        rc_marks,
        name='rc-marks'
    ),
    # AJAX: save marks for one student
    path(
        'report-cards/class/<int:class_id>/term/<int:term_id>/save-marks/',
        rc_save_marks,
        name='rc-save-marks'
    ),
    # Initialise report cards for a class/term
    path(
        'report-cards/class/<int:class_id>/term/<int:term_id>/init/',
        rc_init_class,
        name='rc-init-class'
    ),
    # Compute syntheses for all students in a class
    path(
        'report-cards/class/<int:class_id>/term/<int:term_id>/compute/',
        rc_compute_class,
        name='rc-compute-class'
    ),
    # Single student report card detail + comments form
    path(
        'report-cards/<int:pk>/',
        rc_detail,
        name='rc-detail'
    ),
    # Compute one student's synthese
    path(
        'report-cards/<int:pk>/compute/',
        rc_compute,
        name='rc-compute'
    ),

    # ── PDF endpoints ────────────────────────────────────────────
    # HTML preview
    path(
        'report-card/<int:pk>/preview/',
        report_card_preview,
        name='rc-preview'
    ),
    # Single PDF download
    path(
        'report-card/<int:pk>/pdf/',
        report_card_pdf_download,
        name='rc-pdf'
    ),
    # Bulk class PDF download
    path(
        'report-card/bulk/<int:class_id>/<int:term_id>/',
        bulk_class_pdf_download,
        name='rc-bulk'
    ),

    # ── REST API ─────────────────────────────────────────────────
    path(
        'api/report-cards/<int:pk>/pdf/',
        ReportCardAPIView.as_view(),
        name='rc-api-pdf'
    ),
    path(
        'api/report-cards/bulk/',
        BulkReportCardAPIView.as_view(),
        name='rc-api-bulk'
    ),
]
