diff --git a/common/djangoapps/student/helpers.py b/common/djangoapps/student/helpers.py index 117a2d7f20..14f01bbc5e 100644 --- a/common/djangoapps/student/helpers.py +++ b/common/djangoapps/student/helpers.py @@ -779,3 +779,18 @@ def does_user_profile_exist(user): return hasattr(user, 'profile') except (ProgrammingError, ObjectDoesNotExist): return False + + +def user_has_passing_grade_in_course(enrollment): + """ + Check to see if a user has passing grade for a course + """ + try: + user = enrollment.user + course = enrollment.course_overview + course_grade = CourseGradeFactory().read(user, course, create_if_needed=False) + if course_grade: + return course_grade.passed + except AttributeError: + pass + return False diff --git a/lms/templates/dashboard/_dashboard_certificate_information.html b/lms/templates/dashboard/_dashboard_certificate_information.html index c0ded0d125..e045e30ad9 100644 --- a/lms/templates/dashboard/_dashboard_certificate_information.html +++ b/lms/templates/dashboard/_dashboard_certificate_information.html @@ -1,4 +1,4 @@ -<%page expression_filter="h" args="cert_status, course_overview, enrollment, reverify_link" /> +<%page expression_filter="h" args="cert_status, course_ended_not_passing, course_overview, enrollment, reverify_link" /> <%! from django.urls import reverse @@ -8,6 +8,7 @@ from openedx.core.djangolib.markup import HTML, Text from common.djangoapps.course_modes.models import CourseMode from lms.djangoapps.certificates.data import CertificateStatuses from xmodule.data import CertificatesDisplayBehaviors +from common.djangoapps.student.helpers import user_has_passing_grade_in_course %> <%namespace name='static' file='../static_content.html'/> @@ -33,7 +34,10 @@ elif cert_status['status'] == CertificateStatuses.notpassing: else: status_css_class = 'course-status-processing' %> -<% requesting_post_url = reverse('generate_user_cert', args=[str(course_overview.id)]) %> +<% + requesting_post_url = reverse('generate_user_cert', args=[str(course_overview.id)]) + progress_page_url = reverse('progress', args=[str(course_overview.id)]) +%> % if cert_status['status'] != 'processing': % if cert_status['status'] == 'certificate_earned_but_not_available': @@ -161,5 +165,21 @@ else: % endif +% elif course_ended_not_passing: +
% endif diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html index ea52213f4a..92d3a7f96a 100644 --- a/lms/templates/dashboard/_dashboard_course_listing.html +++ b/lms/templates/dashboard/_dashboard_course_listing.html @@ -11,6 +11,7 @@ from django.utils.translation import ungettext from django.urls import reverse from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.helpers import enrollment_mode_display +from common.djangoapps.student.helpers import user_has_passing_grade_in_course from lms.djangoapps.course_home_api.toggles import course_home_legacy_is_active from lms.djangoapps.verify_student.services import IDVerificationService from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string @@ -43,6 +44,12 @@ from lms.djangoapps.experiments.utils import UPSELL_TRACKING_FLAG is_course_expired = hasattr(show_courseware_link, 'error_code') and show_courseware_link.error_code == 'audit_expired' %> +<% + is_non_certificate_enrollment = enrollment.mode == "audit" or enrollment.mode == "honor" + is_passing_course = user_has_passing_grade_in_course(enrollment) + course_ended_not_passing = course_overview.has_ended() and is_passing_course == False and is_non_certificate_enrollment == False +%> + <%namespace name='static' file='../static_content.html'/>