Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
CHANGELOG
README
If you're a system administrator of a Canvas LMS instance with a deep organization of sub accounts you have inevitably found yourself in one of Dante's 9 Circles of Hell, repetitively clicking Sub Accounts at each and every level as you drill down to where you need to go. Here at CCSD we have over 8,000 sub accounts, and yet this only affects 5 people. So we will share this to help anyone else who is trapped.
The JavaScript and CSS files here add a directory style recursive HTML menu to the Canvas global navigation admin tray...
Collapsed | Expanded | Search |
---|---|---|
Zero to little configuration is needed for admintray-subaccmenu.js, so I won't even bother explaining subacctray.cfg
Option 1
Option 2 (Quick Start)
Once loaded the script will initialize an API call (to /api/v1/accounts/self/sub_accounts) and loop through x/100, collecting every sub account in your instance, compile a recursive HTML unordered list and store it your browser's localStorage.
Depending on the number of your sub accounts and internet speed, this will take a moment, be patient for the first load, open the tray and wait for it to show up. This takes us about 45-60 seconds on production. You will see a loading indicator in the Admin Tray while it compiles.
There are some users (like Instructure Canvas Remote Admins) who may login to multiple Canvas Instances/institutions, so each menu will be stored in localStorage based on the uniqueness of x.instructure.com, including x.beta.instructure.com, x.test.instructure.com, and xyz.instructure.com.
For most users and institutions this will go mostly unnoticed unless you have different sub accounts between your Production, Test and Beta environments. I made this update to help those users it will affect. I also personally hate copying, pasting or replicating files just to change 1 line. This update allows 1 file to be hosted on a CDN like Amazon S3 and simply change the var show_results_parent value in admintray-subaccmenu.inc.js or leave it blank.
Therefore an already minified file has been provided in the repo.
Yup! As far as I know, the Canvas API does not allow sorting API calls alphabetically during pagination. The entire stack of sub accounts is sorted prior to building the menu.
Using JavaScript/jQuery to search within the stored HTML, preventing further API calls. You can search the entire sub account menu by name.
I don't know what else to call it, so here is an explanation.
Suppose your directory structure looks something like the following, where (#) is the depth of the account.
When we search for Science and get multiple sub accounts of 'Science', we can't identify which one we want to choose.
So if we map the results depth of 4 to it's parent depth at 2 (instead of 3, SIS Courses) we can get a result like:
And both are links to their respective account.
// one skip
show_results_parent = { 4:2 }
// expected result:
// George Washington HS > Science
// or multiple skips, must be unique
show_results_parent = { 4:2, 3:2 }
// expected results:
// (4:2) George Washington HS > Science
// (3:2) George Washington HS > SIS Courses
Note: If you don't define the skip, it will not display a parent
The ↻ button at the bottom right of the menu will clear the menu from localStorage and recompile it for the current Canvas instance. Use this when you or other admins have added or removed sub accounts.
As mentioned above, CCSD has 5 system admins, with 40,000 Employees and over 300,000 Students. Be kind to your users, use the snippet below to reduce the impact of your admin-only tools. This is included in the repo as admintray-subaccmenu.inc.js
if (ccsd.util.hasAnyRole('admin','root_admin')) {
// used for search results, result:parent, see documentation for more details
var show_results_parent = {}
// async load the sub account menu script
$.ajax({
url: 'https://cdn.rawgit.com/robert-carroll/ccsd-canvas/master/admintray-subaccmenu/admintray-subaccmenu.m...',
dataType: 'script',
cache: true,
data: {skipd: JSON.stringify(show_results_parent)}
})
}
At the suggestion and some coaching by @James , I have created a User Script version. This is useful for those admins that can't or don't want to install this script in their Canvas Theme/Global JavaScript. This script is identical to the global JavaScript file, except that the CSS will be added to the DOM by the script and has the various userscript requirements at the top for Tampermonkey.
If you are not a root admin of your Canvas Instance, you will need to set (1) sub account in the root setting. At this time you cannot add multiple sub accounts. I am planning to fix this.
Code repo here...
ccsd-canvas/admintray-subaccmenu at master · robert-carroll/ccsd-canvas · GitHub
Credits for Blog Post Banner Image
![]() | Chart of Hell Botticelli : de Laurent le Magnifique à Savonarole : catalogue de l'exposition à Paris, Musée du Luxembourg, du 1er octobre 2003 au 22 février 2004 et à Florence, Palazzo Strozzi, du 10 mars au 11 juillet 2004. Milan : Skira editore, Paris : Musée du Luxembourg, 2003. ISBN 9788884915641 {{PD-US}} |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Constantly curious about Canvas, customization and Community collaboration.
To participate in the Instructure Community, you need to sign up or log in:
Sign In