openedx.core.djangoapps.credentials.tasks.v1 package#

Submodules#

openedx.core.djangoapps.credentials.tasks.v1.tasks module#

This file contains Celery tasks and utility functions supporting the Credentials IDA.

openedx.core.djangoapps.credentials.tasks.v1.tasks.certstr(cert)#
openedx.core.djangoapps.credentials.tasks.v1.tasks.gradestr(grade)#
openedx.core.djangoapps.credentials.tasks.v1.tasks.is_course_run_in_a_program(course_run_key)#

Returns true if the given course key is in any program at all. This functionality depends on data to be present in the program cache. We don’t have an easy way to determine if a course run is in a program, so we must search through each program (on a site-by-site basis).

Parameters:

course_run_key (CourseLocator) – The course run key used we are using to verify program membership

Returns:

A boolean describing if the course run is part of a program

openedx.core.djangoapps.credentials.tasks.v1.tasks.log_dry_run(certs, grades)#

Give a preview of what certs/grades we will handle.

openedx.core.djangoapps.credentials.tasks.v1.tasks.paged_query(queryset, delay, page_size)#

A generator that iterates through a queryset but only resolves chunks of it at once, to avoid overwhelming memory with a giant query. Also adds an optional delay between yields, to help with load.

openedx.core.djangoapps.credentials.tasks.v1.tasks.send_grade_if_interesting(user, course_run_key, mode, status, letter_grade, percent_grade, grade_last_updated=None, verbose=False)#

Checks if a grade is interesting to Credentials and schedules a Celery task if so. This is Credentials business logic that has bled into the LMS. We want to filter here in order to not flood our task queue with a bunch of signals, so we put up with it.

Parameters:
  • user (User) – User associated with this grade update

  • course_run_key (CourseLocator) – The course run key associated with this grade update

  • mode (string) – The “mode” for the specific course run (e.g. “verified”, “audit”, etc.)

  • status (string) – The status of the Certificate associated with this grade update

  • letter_grade (string) – The letter grade associated with this grade update (e.g. “A”, “B”, or “pass” or “fail”)

  • percent_grade (float) – A number representing the learner’s grade in this course run

  • grade_last_updated (DateTime) – DateTime object representing the last time the (percent) grade was updated in the LMS.

  • verbose (bool) – A value determining the logging level desired for this grade update

openedx.core.djangoapps.credentials.tasks.v1.tasks.send_notifications(certs, grades, site_config=None, delay=0, page_size=100, verbose=False, notify_programs=False, revoke_program_certs=False)#

Utility function responsible for bootstrapping certificate and grade updates to the Credentials IDA. We do this by invoking existing code paths that should force the LMS to (re-)send data to Credentials.

First, we directly call our Django signal handlers responsible for updating the status of certificates throughout the system. This will trigger attempts to send certificate status information to the Credentials IDA.

Then, we call a utility function (send_grade_if_interesting) that is responsible for determining if the Credentials IDA cares about this particular grade update for a learner.

Parameters:
  • certs (QuerySet) – A collection of course certificates associated with the users we need to update

  • grades (QuerySet) – A collection of grades associated with the users we need to update

  • site_config (SiteConfiguration) – Optional, may be None. The site associated with the users we need to update.

  • delay (int) – Delay (in seconds) to wait between queries

  • page_size (int) – Number of records to process from the certs or grades QuerySet at once. Used to handle load.

  • verbose (bool) – Used to determine level of logging output during grade updates

  • notify_programs (bool) – Used to determine if an update should be sent to Credentials

  • revoke_program_certs (bool) – Used to determine if the system should attempt revoking program certificates during this run of the notify_credentials management command

Module contents#