Skip to content

Commit

Permalink
refactor: move to unified grading events (#2520)
Browse files Browse the repository at this point in the history
  • Loading branch information
wowkalucky authored and kyrylo-kh committed Apr 15, 2024
1 parent 8a3ccb7 commit 7a01f0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
21 changes: 12 additions & 9 deletions lms/djangoapps/grades/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
from crum import get_current_user
from django.conf import settings
from eventtracking import tracker
from openedx_events.learning.data import UserCourseData, CourseData, UserData, UserPersonalData
from openedx_events.learning.signals import (
COURSE_GRADE_NOW_PASSED as COURSE_GRADE_NOW_PASSED_PUBLIC,
COURSE_GRADE_NOW_FAILED as COURSE_GRADE_NOW_FAILED_PUBLIC,
)
from openedx_events.learning.data import CcxCoursePassingStatusData, CourseData, CoursePassingStatusData, UserData, UserPersonalData
from openedx_events.learning.signals import CCX_COURSE_PASSING_STATUS_UPDATED, COURSE_PASSING_STATUS_UPDATED

from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.models import CourseEnrollment
Expand Down Expand Up @@ -196,8 +193,9 @@ def course_grade_now_passed(user, course_id):
)

# produce to event bus
COURSE_GRADE_NOW_PASSED_PUBLIC.send_event(
user_course_data=UserCourseData(
COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CoursePassingStatusData(
status=CoursePassingStatusData.PASSING,
user=UserData(
pii=UserPersonalData(
username=user.username,
Expand All @@ -210,6 +208,8 @@ def course_grade_now_passed(user, course_id):
course=CourseData(
course_key=course_id,
),
update_timestamp=None,
grading_policy_hash=None,
)
)

Expand All @@ -233,8 +233,9 @@ def course_grade_now_failed(user, course_id):
)

# produce to event bus
COURSE_GRADE_NOW_FAILED_PUBLIC.send_event(
user_course_data=UserCourseData(
COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CoursePassingStatusData(
status = CoursePassingStatusData.FAILING,
user=UserData(
pii=UserPersonalData(
username=user.username,
Expand All @@ -247,6 +248,8 @@ def course_grade_now_failed(user, course_id):
course=CourseData(
course_key=course_id,
),
update_timestamp=None,
grading_policy_hash=None,
)
)

Expand Down
8 changes: 4 additions & 4 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5498,15 +5498,15 @@ def _should_send_certificate_events(settings):
'course-authoring-xblock-lifecycle':
{'event_key_field': 'xblock_info.usage_key', 'enabled': False},
},
"org.openedx.learning.course.grade.now.passed.v1": {
"org.openedx.learning.course.passing.status.v1": {
"learning-badges-lifecycle": {
"event_key_field": "user_course_data.course.course_key",
"event_key_field": "course_passing_status.course.course_key",
"enabled": True,
},
},
"org.openedx.learning.course.grade.now.failed.v1": {
"org.openedx.learning.ccx.course.passing.status.v1": {
"learning-badges-lifecycle": {
"event_key_field": "user_course_data.course.course_key",
"event_key_field": "course_passing_status.course.course_key",
"enabled": True,
},
},
Expand Down

0 comments on commit 7a01f0c

Please sign in to comment.