Uploaded image for project: '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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.0
    • 1.7, 1.8
    • Roles / Access
    • None
    • MOODLE_17_STABLE, MOODLE_18_STABLE
    • MOODLE_20_STABLE

      "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.

            skodak Petr Skoda
            mchurch Mike Churchward
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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