Roster Sync Process for Files from KAMAR

This site processes files from KAMAR to use with Python for creating classes for all teachers with students enrolled for Google Classroom.
Video Walkthrough: https://youtu.be/svHTMnBCC9Y

Students:

Go to Students - Export and the feilds you need from KAMAR are: (can copy and paste)
ID Number
Surname  (Preferred)
First Name  (Preferred)
Student e-mail - School
Current Subjects, Line, Teacher (semi-colon)
Upload your students file:

Staff:

Go to Setup - Users - Print - Export Details.
Then Status: Present; Classification: All; Department: All
'Find' then 'Sort' then select 'Custom Export'
Save type needs to be CSV and can be called whatever.
Then 'Export'
Note: It is worth checking your staff emails are correct, as ours were missing a large number.

Upload your staff file:

Exclude these courses (comma separated list eg: FT,STUDY):

About

If you have issues please email me: contact@assay.co.nz
This site is not affilated with Google or KAMAR but think the things that these companies are doing is fantastic.
This site is provided curtosy of NCEA data analysis for schools.

General Instructions:

To run this, you'll need:

Step 1: Turn on the Classroom API

  1. Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
  2. On the Add credentials to your project page, click the Cancel button.
  3. At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
  4. Select the Credentials tab, click the Create credentials button and select OAuth client ID.
  5. Select the application type Other, enter the name "Python", and click the Create button.
  6. Click OK to dismiss the resulting dialog.
  7. Click the Download JSON button to the right of the client ID.
  8. Move this file to your working directory and rename it client_secret.json.
    To find the current working directory open a python console and type in
    import os
    print(os.getcwd())


Step 2: Install the Google Client Library

Run the following command to install the library using pip:
pip install --upgrade google-api-python-client
You run this command from a command window if you are using windows from the scripts folder inside the cwd folder eg:
C:\Users\jakew\AppData\Local\Programs\Python\Python36\Scripts>pip install --upgrade google-api-python-client
(You may also need to run: pip install --upgrade oauth2client)

Step 3: Set up the sample

Create a file named sync.py in your working directory and copy in the following code generated on the next page.

Step 4: Run the code

Run the code by double clicking on sync.py
  1. The first time this runs the code will attempt to open a new window or tab in your default browser. If this fails, copy the URL from the console and manually open it in your browser.

    If you are not already logged into your Google account, you will be prompted to log in. If you are logged into multiple Google accounts, you will be asked to select one account to use for the authorization.

  2. Click the Accept button.
  3. The code will proceed automatically, and you may close the window/tab.

It will output any errors as it goes, and will display "Finished All Courses" when done.
It saves your credientials locally on the file system, so you won't need to authenticate each time.
To re run the process the only part you need to do is reupload the files, copy the code from the block on the next page into the sync.py file and re run it.