{% set modal_class= "modal-lg" %}
{% extends 'old-bootstrap-modal-layout.html.twig' %}

{% block title %}{{'admin.course_manage.statistics.modal_title'|trans({'%title%': '《' ~ courseSet.title ~ '》'})}}{% endblock %}
{% block body %}
    <div class="clearfix mbl">
      {% if courses|default()|length > 1 %}
        <select style="width:200px;" class="form-control pull-left" name="categoryId" tabindex="-1" id = "course-select">
          {% for course in courses %}
            <option value="{{course.id}}" {% if courseId == course.id  %} selected {% endif %} data-url="{{ path('admin_v2_courses_data',{courseSetId:courseSet.id,courseId:course.id}) }}">{{course.title}}</option>
          {% endfor %}
        </select>
      {% endif %}
      <div class="pull-right">
        {% set course = courses[0]|default() %}
        <a class="btn btn-primary btn-sm task-export" data-prepare-url="{{ path("admin_v2_course_task_data_export_prepare",{courseId: courseId}) }}" data-export-url="{{ path('admin_v2_course_task_data_export',{courseId: courseId}) }}" href="javascript:;">{{ 'course.export'|trans }}</a>
      </div>
    </div>
    <div class="table-responsive">
        <table class="table table-bordered" style="word-break:break-all;text-align:center;">
          <tr class="active">
            <td>{{'admin.course_manage.statistics.data.name'|trans({'%taskName%':setting('course.task_name')|default('admin.setting_course.task'|trans)})}}</td>
            <td>{{'admin.course_manage.statistics.data.study_number'|trans}}</td>
            <td>{{'admin.course_manage.statistics.data.finished_number'|trans}}</td>
            <td>{{'admin.course_manage.statistics.data.average_study_time'|trans}}</td>
            <td>{{'admin.course_manage.statistics.data.video_and_music_study_time'|trans}}</td>
            <td>{{'admin.course_manage.statistics.data.video_and_music_average_study_time'|trans}}</td>
            <td>{{'admin.course_manage.statistics.data.average_score'|trans}}</td>
          </tr>
          {% if tasks %}
            {% for task in tasks %}
              <tr>
                <td>{{ task.title }}</td>
                <td>{{task.studentNum|default() }}</td>
                <td>{{task.finishedNum|default() }}</td>
                <td>{% if task.studentNum|default() == 0 %}0{% else %}{{task.learnedTime|default() // task.studentNum|default()}}{% endif %}</td>
                <td>
                  {{ task.length|default(0) }}
                </td>
                <td>
                  {% if task.type in ['video', 'audio'] %}
                    {% if task.type == 'video' and task.activity.ext.mediaSource != 'self' %}
                      --
                    {% elseif  task.studentNum == 0 %}
                      0
                    {% else %}
                      {{task.watchTime|default(0) // task.studentNum  }}
                    {% endif %}
                  {% else %}
                    --
                  {% endif %}
                </td>
                <td>
                  {% if task.type in ['testpaper'] %}
                    {{ task.score|default('0') }}
                  {% else %}
                    --
                  {% endif %}
                </td>
              </tr>
            {% endfor %}
          {% endif %}
        </table>
    </div>

    <script>app.load('course-set/data-detail.js');</script>
{% endblock %}