@requires_badges_enabled
def course_group_check(user, course_key):
 from certificates.models import CertificateStatuses
 config = CourseEventBadgesConfiguration.current().course_group_settings
 awards = []
 for (slug, keys) in config.items():
  if (course_key in keys):
   certs = user.generatedcertificate_set.filter(status__in=CertificateStatuses.PASSED_STATUSES, course_id__in=keys)
   if (len(certs) == len(keys)):
    awards.append(slug)
 for slug in awards:
  badge_class = BadgeClass.get_badge_class(slug=slug, issuing_component='openedx__course', create=False)
  if (badge_class and (not badge_class.get_for_user(user))):
   badge_class.award(user)

@ requires_badges_enabled def course_group_check ( user , course_key ) : from certificates . models import CertificateStatuses config = CourseEventBadgesConfiguration . current ( ) . course_group_settings awards = [ ] for ( slug , keys ) in config . items ( ) : if ( course_key in keys ) : certs = user . generatedcertificate_set . filter ( status__in = CertificateStatuses . PASSED_STATUSES , course_id__in = keys ) if ( len ( certs ) == len ( keys ) ) : awards . append ( slug ) for slug in awards : badge_class = BadgeClass . get_badge_class ( slug = slug , issuing_component = 'openedx__course' , create = False ) if ( badge_class and ( not badge_class . get_for_user ( user ) ) ) : badge_class . award ( user )
awards a badge if a user has completed every course in a defined set .