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

get_role_users() with more than one role assigned to user

XMLWordPrintable

    • MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_28_STABLE
    • MDL-22309_master
    • Hide
      • All behat and unit tests should pass
      1. Turn debugging mode to full cream milk
      2. Go to Site administration ► Grades ► General settings
      3. Tick Non-editing teacher in gradebookroles so that both Non-editing teacher and Student are ticked
      4. Enrol a user as both a non-editing teacher and a student
      5. Test singleview report
        1. Try setting groups
        2. Try selecting grade items
        3. Try selecting users
        4. Try uptading grades
        5. You SHOULD NOT see any error
        6. You SHOULD NOT see duplicate users
      Show
      All behat and unit tests should pass Turn debugging mode to full cream milk Go to Site administration ► Grades ► General settings Tick Non-editing teacher in gradebookroles so that both Non-editing teacher and Student are ticked Enrol a user as both a non-editing teacher and a student Test singleview report Try setting groups Try selecting grade items Try selecting users Try uptading grades You SHOULD NOT see any error You SHOULD NOT see duplicate users
    • BACKEND Sprint 18

      When user has more than one role assigned, the query in get_role_users() gives more rows. Because $DB->get_records_sql() is used, it may lead to

      Did you remember to make the first column something unique in your call to get_records? Duplicate value xxx found in column 'id'.
      

      and only record per-user being returned. Using DISTINCT here would not work because every row has different role. Also, DISTINCT in combination with ORDER BY ir dangerous in PostgreSQL unless we make sure that ORDER BY fields are includes in SELECTed fields.

      Reproduce:
      =========
      1. Assign yourself both Teacher and Student in a course
      2. Visit the course settings page (with debugging on, of course)

            dmonllao David Monllaó
            mudrd8mz David Mudrák (@mudrd8mz)
            John Okely John Okely
            Sam Hemelryk Sam Hemelryk
            Damyon Wiese Damyon Wiese
            Votes:
            4 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

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