Courses will sometimes fail to be moved across categories if there are collisions in the sortorder field, due to a combined unique index.
With this fix, the 'category move' logic is aware of sortorder and will do The Right Thing(tm) putting the course at the beginning of the category: MIN(sortorder)-1 WHERE category=$destcategory->id .