src/schoology-extractor/data_generation/assignments.py
def generate_assignments(
    assignment_per_section_count: int, enrollments: Dict[str, List[Dict]]
) -> Dict[str, List[Dict]]:
    """
    Generate a list of Schoology assignments.

    Parameters
    ----------
    assignments_per_section : int
        The number of assignments per section to generate.
    enrollments: List[Dict]
        A list of JSON-like section 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 assignment objects
        in a form suitable for submission to the Schoology assignment create endpoint.
    """
    assert (
        assignment_per_section_count > 0
    ), "Number of assignments per section to generate must be greater than zero"

    logging.info(f"Generating {assignment_per_section_count} assignments per section")
    assignments: Dict[str, List[Dict]] = {}
    for section_id, enrollments_for_section in enrollments.items():
        assignments_per_section: List[Dict] = []
        for i in range(1, assignment_per_section_count + 1):
            if i % 100 == 0:
                logging.info(f"{i} assignments...")
            assignments_per_section.append(
                {
                    "title": fake.catch_phrase(),
                    "description": fake.sentence(),
                    "due": datetime.strftime(
                        fake.future_datetime(), "%Y-%m-%d %H:%M:%S"
                    ),
                    "type": "assignment",
                    "assignees": list(
                        map(
                            lambda enrollment: enrollment["uid"],
                            enrollments_for_section,
                        )
                    ),
                }
            )
        assignments[section_id] = assignments_per_section
    return assignments

    Generate a list of Schoology assignments.

    Parameters
    ----------
    assignments_per_section : int
        The number of assignments per section to generate.
    enrollments: List[Dict]
        A list of JSON-like section 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 assignment objects
        in a form suitable for submission to the Schoology assignment create endpoint.
    
Generate a list of Schoology assignments.
Parameters

assignments_per_section : int
The number of assignments per section to generate.
enrollments: List[Dict]
A list of JSON-like section 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 assignment objects
in a form suitable for submission to the Schoology assignment create endpoint.
Generate a list of Schoology assignments . Parameters assignments_per_section : int The number of assignments per section to generate . enrollments : List [ Dict ] A list of JSON - like section 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 assignment objects in a form suitable for submission to the Schoology assignment create endpoint .
def generate_assignments(
    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"
    logging.info(f"Generating {assignment_per_section_count} assignments per section")
    assignments: Dict[str, List[Dict]] = {}
    for section_id, enrollments_for_section in enrollments.items():
        assignments_per_section: List[Dict] = []
        for i in range(1, assignment_per_section_count + 1):
            if i % 100 == 0:
                logging.info(f"{i} assignments...")
            assignments_per_section.append(
                {
                    "title": fake.catch_phrase(),
                    "description": fake.sentence(),
                    "due": datetime.strftime(
                        fake.future_datetime(), "%Y-%m-%d %H:%M:%S"
                    ),
                    "type": "assignment",
                    "assignees": list(
                        map(
                            lambda enrollment: enrollment["uid"],
                            enrollments_for_section,
                        )
                    ),
                }
            )
        assignments[section_id] = assignments_per_section
    return assignments
def generate_assignments ( 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" logging . info ( f"Generating {assignment_per_section_count} assignments per section" ) assignments : Dict [ str , List [ Dict ] ] = { } for section_id , enrollments_for_section in enrollments . items ( ) : assignments_per_section : List [ Dict ] = [ ] for i in range ( 1 , assignment_per_section_count + 1 ) : if i % 100 == 0 : logging . info ( f"{i} assignments..." ) assignments_per_section . append ( { "title" : fake . catch_phrase ( ) , "description" : fake . sentence ( ) , "due" : datetime . strftime ( fake . future_datetime ( ) , "%Y-%m-%d %H:%M:%S" ) , "type" : "assignment" , "assignees" : list ( map ( lambda enrollment : enrollment [ "uid" ] , enrollments_for_section , ) ) , } ) assignments [ section_id ] = assignments_per_section return assignments
Generate a list of Schoology assignments.
Generate a list of Schoology assignments .
"""
    Generate a list of Schoology assignments.

    Parameters
    ----------
    assignments_per_section : int
        The number of assignments per section to generate.
    enrollments: List[Dict]
        A list of JSON-like section 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 assignment objects
        in a form suitable for submission to the Schoology assignment create endpoint.
    """
assignment_per_section_count
int
enrollments
Dict[str, List[Dict]]