Canvas Roster Export

This is based on https://community.canvaslms.com/message/76979-export-student-email. Navigate to the People page, then open the console (also known as Developer Tools) of your browser. (Often found by hitting F12.) Then paste the script below:
1
2
3
4
5
6
7
8
var url = '/api/v1/courses/' + (typeof ENV.COURSE !== 'undefined' ? ENV.COURSE.id : ENV.course.id) + '/users';
$.getJSON(url, 'per_page=100&include[]=email', function(d) {
  console.log(d.map(function(e) {
    return [ 'sortable_name', 'email' ].map(function(f) {
      return e[f];
    }).join('\t');
  }).join('\n'));
});

Application to bulk-importing students to WeBWorK

After running the 8-line code above, the result will be name (Last name comma First name) followed by a tab followed by e-mail address. To import students to WeBWorK, you need to get a CSV file in WeBWorK's classlist file format. To do this,
  • Run the above, and copy/paste the result into a text editor (Notepad on Windows, TextEdit on Mac)
  • Search-replace every ", " with a tab. (To do this, first generate a tab in the text editor, and store this in the clipboard to paste on the find/replace screen.)
  • Store each student's default password in Column A of an Excel
  • Store student's last name in Column B of Excel
  • Store student's first name in Column C of Excel
  • Store student's e-mail address in Column H of Excel
  • Store student's user name for WeBWorK in Column I of Excel
  • Leave all other columns (D, E, F, G, J, K) blank.
  • Export this Excel as a CSV file.
  • Rename the CSV file to end in LST instead.
  • Upload the LST file to WeBWorK in the File Browser.
  • Import the LST file in the "Classlist Editor" section of WeBWorK.

Documentation/comments about the script above

Instead of the two fields (sortable name, email) you may want other fields. Most likely might be [ 'name', 'sortable_name', 'login_id', 'email' ] or for a full list, from the API documentation for user objects:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "id": 2, // The ID of the user.
  "name": "Sheldon Cooper", // The name of the user.
  "sortable_name": "Cooper, Sheldon", // The name of the user that is should be used for sorting groups of users, such as in the gradebook.
  "short_name": "Shelly",   // A short name the user has selected, for use in conversations or other less formal places through the site.
  "sis_user_id": "SHEL93921",   // The SIS ID associated with the user.  This field is only included if the user came from a SIS import and has permissions to view SIS information.
  "sis_import_id": 18,   // The id of the SIS import.  This field is only included if the user came from a SIS import and has permissions to manage SIS information.
  "integration_id": "ABC59802",   // The integration_id associated with the user.  This field is only included if the user came from a SIS import and has permissions to view SIS information.
  "login_id": "sheldon@caltech.example.com",   // The unique login id for the user.  This is what the user uses to log in to Canvas.
  "avatar_url": "https://en.gravatar.com/avatar/d8cb8c8cd40ddf0cd05241443a591868?s=80&r=g", // If avatars are enabled, this field will be included and contain a url to retrieve the user's avatar.
  "enrollments": null,  // Optional: This field can be requested with certain API calls, and will return a list of the users active enrollments. See the List enrollments API for more details about the format of these records.
  "email": "sheldon@caltech.example.com",  // Optional: This field can be requested with certain API calls, and will return the users primary email address.
  "locale": "tlh",  // Optional: This field can be requested with certain API calls, and will return the users locale in RFC 5646 format.
  "last_login": "2012-05-30T17:45:25Z",  // Optional: This field is only returned in certain API calls, and will return a timestamp representing the last time the user logged in to canvas.
  "time_zone": "America/Denver",  // Optional: This field is only returned in certain API calls, and will return the IANA time zone name of the user's preferred timezone.
  "bio": "I like the Muppets."  // Optional: The user's bio.
}

Powered by Jekyll, theme by Scott Emmons under Creative Commons Attribution. All of the code for this website can be viewed at GitHub.