fix: [AA-1106] completed status for unreleased (#29408)
Modify get_course_assignments so it does not mark unreleased content as completed Add unit test
This commit is contained in:
@@ -570,8 +570,10 @@ def get_course_assignments(course_key, user, include_access=False): # lint-amne
|
||||
assignment_released = not start or start < now
|
||||
if assignment_released:
|
||||
url = reverse('jump_to', args=[course_key, subsection_key])
|
||||
complete = is_block_structure_complete_for_assignments(block_data, subsection_key)
|
||||
else:
|
||||
complete = False
|
||||
|
||||
complete = is_block_structure_complete_for_assignments(block_data, subsection_key)
|
||||
past_due = not complete and due < now
|
||||
assignments.append(_Assignment(
|
||||
subsection_key, title, url, due, contains_gated_content,
|
||||
|
||||
@@ -432,7 +432,8 @@ class TestGetCourseAssignments(CompletionWaffleTestMixin, ModuleStoreTestCase):
|
||||
Test that we treat a sequential with incomplete (but not scored) items (like a video maybe) as complete.
|
||||
"""
|
||||
course = CourseFactory()
|
||||
chapter = ItemFactory(parent=course, category='chapter', graded=True, due=datetime.datetime.now())
|
||||
chapter = ItemFactory(parent=course, category='chapter', graded=True, due=datetime.datetime.now(),
|
||||
start=datetime.datetime.now() - datetime.timedelta(hours=1))
|
||||
sequential = ItemFactory(parent=chapter, category='sequential')
|
||||
problem = ItemFactory(parent=sequential, category='problem', has_score=True)
|
||||
ItemFactory(parent=sequential, category='video', has_score=False)
|
||||
@@ -457,3 +458,22 @@ class TestGetCourseAssignments(CompletionWaffleTestMixin, ModuleStoreTestCase):
|
||||
assignments = get_course_assignments(course.location.context_key, self.user, None)
|
||||
assert len(assignments) == 1
|
||||
assert not assignments[0].complete
|
||||
|
||||
def test_completion_does_not_treat_unreleased_as_complete(self):
|
||||
"""
|
||||
Test that unreleased assignments are not treated as complete.
|
||||
"""
|
||||
course = CourseFactory()
|
||||
chapter = ItemFactory(parent=course, category='chapter', graded=True,
|
||||
due=datetime.datetime.now() + datetime.timedelta(hours=2),
|
||||
start=datetime.datetime.now() + datetime.timedelta(hours=1))
|
||||
sequential = ItemFactory(parent=chapter, category='sequential')
|
||||
problem = ItemFactory(parent=sequential, category='problem', has_score=True)
|
||||
ItemFactory(parent=sequential, category='video', has_score=False)
|
||||
|
||||
self.override_waffle_switch(True)
|
||||
BlockCompletion.objects.submit_completion(self.user, problem.location, 1)
|
||||
|
||||
assignments = get_course_assignments(course.location.context_key, self.user, None)
|
||||
assert len(assignments) == 1
|
||||
assert not assignments[0].complete
|
||||
|
||||
Reference in New Issue
Block a user