Allow staff to see all units when viewing the course outline.

This commit is contained in:
attiyaishaque
2018-03-14 17:23:58 +05:00
parent 4e82734cc2
commit b239d7b8d7
2 changed files with 11 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
"""
User Partitions Transformer
"""
from lms.djangoapps.courseware.access import has_access
from openedx.core.djangoapps.content.block_structure.transformer import (
BlockStructureTransformer,
FilteringTransformerMixin
@@ -70,19 +71,22 @@ class UserPartitionTransformer(FilteringTransformerMixin, BlockStructureTransfor
block_structure.set_transformer_block_field(block_key, cls, 'merged_group_access', merged_group_access)
def transform_block_filters(self, usage_info, block_structure):
user = usage_info.user
result_list = SplitTestTransformer().transform_block_filters(usage_info, block_structure)
user_partitions = block_structure.get_transformer_data(self, 'user_partitions')
if not user_partitions:
return [block_structure.create_universal_filter()]
user_groups = _get_user_partition_groups(
usage_info.course_key, user_partitions, usage_info.user
)
user_groups = _get_user_partition_groups(usage_info.course_key, user_partitions, user)
group_access_filter = block_structure.create_removal_filter(
lambda block_key: not block_structure.get_transformer_block_field(
block_key, self, 'merged_group_access'
).check_group_access(user_groups)
lambda block_key: not (
has_access(user, 'staff', block_key) or
block_structure.get_transformer_block_field(block_key, self, 'merged_group_access').check_group_access(
user_groups
)
)
)
result_list.append(group_access_filter)

View File

@@ -1041,7 +1041,7 @@ class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, In
{
'user': self.staff_user,
'enrollment_status': ENROLLED_IN_COURSE,
'grade': [u'0.0', u'Not Available', u'Not Available', u'Not Available', u'Not Available'],
'grade': [u'0.0', u'Not Attempted', u'2.0', u'Not Attempted', u'2.0'],
},
{
'user': self.alpha_user,