Skip to content

Commit fcf1978

Browse files
Muhammad Faraz  MaqsoodMuhammad Faraz  Maqsood
Muhammad Faraz Maqsood
authored and
Muhammad Faraz Maqsood
committed
feat!: add badgr settings, make badges and courses independent incase of programs
1 parent f497c7b commit fcf1978

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lms/djangoapps/badges/events/course_meta.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ def course_group_check(user, course_key):
6262
"""
6363
Awards a badge if a user has completed every course in a defined set.
6464
"""
65-
from lms.djangoapps.certificates.data import CertificateStatuses
65+
from lms.djangoapps.grades.models import PersistentCourseGrade
6666
config = CourseEventBadgesConfiguration.current().course_group_settings
6767
awards = []
6868
for slug, keys in config.items():
6969
if course_key in keys:
70-
certs = user.generatedcertificate_set.filter(
71-
status__in=CertificateStatuses.PASSED_STATUSES,
70+
passed_courses = PersistentCourseGrade.objects.filter(
71+
passed_timestamp__isnull=False,
7272
course_id__in=keys,
73-
)
74-
if len(certs) == len(keys):
73+
).count()
74+
if passed_courses == len(keys):
7575
awards.append(slug)
7676

7777
for slug in awards:

lms/djangoapps/certificates/models.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1252,12 +1252,12 @@ def create_completion_badge(sender, user, course_key, status, **kwargs): # pyli
12521252
completion_check(user)
12531253

12541254

1255-
@receiver(COURSE_CERT_AWARDED, sender=GeneratedCertificate)
1256-
def create_course_group_badge(sender, user, course_key, status, **kwargs): # pylint: disable=unused-argument
1255+
@receiver(COURSE_GRADE_NOW_PASSED, dispatch_uid="new_passing_learner")
1256+
def create_course_group_badge(sender, user, course_id, **kwargs): # pylint: disable=unused-argument
12571257
"""
12581258
Standard signal hook to create badges when a user has completed a prespecified set of courses.
12591259
"""
1260-
course_group_check(user, course_key)
1260+
course_group_check(user, course_id)
12611261

12621262

12631263
class CertificateGenerationCommandConfiguration(ConfigurationModel):

0 commit comments

Comments
 (0)