Moodle
  1. Moodle
  2. MDL-10161

get_course_users and get_course_students don't work the same as they used to for site level

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7, 1.8
    • Fix Version/s: 2.0
    • Component/s: Roles / Access
    • Labels:
      None
    • Affected Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      3863

      Description

      "get_course_users" and "get_course_students" have been moved to "deprecatedlib", but continue to be used by a number of existing and new code. Unfortunately, when they were modified to use the new roles and capabilities functions they lost some of their existing function.

      The "get_course_students" previously would return all users who were considered students at the site level. This was dependent on the "$CFG->allusersaresitestudents" variable being set to true, and excluded users specifically assigned as teachers to the site course. Now, it returns users who have the "moodle/legacy:student" capability. This works if you manually assign users to the 'student' role at the site level. However, the "$CFG->allusersaresitestudents" has been replaced by the "user policies" setting "defaultuserroleid". If this is set to "student", "get_course_students" does not return all the users it should.

      Likewise, "get_course_users" previously used the old "get_course_students" and "get_course_teachers". Now, it gets all users with the "moodle/course:view" capability. This capability doesn't seem to get set for a user unless they are specifically given a role with that capability. Setting the "defaultuserroleid" does not do this.

      These functions need to be updated to handle the "defaultuserroleid" setting for the site course. And, whatever they are replaced with (after they are removed from "deprecatedlib") also needs to be able to handle this.

        Issue Links

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: