Wire up cert status
This commit is contained in:
committed by
Carlos Andrés Rocha
parent
01dcf291b6
commit
cf33d85ef9
@@ -2,7 +2,7 @@ from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from datetime import datetime
|
||||
|
||||
'''
|
||||
"""
|
||||
Certificates are created for a student and an offering of a course.
|
||||
|
||||
When a certificate is generated, a unique ID is generated so that
|
||||
@@ -35,8 +35,7 @@ State diagram:
|
||||
v v v
|
||||
[downloadable] [downloadable] [deleted]
|
||||
|
||||
'''
|
||||
|
||||
"""
|
||||
|
||||
class CertificateStatuses(object):
|
||||
unavailable = 'unavailable'
|
||||
@@ -88,6 +87,7 @@ def certificate_status_for_student(student, course_id):
|
||||
If the status is "downloadable", the dictionary also contains
|
||||
"download_url".
|
||||
|
||||
If the student has been graded, the dictionary also contains their grade for the course.
|
||||
'''
|
||||
|
||||
try:
|
||||
@@ -97,6 +97,7 @@ def certificate_status_for_student(student, course_id):
|
||||
return {
|
||||
'status': CertificateStatuses.downloadable,
|
||||
'download_url': generated_certificate.download_url,
|
||||
'grade': generated_certificate.grade,
|
||||
}
|
||||
else:
|
||||
return {'status': generated_certificate.status}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
from courseware.courses import course_image_url, get_course_about_section
|
||||
from courseware.access import has_access
|
||||
from certificates.models import CertificateStatuses
|
||||
%>
|
||||
<%inherit file="main.html" />
|
||||
|
||||
@@ -114,7 +115,7 @@
|
||||
</header>
|
||||
|
||||
% if len(courses) > 0:
|
||||
% for course in courses:
|
||||
% for course, cert_status in zip(courses, cert_statuses):
|
||||
|
||||
<article class="my-course">
|
||||
<%
|
||||
@@ -145,35 +146,65 @@
|
||||
</a>
|
||||
</article>
|
||||
|
||||
<div class="message message-status course-status-processing is-shown">
|
||||
<p class="message-copy">Final course details are being wrapped up at this time. Your final standing will be available shortly.</p>
|
||||
</div>
|
||||
|
||||
<div class="message message-status course-status-certrendering is-shown">
|
||||
<p class="message-copy">You have received a grade of <span class="grade-value">B</span> in this course.</p>
|
||||
% if course.has_ended:
|
||||
<%
|
||||
passing_grade = False
|
||||
cert_button = False
|
||||
survey_button = False
|
||||
if cert_status['status'] in [CertificateStatuses.generating, CertificateStatuses.regenerating]:
|
||||
status_css_class = 'course-status-certrendering'
|
||||
cert_button = True
|
||||
survey_button = True
|
||||
passing_grade = True
|
||||
elif cert_status['status'] == CertificateStatuses.downloadable:
|
||||
status_css_class = 'course-status-certavailable'
|
||||
cert_button = True
|
||||
survey_button = True
|
||||
passing_grade = True
|
||||
elif cert_status['status'] == CertificateStatuses.notpassing:
|
||||
status_css_class = 'course-status-certnotavailable'
|
||||
survey_button = True
|
||||
else cert_status['status']:
|
||||
# This is primarily the 'unavailable' state, but also 'error', 'deleted', etc.
|
||||
status_css_class = 'course-status-processing'
|
||||
|
||||
<ul class="actions">
|
||||
<li class="action"><span class="btn disabled" href="">Your Certificate is Generating</span></li>
|
||||
<li class="action"><a class="cta" href="">Complete our course feedback survey</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
if survey_button and not course.end_of_course_survey_url:
|
||||
survey_button = False
|
||||
%>
|
||||
<div class="message message-status ${status_css_class} is-shown">
|
||||
|
||||
<div class="message message-status course-status-certavailable is-shown">
|
||||
<p class="message-copy">You have received a grade of <span class="grade-value">B</span> in this course.</p>
|
||||
% if cert_status == CertificateStatuses.unavailable:
|
||||
<p class="message-copy">Final course details are being wrapped up at this time.
|
||||
Your final standing will be available shortly.</p>
|
||||
% elif passing_grade:
|
||||
<p class="message-copy">You have received a grade of
|
||||
<span class="grade-value">${cert_status['grade']}</span>
|
||||
in this course.</p>
|
||||
% elif cert_status == CertificateStatuses.notpassing:
|
||||
<p class="message-copy">You did not complete the necessary requirements for
|
||||
completion of this course. Your grade was <span class="grade-value">${cert_status['grade']}</span>
|
||||
</p>
|
||||
% endif
|
||||
% if cert_button or survey_button:
|
||||
<ul class="actions">
|
||||
% if cert_button and cert_status['status'] == CertificateStatuses.generating:
|
||||
<li class="action"><span class="btn disabled" href="">Your Certificate is Generating</span></li>
|
||||
% elif cert_button and cert_status['status'] == CertificateStatuses.downloadable:
|
||||
<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 survey_button:
|
||||
<li class="action"><a class="cta" href="${course.end_of_course_survey_url}">
|
||||
Complete our course feedback survey</a></li>
|
||||
% endif
|
||||
</ul>
|
||||
% endif
|
||||
</div>
|
||||
|
||||
<ul class="actions">
|
||||
<li class="action"><a class="btn" href="" title="This link will open/download a PDF document">Download Your PDF Certificate</a></li>
|
||||
<li class="action"><a class="cta" href="">Complete our course feedback survey</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="message message-status course-status-certnotavailable is-shown">
|
||||
<p class="message-copy">You did not complete the necessary requirements for completion of this course.</p>
|
||||
|
||||
<ul class="actions">
|
||||
<li class="action"><a class="cta" href="">Complete our course feedback survey</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
<a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id}" data-course-number="${course.number}">Unregister</a>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user