from django.urls import path, include

from rapids.models import Answer
from . import views

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

app_name = "rapids"



urlpatterns = [
    #path("", views.GenericExamViews.index, name="index"),
    #path("exam", generic_exam_urls(views.GenericExamViews), name="index"),
    path("question_viewer", views.question_viewer, name="question_viewer"),
    path("question/", views.RapidView.as_view(), name="question_view"),
    path("question/hash", views.get_question_by_hash, name="rapid_question_by_hash"),
    # path("unchecked/", views.unchecked_list, name="unchecked_list"),
    # path("verified/<int:pk>/", views.verified_detail, name="verified_detail"),
    path("question/<int:pk>/json", views.question_json, name="question_json"),
    path(
        "question/<int:pk>/json/unbased",
        views.question_json_unbased,
        name="question_json_unbased",
    ),
    path(
        "question/<int:pk>/save_annotation",
        views.question_save_annotation,
        name="question_save_annotation",
    ),
    path("question/<int:pk>/split", views.rapid_split, name="rapid_split"),
    path("question/<int:pk>/migrate", views.question_migrate_to_shorts, name="question_migrate_to_shorts"),
    path("question/<int:pk>/clone", views.RapidClone.as_view(), name="rapid_clone"),
    # path("verified/", views.verified, name="verified"),
    # path("all_questions/", views.all_questions, name="all_questions"),
    path("question/<int:pk>/scrap", views.rapid_scrap, name="rapid_scrap"),
    path(
        "question/<int:pk>/delete",
        views.QuestionDelete.as_view(),
        name="question_delete",
    ),
    path(
        "question/<int:pk>/anon",
        views.question_anonymise_dicom,
        name="question_anonymise_dicom",
    ),
    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: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("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>/migrate_all", views.exam_migrate_rapids_to_shorts, name="exam_migrate_rapids_to_shorts"),
    path("exam/<int:pk>/delete", views.ExamDelete.as_view(), name="exam_delete"),
    path("create/", views.RapidCreate.as_view(), name="question_create"),
    path("create/exam/<int:pk>", views.RapidCreate.as_view(), name="question_create_exam"),
    path("region/create/", views.create_region, name="create_region"),
    path("region/ajax/get_region_id", views.get_region_id, name="get_region_id"),
    path("abnormality/create/", views.create_abnormality, name="create_abnormality"),
    path(
        "abnormality/ajax/get_abnormality_id",
        views.get_abnormality_id,
        name="get_abnormality_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(
        "question/<int:pk>/update",
        views.RapidUpdate.as_view(),
        name="rapid_update",
    ),
    path(
        "question/<int:pk>/update_answers",
        views.RapidAnswerUpdate.as_view(),
        name="question_answer_update",
    ),
    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(
        "answer-autocomplete",
        views.AnswerAutocomplete.as_view(
            model=Answer, create_field="answer"
        ),
        name="answer-autocomplete",
    ),
]

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