src/schoology-extractor/data_generation/enrollments.py
def load_enrollments(
    request_client: RequestClient, section_id: str, enrollments: List[Dict]
) -> List[Dict]:
    """
    Load a list of enrollments for a course via the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    section_id : str
        The Schoolgy internal section id the enrollments are to be associated with
    enrollments: List[Dict]
        A list of JSON-like enrollment objects in a form suitable for submission to the
        Schoology enrollment creation endpoint.

    Returns
    -------
    List[Dict]
        A list of JSON-like enrollment objects incorporating the response values from the
        Schoology API, e.g. resource ids and status from individual POSTing
    """
    assert (
        len(enrollments) > 0 and len(enrollments) < 51
    ), "Number of enrollments must be between 1 and 50"

    logger.info("Creating %s enrollments via Schoology API", len(enrollments))

    enrollments_json = {"enrollments": {"enrollment": enrollments}}
    post_response: List[Dict] = request_client.bulk_post(
        f"sections/{section_id}/enrollments", enrollments_json
    )["enrollments"]["enrollment"]
    validate_multi_status(post_response)
    logger.info("Successfully created %s enrollments", len(post_response))

    with_schoology_response_df: DataFrame = merge(
        json_normalize(enrollments),
        json_normalize(post_response).drop(["uid"], axis=1),
        left_index=True,
        right_index=True,
    )

    return with_schoology_response_df.to_dict("records")

    Load a list of enrollments for a course via the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    section_id : str
        The Schoolgy internal section id the enrollments are to be associated with
    enrollments: List[Dict]
        A list of JSON-like enrollment objects in a form suitable for submission to the
        Schoology enrollment creation endpoint.

    Returns
    -------
    List[Dict]
        A list of JSON-like enrollment objects incorporating the response values from the
        Schoology API, e.g. resource ids and status from individual POSTing
    
Load a list of enrollments for a course via the Schoology API.
Parameters

request_client : RequestClient
A RequestClient initialized for access to the Schoology API
section_id : str
The Schoolgy internal section id the enrollments are to be associated with
enrollments: List[Dict]
A list of JSON-like enrollment objects in a form suitable for submission to the
Schoology enrollment creation endpoint.

Returns

List[Dict]
A list of JSON-like enrollment objects incorporating the response values from the
Schoology API, e.g. resource ids and status from individual POSTing
Load a list of enrollments for a course via the Schoology API . Parameters request_client : RequestClient A RequestClient initialized for access to the Schoology API section_id : str The Schoolgy internal section id the enrollments are to be associated with enrollments : List [ Dict ] A list of JSON - like enrollment objects in a form suitable for submission to the Schoology enrollment creation endpoint . Returns List [ Dict ] 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 load_enrollments(
    request_client: RequestClient, section_id: str, enrollments: List[Dict]
) -> List[Dict]:
    assert (
        len(enrollments) > 0 and len(enrollments) < 51
    ), "Number of enrollments must be between 1 and 50"
    logger.info("Creating %s enrollments via Schoology API", len(enrollments))
    enrollments_json = {"enrollments": {"enrollment": enrollments}}
    post_response: List[Dict] = request_client.bulk_post(
        f"sections/{section_id}/enrollments", enrollments_json
    )["enrollments"]["enrollment"]
    validate_multi_status(post_response)
    logger.info("Successfully created %s enrollments", len(post_response))
    with_schoology_response_df: DataFrame = merge(
        json_normalize(enrollments),
        json_normalize(post_response).drop(["uid"], axis=1),
        left_index=True,
        right_index=True,
    )
    return with_schoology_response_df.to_dict("records")
def load_enrollments ( request_client : RequestClient , section_id : str , enrollments : List [ Dict ] ) -> List [ Dict ] : assert ( len ( enrollments ) > 0 and len ( enrollments ) < 51 ) , "Number of enrollments must be between 1 and 50" logger . info ( "Creating %s enrollments via Schoology API" , len ( enrollments ) ) enrollments_json = { "enrollments" : { "enrollment" : enrollments } } post_response : List [ Dict ] = request_client . bulk_post ( f"sections/{section_id}/enrollments" , enrollments_json ) [ "enrollments" ] [ "enrollment" ] validate_multi_status ( post_response ) logger . info ( "Successfully created %s enrollments" , len ( post_response ) ) with_schoology_response_df : DataFrame = merge ( json_normalize ( enrollments ) , json_normalize ( post_response ) . drop ( [ "uid" ] , axis = 1 ) , left_index = True , right_index = True , ) return with_schoology_response_df . to_dict ( "records" )
Load a list of enrollments for a course via the Schoology API.
Load a list of enrollments for a course via the Schoology API .
"""
    Load a list of enrollments for a course via the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    section_id : str
        The Schoolgy internal section id the enrollments are to be associated with
    enrollments: List[Dict]
        A list of JSON-like enrollment objects in a form suitable for submission to the
        Schoology enrollment creation endpoint.

    Returns
    -------
    List[Dict]
        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
section_id
str
enrollments
List[Dict]