cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Member

Sorting quizzes alphabetically

Jump to solution

I know this has been asked before, but I didn't find the correct answer to fit the situation i am looking at.  Please to not refer me to the discussion previously posted in October - I read that one. The quizzes are supposedly sorted by due date  - but this is what I am looking at on my feed -  These are in neither alphabetical order or due date order . Only one is listed as closed, not sure what that is about either. The first 6 quizzes are not sorted the way the rest of the tests at the bottom are sorted.  The top 6 are by date, then the rest are actually sorted by alpha then date.  I would love to have control over this sorting.  Must be my type-A personality. : )

138246_pastedImage_0.png

1 Solution

Accepted Solutions
Highlighted
Navigator

kdonohue@wsdweb.org​,

Since you're not sure what the closed is about, you may not be familiar with the role of the different dates and that could cause the list of quizzes to seem to be in a random order.

There is a sort order specified in the source code. Starting at line 57 of the quizzes_controller.rb file is the definition used for the index, which is the list of quizzes. In lines 73-79, you have this:

quizzes = scope.sort_by do |quiz|

  due_date = quiz.assignment ? quiz.assignment.due_at : quiz.lock_at

  [

    due_date || CanvasSort::Last,

    Canvas::ICU.collation_key(quiz.title || CanvasSort::First)

  ]

end

In my limited understanding of the Ruby programming language, I take that to be something like this:

  1. If the quiz is an assignment, then look at the due_at date. For practice quizzes and surveys, look at the lock_at date. Carry that date into step 2.
  2. If the chosen date from step 1 is missing, then put the quiz at the bottom of the list
  3. As a secondary sort, for when the dates are the same, then sort by the title of the quiz (alphabetically) or if it doesn't have a title, then put it first.

For assignment quizzes, look at #1. For other types of quizzes, look at #2.

138266_pastedImage_2.png

There's another kink in the mix. On the page that actually displays the quizzes, there is a directive to repeat this process for each item group. Those appear to be Assignment Quizzes, Practice Quizzes, and Surveys in that order. Those appear on my Quizzes page in separate sections and are collapsible and the screen shot you gave was all one section, so it's probably not the issue with what you're experiencing.

There's another possible wrench here. There are a couple of other filters thrown in here that take place if you're a student or if you have differentiated assignments (you do). Those take place before the sort, so they shouldn't change the order things are presented in, but they might change what is presented.

So, here's what I would do if I were trying to diagnose this.

  1. Confirm we're talking about the same thing. I'm talking about the page that you get when you click on Quizzes in the navigation menu. If you're on a different page, different rules may apply. You didn't include the headings from the screen shot or the location (URL) so I'm assuming that these are all Assignment Quizzes. Assumption can get you into trouble sometimes.
  2. Try this on a different browser. There is some JavaScript that runs on the quizzes pages and sometimes it runs differently on Firefox than it does on Chrome.
  3. Did you include the entire screenshot or just a representative sample? The list of quizzes is loaded dynamically using AJAX calls and those use pagination. You had a lot of quizzes that were due in a short time period -- is it possible that you have more than 50 quizzes? If so, you may only be getting a list of some of the quizzes (I don't have enough quizzes to test this) until you scroll down. That may factor into it.
  4. Check the dates on the quizzes and make sure they're set. They look like it from the screen shot, but it doesn't hurt to double check.
  5. At some point, be willing to just let it go. I know you said you're type A, but sometimes you'll sleep a lot better if you just let it go. There have been some lengthy discussions about how Canvas sorts things that seem random and sometimes the answer is just "whatever order the database decides to return it in."

View solution in original post

5 Replies
Highlighted
Navigator

kdonohue@wsdweb.org​,

Since you're not sure what the closed is about, you may not be familiar with the role of the different dates and that could cause the list of quizzes to seem to be in a random order.

There is a sort order specified in the source code. Starting at line 57 of the quizzes_controller.rb file is the definition used for the index, which is the list of quizzes. In lines 73-79, you have this:

quizzes = scope.sort_by do |quiz|

  due_date = quiz.assignment ? quiz.assignment.due_at : quiz.lock_at

  [

    due_date || CanvasSort::Last,

    Canvas::ICU.collation_key(quiz.title || CanvasSort::First)

  ]

end

In my limited understanding of the Ruby programming language, I take that to be something like this:

  1. If the quiz is an assignment, then look at the due_at date. For practice quizzes and surveys, look at the lock_at date. Carry that date into step 2.
  2. If the chosen date from step 1 is missing, then put the quiz at the bottom of the list
  3. As a secondary sort, for when the dates are the same, then sort by the title of the quiz (alphabetically) or if it doesn't have a title, then put it first.

For assignment quizzes, look at #1. For other types of quizzes, look at #2.

138266_pastedImage_2.png

There's another kink in the mix. On the page that actually displays the quizzes, there is a directive to repeat this process for each item group. Those appear to be Assignment Quizzes, Practice Quizzes, and Surveys in that order. Those appear on my Quizzes page in separate sections and are collapsible and the screen shot you gave was all one section, so it's probably not the issue with what you're experiencing.

There's another possible wrench here. There are a couple of other filters thrown in here that take place if you're a student or if you have differentiated assignments (you do). Those take place before the sort, so they shouldn't change the order things are presented in, but they might change what is presented.

So, here's what I would do if I were trying to diagnose this.

  1. Confirm we're talking about the same thing. I'm talking about the page that you get when you click on Quizzes in the navigation menu. If you're on a different page, different rules may apply. You didn't include the headings from the screen shot or the location (URL) so I'm assuming that these are all Assignment Quizzes. Assumption can get you into trouble sometimes.
  2. Try this on a different browser. There is some JavaScript that runs on the quizzes pages and sometimes it runs differently on Firefox than it does on Chrome.
  3. Did you include the entire screenshot or just a representative sample? The list of quizzes is loaded dynamically using AJAX calls and those use pagination. You had a lot of quizzes that were due in a short time period -- is it possible that you have more than 50 quizzes? If so, you may only be getting a list of some of the quizzes (I don't have enough quizzes to test this) until you scroll down. That may factor into it.
  4. Check the dates on the quizzes and make sure they're set. They look like it from the screen shot, but it doesn't hurt to double check.
  5. At some point, be willing to just let it go. I know you said you're type A, but sometimes you'll sleep a lot better if you just let it go. There have been some lengthy discussions about how Canvas sorts things that seem random and sometimes the answer is just "whatever order the database decides to return it in."

View solution in original post

Highlighted
Community Member

I would have to concur with Kathleen. I use Chrome and mine don't appear to be sorted chronologically. I wish there was a way to sort alphabetically, but wasn't sure if was worth putting in the idea, since others have seemed fine with it. As James suggested, I let it go . . . but alphabetical sorting would definitely make it easier to find things. For now, I just use a search command if I can't quickly locate it.

Highlighted

kona@richland.edu​ said she hides the quizzes page from the students so they don't have to see it and that helps her not obsess over it.

Highlighted

Yes, thank you, james@richland.edu​for mentioning kona@richland.edu​'s approach. That's what I do too. In fact, I hide all of the navigation tabs except Home, Modules, and Grades from students. They can access everything they will need to complete the course from links in Modules. Having said that, I checked my Quizzes page (hidden from students) and noted that the quizzes are categorized by assignment group and display in precise due date order under their respective groups.

Highlighted

cwendt@plymouth.k12.in.us​,

There is a way to get them sorted, but it would take JavaScript programming to get it done. That means that it would be for everyone in an account/sub-account if you put it in the global custom JavaScript file or for a specific user if you put it into a GreaseMonkey script.

Then, it would be highly susceptible to breaking changes when Canvas goes through and changes something on the back-end. The best way to address the issue would be from the Canvas side of thing.

Their sort order is by date and asking them to change to alphabetically probably won't get the votes because students want to know what they have to do and when they have to do it and that's date order.

Now, if you do like me and name all your quizzes like "Chapter 1 Quiz 1", then they are both date order and alphabetical.

Top Kudoed Authors
Labels