-
Bug
-
Resolution: Fixed
-
Minor
-
3.8.3, 3.9, 3.10, 4.4.5
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
- Log as an admin.
- Go to Site administration / Users / Permissions / Define roles
- Edit a Non-editing teacher role and check the User context in "Context types where this role may be assigned"
- Save changes and go to Site administration / Users / Accounts / Cohorts
- Add a new cohort.
- Go to Site administration / Users / Permissions / Assign user roles to cohort
- And select two users in "Select users to assign role "
- Select "Non-editing teacher" in Select role dropdown.
- And select the new cohort in Select cohort and click on Assign button.
- After that you could see a list of existing cohort role assignments.
- Click on "Role" column to sort the list.
- Expected result:
- 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.
- Current result:
- 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.