Commit 97665bb1 by Joe Blaylock Committed by Giulio Gratta

Minimal refactoring for rolling certificates

* Studio advanced setting added, "certificates_show_before_end", which
  determines whether a course should permit certificates to be
  downloadable by students before the coures's end date has passed.
* Modifications to dashboard view and templates to allow display of
  certificate download links before course has ended. (XXX: may declare
  failing students as failing before the course has ended.)
* To test, turn the setting on in a course which hasn't ended yet, and
  force certificate generation for a student, then check their
  dashboard.
* TODO:
  - needs tests
  - needs pep8/pylint
parent 0f906d5a
...@@ -31,7 +31,6 @@ from django_future.csrf import ensure_csrf_cookie ...@@ -31,7 +31,6 @@ from django_future.csrf import ensure_csrf_cookie
from django.utils.http import cookie_date, base36_to_int from django.utils.http import cookie_date, base36_to_int
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.http import require_POST, require_GET from django.views.decorators.http import require_POST, require_GET
from django.contrib.admin.views.decorators import staff_member_required
from ratelimitbackend.exceptions import RateLimitException from ratelimitbackend.exceptions import RateLimitException
...@@ -185,7 +184,7 @@ def cert_info(user, course): ...@@ -185,7 +184,7 @@ def cert_info(user, course):
'survey_url': url, only if show_survey_button is True 'survey_url': url, only if show_survey_button is True
'grade': if status is not 'processing' 'grade': if status is not 'processing'
""" """
if not course.has_ended(): if not course.may_certify():
return {} return {}
return _cert_info(user, course, certificate_status_for_student(user, course.id)) return _cert_info(user, course, certificate_status_for_student(user, course.id))
......
...@@ -350,6 +350,9 @@ class CourseFields(object): ...@@ -350,6 +350,9 @@ class CourseFields(object):
) )
enrollment_domain = String(help="External login method associated with user accounts allowed to register in course", enrollment_domain = String(help="External login method associated with user accounts allowed to register in course",
scope=Scope.settings) scope=Scope.settings)
certificates_show_before_end = Boolean(help="True if students may download certificates before course end",
scope=Scope.settings,
default=False)
course_image = String( course_image = String(
help="Filename of the course image", help="Filename of the course image",
scope=Scope.settings, scope=Scope.settings,
...@@ -572,6 +575,12 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): ...@@ -572,6 +575,12 @@ class CourseDescriptor(CourseFields, SequenceDescriptor):
return datetime.now(UTC()) > self.end return datetime.now(UTC()) > self.end
def may_certify(self):
"""
Return True if it is acceptable to show the student a certificate download link
"""
return self.certificates_show_before_end or self.has_ended()
def has_started(self): def has_started(self):
return datetime.now(UTC()) > self.start return datetime.now(UTC()) > self.start
......
...@@ -62,6 +62,7 @@ def update_certificate(request): ...@@ -62,6 +62,7 @@ def update_certificate(request):
This view should only ever be accessed by the xqueue server This view should only ever be accessed by the xqueue server
""" """
status = CertificateStatuses
if request.method == "POST": if request.method == "POST":
xqueue_body = json.loads(request.POST.get('xqueue_body')) xqueue_body = json.loads(request.POST.get('xqueue_body'))
......
...@@ -14,7 +14,9 @@ else: ...@@ -14,7 +14,9 @@ else:
%> %>
<div class="message message-status ${status_css_class} is-shown"> <div class="message message-status ${status_css_class} is-shown">
% if cert_status['status'] == 'processing': % if course.may_certify() and cert_status['status'] == 'processing':
<p class="message-copy">${_("Your final standing is unrequested or unavailable at this time.")}</p>
% elif 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> <p class="message-copy">${_("Final course details are being wrapped up at this time. Your final standing will be available shortly.")}</p>
% elif cert_status['status'] in ('generating', 'ready', 'notpassing', 'restricted'): % elif cert_status['status'] in ('generating', 'ready', 'notpassing', 'restricted'):
<p class="message-copy">${_("Your final grade:")} <p class="message-copy">${_("Your final grade:")}
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
</h3> </h3>
</hgroup> </hgroup>
% if course.has_ended() and cert_status and not enrollment.mode == 'audit': % if course.may_certify() and cert_status and not enrollment.mode == 'audit':
<%include file='_dashboard_certificate_information.html' args='cert_status=cert_status,course=course, enrollment=enrollment'/> <%include file='_dashboard_certificate_information.html' args='cert_status=cert_status,course=course, enrollment=enrollment'/>
% endif % endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment