Replacing a File in all Courses
We have one file that's placed in all courses. I would like to find out the best way to replace this file. We can upload a new file and delete the old one, but the API calls to upload files only allows uploading the file to one course at a time and we have to provide all the course#s. Has anyone had to do this or something similar? Do we just batch the calls together? Thanks for all your suggestions.
@nschutz , you come up with such good questions. They make me want to drop whatever I'm doing and respond instead of doing other things I should do like going to bed.
I'm not trying to avoid the question, but I'm always in search of a more productive way to do things.
Is there a reason that you can't host it on another site and then link to or embed it? For example, several people have hosted documents on Google Drive and then used that as the source (either sharing it with anyone who has the link or publishing it). You can get a short URL if you are having people manually enter the link or you can write code that will go through and add pages that link to it. It may even be possible to add a navigation link to it.
When it needs updated, it only needs updated once and then all the courses automatically recognize the changes.
I don't have access to Canvas Commons, so I'm going out on a limb here. If you use Commons, then you can share the file with Commons and people can add it to their courses. If it needs updated, then you can update the file in Commons. My understanding is that the file is not automatically updated but that there is some action required on the user's part. There is a Commons API including an Import Latest Version of Resource into Canvas Course endpoint. The description says that it allows you to import the resource into a single or multiple Canvas courses, so you could update all the courses at once. If you didn't use Commons in the first place, it's not going to help here, but it may be worth considering in the future if you can't go with the hosted on another server thing.
Now to answer the question. If the file is stored at the course level, then yes, you would need to update it in every course that has it. That can be scripted. If you didn't save the file ID when you uploaded it (I wouldn't have), then I would write code that would download a list of courses, then iterate through them looking for the file within each course --- hopefully you named it the same thing in every case so you can use the search feature. The ID for the file is different in each course and the file-upload process is multipart, so this probably won't be a batch process (but then I will admit that I have never uploaded a file through the API other than a SIS import). Then upload/replace the existing file with the new version. Repeat for the next course.
Since this is something that I would probably not get working right the first time, I would definitely test it on the beta instance of Canvas and put in an extra check to see when the file was last updated. That way, if the process had an error midway, I could run it again without overwriting the file in courses that had already been updated.
James you are the best!! You gave me so much to think about ..... it's hard to wrap my brain around all of this. It's people like you that makes this community so valuable.
Well, the most sensible approach seems to be to have 1 file loaded outside of Canvas and then iterate thru each course and update the Assignment Description field. I will let you know how it turns out on our test site.
The Google Drive option is really good. It is so helpful to have one place to make changes and have those changes in effect populate everywhere. Google Drive also retains a revision history automatically, so prior versions of the Google Document can be accessed if necessary.