Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PADV 1276 - Move edx-platform changes to our repository #123

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions lms/djangoapps/grades/event_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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


def emit_course_passing_status_update(user, course_id, is_passing):
if hasattr(course_id, 'ccx'):
CCX_COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CcxCoursePassingStatusData(
is_passing=is_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(),
),
)
)
else:
COURSE_PASSING_STATUS_UPDATED.send_event(
course_passing_status=CoursePassingStatusData(
is_passing=is_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,
),
)
)
5 changes: 5 additions & 0 deletions lms/djangoapps/grades/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
get_event_transaction_type,
set_event_transaction_type
)
from lms.djangoapps.grades.event_utils import emit_course_passing_status_update
from lms.djangoapps.grades.signals.signals import SCHEDULE_FOLLOW_UP_SEGMENT_EVENT_FOR_COURSE_PASSED_FIRST_TIME
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.features.enterprise_support.context import get_enterprise_event_context
Expand Down Expand Up @@ -190,6 +191,8 @@ def course_grade_now_passed(user, course_id):
}
)

emit_course_passing_status_update(user, course_id, is_passing=True)


def course_grade_now_failed(user, course_id):
"""
Expand All @@ -209,6 +212,8 @@ def course_grade_now_failed(user, course_id):
}
)

emit_course_passing_status_update(user, course_id, is_passing=False)


def fire_segment_event_on_course_grade_passed_first_time(user_id, course_locator):
"""
Expand Down
Loading