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

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

    XMLWordPrintable

    Details

    • Database:
      MySQL
    • Testing Instructions:
      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.
    • Workaround:
      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.
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-44560-master

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                13 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  2/Feb/15