{% extends "base.html" %} {% block content %}

{{ institution|upper }}

{% if level and alias %}Level {{ level }} ({{ alias }}) {% elif level %}Level {{ level }} {% elif alias %}{{ alias }} {% endif %}

{% if date %} Exam Date: {{ date }}{% else %}Exam Date: (not specified){% endif %}

{% if paper_obj %} {% set _ps = lookup_paper(paper_obj.paper_key) %} {% if _ps and _ps.syllabus %}
๐Ÿ“š {{ _ps.syllabus.display_name }}{% if _ps.syllabus.level %} (Level {{ _ps.syllabus.level }}){% endif %}
{% endif %} ๐Ÿ“„ {{ paper_obj.display_name }} {% elif paper %} {{ paper }} {% endif %}

Exam Date: {{ date if date else 'N/A' }} {% if total_questions is defined and total_questions %} ยท {{ total_questions }} questions ยท {{ total_marks }} marks {% endif %}

Instructions: Answer all questions. Each question carries marks as indicated.
{% set ns = namespace(last_pid=None) %} {% for group, subjects in grouped.items()|sort %}

Group: {{ group }}

{% for subject, qs in subjects.items()|sort %}

{{ subject }}

    {% for q in qs|sort(attribute='question_number') %} {# ---------- Reading passage: print once when it changes ---------- #} {% if q.passage_id and q.passage_id != ns.last_pid %} {% set _p = get_passage(q.passage_id) %} {% if _p and _p.content %}
  • ๐Ÿ“– Reading Passage
    {{ _p.content }}
  • {% set ns.last_pid = q.passage_id %} {% endif %} {% endif %}
  • {% if q.notes %}
    {{ q.notes }}
    {% endif %}
    {{ q.question_number }}.
    {% if q.marks %} {{ q.marks }} marks {% endif %} {% if q.chapter %} {{ q.chapter }} {% endif %} {% if q.syllabus_code %} {{ q.syllabus_code }} {% endif %} {% set _et = (q.exam_type or 'open')|lower %} {% if _et != 'open' %} {{ _et|capitalize }} {% endif %}
    {% if q.source %} {% set _src_parts = [] %} {% for _s in q.source.split('\n') %} {% if _s.strip() and _s.strip() not in _src_parts %} {% set _ = _src_parts.append(_s.strip()) %} {% endif %} {% endfor %} {% if _src_parts %}
    ๐Ÿ”– {{ _src_parts | join(' ยท ') }}
    {% endif %} {% endif %}
    {% if q.nepali_transcription and q.english_transcription %} {{ q.nepali_transcription|safe }} ({{ q.english_transcription|safe }}) {% elif q.nepali_transcription %} {{ q.nepali_transcription|safe }} {% elif q.english_transcription %} {{ q.english_transcription|safe }} {% endif %}
    {# ---------- MULTICHOICE ---------- #} {% if q.type == 'multichoice' and q.options %}
      {% for opt in q.options %}
    • {{ 'ABCDEFGH'[loop.index0] }}. {{ opt.text|safe }} {% if opt.correct %}โœ“{% endif %}
    • {% endfor %}
    {# ---------- TRUE / FALSE ---------- #} {% elif q.type == 'truefalse' and q.options %}
      {% for opt in q.options %}
    • ( ) (โœ“) {{ opt.text }}
    • {% endfor %}
    {% if q.feedback_true %}
    If answered True: {{ q.feedback_true|safe }}
    {% endif %} {% if q.feedback_false %}
    If answered False: {{ q.feedback_false|safe }}
    {% endif %} {# ---------- MATCHING ---------- #} {% elif q.type == 'matching' and q.pairs %}
    Sub-questions
      {% for pair in q.pairs %}
    1. {{ pair.subquestion }}
    2. {% endfor %}
    Answer bank
    {% set seen_answers = [] %} {% for pair in q.pairs %} {% if pair.answer not in seen_answers %} {% set _ = seen_answers.append(pair.answer) %} {% endif %} {% endfor %}
      {% for ans in seen_answers|sort %}
    • {{ ans }}
    • {% endfor %}
    {% for pair in q.pairs %} {% endfor %}
    {{ pair.subquestion }} โ†” {{ pair.answer }}
    Shuffle answers: {{ 'Yes' if q.shuffle_answers else 'No' }} ยท Show number correct: {{ 'Yes' if q.show_num_correct else 'No' }}
    {% if q.hints %}
    ๐Ÿ’ก Hints:
      {% for h in q.hints %}
    • {{ h.hint_text or h.text or '' }} {% if h.clear_incorrect %}clears incorrect{% endif %} {% if h.show_num_correct %}shows count{% endif %}
    • {% endfor %}
    {% endif %}
    {% endif %} {# ---------- ESSAY grader info (answer mode only) ---------- #} {% if q.type == 'essay' and q.grader_info %}
    ๐Ÿ“ Grader notes: {{ q.grader_info|safe }}
    {% endif %} {# ---------- General feedback (answer mode only) ---------- #} {% if q.general_feedback %}
    ๐Ÿ’ก Explanation: {{ q.general_feedback|safe }}
    {% endif %}
  • {% endfor %}
{% endfor %}
{% else %}
No questions found for this paper.
{% endfor %}
{% if total_questions %}
๐Ÿ“Š Paper Summary
Questions
{{ total_questions }}
Total marks
{{ total_marks }}
By type
{% for t, n in type_breakdown %} {{ t }}: {{ n }} {% endfor %}
{% if sources_in_paper %}
๐Ÿ”– Sources
    {% for s in sources_in_paper %}
  • {{ s }}
  • {% endfor %}
{% endif %}
{% endif %}
{% endblock %}