def get_cached_discussion_id_map(course, discussion_ids, user):
 try:
  entries = []
  for discussion_id in discussion_ids:
   key = get_cached_discussion_key(course.id, discussion_id)
   if (not key):
    continue
   xblock = modulestore().get_item(key)
   if (not (has_required_keys(xblock) and has_access(user, 'load', xblock, course.id))):
    continue
   entries.append(get_discussion_id_map_entry(xblock))
  return dict(entries)
 except DiscussionIdMapIsNotCached:
  return get_discussion_id_map(course, user)

def get_cached_discussion_id_map ( course , discussion_ids , user ) : try : entries = [ ] for discussion_id in discussion_ids : key = get_cached_discussion_key ( course . id , discussion_id ) if ( not key ) : continue xblock = modulestore ( ) . get_item ( key ) if ( not ( has_required_keys ( xblock ) and has_access ( user , 'load' , xblock , course . id ) ) ) : continue entries . append ( get_discussion_id_map_entry ( xblock ) ) return dict ( entries ) except DiscussionIdMapIsNotCached : return get_discussion_id_map ( course , user )
returns a dict mapping discussion_ids to respective discussion xblock metadata if it is cached and visible to the user .