From 1ecee832b8e7ec0a7c1c7fb3ab6d5ad2055e933f Mon Sep 17 00:00:00 2001 From: NiedielnitsevIvan <81557788+NiedielnitsevIvan@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:50:29 +0200 Subject: [PATCH] fix: [AXIMST-584] add correct icon for vertical block (#2513) * fix: [AXIMST-584] add correct icon for vertical block * style: [AXIMST-584] add missing docstring --- .../course_home_api/outline/serializers.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lms/djangoapps/course_home_api/outline/serializers.py b/lms/djangoapps/course_home_api/outline/serializers.py index 29b46d30e967..5e40b7900cf2 100644 --- a/lms/djangoapps/course_home_api/outline/serializers.py +++ b/lms/djangoapps/course_home_api/outline/serializers.py @@ -35,6 +35,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') @@ -60,6 +63,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): """