src/schoology-extractor/data_generation/discussions.py
def generate_and_load_discussions(
    request_client: RequestClient,
    discussions_per_assignment_count: int,
    assignments: Dict[str, List[Dict]],
) -> Dict[str, List[Dict]]:
    """
    Generate and load a number of discussions into the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    discussions_per_assignment_count : int
         The number of discussions per assignment to generate
    assignments: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        assignment 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 discussion
         objects incorporating the response values from the Schoology API,
         e.g. resource ids and status from individual POSTing
    """
    assert (
        discussions_per_assignment_count > 0
    ), "Number of discussions per assignment to generate must be greater than zero"

    discussion_per_section: Dict[str, List[Dict]] = generate_discussions(
        discussions_per_assignment_count, assignments
    )

    result: Dict[str, List[Dict]] = {}
    for section_id, total_discussions_per_section in discussion_per_section.items():
        MAX_CHUNK_SIZE = 50
        chunked_discussions: List[List[Dict]] = [
            total_discussions_per_section[x : x + MAX_CHUNK_SIZE]
            for x in range(0, len(total_discussions_per_section), MAX_CHUNK_SIZE)
        ]

        result[section_id] = []
        for discussion_chunk in chunked_discussions:
            try:
                chunked_result = load_discussions(
                    request_client, section_id, discussion_chunk
                )
                result[section_id].extend(chunked_result)
            except Exception as ex:
                logger.exception(ex)

    return result

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

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    discussions_per_assignment_count : int
         The number of discussions per assignment to generate
    assignments: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        assignment 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 discussion
         objects incorporating the response values from the Schoology API,
         e.g. resource ids and status from individual POSTing
    
Generate and load a number of discussions into the Schoology API.
Parameters

request_client : RequestClient
A RequestClient initialized for access to the Schoology API
discussions_per_assignment_count : int
The number of discussions per assignment to generate
assignments: Dict[str, List[Dict]]
A Dict of mappings from Schoology section id to a list of JSON-like
assignment 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 discussion
objects incorporating the response values from the Schoology API,
e.g. resource ids and status from individual POSTing
Generate and load a number of discussions into the Schoology API . Parameters request_client : RequestClient A RequestClient initialized for access to the Schoology API discussions_per_assignment_count : int The number of discussions per assignment to generate assignments : Dict [ str List [ Dict ]] A Dict of mappings from Schoology section id to a list of JSON - like assignment 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 discussion objects incorporating the response values from the Schoology API e . g . resource ids and status from individual POSTing
def generate_and_load_discussions(
    request_client: RequestClient,
    discussions_per_assignment_count: int,
    assignments: Dict[str, List[Dict]],
) -> Dict[str, List[Dict]]:
    assert (
        discussions_per_assignment_count > 0
    ), "Number of discussions per assignment to generate must be greater than zero"
    discussion_per_section: Dict[str, List[Dict]] = generate_discussions(
        discussions_per_assignment_count, assignments
    )
    result: Dict[str, List[Dict]] = {}
    for section_id, total_discussions_per_section in discussion_per_section.items():
        MAX_CHUNK_SIZE = 50
        chunked_discussions: List[List[Dict]] = [
            total_discussions_per_section[x : x + MAX_CHUNK_SIZE]
            for x in range(0, len(total_discussions_per_section), MAX_CHUNK_SIZE)
        ]
        result[section_id] = []
        for discussion_chunk in chunked_discussions:
            try:
                chunked_result = load_discussions(
                    request_client, section_id, discussion_chunk
                )
                result[section_id].extend(chunked_result)
            except Exception as ex:
                logger.exception(ex)
    return result
def generate_and_load_discussions ( request_client : RequestClient , discussions_per_assignment_count : int , assignments : Dict [ str , List [ Dict ] ] , ) -> Dict [ str , List [ Dict ] ] : assert ( discussions_per_assignment_count > 0 ) , "Number of discussions per assignment to generate must be greater than zero" discussion_per_section : Dict [ str , List [ Dict ] ] = generate_discussions ( discussions_per_assignment_count , assignments ) result : Dict [ str , List [ Dict ] ] = { } for section_id , total_discussions_per_section in discussion_per_section . items ( ) : MAX_CHUNK_SIZE = 50 chunked_discussions : List [ List [ Dict ] ] = [ total_discussions_per_section [ x : x + MAX_CHUNK_SIZE ] for x in range ( 0 , len ( total_discussions_per_section ) , MAX_CHUNK_SIZE ) ] result [ section_id ] = [ ] for discussion_chunk in chunked_discussions : try : chunked_result = load_discussions ( request_client , section_id , discussion_chunk ) result [ section_id ] . extend ( chunked_result ) except Exception as ex : logger . exception ( ex ) return result
Generate and load a number of discussions into the Schoology API.
Generate and load a number of discussions into the Schoology API .
"""
    Generate and load a number of discussions into the Schoology API.

    Parameters
    ----------
    request_client : RequestClient
        A RequestClient initialized for access to the Schoology API
    discussions_per_assignment_count : int
         The number of discussions per assignment to generate
    assignments: Dict[str, List[Dict]]
        A Dict of mappings from Schoology section id to a list of JSON-like
        assignment 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 discussion
         objects incorporating the response values from the Schoology API,
         e.g. resource ids and status from individual POSTing
    """
request_client
RequestClient
discussions_per_assignment_count
int
assignments
Dict[str, List[Dict]]