<%inherit file="base.html" />
<%block name="title">${_("Grading Settings")}</%block>
<%block name="bodyclass">is-signedin course grading view-settings</%block>

<%namespace name='static' file='static_content.html'/>
<%!
  from contentstore import utils
  from django.utils.translation import ugettext as _
  from xmodule.modulestore.django import loc_mapper
  from django.core.urlresolvers import reverse
%>

<%block name="header_extras">
% for template_name in ["course_grade_policy"]:
  <script type="text/template" id="${template_name}-tpl">
    <%static:include path="js/${template_name}.underscore" />
  </script>
% endfor
</%block>

<%block name="jsextra">
  <link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" />
  <script type="text/javascript">
require(["domReady!", "jquery", "js/views/settings/grading", "js/models/settings/course_grading_policy"], function(doc, $, GradingView, CourseGradingPolicyModel) {
    $("form :input").focus(function() {
      $("label[for='" + this.id + "']").addClass("is-focused");
    }).blur(function() {
      $("label").removeClass("is-focused");
    });

    var editor = new GradingView({
        el: $('.settings-grading'),
        model : new CourseGradingPolicyModel(${course_details|n},{parse:true})
    });

    editor.render();
});
  </script>
</%block>

<%block name="content">
<div class="wrapper-mast wrapper">
  <header class="mast has-subtitle">
    <h1 class="page-header">
      <small class="subtitle">${_("Settings")}</small>
      <span class="sr">&gt; </span>${_("Grading")}
    </h1>
  </header>
</div>

<div class="wrapper-content wrapper">
  <section class="content">
    <article class="content-primary" role="main">
      <form id="settings_details" class="settings-grading" method="post" action="">
        <section class="group-settings grade-range">
          <header>
            <h2 class="title-2">${_("Overall Grade Range")}</h2>
            <span class="tip">${_("Your overall grading scale for student final grades")}</span>
          </header>

          <ol class="list-input">
            <li class="field" id="field-course-grading-range">
              <div class="grade-controls course-grading-range well">
                <a href="#" class="new-grade-button"><span class="plus-icon"></span></a>
                <div class="grade-slider">
                  <div class="grade-bar">
                    <ol class="increments">
                      <li class="increment-0">0</li>
                      <li class="increment-10">10</li>
                      <li class="increment-20">20</li>
                      <li class="increment-30">30</li>
                      <li class="increment-40">40</li>
                      <li class="increment-50">50</li>
                      <li class="increment-60">60</li>
                      <li class="increment-70">70</li>
                      <li class="increment-80">80</li>
                      <li class="increment-90">90</li>
                      <li class="increment-100">100</li>
                    </ol>
                    <ol class="grades">
                    </ol>
                  </div>
                </div>
              </div>
            </li>
          </ol>
        </section>

        <hr class="divide" />

        <section class="group-settings grade-rules">
          <header>
            <h2 class="title-2">${_("Grading Rules &amp; Policies")}</h2>
            <span class="tip">${_("Deadlines, requirements, and logistics around grading student work")}</span>
          </header>

          <ol class="list-input">
            <li class="field text" id="field-course-grading-graceperiod">
              <label for="course-grading-graceperiod">${_("Grace Period on Deadline:")}</label>
              <input type="text" class="short time" id="course-grading-graceperiod" value="00:00" placeholder="HH:MM" autocomplete="off" />
              <span class="tip tip-inline">${_("Leeway on due dates")}</span>
            </li>
          </ol>
        </section>

        <hr class="divide" />

        <section class="group-settings assignment-types">
          <header>
            <h2 class="title-2">${_("Assignment Types")}</h2>
            <span class="tip">${_("Categories and labels for any exercises that are gradable")}</span>
          </header>

          <ol class="list-input course-grading-assignment-list enum">

          </ol>

          <div class="actions">
            <a href="#" class="new-button new-course-grading-item add-grading-data">
              <i class="icon-plus"></i> ${_("New Assignment Type")}
            </a>
          </div>
        </section>
      </form>
    </article>

    <aside class="content-supplementary" role="complimentary">
      <div class="bit">
        <h3 class="title-3">${_("How will these settings be used?")}</h3>
        <p>${_("Your grading settings will be used to calculate students grades and performance.")}</p>

        <p>${_("Overall grade range will be used in students' final grades, which are calculated by the weighting you determine for each custom assignment type.")}</p>
      </div>

      <div class="bit">
      % if context_course:
        <%
          ctx_loc = context_course.location
          location = loc_mapper().translate_location(ctx_loc.course_id, ctx_loc, False, True)
          course_team_url = location.url_reverse('course_team/', '')
        %>
        <h3 class="title-3">${_("Other Course Settings")}</h3>
        <nav class="nav-related">
          <ul>
            <li class="nav-item"><a href="${reverse('contentstore.views.get_course_settings', kwargs=dict(org=ctx_loc.org, course=ctx_loc.course, name=ctx_loc.name))}">${_("Details &amp; Schedule")}</a></li>
            <li class="nav-item"><a href="${course_team_url}">${_("Course Team")}</a></li>
            <li class="nav-item"><a href="${reverse('course_advanced_settings', kwargs={'org' : ctx_loc.org, 'course' : ctx_loc.course, 'name': ctx_loc.name})}">${_("Advanced Settings")}</a></li>
          </ul>
        </nav>
      % endif
      </div>
    </aside>
  </section>
</div>
</%block>
