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

Navigation block not displaying all categories

XMLWordPrintable

    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • master-48421
    • Hide

      1. Setup courses and categories as mentioned in the description (i.e. have a depth of atleast 3, with courses in multiple levels of the structure)
      2. Log in as admin
      3. On the home page look at the Navigation block -> Courses
      4. Expand the Courses tab fully, including all categories and subcategories.
      5. Ensure all of the courses and categories added in step 1 appear in the tree

      Do the same on a course/view.php page.
      This issue is not present on the course/management.php page.

      Dan added: Try more combinations of structures and try to break the navigation.

      Show
      1. Setup courses and categories as mentioned in the description (i.e. have a depth of atleast 3, with courses in multiple levels of the structure) 2. Log in as admin 3. On the home page look at the Navigation block -> Courses 4. Expand the Courses tab fully, including all categories and subcategories. 5. Ensure all of the courses and categories added in step 1 appear in the tree Do the same on a course/view.php page. This issue is not present on the course/management.php page. Dan added: Try more combinations of structures and try to break the navigation.

      When the system has multiple levels of subcategories, they are not all being loaded correctly into the navigation block under Courses or My courses. I discovered this with a structure like this:

      • Category 1
        • Subcategory 1a
          • Subsubcategory 1aA
          • courses
        • Subcategory 1b
          • Subsubcategory 1bB
          • courses
      • Category 2

      Where the block would load all of the courses and subcategories for 1a but none of the subcategories in 1b. The full category list and block display can be seen in the 2 screenshots attached.

      This appears to be caused by the parent category being loaded before the child categories are loaded in the block. I'm not sure how the load order for course categories is being set, so I am unable to provide more specific steps to replicate.

      The issue is being caused by a bug in the load_all_categories function in lib/navigationlib.php, specifically this section:
      else if (array_key_exists($categoryid, $this->addedcategories)) {
      // The category itself has been loaded already so we just need to ensure its subcategories
      // have been loaded
      list($sql, $params) = $DB->get_in_or_equal(array_keys($this->addedcategories), SQL_PARAMS_NAMED, 'parent', false);
      if ($showbasecategories) {
      // We need to include categories with parent = 0 as well
      $sqlwhere .= " AND (cc.parent = :categoryid OR cc.parent = 0) AND cc.parent {$sql}";
      } else {
      // All we need is categories that match the parent
      $sqlwhere .= " AND cc.parent = :categoryid AND cc.parent {$sql}";
      }
      $params['categoryid'] = $categoryid;
      }
      which generates an SQL query that contains "cc.parent = categoryid AND cc.parent NOT IN (..., categoryid, ...)"

            timprice Tim Price
            timprice Tim Price
            Jetha Chan Jetha Chan
            Dan Poltawski Dan Poltawski
            Frédéric Massart Frédéric Massart
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.