Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ definitions:
type: string
exam_id:
type: integer
exam_name:
type: string
exam_type:
type: string
enum: [timed, proctored, practice]
status:
type: string
start_time:
Expand All @@ -501,6 +506,8 @@ definitions:
allowed_time_limit_mins:
type: integer
x-nullable: true
ready_to_resume:
type: boolean

ProctoringSettings:
type: object
Expand Down
27 changes: 27 additions & 0 deletions lms/djangoapps/instructor/tests/views/test_special_exams_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ def test_attempt_exam_type(self, is_proctored, is_practice_exam, expected_type):
data = response.json()
assert data['count'] == 1
assert data['results'][0]['exam_id'] == exam_id
assert data['results'][0]['exam_name'] == 'Test Exam'
assert data['results'][0]['exam_type'] == expected_type
assert data['results'][0]['ready_to_resume'] is False
Comment thread
brianjbuck-wgu marked this conversation as resolved.
assert data['results'][0]['user']['username'] == 'student1'

def test_list_attempts_filters_by_exam(self):
Expand All @@ -280,6 +282,18 @@ def test_list_attempts_filters_by_exam(self):
assert data['count'] == 1
assert data['results'][0]['exam_id'] == exam_id

def test_ready_to_resume_true(self):
"""Verify ready_to_resume reflects the actual attempt state."""
exam_id = self._create_exam()
attempt_id = create_exam_attempt(exam_id, self.student.id)
attempt = ProctoredExamStudentAttempt.objects.get(id=attempt_id)
attempt.ready_to_resume = True
attempt.save()

response = self.client.get(self._url(exam_id))
assert response.status_code == status.HTTP_200_OK
assert response.json()['results'][0]['ready_to_resume'] is True


@override_settings(**PROCTORING_SETTINGS)
@patch.dict(settings.FEATURES, {'ENABLE_SPECIAL_EXAMS': True})
Expand Down Expand Up @@ -682,6 +696,8 @@ def test_list_all_attempts(self):
data = response.json()
assert data['count'] == 1
assert data['results'][0]['exam_id'] == self.exam_id
assert data['results'][0]['exam_name'] == 'Midterm Exam'
assert data['results'][0]['ready_to_resume'] is False
Comment thread
brianjbuck-wgu marked this conversation as resolved.

def test_search_attempts_by_username(self):
create_exam_attempt(self.exam_id, self.student.id)
Expand Down Expand Up @@ -750,3 +766,14 @@ def test_sort_attempts_descending(self):
results = response.json()['results']
assert results[0]['user']['username'] == 'student2'
assert results[1]['user']['username'] == 'student1'

def test_ready_to_resume_true(self):
"""Verify ready_to_resume reflects the actual attempt state."""
attempt_id = create_exam_attempt(self.exam_id, self.student.id)
attempt = ProctoredExamStudentAttempt.objects.get(id=attempt_id)
attempt.ready_to_resume = True
attempt.save()

response = self.client.get(self._url())
assert response.status_code == status.HTTP_200_OK
assert response.json()['results'][0]['ready_to_resume'] is True
2 changes: 2 additions & 0 deletions lms/djangoapps/instructor/views/serializers_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,13 @@ class ExamAttemptSerializer(serializers.Serializer):
id = serializers.IntegerField()
user = ExamAttemptUserSerializer()
exam_id = serializers.IntegerField(source='proctored_exam.id')
exam_name = serializers.CharField(source='proctored_exam.exam_name')
exam_type = serializers.SerializerMethodField()
status = serializers.CharField()
start_time = serializers.DateTimeField(source='started_at', allow_null=True, required=False)
end_time = serializers.DateTimeField(source='completed_at', allow_null=True, required=False)
allowed_time_limit_mins = serializers.IntegerField(allow_null=True, required=False)
ready_to_resume = serializers.BooleanField()

def get_exam_type(self, obj):
"""Derive exam type from proctored_exam flags."""
Expand Down
Loading