Skip to content

Commit

Permalink
test!: add loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Faraz Maqsood authored and Muhammad Faraz Maqsood committed Dec 22, 2023
1 parent fcf1978 commit 018c583
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lms/djangoapps/badges/events/course_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
Events which have to do with a user doing something with more than one course, such
as enrolling in a certain number, completing a certain number, or completing a specific set of courses.
"""

import logging

from lms.djangoapps.badges.models import BadgeClass, CourseEventBadgesConfiguration
from lms.djangoapps.badges.utils import requires_badges_enabled


log = logging.getLogger(__name__)


def award_badge(config, count, user):
"""
Given one of the configurations for enrollments or completions, award
Expand Down Expand Up @@ -62,18 +65,23 @@ def course_group_check(user, course_key):
"""
Awards a badge if a user has completed every course in a defined set.
"""
log.info("\n\n\n inside course_group_check \n\n\n")
from lms.djangoapps.grades.models import PersistentCourseGrade
config = CourseEventBadgesConfiguration.current().course_group_settings
log.info(f"\n\n\n course_key: {course_key} \n\n\n")
log.info(f"\n\n\n config: {config} \n\n\n")
awards = []
for slug, keys in config.items():
if course_key in keys:
passed_courses = PersistentCourseGrade.objects.filter(
passed_timestamp__isnull=False,
course_id__in=keys,
).count()
log.info(f"\n\n\n passed_courses: {passed_courses} \n\n\n")
log.info(f"\n\n\n len(keys): {len(keys)} \n\n\n")
if passed_courses == len(keys):
awards.append(slug)

log.info(f"\n\n\n awards: {awards} \n\n\n")
for slug in awards:
badge_class = BadgeClass.get_badge_class(
slug=slug, issuing_component='openedx__course', create=False,
Expand Down

0 comments on commit 018c583

Please sign in to comment.