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-1191: Add DeepLinkingForm to DeepLinkingView. #35

Merged
merged 1 commit into from
May 22, 2024
Merged

Conversation

kuipumu
Copy link
Contributor

@kuipumu kuipumu commented May 16, 2024

Ticket

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

Description

This PR add the DeepLinkingForm to the DeepLinkingFormView that was created on the PR for PADV-1190. This PR handles the second and third step on the Deep Linking UI process.

Type of Change

  • Add deep_linking/forms.py module.
  • Add learning_sequences edxapp_wrapper backend.
  • Add DeepLinkingForm Django form.
  • Add DeepLinkingForm to DeepLinkingFormView Django view logic.
  • 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.ngrok.io/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.ngrok.io/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".
  • 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 16, 2024 21:03
@@ -0,0 +1,8 @@
"""learning_sequences module backend (olive v1)."""
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Why is this olive v1?

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 This is following the same formula from previously defined edx_wrapper backends, which was also done following the structure from course_operations. I'm not sure what could be done to improve this but the (olive v1) comment is just to make clear that the o_v1 suffix on the module name refers to Olive and that this is the v1 of such backend.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Understood I thought that was the last stable version of olive https://github.com/openedx/edx-platform/tree/open-release/olive.4.

@patch.object(DeepLinkingForm, '__init__', return_value=None)
def test_get_deep_link_resources(
self,
deep_linking_form_init: MagicMock, # pylint: disable=W0613
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Please use the explicit pylint title.

Suggested change
deep_linking_form_init: MagicMock, # pylint: disable=W0613
deep_linking_form_init: MagicMock, # pylint: disable=unused-argument

@patch.object(DeepLinkingForm, '__init__', return_value=None)
def test_get_content_items_choice(
self,
deep_linking_form_init: MagicMock, # pylint: disable=W0613
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Please use the explicit pylint title.

@patch.object(DeepLinkingForm, '__init__', return_value=None)
def test_get_content_items_choices(
self,
deep_linking_form_init: MagicMock, # pylint: disable=W0613
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu Please use the explicit pylint title.

List of DeepLinkResource objects or an empty list

"""
return [
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuipumu It is necessary to use a list, what would happen if a set were used?

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 It will work the same, the return just needs to be iterable, I will change it to a set since avoids having multiple occurrences and we don't care about order in this case, however both a list or a set will work in this case

anfbermudezme
anfbermudezme previously approved these changes May 21, 2024
"""
return [
self.get_content_items_choice(course, request)
for course in course_context().objects.all()
Copy link
Contributor

Choose a reason for hiding this comment

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

This query can become pretty big, do you think it is worth to implement a more robust field? One that has a search option and progressive loading? or maybe only retrieve the courses which are specified in a site configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexjmpb Right now there is this other PR that will separate the queryset into another method of this form: #36

I do think we need to come up with a more robust way to handle this form since there seems to be the future requirement to filter per institutions, licenses or even select unit or components, I'm thinking on using a more dynamic form using a JSONField and a custom form template, I'm still not sure of what will be the UI requirements so for now I think is OK to handle it has we are doing on #36.

What do you think?, do you have any resources that could be useful to create a more dynamic form?.

Copy link
Contributor

Choose a reason for hiding this comment

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

No I was worried of not applying a filter on this since it would query all the courses in prod. But #36 does the job, maybe it's worth discussing later if a select field with a search bar can be implemented.

@kuipumu kuipumu merged commit 234bf29 into main May 22, 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