Skip to content

Commit

Permalink
feat: add ability to notify credentials about honor certificates (#32633
Browse files Browse the repository at this point in the history
)
  • Loading branch information
DmytroAlipov authored Apr 4, 2024
1 parent d865e1b commit 03a490f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 13 additions & 3 deletions openedx/core/djangoapps/credentials/tasks/v1/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.'
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions openedx/core/djangoapps/programs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 03a490f

Please sign in to comment.