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

Pagination in glossary category view not working when entries have multiple categories

XMLWordPrintable

    • MySQL
    • MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MDL-44560-master
    • Hide

      (Pull Branch will be provided soon)

      In file moodle/mod/glossary/sql.php after line 270: $count = $DB->count_records_sql("SELECT COUNT(DISTINCT(ge.id)) $sqlfrom $sqlwhere", $params))

      add the following lines:
      if ($tab == GLOSSARY_CATEGORY_VIEW && $hook == GLOSSARY_SHOW_ALL_CATEGORIES)

      { $count = $DB->count_records_sql("SELECT COUNT(ge.id) $sqlfrom $sqlwhere", $params); }

      This will result in a correct pagination bar for the category view.

      Show
      (Pull Branch will be provided soon) In file moodle/mod/glossary/sql.php after line 270: $count = $DB->count_records_sql("SELECT COUNT(DISTINCT(ge.id)) $sqlfrom $sqlwhere", $params)) add the following lines: if ($tab == GLOSSARY_CATEGORY_VIEW && $hook == GLOSSARY_SHOW_ALL_CATEGORIES) { $count = $DB->count_records_sql("SELECT COUNT(ge.id) $sqlfrom $sqlwhere", $params); } This will result in a correct pagination bar for the category view.
    • Hide
      1. Add a glossary module
      2. Edit the glossary settings
      3. Set "Entries shown per page" to a low number to make it easier to test
      4. In a glossary with a sufficient amount of entries, assign multiple categories to some entries.
      5. Then switch to view by category.
      6. The pagination bar offered in that view should have a sufficient amount of pages, to view all the items in all the categories.
      Show
      Add a glossary module Edit the glossary settings Set "Entries shown per page" to a low number to make it easier to test In a glossary with a sufficient amount of entries, assign multiple categories to some entries. Then switch to view by category. The pagination bar offered in that view should have a sufficient amount of pages, to view all the items in all the categories.

      There is a bug in the pagination behaviour of the glossary which occures if 2 conditions are met:

      • In a glossary the user selects the view by category
      • Several glossary entries belong to multiple categories

      In function glossary_get_paging_bar in glossary/lib.php the first variable $totalcount is equal to the (distinct) number of entries in the glossary. However, in category view, for each entry the association between entry and categories has to be taken into account, else the resulting pagination bar will not show the sufficient amount of pages.

      Reproduction steps:

      1. In a glossary with a sufficient amount of entries, assign multiple categories to some entries.
      2. Then switch to view by category. If there are enough entries belonging to multiple categories, you will see that the pagination bar offered in that view, does not have a sufficient amount of pages.

      The problem is that the number of pages that is needed to fit all entries is just based on the number of entries in the glossary. The correct computation also has to take the number of categories into account.

            johno John Okely
            sebabo Sebastian B
            Dan Poltawski Dan Poltawski
            Andrew Lyons Andrew Lyons
            Simey Lameze Simey Lameze
            Votes:
            13 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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