Site Administration > Courses > Add/edit courses > (any category)
The "Re-sort courses by name" button doesn't work in all categories. And when it doesn't work, I can't even sort the courses manually by using the up/down arrow icons.
They're in a sub-sub category.
Term
Subject
(unsorted list of courses)
We're running Moodle v1.8 and I've got Admin privs. And despite claims by a co-worker that Moodle Tracker is "All-Seeing and All Knowing", I can't find any mention of this bug.
Reports of similar experiences and/or pointers to the appropriate entry in Moodle Tracker warmly welcome.
Donna Hrynkiw
Kwantlen University College
Re: "Re-sort courses by name" button doesn't always work
Alas!
Donna
Kwantlen
We are experiecing the same problem for about 6 months. Altough we did some Moodle upgrades during this time (we now are using 1.9.5+) the problem still exists: in some categories the re-sort button and up-and-down-arrows don't work.
Jos Winkel
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
We're currently running 1.8.3 and won't be doing any upgrades before the end of next semester (Aug 2008, v1.9 is under consideration). Faculty get cranky if the site software changes mid-term...
However I believe we have a test instance of v1.9 around and will see if I can reproduce the problem there. If not, we'll just have to wait for the v1.9 upgrade to fix this.
Donna
Kwantlen
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
- Only one of our instances is affected. Unfortunately, it's on our biggest production instance.
- No error message, not even in php.log
- It works only in categories where the course names are mostly-alphabetical
- It fails in categories where the course names are in this format: "ENGL 1100: English Literature 1 (S10)". Are the digits or punctuation characters breaking the sort code?
I'm pretty sure this is the code in question (below, from courses/category.php), but I'm only six weeks into my PHP course and some of the constructs are still beyond me.
/// Resort the category if requested if ($resort and confirm_sesskey()) if ($courses = get_courses($category->id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) { // move it off the range $count = get_record_sql('SELECT MAX(sortorder) AS max, 1 FROM ' . $CFG->prefix . 'course WHERE category=' . $category->id); $count = $count->max + 100; begin_sql(); foreach ($courses as $course) { set_field('course', 'sortorder', $count, 'id', $course->id); $count++; } commit_sql(); fix_course_sortorder($category->id); } }
If there are any developers out there with a secret yen to be a bit of a PHP lecturer, now's your chance. What's going on in this code and what might cause it to fail?
[ETA: Apologies. I can't get the code indenting to stick in this editor.]
Donna
Kwantlen Polytechnic University
Re: "Re-sort courses by name" button doesn't always work
Any suggestions are welcome.
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
SELECT * from mdl_course
WHERE category = 1
ORDER BY fullname ASC;
It may also help to have some sample data to see what is not being sorted correctly. Could you provide me a list of course names in the order you believe they should appear and another list in the order that they are appearing?
Peace - Anthony
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Re: "Re-sort courses by name" button doesn't always work
Many subcategories can't be sorted (via sort-button or manually by arrows) anymore.
Any advice?
Rather than adding one-word replies to this discussion, please see Anthony's last post and comment, vote, and/or watch the issues mentioned.
Re: "Re-sort courses by name" button doesn't always work
We're still experiencing the same problem in Moodle v1.9.6
I'm still unable to find an appropriate entry in Moodle Tracker.
So I've created a new issue: http://tracker.moodle.org/browse/MDL-21011
Go add your comments there, and vote.
Re: "Re-sort courses by name" button doesn't always work
I also got this problem on a production server, and so created a script to reset the sortorder to 1000 on all course records, then run the function to alphabetically sort a category for every category ID. This worked fine on our test server, but on the production server it still broke - sortorder values were maxed out again.
Changing the initial value from 1000 to 10009999 worked though! After running with that value there was one course which had a sortorder value about 5000 less than that. The course wasn't visible through the GUI, and when I changed the URL to view it I just got a bunch of phantom objects. I think an incomplete course restore was what caused this.
Anyway, we're up and running now and can re-sort all our categories at once as a bonus. I've attached the script, which was based on the moodle 1.9.12 sort category function - it may need reworking for different moodle versions. I hope this is of some help to anyone still suffering from this problem. It would benefit from some security as anyone can run it as it stands, if they know the URL...
Jason