def validate_course_id(course_id):
 try:
  course_key = CourseKey.from_string(unicode(course_id))
 except InvalidKeyError:
  raise serializers.ValidationError(_('{course_id} is not a valid course key.').format(course_id=course_id))
 if (not modulestore().has_course(course_key)):
  raise serializers.ValidationError(_('Course {course_id} does not exist.').format(course_id=course_id))

def validate_course_id ( course_id ) : try : course_key = CourseKey . from_string ( unicode ( course_id ) ) except InvalidKeyError : raise serializers . ValidationError ( _ ( '{course_id} is not a valid course key.' ) . format ( course_id = course_id ) ) if ( not modulestore ( ) . has_course ( course_key ) ) : raise serializers . ValidationError ( _ ( 'Course {course_id} does not exist.' ) . format ( course_id = course_id ) )
check that course id is valid and exists in modulestore .