code: def course_register_user(self, course, username=None, password=None, force=False):
          
          if username is None:
              username = self.session_username()
  
          user_info = self._database.users.find_one({"username":username})
  
          # Do not continue registering the user in the course if username is empty.
          if not username:
              return False
  
          if not force:
              if not course.is_registration_possible(user_info):
                  return False
              if course.is_password_needed_for_registration() and course.get_registration_password() != password:
                  return False
          if self.course_is_user_registered(course, username):
              return False  # already registered?
  
          aggregation = self._database.aggregations.find_one({"courseid": course.get_id(), "default": True})
          if aggregation is None:
              self._database.aggregations.insert({"courseid": course.get_id(), "description": "Default classroom",
                                                "students": [username], "tutors": [], "groups": [], "default": True})
          else:
              self._database.aggregations.find_one_and_update({"courseid": course.get_id(), "default": True},
                                                            {"$push": {"students": username}})
  
          self._logger.info("User %s registered to course %s", username, course.get_id())
          return True
docs: Register a user to the course
          :param course: a Course object
          :param username: The username of the user that we want to register. If None, uses self.session_username()
          :param password: Password for the course. Needed if course.is_password_needed_for_registration() and force != True
          :param force: Force registration
          :return: True if the registration succeeded, False else