src/schoology-extractor/data_generation/enrollments.py
def generate_and_load_enrollments(
    request_client: RequestClient,
    users_per_section_count: int,
    sections: List[Dict],
    users: List[Dict],
) -> Dict[str, List[Dict]]:
    """
    Generate and load a number of enrollments into the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    users_per_section_count : int
        The number of users to be in each section
    sections: List[Dict]
        A list of JSON-like section objects from a bulk create response
    users: List[Dict]
        A list of JSON-like user objects from a bulk create response

    Returns
    -------
    Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like enrollment
        objects incorporating the response values from the Schoology API,
        e.g. resource ids and status from individual POSTing
    """
    result: Dict[str, List[Dict]] = {}

    for section in sections:
        try:
            users_in_section = fake.random_sample(
                elements=users, length=users_per_section_count
            )
            enrollments = list(
                map(
                    lambda user: {
                        "uid": user["id"],
                        "admin": IS_STUDENT,
                        "status": IS_ACTIVE,
                    },
                    users_in_section,
                )
            )

            enrollment_result = load_enrollments(
                request_client, section["id"], enrollments
            )
            result[section["id"]] = enrollment_result
        except Exception as ex:
            logger.exception(ex)

    return result

    Generate and load a number of enrollments into the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    users_per_section_count : int
        The number of users to be in each section
    sections: List[Dict]
        A list of JSON-like section objects from a bulk create response
    users: List[Dict]
        A list of JSON-like user objects from a bulk create response

    Returns
    -------
    Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like enrollment
        objects incorporating the response values from the Schoology API,
        e.g. resource ids and status from individual POSTing
    
Generate and load a number of enrollments into the Schoology API.
Parameters

request_client : RequestClient
A RequestClient initialized for access to the Schoology API
users_per_section_count : int
The number of users to be in each section
sections: List[Dict]
A list of JSON-like section objects from a bulk create response
users: List[Dict]
A list of JSON-like user objects from a bulk create response

Returns

Dict[str, List[Dict]]
A Dict of mappings from Schoology section id to a list of JSON-like enrollment
objects incorporating the response values from the Schoology API,
e.g. resource ids and status from individual POSTing
Generate and load a number of enrollments into the Schoology API . Parameters request_client : RequestClient A RequestClient initialized for access to the Schoology API users_per_section_count : int The number of users to be in each section sections : List [ Dict ] A list of JSON - like section objects from a bulk create response users : List [ Dict ] A list of JSON - like user objects from a bulk create response Returns Dict [ str List [ Dict ]] A Dict of mappings from Schoology section id to a list of JSON - like enrollment objects incorporating the response values from the Schoology API e . g . resource ids and status from individual POSTing
def generate_and_load_enrollments(
    request_client: RequestClient,
    users_per_section_count: int,
    sections: List[Dict],
    users: List[Dict],
) -> Dict[str, List[Dict]]:
    result: Dict[str, List[Dict]] = {}
    for section in sections:
        try:
            users_in_section = fake.random_sample(
                elements=users, length=users_per_section_count
            )
            enrollments = list(
                map(
                    lambda user: {
                        "uid": user["id"],
                        "admin": IS_STUDENT,
                        "status": IS_ACTIVE,
                    },
                    users_in_section,
                )
            )
            enrollment_result = load_enrollments(
                request_client, section["id"], enrollments
            )
            result[section["id"]] = enrollment_result
        except Exception as ex:
            logger.exception(ex)
    return result
def generate_and_load_enrollments ( request_client : RequestClient , users_per_section_count : int , sections : List [ Dict ] , users : List [ Dict ] , ) -> Dict [ str , List [ Dict ] ] : result : Dict [ str , List [ Dict ] ] = { } for section in sections : try : users_in_section = fake . random_sample ( elements = users , length = users_per_section_count ) enrollments = list ( map ( lambda user : { "uid" : user [ "id" ] , "admin" : IS_STUDENT , "status" : IS_ACTIVE , } , users_in_section , ) ) enrollment_result = load_enrollments ( request_client , section [ "id" ] , enrollments ) result [ section [ "id" ] ] = enrollment_result except Exception as ex : logger . exception ( ex ) return result
Generate and load a number of enrollments into the Schoology API.
Generate and load a number of enrollments into the Schoology API .
"""
    Generate and load a number of enrollments into the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    users_per_section_count : int
        The number of users to be in each section
    sections: List[Dict]
        A list of JSON-like section objects from a bulk create response
    users: List[Dict]
        A list of JSON-like user objects from a bulk create response

    Returns
    -------
    Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like enrollment
        objects incorporating the response values from the Schoology API,
        e.g. resource ids and status from individual POSTing
    """
request_client
RequestClient
users_per_section_count
int
sections
List[Dict]
users
List[Dict]