<# This template is used when reporting the exam stats Command Line app #>
<|- set ns = namespace(total_marks=0, expected_mark=0) -|>
<|- set default_marks = {'mc': 2.5, 'ma': 2.5, 'tf': 2.5, 'essay': 5, 'matching': 2.5, 'ordering': 2.5} -|>

| Q | Type | Marks | # | Exp | Question Statement |
|---:|:---:|---:|---:|---:|---|
<| for q in questions if q.type in default_marks -|>
    <|- set q_marks = q.marks if q.marks is defined else default_marks.get(q.type, 0) -|>
    <|- set n_choices = (q.choices | length) if q.choices is defined else (2 if q.type == 'tf' else 0) -|>
    <|- set prob = (1.0/n_choices) if q.type == 'mc' else 
               (1.0/(2**(n_choices-1)) if q.type == 'ma' else 
               (0.5 if q.type == 'tf' else 
               (1.0/math.factorial(n_choices) if q.type == 'matching' else 0))) -|>
    <|- set q_em = q_marks * prob -|>
    <|- set q_lines = q.question.strip().splitlines() -|>
    <|- set excerpt = q_lines[0] ~ ("..." if q_lines|length > 1 else "") -|>
    <#- Update the totals using direct set -#>
    <|- set ns.total_marks = ns.total_marks + q_marks -|>
    <|- set ns.expected_mark = ns.expected_mark + q_em -|>
| << loop.index >> | << q.type >> | << "%2.1f"|format(q_marks) >> | << n_choices if q.type != 'essay' else '-' >> | << "%3.1f"|format(q_em) >> | << excerpt >> |
<| endfor |>

**Total: << "%3.1f"|format(ns.total_marks) >>** (Random Exp: **<< "%2.1f"|format(ns.expected_mark/ns.total_marks*100 if ns.total_marks > 0 else 0) >>%**)
