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

Unknown column 'rolename' in 'order clause' in Assign user roles to cohort

XMLWordPrintable

      When you try to order the list of existing cohort role assignments by role column you get this error:

       

      Debug info:  Unknown column 'rolename' in 'order clause'
      SELECT uca.id, uca.cohortid, uca.userid, uca.roleid, c.name as cohortname, c.idnumber as cohortidnumber, c.contextid as cohortcontextid, c.visible as cohortvisible, c.description as cohortdescription, c.theme as cohorttheme, u.email, u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.firstname,u.lastname
       FROM mdl_tool_cohortroles uca
       JOIN mdl_user u ON u.id = uca.userid
       JOIN mdl_cohort c ON c.id = uca.cohortid ORDER BY rolename DESC, lastname ASC LIMIT 0, 50
      [array (
      )]
      Error code: dmlreadexception

       

      How to replicate

      1. Log as an admin.
      2. Go to Site administration / Users / Permissions / Define roles
      3. Edit a Non-editing teacher role and check the User context in "Context types where this role may be assigned"
      4. Save changes and go to Site administration / Users / Accounts / Cohorts
      5. Add a new cohort.
      6. Go to Site administration / Users / Permissions / Assign user roles to cohort
      7. And select two users in "Select users to assign role "
      8. Select "Non-editing teacher" in Select role dropdown.
      9. And select the new cohort in Select cohort and click on Assign button.
      10. After that you could see a list of existing cohort role assignments.
      11. Click on "Role" column to sort the list.
      12. Expected result:
        1. The list of existing cohort role assignments will be sorted or not having the possibility to order by role since it does not add value to the list of items.
      13. Current result:
        1. Error reading from database.

      Notice: 

      Checking the code, I think originally someone forgot to indicate that the role column was not sortable. This is because using table_sql you cannot sort by the role name as it is currently developed. It is not easy to sort through SQL a list by role name considering that role names are localized for a context. See role_get_names] function.

      So, maybe the fix should be don't let the user sort by role column like other parts in Moodle.

            pholden Paul Holden
            cescobedo Carlos Escobedo
            Carlos Escobedo Carlos Escobedo
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 51 minutes
                3h 51m

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