from django.urls import path, include

from generic.urls import generic_exam_urls, generic_view_urls
from . import views
from django.views.decorators.cache import cache_page

app_name = "anatomy"

urlpatterns = [
    # path('', views.question_view, name='question_view'),
    path(
        "question/",
        views.AnatomyQuestionView.as_view(),
        name="question_view",
    ),
    path(
        "question/create/",
        views.AnatomyQuestionCreate.as_view(),
        name="question_create",
    ),
    path(
        "question/<int:pk>/update",
        views.AnatomyQuestionUpdate.as_view(),
        name="anatomy_question_update",
    ),
    path(
        "question/<int:pk>/update_answers",
        views.AnatomyQuestionAnswerUpdate.as_view(),
        name="question_answer_update",
    ),
    path(
        "question/<int:pk>/save_annotation",
        views.question_save_annotation,
        name="question_save_annotation",
    ),
    path(
        "question/<int:pk>/clear_annotation",
        views.question_clear_annotation,
        name="question_clear_annotation",
    ),
    path(
        "question/<int:pk>/suggest_incorrect_answers",
        views.question_suggest_incorrect_answers,
        name="question_suggest_incorrect_answers",
    ),
    path(
        "question/<int:pk>/suggest_incorrect_collapsed",
        views.question_suggest_incorrect_collapsed,
        name="question_suggest_incorrect_collapsed",
    ),

    path("question/<int:pk>/answer/", views.answer_question, name="answer_question"),
    path(
        "question/<int:pk>/clone", views.QuestionClone.as_view(), name="question_clone"
    ),
    path(
        "question/<int:pk>/delete",
        views.QuestionDelete.as_view(),
        name="question_delete",
    ),
    path(
        "question/<int:question_id>/add_exam",
        views.question_add_exam,
        name="question_add_exam",
    ),
    path("answer/<int:answer_id>/confirm", views.confirm_answer, name="confirm_answer"),
    path("answer/<int:answer_id>/delete", views.delete_answer, name="delete_answer"),
    path("exam/<int:exam_pk>/<int:sk>/mark", views.mark, name="mark"),
    path("exam/<int:exam_pk>/<int:sk>/mark/all", views.mark_all, name="mark_all"),
    path(
        "exam/<int:exam_pk>/<int:sk>/mark/review", views.mark_review, name="mark_review"
    ),
    path("exam/<int:pk>/markers", views.ExamMarkersUpdate.as_view(), name="exam_markers"),
    path("exam/<int:pk>/groups", views.ExamGroupsUpdate.as_view(), name="exam_groups_edit"),
    path("exam/<int:pk>/authors", views.ExamAuthorUpdate.as_view(), name="exam_authors"),
    path("exam/create", views.ExamCreate.as_view(), name="exam_create"),
    path("exam/<int:exam_id>/clone", views.ExamClone.as_view(), name="exam_clone"),
    path("exam/<int:pk>/update", views.ExamUpdate.as_view(), name="exam_update"),
    path("exam/<int:pk>/delete", views.ExamDelete.as_view(), name="exam_delete"),
    path("body_part/create/", views.create_body_part, name="create_body_part"),
    path(
        "body_part/ajax/get_body_part_id",
        views.get_body_part_id,
        name="get_body_part_id",
    ),
    path("examination/create/", views.create_examination, name="create_examination"),
    path(
        "examination/ajax/get_examination_id",
        views.get_examination_id,
        name="get_examination_id",
    ),
    path(
        "user_answers/",
        views.UserAnswerTableView.as_view(),
        name="user_answer_table_view",
    ),
    path(
        "user_answers/<int:pk>", views.UserAnswerView.as_view(), name="user_answer_view"
    ),
    path(
        "user_answers/<int:pk>/delete",
        views.UserAnswerDelete.as_view(),
        name="user_answer_delete",
    ),
    path(
        "exam/<int:pk>/review/<int:q_index>/responses",
        views.exam_review_question_responses,
        name="exam_review_question_responses",
    ),
    path(
        "exam/<int:pk>/review/<int:q_index>/summary",
        views.exam_review_question_summary,
        name="exam_review_question_summary",
    ),
    # New improved marking UI (mark2) and small toggle endpoint used by JS/HTMX
    path("exam/<int:exam_pk>/<int:sk>/mark2", views.mark2, name="mark2"),
    path("exam/<int:pk>/mark2", views.mark2_overview, name="mark2_overview"),
    path("exam/mark2/toggle", views.mark2_toggle_answer, name="mark2_toggle_answer"),
    path("exam/<int:exam_pk>/<int:sk>/mark2/exam_marked", views.mark2_exam_marked, name="mark2_exam_marked"),
    path("question/<int:pk>/mark2/question_marked", views.mark2_question_marked, name="mark2_question_marked"),
    path("exam/mark2/edit_answer", views.mark2_edit_answer, name="mark2_edit_answer"),
    path("question/<int:pk>/primary_answer/", views.primary_answer_htmx, name="primary_answer_htmx"),
]

urlpatterns.extend(generic_view_urls(views.GenericViews))
urlpatterns.extend(generic_exam_urls(views.GenericExamViews))