Skip to content

feat: new event to track LTI Launches via LTI Provider#320

Merged
pdpinch merged 4 commits into
mitodl:mitx/teakfrom
open-craft:kshitij/lti-launch-event.mitx.teak
Aug 11, 2025
Merged

feat: new event to track LTI Launches via LTI Provider#320
pdpinch merged 4 commits into
mitodl:mitx/teakfrom
open-craft:kshitij/lti-launch-event.mitx.teak

Conversation

@xitij2000

@xitij2000 xitij2000 commented May 29, 2025

Copy link
Copy Markdown

Description

Cherry pick of openedx#36756 to teak

arslanashraf7 and others added 3 commits May 27, 2025 08:27
* feat: add canvas integration support

(cherry picked from commit fdb818a)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @xitij2000, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello team,

Gemini (gemini-code-assist) here to provide a summary of this pull request based on the provided title, empty description, and patch content.

Based on the changes, the primary intent of this PR appears to be the implementation of an event signal for successful LTI launches within the LMS. This signal, LTI_PROVIDER_LAUNCH_SUCCESS, is emitted after a valid LTI launch request has been processed and the user has been authenticated and parameters stored. The event carries detailed data about the launch, including user information (with PII), course and usage keys, and sanitized launch parameters.

To support this, the PR also updates the openedx-events dependency to point to a specific branch (kshitij/lti-launch-event) on a GitHub repository, suggesting that the necessary event definition and data structures are included in that particular version of the library.

Highlights

  • New Event Signal: Introduces the LTI_PROVIDER_LAUNCH_SUCCESS event signal, emitted upon successful LTI launches.
  • Event Data: The new event includes structured data about the launch, such as user details (including PII like username, email, and name), the course and usage keys, and the LTI launch parameters (excluding sensitive OAuth fields).
  • Dependency Update: Updates the openedx-events library dependency across various requirements files to point to a specific development branch (kshitij/lti-launch-event) where the new event definition likely resides.

Changelog

Click here to see the changelog
  • lms/djangoapps/lti_provider/tests/test_views.py
    • Added imports for new event data classes from openedx_events.learning.data (line 13).
    • Patched the LTI_PROVIDER_LAUNCH_SUCCESS.send_event signal in test_valid_launch (line 100).
    • Added an assertion to verify that the send_event method is called with the correct LtiProviderLaunchData structure containing user, course, usage, and launch parameter details (lines 110-129).
  • lms/djangoapps/lti_provider/views.py
    • Added imports for event data classes and the LTI_PROVIDER_LAUNCH_SUCCESS signal from openedx_events.learning (lines 15-16).
    • Added code within the lti_launch view to copy and sanitize launch parameters by removing oauth_ prefixed keys (lines 112-116).
    • Added code to construct LtiProviderLaunchData using user details, course/usage keys, and sanitized launch parameters (lines 118-137).
    • Added a call to LTI_PROVIDER_LAUNCH_SUCCESS.send_event with the constructed launch data (line 118).
  • requirements/constraints.txt
    • Updated the openedx-events dependency to reference a specific git branch (kshitij/lti-launch-event) instead of a fixed version (line 172).
  • requirements/edx/base.txt
    • Updated the openedx-events dependency to reference a specific git branch (kshitij/lti-launch-event) instead of a fixed version (line 804).
  • requirements/edx/development.txt
    • Updated the openedx-events dependency to reference a specific git branch (kshitij/lti-launch-event) instead of a fixed version (line 1361).
  • requirements/edx/doc.txt
    • Updated the openedx-events dependency to reference a specific git branch (kshitij/lti-launch-event) instead of a fixed version (line 975).
  • requirements/edx/testing.txt
    • Updated the openedx-events dependency to reference a specific git branch (kshitij/lti-launch-event) instead of a fixed version (line 1033).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A signal sent,
Launch data flows out,
Event now known.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@xitij2000 xitij2000 changed the title Kshitij/lti launch event.mitx.teak feat: new event to track LTI Launches via LTI Provider May 29, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an event signal for successful LTI provider launches. The implementation is straightforward and includes necessary tests and updates to dependencies. The core logic for event data preparation and emission is sound. Key areas for attention are the accuracy of test assertions and ensuring the PR description is comprehensive for future reference and review. The dependency on a development branch of openedx-events should also be managed before merging to a stable environment.

Summary of Findings

  • Test Accuracy for extra_params: The test test_valid_launch asserts extra_params={}. However, the build_launch_request function and the view logic imply that extra_params should contain other LTI parameters like lis_result_sourcedid, lis_outcome_service_url, and tool_consumer_instance_guid. The test assertion needs to be updated to reflect this for correctness.
  • PR Description: The pull request description is currently a template. It should be filled out to provide context, testing instructions, and other relevant information about the change.
  • Dependency Management: The PR changes openedx-events to a git branch. This is fine for development but should be updated to a released version before merging to a stable branch or for a release.

Merge Readiness

This PR introduces a valuable event for LTI launches. Before merging, I recommend addressing the high-severity issue in the test to ensure its accuracy. Additionally, filling out the PR description and having a clear plan for managing the openedx-events dependency (updating it to a released version eventually) would be beneficial. I am not authorized to approve pull requests, so please ensure further review and approval from authorized maintainers.

Comment on lines +110 to +129
lti_launch_success_send_event.assert_called_with(
launch_data=LtiProviderLaunchData(
user=UserData(
id=request.user.id,
is_active=request.user.is_active,
pii=UserPersonalData(
username=request.user.username,
email=request.user.email,
name=request.user.profile.name,
)
),
course_key=COURSE_KEY,
usage_key=USAGE_KEY,
launch_params=LtiProviderLaunchParamsData(
roles='Instructor,urn:lti:instrole:ims/lis/Administrator',
context_id='lti_launch_context_id',
user_id='LTI_User', extra_params={}
)
)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The assertion for extra_params is currently extra_params={}. However, based on the build_launch_request function (which populates the initial LTI parameters for the test) and the logic in lti_provider.views.lti_launch (which processes these parameters), several non-OAuth, non-explicitly-popped parameters should remain and be collected into extra_params.

Specifically, build_launch_request includes:

  • lis_result_sourcedid: 'test_sourcedid'
  • lis_outcome_service_url: 'test_url'
  • tool_consumer_instance_guid: 'test_guid'

These parameters are not OAuth parameters and are not among those explicitly popped (course_key, usage_key, roles, context_id, user_id) before constructing extra_params in the view. Therefore, they should be present in the extra_params dictionary.

Could you update the assertion to reflect the expected extra_params? This would make the test more accurately verify the behavior of the extra_params collection.

        lti_launch_success_send_event.assert_called_with(
            launch_data=LtiProviderLaunchData(
                user=UserData(
                    id=request.user.id,
                    is_active=request.user.is_active,
                    pii=UserPersonalData(
                        username=request.user.username,
                        email=request.user.email,
                        name=request.user.profile.name,
                    )
                ),
                course_key=COURSE_KEY,
                usage_key=USAGE_KEY,
                launch_params=LtiProviderLaunchParamsData(
                    roles='Instructor,urn:lti:instrole:ims/lis/Administrator',
                    context_id='lti_launch_context_id',
                    user_id='LTI_User', extra_params={
                        'lis_result_sourcedid': 'test_sourcedid',
                        'lis_outcome_service_url': 'test_url',
                        'tool_consumer_instance_guid': 'test_guid'
                    }
                )
            )
        )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_launch_request takes an extra_post_data if that is blank then no extra params will be added and extra_params will be empty as it is in the reviewed code.

Comment thread requirements/edx/base.txt
openedx-django-wiki==2.1.0
# via -r requirements/edx/kernel.in
openedx-events==10.2.0
openedx-events @ git+https://github.com/open-craft/openedx-events.git@kshitij/lti-launch-event

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change pins openedx-events to a specific branch. While this is fine for development, it's important to ensure this is updated to a released version before merging to a stable branch or for a release. This ensures that the platform is using stable, tested code and not code that is still under development.

openedx-events==10.2.0

xmlsec==1.3.14
social-auth-core==4.5.4

openedx-events @ git+https://github.com/open-craft/openedx-events.git@kshitij/lti-launch-event

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change pins openedx-events to a specific branch. While this is fine for development, it's important to ensure this is updated to a released version before merging to a stable branch or for a release. This ensures that the platform is using stable, tested code and not code that is still under development.

openedx-events==10.2.0

# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
openedx-events==10.2.0
openedx-events @ git+https://github.com/open-craft/openedx-events.git@kshitij/lti-launch-event

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change pins openedx-events to a specific branch. While this is fine for development, it's important to ensure this is updated to a released version before merging to a stable branch or for a release. This ensures that the platform is using stable, tested code and not code that is still under development.

openedx-events==10.2.0

Comment thread requirements/edx/doc.txt
openedx-django-wiki==2.1.0
# via -r requirements/edx/base.txt
openedx-events==10.2.0
openedx-events @ git+https://github.com/open-craft/openedx-events.git@kshitij/lti-launch-event

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change pins openedx-events to a specific branch. While this is fine for development, it's important to ensure this is updated to a released version before merging to a stable branch or for a release. This ensures that the platform is using stable, tested code and not code that is still under development.

openedx-events==10.2.0

openedx-django-wiki==2.1.0
# via -r requirements/edx/base.txt
openedx-events==10.2.0
openedx-events @ git+https://github.com/open-craft/openedx-events.git@kshitij/lti-launch-event

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change pins openedx-events to a specific branch. While this is fine for development, it's important to ensure this is updated to a released version before merging to a stable branch or for a release. This ensures that the platform is using stable, tested code and not code that is still under development.

openedx-events==10.2.0

@xitij2000 xitij2000 marked this pull request as ready for review June 3, 2025 10:02
@pdpinch

pdpinch commented Jun 12, 2025

Copy link
Copy Markdown
Member

@xitij2000 we'd prefer to get this code from upstream. Have you opened a backport to Teak with this?

@xitij2000

Copy link
Copy Markdown
Author

@pdpinch I'm not sure I understand. Are you asking if there is a PR to backport it to the upstream teak branch? If so, there isn't one, and I'm not sure if there should be once since this is a new feature.

The upstream PR against the master branch is here: openedx#36756

@pdpinch pdpinch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to leave you hanging @xitij2000. It makes sense that this wouldn't be back-ported upstream.

I'll approve so we can deploy to Residential MITx from the future.

@pdpinch pdpinch merged commit 20352da into mitodl:mitx/teak Aug 11, 2025
@xitij2000 xitij2000 deleted the kshitij/lti-launch-event.mitx.teak branch August 22, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants