{% set questionTypesDict = getQuestionTypes() %}

<div class="media testpaper-result">
  <div class="testpaper-result-total">
    <div class="well">
      <div class="testpaper-result-total-score">
        {% if paperResult.status == 'finished' %}
          {{ paperResult.score }}
        {% else %}?
        {% endif %}
        <small>{{'分'|trans}}</small>
      </div>
      <small class="color-gray">{{'总分%score%分'|trans({'%score%':paper.score})}}</small>
    </div>
  </div>
  <div class="media-body">
    <div class="table-responsive">
      <table class="table table-bordered table-condensed testpaper-result-table">
        <thead>
          <th></th>
          {% for type in questionTypes|default([]) if accuracy[type]|default(null) %}
            <th>{{ questionTypesDict[type] }} <small class="color-gray">({{ accuracy[type].all }}{{'道'|trans}})</small></th>
          {% endfor %}
        </thead>
        <tbody>
          <tr>
            <th>{{'答对'|trans}}</th>
            {% for type in questionTypes|default([]) if accuracy[type]|default(null) %}
              {% if type == 'essay' %}
                {% if paperResult.status == 'finished' %}
                  <td><span class="color-success">{{ accuracy[type].right }} <small>{{'道'|trans}}</small></span></td>
                {% else %}
                  <td rowspan="4" style="vertical-align:middle"><span class="color-success" style="font-size:40px">?</span></td>
                {% endif %}
              {% else %}
                {% if paperResult.status == 'finished' or not accuracy[type].hasEssay|default(false) %}
                  <td><span class="color-success">{{ accuracy[type].right }} <small>{{'道'|trans}}</small></span></td>
                {% else %}
                  <td rowspan="4" style="vertical-align:middle"><span class="color-success" style="font-size:40px">?</span></td>
                {% endif %}
              {% endif %}
            {% endfor %}
          </tr>
          <tr>
            <th>{{'答错'|trans}}</th>
            {% for type in questionTypes|default([]) if accuracy[type]|default(null) %}
              {% if type == 'essay' %}
                {% if paperResult.status == 'finished' %}
                  <td><span class="color-danger">{{ accuracy[type].wrong + accuracy[type].partRight }} <small>{{'道'|trans}}</small></span></td>
                {% endif %}
              {% else %}
                {% if paperResult.status == 'finished' or not accuracy[type].hasEssay|default(false) %}
                  <td>
                    <span class="color-danger">
                      {{ accuracy[type].wrong + accuracy[type].partRight }}
                      <small>
                        {{'道'|trans}}
                        {% if type in ['choice', 'uncertain_choice'] and accuracy[type].partRight != 0 %}
                          {{'（其中有%partRightNum%道漏选）'|trans({'%partRightNum%': accuracy[type].partRight})}}
                        {% endif %}
                      </small>
                    </span>
                  </td>
                {% endif %}
              {% endif %}
            {% endfor %}
          </tr>
          <tr>
            <th>{{'未答'|trans}}</th>
            {% for type in questionTypes|default([]) if accuracy[type]|default(null) %}
              {% if type == 'essay' %}
                {% if paperResult.status == 'finished' %}
                  <td><span class="color-gray">{{ accuracy[type].noAnswer }} <small>{{'道'|trans}}</small></span></td>
                {% endif %}
              {% else %}
                {% if paperResult.status == 'finished' or not accuracy[type].hasEssay|default(false) %}
                  <td><span class="color-gray">{{ accuracy[type].noAnswer }} <small>{{'道'|trans}}</small></span></td>
                {% endif %}
              {% endif %}
            {% endfor %}
          </tr>
          <tr>
            <th>{{'得分'|trans}}</th>
            {% for type in questionTypes|default([]) if accuracy[type]|default(null) %}
              {% if type == 'essay' %}
                {% if paperResult.status == 'finished' %}
                  <td><span class="text-score">{{ accuracy[type].score }} <small>{{'分'|trans}}</small></span></td>
                {% endif %}
              {% else %}
                {% if paperResult.status == 'finished' or not accuracy[type].hasEssay|default(false) %}
                  <td><span class="text-score">{{ accuracy[type].score }} <small>{{'分'|trans}}</small></span></td>
                {% endif %}
              {% endif %}
            {% endfor %}
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
