Skip to content

Commit

Permalink
Add LTI session id to parameters sent to ACOS
Browse files Browse the repository at this point in the history
  • Loading branch information
murhum1 committed Dec 18, 2023
1 parent 62e17e0 commit 407edb2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions exercise/async_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def _post_async_submission(request, exercise, submission, errors=None):
if (form.cleaned_data["lti_launch_id"]
and submission.meta_data.get("lti-launch-id") is None):
submission.meta_data["lti-launch-id"] = form.cleaned_data["lti_launch_id"]
if (form.cleaned_data["lti_session_id"]
and submission.meta_data.get("lti-session-id") is None):
submission.meta_data["lti-session-id"] = form.cleaned_data["lti_session_id"]

if form.cleaned_data["error"]:
submission.set_error()
Expand Down
8 changes: 6 additions & 2 deletions exercise/exercise_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,8 @@ def get_load_url( # pylint: disable=too-many-arguments
)
return self._build_service_url(
language, students,
ordinal, url_name, submission_url, lti_launch_id=request.session.get("lti-launch-id")
ordinal, url_name, submission_url, lti_launch_id=request.session.get("lti-launch-id"),
lti_session_id=request.COOKIES.get("lti1p3-session-id")
)
return super().get_load_url(language, request, students, url_name, ordinal)

Expand Down Expand Up @@ -1084,7 +1085,8 @@ def modify_post_parameters(self, data, files, user, students, request, url): # p
"""

# pylint: disable-next=too-many-arguments
def _build_service_url(self, language, students, ordinal_number, url_name, submission_url, lti_launch_id=None):
def _build_service_url(self, language, students, ordinal_number, url_name, submission_url,
lti_launch_id=None, lti_session_id=None):
"""
Generates complete URL with added parameters to the exercise service.
"""
Expand All @@ -1100,6 +1102,8 @@ def _build_service_url(self, language, students, ordinal_number, url_name, submi
}
if lti_launch_id:
params["lti_launch_id"] = lti_launch_id
if lti_session_id:
params["lti_session_id"] = lti_session_id
return update_url_params(self.get_service_url(language), params)

@property
Expand Down
1 change: 1 addition & 0 deletions exercise/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SubmissionCallbackForm(forms.Form):
notify = forms.CharField(required=False)
grading_payload = forms.CharField(required=False)
lti_launch_id = forms.CharField(required=False)
lti_session_id = forms.CharField(required=False)
error = forms.BooleanField(required=False)

def clean(self):
Expand Down

0 comments on commit 407edb2

Please sign in to comment.