<commit_before><%inherit file="main.html" />

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

<%block name="headextra">
<script type="text/javascript" src="/static/js/flot/jquery.flot.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.stack.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.symbol.js"></script>
<script>
<%include file="profile_graphs.js"/>
</script>

<script>
var loc=true; // Activate on clicks? Not if already clicked.
var lang=true;
$(function() {
      $("#change_location").click(function() {
         $(this).hide();

         log_event("profile", {"type":"location_show", "old":$("#location_sub").text()});

         if(loc) {
           $("#description").html('<div>'+
                                  "Preferred format is city, state, country (so for us, "+
                                  "&quot;Cambridge, Massachusetts, USA&quot;), but give "+
                                  "as much or as little detail as you want. </div>");

           loc=false;

           $("#location_sub").html('<form>'+'<input id="id_loc_text" type="text" name="loc_text" />'+
             '<input type="submit" id="change_loc_button" value="Save" />'+'</form>');

           $("#change_loc_button").click(function() {
             $("#change_location").show();

              postJSON('/change_setting', {'location':$("#id_loc_text").attr("value")}, function(json) {
                $("#location_sub").text(json.location);
                loc=true;
                $("#description").html("");
               log_event("profile", {"type":"location_change", "new":json.location});
              });
           });
         }
      });

      $("#change_language").click(function() {
         $(this).hide();
         log_event("profile", {"type":"language_show", "old":$("#language_sub").text()});

         if(lang) {
           lang=false;
           $("#language_sub").html('<form>'+'<input id="id_lang_text" type="text" name="lang_text" />'+
             '<input type="submit" id="change_lang_button" value="Save" />'+'</form>');
           $("#change_lang_button").click(function() {
             $("#change_language").show();
              postJSON('/change_setting', {'language':$("#id_lang_text").attr("value")}, function(json) {
                $("#language_sub").text(json.language);
                lang=true;
                $("#description").html("");
               log_event("profile", {"type":"language_change", "new":json.language});
              });
           });
         }
      });

      $('#change_password').click(function(){
        $('.modal').trigger('click');
        log_event("profile", {"type":"password_show"});
      });

    $('#pwd_reset_button').click(function() {
      $.post('/password_reset/',{ "csrfmiddlewaretoken" : "${ csrf }",
                    "email"  : $('#id_email').val()}, function(data){
         $("#password_reset_complete_link").click();
         log_event("profile", {"type":"password_send"});
      });
    });
});
</script>
</%block>


<%include file="navigation.html" args="active_page='profile'" />

<section class="main-content">
  <div class="profile-wrapper">

    <section class="course-info">
      <h1>Course Progress</h1>

      <div id="grade-detail-graph"></div>
            
      <ol class="chapters">
        %for chapter in chapters:
        %if not chapter['chapter'] == "hidden":
        <li>
          <h2><a href="${reverse('courseware_chapter', args=format_url_params([chapter['course'], chapter['chapter']])) }">
          ${ chapter['chapter'] }</a></h2>
        
          <ol class="sections">
            %for section in chapter['sections']:
            <li>
              <%
              earned = section['section_total'][0]
              total = section['section_total'][1]
              percentageString = "{0:.0%}".format( float(earned)/total) if earned > 0 else ""
              %>
              
              <h3><a href="${reverse('courseware_section', args=format_url_params([chapter['course'], chapter['chapter'], section['section']])) }">
                ${ section['section'] }</a> ${"({0:g}/{1:g}) {2}".format( earned, total, percentageString )}</h3>
              ${section['subtitle']}
              %if 'due' in section and section['due']!="":
                due ${section['due']}
              %endif
              
              %if len(section['scores']) > 0:
                <ol class="scores">
                  ${ "Problem Scores: " if section['graded'] else "Practice Scores: "}
                  %for score in section['scores']:
                    <li class="score">${"{0:g}/{1:g}".format(score[0],score[1])}</li>
                  %endfor
                </ol>
              %endif
              
            </li> <!--End section-->
            %endfor
          </ol> <!--End sections-->
        </li> <!--End chapter-->
        %endif
        %endfor
      </ol> <!--End chapters-->
    </section>

    <section class="user-info">

      <h1>${name}</h1>

      <ul>
        <li>Forum name: <strong>${username}</strong></li>
        <li>E-mail: <strong>${email}</strong></li>
        <li>
          Location: <div id="location_sub">${location}</div><div id="description"></div> <a href="#" id="change_location">Edit</a>
        </li>
        <li>
          Language: <div id="language_sub">${language}</div> <a href="#" id="change_language">Edit</a>
        </li>
      </ul>

      <div id="change_password_pop">
        <h2>Password change</h2>
        <p>We'll e-mail a password reset link to ${email}.</p>

        <input id="id_email" type="hidden" name="email" maxlength="75" value="${email}" />
        <input type="submit" id="pwd_reset_button" value="Reset Password" />
      </div>

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

      <div id="password_reset_complete" class="leanModal_box">
      <a href="#password_reset_complete" rel="leanModal" id="password_reset_complete_link"></a>
        <h1>Password Reset Email Sent</h1>
        An email has been sent to ${email}. Follow the link in the email to change your password.
      </div><commit_msg>Dialogs for name changes, etc. (non-working)<commit_after><%inherit file="main.html" />

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

<%block name="headextra">
<script type="text/javascript" src="/static/js/flot/jquery.flot.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.stack.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.symbol.js"></script>
<script>
<%include file="profile_graphs.js"/>
</script>

<script>
var loc=true; // Activate on clicks? Not if already clicked.
var lang=true;
$(function() {
      $("#change_location").click(function() {
         $(this).hide();

         log_event("profile", {"type":"location_show", "old":$("#location_sub").text()});

         if(loc) {
           $("#description").html('<div>'+
                                  "Preferred format is city, state, country (so for us, "+
                                  "&quot;Cambridge, Massachusetts, USA&quot;), but give "+
                                  "as much or as little detail as you want. </div>");

           loc=false;

           $("#location_sub").html('<form>'+'<input id="id_loc_text" type="text" name="loc_text" />'+
             '<input type="submit" id="change_loc_button" value="Save" />'+'</form>');

           $("#change_loc_button").click(function() {
             $("#change_location").show();

              postJSON('/change_setting', {'location':$("#id_loc_text").attr("value")}, function(json) {
                $("#location_sub").text(json.location);
                loc=true;
                $("#description").html("");
               log_event("profile", {"type":"location_change", "new":json.location});
              });
           });
         }
      });

      $("#change_language").click(function() {
         $(this).hide();
         log_event("profile", {"type":"language_show", "old":$("#language_sub").text()});

         if(lang) {
           lang=false;
           $("#language_sub").html('<form>'+'<input id="id_lang_text" type="text" name="lang_text" />'+
             '<input type="submit" id="change_lang_button" value="Save" />'+'</form>');
           $("#change_lang_button").click(function() {
             $("#change_language").show();
              postJSON('/change_setting', {'language':$("#id_lang_text").attr("value")}, function(json) {
                $("#language_sub").text(json.language);
                lang=true;
                $("#description").html("");
               log_event("profile", {"type":"language_change", "new":json.language});
              });
           });
         }
      });

      $('#change_password').click(function(){
        $('.modal').trigger('click');
        log_event("profile", {"type":"password_show"});
      });

    $('#pwd_reset_button').click(function() {
      $.post('/password_reset/',{ "csrfmiddlewaretoken" : "${ csrf }",
                    "email"  : $('#id_email').val()}, function(data){
         $("#password_reset_complete_link").click();
         log_event("profile", {"type":"password_send"});
      });
    });

    $("#update_email").click(function() {
      $("#change_email_link").click();
    });

    $("#apply_name").click(function() {
      $("#apply_name_change_link").click();      
    });

    $("#unenroll_button").click(function(){
      $("#unenroll_course_link").click();
    });

});
</script>
</%block>


<%include file="navigation.html" args="active_page='profile'" />

<section class="main-content">
  <div class="profile-wrapper">

    <section class="course-info">
      <h1>Course Progress</h1>

      <div id="grade-detail-graph"></div>
            
      <ol class="chapters">
        %for chapter in chapters:
        %if not chapter['chapter'] == "hidden":
        <li>
          <h2><a href="${reverse('courseware_chapter', args=format_url_params([chapter['course'], chapter['chapter']])) }">
          ${ chapter['chapter'] }</a></h2>
        
          <ol class="sections">
            %for section in chapter['sections']:
            <li>
              <%
              earned = section['section_total'][0]
              total = section['section_total'][1]
              percentageString = "{0:.0%}".format( float(earned)/total) if earned > 0 else ""
              %>
              
              <h3><a href="${reverse('courseware_section', args=format_url_params([chapter['course'], chapter['chapter'], section['section']])) }">
                ${ section['section'] }</a> ${"({0:g}/{1:g}) {2}".format( earned, total, percentageString )}</h3>
              ${section['subtitle']}
              %if 'due' in section and section['due']!="":
                due ${section['due']}
              %endif
              
              %if len(section['scores']) > 0:
                <ol class="scores">
                  ${ "Problem Scores: " if section['graded'] else "Practice Scores: "}
                  %for score in section['scores']:
                    <li class="score">${"{0:g}/{1:g}".format(score[0],score[1])}</li>
                  %endfor
                </ol>
              %endif
              
            </li> <!--End section-->
            %endfor
          </ol> <!--End sections-->
        </li> <!--End chapter-->
        %endif
        %endfor
      </ol> <!--End chapters-->
    </section>

    <section class="user-info">

      <h1>${name}</h1>
      %if True:
        <a href="#" id="apply_name">Apply to change</a>
      %else:
	(Name change pending)
      %endif
      <ul>
        <li>
	  Forum name: <strong>${username}</strong> 
	</li>
        <li>
	  E-mail: <strong>${email}</strong> <a href="#" id="update_email">Update</a>
	</li>
        <li>
          Location: <div id="location_sub">${location}</div><div id="description"></div> <a href="#" id="change_location">Edit</a>
        </li>
        <li>
          Language: <div id="language_sub">${language}</div> <a href="#" id="change_language">Edit</a>
        </li>
      </ul>

      <div id="change_password_pop">
        <h2>Password change</h2>
        <p>We'll e-mail a password reset link to ${email}.</p>

        <input id="id_email" type="hidden" name="email" maxlength="75" value="${email}" />
        <input type="submit" id="pwd_reset_button" value="Reset Password" />
      </div>
      
      <div id="unenroll">
	<input type="submit" id="unenroll_button" value="Unenroll" />
      </div>
    </section>
  </div>
</section>

<div id="password_reset_complete" class="leanModal_box">
  <a href="#password_reset_complete" rel="leanModal" id="password_reset_complete_link"></a>
  <h1>Password Reset Email Sent</h1>
  An email has been sent to ${email}. Follow the link in the email to change your password.
</div>

<div id="apply_name_change" class="leanModal_box">
  <a href="#apply_name_change_link" rel="leanModal" id="apply_name_change_link"></a>
  <h1>Apply to change your name</h1>
  Enter your desired full name, as it will appear on the MITx Certificate: 
  <p><input id="new_name" value="" />
  <p>Reason for name change: 
  <p><input id="name_rationale" value="" />
  <p>A member of the course staff will review your request, and if approved, update your information. 
  <p><input id="submit">
</div>

<div id="change_email" class="leanModal_box">
  <a href="#change_email_link" rel="leanModal" id="change_email_link"></a>
  <h1>Change e-mail</h1> 
  <p> Please enter your new email address: 
  <p><input id="new_name" value="" />
  <p> Please confirm your password: 
  <p><input id="new_name" value="" type="password" />
  <p> We will send a confirmation to both ${email} and your new e-mail
  as part of the process. Since we use e-mail as an authentication
  mechanism, we keep a log e-mail changes.
  <p><input id="submit">
</div>

<div id="unenroll_course" class="leanModal_box">
  <a href="#unenroll_course_link" rel="leanModal" id="unenroll_course_link"></a>
<h1> Unenroll </h1>
<p> At the end of the semester, all students who do not complete the
course will be automatically dropped. If you would still prefer to
deactivate your account, you can: 
<p> Deactivate account, but inform me about future courses.
<p> Deactivate account/do not inform me about future courses. 
</p>
</div>
{'fraction_non_alphanumeric': 0.19644599303135887, 'fraction_numerical': 0.004181184668989547, 'mean_word_length': 2.467262623822179, 'pattern_counts': {'":': 24, '<': 255, '<?xml version=': 0, '>': 259, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2520374', 'n_tokens_mistral': 4328, 'n_tokens_neox': 4260, 'n_words': 853}