canvasapi icon indicating copy to clipboard operation
canvasapi copied to clipboard

Support submitting multiple files to an assignment

Open theunkn0wn1 opened this issue 3 years ago • 1 comments

It is possible for instructors to create assignments that require students to upload multiple loose files for a submission, and this library doesn't provide a direct mechanism for facilitating this as a student.

As a practical example: the instructor in one of my current courses requires students to upload no less than 72 loose files per assignment.

The necessary machinery exists, through assignment.upload_to_submission

In my downstream project, I have produced the desired functionality in a downstream by calling Assignment.upload_to_submission in a loop over the input files, and passing the resulting list of file IDs to Assignment.submit in a dict.

Since this route requires working around the Assignment.submit's single file limitation, finding this pathway wasn't immediately obvious.

Desired interface

modify Assignment.submit to accept a list of files, and have a single function call for users.

assignment.submit(file=["/list", "./of", "~/files" ])

Alternatively, and this is the approach I took in the downstream, is to add a new method for bulk uploads

def submit_assignment(assignment: Assignment, files: List[Path]) -> Submission:
    # step four: upload all relevant files to the submission that doesn't exist yet and enumerate the
    # IDs you get back
    file_ids = mass_upload(assignment, files)

    # step 5: call `assignment.submit` and pass the file IDs acquired via step 4
    return assignment.submit(
        {"file_ids": file_ids, "submission_type": "online_upload"}
    )

theunkn0wn1 avatar Feb 02 '21 22:02 theunkn0wn1

I'd like to take a look at this issue. Looking at the code, it seems like adding a new method for mass uploading might be the way to go instead of modifying the signature of the existing function.

kailukaitisBrendan avatar Apr 12 '21 04:04 kailukaitisBrendan