|
1 | 1 | from .mixins import HelpLinkMixin, ResourceManagementViewMixin, MustBeInstructorMixin, MustHaveExamMixin, INSTRUCTOR_ROLES, lti_role_or_superuser_required, reverse_with_lti |
2 | 2 | from .generic import CreateFileReportView, JSONView |
3 | 3 | from numbas_lti import forms, save_scorm_data, tasks |
| 4 | +from numbas_lti.exceptions import LineItemDoesNotExist |
4 | 5 | from numbas_lti.models import \ |
5 | 6 | Resource, LTI_13_ResourceLink, AccessToken, Exam, Attempt, \ |
6 | 7 | ReportProcess, DiscountPart, EditorLink, COMPLETION_STATUSES, \ |
|
25 | 26 | from django.views import generic |
26 | 27 | from django_auth_lti.decorators import lti_role_required |
27 | 28 | from pathlib import Path |
| 29 | +from pylti1p3.exception import LtiException |
28 | 30 | import csv |
29 | 31 | import datetime |
30 | 32 | import json |
@@ -289,19 +291,27 @@ def summarise_student(student): |
289 | 291 | 'access_tokens': AccessToken.objects.filter(user=student,resource=resource).count(), |
290 | 292 | } |
291 | 293 |
|
292 | | - message_launch = self.get_message_launch() |
293 | | - if message_launch: |
294 | | - is_lti_13 = context['is_lti_13'] = True |
295 | | - else: |
296 | | - is_lti_13 = context['is_lti_13'] = False |
| 294 | + is_lti_13 = False |
| 295 | + try: |
| 296 | + message_launch = self.get_message_launch() |
| 297 | + if message_launch: |
| 298 | + is_lti_13 = True |
| 299 | + except LtiException: |
| 300 | + pass |
| 301 | + |
| 302 | + context['is_lti_13'] = is_lti_13 |
297 | 303 |
|
298 | 304 | extra_students = [] |
299 | 305 | ags_grades = None |
300 | 306 | lti_context = resource.lti_13_contexts().first() |
301 | 307 | if lti_context: |
302 | 308 | ags = lti_context.get_ags() |
303 | | - lineitem = resource.get_lti_13_lineitem() |
304 | | - ags_grades = context['grades'] = ags.get_grades(lineitem) |
| 309 | + try: |
| 310 | + lineitem = resource.get_lti_13_lineitem() |
| 311 | + ags_grades = context['grades'] = ags.get_grades(lineitem) |
| 312 | + except LineItemDoesNotExist: |
| 313 | + pass |
| 314 | + |
305 | 315 | nrps_members = [m for m in lti_context.nrps_members() if m['student']] |
306 | 316 | if nrps_members: |
307 | 317 | got_ids = [s for student in students for s in student.lti_13_aliases.all().values_list('sub', flat=True)] |
|
0 commit comments