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 = "sbas"

urlpatterns = [
    path("question/", views.QuestionView.as_view(), name="question_view"),
    #path("question/<int:pk>/", views.question_detail, name="question_detail"),
    path("question/create/", views.QuestionCreate.as_view(), name="question_create"),
    path(
        "question/<int:pk>/update",
        views.QuestionUpdate.as_view(),
        name="question_update",
    ),
    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(
        "exam/<int:pk>/<int:sk>/<str:cid>/<str:passcode>/take",
        views.exam_take,
        name="exam_take",
    ),
    path(
        "exam/<int:pk>/<int:sk>/<str:cid>/<str:passcode>/take_fragment",
        views.exam_take_fragment,
        name="exam_take_fragment",
    ),
    path(
        "exam/<int:pk>/<int:sk>/take",
        views.exam_take,
        name="exam_take_user",
    ),
    path(
        "exam/<int:pk>/<int:sk>/take_fragment",
        views.exam_take_fragment,
        name="exam_take_fragment_user",
    ),
    # Flag toggle (HTMX)
    path(
        "exam/<int:pk>/<int:sk>/toggle_flag",
        views.exam_toggle_flag,
        name="exam_toggle_flag_user",
    ),
    path(
        "exam/<int:pk>/<int:sk>/<str:cid>/<str:passcode>/toggle_flag",
        views.exam_toggle_flag,
        name="exam_toggle_flag",
    ),
    path("exam/<int:pk>/start", views.exam_start, name="exam_start"),
    path(
        "exam/<int:pk>/<str:cid>/<str:passcode>/finish",
        views.exam_take_overview,
        name="exam_take_overview",
    ),
    path(
        "exam/<int:pk>/finish",
        views.exam_take_overview,
        name="exam_take_overview_user",
    ),
    path(
        "exam/<int:pk>/<str:cid>/<str:passcode>/complete",
        views.exam_complete,
        name="exam_complete",
    ),
    path(
        "exam/<int:pk>/complete",
        views.exam_complete,
        name="exam_complete_user",
    ),

    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/<int:exam_id>/clone", views.ExamClone.as_view(), name="exam_clone"),
    path("exam/<int:exam_id>/clone2", views.exam_clone2, name="exam_clone2"),
    path("exam/available", views.active_exams, name="active_exams"),
    path("exam/create", views.ExamCreate.as_view(), name="exam_create"),
    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("exam/json/<int:pk>", views.exam_json, name="exam_json"),
    # path("exam/json/<int:pk>/recreate", views.exam_json_recreate, name="exam_json_recreate"),
    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(
        "llm_prompts/",
        views.llm_prompt_view,
        name="llm_prompt_view",

    )
    ,
    path(
        "import_llm_questions/",
        views.import_llm_questions,
        name="import_llm_questions",
    ),
    path(
        "import_llm_confirm/",
        views.import_llm_confirm,
        name="import_llm_confirm",
    ),

    path(
        "exam/create_from_filters_with_name/",
        views.create_personal_exam_with_name,
        name="exam_create_from_filters_with_name",
    ),
    path(
        "question/generate/",
        views.generate_exam,
        name="generate_exam",
    ),
    path(
        "question/overview/",
        views.question_overview,
        name="question_overview",
    ),
    path("search/", views.question_search_page, name="question_search_page"),
    path("search/questions/", views.question_search_partial, name="question_search_partial"),
    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",
    ),
    path(
        "exam/<int:pk>/review/<int:q_index>/responses",
        views.exam_review_question_responses,
        name="exam_review_question_responses",
    ),
    path("question/<int:pk>/toggle_frcr/", views.toggle_frcr_appropriate, name="toggle_frcr"),
    path("category/merge/", views.merge_category, name="merge_category"),
]

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