src/google-classroom-extractor/edfi_google_classroom_extractor/mapping/user_section_associations.py
def students_and_teachers_to_user_section_associations_dfs(
    students_df: DataFrame, teachers_df: DataFrame
) -> Dict[str, DataFrame]:
    """
    Convert Student and Teacher API DataFrames to a Dict of
    UserSectionAssociation UDM DataFrames grouped by source system
    section id

    Parameters
    ----------
    students_df: DataFrame
        is a Students API DataFrame
    teachers_df: DataFrame
        is a Students API DataFrame

    Returns
    -------
    Dict[str, DataFrame]
        LMS UDM UserSectionAssociation DataFrames grouped by
            source system section id

    Notes
    -----
    UserSectionAssociation DataFrame columns are:
        EnrollmentStatus: The status of the user section association. E.g., Active,
            Inactive, Withdrawn
        LMSSectionSourceSystemIdentifier: A unique numeric identifier assigned to the section
        SourceSystem: The system code or name providing the user data
        SourceSystemIdentifier: A unique number or alphanumeric code
            assigned to a user by the source system
        LMSUserSourceSystemIdentifier: A unique numeric identifier assigned to the user
        SourceCreateDate: Date this record was created in the LMS
        SourceLastModifiedDate: Date this record was last updated in the LMS
        CreateDate: Date this record was created in the extractor
        LastModifiedDate: Date this record was last updated in the extractor
    """
    assert "userId" in students_df.columns
    assert "courseId" in students_df.columns
    assert "userId" in teachers_df.columns
    assert "courseId" in teachers_df.columns

    associations_from_students_df: DataFrame = (
        _students_or_teachers_to_user_section_associations_df(
            students_df,
        )
    )
    associations_from_teachers_df: DataFrame = (
        _students_or_teachers_to_user_section_associations_df(
            teachers_df,
        )
    )

    user_section_associations_df = concat(
        [associations_from_students_df, associations_from_teachers_df],
        ignore_index=True,
        sort=False,
    )

    # group by section id as a Dict of DataFrames
    result: Dict[str, DataFrame] = dict(
        tuple(
            user_section_associations_df.groupby(
                [
                    "LMSSectionSourceSystemIdentifier",
                ]
            )
        )
    )

    return result

    Convert Student and Teacher API DataFrames to a Dict of
    UserSectionAssociation UDM DataFrames grouped by source system
    section id

    Parameters
    ----------
    students_df: DataFrame
        is a Students API DataFrame
    teachers_df: DataFrame
        is a Students API DataFrame

    Returns
    -------
    Dict[str, DataFrame]
        LMS UDM UserSectionAssociation DataFrames grouped by
            source system section id

    Notes
    -----
    UserSectionAssociation DataFrame columns are:
        EnrollmentStatus: The status of the user section association. E.g., Active,
            Inactive, Withdrawn
        LMSSectionSourceSystemIdentifier: A unique numeric identifier assigned to the section
        SourceSystem: The system code or name providing the user data
        SourceSystemIdentifier: A unique number or alphanumeric code
            assigned to a user by the source system
        LMSUserSourceSystemIdentifier: A unique numeric identifier assigned to the user
        SourceCreateDate: Date this record was created in the LMS
        SourceLastModifiedDate: Date this record was last updated in the LMS
        CreateDate: Date this record was created in the extractor
        LastModifiedDate: Date this record was last updated in the extractor
    
Convert Student and Teacher API DataFrames to a Dict of
UserSectionAssociation UDM DataFrames grouped by source system
section id

Parameters



Returns

Dict[str, DataFrame]
LMS UDM UserSectionAssociation DataFrames grouped by
source system section id

Notes

UserSectionAssociation DataFrame columns are:
EnrollmentStatus: The status of the user section association.
Convert Student and Teacher API DataFrames to a Dict of UserSectionAssociation UDM DataFrames grouped by source system section id Parameters Returns Dict [ str DataFrame ] LMS UDM UserSectionAssociation DataFrames grouped by source system section id Notes UserSectionAssociation DataFrame columns are : EnrollmentStatus : The status of the user section association .
def students_and_teachers_to_user_section_associations_dfs(
    students_df: DataFrame, teachers_df: DataFrame
) -> Dict[str, DataFrame]:
    assert "userId" in students_df.columns
    assert "courseId" in students_df.columns
    assert "userId" in teachers_df.columns
    assert "courseId" in teachers_df.columns
    associations_from_students_df: DataFrame = (
        _students_or_teachers_to_user_section_associations_df(
            students_df,
        )
    )
    associations_from_teachers_df: DataFrame = (
        _students_or_teachers_to_user_section_associations_df(
            teachers_df,
        )
    )
    user_section_associations_df = concat(
        [associations_from_students_df, associations_from_teachers_df],
        ignore_index=True,
        sort=False,
    )
    result: Dict[str, DataFrame] = dict(
        tuple(
            user_section_associations_df.groupby(
                [
                    "LMSSectionSourceSystemIdentifier",
                ]
            )
        )
    )
    return result
def students_and_teachers_to_user_section_associations_dfs ( students_df : DataFrame , teachers_df : DataFrame ) -> Dict [ str , DataFrame ] : assert "userId" in students_df . columns assert "courseId" in students_df . columns assert "userId" in teachers_df . columns assert "courseId" in teachers_df . columns associations_from_students_df : DataFrame = ( _students_or_teachers_to_user_section_associations_df ( students_df , ) ) associations_from_teachers_df : DataFrame = ( _students_or_teachers_to_user_section_associations_df ( teachers_df , ) ) user_section_associations_df = concat ( [ associations_from_students_df , associations_from_teachers_df ] , ignore_index = True , sort = False , ) result : Dict [ str , DataFrame ] = dict ( tuple ( user_section_associations_df . groupby ( [ "LMSSectionSourceSystemIdentifier" , ] ) ) ) return result
Convert Student and Teacher API DataFrames to a Dict of
UserSectionAssociation UDM DataFrames grouped by source system
section id
Convert Student and Teacher API DataFrames to a Dict of UserSectionAssociation UDM DataFrames grouped by source system section id
"""
    Convert Student and Teacher API DataFrames to a Dict of
    UserSectionAssociation UDM DataFrames grouped by source system
    section id

    Parameters
    ----------
    students_df: DataFrame
        is a Students API DataFrame
    teachers_df: DataFrame
        is a Students API DataFrame

    Returns
    -------
    Dict[str, DataFrame]
        LMS UDM UserSectionAssociation DataFrames grouped by
            source system section id

    Notes
    -----
    UserSectionAssociation DataFrame columns are:
        EnrollmentStatus: The status of the user section association. E.g., Active,
            Inactive, Withdrawn
        LMSSectionSourceSystemIdentifier: A unique numeric identifier assigned to the section
        SourceSystem: The system code or name providing the user data
        SourceSystemIdentifier: A unique number or alphanumeric code
            assigned to a user by the source system
        LMSUserSourceSystemIdentifier: A unique numeric identifier assigned to the user
        SourceCreateDate: Date this record was created in the LMS
        SourceLastModifiedDate: Date this record was last updated in the LMS
        CreateDate: Date this record was created in the extractor
        LastModifiedDate: Date this record was last updated in the extractor
    """ # group by section id as a Dict of DataFrames
students_df
DataFrame
teachers_df
DataFrame