dashboard.html 17.9 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 68 69 70 71 72 73 74 75 76 77 78 79
    });

    $(document).delegate('#unenroll_form', 'ajax:success', function(data, json, xhr) {
      if(json.success) {
        location.href="${reverse('dashboard')}";
      } else {
        if($('#unenroll_error').length == 0) {
          $('#unenroll_form').prepend('<div id="unenroll_error" class="modal-form-error"></div>');
        }
        $('#unenroll_error').text(json.error).stop().css("display", "block");
      }
    });

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

81 82 83 84 85 86 87 88 89
    $("#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");
90
                   $("#change_email_form").html("<p>You'll receive a confirmation in your " +
91 92 93
                                                "in-box. Please click the link in the " +
                                                "email to confirm the email change.</p>");
                 } else {
94
                   $("#change_email_error").html(data.error).stop().css("display", "block");
95 96 97
                 }
               });
      return false;
98
    });
99

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    $("#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;
    });

117 118 119 120
  })(this)
  </script>
</%block>

121
<section class="container dashboard">
122

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

129
  <section class="profile-sidebar">
130
    <header class="profile">
131
      <h1 class="user-name">${ user.username }</h1>
132
    </header>
133 134 135
    <section class="user-info">
      <ul>
        <li>
136
          <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>
137 138 139
        </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>
140 141
        </li>
        <li>
142
          <span class="title"><a href="#password_reset_complete" rel="leanModal" id="pwd_reset_button">Reset Password</a></span>
143 144 145 146
          <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>
147 148 149
        </li>
      </ul>
    </section>
150

151
    %if news:
152 153 154 155 156 157 158 159 160 161 162 163
    <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">
164
        % for entry in news:
165
        <section class="page">
166
          %if entry.image:
167
          <div class="news-image">
168
            <a href="${entry.link}"><img src="${entry.image}" /></a>
169
          </div>
170 171
          %endif
          <h5><a href="${entry.link}">${entry.title}</a></h5>
172
          <div class="excerpt">
173 174 175 176
            %if entry.summary:
            <p>${entry.summary}</p>
            %endif
            <p><a href="${entry.link}">Learn More ›</a></p>
177 178
          </div>
        </section>
179
        %endfor
180 181
      </div>
    </article>
182
    %endif
183
  </section>
Matthew Mongeau committed
184

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

190
    % if len(courses) > 0:
191
      % for course in courses:
192

193
        <article class="my-course">
194
          <%
195
          if has_access(user, course, 'load'):
196 197 198 199
            course_target = reverse('info', args=[course.id])
          else:
            course_target = reverse('about_course', args=[course.id])
          %>
200

201 202 203 204 205 206 207 208 209

          
          <a href="${course_target}" class="cover">
            <img src="${course_image_url(course)}" />
          </a>

          <section class="info">
            <hgroup>
              <p class="date-block">
210
              % if course.has_ended():
211
              Course Completed - ${course.end_date_text}
212
              % elif course.has_started():
213
              Course Started - ${course.start_date_text}
214
              % else:   # hasn't started yet
215
              Course Starts - ${course.start_date_text}
216 217
              % endif
              </p>
218 219 220 221
              <h2 class="university">${get_course_about_section(course, 'university')}</h2>
              <h3><a href="${course_target}">${course.number} ${course.title}</a></h3>
            </hgroup>

222
            <%
223 224
                testcenter_exam_info = course.current_test_center_exam
                registration = exam_registrations.get(course.id)
225
                testcenter_register_target = reverse('begin_exam_registration', args=[course.id])
226
            %>
227 228 229
            % if testcenter_exam_info is not None:

                % if registration is None and testcenter_exam_info.is_registering():	    
230
                <div class="message message-status is-shown exam-register">
231 232
                  <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>
233
                </div>
234 235 236
                % endif
                <!-- display a registration for a current exam, even if the registration period is over -->
                % if registration is not None:
237
                    % if registration.is_accepted:  
238
                <div class="message message-status is-shown exam-schedule">
239
                   <a href="${registration.registration_signup_url}" class="button exam-button">Schedule Pearson exam</a>
240
                   <p class="exam-registration-number"><a href="${testcenter_register_target}" id="exam_register_link">Registration</a> number: <strong>${registration.client_candidate_id}</strong></p>
241 242
                   <p class="message-copy">Write this down! You’ll need it to schedule your exam.</p>
                </div>
243
                    % endif
244
                    % if  registration.is_rejected:	    
245
                <div class="message message-status is-shown exam-schedule">
246
                  <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>
247 248
                </div>
                    % endif
249
                   	% if not registration.is_accepted and not registration.is_rejected:	    
250
	            <div class="message message-status is-shown">
251
    	              <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>
252 253
                </div>
                    % endif
254
                % endif
255
            % endif   
256

Victor Shnayder committed
257
            <%
258
            cert_status = cert_statuses.get(course.id)
Victor Shnayder committed
259
            %>
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
            % 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>
276
                % elif cert_status['status'] in ('generating', 'ready', 'notpassing', 'restricted'):
277 278 279 280 281
                      <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>.
282 283
                      % elif cert_status['status'] == 'restricted':
                          <p class="message-copy">
284
                          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>.
285
                          </p>
286 287
                      % endif
                      </p>
Victor Shnayder committed
288
                % endif
289

290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
                % 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
307
                % endif
308 309
                </div>

Victor Shnayder committed
310 311
            % endif

312 313 314 315 316 317 318 319 320 321
            % 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>
              % endif              
            % endif
            <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id}" data-course-number="${course.number}">Unregister</a>
          </section>
        </article>
322

323
        
324

325 326 327
      % endfor
    % else:
      <section class="empty-dashboard-message">
328 329
        <p>Looks like you haven't registered for any courses yet.</p>
        <a href="${reverse('courses')}">Find courses now!</a>
330 331
      </section>
    % endif
Matthew Mongeau committed
332

333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
    % 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
348 349
  </section>
</section>
350 351 352 353

<section id="unenroll-modal" class="modal unenroll-modal">
  <div class="inner-wrapper">
    <header>
354
      <h2>Are you sure you want to unregister from <span id="unenroll_course_number"></span>?</h2>
355
      <hr/>
356 357 358 359 360 361
    </header>

    <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">
362
        <input name="submit" type="submit" value="Unregister" />
363 364 365 366 367 368 369 370 371 372 373
      </div>
    </form>

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

374 375
<section id="password_reset_complete" class="modal">
  <div class="inner-wrapper">
376 377 378 379
    <header>
      <h2>Password Reset Email Sent</h2>
      <hr/>
    </header>
380
    <div>
381 382 383 384 385
      <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>
386 387 388 389 390 391 392 393
    </div>
    <div class="close-modal">
      <div class="inner">
        <p>&#10005;</p>
      </div>
    </div>
  </div>
</section>
394

395 396 397
<section id="change_email" class="modal">
  <div class="inner-wrapper">
    <header>
398
      <h2><span id="change_email_title">Change Email</span></h2>
399 400 401 402
      <hr/>
    </header>
    <div id="change_email_body">
      <form id="change_email_form">
403
        <div id="change_email_error" class="modal-form-error"> </div>
404
        <fieldset>
405 406 407 408 409 410
          <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>
411
          <section>
412
            <p>We will send a confirmation to both ${user.email} and your new email as part of the process.</p>
413
          </section>
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
          <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>
449 450 451 452 453 454 455 456 457 458
        </fieldset>
      </form>
    </div>
    <div class="close-modal">
      <div class="inner">
        <p>&#10005;</p>
      </div>
    </div>
  </div>
</section>