Skip to content

Commit 5b043a3

Browse files
fix: Add exam_name and ready_to_resume to Inst Dash Special Exams tab (#38505)
1 parent 25bb919 commit 5b043a3

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

lms/djangoapps/instructor/docs/references/instructor-v2-special-exams-api-spec.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,11 @@ definitions:
488488
type: string
489489
exam_id:
490490
type: integer
491+
exam_name:
492+
type: string
493+
exam_type:
494+
type: string
495+
enum: [timed, proctored, practice]
491496
status:
492497
type: string
493498
start_time:
@@ -501,6 +506,8 @@ definitions:
501506
allowed_time_limit_mins:
502507
type: integer
503508
x-nullable: true
509+
ready_to_resume:
510+
type: boolean
504511

505512
ProctoringSettings:
506513
type: object

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ def test_attempt_exam_type(self, is_proctored, is_practice_exam, expected_type):
264264
data = response.json()
265265
assert data['count'] == 1
266266
assert data['results'][0]['exam_id'] == exam_id
267+
assert data['results'][0]['exam_name'] == 'Test Exam'
267268
assert data['results'][0]['exam_type'] == expected_type
269+
assert data['results'][0]['ready_to_resume'] is False
268270
assert data['results'][0]['user']['username'] == 'student1'
269271

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

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+
283297

284298
@override_settings(**PROCTORING_SETTINGS)
285299
@patch.dict(settings.FEATURES, {'ENABLE_SPECIAL_EXAMS': True})
@@ -682,6 +696,8 @@ def test_list_all_attempts(self):
682696
data = response.json()
683697
assert data['count'] == 1
684698
assert data['results'][0]['exam_id'] == self.exam_id
699+
assert data['results'][0]['exam_name'] == 'Midterm Exam'
700+
assert data['results'][0]['ready_to_resume'] is False
685701

686702
def test_search_attempts_by_username(self):
687703
create_exam_attempt(self.exam_id, self.student.id)
@@ -750,3 +766,14 @@ def test_sort_attempts_descending(self):
750766
results = response.json()['results']
751767
assert results[0]['user']['username'] == 'student2'
752768
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,13 @@ class ExamAttemptSerializer(serializers.Serializer):
12241224
id = serializers.IntegerField()
12251225
user = ExamAttemptUserSerializer()
12261226
exam_id = serializers.IntegerField(source='proctored_exam.id')
1227+
exam_name = serializers.CharField(source='proctored_exam.exam_name')
12271228
exam_type = serializers.SerializerMethodField()
12281229
status = serializers.CharField()
12291230
start_time = serializers.DateTimeField(source='started_at', allow_null=True, required=False)
12301231
end_time = serializers.DateTimeField(source='completed_at', allow_null=True, required=False)
12311232
allowed_time_limit_mins = serializers.IntegerField(allow_null=True, required=False)
1233+
ready_to_resume = serializers.BooleanField()
12321234

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

0 commit comments

Comments
 (0)