course sorting MDL-21011 "Re-sort courses by name" button eventually lead sortorder to hit column maximum value
This commit is contained in:
+2
-2
@@ -57,9 +57,9 @@
|
||||
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
|
||||
$count = get_record_sql('SELECT MIN(sortorder) AS min, 1
|
||||
FROM ' . $CFG->prefix . 'course WHERE category=' . $category->id);
|
||||
$count = $count->max + 100;
|
||||
$count = $count->min;
|
||||
begin_sql();
|
||||
foreach ($courses as $course) {
|
||||
set_field('course', 'sortorder', $count, 'id', $course->id);
|
||||
|
||||
+1
-1
@@ -1343,7 +1343,7 @@ function fix_course_sortorder($categoryid=0, $n=0, $safe=0, $depth=0, $path='')
|
||||
// $mustshift indicates whether the sequence must be shifted to
|
||||
// meet its range
|
||||
$mustshift = false;
|
||||
if ($min < $n+$tolerance || $min > $n+$tolerance+$catgap ) {
|
||||
if ($min < $n-$tolerance || $min > $n+$tolerance+$catgap ) {
|
||||
$mustshift = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user