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-1201: Filter courses in DeepLinkingForm #36

Merged
merged 1 commit into from
May 23, 2024
Merged

Conversation

kuipumu
Copy link
Contributor

@kuipumu kuipumu commented May 22, 2024

Ticket

https://agile-jira.pearson.com/browse/PADV-1201

Description

This PR adds a filter to the courses available on the DeepLinkingForm. This PR adds a DeepLinkingForm method that either returns all CourseContext objects with all courses on the LMS or a filtered CourseContext queryset with only the courses available per LtiTool using the CourseAccesConfiguration allowed_course_ids field.

Type of Change

  • Add get_course_contexts method to DeepLinkingForm Django form.
  • Modify get_content_items_choices method in the DeepLinkingForm Django form.
  • Add or modify all tests related to this code.

Testing:

  • Run the LMS: make dev.up.lms.
  • Install openedx_lti_tool_plugin on the LMS.
  • Run ngrok or any other similar service on LMS: ngrok http 18000
  • Add required settings to LMS.
# Enable LTI Tool Provider Plugin.
OLTITP_ENABLE_LTI_TOOL = True
Issuer: https://saltire.lti.app/platform
Client id: saltire.lti.app
Auth login: url: https://saltire.lti.app/platform/auth
Auth token url: https://saltire.lti.app/platform/token/sda42bb0cf2352259a367a404d48d54e8
Key set url: https://saltire.lti.app/platform/jwks/sda42bb0cf2352259a367a404d48d54e8
Deployment ids: ["cLWwj9cbmkSrCNsckEFBmA"]
Message URL: https://lms-dstack.kuje.net.eu.org/openedx_lti_tool_plugin/1.3/deep_linking/
Initiate login URL: https://lms.ngrok.io/openedx_lti_tool_plugin/1.3/login
Redirection URI(s): https://lms-dstack.kuje.net.eu.org/openedx_lti_tool_plugin/1.3/deep_linking/
Public keyset URL: https://lms.ngrok.io/openedx_lti_tool_plugin/1.3/pub/jwks
  • Go to "Message" on the left sidebar and set these settings:
Message type: LtiDeepLinkingRequest
  • Click on the "Save" button on the top navbar.
  • Click on the dropdown next to the "Connect" button on the top navbar.
  • Click on "Open in new window".
  • You should be presented with a form with only the courses that where added to the course access configuration "Allowed Course IDs" field.
  • Select one or more courses from the deep linking UI form.
  • Click on the "Submit" button.
  • The browser should be redirected back to saLTIre,
  • The "Sumary" section should show "Verification: Passed" and the "JWT" section should contain the requested courses on the "https://purl.imsglobal.org/spec/lti-dl/claim/content_items" key.

@kuipumu kuipumu requested review from anfbermudezme and alexjmpb May 22, 2024 13:49
@kuipumu kuipumu self-assigned this May 22, 2024
@kuipumu kuipumu changed the base branch from vue/PADV-1191 to main May 22, 2024 15:52
Returns:
List of tuples with choices for the `content_items` field.

"""
return [
self.get_content_items_choice(course, request)
for course in course_context().objects.all()
self.get_content_items_choice(course)
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Same question of the last PR review, Is it necessary that the return of the function be a list? I mention it because of the performance where for example, searching through 100,000 items takes 49.663 seconds with a list, but only 0.007 seconds with a set, taking into account that there are no repeated values in this array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anfbermudezme I didn't tried with a set since the Django documentation specifies the choices field to be a list of tuples, however it works with a set so I change this.

validate_deep_linking_message(message)

# Redirect to DeepLinkingForm view.
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Add blank line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anfbermudezme I don't think is necessary to add a blank line


# Get identity claims from launch data.
iss, aud, _sub, _pii = get_identity_claims(message.get_launch_data())
# Render form template.
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Add blank line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anfbermudezme I don't think is necessary to add a blank line

openedx_lti_tool_plugin/deep_linking/views.py Outdated Show resolved Hide resolved
@@ -99,8 +99,12 @@ def post(
_('Message type is not LtiResourceLinkRequest.'),
)
# Get launch data.
# TODO: Replace redundant get_launch_data method with
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu There are already tickets for these TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anfbermudezme Just created PADV-1338 so there is also a reference on the backlog for these TODOs.

launch_data: Launch data dictionary.

Returns:
A tuple containing the `iss`, `aud`, `sub` and PII claims.
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Add the reference of PII in the docstring please.

@kuipumu kuipumu merged commit 456a76a into main May 23, 2024
6 checks passed
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