Skip to content

Commit fcbac72

Browse files
murhum1markkuriekkinen
authored andcommitted
Add LTI Tool grading for Acos server assignments
When the A+ LTI Tool v1.3 feature was added in v1.18, there was no support yet for the LTI grading of Acos server assignments. Now, those grades can be sent to the LTI Platform. Short description of the implementation: - When the A+ front retrieves the exercise description from the exercise service, the HTTP GET request includes an extra parameter `lti_launch_id` if the user's current session includes LTI parameters from an LTI v1.3 launch (to A+ as the LTI Tool). - The Aplus protocol at the Acos server (acos-server/acos-aplus#8) is modified so that it will store the LTI launch id parameter in the user's browser in a hidden HTML `<input>` element. - Acos server forwards the LTI launch parameter to the A+ front when the exercise submission is sent to the Acos server. - When A+ receives the graded submission from the Acos server, A+ stores the LTI launch id in the submission `meta_data` field. The LTI launch id is then used to send the grade to the LTI Platform. Fixes #1154
1 parent b36e145 commit fcbac72

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

exercise/async_views.py

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def _post_async_submission(request, exercise, submission, errors=None):
5252
submission.feedback = form.cleaned_data["feedback"]
5353
submission.grading_data = post_data
5454

55+
# Acos-submissions initialize this as an empty string for some reason; fix here
56+
if submission.meta_data == "":
57+
submission.meta_data = {}
58+
if form.cleaned_data["lti_launch_id"]:
59+
submission.meta_data["lti-launch-id"] = form.cleaned_data["lti_launch_id"]
60+
5561
if form.cleaned_data["error"]:
5662
submission.set_error()
5763
else:

exercise/exercise_models.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ def get_load_url(
955955
)
956956
return self._build_service_url(
957957
language, students,
958-
ordinal, url_name, submission_url
958+
ordinal, url_name, submission_url, lti_launch_id=request.session.get("lti-launch-id")
959959
)
960960
return super().get_load_url(language, request, students, url_name, ordinal)
961961

@@ -994,20 +994,23 @@ def modify_post_parameters(self, data, files, user, students, request, url):
994994
"""
995995
pass
996996

997-
def _build_service_url(self, language, students, ordinal_number, url_name, submission_url):
997+
def _build_service_url(self, language, students, ordinal_number, url_name, submission_url, lti_launch_id=None):
998998
"""
999999
Generates complete URL with added parameters to the exercise service.
10001000
"""
10011001
uid_str = '-'.join(sorted(str(profile.user.id) for profile in students)) if students else ''
1002-
return update_url_params(self.get_service_url(language), {
1002+
params = {
10031003
"max_points": self.max_points,
10041004
"max_submissions": self.max_submissions,
10051005
"submission_url": build_aplus_url(submission_url),
10061006
"post_url": build_aplus_url(str(self.get_url(url_name)), user_url=True),
10071007
"uid": uid_str,
10081008
"ordinal_number": ordinal_number,
10091009
"lang": language,
1010-
})
1010+
}
1011+
if lti_launch_id:
1012+
params["lti_launch_id"] = lti_launch_id
1013+
return update_url_params(self.get_service_url(language), params)
10111014

10121015
@property
10131016
def can_regrade(self):

exercise/forms.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class SubmissionCallbackForm(forms.Form):
2020
feedback = forms.CharField(required=False)
2121
notify = forms.CharField(required=False)
2222
grading_payload = forms.CharField(required=False)
23+
lti_launch_id = forms.CharField(required=False)
2324
error = forms.BooleanField(required=False)
2425

2526
def clean(self):

0 commit comments

Comments
 (0)