<%page args="section_data" expression_filter="h"/>
<%!
from itertools import groupby

from django.utils.translation import ugettext as _
from django.urls import reverse

from lms.djangoapps.courseware.courses import get_course_by_id
from ol_openedx_rapid_response_reports.utils import get_display_name_from_usage_key
%>


<div>
    <% course = get_course_by_id(section_data['course_key'], depth=None) %>
    % for date,runs in groupby(section_data['problem_runs'],key=lambda x:x['created'].date()):
    <ul>
        <li>${date.strftime('%Y/%m/%d')}</li>
        <ul>
            % for run in runs:
            <li>${get_display_name_from_usage_key(run['problem_usage_key'], course)} - ${run['created'].strftime('%I:%M:%S %p')}:
                <a type="button" class="btn-link"
                   href="${reverse('get_rapid_response_report', kwargs={'course_id': section_data['course_key'], 'run_id': run['id']})}">
                    ${_("Download")}
                </a>
            </li>
            % endfor
        </ul>
    </ul>
    % endfor
</div>
