From fe376a1e1588745cd4e25c149a53d141ea099c4a Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 19 Dec 2023 18:48:04 +0500 Subject: [PATCH] testing --- lms/djangoapps/badges/events/course_complete.py | 8 +++++++- lms/djangoapps/certificates/models.py | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/badges/events/course_complete.py b/lms/djangoapps/badges/events/course_complete.py index 853465dfb8d6..29c9c532b554 100644 --- a/lms/djangoapps/badges/events/course_complete.py +++ b/lms/djangoapps/badges/events/course_complete.py @@ -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 @@ -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='', @@ -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 diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index dc43b0fd3515..3b0827f09ece 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -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 @@ -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): """