diff --git a/anatomy/templates/anatomy/partials/exam_review_question_fragment.html b/anatomy/templates/anatomy/partials/exam_review_question_fragment.html new file mode 100644 index 00000000..f525b4fa --- /dev/null +++ b/anatomy/templates/anatomy/partials/exam_review_question_fragment.html @@ -0,0 +1,33 @@ +
+
+
Anatomy
+
Question
+

{{ question }}

+ +

+ View full question details +

+ +
+ {% if prev_index is not None %} + ← Previous + {% else %} + + {% endif %} + + {% if next_index is not None %} + Next → + {% else %} + Complete review + {% endif %} +
+
+
diff --git a/atlas/templates/atlas/partials/exam_review_question_fragment.html b/atlas/templates/atlas/partials/exam_review_question_fragment.html new file mode 100644 index 00000000..ff831454 --- /dev/null +++ b/atlas/templates/atlas/partials/exam_review_question_fragment.html @@ -0,0 +1,33 @@ +
+
+
Atlas
+
Question
+

{{ question }}

+ +

+ View full question details +

+ +
+ {% if prev_index is not None %} + ← Previous + {% else %} + + {% endif %} + + {% if next_index is not None %} + Next → + {% else %} + Complete review + {% endif %} +
+
+
diff --git a/generic/templates/generic/exam_review_question.html b/generic/templates/generic/exam_review_question.html index 232eb222..c1bea05d 100644 --- a/generic/templates/generic/exam_review_question.html +++ b/generic/templates/generic/exam_review_question.html @@ -6,7 +6,10 @@
{# The #review-content element is replaced by HTMX when navigating between questions. #}
- {% include 'generic/partials/exam_review_question_fragment.html' %} + {# The view selects an app-specific fragment if present and passes its name + in `fragment_template`. Include that fragment here so the full-page + render and the HTMX partials both use the same template. #} + {% include fragment_template %}
diff --git a/generic/views.py b/generic/views.py index b4a5b3de..a7b1839c 100644 --- a/generic/views.py +++ b/generic/views.py @@ -1216,8 +1216,31 @@ class ExamViews(View, LoginRequiredMixin): "can_edit": self.check_user_edit_access(request.user, exam_id=pk), } - if request.htmx: - return render(request, "generic/partials/exam_review_question_fragment.html", context) + # Choose an app-specific fragment if present, otherwise fall back to + # the generic fragment. Expose the chosen fragment name in the + # context so the full-page render can include it; return the fragment + # directly for HTMX requests. + from django.template import loader + + fragment_candidates = [ + f"{self.app_name}/partials/exam_review_question_fragment.html", + "generic/partials/exam_review_question_fragment.html", + ] + template = loader.select_template(fragment_candidates) + fragment_template_name = template.template.name + context["fragment_template"] = fragment_template_name + + # Detect HTMX: prefer the request.htmx attribute when available, otherwise + # check the HX-Request header. + is_htmx = getattr(request, "htmx", False) + if not is_htmx: + try: + is_htmx = request.headers.get("HX-Request", "").lower() == "true" + except Exception: + is_htmx = request.META.get("HTTP_HX_REQUEST", "") == "true" + + if is_htmx: + return render(request, fragment_template_name, context) return render(request, "generic/exam_review_question.html", context) diff --git a/longs/templates/longs/partials/exam_review_question_fragment.html b/longs/templates/longs/partials/exam_review_question_fragment.html new file mode 100644 index 00000000..a35d94b3 --- /dev/null +++ b/longs/templates/longs/partials/exam_review_question_fragment.html @@ -0,0 +1,33 @@ +
+
+
Longs
+
Question
+

{{ question }}

+ +

+ View full question details +

+ +
+ {% if prev_index is not None %} + ← Previous + {% else %} + + {% endif %} + + {% if next_index is not None %} + Next → + {% else %} + Complete review + {% endif %} +
+
+
diff --git a/physics/templates/physics/partials/exam_review_question_fragment.html b/physics/templates/physics/partials/exam_review_question_fragment.html new file mode 100644 index 00000000..6b74b338 --- /dev/null +++ b/physics/templates/physics/partials/exam_review_question_fragment.html @@ -0,0 +1,33 @@ +
+
+
Physics
+
Question
+

{{ question }}

+ +

+ View full question details +

+ +
+ {% if prev_index is not None %} + ← Previous + {% else %} + + {% endif %} + + {% if next_index is not None %} + Next → + {% else %} + Complete review + {% endif %} +
+
+
diff --git a/rapids/templates/rapids/partials/exam_review_question_fragment.html b/rapids/templates/rapids/partials/exam_review_question_fragment.html new file mode 100644 index 00000000..d7fc0ad0 --- /dev/null +++ b/rapids/templates/rapids/partials/exam_review_question_fragment.html @@ -0,0 +1,33 @@ +
+
+
Rapids
+
Question
+

{{ question }}

+ +

+ View full question details +

+ +
+ {% if prev_index is not None %} + ← Previous + {% else %} + + {% endif %} + + {% if next_index is not None %} + Next → + {% else %} + Complete review + {% endif %} +
+
+
diff --git a/sbas/templates/sbas/partials/exam_review_question_fragment.html b/sbas/templates/sbas/partials/exam_review_question_fragment.html new file mode 100644 index 00000000..16586772 --- /dev/null +++ b/sbas/templates/sbas/partials/exam_review_question_fragment.html @@ -0,0 +1,33 @@ +
+
+
SBAs
+
Question
+

{{ question }}

+ +

+ View full question details +

+ +
+ {% if prev_index is not None %} + ← Previous + {% else %} + + {% endif %} + + {% if next_index is not None %} + Next → + {% else %} + Complete review + {% endif %} +
+
+
diff --git a/shorts/templates/shorts/partials/exam_review_question_fragment.html b/shorts/templates/shorts/partials/exam_review_question_fragment.html new file mode 100644 index 00000000..6593a2c3 --- /dev/null +++ b/shorts/templates/shorts/partials/exam_review_question_fragment.html @@ -0,0 +1,33 @@ +
+
+
Shorts
+
Question
+

{{ question }}

+ +

+ View full question details +

+ +
+ {% if prev_index is not None %} + ← Previous + {% else %} + + {% endif %} + + {% if next_index is not None %} + Next → + {% else %} + Complete review + {% endif %} +
+
+