Moodle
  1. Moodle
  2. MDL-18328

Users Online Block not showing number of users online correctly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.4, 1.9.5
    • Fix Version/s: 1.9.7
    • Component/s: Blocks
    • Labels:
      None
    • Environment:
      Linux
    • Database:
      Any
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      blocks/online_users/block_online_users.php - line:119

      This SQL query would always return 1 (number of instances the first userid in the returned SQL)

      $usercount = count_records_sql("SELECT COUNT(u.id), u.id $from $where GROUP BY u.id");

      The patch counts the distinct userids to correctly return the real userc ount. :-

      $usercount = count_records_sql("SELECT COUNT(DISTINCT(u.id)) $from $where");

        Gliffy Diagrams

          Activity

          Hide
          Ashley Holman added a comment -

          +1 for this issue.

          When viewing the Online Users block, it always says 1 user is online:

          (last 5 minutes: 1)

          But actually there are several hundred users online.

          Tim's patch above fixes the count.

          Show
          Ashley Holman added a comment - +1 for this issue. When viewing the Online Users block, it always says 1 user is online: (last 5 minutes: 1) But actually there are several hundred users online. Tim's patch above fixes the count.
          Hide
          Séverin Terrier added a comment -

          In fact, for students (with no permission to see users list, see MDL-11984), the count seems OK

          But, as an admin, when >50 connected people, i only see (last 5 minutes: 1)

          Show
          Séverin Terrier added a comment - In fact, for students (with no permission to see users list, see MDL-11984 ), the count seems OK But, as an admin, when >50 connected people, i only see (last 5 minutes: 1)
          Hide
          Andrew Davis added a comment -

          Implemented in 1.9. This block in 2 has previously been altered in a way that will avoid this issue.

          Show
          Andrew Davis added a comment - Implemented in 1.9. This block in 2 has previously been altered in a way that will avoid this issue.
          Hide
          Martin Dougiamas added a comment -

          Andrew, don't forget to set the MOODLE_19_MERGED tag on the 1.9 branch even if a merge wasn't necessary.

          Show
          Martin Dougiamas added a comment - Andrew, don't forget to set the MOODLE_19_MERGED tag on the 1.9 branch even if a merge wasn't necessary.

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: