Sort Courses List On Account Details Page Script

chadscott
Community Contributor
4
1109

I was asked to create a script to sort courses on the Account Details page, as it can be difficult to find a course for the most current term as we don't hide previous terms from the list. It adds two sort buttons – Sort by Name (which is the default sort) and Sort by Term.

 

To Install:

  1. Make sure you have Tampermonkey installed in Chrome

https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en

 

  1. Click on the link (or copy/paste) and open in Chrome.

https://github.com/sukotsuchido/CanvasUserScripts/raw/master/Canvas%20User%20Profile%20Course%20Sort...

  1. An Install page for Tampermonkey will open, click the “Install” button.

 

To Use:

  1. Navigate to any User Account Details Page
    • It will work equally well on student or teacher pages.
  2. Click “Sort by Term” to sort in descending order (most recent first), click again to sort in ascending order (oldest or manually created first)

303392_sortpic.jpg 

4 Comments
MattHanes
Community Champion

I didn't even know I wanted this until I saw this post. Well done! 

I added this line to the script so the page would show the whole enrollment list without having the inner scroll bar (I hate inner scroll bars!):

//expand enrollments window
document.getElementById('courses_list').childNodes[3].childNodes[1].style.maxHeight = "";
chadscott
Community Contributor

Wonderful! One of my colleagues asked for this and I just hadn't gotten to it yet. I'll add it! Thanks!

James
Community Champion

Matt, you may want to be careful using childNodes. Some browser include empty text nodes in childeNodes and others don't. Without checking extensively, I mostly see it's an IE issue (which I don't even pretend to support), so what you do will probably work in Firefox and Chrome, but I remember some of the stuff I was developing had issues until I switched to .children instead of .childNodes.

Since you're installing it as a user script, it probably won't matter, but someone might take this and make it available globally and I wanted to throw out a heads-up just in case it didn't work right. I always try to look for a different way, whenever possible, other than counting the number of items into something. I want to think it keeps things from breaking as quickly when/if Canvas changes something, but have no hard evidence of that.

MattHanes
Community Champion

I figured this was probably super janky and overly reliant on that page structure not changing. I even have a note in my tampermonkey script for that line that says "Will probably break one day".