fix: register exams without due date or course end date (#34421)
This commit is contained in:
@@ -71,6 +71,8 @@ def register_exams(course_key):
|
||||
timed_exam.is_onboarding_exam
|
||||
)
|
||||
|
||||
due_date = timed_exam.due.isoformat() if timed_exam.due else (course.end.isoformat() if course.end else None)
|
||||
|
||||
exams_list.append({
|
||||
'course_id': str(course_key),
|
||||
'content_id': str(timed_exam.location),
|
||||
@@ -83,7 +85,7 @@ def register_exams(course_key):
|
||||
# exam service. Also note that we no longer consider the pacing type of the course - this applies to both
|
||||
# self-paced and indstructor-paced courses. Therefore, this effectively opts out exams powered by edx-exams
|
||||
# from personalized learner schedules/relative dates.
|
||||
'due_date': timed_exam.due.isoformat() if timed_exam.due else course.end.isoformat(),
|
||||
'due_date': due_date,
|
||||
'exam_type': exam_type,
|
||||
'is_active': True,
|
||||
'hide_after_due': timed_exam.hide_after_due,
|
||||
|
||||
@@ -147,15 +147,21 @@ class TestExamService(ModuleStoreTestCase):
|
||||
listen_for_course_publish(self, self.course.id)
|
||||
mock_patch_course_exams.assert_not_called()
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_no_due_dates(self, is_self_paced, mock_patch_course_exams):
|
||||
# MODIFY DUE DATE HERE
|
||||
@ddt.data(
|
||||
(True, datetime(2035, 1, 1, 0, 0, tzinfo=timezone.utc)),
|
||||
(False, datetime(2035, 1, 1, 0, 0, tzinfo=timezone.utc)),
|
||||
(True, None),
|
||||
(False, None),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_no_due_dates(self, is_self_paced, course_end_date, mock_patch_course_exams):
|
||||
"""
|
||||
Test that the coures end date is registered as the due date when the subsection does not have a due date for
|
||||
both self-paced and instructor-paced exams.
|
||||
"""
|
||||
self.course.self_paced = is_self_paced
|
||||
end_date = datetime(2035, 1, 1, 0, 0, tzinfo=timezone.utc)
|
||||
self.course.end = end_date
|
||||
self.course.end = course_end_date
|
||||
self.course = self.update_course(self.course, 1)
|
||||
BlockFactory.create(
|
||||
parent=self.chapter,
|
||||
@@ -173,7 +179,7 @@ class TestExamService(ModuleStoreTestCase):
|
||||
|
||||
listen_for_course_publish(self, self.course.id)
|
||||
called_exams, called_course = mock_patch_course_exams.call_args[0]
|
||||
assert called_exams[0]['due_date'] == end_date.isoformat()
|
||||
assert called_exams[0]['due_date'] == (course_end_date.isoformat() if course_end_date else None)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_subsection_due_date_prioritized(self, is_self_paced, mock_patch_course_exams):
|
||||
|
||||
Reference in New Issue
Block a user