def set_prerequisite_courses(course_key, prerequisite_course_keys):
 if (not is_prerequisite_courses_enabled()):
  return None
 course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship='requires')
 if course_milestones:
  for milestone in course_milestones:
   remove_prerequisite_course(course_key, milestone)
 if prerequisite_course_keys:
  for prerequisite_course_key_string in prerequisite_course_keys:
   prerequisite_course_key = CourseKey.from_string(prerequisite_course_key_string)
   add_prerequisite_course(course_key, prerequisite_course_key)

def set_prerequisite_courses ( course_key , prerequisite_course_keys ) : if ( not is_prerequisite_courses_enabled ( ) ) : return None course_milestones = milestones_api . get_course_milestones ( course_key = course_key , relationship = 'requires' ) if course_milestones : for milestone in course_milestones : remove_prerequisite_course ( course_key , milestone ) if prerequisite_course_keys : for prerequisite_course_key_string in prerequisite_course_keys : prerequisite_course_key = CourseKey . from_string ( prerequisite_course_key_string ) add_prerequisite_course ( course_key , prerequisite_course_key )
it would remove any existing requirement milestones for the given course_key and create new milestones for each pre-requisite course in prerequisite_course_keys .