diff --git a/sbas/templates/sbas/partials/exam_review_question_fragment.html b/sbas/templates/sbas/partials/exam_review_question_fragment.html index bdba3cf6..ef09f971 100644 --- a/sbas/templates/sbas/partials/exam_review_question_fragment.html +++ b/sbas/templates/sbas/partials/exam_review_question_fragment.html @@ -109,39 +109,19 @@ View full question details

- {# Show responses given during this exam for the question #} + {# Responses partial: load on demand via HTMX. Button fetches partial into #responses-container #}
-
Responses in this exam
-
List of candidate answers recorded for this question in the current exam.
- -
+
+
+ +
+
+
+
Responses are hidden — click “Show responses” to load.
+
{% if prev_index is not None %} diff --git a/sbas/templates/sbas/partials/exam_review_question_responses_fragment.html b/sbas/templates/sbas/partials/exam_review_question_responses_fragment.html new file mode 100644 index 00000000..9dfce6fd --- /dev/null +++ b/sbas/templates/sbas/partials/exam_review_question_responses_fragment.html @@ -0,0 +1,33 @@ +{# Partial: responses for a question within an exam. Rendered server-side or via HTMX. #} +
+
Responses in this exam
+
List of candidate answers recorded for this question in the current exam.
+ +
diff --git a/sbas/urls.py b/sbas/urls.py index cf911d4d..fc7339bd 100644 --- a/sbas/urls.py +++ b/sbas/urls.py @@ -117,6 +117,11 @@ urlpatterns = [ ), path("search/", views.question_search_page, name="question_search_page"), path("search/questions/", views.question_search_partial, name="question_search_partial"), + path( + "exam//review//responses", + views.exam_review_question_responses, + name="exam_review_question_responses", + ), path("question//toggle_frcr/", views.toggle_frcr_appropriate, name="toggle_frcr"), path("category/merge/", views.merge_category, name="merge_category"), #path( diff --git a/sbas/views.py b/sbas/views.py index 5941aa14..0dcc022e 100644 --- a/sbas/views.py +++ b/sbas/views.py @@ -87,6 +87,31 @@ from .forms import ( ) +@login_required +def exam_review_question_responses(request, pk: int, q_index: int): + """Return the responses partial for a given exam question (HTMX-friendly). + + pk: exam pk + q_index: question index within the exam + """ + exam = get_object_or_404(Exam, pk=pk) + + questions = exam.get_questions() + try: + question = questions[q_index] + except Exception: + raise Http404("Question not found in exam") + + context = { + "exam": exam, + "question": question, + "q_index": q_index, + "app_name": "sbas", + } + + return render(request, "sbas/partials/exam_review_question_responses_fragment.html", context) + + class AuthorOrCheckerRequiredMixin(object): def get_object(self, *args, **kwargs): obj = super().get_object(*args, **kwargs)