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

     Parameters
     ----------
     request_client : RequestClient
         A RequestClient initialized for access to the Schoology API
     assignment_per_section_count : int
         The number of assignments per section to generate
     enrollments: Dict[str, List[Dict]]
         A Dict of mappings from Schoology section id to a list of JSON-like
         enrollment objects

     Returns
     -------
    Dict[str, List[Dict]]
         A Dict of mappings from Schoology section id to a list of JSON-like assignment
         objects incorporating the response values from the Schoology API,
         e.g. resource ids and status from individual POSTing
    """
    assert (
        assignment_per_section_count > 0
    ), "Number of assignments per section to generate must be greater than zero"

    assignment_per_section: Dict[str, List[Dict]] = generate_assignments(
        assignment_per_section_count, enrollments
    )

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

        result[section_id] = []
        for assignment_chunk in chunked_assignments:
            try:
                chunked_result = load_assignments(
                    request_client, section_id, assignment_chunk
                )
                result[section_id].extend(chunked_result)
            except Exception as ex:
                logger.exception(ex)

    return result

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

     Parameters
     ----------
     request_client : RequestClient
         A RequestClient initialized for access to the Schoology API
     assignment_per_section_count : int
         The number of assignments per section to generate
     enrollments: Dict[str, List[Dict]]
         A Dict of mappings from Schoology section id to a list of JSON-like
         enrollment objects

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

request_client : RequestClient
A RequestClient initialized for access to the Schoology API
assignment_per_section_count : int
The number of assignments per section to generate
enrollments: Dict[str, List[Dict]]
A Dict of mappings from Schoology section id to a list of JSON-like
enrollment objects

Returns

Dict[str, List[Dict]]
A Dict of mappings from Schoology section id to a list of JSON-like assignment
objects incorporating the response values from the Schoology API,
e.g. resource ids and status from individual POSTing
Generate and load a number of assignments into the Schoology API . Parameters request_client : RequestClient A RequestClient initialized for access to the Schoology API assignment_per_section_count : int The number of assignments per section to generate enrollments : Dict [ str List [ Dict ]] A Dict of mappings from Schoology section id to a list of JSON - like enrollment objects Returns Dict [ str List [ Dict ]] A Dict of mappings from Schoology section id to a list of JSON - like assignment objects incorporating the response values from the Schoology API e . g . resource ids and status from individual POSTing
def generate_and_load_assignments(
    request_client: RequestClient,
    assignment_per_section_count: int,
    enrollments: Dict[str, List[Dict]],
) -> Dict[str, List[Dict]]:
    assert (
        assignment_per_section_count > 0
    ), "Number of assignments per section to generate must be greater than zero"
    assignment_per_section: Dict[str, List[Dict]] = generate_assignments(
        assignment_per_section_count, enrollments
    )
    result: Dict[str, List[Dict]] = {}
    for section_id, total_assignments_per_section in assignment_per_section.items():
        MAX_CHUNK_SIZE = 50
        chunked_assignments: List[List[Dict]] = [
            total_assignments_per_section[x : x + MAX_CHUNK_SIZE]
            for x in range(0, len(total_assignments_per_section), MAX_CHUNK_SIZE)
        ]
        result[section_id] = []
        for assignment_chunk in chunked_assignments:
            try:
                chunked_result = load_assignments(
                    request_client, section_id, assignment_chunk
                )
                result[section_id].extend(chunked_result)
            except Exception as ex:
                logger.exception(ex)
    return result
def generate_and_load_assignments ( request_client : RequestClient , assignment_per_section_count : int , enrollments : Dict [ str , List [ Dict ] ] , ) -> Dict [ str , List [ Dict ] ] : assert ( assignment_per_section_count > 0 ) , "Number of assignments per section to generate must be greater than zero" assignment_per_section : Dict [ str , List [ Dict ] ] = generate_assignments ( assignment_per_section_count , enrollments ) result : Dict [ str , List [ Dict ] ] = { } for section_id , total_assignments_per_section in assignment_per_section . items ( ) : MAX_CHUNK_SIZE = 50 chunked_assignments : List [ List [ Dict ] ] = [ total_assignments_per_section [ x : x + MAX_CHUNK_SIZE ] for x in range ( 0 , len ( total_assignments_per_section ) , MAX_CHUNK_SIZE ) ] result [ section_id ] = [ ] for assignment_chunk in chunked_assignments : try : chunked_result = load_assignments ( request_client , section_id , assignment_chunk ) result [ section_id ] . extend ( chunked_result ) except Exception as ex : logger . exception ( ex ) return result
Generate and load a number of assignments into the Schoology API.
Generate and load a number of assignments into the Schoology API .
"""
     Generate and load a number of assignments into the Schoology API.

     Parameters
     ----------
     request_client : RequestClient
         A RequestClient initialized for access to the Schoology API
     assignment_per_section_count : int
         The number of assignments per section to generate
     enrollments: Dict[str, List[Dict]]
         A Dict of mappings from Schoology section id to a list of JSON-like
         enrollment objects

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