Skip to content

Commit

Permalink
refactor: [AXIMST-676] change block type to 'lock' if it has a prereq…
Browse files Browse the repository at this point in the history
…uisite
  • Loading branch information
NiedielnitsevIvan committed Mar 21, 2024
1 parent 0af632a commit 4740faa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lms/djangoapps/course_home_api/outline/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def get_blocks(self, block): # pylint: disable=missing-function-docstring
description = block['special_exam_info'].get('short_description')
icon = block['special_exam_info'].get('suggested_icon', 'fa-pencil-square-o')

if self.context.get('display_block_prerequisite_icon', False) and block.get('accessible') is False:
icon = 'lock'
if self.context.get('enable_prerequisite_block_type', False) and block.get('accessible') is False:
block_type = 'lock'

serialized = {
block_key: {
Expand Down
6 changes: 3 additions & 3 deletions lms/djangoapps/course_home_api/outline/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@ def test_assignment(self):

exam_data = response.data['blocks'][str(self.sequential.location)]
assert exam_data['display_name'] == 'Test (1 Question)'
assert exam_data['icon'] == 'lock'
assert exam_data['icon'] == 'fa-pencil-square-o'
assert str(self.vertical.location) in exam_data['children']

ungraded_data = response.data['blocks'][str(self.ungraded_sequential.location)]
assert ungraded_data['display_name'] == 'Ungraded'
assert ungraded_data['icon'] == 'lock'
assert ungraded_data['icon'] is None
assert str(self.ungraded_vertical.location) in ungraded_data['children']

@override_waffle_flag(COURSE_ENABLE_UNENROLLED_ACCESS_FLAG, active=True)
Expand Down Expand Up @@ -669,7 +669,7 @@ def test_hide_learning_sequences(self):
assert response.status_code == 200

blocks = response.data['blocks']
seq_block_id = next(block_id for block_id, block in blocks.items() if block['type'] == 'sequential')
seq_block_id = next(block_id for block_id, block in blocks.items() if block['type'] in ('sequential', 'lock'))

# With a course outline loaded, the same sequence is removed.
new_learning_seq_outline = CourseOutlineData(
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/course_home_api/outline/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def get(self, request, *args, **kwargs):
context.update({
'include_vertical': True,
'extra_fields': ['special_exam_info',],
'display_block_prerequisite_icon': True,
'enable_prerequisite_block_type': True,
})

serializer = self.get_serializer_class()(course_blocks, context=context)
Expand Down

0 comments on commit 4740faa

Please sign in to comment.