Hello Instructure Community,
I was tasked with scripting our Canvas avatar uploads. After a good few weeks of work, I have a solution that I hope will assist others in doing the same.
Here is how it works:
The script queries your Canvas instance for users and looks for a local image file that matches their SIS ID.
- It looks for an image matching the user's primary SIS ID If a match isn't found, it grabs the user's secondary Canvas logins and looks for a match against any alternative SIS IDs attached to their account.
- Once a match is found, the script ensures the required 'Profile Pictures' folder exists in the user's Canvas files. The script will completely clear out any existing files in this folder and lock the user from changing their avatar once it has been set by the script.
- The avatar is then uploaded to that folder and assigns it as the user's active avatar.
- Once completed. the script generates a detailed .csv file in the same folder the script is run from to log information about the upload.
For the script to successfully map an image to a Canvas user, the local image file must be named using the user's SIS ID (i.e. [SIS_ID].[extention]).
The script is configured to look for .jpg files but if your photos are .png files, you will need to change the $SCRIPT:imageFileExtension variable.
Before you run this script, update the configuration variables at the very top of the file to match your environment and ensure your test in your test instance to ensure the script works for your needs.