diff --git a/cms/static/js/views/settings/grading.js b/cms/static/js/views/settings/grading.js index e226147bdde..9e320cbfc71 100644 --- a/cms/static/js/views/settings/grading.js +++ b/cms/static/js/views/settings/grading.js @@ -147,7 +147,7 @@ define(['js/views/validation', // A does not have a drag bar (cannot change its upper limit) // Need to insert new bars in right place. - GRADES: ['A', 'B', 'C', 'D'], // defaults for new grade designators + GRADES: ['5', '4', '3', '2'], // defaults for new grade designators descendingCutoffs: [], // array of { designation : , cutoff : } gradeBarWidth: null, // cache of value since it won't change (more certain) diff --git a/common/djangoapps/student/helpers.py b/common/djangoapps/student/helpers.py index 71b46d5af5e..bab6b73e5bd 100644 --- a/common/djangoapps/student/helpers.py +++ b/common/djangoapps/student/helpers.py @@ -587,6 +587,17 @@ def _cert_info(user, enrollment, cert_status): course_overview.display_name, cert_status.get('mode'), cert_status['download_url'], ) + def get_utec_grade_from_standard_grade(standard_grade): + """ + This method receives a float standard grade and returns the corresponding utec grade label + """ + if settings.FEATURES.get('UTEC_CUSTOM_CERTS_GRADE', False): + for val in settings.FEATURES['UTEC_GRADE'].values(): + if float(val['min']) <= standard_grade <= float(val['max']): + return val['label'] + else: + return False + if status in {'generating', 'downloadable', 'notpassing', 'restricted', 'auditing', 'unverified'}: cert_grade_percent = -1 persisted_grade_percent = -1 @@ -609,6 +620,9 @@ def _cert_info(user, enrollment, cert_status): else max(filter(lambda x: x is not None, grades_input)) ) status_dict['grade'] = str(max_grade) + status_dict['utec_grade'] = str( + get_utec_grade_from_standard_grade(max_grade) + ) # If the grade is passing, the status is one of these statuses, and request certificate # is enabled for a course then we need to provide the option to the learner diff --git a/common/djangoapps/student/tests/tests.py b/common/djangoapps/student/tests/tests.py index a2e4c8a5dec..7d086b2381f 100644 --- a/common/djangoapps/student/tests/tests.py +++ b/common/djangoapps/student/tests/tests.py @@ -104,13 +104,15 @@ def test_cert_info(self): with patch('lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.read') as patch_persisted_grade: patch_persisted_grade.return_value = Mock(percent=1.0) assert _cert_info(user, enrollment, cert_status) == {'status': 'generating', 'show_survey_button': True, - 'survey_url': survey_url, 'grade': '1.0', + 'survey_url': survey_url, 'utec_grade': 'False', + 'grade': '1.0', 'mode': 'honor', 'linked_in_url': None, 'can_unenroll': False} cert_status = {'status': 'generating', 'grade': '0.67', 'mode': 'honor', 'uuid': None} assert _cert_info(user, enrollment, cert_status) == {'status': 'generating', 'show_survey_button': True, - 'survey_url': survey_url, 'grade': '0.67', 'mode': 'honor', + 'survey_url': survey_url, 'utec_grade': 'False', + 'grade': '0.67', 'mode': 'honor', 'linked_in_url': None, 'can_unenroll': False} cert_status = { @@ -123,6 +125,7 @@ def test_cert_info(self): assert _cert_info(user, enrollment, cert_status) == {'status': 'downloadable', 'download_url': cert.download_url, 'show_survey_button': True, 'survey_url': survey_url, + 'utec_grade': 'False', 'grade': '0.67', 'mode': 'honor', 'linked_in_url': None, 'can_unenroll': False} @@ -133,7 +136,7 @@ def test_cert_info(self): 'uuid': 'fakeuuidbutitsfine', } assert _cert_info(user, enrollment, cert_status) == {'status': 'notpassing', 'show_survey_button': True, - 'survey_url': survey_url, 'grade': '0.67', 'mode': 'honor', + 'survey_url': survey_url, 'utec_grade': 'False', 'grade': '0.67', 'mode': 'honor', 'linked_in_url': None, 'can_unenroll': True} # Test a course that doesn't have a survey specified @@ -148,7 +151,7 @@ def test_cert_info(self): 'download_url': cert.download_url, 'mode': 'honor', 'uuid': 'fakeuuidbutitsfine' } assert _cert_info(user, enrollment2, cert_status) == {'status': 'notpassing', 'show_survey_button': False, - 'grade': '0.67', 'mode': 'honor', 'linked_in_url': None, + 'grade': '0.67', 'utec_grade': 'False', 'mode': 'honor', 'linked_in_url': None, 'can_unenroll': True} course3 = CourseOverviewFactory.create( @@ -198,6 +201,7 @@ def test_cert_info_beta_tester(self): 'download_url': cert.download_url, 'show_survey_button': False, 'grade': grade, + 'utec_grade': 'False', 'mode': mode, 'linked_in_url': None, 'can_unenroll': False diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 8136ad3c50c..83293795bbd 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -1264,6 +1264,12 @@ def grade_cutoffs(self, value): def lowest_passing_grade(self): return min(self._grading_policy['GRADE_CUTOFFS'].values()) + @property + def utec_lowest_passing_grade(self): + for val in settings.FEATURES['UTEC_GRADE'].values(): + if float(val['min']) <= float(min(self._grading_policy['GRADE_CUTOFFS'].values())) <= float(val['max']): + return val['label'] + @property def is_cohorted(self): """ diff --git a/lms/djangoapps/certificates/views/webview.py b/lms/djangoapps/certificates/views/webview.py index 730b4526457..dc479bbd256 100644 --- a/lms/djangoapps/certificates/views/webview.py +++ b/lms/djangoapps/certificates/views/webview.py @@ -320,6 +320,7 @@ def _update_context_with_user_info(context, user, user_certificate): context['username'] = user.username context['course_mode'] = user_certificate.mode + context['grade'] = user_certificate.grade context['accomplishment_user_id'] = user.id context['accomplishment_copy_name'] = user_fullname context['accomplishment_copy_username'] = user.username @@ -342,6 +343,14 @@ def _update_context_with_user_info(context, user, user_certificate): fullname=user_fullname ) + if settings.FEATURES.get('UTEC_CUSTOM_CERTS_GRADE', False) and user_certificate.grade: + for val in settings.FEATURES['UTEC_GRADE'].values(): + if float(val['min']) <= float(user_certificate.grade) <= float(val['max']): + utec_grade = val['label'] + context['utec_final_grade'] = _('La calificacion de aprobacion es %(grade)s' % {'grade': utec_grade}) + else: + context['utec_final_grade'] = False + def _get_user_certificate(request, user, course_key, course_overview, preview_mode=None): """ diff --git a/lms/templates/certificates/_accomplishment-rendering.html b/lms/templates/certificates/_accomplishment-rendering.html index 7c5ae957f39..35dbf65b6f6 100644 --- a/lms/templates/certificates/_accomplishment-rendering.html +++ b/lms/templates/certificates/_accomplishment-rendering.html @@ -32,6 +32,9 @@ ${accomplishment_copy_course_org} ${course_number}: ${accomplishment_copy_course_name} + % if utec_final_grade: +
${utec_final_grade}
+ % endif diff --git a/lms/templates/dashboard/_dashboard_certificate_information.html b/lms/templates/dashboard/_dashboard_certificate_information.html index 51e2c58dc6e..a72e09b60c9 100644 --- a/lms/templates/dashboard/_dashboard_certificate_information.html +++ b/lms/templates/dashboard/_dashboard_certificate_information.html @@ -63,12 +63,19 @@