Skip to content

Commit

Permalink
Store the LTI1.3 version of the assignment ID when available
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Sep 2, 2024
1 parent 72ed26a commit cde9076
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lms/services/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ def get_assignment_for_launch(self, request, course: Course) -> Assignment | Non
)
)

# Set the value for the v13 id for this assignment.
assignment.lti_v13_resource_link_id = request.lti_params.v13.get(
"https://purl.imsglobal.org/spec/lti/claim/resource_link", {}
).get("id")

# Always update the assignment configuration
# It often will be the same one while launching the assignment again but
# it might for example be an updated deep linked URL or similar.
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ def pyramid_request(db_session, application_instance, lti_v11_params):
return pyramid_request


@pytest.fixture
def lti_v13_pyramid_request(pyramid_request, lti_v13_params, lti_v11_params):
pyramid_request.lti_jwt = "JWT"
pyramid_request.lti_params = LTIParams(v11=lti_v11_params, v13=lti_v13_params)

return pyramid_request


@pytest.fixture
def product(pyramid_request):
return pyramid_request.product
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/lms/services/assignment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ def test_get_assignment_for_launch_existing(
)
assert assignment.is_gradable == misc_plugin.is_assignment_gradable.return_value
assert assignment.course_id == course.id
assert (
assignment.lti_v13_resource_link_id
== pyramid_request.lti_params.v13.get("")
)

def test_get_assignment_for_launch_set_v13_context_id(
self, lti_v13_pyramid_request, svc, course
):
assignment = svc.get_assignment_for_launch(lti_v13_pyramid_request, course)

assert assignment.lti_v13_resource_link_id == "RESOURCE_LINK_ID"

def test_get_assignment_returns_None_with_when_no_document(
self, pyramid_request, svc, misc_plugin, course
Expand Down

0 comments on commit cde9076

Please sign in to comment.