Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-15910

When a course category is edited, it is given a sortorder of 999 which moves it to the bottom of its group if the group had previously been sorted.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 1.9.2
    • Fix Version/s: None
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      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

      moodle/course/editcategory.php
      moodle/course/editcategory_form.php

      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;

      to read

      $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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              timhunt Tim Hunt
              Reporter:
              marcgale Marc Gale
              Tester:
              Nobody Nobody
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: