def get_course_chapters(course_key):
 if (course_key is None):
  return
 try:
  course_obj = CourseStructure.objects.get(course_id=course_key)
 except CourseStructure.DoesNotExist:
  return
 course_struct = course_obj.structure
 try:
  return course_struct['blocks'][course_struct['root']].get('children', [])
 except KeyError:
  return []

def get_course_chapters ( course_key ) : if ( course_key is None ) : return try : course_obj = CourseStructure . objects . get ( course_id = course_key ) except CourseStructure . DoesNotExist : return course_struct = course_obj . structure try : return course_struct [ 'blocks' ] [ course_struct [ 'root' ] ] . get ( 'children' , [ ] ) except KeyError : return [ ]
extracts the chapters from a course structure .