def get_pre_requisite_courses_not_completed(user, enrolled_courses):
 if (not is_prerequisite_courses_enabled()):
  return {}
 pre_requisite_courses = {}
 for course_key in enrolled_courses:
  required_courses = []
  fulfillment_paths = milestones_api.get_course_milestones_fulfillment_paths(course_key, {'id': user.id})
  for (__, milestone_value) in fulfillment_paths.items():
   for (key, value) in milestone_value.items():
    if ((key == 'courses') and value):
     for required_course in value:
      required_course_key = CourseKey.from_string(required_course)
      required_course_overview = CourseOverview.get_from_id(required_course_key)
      required_courses.append({'key': required_course_key, 'display': get_course_display_string(required_course_overview)})
  if required_courses:
   pre_requisite_courses[course_key] = {'courses': required_courses}
 return pre_requisite_courses

def get_pre_requisite_courses_not_completed ( user , enrolled_courses ) : if ( not is_prerequisite_courses_enabled ( ) ) : return { } pre_requisite_courses = { } for course_key in enrolled_courses : required_courses = [ ] fulfillment_paths = milestones_api . get_course_milestones_fulfillment_paths ( course_key , { 'id' : user . id } ) for ( __ , milestone_value ) in fulfillment_paths . items ( ) : for ( key , value ) in milestone_value . items ( ) : if ( ( key == 'courses' ) and value ) : for required_course in value : required_course_key = CourseKey . from_string ( required_course ) required_course_overview = CourseOverview . get_from_id ( required_course_key ) required_courses . append ( { 'key' : required_course_key , 'display' : get_course_display_string ( required_course_overview ) } ) if required_courses : pre_requisite_courses [ course_key ] = { 'courses' : required_courses } return pre_requisite_courses
makes a dict mapping courses to their unfulfilled milestones using the fulfillment api of the milestones app .