diff --git a/lms/djangoapps/course_blocks/transformers/library_content.py b/lms/djangoapps/course_blocks/transformers/library_content.py index b92b58dbebfeadb45cb85342810a37e5c8217d73..e566a1a0c73ccd1721bc383b51443a6c97450184 100644 --- a/lms/djangoapps/course_blocks/transformers/library_content.py +++ b/lms/djangoapps/course_blocks/transformers/library_content.py @@ -22,7 +22,7 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo blocks within a library_content module to which a user should not have access. - Staff users are *not* exempted from library content pathways. + Staff users are to exempted from library content pathways. """ WRITE_VERSION = 1 READ_VERSION = 1 @@ -123,8 +123,10 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo Return True if selected block should be removed. Block is removed if it is part of library_content, but has - not been selected for current user. + not been selected for current user, with staff as an exemption. """ + if usage_info.has_staff_access: + return False if block_key not in all_library_children: return False if block_key in all_selected_children: diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py b/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py index 3c4db113e97e5b0a230f116306aa43441fa697a6..44b0c1ea92771fede5cb02b70724ae423a0feda6 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_library_content.py @@ -164,3 +164,19 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase): ), u"Expected 'selected' equality failed in iteration {}.".format(i) ) + + def test_staff_access_to_library_content(self): + """ + To verify that staff member has access to all the library content blocks. + + Scenario: Given a staff member in a course with library content + when data is transformed by LibraryContentTransformer + none of the unassigned block is removed from the access list + and staff member will have access to all the blocks + """ + transformed_blocks = get_course_blocks( + self.staff, + self.course.location, + transformers=self.transformers + ) + self.assertEqual(len(list(transformed_blocks.get_block_keys())), len(self.blocks))