Skip to content

Commit db57e87

Browse files
committed
Attempt.get_end_time: cope with there being no suspend data
I think this case can happen when an attempt that was never begun is implicitly ended.
1 parent d679c69 commit db57e87

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

numbas_lti/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,8 +1402,9 @@ def get_end_time(self):
14021402
now = timezone.now()
14031403
resource = self.resource
14041404
# If the due date hasn't passed, or the student has since reopened the attempt, use the time of the last suspend data change, or the available_until, whichever is earliest
1405-
if self.student_has_reopened() or resource.due_date is None or now < resource.due_date:
1406-
return min(resource.available_until, self.scormelements.filter(remarked=None, key='cmi.suspend_data').first().time)
1405+
suspend_data_elements = self.scormelements.filter(remarked=None, key='cmi.suspend_data')
1406+
if (self.student_has_reopened() or resource.due_date is None or now < resource.due_date) and suspend_data_elements.exists():
1407+
return min(resource.available_until, suspend_data_elements.first().time)
14071408
# If the due date has passed, use that
14081409
elif resource.due_date is not None:
14091410
return resource.due_date

0 commit comments

Comments
 (0)