diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c8310954..6928ff70 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,15 @@ Change Log Unreleased __________ +[10.3.0] - 2025-05-23 +--------------------- + +Added +~~~~~ + +* Added new ``LTI_PROVIDER_LAUNCH_SUCCESS`` event in learning. + + [10.2.1] - 2025-05-13 --------------------- diff --git a/openedx_events/__init__.py b/openedx_events/__init__.py index fcbd00c9..3be70d9a 100644 --- a/openedx_events/__init__.py +++ b/openedx_events/__init__.py @@ -5,4 +5,4 @@ more information about the project. """ -__version__ = "10.2.1" +__version__ = "10.3.0" diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+lti_provider+launch+success+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+lti_provider+launch+success+v1_schema.avsc new file mode 100644 index 00000000..6738f548 --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+lti_provider+launch+success+v1_schema.avsc @@ -0,0 +1,91 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "launch_data", + "type": { + "name": "LtiProviderLaunchData", + "type": "record", + "fields": [ + { + "name": "user", + "type": { + "name": "UserData", + "type": "record", + "fields": [ + { + "name": "id", + "type": "long" + }, + { + "name": "is_active", + "type": "boolean" + }, + { + "name": "pii", + "type": { + "name": "UserPersonalData", + "type": "record", + "fields": [ + { + "name": "username", + "type": "string" + }, + { + "name": "email", + "type": "string" + }, + { + "name": "name", + "type": "string" + } + ] + } + } + ] + } + }, + { + "name": "course_key", + "type": "string" + }, + { + "name": "usage_key", + "type": "string" + }, + { + "name": "launch_params", + "type": { + "name": "LtiProviderLaunchParamsData", + "type": "record", + "fields": [ + { + "name": "roles", + "type": "string" + }, + { + "name": "context_id", + "type": "string" + }, + { + "name": "user_id", + "type": "string" + }, + { + "name": "extra_params", + "type": { + "type": "map", + "values": "string" + } + } + ] + } + } + ] + } + } + ], + "namespace": "org.openedx.learning.lti_provider.launch.success.v1" +} \ No newline at end of file diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index eb12708c..014c53ec 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -656,3 +656,37 @@ class ExternalGraderScoreData: module_id = attr.ib(type=str) queue_key = attr.ib(type=str) queue_name = attr.ib(type=str) + + +@attr.s(frozen=True) +class LtiProviderLaunchParamsData: + """ + Data required for a successful LTI launch. + + Attributes: + roles (str): A comma-separated list of roles (as per LTI Spec) of the User. + context_id (str): An ID for the launch context of LTI content. + user_id (str): External (LTI) User ID of user performing the launch. + extra_params (dict): A dictionary of other optional launch parameters. + """ + roles = attr.ib(type=str) + context_id = attr.ib(type=str) + user_id = attr.ib(type=str) + extra_params = attr.ib(type=dict[str, str], factory=dict) + + +@attr.s(frozen=True) +class LtiProviderLaunchData: + """ + Class that encapsulates LTI data for an LTI launch event. + + Attributes: + user (UserData): The user data for the Open edX user initiating the launch. + course_key (CourseKey): The unique course ID for the course to which the launched content belongs. + usage_key (UsageKey): The usage key for the content being luanched via LtiProviderLaunchParamsData. + launch_params (LtiProviderLaunchParamsData): The LTI parameters used for the launch. + """ + user = attr.ib(type=UserData) + course_key = attr.ib(type=CourseKey) + usage_key = attr.ib(type=UsageKey) + launch_params = attr.ib(type=LtiProviderLaunchParamsData) diff --git a/openedx_events/learning/signals.py b/openedx_events/learning/signals.py index d5b7c1ff..89bdce85 100644 --- a/openedx_events/learning/signals.py +++ b/openedx_events/learning/signals.py @@ -21,6 +21,7 @@ DiscussionThreadData, ExamAttemptData, ExternalGraderScoreData, + LtiProviderLaunchData, ORASubmissionData, PersistentCourseGradeData, ProgramCertificateData, @@ -504,3 +505,15 @@ "score": ExternalGraderScoreData, } ) + + +# .. event_type: org.openedx.learning.lti_provider.launch.success.v1 +# .. event_name: LTI_PROVIDER_LAUNCH_SUCCESS +# .. event_description: emitted when a student accesses learning content via LTI +# .. event_data: LtiProviderLaunchData +LTI_PROVIDER_LAUNCH_SUCCESS = OpenEdxPublicSignal( + event_type="org.openedx.learning.lti_provider.launch.success.v1", + data={ + "launch_data": LtiProviderLaunchData, + } +)