{% extends "base.html" %}
{% block content %}
<h1>
    Reports Matrix : {{ title }}
</h1>

<table class="mx-table">
    {%- set report_names = matrix.report_order() %}
    {%- set n_reports = report_names.__len__() %}
    {%- if n_reports > 0 %}
    <tr><!-- top row, stats and each matrix axis -->
        <td> <!-- stats -->
            <table class="stats-table">
                {%- for outcome in matrix.result_stats %}
                <tr>
                    <th class="{{outcome}}">{{outcome.title()}}</th>
                    <td>{{matrix.result_stats[outcome]}}</td>
                </tr>
                {%- endfor %}
            </table>
        </td>
        <td colspan="{{n_reports + 1}}"></td>
    </tr>
    <tr><td colspan="2"></td>
    {%- for i in range(n_reports) %}
        <td class="{% if (n_reports - i) % 2 == 0 %}mx-even{% endif %}">
            <div class="mx-ax-vertical">
                <a href="{{report_names[n_reports - 1 - i]}}.html">{{matrix.short_axis(report_names[n_reports - 1 - i])}}</a>
            </div>
        </td>
    {%- endfor %}
    </tr>
    {%- endif %}

    <!-- test results by class/test -->
    {%- for classname in matrix.classes %}
    <tr>
        <th class="mx-cls" colspan="2">{{classname}}</th>
        {%- for n in range(n_reports) %}
        <td class="mx-ax-line {% if n % 2 == 1 %}mx-even{% endif %}"></td>
        {%- endfor %}
    </tr>
    {%- for casename in matrix.casenames[classname] %}
    {%- set xcase = matrix.cases[classname][casename] %}
    <tr>
        <th class="mx-name">{{casename}}</th>
        <td class="mx-name mx-res-combined">{{ matrix.combined_result_list(classname, casename)[1] }}</td>
        {%- for n in range(n_reports) %}
        {%- set axis = report_names[n] %}
        {%- set line_class="mx-ax-line" %}
        {%- if axis in xcase %}
            {%- set line_class = line_class ~ " mx-res-" ~ xcase[axis].outcome() %}
        {%- endif %}
        <td class="{{ line_class }}">
        {%- if axis in xcase %}
            <a href="{{axis}}.html#{{xcase[axis].anchor()}}">
                <div class="mx-res">{{ matrix.short_outcome(xcase[axis].outcome()) }}</div>
            </a>
        {%- endif %}
        </td>
        {%- endfor %}
        {%- endfor %}
    </tr>
    {%- endfor %}
</table>
{% endblock %}
