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

get_my_courses returns all courses with permission to access, not just enrolled courses


    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.0
    • 1.8, 1.9
    • Libraries
    • None

      The datalib function get_my_courses returns all courses that the current user has permission to view. For example, for an admin it returns every course on the site. This can cause performance and also interface problems.

      In the past for a quick fix I added a limit parameter which you can use to resolve performance problems (calling the function as-is for admin requires many thousand database queries if you have thousands of courses). However the real issue is that usually when this function is called, you actually want the enrolled courses i.e. courses which people have an actual role in.

      I would suggest making get_my_courses deprecated and creating two functions get_my_permitted_courses (which is the same as current, and is what get_my_courses calls) and get_my_enrolled_courses. get_my_enrolled_courses would basically restrict the list to include only those courses you have a specific role in (as well as having the course:view permission).

      (note, eloy asked me to file this bug! blame him!

            skodak Petr Skoda (Inactive)
            quen Sam Marshall
            12 Vote for this issue
            12 Start watching this issue


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