accordion.html 4.83 KB
Newer Older
1
<%page expression_filter="h"/>
2
<%namespace name='static' file='../static_content.html'/>
3 4 5
<%!
    from django.core.urlresolvers import reverse
    from django.utils.translation import ugettext as _
6
    from django.conf import settings
7
    from openedx.core.djangolib.markup import HTML, Text
8
%>
9

pmitros committed
10
<%def name="make_chapter(chapter)">
11 12 13 14 15 16 17 18 19 20 21
<%
if chapter.get('active'):
    aria_label = _('{chapter} current chapter').format(chapter=chapter['display_name'])
    active_class = 'active'
else:
    aria_label = chapter['display_name']
    active_class = ''
%>
<a href="#${chapter['display_id']}-child" role="button" class="button-chapter chapter ${active_class}" id="${chapter['display_id']}-parent" aria-controls="${chapter['display_id']}-child" aria-expanded="false">
    <span class="group-heading ${active_class}" aria-label="${aria_label}">
        <span class="icon fa fa-caret-right" aria-hidden="true"></span>
22
        ${HTML(chapter['display_name'])}
23 24
    </span>
</a>
25
<div class="chapter-content-container" id="${chapter['display_id']}-child" tabindex="-1" role="region" aria-label="${chapter['display_name']} submenu">
26 27 28
    <div class="chapter-menu">
        % for section in chapter['sections']:
        <div class="menu-item ${'active' if 'active' in section and section['active'] else ''} ${'graded'  if 'graded' in section and section['graded'] else ''}">
29
            <a class="accordion-nav" href="${reverse('courseware_section', args=[course_id, chapter['url_name'], section['url_name']])}">
30
                <p class="accordion-display-name">${HTML(section['display_name'])} ${Text(_('{span_start}current section{span_end}')).format(
31 32 33
                        span_start=HTML('<span class="sr">'),
                        span_end=HTML('</span>'),
                    ) if 'active' in section and section['active'] else ''}</p>
34

35
                ## There are behavior differences between
36
                ## rendering of sections which have proctoring/timed examinations
37 38 39 40
                ## and those that do not.
                ##
                ## Proctoring exposes a exam status message field as well as
                ## a status icon
41 42
                <%
                    if section.get('due') is None:
Gregory Martin committed
43
                        data_string = section['format']
44
                    else:
Gregory Martin committed
45 46 47 48
                        if 'proctoring' in section:
                            data_string = _('due {date}')
                        else:
                            data_string = _("{section_format} due {{date}}").format(section_format=section['format'])
49
               %>
50 51 52 53
                % if section['format'] or due_date or 'proctoring' in section:
                <p class="subtitle">
                    % if 'proctoring' in section:
                        ## Display the proctored exam status icon and status message
54
                        <span class="menu-icon icon fa ${section['proctoring'].get('suggested_icon', 'fa-pencil-square-o')} ${section['proctoring'].get('status', 'eligible')}" aria-hidden="true"></span>
55 56 57 58 59
                        <span class="subtitle-name">${section['proctoring'].get('short_description', '')}</span>

                        ## completed proctored exam statuses should not show the due date
                        ## since the exam has already been submitted by the user
                        % if not section['proctoring'].get('in_completed_state', False):
60
                            <span class="localized-datetime subtitle-name" data-datetime="${section['due']}" data-string="${data_string}" data-timezone="${user_timezone}" data-language="${user_language}"></span>
61 62 63 64
                        % endif
                    % else:
                        ## non-proctored section, we just show the exam format and the due date
                        ## this is the standard case in edx-platform
65
                        <span class="localized-datetime subtitle-name" data-datetime="${section['due']}" data-string="${data_string}" data-timezone="${user_timezone}" data-language="${user_language}"></span>
66 67 68 69 70 71 72

                        % if 'graded' in section and section['graded']:
                            <span class="menu-icon icon fa fa-pencil-square-o" aria-hidden="true"></span>
                            <span class="sr">${_("This content is graded")}</span>
                        % endif
                    % endif
                </p>
73 74
                % endif
            </a>
75 76 77 78
        </div>
        % endfor
    </div>
</div>
79
</%def>
pmitros committed
80 81 82

% for chapter in toc:
    ${make_chapter(chapter)}
83
% endfor
84 85 86


% if toc:
87
    <%static:require_module_async module_name="js/courseware/accordion_events" class_name="AccordionEvents">
88
        AccordionEvents();
89
    </%static:require_module_async>
90

Gregory Martin committed
91 92 93
    <%static:require_module_async module_name="js/dateutil_factory" class_name="DateUtilFactory">
        DateUtilFactory.transform(iterationKey=".localized-datetime");
    </%static:require_module_async>
94
% endif