def get_prerequisites(course_key):
 course_content_milestones = find_gating_milestones(course_key)
 milestones_by_block_id = {}
 block_ids = []
 for milestone in course_content_milestones:
  prereq_content_key = milestone['namespace'].replace(GATING_NAMESPACE_QUALIFIER, '')
  block_id = UsageKey.from_string(prereq_content_key).block_id
  block_ids.append(block_id)
  milestones_by_block_id[block_id] = milestone
 result = []
 for block in modulestore().get_items(course_key, qualifiers={'name': block_ids}):
  milestone = milestones_by_block_id.get(block.location.block_id)
  if milestone:
   milestone['block_display_name'] = block.display_name
   milestone['block_usage_key'] = unicode(block.location)
   result.append(milestone)
 return result

def get_prerequisites ( course_key ) : course_content_milestones = find_gating_milestones ( course_key ) milestones_by_block_id = { } block_ids = [ ] for milestone in course_content_milestones : prereq_content_key = milestone [ 'namespace' ] . replace ( GATING_NAMESPACE_QUALIFIER , '' ) block_id = UsageKey . from_string ( prereq_content_key ) . block_id block_ids . append ( block_id ) milestones_by_block_id [ block_id ] = milestone result = [ ] for block in modulestore ( ) . get_items ( course_key , qualifiers = { 'name' : block_ids } ) : milestone = milestones_by_block_id . get ( block . location . block_id ) if milestone : milestone [ 'block_display_name' ] = block . display_name milestone [ 'block_usage_key' ] = unicode ( block . location ) result . append ( milestone ) return result
find all the gating milestones associated with a course and the xblock info associated with those gating milestones .