How to Re-send to LTI submissions with Python canvasapi?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
17 hours ago
My dears,
I am new with Canvas and LTI, so please be patient. I have a test course and some files already assignment. I can use the Python code to see those files.
# Import the Canvas class
from canvasapi import Canvas
# Canvas API URL
API_URL = "https://xxxxx.instructure.com/"
# Canvas API key
API_KEY = "xxxxxxx"
# Initialize a new Canvas object
canvas = Canvas(API_URL, API_KEY)
course = canvas.get_course(218)
assignments = course.get_assignments()
for assignment in assignments:
print('Assignment:',assignment, assignment.created_at) # dir(assignment)
submissions = assignment.get_submissions()
for one in submissions:
att_files = one.attachments
for file in att_files:
vv = vars(file)
print(f"{vv['filename']} -> {vv['content-type']}")
The output code:
Assignment: Test LOCAL Upload (565) 2024-12-30T13:52:48Z
adam.jurkiewicz-2025-01.pdf -> application/pdf
test+pdf.pdf -> application/pdf
Assignment: Plik - bad extension (566) 2025-01-02T11:47:17Z
test-mp3-2.pdf -> application/pdf
bad-extension-test.pdf -> application/pdf
Assignment: PVE - upload file (567) 2025-01-02T13:40:21Z
What I have to achive? Make submission of those files once again - by script, automaticly - beaceuse when I was submitting them, LTI was not working 100% good, and some of them were not sent to LTI - but I do not know Exactly which... there are hundreds of them... this is only example. I read the docs (https://canvasapi.readthedocs.io/en/stable/index.html) and dont know how to upload a new submussion, and how to re-send to LTI already uploaded one.
Maybe someone here will have some advice.... Thanks