Skip to content

Commit

Permalink
feat: [ACI-513, ACI-519] Emit CCX course FAILING/PASSING status (#2526)
Browse files Browse the repository at this point in the history
Co-authored-by: Sagirov Eugeniy <[email protected]>
  • Loading branch information
UvgenGen and Sagirov Eugeniy authored Mar 31, 2024
1 parent d72ed78 commit edc3218
Showing 1 changed file with 78 additions and 35 deletions.
113 changes: 78 additions & 35 deletions lms/djangoapps/grades/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
from crum import get_current_user
from django.conf import settings
from eventtracking import tracker
from openedx_events.learning.data import CcxCoursePassingStatusData, CourseData, CoursePassingStatusData, UserData, UserPersonalData
from openedx_events.learning.data import (
CcxCourseData,
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
Expand Down Expand Up @@ -193,25 +200,43 @@ def course_grade_now_passed(user, course_id):
)

# produce to event bus
COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CoursePassingStatusData(
status=CoursePassingStatusData.PASSING,
user=UserData(
pii=UserPersonalData(
username=user.username,
email=user.email,
name=user.get_full_name(),
if hasattr(course_id, 'ccx'):
CCX_COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CcxCoursePassingStatusData(
status=CcxCoursePassingStatusData.PASSING,
user=UserData(
pii=UserPersonalData(
username=user.username,
email=user.email,
name=user.get_full_name(),
),
id=user.id,
is_active=user.is_active,
),
course=CcxCourseData(
ccx_course_key=course_id,
master_course_key=course_id.to_course_locator(),
),
id=user.id,
is_active=user.is_active,
),
course=CourseData(
course_key=course_id,
),
update_timestamp=None,
grading_policy_hash=None,
)
)
else:
COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CoursePassingStatusData(
status=CoursePassingStatusData.PASSING,
user=UserData(
pii=UserPersonalData(
username=user.username,
email=user.email,
name=user.get_full_name(),
),
id=user.id,
is_active=user.is_active,
),
course=CourseData(
course_key=course_id,
),
)
)
)


def course_grade_now_failed(user, course_id):
Expand All @@ -233,25 +258,43 @@ def course_grade_now_failed(user, course_id):
)

# produce to event bus
COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CoursePassingStatusData(
status = CoursePassingStatusData.FAILING,
user=UserData(
pii=UserPersonalData(
username=user.username,
email=user.email,
name=user.get_full_name(),
if hasattr(course_id, 'ccx'):
CCX_COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CcxCoursePassingStatusData(
status=CcxCoursePassingStatusData.FAILING,
user=UserData(
pii=UserPersonalData(
username=user.username,
email=user.email,
name=user.get_full_name(),
),
id=user.id,
is_active=user.is_active,
),
id=user.id,
is_active=user.is_active,
),
course=CourseData(
course_key=course_id,
),
update_timestamp=None,
grading_policy_hash=None,
course=CcxCourseData(
ccx_course_key=course_id,
master_course_key=course_id.to_course_locator(),
),
)
)
else:
COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CoursePassingStatusData(
status = CoursePassingStatusData.FAILING,
user=UserData(
pii=UserPersonalData(
username=user.username,
email=user.email,
name=user.get_full_name(),
),
id=user.id,
is_active=user.is_active,
),
course=CourseData(
course_key=course_id,
),
)
)
)


def fire_segment_event_on_course_grade_passed_first_time(user_id, course_locator):
Expand Down

0 comments on commit edc3218

Please sign in to comment.