def set_credit_requirements(course_key, requirements):
 invalid_requirements = _validate_requirements(requirements)
 if invalid_requirements:
  invalid_requirements = ', '.join(invalid_requirements)
  raise InvalidCreditRequirements(invalid_requirements)
 try:
  credit_course = CreditCourse.get_credit_course(course_key=course_key)
 except CreditCourse.DoesNotExist:
  raise InvalidCreditCourse()
 old_requirements = CreditRequirement.get_course_requirements(course_key=course_key)
 requirements_to_disable = _get_requirements_to_disable(old_requirements, requirements)
 if requirements_to_disable:
  CreditRequirement.disable_credit_requirements(requirements_to_disable)
 for (order, requirement) in enumerate(requirements):
  CreditRequirement.add_or_update_course_requirement(credit_course, requirement, order)

def set_credit_requirements ( course_key , requirements ) : invalid_requirements = _validate_requirements ( requirements ) if invalid_requirements : invalid_requirements = ', ' . join ( invalid_requirements ) raise InvalidCreditRequirements ( invalid_requirements ) try : credit_course = CreditCourse . get_credit_course ( course_key = course_key ) except CreditCourse . DoesNotExist : raise InvalidCreditCourse ( ) old_requirements = CreditRequirement . get_course_requirements ( course_key = course_key ) requirements_to_disable = _get_requirements_to_disable ( old_requirements , requirements ) if requirements_to_disable : CreditRequirement . disable_credit_requirements ( requirements_to_disable ) for ( order , requirement ) in enumerate ( requirements ) : CreditRequirement . add_or_update_course_requirement ( credit_course , requirement , order )
add requirements to given course .