Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9.3, 1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8
    • Fix Version/s: 1.9.9
    • Component/s: Roles / Access
    • Labels:
      None
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      24657

      Description

      When we setup assignments to different groups, we can view assignments . But if we choose a group, we got error message "No users were found with permissions to submit this assignment". I tracked the source code and found the problem is in the file accesslib.php in moodle lib directory. in function get_users_by_capability, because of our site settings, it went through the code
      if ($defaultroleinteresting) {
      $sql = "SELECT $fields
      FROM {$CFG->prefix}user u
      $uljoin
      $where
      ORDER BY $sort";

      return get_records_sql($sql, $limitfrom, $limitnum);
      }
      I displayed the sql statement, it shows
      SELECT u.id FROM mdl_user u WHERE u.deleted = 0 AND (ra.userid IN (SELECT userid FROM mdl_groups_members gm WHERE gm.groupid = 1)) ORDER BY u.lastaccess

      the problem is ra.userid in the statement, there is no table alias is ra, so I tracked down where it came from. It is still in the same function. the code is
      if ($groups) {
      if (is_array($groups))

      { $grouptest = 'gm.groupid IN (' . implode(',', $groups) . ')'; }

      else

      { $grouptest = 'gm.groupid = ' . $groups; }

      $grouptest = 'ra.userid IN (SELECT userid FROM ' .
      $CFG->prefix . 'groups_members gm WHERE ' . $grouptest . ')';

      if ($useviewallgroups)

      { $viewallgroupsusers = get_users_by_capability($context, 'moodle/site:accessallgroups', 'u.id, u.id', '', '', '', '', $exceptions); $wherecond['groups'] = '('. $grouptest . ' OR ra.userid IN (' . implode(',', array_keys($viewallgroupsusers)) . '))'; }

      else

      { $wherecond['groups'] = '(' . $grouptest .')'; }

      }

      if we change ra.userid to u.id in the code above, it will work. But I am not sure whether the changes will affect something else, so I report this bug and let the author of this file fix it.

      once it is fixed, please inform us and I can upload the fixed file to solve our problems.

      Thanks
      Ye

        Activity

        Hide
        Petr Škoda added a comment -

        This was already fixed in head, looking at the old 1.9.x code, thanks for the report

        Show
        Petr Škoda added a comment - This was already fixed in head, looking at the old 1.9.x code, thanks for the report
        Hide
        Ye Chen added a comment -

        Petr,
        My moodle version is 1.9.7+, it had the bugs. I just upgrade to 1.9.8, the problem is still there.

        Show
        Ye Chen added a comment - Petr, My moodle version is 1.9.7+, it had the bugs. I just upgrade to 1.9.8, the problem is still there.
        Hide
        Petr Škoda added a comment -

        Should be fixed now in cvs, I agree the u.id is the correct way,
        thanks for the report and solution.

        petr

        Show
        Petr Škoda added a comment - Should be fixed now in cvs, I agree the u.id is the correct way, thanks for the report and solution. petr
        Hide
        Murad Jamal added a comment -

        I followed this solution on moodle (1.9.4) but i did not work !!!
        how can i solve this issue please ?

        Show
        Murad Jamal added a comment - I followed this solution on moodle (1.9.4) but i did not work !!! how can i solve this issue please ?

          People

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

            Dates

            • Created:
              Updated:
              Resolved: