Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Faraz Maqsood authored and Muhammad Faraz Maqsood committed Dec 19, 2023
1 parent 2936693 commit fe376a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lms/djangoapps/badges/events/course_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def criteria(course_key):
about_path = reverse('about_course', kwargs={'course_id': str(course_key)})
return f'{site_prefix()}{about_path}'


import logging
log = logging.getLogger(__name__)
def get_completion_badge(course_id, user):
"""
Given a course key and a user, find the user's enrollment mode
Expand All @@ -90,12 +91,15 @@ def get_completion_badge(course_id, user):
badge_classes = CourseEnrollment.objects.filter(
user=user, course_id=course_id
).order_by('-is_active')
log.info(f"badge_classes {badge_classes}")
if not badge_classes:
return None
mode = badge_classes[0].mode
course = modulestore().get_course(course_id)
log.info(f"course.issue_badges {course.issue_badges}")
if not course.issue_badges:
return None
log.info(f"outside get_badge_class")
return BadgeClass.get_badge_class(
slug=course_slug(course_id, mode),
issuing_component='',
Expand All @@ -114,10 +118,12 @@ def course_badge_check(user, course_key):
Takes a GeneratedCertificate instance, and checks to see if a badge exists for this course, creating
it if not, should conditions be right.
"""
LOGGER.info("inside course_badge_check")
if not modulestore().get_course(course_key).issue_badges:
LOGGER.info("Course is not configured to issue badges.")
return
badge_class = get_completion_badge(course_key, user)
LOGGER.info(f"badge_class {badge_class}")
if not badge_class:
# We're not configured to make a badge for this course mode.
return
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/certificates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from lms.djangoapps.badges.events.course_meta import completion_check, course_group_check
from lms.djangoapps.certificates.data import CertificateStatuses
from lms.djangoapps.instructor_task.models import InstructorTask
from openedx.core.djangoapps.signals.signals import COURSE_CERT_AWARDED, COURSE_CERT_CHANGED, COURSE_CERT_REVOKED
from openedx.core.djangoapps.signals.signals import COURSE_CERT_AWARDED, COURSE_CERT_CHANGED, COURSE_CERT_REVOKED, COURSE_GRADE_NOW_PASSED
from openedx.core.djangoapps.xmodule_django.models import NoneToEmptyManager
from openedx.features.name_affirmation_api.utils import get_name_affirmation_service

Expand Down Expand Up @@ -1235,7 +1235,7 @@ class Meta:
app_label = "certificates"


@receiver(COURSE_CERT_AWARDED, sender=GeneratedCertificate)
@receiver(COURSE_GRADE_NOW_PASSED, sender=GeneratedCertificate)
# pylint: disable=unused-argument
def create_course_badge(sender, user, course_key, status, **kwargs):
"""
Expand Down

0 comments on commit fe376a1

Please sign in to comment.