Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [AXIMST-584] add correct icon for vertical block #2513

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +68 to +80
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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
@staticmethod
def get_vertical_icon_class(block, icon_mapping=None):
"""
Returns the icon class for a vertical block based on its children.
Args:
block (object): xblock object
Returns:
str: The icon class name to be used, or 'other' if no match is found.
"""
if icon_mapping is None:
icon_mapping = {
'video': 'video',
'problem': 'problem',
}
for child in block.get('children', []):
if child.get('type') in icon_mapping:
return icon_mapping[child.get('type')]
return 'other'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if this passes as a solution



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