course sorting MDL-21011 "Re-sort courses by name" button eventually lead sortorder to hit column maximum value

This commit is contained in:
Andrew Davis
2010-01-08 07:07:55 +00:00
parent e45757ad63
commit 9c09c3b89a
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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
View File
@@ -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;
}