profile.html 11.1 KB
Newer Older
pmitros committed
1
<%inherit file="main.html" />
2
<%namespace name="profile_graphs" file="profile_graphs.js"/>
pmitros committed
3

4
<%block name="title"><title>Profile - MITx 6.002x</title></%block>
pmitros committed
5

6 7 8 9
<%!
    from django.core.urlresolvers import reverse
%>

10
<%block name="headextra">
11 12 13
<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>
14
<script>
15
${profile_graphs.body(grade_summary, "grade-detail-graph")}
16
</script>
17

Piotr Mitros committed
18
<script>
19
var loc=true; // Activate on clicks? Not if already clicked.
20
var lang=true;
Piotr Mitros committed
21
$(function() {
22
      $("#change_location").click(function() {
23 24
         $(this).hide();

25 26 27 28 29 30 31 32 33 34
         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;

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

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

41 42 43 44 45 46 47 48 49 50 51
              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() {
52
         $(this).hide();
53 54 55 56
         log_event("profile", {"type":"language_show", "old":$("#language_sub").text()});

         if(lang) {
           lang=false;
57
           $("#language_sub").html('<form>'+'<input id="id_lang_text" type="text" name="lang_text" />'+
58
             '<input type="submit" id="change_lang_button" value="Save" />'+'</form>');
59
           $("#change_lang_button").click(function() {
60
             $("#change_language").show();
61 62 63 64 65 66 67 68 69 70 71 72
              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');
Kyle Fiedler committed
73
        log_event("profile", {"type":"password_show"});
74
      });
75 76 77 78

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


85
    $("#change_email_form").submit(function(){
86 87 88
      var new_email = $('#new_email_field').val();
      var new_password = $('#new_email_password').val();

89 90 91 92
      postJSON('/change_email',{"new_email":new_email, 
                                "password":new_password},
               function(data){
          if(data.success){
93
          $("#change_email").html("<h1>Please verify your new email</h1><p>You'll receive a confirmation in your in-box. Please click the link in the email to confirm the email change.</p>");
94 95 96 97
          } else {
            $("#change_email_error").html(data.error);
          }
       });
98 99 100
       log_event("profile", {"type":"email_change_request", 
                               "old_email":"${email}",
                               "new_email":new_email});
101
       return false;
102 103
    });

104 105 106 107
    $("#change_name_form").submit(function(){
      var new_name = $('#new_name_field').val();
      var rationale = $('#name_rationale_field').val();

108
      postJSON('/change_name',{"new_name":new_name, 
109 110 111
                                "rationale":rationale},
               function(data){
          if(data.success){
112
          $("#apply_name_change").html("<h1>Your request has been submitted.</h1><p>We'll send you an e-mail when approve the change or need further information. Please allow for up to a week for us to process your request.</p>");
113
          } else {
114
            $("#change_name_error").html(data.error);
115 116 117 118 119 120 121 122
          }
       });
       log_event("profile", {"type":"name_change_request", 
                               "new_name":new_name,
                               "rationale":rationale});
       return false;
    });

Kyle Fiedler committed
123
});
Piotr Mitros committed
124
</script>
125
</%block>
126

Piotr Mitros committed
127

128
<%include file="navigation.html" args="active_page='profile'" />
Kyle Fiedler committed
129

130
<section class="main-content">
131
  <div class="profile-wrapper">
132 133

    <section class="course-info">
134 135 136
      <header>
        <h1>Course Progress</h1>
      </header>
137

138
      <div id="grade-detail-graph"></div>
139

140
      <ol class="chapters">
141
        %for chapter in courseware_summary:
142
        %if not chapter['chapter'] == "hidden":
143
        <li>
144 145
          <h2><a href="${reverse('courseware_chapter', args=format_url_params([chapter['course'], chapter['chapter']])) }">
          ${ chapter['chapter'] }</a></h2>
146

147 148 149 150
          <ol class="sections">
            %for section in chapter['sections']:
            <li>
              <%
151 152
              earned = section['section_total'].earned
              total = section['section_total'].possible
153 154 155 156
              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']])) }">
157
                ${ section['section'] }</a> ${"({0:g}/{1:g}) {2}".format( earned, total, percentageString )}</h3>
158 159 160 161 162 163 164 165 166
              ${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']:
167
                    <li class="score">${"{0:g}/{1:g}".format(score.earned,score.possible)}</li>
168 169
                  %endfor
                </ol>
170
              %endif
171 172 173 174 175
              
            </li> <!--End section-->
            %endfor
          </ol> <!--End sections-->
        </li> <!--End chapter-->
176
        %endif
177 178
        %endfor
      </ol> <!--End chapters-->
179

180 181
    </section>

182 183
    <section class="user-info">

184
      <header>
185
        <h1>Student Profile</h1>
186 187
      </header>

188
      <ul>
189
        <li>
190 191 192 193 194 195 196 197 198
          Name: <strong>${name}</strong>
          %if True:
          <a href="#apply_name_change" rel="leanModal" class="name-edit">Edit</a>
          %else:
          (Name change pending)
          %endif
        </li>

        <li>
199 200 201
          Forum name: <strong>${username}</strong> 
        </li>

202
        <li>
203
          E-mail: <strong>${email}</strong> <a href="#change_email" rel="leanModal" class="edit-email">Edit</a>
204
        </li>
205
        <li>
206
          Location: <div id="location_sub">${location}</div><div id="description"></div> <a href="#" id="change_location">Edit</a>
207 208
        </li>
        <li>
209
          Language: <div id="language_sub">${language}</div> <a href="#" id="change_language">Edit</a>
210
        </li>
211 212 213 214 215 216
        <li>
          Password reset
          <input id="id_email" type="hidden" name="email" maxlength="75" value="${email}" />
          <input type="submit" id="pwd_reset_button" value="Reset" />
          <p>We'll e-mail a password reset link to ${email}.</p>
        </li>
217 218 219 220
      </ul>

    </section>
  </div>
Kyle Fiedler committed
221
</section>
222

223 224 225
<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>
226 227 228
  <p>
    An email has been sent to ${email}. Follow the link in the email to change your password.
  </p>
229 230 231 232
</div>

<div id="apply_name_change" class="leanModal_box">
  <h1>Apply to change your name</h1>
233 234
  <form id="change_name_form">
    <div id="change_name_error"> </div>
235
    <fieldset>
236
      <p>To uphold the credibility of MITx certificates, name changes must go through an approval process. A member of the course staff will review your request, and if approved, update your information. Please allow up to a week for your request to be processed. Thank you.</p> 
237 238 239
      <ul>
        <li>
          <label>Enter your desired full name, as it will appear on the MITx Certificate: </label>
240
          <input id="new_name_field" value="" type="text" />
241 242 243
        </li>
        <li>
          <label>Reason for name change:</label>
244
          <textarea id="name_rationale_field" value=""></textarea>
245 246 247 248 249 250 251
        </li>
        <li>
          <input type="submit" id="submit">
        </li>
      </ul>
    </fieldset>
  </form>
252 253 254 255
</div>

<div id="change_email" class="leanModal_box">
  <h1>Change e-mail</h1> 
256
  <div id="apply_name_change_error"></div>
257 258
  <form id="change_email_form">
    <div id="change_email_error"> </div>
259 260 261 262
    <fieldset>
      <ul>
        <li>
          <label> Please enter your new email address: </label>
263
          <input id="new_email_field" type="email" value="" />
264 265 266 267
        </li>

        <li>
          <label> Please confirm your password: </label>
268
          <input id="new_email_password" value="" type="password" />
269 270
        </li>
        <li>
271
          <p>We will send a confirmation to both ${email} and your new e-mail as part of the process.</p>
272
          <input type="submit" id="submit_email_change" />
273 274 275 276
        </li>
      </ul>
      </fieldset>
    </form>
277 278
</div>

279 280 281 282 283
<div id="deactivate-account" class="leanModal_box">
  <h1>Deactivate MITx Account</h1>
  <p>Once you deactivate you&rsquo;re MIT<em>x</em> account you will no longer recieve updates and new class announcements from MIT<em>x</em>.</p>
  <p>If you&rsquo;d like to still get updates and new class announcements you can just <a href="#unenroll" rel="leanModal">unenroll</a> and keep your account active.</p>

284 285
  <form id="unenroll_form">
    <div id="unenroll_error"> </div>
286 287 288
    <fieldset>
      <ul>
        <li>
289
          <input type="submit" id="" value="Yes, I don't want an MITx account or hear about any new classes or updates to MITx" />
290
        </li>
291 292 293 294 295 296 297 298 299 300 301 302 303
      </ul>
    </fieldset>
  </form>
</div>

<div id="unenroll" class="leanModal_box">
  <h1>Unenroll from 6.002x</h1>
  <p>Please note: you will still receive updates and new class announcements from MIT<em>x</em>. If you don&rsquo;t wish to receive any more updates or announcements <a href="#deactivate-account" rel="leanModal">deactivate your account</a>.</p>

  <form id="unenroll_form">
    <div id="unenroll_error"> </div>
    <fieldset>
      <ul>
304
        <li>
305
          <input type="submit" id="" value="Yes, I want to unenroll from 6.002x but still hear about any new classes or updates to MITx" />
306 307 308 309
        </li>
      </ul>
    </fieldset>
  </form>
310
</div>