dashboard.html 18.3 KB
Newer Older
1 2
<%!
  from django.core.urlresolvers import reverse
3
  from courseware.courses import course_image_url, get_course_about_section
4
  from courseware.access import has_access
Victor Shnayder committed
5
  from certificates.models import CertificateStatuses
6
%>
Matthew Mongeau committed
7 8 9 10
<%inherit file="main.html" />

<%namespace name='static' file='static_content.html'/>

11 12
<%block name="title"><title>Dashboard</title></%block>

13 14 15 16
<%block name="js_extra">
  <script type="text/javascript">
  (function() {

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
    var carouselPageHeight = 0;
    var carouselIndex = 0;
    var carouselDelay = 5000;
    var carouselPages = $('.news-carousel .page').length;


    $('.news-carousel .page').each(function() {
      carouselPageHeight = Math.max($(this).outerHeight(), carouselPageHeight);
    });
    $('.news-carousel .pages').css('height', carouselPageHeight);
    $('.news-carousel .page-dot').bind('click', setCarouselPage);
    var carouselTimer = setInterval(nextCarouselPage, carouselDelay);

    function nextCarouselPage() {
      carouselIndex = carouselIndex + 1 < carouselPages ? carouselIndex + 1 : 0;
      setCarouselPage(null, carouselIndex);
    }

35
    function setCarouselPage(event, index) {
36 37 38 39
      var $pageToShow;
      var transitionSpeed;
      $('.news-carousel .page-dots').find('.current').removeClass('current');

40
      if(event) {
41 42
        clearInterval(carouselTimer);
        carouselTimer = setInterval(nextCarouselPage, carouselDelay);
43
        carouselIndex = $(this).closest('li').index();
44
        transitionSpeed = 250;
45
        $pageToShow = $('.news-carousel .page').eq(carouselIndex);
46 47 48 49 50 51 52 53 54 55 56
        $(this).addClass('current');
      } else {
        transitionSpeed = 750;
        $pageToShow = $('.news-carousel .page').eq(index);
        $('.news-carousel .page-dot').eq(index).addClass('current');
      }

      $pageToShow.fadeIn(transitionSpeed);
      $('.news-carousel .page').not($pageToShow).fadeOut(transitionSpeed);
    }

57 58 59
    $(".unenroll").click(function(event) {
      $("#unenroll_course_id").val( $(event.target).data("course-id") );
      $("#unenroll_course_number").text( $(event.target).data("course-number") );
60 61
    });

62 63 64 65 66 67
    $('#unenroll_form').on('ajax:complete', function(event, xhr) {
      if(xhr.status == 200) {
        location.href = "${reverse('dashboard')}";
      } else if (xhr.status == 403) {
        location.href = "${reverse('signin_user')}?course_id=" +
          $("#unenroll_course_id").val() + "&enrollment_action=unenroll";
68
      } else {
69 70 71
        $('#unenroll_error').html(
          xhr.responseText ? xhr.responseText : "An error occurred. Please try again later."
        ).stop().css("display", "block");
72 73 74 75 76 77 78 79 80 81
      }
    });

    $('#pwd_reset_button').click(function() {
      $.post('${reverse("password_reset")}',
             {"email"  : $('#id_email').val()},
             function(data){
               $("#password_reset_complete_link").click();
             });
    });
82

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

      $.post('${reverse("change_email")}',
               {"new_email" : new_email, "password" : new_password},
               function(data) {
                 if (data.success) {
                   $("#change_email_title").html("Please verify your new email");
92
                   $("#change_email_form").html("<p>You'll receive a confirmation in your " +
93 94 95
                                                "in-box. Please click the link in the " +
                                                "email to confirm the email change.</p>");
                 } else {
96
                   $("#change_email_error").html(data.error).stop().css("display", "block");
97 98 99
                 }
               });
      return false;
100
    });
101

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    $("#change_name_form").submit(function(){
      var new_name = $('#new_name_field').val();
      var rationale = $('#name_rationale_field').val();

      $.post('${reverse("change_name")}',
             {"new_name":new_name, "rationale":rationale},
             function(data) {
               if(data.success) {
                 location.reload();
                 // $("#change_name_body").html("<p>Name changed.</p>");
               } else {
                 $("#change_name_error").html(data.error).stop().css("display", "block");
               }
             });
       return false;
    });

119 120 121 122
  })(this)
  </script>
</%block>

123
<section class="container dashboard">
124

125 126 127 128 129
  %if message:
    <section class="dashboard-banner">
      ${message}
    </section>
  %endif
Matthew Mongeau committed
130

131
  <section class="profile-sidebar">
132
    <header class="profile">
133
      <h1 class="user-name">${ user.username }</h1>
134
    </header>
135 136 137
    <section class="user-info">
      <ul>
        <li>
138
          <span class="title"><div class="icon name-icon"></div>Full Name (<a href="#apply_name_change" rel="leanModal" class="edit-name">edit</a>)</span> <span class="data">${ user.profile.name | h }</span>
139 140 141
        </li>
        <li>
          <span class="title"><div class="icon email-icon"></div>Email (<a href="#change_email" rel="leanModal" class="edit-email">edit</a>)</span> <span class="data">${ user.email | h }</span>
142 143
        </li>
        <li>
144
          <span class="title"><a href="#password_reset_complete" rel="leanModal" id="pwd_reset_button">Reset Password</a></span>
145 146 147 148
          <form id="password_reset_form" method="post" data-remote="true" action="${reverse('password_reset')}">
            <input id="id_email" type="hidden" name="email" maxlength="75" value="${user.email}" />
            <!-- <input type="submit" id="pwd_reset_button" value="Reset Password" /> -->
          </form>
149 150 151
        </li>
      </ul>
    </section>
152

153
    %if news:
154 155 156 157 158 159 160 161 162 163 164 165
    <article class="news-carousel">
      <header>
        <h4>edX News</h4>
        <nav class="page-dots">
          <ol>
            <li><a href="#" class="page-dot current"></a></li>
            <li><a href="#" class="page-dot"></a></li>
            <li><a href="#" class="page-dot"></a></li>
          </ol>
        </nav>
      </header>
      <div class="pages">
166
        % for entry in news:
167
        <section class="page">
168
          %if entry.image:
169
          <div class="news-image">
170
            <a href="${entry.link}"><img src="${entry.image}" /></a>
171
          </div>
172 173
          %endif
          <h5><a href="${entry.link}">${entry.title}</a></h5>
174
          <div class="excerpt">
175 176 177 178
            %if entry.summary:
            <p>${entry.summary}</p>
            %endif
            <p><a href="${entry.link}">Learn More ›</a></p>
179 180
          </div>
        </section>
181
        %endfor
182 183
      </div>
    </article>
184
    %endif
185
  </section>
Matthew Mongeau committed
186

187 188
  <section class="my-courses">
    <header>
189
      <h2>Current Courses</h2>
190
    </header>
Matthew Mongeau committed
191

192
    % if len(courses) > 0:
193
      % for course in courses:
194

195
        <article class="my-course">
196 197 198
          <%
            course_target = reverse('info', args=[course.id])
          %>
199

200

201

202 203 204 205 206 207 208 209 210
          % if course.id in show_courseware_links_for:
            <a href="${course_target}" class="cover">
              <img src="${course_image_url(course)}" />
            </a>
          % else:
            <div class="cover">
              <img src="${course_image_url(course)}" />
            </div>
          % endif
211 212 213 214

          <section class="info">
            <hgroup>
              <p class="date-block">
215
              % if course.has_ended():
216
              Course Completed - ${course.end_date_text}
217
              % elif course.has_started():
218
              Course Started - ${course.start_date_text}
219
              % else:   # hasn't started yet
220
              Course Starts - ${course.start_date_text}
221 222
              % endif
              </p>
223
              <h2 class="university">${get_course_about_section(course, 'university')}</h2>
224 225 226 227 228 229 230
              <h3>
                % if course.id in show_courseware_links_for:
                  <a href="${course_target}">${course.number} ${course.display_name_with_default}</a>
                % else:
                  <span>${course.number} ${course.display_name_with_default}</span>
                % endif
              </h3>
231 232
            </hgroup>

233
            <%
234 235
                testcenter_exam_info = course.current_test_center_exam
                registration = exam_registrations.get(course.id)
236
                testcenter_register_target = reverse('begin_exam_registration', args=[course.id])
237
            %>
238 239
            % if testcenter_exam_info is not None:

240
                % if registration is None and testcenter_exam_info.is_registering():
241
                <div class="message message-status is-shown exam-register">
242 243
                  <a href="${testcenter_register_target}" class="button exam-button" id="exam_register_button">Register for Pearson exam</a>
                  <p class="message-copy">Registration for the Pearson exam is now open and will close on <strong>${testcenter_exam_info.registration_end_date_text}</strong></p>
244
                </div>
245 246 247
                % endif
                <!-- display a registration for a current exam, even if the registration period is over -->
                % if registration is not None:
248
                    % if registration.is_accepted:
249
                <div class="message message-status is-shown exam-schedule">
250
                   <a href="${registration.registration_signup_url}" class="button exam-button">Schedule Pearson exam</a>
251
                   <p class="exam-registration-number"><a href="${testcenter_register_target}" id="exam_register_link">Registration</a> number: <strong>${registration.client_candidate_id}</strong></p>
252 253
                   <p class="message-copy">Write this down! You’ll need it to schedule your exam.</p>
                </div>
254
                    % endif
255
                    % if  registration.is_rejected:
256
                <div class="message message-status is-shown exam-schedule">
257
                  <p class="message-copy"><strong>Your registration for the Pearson exam has been rejected. Please <a href="${testcenter_register_target}" id="exam_register_link">see your registration status details</a></strong>. Otherwise <a class="contact-link" href="mailto:exam-help@edx.org?subject=Pearson VUE Exam - ${get_course_about_section(course, 'university')} ${course.number}">contact edX at exam-help@edx.org</a> for further help.</p>
258 259
                </div>
                    % endif
260
                   	% if not registration.is_accepted and not registration.is_rejected:
261
	            <div class="message message-status is-shown">
262
    	              <p class="message-copy"><strong>Your <a href="${testcenter_register_target}" id="exam_register_link">registration for the Pearson exam</a> is pending</strong>. Within a few days, you should see a confirmation number here, which can be used to schedule your exam.</p>
263 264
                </div>
                    % endif
265
                % endif
266
            % endif
267

Victor Shnayder committed
268
            <%
269
            cert_status = cert_statuses.get(course.id)
Victor Shnayder committed
270
            %>
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
            % if course.has_ended() and cert_status:
                <%
                if cert_status['status'] == 'generating':
                    status_css_class = 'course-status-certrendering'
                elif cert_status['status'] == 'ready':
                    status_css_class = 'course-status-certavailable'
                elif cert_status['status'] == 'notpassing':
                    status_css_class = 'course-status-certnotavailable'
                else:
                    status_css_class = 'course-status-processing'
                %>
                <div class="message message-status ${status_css_class} is-shown">

                % if cert_status['status'] == 'processing':
                      <p class="message-copy">Final course details are being wrapped up at
                      this time. Your final standing will be available shortly.</p>
287
                % elif cert_status['status'] in ('generating', 'ready', 'notpassing', 'restricted'):
288 289 290 291 292
                      <p class="message-copy">Your final grade:
                      <span class="grade-value">${"{0:.0f}%".format(float(cert_status['grade'])*100)}</span>.
                      % if cert_status['status'] == 'notpassing':
                         Grade required for a certificate: <span class="grade-value">
                           ${"{0:.0f}%".format(float(course.lowest_passing_grade)*100)}</span>.
293 294
                      % elif cert_status['status'] == 'restricted':
                          <p class="message-copy">
295
                          Your certificate is being held pending confirmation that the issuance of your certificate is in compliance with strict U.S. embargoes on Iran, Cuba, Syria and Sudan. If you think our system has mistakenly identified you as being connected with one of those countries, please let us know by contacting <a class="contact-link" href="mailto:info@edx.org">info@edx.org</a>.
296
                          </p>
297 298
                      % endif
                      </p>
Victor Shnayder committed
299
                % endif
300

301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
                % if cert_status['show_disabled_download_button'] or cert_status['show_download_url'] or cert_status['show_survey_button']:
                  <ul class="actions">
                    % if cert_status['show_disabled_download_button']:
                      <li class="action"><span class="disabled">
                          Your Certificate is Generating</span></li>
                    % elif cert_status['show_download_url']:
                      <li class="action">
                      <a class="btn" href="${cert_status['download_url']}"
                         title="This link will open/download a PDF document">
                         Download Your PDF Certificate</a></li>
                    % endif

                    % if cert_status['show_survey_button']:
                      <li class="action"><a class="cta" href="${cert_status['survey_url']}">
                             Complete our course feedback survey</a></li>
                    % endif
                  </ul>
Victor Shnayder committed
318
                % endif
319 320
                </div>

Victor Shnayder committed
321 322
            % endif

323 324 325 326 327
            % if course.id in show_courseware_links_for:
              % if course.has_ended():
                <a href="${course_target}" class="enter-course archived">View Archived Course</a>
              % else:
                <a href="${course_target}" class="enter-course">View Course</a>
328
              % endif
329 330 331 332
            % endif
            <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id}" data-course-number="${course.number}">Unregister</a>
          </section>
        </article>
333

334

335

336 337 338
      % endfor
    % else:
      <section class="empty-dashboard-message">
339
        <p>Looks like you haven't registered for any courses yet.</p>
340 341 342
        <a href="${marketing_link('COURSES')}">
            Find courses now!
        </a>
343 344
      </section>
    % endif
Matthew Mongeau committed
345

346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
    % if staff_access and len(errored_courses) > 0:
      <div id="course-errors">
        <h2>Course-loading errors</h2>

      % for course_dir, errors in errored_courses.items():
         <h3>${course_dir | h}</h3>
             <ul>
           % for (msg, err) in errors:
               <li>${msg}
                 <ul><li><pre>${err}</pre></li></ul>
               </li>
           % endfor
             </ul>
      % endfor
    % endif
Matthew Mongeau committed
361 362
  </section>
</section>
363 364 365 366

<section id="unenroll-modal" class="modal unenroll-modal">
  <div class="inner-wrapper">
    <header>
367
      <h2>Are you sure you want to unregister from <span id="unenroll_course_number"></span>?</h2>
368
      <hr/>
369 370
    </header>

371 372
    <div id="unenroll_error" class="modal-form-error"></div>

373 374 375 376
    <form id="unenroll_form" method="post" data-remote="true" action="${reverse('change_enrollment')}">
      <input name="course_id" id="unenroll_course_id" type="hidden" />
      <input name="enrollment_action" type="hidden" value="unenroll" />
      <div class="submit">
377
        <input name="submit" type="submit" value="Unregister" />
378 379 380 381 382 383 384 385 386 387 388
      </div>
    </form>

    <div class="close-modal">
      <div class="inner">
        <p>&#10005;</p>
      </div>
    </div>
  </div>
</section>

389 390
<section id="password_reset_complete" class="modal">
  <div class="inner-wrapper">
391 392 393 394
    <header>
      <h2>Password Reset Email Sent</h2>
      <hr/>
    </header>
395
    <div>
396 397 398 399 400
      <form> <!-- Here for styling reasons -->
        <section>
          <p>An email has been sent to ${user.email}. Follow the link in the email to change your password.</p>
        </section>
      </form>
401 402 403 404 405 406 407 408
    </div>
    <div class="close-modal">
      <div class="inner">
        <p>&#10005;</p>
      </div>
    </div>
  </div>
</section>
409

410 411 412
<section id="change_email" class="modal">
  <div class="inner-wrapper">
    <header>
413
      <h2><span id="change_email_title">Change Email</span></h2>
414 415 416 417
      <hr/>
    </header>
    <div id="change_email_body">
      <form id="change_email_form">
418
        <div id="change_email_error" class="modal-form-error"> </div>
419
        <fieldset>
420 421 422 423 424 425
          <div class="input-group">
            <label>Please enter your new email address:</label>
            <input id="new_email_field" type="email" value="" />
            <label>Please confirm your password:</label>
            <input id="new_email_password" value="" type="password" />
          </div>
426
          <section>
427
            <p>We will send a confirmation to both ${user.email} and your new email as part of the process.</p>
428
          </section>
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
          <div class="submit">
            <input type="submit" id="submit_email_change" value="Change Email"/>
          </div>
        </fieldset>
      </form>
    </div>
    <div class="close-modal">
      <div class="inner">
        <p>&#10005;</p>
      </div>
    </div>
  </div>
</section>

<section id="apply_name_change" class="modal">
  <div class="inner-wrapper">
    <header>
      <h2>Change your name</h2>
      <hr/>
    </header>
    <div id="change_name_body">
      <form id="change_name_form">
        <div id="change_name_error" class="modal-form-error"> </div>
        <p>To uphold the credibility of edX certificates, all name changes will be logged and recorded.</p>
        <br/>
        <fieldset>
          <div class="input-group">
            <label>Enter your desired full name, as it will appear on the edX certificates: </label>
            <input id="new_name_field" value="" type="text" />
            <label>Reason for name change:</label>
            <textarea id="name_rationale_field" value=""></textarea>
          </div>
          <div class="submit">
            <input type="submit" id="submit" value="Change My Name">
          </div>
464 465 466 467 468 469 470 471 472 473
        </fieldset>
      </form>
    </div>
    <div class="close-modal">
      <div class="inner">
        <p>&#10005;</p>
      </div>
    </div>
  </div>
</section>