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

Embed annotation object in a Canvas page #150

Merged
merged 6 commits into from
Jul 29, 2021

Conversation

arthurian
Copy link
Contributor

@arthurian arthurian commented Jun 22, 2021

This PR provides instructors with a way to embed/insert an annotation assignment object in a Canvas page using the rich content editor. This is something that we know GSE courses have attempted to do in the past manually. Here's a brief demo of how the functionality works.

Changes:

  • Added XML config to enable a button in the WYSIWYG editor (examples), that when clicked, triggers an LTI ContentItemSelectionRequest.
  • Updated middleware.py to validate a ContentItemSelectionRequest message which is similar to an LTI launch message. This triggers the LTI Content Item Selection Request Workflow (spec).
  • Created views embed_lti and embed_lti_response that allow the user to select an annotation object and insert it as an LTI link in the content.
  • Created forms EmbedLtiSelectionForm and EmbedLtiResponseForm to support the selection of content items and the oauth-signed POST back to the LMS with the selected item.
  • Updated LTI launch view to accept collection_id and object_id as custom GET parameters in addition to POST parameters, which will route directly to the annotation view.

Limitations:

  • The course and admin user must already exist in the DB. If they don't, the user will get a message saying they need to login to the tool first (e.g. via the course navigation). This can/should be improved later, but will require refactoring some logic that is tightly woven into the launch_lti view.
  • When the tool is embedded on a page,resource_link_id == context_id where context_id is the course-level identifier. This means we can't use the starting resource configuration method of routing learners to a particular assignment object like we do with module items, but instead must pass the assignment and target IDs directly as parameters (collection_id and object_id).
  • There can only be a single tool embedded on a page, otherwise there are issues with websocket messages. Even though the notifications app identifies websocket channels using a combination of (context_id,collection_id,object_id), the middleware checks these values against the session, which assumes the resource_link_id has partitioned the sessions, except it hasn't in this context. So this can result in 403 responses.

To test in Canvas:

  1. Install the tool with the updated XML config that enables the RCE (editor button) functionality.
  2. Add at least one annotation assignment with a text, video, or image object.
  3. When editing the Canvas page, click on the "plug" icon on the toolbar, and then select "Add from AnntoationsX". This should then launch the embed workflow.

@lduarte1991 @nmaekawa Let me know if you want to walk through this together since this is a large PR.

This adds a simple interface to select an existing assignment object and
embed it on the page. The assumption is that the admin has already
created the assignment through the admin hub.

For a single content item embedded on a page, this seems to work well
enough, but it does not work for multiple content items. The problem is
that the resource_link_id is not unique in this context, but live
updates (websockets) and other parts of the app assume that it is.
@lduarte1991
Copy link
Owner

@arthurian : This one I think would definitely require us sitting down together and walking through it. At the same time, this does not look like something we would be using at all on our end, so I don't think there would be a problem merging it from your end if we can't get a meeting set up before your cut-off date.

@lduarte1991 lduarte1991 merged commit c07bcc3 into lduarte1991:master Jul 29, 2021
@arthurian arthurian deleted the editor_button branch July 29, 2021 20:44
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.

2 participants