Skip to content

Commit

Permalink
refactor: move to unified grading events
Browse files Browse the repository at this point in the history
  • Loading branch information
wowkalucky committed Mar 28, 2024
1 parent 474269c commit bec1211
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 @@ -5277,15 +5277,15 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
# Note: The topic names should not include environment prefix as it will be dynamically added based on
# EVENT_BUS_TOPIC_PREFIX setting.
EVENT_BUS_PRODUCER_CONFIG = {
"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 bec1211

Please sign in to comment.