Skip to content

Commit

Permalink
feat: take the changes make in commit 049ec229812fb499d432a41a350f5dd…
Browse files Browse the repository at this point in the history
…594c45531
  • Loading branch information
BetoFandino committed Aug 26, 2023
1 parent d21ef9e commit ed7601c
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cms/static/js/views/settings/grading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions common/djangoapps/student/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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}

Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions common/lib/xmodule/xmodule/course_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
9 changes: 9 additions & 0 deletions lms/djangoapps/certificates/views/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down
3 changes: 3 additions & 0 deletions lms/templates/certificates/_accomplishment-rendering.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<span class="accomplishment-course-org">${accomplishment_copy_course_org} </span>
<span class="accomplishment-course-number">${course_number}</span>:
<span class="accomplishment-course-name">${accomplishment_copy_course_name}</span>
% if utec_final_grade:
<p>${utec_final_grade}</p>
% endif
</span>
</p>

Expand Down
15 changes: 11 additions & 4 deletions lms/templates/dashboard/_dashboard_certificate_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@
<div class="message-copy">
% if cert_status['status'] == CertificateStatuses.downloadable or cert_status['status'] == CertificateStatuses.requesting:
${_("Congratulations! Your certificate is ready.")}
% elif cert_status['status'] == 'notpassing':
% if enrollment.mode != 'audit':
${_("Grade required for a {cert_name_short}:").format(cert_name_short=cert_name_short)}
% if cert_status['utec_grade']:
<span class="grade-value">${cert_status['utec_grade']}</span>
% else:
<span class="grade-value">${"{0:.0f}%".format(float(cert_status['grade'])*100)}</span>.
% endif
% elif ccert_status['status'] == 'notpassing' and enrollment.mode != 'audit':
${_("Grade required for a {cert_name_short}:").format(cert_name_short=cert_name_short)}
% if cert_status['utec_grade']:
<span class="grade-value">${course_overview.utec_lowest_passing_grade}</span>
% else:
${_("Grade required to pass this course:")}
<span class="grade-value">${"{0:.0f}%".format(float(course_overview.lowest_passing_grade)*100)}</span>.
% endif

<span class="grade-value">${"{0:.0f}%".format(float(course_overview.lowest_passing_grade)*100)}</span>.
% elif cert_status['status'] == 'restricted' and enrollment.mode == 'verified':
<p class="message-copy">
Expand Down
6 changes: 6 additions & 0 deletions openedx/core/djangoapps/content/course_overviews/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@ def location(self):
self._location = self._location.map_into_course(self.id)
return self._location

@property
def utec_lowest_passing_grade(self):
store = modulestore()
descriptor = store.get_course(self.id)
return descriptor.utec_lowest_passing_grade

@property
def number(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions openedx/core/djangoapps/user_authn/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def create_account_with_params(request, params): # pylint: disable=too-many-sta
registration_fields.get('honor_code') != 'hidden'
)

tos_required = settings.FEATURES.get("UTEC_TOS_REQUIRED", tos_required)

form = AccountCreationForm(
data=params,
extra_fields=extra_fields,
Expand Down

0 comments on commit ed7601c

Please sign in to comment.