src/schoology-extractor/data_generation/discussion_comments.py
def generate_discussion_comments(
    discussion_comments_per_discussion_count: int,
    discussions: Dict[str, List[Dict]],
    enrollments: Dict[str, List[Dict]],
) -> Dict[str, Dict[str, List[Dict]]]:
    """
    Generate a list of graded Schoology discussion comments for discussions.

    Parameters
    ----------
    discussion_comments_per_discussion_count : int
         The number of discussion comments per discussion to generate
    discussions: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        discussion objects from a bulk create response
    enrollments: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        enrollment objects from a bulk create response

    Returns
    -------
    Dict[str, Dict[str, List[Dict]]]
        A Dict of mappings from Schoology section id to a dict of mappings
        of discussion ids to a list of JSON-like discussion comment objects
        in a form suitable for submission to the Schoology discussion comment
        create endpoint.
    """
    assert (
        discussion_comments_per_discussion_count > 0
    ), "Number of discussion comments per section to generate must be greater than zero"

    logging.info(
        f"Generating {discussion_comments_per_discussion_count} comments per discussion"
    )

    discussion_comments: Dict[str, Dict[str, List[Dict]]] = {}
    for section_id, discussions_for_section in discussions.items():
        discussion_comments[section_id] = {}
        enrollment_user_ids_for_section: List[str] = list(
            map(
                lambda enrollment: enrollment["uid"],
                enrollments[section_id],
            )
        )

        for discussion in discussions_for_section:
            user_ids_for_each_comment: List[str] = fake.random_choices(
                enrollment_user_ids_for_section,
                length=discussion_comments_per_discussion_count,
            )

            comments: List[Dict] = list(
                map(
                    lambda uid: {
                        "uid": uid,
                        "comment": fake.sentence(),
                    },
                    user_ids_for_each_comment,
                )
            )
            discussion_comments[section_id][discussion["id"]] = comments
    return discussion_comments

    Generate a list of graded Schoology discussion comments for discussions.

    Parameters
    ----------
    discussion_comments_per_discussion_count : int
         The number of discussion comments per discussion to generate
    discussions: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        discussion objects from a bulk create response
    enrollments: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        enrollment objects from a bulk create response

    Returns
    -------
    Dict[str, Dict[str, List[Dict]]]
        A Dict of mappings from Schoology section id to a dict of mappings
        of discussion ids to a list of JSON-like discussion comment objects
        in a form suitable for submission to the Schoology discussion comment
        create endpoint.
    
Generate a list of graded Schoology discussion comments for discussions.
Parameters

discussion_comments_per_discussion_count : int
The number of discussion comments per discussion to generate
discussions: Dict[str, List[Dict]]
A Dict of mappings from Schoology section id to a list of JSON-like
discussion objects from a bulk create response
enrollments: Dict[str, List[Dict]]
A Dict of mappings from Schoology section id to a list of JSON-like
enrollment objects from a bulk create response

Returns

Dict[str, Dict[str, List[Dict]]]
A Dict of mappings from Schoology section id to a dict of mappings
of discussion ids to a list of JSON-like discussion comment objects
in a form suitable for submission to the Schoology discussion comment
create endpoint.
Generate a list of graded Schoology discussion comments for discussions . Parameters discussion_comments_per_discussion_count : int The number of discussion comments per discussion to generate discussions : Dict [ str List [ Dict ]] A Dict of mappings from Schoology section id to a list of JSON - like discussion objects from a bulk create response enrollments : Dict [ str List [ Dict ]] A Dict of mappings from Schoology section id to a list of JSON - like enrollment objects from a bulk create response Returns Dict [ str Dict [ str List [ Dict ]]] A Dict of mappings from Schoology section id to a dict of mappings of discussion ids to a list of JSON - like discussion comment objects in a form suitable for submission to the Schoology discussion comment create endpoint .
def generate_discussion_comments(
    discussion_comments_per_discussion_count: int,
    discussions: Dict[str, List[Dict]],
    enrollments: Dict[str, List[Dict]],
) -> Dict[str, Dict[str, List[Dict]]]:
    assert (
        discussion_comments_per_discussion_count > 0
    ), "Number of discussion comments per section to generate must be greater than zero"
    logging.info(
        f"Generating {discussion_comments_per_discussion_count} comments per discussion"
    )
    discussion_comments: Dict[str, Dict[str, List[Dict]]] = {}
    for section_id, discussions_for_section in discussions.items():
        discussion_comments[section_id] = {}
        enrollment_user_ids_for_section: List[str] = list(
            map(
                lambda enrollment: enrollment["uid"],
                enrollments[section_id],
            )
        )
        for discussion in discussions_for_section:
            user_ids_for_each_comment: List[str] = fake.random_choices(
                enrollment_user_ids_for_section,
                length=discussion_comments_per_discussion_count,
            )
            comments: List[Dict] = list(
                map(
                    lambda uid: {
                        "uid": uid,
                        "comment": fake.sentence(),
                    },
                    user_ids_for_each_comment,
                )
            )
            discussion_comments[section_id][discussion["id"]] = comments
    return discussion_comments
def generate_discussion_comments ( discussion_comments_per_discussion_count : int , discussions : Dict [ str , List [ Dict ] ] , enrollments : Dict [ str , List [ Dict ] ] , ) -> Dict [ str , Dict [ str , List [ Dict ] ] ] : assert ( discussion_comments_per_discussion_count > 0 ) , "Number of discussion comments per section to generate must be greater than zero" logging . info ( f"Generating {discussion_comments_per_discussion_count} comments per discussion" ) discussion_comments : Dict [ str , Dict [ str , List [ Dict ] ] ] = { } for section_id , discussions_for_section in discussions . items ( ) : discussion_comments [ section_id ] = { } enrollment_user_ids_for_section : List [ str ] = list ( map ( lambda enrollment : enrollment [ "uid" ] , enrollments [ section_id ] , ) ) for discussion in discussions_for_section : user_ids_for_each_comment : List [ str ] = fake . random_choices ( enrollment_user_ids_for_section , length = discussion_comments_per_discussion_count , ) comments : List [ Dict ] = list ( map ( lambda uid : { "uid" : uid , "comment" : fake . sentence ( ) , } , user_ids_for_each_comment , ) ) discussion_comments [ section_id ] [ discussion [ "id" ] ] = comments return discussion_comments
Generate a list of graded Schoology discussion comments for discussions.
Generate a list of graded Schoology discussion comments for discussions .
"""
    Generate a list of graded Schoology discussion comments for discussions.

    Parameters
    ----------
    discussion_comments_per_discussion_count : int
         The number of discussion comments per discussion to generate
    discussions: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        discussion objects from a bulk create response
    enrollments: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        enrollment objects from a bulk create response

    Returns
    -------
    Dict[str, Dict[str, List[Dict]]]
        A Dict of mappings from Schoology section id to a dict of mappings
        of discussion ids to a list of JSON-like discussion comment objects
        in a form suitable for submission to the Schoology discussion comment
        create endpoint.
    """
discussion_comments_per_discussion_count
int
discussions
Dict[str, List[Dict]]
enrollments
Dict[str, List[Dict]]