From 1f1efbbeaf4f7e0b771e4c557896bd53ce6dfeb2 Mon Sep 17 00:00:00 2001 From: alipov_d Date: Wed, 4 Oct 2023 08:46:01 +0300 Subject: [PATCH] feat: add ability to notify credentials about honor certificates --- .../djangoapps/credentials/tasks/v1/tasks.py | 16 +++++++++++++--- openedx/core/djangoapps/programs/tasks.py | 10 ++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/openedx/core/djangoapps/credentials/tasks/v1/tasks.py b/openedx/core/djangoapps/credentials/tasks/v1/tasks.py index 31d2db8cfa0f..347e9552a19a 100644 --- a/openedx/core/djangoapps/credentials/tasks/v1/tasks.py +++ b/openedx/core/djangoapps/credentials/tasks/v1/tasks.py @@ -366,7 +366,11 @@ def send_grade_if_interesting( # a learner has made an attempt at a course run of a course, so it wants to know about all the learner's efforts. # This check is attempt to prevent updates being sent to Credentials that it does not care about (e.g. updates # related to a legacy Audit course) - if mode not in INTERESTING_MODES or status not in INTERESTING_STATUSES: + if ( + mode not in INTERESTING_MODES + and not CourseMode.is_eligible_for_certificate(mode) + or status not in INTERESTING_STATUSES + ): if verbose: logger.warning(f"{warning_base} mode ({mode}) or status ({status}) is not interesting to Credentials") return @@ -439,7 +443,10 @@ def backfill_date_for_all_course_runs(): course_key = str(course_run.id) course_modes = CourseMode.objects.filter(course_id=course_key) # There should only ever be one certificate relevant mode per course run - modes = [mode.slug for mode in course_modes if mode.slug in CourseMode.CERTIFICATE_RELEVANT_MODES] + modes = [ + mode.slug for mode in course_modes + if mode.slug in CourseMode.CERTIFICATE_RELEVANT_MODES or CourseMode.is_eligible_for_certificate(mode.slug) + ] if len(modes) != 1: logger.exception( f'Either course {course_key} has no certificate mode or multiple modes. Task failed.' @@ -490,7 +497,10 @@ def clean_certificate_available_date(): course_key = str(course_run.id) course_modes = CourseMode.objects.filter(course_id=course_key) # There should only ever be one certificate relevant mode per course run - modes = [mode.slug for mode in course_modes if mode.slug in CourseMode.CERTIFICATE_RELEVANT_MODES] + modes = [ + mode.slug for mode in course_modes + if mode.slug in CourseMode.CERTIFICATE_RELEVANT_MODES or CourseMode.is_eligible_for_certificate(mode.slug) + ] if len(modes) != 1: logger.exception(f'Either course {course_key} has no certificate mode or multiple modes. Task failed.') # if there is only one relevant mode, post to credentials diff --git a/openedx/core/djangoapps/programs/tasks.py b/openedx/core/djangoapps/programs/tasks.py index 9d77f427d66d..72ccc79bddfc 100644 --- a/openedx/core/djangoapps/programs/tasks.py +++ b/openedx/core/djangoapps/programs/tasks.py @@ -426,7 +426,10 @@ def update_credentials_course_certificate_configuration_available_date( course_key = str(course_key) course_modes = CourseMode.objects.filter(course_id=course_key) # There should only ever be one certificate relevant mode per course run - modes = [mode.slug for mode in course_modes if mode.slug in CourseMode.CERTIFICATE_RELEVANT_MODES] + modes = [ + mode.slug for mode in course_modes + if mode.slug in CourseMode.CERTIFICATE_RELEVANT_MODES or CourseMode.is_eligible_for_certificate(mode.slug) + ] if len(modes) != 1: LOGGER.exception(f"Either course {course_key} has no certificate mode or multiple modes. Task failed.") return @@ -509,7 +512,10 @@ def _retry_with_custom_exception(username, course_run_key, reason, countdown): ) return - if certificate.mode in CourseMode.CERTIFICATE_RELEVANT_MODES: + if ( + certificate.mode in CourseMode.CERTIFICATE_RELEVANT_MODES + or CourseMode.is_eligible_for_certificate(certificate.mode) + ): course_overview = get_course_overview_or_none(course_key) if not course_overview: LOGGER.warning(