Rescuing a Classroom Folder from a Shared Drive
The Backstory: If a Google Classroom Folder lands in a Shared Drive, All Hell Breaks Loose
Google Classroom organizes materials in Google Drive. The way it does so is somewhat mysterious, but for the most part it just works. Until it doesn’t, that is.
I accidentally moved a Classroom folder into a Shared Drive (long story, but someone had organized the folder deep in a nested tree of folders I was moving into a Shared Drive to try to smooth over a staffing transition). As of November 2021, Google doesn’t give you a warning if you move a Classroom folder into a Shared Drive and if you have the admin permissions to move other people’s file, it will just let you.
Once a folder has moved to a Shared Drive, the organization becomes the Owner of all the files. That means that Google Classroom breaks — teachers suddenly get errors when trying to post or update assignments; students can’t access or turn in their work; essentially, all hell breaks loose.
Google Support told me their “Advanced Team” would be on it and make it highest priority, but as of this writing I’m three days in with no help from Google, so I took matters into my own hands.
First Attempts
My first thought was to use the history API to see the history for the files in question. Each file in the folder should have a history that would show me who the owner was before I moved it to the Shared Drive and stripped the ownership, so all I’d have to do is look at each file, access the history, and roll the ownership back.
It’s possible that approach worked, but the DriveActivity API and the Admin Reports history API are both quite a nightmare to work with. What’s more, folders that had been moved in and out of a shared drive and in and out of Classroom had weird records, sometimes getting magically turned into shortcuts. It wasn’t at all clear that I could simply access the full history for each folder in the root folder I’d moved. When I did get history, each item in the activity history was a byzantine bit of JSON, and the permissions changes gave me people in the terms of weird person URLs that I would then have to resolve through another API if I wanted to get an actual email address.
The Solution
I’m already familiar with the Classroom API, having built a number of reporting tools for our school. What’s more, I already had some scripts with all the correct APIs enabled, which would let me save a huge chunk of time tracking down all the right developer consoles for adding permissions, so I decided to roll with it. Once I had the right idea, I had a solution in under an hour.
For this to work, you need:
- The IDs of each affected Google Classroom
- You need to be the owner of the files in question (i.e. you transferred them out of a shared drive and into your own drive)
- You need access to the Google Classroom API for the Classrooms in question.
In my case, I had access to the Shared Drive so I copied the files out to my own drive as my first step in rescuing the Classrooms and I’m the super-admin so I have access to all of the classrooms for our district.
I create all the Classrooms in the first place via script, so I have a spreadsheet which lists the ID for every classroom in the school. If you didn’t have that, you’d need to write a bit of code to figure out what the Classroom ID is for the Classrooms you’d hosed.