Commit 1ce7a245 by Filippo Valsorda

Make the SHOW_PROGRESS_SUCCESS_BUTTON feature more flexible

The button text default is now in the template and i18n-able, a
PROGRESS_SUCCESS_BUTTON_TEXT_OVERRIDE option is offered in settings.
The button url now uses string formatting.
parent da5ab6d2
...@@ -1288,9 +1288,9 @@ GRADES_DOWNLOAD = { ...@@ -1288,9 +1288,9 @@ GRADES_DOWNLOAD = {
} }
######################## PROGRESS SUCCESS BUTTON ############################## ######################## PROGRESS SUCCESS BUTTON ##############################
# The course id will be appended to the following url # The following fields are available in the URL: {course_id} {student_id}
PROGRESS_SUCCESS_BUTTON_URL = 'http://<domain>/<path>/' PROGRESS_SUCCESS_BUTTON_URL = 'http://<domain>/<path>/{course_id}'
PROGRESS_SUCCESS_BUTTON_TEXT = "Download your certificate" PROGRESS_SUCCESS_BUTTON_TEXT_OVERRIDE = None
#### PASSWORD POLICY SETTINGS ##### #### PASSWORD POLICY SETTINGS #####
......
...@@ -48,15 +48,17 @@ from django.conf import settings ...@@ -48,15 +48,17 @@ from django.conf import settings
<h1>${_("Course Progress for Student '{username}' ({email})").format(username=student.username, email=student.email)}</h1> <h1>${_("Course Progress for Student '{username}' ({email})").format(username=student.username, email=student.email)}</h1>
</header> </header>
%if settings.FEATURES['SHOW_PROGRESS_SUCCESS_BUTTON']: %if settings.FEATURES.get("SHOW_PROGRESS_SUCCESS_BUTTON"):
<% <%
SUCCESS_BUTTON_URL = settings.PROGRESS_SUCCESS_BUTTON_URL.format(
course_id=course.id, student_id=student.id)
nonzero_cutoffs = [cutoff for cutoff in course.grade_cutoffs.values() if cutoff > 0] nonzero_cutoffs = [cutoff for cutoff in course.grade_cutoffs.values() if cutoff > 0]
success_cutoff = min(nonzero_cutoffs) if nonzero_cutoffs else None success_cutoff = min(nonzero_cutoffs) if nonzero_cutoffs else None
%> %>
%if success_cutoff and grade_summary['percent'] > success_cutoff: %if success_cutoff and grade_summary['percent'] > success_cutoff:
<div id="course-success"> <div id="course-success">
<a href="${settings.PROGRESS_SUCCESS_BUTTON_URL}${course.id}"> <a href="${SUCCESS_BUTTON_URL}">
${settings.PROGRESS_SUCCESS_BUTTON_TEXT} ${settings.PROGRESS_SUCCESS_BUTTON_TEXT_OVERRIDE or _("Download your certificate")}
</a> </a>
</div> </div>
%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