Viewing a list of responses in a feedback module, you click the date heading
Page reloads with the list of responses sorted by date
Page returns an error (when debugging is on) as follows:
Debug info: ERROR: column reference "timemodified" is ambiguous at character 226
SELECT DISTINCT u.id,u.picture,u.firstname,u.lastname,u.imagealt,u.email FROM mdl_user u, mdl_feedback_completed c
WHERE anonymous_response = $1 AND u.id = c.userid AND c.feedback = $2
ORDER BY timemodified ASC, lastname DESC LIMIT 20 OFFSET 0
0 => 2,
1 => '13',
• line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown
• line 229 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
• line 669 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
• line 875 of /mod/feedback/lib.php: call to pgsql_native_moodle_database->get_records_sql()
• line 167 of /mod/feedback/show_entries.php: call to feedback_get_complete_users()
Error is caused by timemodified being ambiguous (exists in both user and feedback_completed table), the field also needs to be in the select statement so it can be sorted on.
I've attached a patch that fixes this issue. Tested successfully.