<%! from django.utils.translation import ugettext as _ %>
<%inherit file="/main.html" />
<%namespace name='static' file='/static_content.html'/>

<%block name="headextra">
  <%static:css group='course'/>
</%block>

<%namespace name="progress_graph" file="/courseware/progress_graph.js"/>

<%block name="title"><title>${_("{course_number} Progress").format(course_number=course.display_number_with_default) | h}</title></%block>

<%!
    from django.core.urlresolvers import reverse
%>

<%! from xmodule.util.date_utils import get_default_time_display %>

<%block name="js_extra">
<script type="text/javascript" src="${static.url('js/vendor/flot/jquery.flot.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/flot/jquery.flot.stack.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/flot/jquery.flot.symbol.js')}"></script>
<script>
${progress_graph.body(grade_summary, course.grade_cutoffs, "grade-detail-graph", not course.no_grade, not course.no_grade)}
</script>
</%block>

<%include file="/courseware/course_navigation.html" args="active_page='progress'" />

<section class="container">
  <div class="profile-wrapper">

    <section class="course-info">
      <header>
      <h1>${_("Course Progress for Student '{username}' ({email})").format(username=student.username, email=student.email)}</h1>
      </header>

      %if not course.disable_progress_graph:
        <div id="grade-detail-graph" aria-hidden="true"></div>
      %endif

      <ol class="chapters">
        %for chapter in courseware_summary:
        %if not chapter['display_name'] == "hidden":
        <li>
          <h2>${ chapter['display_name'] }</h2>

          <ol class="sections">
            %for section in chapter['sections']:
            <li>
              <%
              earned = section['section_total'].earned
              total = section['section_total'].possible
              percentageString = "{0:.0%}".format( float(earned)/total) if earned > 0 and total > 0 else ""
              %>

              <h3><a href="${reverse('courseware_section', kwargs=dict(course_id=course.id, chapter=chapter['url_name'], section=section['url_name']))}">
                ${ section['display_name'] }
                %if total > 0 or earned > 0:
                  <span class="sr">
                    ${"{0:.3n} of {1:.3n} possible points".format( float(earned), float(total) )}
                  </span></a>
                %endif
                %if total > 0 or earned > 0:
                  <span> ${"({0:.3n}/{1:.3n}) {2}".format( float(earned), float(total), percentageString )}</span>
                %endif
              </h3>
              <p>
                ${section['format']}

                %if section.get('due') is not None:
                  <em>
                  due ${get_default_time_display(section['due'], course.show_timezone)}
                  </em>
                %endif
              </p>

              <section class="scores">
                %if len(section['scores']) > 0:
                  <h3> ${ "Problem Scores: " if section['graded'] else "Practice Scores: "} </h3>
                  <ol>
                    %for score in section['scores']:
                    <li>${"{0:.3n}/{1:.3n}".format(float(score.earned),float(score.possible))}</li>
                    %endfor
                  </ol>
                %else:
                  <h3 class="no-scores"> ${_("No problem scores in this section")} </h3>
                %endif
              </section>


            </li> <!--End section-->
            %endfor
          </ol> <!--End sections-->
        </li> <!--End chapter-->
        %endif
        %endfor
      </ol> <!--End chapters-->

    </section>
  </div>
</section>