src/canvas-extractor/tests/data_generation/submissions.py
def generate_and_load_submissions(
    enrollments_by_course: Dict[Course, List[Enrollment]],
    assignments_by_course: Dict[Course, List[Assignment]],
) -> Dict[Assignment, List[Submission]]:
    """
    Generate and load a number of submissions into the Canvas API.

    Parameters
    ----------
    enrollments_by_course: Dict[Course, List[Enrollment]]
        A list of Canvas SDK Enrollment objects, grouped by Course SDK object
    assignments_by_course: Dict[Course, List[Assignment]]
        A list of Assignment SDK Section objects, grouped by Course SDK object

    Returns
    -------
    Dict[Assignment, List[Submission]]
        A list of Canvas SDK Submission objects representing the created submissions,
        grouped by Assignment SDK object
    """
    result: Dict[Assignment, List[Submission]] = {}

    for course, assignment_list in assignments_by_course.items():
        try:
            enrollments_in_course: List[Enrollment] = enrollments_by_course.get(course, [])
            for assignment in assignment_list:
                submissions = list(
                    map(
                        lambda enrollment: {
                            "submission_type": "online_url",
                            "url": fake.url(),
                            "user_id": enrollment.user_id,
                        },
                        enrollments_in_course,
                    )
                )

                submissions_list: List[Submission] = load_submissions(assignment, submissions)
                result[assignment] = submissions_list
        except Exception as ex:
            logger.exception(ex)

    return result

    Generate and load a number of submissions into the Canvas API.

    Parameters
    ----------
    enrollments_by_course: Dict[Course, List[Enrollment]]
        A list of Canvas SDK Enrollment objects, grouped by Course SDK object
    assignments_by_course: Dict[Course, List[Assignment]]
        A list of Assignment SDK Section objects, grouped by Course SDK object

    Returns
    -------
    Dict[Assignment, List[Submission]]
        A list of Canvas SDK Submission objects representing the created submissions,
        grouped by Assignment SDK object
    
Generate and load a number of submissions into the Canvas API.
Parameters

Dict[Course, List[Enrollment]]
A list of Canvas SDK Enrollment objects, grouped by Course SDK object
assignments_by_course: Dict[Course, List[Assignment]]
A list of Assignment SDK Section objects, grouped by Course SDK object

Returns

Dict[Assignment, List[Submission]]
A list of Canvas SDK Submission objects representing the created submissions,
grouped by Assignment SDK object
Generate and load a number of submissions into the Canvas API . Parameters Dict [ Course List [ Enrollment ]] A list of Canvas SDK Enrollment objects grouped by Course SDK object assignments_by_course : Dict [ Course List [ Assignment ]] A list of Assignment SDK Section objects grouped by Course SDK object Returns Dict [ Assignment List [ Submission ]] A list of Canvas SDK Submission objects representing the created submissions grouped by Assignment SDK object
def generate_and_load_submissions(
    enrollments_by_course: Dict[Course, List[Enrollment]],
    assignments_by_course: Dict[Course, List[Assignment]],
) -> Dict[Assignment, List[Submission]]:
    result: Dict[Assignment, List[Submission]] = {}
    for course, assignment_list in assignments_by_course.items():
        try:
            enrollments_in_course: List[Enrollment] = enrollments_by_course.get(course, [])
            for assignment in assignment_list:
                submissions = list(
                    map(
                        lambda enrollment: {
                            "submission_type": "online_url",
                            "url": fake.url(),
                            "user_id": enrollment.user_id,
                        },
                        enrollments_in_course,
                    )
                )
                submissions_list: List[Submission] = load_submissions(assignment, submissions)
                result[assignment] = submissions_list
        except Exception as ex:
            logger.exception(ex)
    return result
def generate_and_load_submissions ( enrollments_by_course : Dict [ Course , List [ Enrollment ] ] , assignments_by_course : Dict [ Course , List [ Assignment ] ] , ) -> Dict [ Assignment , List [ Submission ] ] : result : Dict [ Assignment , List [ Submission ] ] = { } for course , assignment_list in assignments_by_course . items ( ) : try : enrollments_in_course : List [ Enrollment ] = enrollments_by_course . get ( course , [ ] ) for assignment in assignment_list : submissions = list ( map ( lambda enrollment : { "submission_type" : "online_url" , "url" : fake . url ( ) , "user_id" : enrollment . user_id , } , enrollments_in_course , ) ) submissions_list : List [ Submission ] = load_submissions ( assignment , submissions ) result [ assignment ] = submissions_list except Exception as ex : logger . exception ( ex ) return result
Generate and load a number of submissions into the Canvas API.
Generate and load a number of submissions into the Canvas API .
"""
    Generate and load a number of submissions into the Canvas API.

    Parameters
    ----------
    enrollments_by_course: Dict[Course, List[Enrollment]]
        A list of Canvas SDK Enrollment objects, grouped by Course SDK object
    assignments_by_course: Dict[Course, List[Assignment]]
        A list of Assignment SDK Section objects, grouped by Course SDK object

    Returns
    -------
    Dict[Assignment, List[Submission]]
        A list of Canvas SDK Submission objects representing the created submissions,
        grouped by Assignment SDK object
    """
enrollments_by_course
Dict[Course, List[Enrollment]]
assignments_by_course
Dict[Course, List[Assignment]]