Implement HTMX-based loading of exam question responses and add corresponding view and URL routing

This commit is contained in:
Ross
2025-11-09 22:01:57 +00:00
parent c89c14b89e
commit ae720662f7
4 changed files with 75 additions and 32 deletions
+25
View File
@@ -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)