Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

course sorting MDL-21011 "Re-sort courses by name" button eventually …

…lead sortorder to hit column maximum value
  • Loading branch information...
commit 9c09c3b89a58adcdc4a060a4f72008d2d633fc7d 1 parent e45757a
Andrew Davis authored
Showing with 3 additions and 3 deletions.
  1. +2 −2 course/category.php
  2. +1 −1  lib/datalib.php
View
4 course/category.php
@@ -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);
View
2  lib/datalib.php
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.