Skip to content

Commit

Permalink
fix: [AXIMST-584] add correct icon for vertical block (#2513)
Browse files Browse the repository at this point in the history
* fix: [AXIMST-584] add correct icon for vertical block

* style: [AXIMST-584] add missing docstring
  • Loading branch information
NiedielnitsevIvan authored Mar 13, 2024
1 parent 8292187 commit bb61ce2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lms/djangoapps/course_home_api/outline/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def get_blocks(self, block): # pylint: disable=missing-function-docstring
if graded and scored:
icon = 'fa-pencil-square-o'

if block_type == 'vertical':
icon = self.get_vertical_icon_class(block)

if 'special_exam_info' in block:
description = block['special_exam_info'].get('short_description')
icon = block['special_exam_info'].get('suggested_icon', 'fa-pencil-square-o')
Expand All @@ -62,6 +65,20 @@ def get_blocks(self, block): # pylint: disable=missing-function-docstring
serialized.update(self.get_blocks(child))
return serialized

@staticmethod
def get_vertical_icon_class(block):
"""
Get the icon class for a vertical block based on its children.
"""
children = block.get('children', [])
child_classes = {child.get('type') for child in children}
new_class = 'other'
icon_call_priority = ['video', 'problem']
for higher_class in icon_call_priority:
if higher_class in child_classes:
new_class = higher_class
return new_class


class CourseGoalsSerializer(serializers.Serializer):
"""
Expand Down

0 comments on commit bb61ce2

Please sign in to comment.