<tal:tag condition="view/update" />
<html metal:use-macro="context/@@standard_macros/page"
      i18n:domain="schooltool">
<head>
  <title metal:fill-slot="title" i18n:translate="">
    Gradebook
  </title>
  <metal:block fill-slot="extrahead">
    <script type="text/javascript" src="gradebook_overview.js">
    </script>
  </metal:block>
</head>
<body>
<div metal:fill-slot="body">

    <h1 style="color: red" id="javascript-warning">
    Your browser either has Javascript turned off, or it is not supported.
    Javascript is <b>required</b> for the gradebook.
    Please enable Javascript or use a browser with Javascript.
    </h1>
    <script type="text/javascript">
      <!--
	  document.getElementById("javascript-warning").innerHTML = "";
	  //-->
    </script>
    <form method="post"
          tal:attributes="action string:${context/@@absolute_url}">
    <div tal:condition="view/changed"
         id="warning">
      <span id="warningtext"> Evaluations changes saved at <span tal:content="view/time">some time</span>. Remember to click "Update" to submit any further changes.</span>
    </div>
    <div tal:condition="python: not view.changed"
         id="warning">
      <span id="warningtext"> Changes are not saved as they are typed. Click "Update" to save them.</span>
    </div>
    <tal:if condition="python:not list(view.getSections(True))">
      <span tal:content="string:Section: ${view/getCurrentSection}" />
    </tal:if>
    <tal:if condition="python:list(view.getSections(True))">
      <label for="currentSection" i18n:translate="">Section</label>
      <select name="currentSection"
              onchange="this.form.submit()">
        <tal:block repeat="section python:view.getSections(True)">
          <option value="1"
              tal:condition="python:section['title'] != view.getCurrentSection()"
              tal:attributes="value section/title"
              tal:content="section/title" />
          <option value="1" selected="selected"
              tal:condition="python:section['title'] == view.getCurrentSection()"
              tal:attributes="value section/title"
              tal:content="section/title" />
        </tal:block>
      </select>
    </tal:if>
    <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
    <label for="currentWorksheet" i18n:translate="">Worksheet</label>
    <select name="currentWorksheet"
            onchange="this.form.submit()">
      <tal:block repeat="worksheet context/worksheets">
        <option value="1"
            tal:condition="python:worksheet != view.getCurrentWorksheet()"
            tal:attributes="value worksheet/title"
            tal:content="worksheet/title" />
        <option value="1" selected="selected"
            tal:condition="python:worksheet == view.getCurrentWorksheet()"
            tal:attributes="value worksheet/title"
            tal:content="worksheet/title" />
      </tal:block>
    </select>
    <a class="button-ok" title="Weight Categories"
       tal:condition="context/worksheets"
       tal:define="worksheet view/getCurrentWorksheet"
       tal:attributes="href string:${worksheet/@@absolute_url}/weights.html">
       Weight Categories
    </a>
    <br /><br />

  <div class="message" style="color:red; padding:1em"
       tal:condition="view/message"
       tal:content="view/message">
    Message
  </div>

  <table class="schooltool_gradebook">
    <tr>
     <th class="cell header">
       <div i18n:translate="">Name</div>
       <a href="?sort_by=student" i18n:translate="">(sort)</a>
     </th>
     <th class="cell header">
       <div i18n:translate="">Total</div>
     </th>
     <th class="cell header">
       <div i18n:translate="">Average</div>
       <a tal:condition="nothing" href="?sort_by=average" i18n:translate="">(sort)</a>
     </th>
     <th class="cell title header" tal:repeat="activity view/activities">
       <div>
         <a href=""
            tal:attributes="href 
                            string:gradeActivity.html?activity=${activity/hash};
                            title activity/longTitle"
            tal:content="activity/shortTitle">
           HW 1
         </a>
       </div>
       <a href="?sort_by="
          tal:attributes="href
              string:${request/URL}?sort_by=${activity/hash}"
          i18n:translate="">
         (sort)
       </a>
       <div tal:content="activity/max" />
     </th>
    </tr>

    <tr>
      <td colspan="3" class="cell padded fd_cell empty" i18n:translate="">Apply a grade for all students:</td>
      <td class="cell padded fd_cell" tal:repeat="activity view/activities"
          tal:attributes="id string:fd_${activity/hash}_cell">
        <input type="text" size="4"
               class="data fd"
               tal:attributes="id string:fd_${activity/hash};
                   onkeyup string:checkFillDown('${activity/hash}')">
        <input type="button"
               style="display: none"
               class="fdbtn"
               value="Apply"
               tal:attributes="id string:fdbtn_${activity/hash};
                   onclick string:performFillDown('${activity/hash}')">
      </td>
    </tr>

    <tr tal:repeat="row view/table">
      <tal:if condition="repeat/row/even">
        <td class="cell padded even">
          <a href=""
             tal:attributes="href
                 string:gradeStudent.html?student=${row/student/id}"
             tal:content="row/student/title">
            Tom Hoffman
          </a>
        </td>
        <td class="cell padded even">
	      <tal:if condition="row/total|nothing">
	        <b><span tal:replace="row/total" /></b>
	      </tal:if>
        </td>
        <td class="cell padded even">
	      <tal:if condition="row/average|nothing">
	        <b><span tal:replace="row/average" />%</b>
	      </tal:if>
        </td>
        <td class="cell even" tal:repeat="grade row/grades"
            tal:attributes="id string:${grade/activity}_${row/student/id}_cell">
          <input class="data" type="text" name="" value="" size="4"
                 tal:attributes="name string:${grade/activity}_${row/student/id};
  			       id string:${grade/activity}_${row/student/id};
                                 value grade/value;
  			       onkeyup string:checkValid(event,'${grade/activity}_${row/student/id}')"/>
        </td>
      </tal:if>
      <tal:if condition="repeat/row/odd">
        <td class="cell padded odd">
          <a href=""
             tal:attributes="href
                 string:gradeStudent.html?student=${row/student/id}"
             tal:content="row/student/title">
            Tom Hoffman
          </a>
        </td>
        <td class="cell padded odd">
	      <tal:if condition="row/total|nothing">
	        <b><span tal:replace="row/total" /></b>
	      </tal:if>
        </td>
        <td class="cell padded odd">
	      <tal:if condition="row/average|nothing">
	        <b><span tal:replace="row/average" />%</b>
	      </tal:if>
        </td>
        <td class="cell odd" tal:repeat="grade row/grades"
            tal:attributes="id string:${grade/activity}_${row/student/id}_cell">
          <input class="data" type="text" name="" value="" size="4"
                 tal:attributes="name string:${grade/activity}_${row/student/id};
  			       id string:${grade/activity}_${row/student/id};
                                 value grade/value;
  			       onkeyup string:checkValid(event,'${grade/activity}_${row/student/id}')"/>
        </td>
      </tal:if>
    </tr>
  </table>

  <div class="controls">
    <tal:block metal:use-macro="view/@@standard_macros/update-button" />
  </div>

  </form>
</div>
</body>
</html>
