Skip to content

Commit

Permalink
fix: revision after review
Browse files Browse the repository at this point in the history
  • Loading branch information
ruzniaievdm committed Mar 6, 2024
1 parent 0557c26 commit c42d7dd
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions xmodule/split_test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,19 @@ def child(self):
"""
Return the user bound child block for the partition or None.
We are using try/except block here because we ran into issues with
CachingDescriptorSystem has no attribute when we get an icon for the split_test xblock.
Handles the AttributeError exception that may occur when attempting to retrieve
an icon for the split_test xblock within the CMS.
"""
try:
return self.runtime.get_block_for_descriptor(self.child_block)
if self.child_block is not None:
return self.runtime.get_block_for_descriptor(self.child_block)
else:
return None
except AttributeError:
log.warning("Error while getting block for descriptor")
log.warning(
"Error while getting block instance for descriptor with location: [%s]",
self.location
)
return None

def get_child_block_by_location(self, location):
Expand Down Expand Up @@ -218,20 +224,30 @@ def get_child_blocks(self):
"""
For grading--return just the chosen child.
We are using try/except block here because we ran into issues with
User service being undefined when we get an icon for the split_test xblock.
Handles the NoSuchServiceError and ValueError exception that may occur when attempting to retrieve
an icon for the split_test xblock within the CMS.
"""
try:
group_id = self.get_group_id()
except NoSuchServiceError:
log.warning("Error while getting user service in runtime")
log.warning(
"Error while getting user service in runtime with location: [%s]",
self.location
)
return []
except ValueError:
log.warning(
"Error while getting group ID for partition with location: [%s]",
self.location
)
return []

if group_id is None:
return []

# group_id_to_child comes from json, so it has to have string keys
str_group_id = str(group_id)
child_block = None
if str_group_id in self.group_id_to_child:
child_location = self.group_id_to_child[str_group_id]
child_block = self.get_child_block_by_location(child_location)
Expand Down

0 comments on commit c42d7dd

Please sign in to comment.