'Creates and returns the course.
Args:
org (str): the organization that owns the course
course (str): the name of the course
run (str): the name of the run
user_id: id of the user creating the course
fields (dict): Fields to set on the course at initialization
kwargs: Any optional arguments understood by a subset of modulestores to customize instantiation
Returns: a CourseDescriptor
Raises:
InvalidLocationError: If a course with the same org, course, and run already exists'

def create_course(self, org, course, run, user_id, fields=None, **kwargs):

    course_id = SlashSeparatedCourseKey(org, course, run)
    course_search_location = SON([('_id.tag', 'i4x'), ('_id.org', re.compile(u'^{}$'.format(course_id.org), re.IGNORECASE)), ('_id.course', re.compile(u'^{}$'.format(course_id.course), re.IGNORECASE)), ('_id.category', 'course')])
    courses = self.collection.find(course_search_location, projection={'_id': True})
    if (courses.count() > 0):
        raise DuplicateCourseError(course_id, courses[0]['_id'])
    with self.bulk_operations(course_id):
        xblock = self.create_item(user_id, course_id, 'course', course_id.run, fields=fields, **kwargs)
        super(MongoModuleStore, self).create_course(org, course, run, user_id, runtime=xblock.runtime, **kwargs)
        return xblock
