From da5ab6d222e629c58741024edf7a014dfc29bd41 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Mon, 3 Mar 2014 01:21:25 +0100 Subject: [PATCH 1/2] Add SHOW_PROGRESS_SUCCESS_BUTTON feature Show a button at the top of lms/templates/courseware/progress.html if the lowest nonzero grade cutoff has been reached. Introduce two settings: PROGRESS_SUCCESS_BUTTON_URL is the href of that button (the course id is appended); PROGRESS_SUCCESS_BUTTON_TEXT is the text, defaults to "Download your certificate" --- lms/envs/common.py | 9 +++++++++ lms/static/sass/course/_profile.scss | 18 ++++++++++++++++++ lms/templates/courseware/progress.html | 14 ++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/lms/envs/common.py b/lms/envs/common.py index 2d6cd4b525..8d3f205cd2 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -243,6 +243,10 @@ FEATURES = { # Turn off Advanced Security by default 'ADVANCED_SECURITY': False, + + # Show a "Download your certificate" on the Progress page if the lowest + # nonzero grade cutoff is met + 'SHOW_PROGRESS_SUCCESS_BUTTON': False, } # Used for A/B testing @@ -1283,6 +1287,11 @@ GRADES_DOWNLOAD = { 'ROOT_PATH': '/tmp/edx-s3/grades', } +######################## PROGRESS SUCCESS BUTTON ############################## +# The course id will be appended to the following url +PROGRESS_SUCCESS_BUTTON_URL = 'http:////' +PROGRESS_SUCCESS_BUTTON_TEXT = "Download your certificate" + #### PASSWORD POLICY SETTINGS ##### PASSWORD_MIN_LENGTH = None diff --git a/lms/static/sass/course/_profile.scss b/lms/static/sass/course/_profile.scss index 87272963be..00615a07a6 100644 --- a/lms/static/sass/course/_profile.scss +++ b/lms/static/sass/course/_profile.scss @@ -148,6 +148,24 @@ } } + #course-success { + margin-bottom: 30px; + text-align: center; + > a { + @include button(simple, $button-color); + @include box-sizing(border-box); + border-radius: 3px; + font: normal 15px/1.6rem $sans-serif; + letter-spacing: 0; + padding: 5px 18px 6px; + text-align: center; + + &:hover, &:focus { + text-decoration: none; + } + } + } + #grade-detail-graph { min-height: 400px; width: 100%; diff --git a/lms/templates/courseware/progress.html b/lms/templates/courseware/progress.html index 762d4dcea1..a1ef13debf 100644 --- a/lms/templates/courseware/progress.html +++ b/lms/templates/courseware/progress.html @@ -48,6 +48,20 @@ from django.conf import settings

${_("Course Progress for Student '{username}' ({email})").format(username=student.username, email=student.email)}

+ %if settings.FEATURES['SHOW_PROGRESS_SUCCESS_BUTTON']: + <% + nonzero_cutoffs = [cutoff for cutoff in course.grade_cutoffs.values() if cutoff > 0] + success_cutoff = min(nonzero_cutoffs) if nonzero_cutoffs else None + %> + %if success_cutoff and grade_summary['percent'] > success_cutoff: + + %endif + %endif + %if not course.disable_progress_graph: %endif From 1ce7a24572c254beb943bc9482cd44cf81fa7f27 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Fri, 28 Mar 2014 21:04:27 +0100 Subject: [PATCH 2/2] 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. --- lms/envs/common.py | 6 +++--- lms/templates/courseware/progress.html | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index 8d3f205cd2..f4e553b72f 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1288,9 +1288,9 @@ GRADES_DOWNLOAD = { } ######################## PROGRESS SUCCESS BUTTON ############################## -# The course id will be appended to the following url -PROGRESS_SUCCESS_BUTTON_URL = 'http:////' -PROGRESS_SUCCESS_BUTTON_TEXT = "Download your certificate" +# The following fields are available in the URL: {course_id} {student_id} +PROGRESS_SUCCESS_BUTTON_URL = 'http:////{course_id}' +PROGRESS_SUCCESS_BUTTON_TEXT_OVERRIDE = None #### PASSWORD POLICY SETTINGS ##### diff --git a/lms/templates/courseware/progress.html b/lms/templates/courseware/progress.html index a1ef13debf..ad5fa70b18 100644 --- a/lms/templates/courseware/progress.html +++ b/lms/templates/courseware/progress.html @@ -48,15 +48,17 @@ from django.conf import settings

${_("Course Progress for Student '{username}' ({email})").format(username=student.username, email=student.email)}

- %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] success_cutoff = min(nonzero_cutoffs) if nonzero_cutoffs else None %> %if success_cutoff and grade_summary['percent'] > success_cutoff: %endif