Affects Version/s: 1.9.2
Fix Version/s: None
This issue only occurs if you have made changes to the order of the categories (as otherwise they are all still 999).
When a course category is edited (even if no changes are made) its sortorder field is set to 999, ignoring any previous setting.
This moves the course category out of its intended position and if you have a large number of course categories, this is an inconvenience to go and re-order them.
I (hopefully) fixed the problem by changing two files
In editcategory_form.php I added a line between the hidden field declarations for 'id' and 'categoryadd', my line being:
$mform->addElement('hidden', 'sortorder', 999);
In editcategory.php I changed line 61 from:
$newcategory->sortorder = 999;
$newcategory->sortorder = $data->sortorder;
I tested the correction by creating a subcategory and checking the database tables. It had a sortorder of 999 as expected. I then moved it up in the category and checked the table again, and it had an appropriate sortorder value. I then edited and saved back the category and checked the tables again, it retained its appropriate sortorder value.