openedx / xblock-lti-consumer

GNU Affero General Public License v3.0
28 stars 81 forks source link

Add course flag to send external_user_id as user_id in LTI 1.1 XBlock launches #307

Closed MichaelRoytman closed 1 year ago

MichaelRoytman commented 1 year ago

Description:

JIRA: MST-1717

This commit introduces a new CourseWaffleFlag lti_consumer.enable_external_user_id_1p1_launches. When this flag is enabled for a course, LTI 1.1 XBlock launches in that course will send the user's external_user_id as the user_id attribute of the launch. external_user_id is the user's external user ID as defined, created, and stored by the external_user_ids Djangoapp in the edx-platform. When this waffle is not enabled for a course - the default case - LTI 1.1 XBlock launches in that course will continue to send the user's anonymous_user_id as the user_id attribute of the launch, as before.

This provides an opt-in opportunity for courses to send a consistent, static, and opaque user identifier in an LTI 1.1 XBlock launch. This may be necessary for integration with LTI tools that require such an identifier.

Please be aware that toggling this flag in a running course carries the risk of breaking the LTI integrations in the course. This flag should also only be enabled for new courses in which no LTI attempts have been made.

Verification:

This change was manually tested using the testing instructions in the README via an integration with the saLTIre testing tool. Please see the screenshots below. They show two courses to demonstrate that, after the change, the user_id is the same.

Before Change, Course 1:

before-course-1

Before Change, Course 2:

before-course-2

After Change, Course 1:

after-course-1

After Change, Course 2:

after-course-2

Testing:

In order to test these changes, follow these steps.

  1. Set up an LTI 1.1 integration in Studio by following the steps in the README: https://github.com/openedx/xblock-lti-consumer#lti-11.
  2. In the Django admin, add a CourseWaffleFlag in django-waffle > Flags. Name: lti_consumer.enable_external_user_id_1p1_launches Leave the remaining fields as the default.
  3. In the Django admin, add a CourseWaffleFlag override in Waffle_Utils › Waffle flag course overrides. Waffle flag: lti_consumer.enable_external_user_id_1p1_launches Course id: Override choice: Force On Enabled:
  4. As a non-superuser, load the LTI component in the LMS and observe the user_id attribute in the Message Parameters section.
codecov[bot] commented 1 year ago

Codecov Report

Base: 97.79% // Head: 97.78% // Decreases project coverage by -0.00% :warning:

Coverage data is based on head (cff7744) compared to base (9c04004). Patch coverage: 93.54% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #307 +/- ## ========================================== - Coverage 97.79% 97.78% -0.01% ========================================== Files 72 72 Lines 5843 5870 +27 ========================================== + Hits 5714 5740 +26 - Misses 129 130 +1 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `97.78% <93.54%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/openedx/xblock-lti-consumer/pull/307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx) | Coverage Δ | | |---|---|---| | [lti\_consumer/plugin/compat.py](https://codecov.io/gh/openedx/xblock-lti-consumer/pull/307/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx#diff-bHRpX2NvbnN1bWVyL3BsdWdpbi9jb21wYXQucHk=) | `74.07% <50.00%> (-4.19%)` | :arrow_down: | | [lti\_consumer/lti\_xblock.py](https://codecov.io/gh/openedx/xblock-lti-consumer/pull/307/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx#diff-bHRpX2NvbnN1bWVyL2x0aV94YmxvY2sucHk=) | `95.64% <100.00%> (+0.27%)` | :arrow_up: | | [lti\_consumer/tests/unit/test\_lti\_xblock.py](https://codecov.io/gh/openedx/xblock-lti-consumer/pull/307/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx#diff-bHRpX2NvbnN1bWVyL3Rlc3RzL3VuaXQvdGVzdF9sdGlfeGJsb2NrLnB5) | `99.12% <100.00%> (+0.01%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.