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

Move Canvas assignments into the DB #2527

Closed
marcospri opened this issue Mar 29, 2021 · 1 comment · Fixed by #3118 or #3126
Closed

Move Canvas assignments into the DB #2527

marcospri opened this issue Mar 29, 2021 · 1 comment · Fixed by #3118 or #3126
Assignees
Labels

Comments

@marcospri
Copy link
Member

marcospri commented Mar 29, 2021

Canva's assignments currently store all their configuration on the LTI launch URL as query params.

Follow the same pattern as other's LMS assignments and create/update/upsert a row in ModuleItemConfiguration per assignment.

This might be partially achieved by: #2769

@seanh seanh added the Backend label May 10, 2021
@marcospri marcospri changed the title Move Canvas assignments into DB Move Canvas assignments into the DB May 14, 2021
@seanh
Copy link
Collaborator

seanh commented Jun 2, 2021

Unlike in non-Canvas LMS's, in Canvas at the time when the user is creating an assignment and they select the assignment's document there is no LTI assignment ID (resource_link_id) yet. We therefore cannot use the resource_link_id as the ID for the assignment's config in our DB. For non-Canvas LMS's we currently do use the resource_link_id as the ID for looking up the assignment's configuration in the DB:

resource_link_id = sa.Column(sa.String, nullable=False)
"""The resource_link_id launch param of the module item or assignment."""
but we won't be able to do that for Canvas assignments.

Instead we are going to have to generate our own unique ID for the assignment and save that both in the DB and in the LTI launch params. We will have to submit a launch URL like this to Canvas: https://lms.hypothes.is/lti_launches?hypothesis_assignment_id=<ID>. When we receive an LTI launch we read the hypothesis_assignment_id from the query params and use it to look up the ModuleItemConfiguration in the DB and find the assignment's configuration (e.g. its document URL).

So this means that we have to both:

  1. Make an API call to our own backend to create a new ModuleItemConfiguration in the DB. This API call should return a new hypothesis_assignment_id
  2. Still submit an LTI launch URL to Canvas like we currently do. But instead of having the actual assignment configuration in the query params, it's just going to have the hypothesis_assignment_id

We better namespace the query param name (hypothesis_*) so it doesn't clash with any current or future Canvas launch params.

The first time an assignment is launched (after having been created) we do receive the resource_link_id param, as well as our hypothesis_assignment_id. At this point we need to record the resource_link_id in the ModuleItemConfiguration in our DB, forever associating this resource_link_id and hypothesis_assignment_id with each other.

This is crucial for course copy. When a user copies a Canvas course all the Hypothesis assignments get copied into the new course and the new copies of the assignments get new resource_link_id's. Given that the resource_link_id's have changed, if we were using the resource_link_id to look up the assignment's configuration in our DB we would not find it. AFAIK Canvas does not provide any way (e.g. in the launch params) for us to find the resource_link_id of the original assignment or even to know that the assignment was copied.

Fortunately the assignment's launch URL gets copied into the new assignment un-modified, complete with ?hypothesis_assignment_id=<ID> query param. So we can use the hypothesis_assignment_id to find the ModuleItemConfiguration. We can then look at the ModuleItemConfiguration's resource_link_id and, if it differs from the resource_link_id in the launch params then we know we're seeing a copied assignment and we need to make a new copy of the ModuleItemConfiguration in our DB.

Slack thread: https://hypothes-is.slack.com/archives/C4K6M7P5E/p1621249716149100?thread_ts=1620901832.105300&cid=C4K6M7P5E

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants