def set_required_content(course_key, gated_content_key, prereq_content_key, min_score):
 milestone = None
 for gating_milestone in find_gating_milestones(course_key, gated_content_key, 'requires'):
  if ((not prereq_content_key) or (prereq_content_key not in gating_milestone.get('namespace'))):
   milestones_api.remove_course_content_milestone(course_key, gated_content_key, gating_milestone)
  else:
   milestone = gating_milestone
 if prereq_content_key:
  _validate_min_score(min_score)
  requirements = {'min_score': min_score}
  if (not milestone):
   milestone = _get_prerequisite_milestone(prereq_content_key)
  milestones_api.add_course_content_milestone(course_key, gated_content_key, 'requires', milestone, requirements)

def set_required_content ( course_key , gated_content_key , prereq_content_key , min_score ) : milestone = None for gating_milestone in find_gating_milestones ( course_key , gated_content_key , 'requires' ) : if ( ( not prereq_content_key ) or ( prereq_content_key not in gating_milestone . get ( 'namespace' ) ) ) : milestones_api . remove_course_content_milestone ( course_key , gated_content_key , gating_milestone ) else : milestone = gating_milestone if prereq_content_key : _validate_min_score ( min_score ) requirements = { 'min_score' : min_score } if ( not milestone ) : milestone = _get_prerequisite_milestone ( prereq_content_key ) milestones_api . add_course_content_milestone ( course_key , gated_content_key , 'requires' , milestone , requirements )
adds a requires milestone relationship for the given gated_content_key if a prerequisite prereq_content_key is provided .