def parse_get_teachers(courses):
    """
    Parse the teacher information received from Moodle.

    :param courses: All information about all courses in Moodle.
    :type courses: list(dict(str, int))
    :return: A list of dictionaries containing all user information and the course they are teacher from.
    :rtype: dict(int, dict(str, str))
    """
    teachers_list = {}
    for course in courses:
        for user in course['users']:
            roles = []
            for role in user['roles']:
                roles.append(role['shortname'])
            if user['id'] in teachers_list:
                teachers_list[user['id']]['courses'].update({course['courseid']: roles})
            else:
                teachers_list[user['id']] = {"username": user['username'], "id": user['id'],
                                             "firstname": user['firstname'],
                                             "lastname": user["lastname"], "email": user['email'],
                                             "courses": {course['courseid']: roles}
                                             }

    return teachers_list