Implement HTMX-based loading of exam question responses and add corresponding view and URL routing
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user