Skip to content

Commit 16ec12e

Browse files
fix: Address Copilot feedback
1 parent d845ded commit 16ec12e

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

lms/djangoapps/instructor/tests/views/test_special_exams_api_v2.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@ def test_list_attempts_filters_by_exam(self):
282282
assert data['count'] == 1
283283
assert data['results'][0]['exam_id'] == exam_id
284284

285+
def test_ready_to_resume_true(self):
286+
"""Verify ready_to_resume reflects the actual attempt state."""
287+
exam_id = self._create_exam()
288+
attempt_id = create_exam_attempt(exam_id, self.student.id)
289+
attempt = ProctoredExamStudentAttempt.objects.get(id=attempt_id)
290+
attempt.ready_to_resume = True
291+
attempt.save()
292+
293+
response = self.client.get(self._url(exam_id))
294+
assert response.status_code == status.HTTP_200_OK
295+
assert response.json()['results'][0]['ready_to_resume'] is True
296+
285297

286298
@override_settings(**PROCTORING_SETTINGS)
287299
@patch.dict(settings.FEATURES, {'ENABLE_SPECIAL_EXAMS': True})
@@ -754,3 +766,14 @@ def test_sort_attempts_descending(self):
754766
results = response.json()['results']
755767
assert results[0]['user']['username'] == 'student2'
756768
assert results[1]['user']['username'] == 'student1'
769+
770+
def test_ready_to_resume_true(self):
771+
"""Verify ready_to_resume reflects the actual attempt state."""
772+
attempt_id = create_exam_attempt(self.exam_id, self.student.id)
773+
attempt = ProctoredExamStudentAttempt.objects.get(id=attempt_id)
774+
attempt.ready_to_resume = True
775+
attempt.save()
776+
777+
response = self.client.get(self._url())
778+
assert response.status_code == status.HTTP_200_OK
779+
assert response.json()['results'][0]['ready_to_resume'] is True

lms/djangoapps/instructor/views/serializers_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ class ExamAttemptSerializer(serializers.Serializer):
12301230
start_time = serializers.DateTimeField(source='started_at', allow_null=True, required=False)
12311231
end_time = serializers.DateTimeField(source='completed_at', allow_null=True, required=False)
12321232
allowed_time_limit_mins = serializers.IntegerField(allow_null=True, required=False)
1233-
ready_to_resume = serializers.BooleanField(default=False)
1233+
ready_to_resume = serializers.BooleanField()
12341234

12351235
def get_exam_type(self, obj):
12361236
"""Derive exam type from proctored_exam flags."""

0 commit comments

Comments
 (0)